All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.jaad.aac.syntax.CCE Maven / Gradle / Ivy

There is a newer version: 0.2.5
Show newest version
package net.sourceforge.jaad.aac.syntax;

import net.sourceforge.jaad.aac.AACException;
import net.sourceforge.jaad.aac.DecoderConfig;
import net.sourceforge.jaad.aac.huffman.HCB;
import net.sourceforge.jaad.aac.huffman.Huffman;

/**
 * This class is part of JAAD ( jaadec.sourceforge.net ) that is distributed
 * under the Public Domain license. Code changes provided by the JCodec project
 * are distributed under FreeBSD license. 
 *
 * @author in-somnia
 */
class CCE extends Element implements SyntaxConstants {

	public static final int BEFORE_TNS = 0;
	public static final int AFTER_TNS = 1;
	public static final int AFTER_IMDCT = 2;
	private static final float[] CCE_SCALE = {
		1.09050773266525765921f,
		1.18920711500272106672f,
		1.4142135623730950488016887f,
		2f};
	private final ICStream ics;
	private float[] iqData;
	private int couplingPoint;
	private int coupledCount;
	private final boolean[] channelPair;
	private final int[] idSelect;
	private final int[] chSelect;
	/*[0] shared list of gains; [1] list of gains for right channel;
	 *[2] list of gains for left channel; [3] lists of gains for both channels
	 */
	private final float[][] gain;

	CCE(int frameLength) {
		super();
		ics = new ICStream(frameLength);
		channelPair = new boolean[8];
		idSelect = new int[8];
		chSelect = new int[8];
		gain = new float[16][120];
	}

	int getCouplingPoint() {
		return couplingPoint;
	}

	int getCoupledCount() {
		return coupledCount;
	}

	boolean isChannelPair(int index) {
		return channelPair[index];
	}

	int getIDSelect(int index) {
		return idSelect[index];
	}

	int getCHSelect(int index) {
		return chSelect[index];
	}

	void decode(IBitStream _in, DecoderConfig conf) throws AACException {
		couplingPoint = 2*_in.readBit();
		coupledCount = _in.readBits(3);
		int gainCount = 0;
		int i;
		for(i = 0; i<=coupledCount; i++) {
			gainCount++;
			channelPair[i] = _in.readBool();
			idSelect[i] = _in.readBits(4);
			if(channelPair[i]) {
				chSelect[i] = _in.readBits(2);
				if(chSelect[i]==3) gainCount++;
			}
			else chSelect[i] = 2;
		}
		couplingPoint += _in.readBit();
		couplingPoint |= (couplingPoint>>1);

		final boolean sign = _in.readBool();
		final double scale = CCE_SCALE[_in.readBits(2)];

		ics.decode(_in, false, conf);
		final ICSInfo info = ics.getInfo();
		final int windowGroupCount = info.getWindowGroupCount();
		final int maxSFB = info.getMaxSFB();
		//TODO:
		final int[][] sfbCB = {{}};//ics.getSectionData().getSfbCB();

		for(i = 0; i0) {
				cge = couplingPoint==2 ? 1 : _in.readBit();
				xg = cge==0 ? 0 : Huffman.decodeScaleFactor(_in)-60;
				gainCache = (float) Math.pow(scale, -xg);
			}
			if(couplingPoint==2) gain[i][0] = gainCache;
			else {
				int sfb;
				for(int g = 0; g>= 1;
									}
									gainCache = (float) (Math.pow(scale, -t)*s);
								}
							}
							gain[i][idx] = gainCache;
						}
					}
				}
			}
		}
	}

	void process() throws AACException {
		iqData = ics.getInvQuantData();
	}

	void applyIndependentCoupling(int index, float[] data) {
		final double g = gain[index][0];
		for(int i = 0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy