www in docker support

This commit is contained in:
MaddoScientisto 2026-04-22 18:41:37 +02:00
commit c227fce036
2145 changed files with 399596 additions and 58 deletions

View file

@ -0,0 +1,9 @@
package org.jcodec.codecs.aac;
public class AACConts {
public static final short[] AAC_CHANNEL_COUNT = new short[] { 0, 1, 2, 3, 4, 5, 6, 8 };
public static int[] AAC_SAMPLE_RATES = new int[] {
96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000,
11025, 8000, 7350 };
}

View file

@ -0,0 +1,59 @@
package org.jcodec.codecs.aac;
import java.io.IOException;
import java.nio.ByteBuffer;
import net.sourceforge.jaad.aac.AACException;
import net.sourceforge.jaad.aac.Decoder;
import net.sourceforge.jaad.aac.SampleBuffer;
import org.jcodec.common.AudioCodecMeta;
import org.jcodec.common.AudioDecoder;
import org.jcodec.common.AudioFormat;
import org.jcodec.common.UsedViaReflection;
import org.jcodec.common.io.NIOUtils;
import org.jcodec.common.logging.Logger;
import org.jcodec.common.model.AudioBuffer;
public class AACDecoder implements AudioDecoder {
private Decoder decoder;
public AACDecoder(ByteBuffer decoderSpecific) throws AACException {
if (decoderSpecific.remaining() >= 7) {
ADTSParser.Header header = ADTSParser.read(decoderSpecific);
if (header != null)
decoderSpecific = ADTSParser.adtsToStreamInfo(header);
Logger.info("Creating AAC decoder from ADTS header.");
}
this.decoder = new Decoder(NIOUtils.toArray(decoderSpecific));
}
public AudioBuffer decodeFrame(ByteBuffer frame, ByteBuffer dst) throws IOException {
ADTSParser.read(frame);
SampleBuffer sampleBuffer = new SampleBuffer();
this.decoder.decodeFrame(NIOUtils.toArray(frame), sampleBuffer);
if (sampleBuffer.isBigEndian())
sampleBuffer.setBigEndian(false);
return new AudioBuffer(ByteBuffer.wrap(sampleBuffer.getData()), toAudioFormat(sampleBuffer), 0);
}
private AudioFormat toAudioFormat(SampleBuffer sampleBuffer) {
return new AudioFormat(sampleBuffer.getSampleRate(), sampleBuffer.getBitsPerSample(),
sampleBuffer.getChannels(), true, sampleBuffer.isBigEndian());
}
public AudioCodecMeta getCodecMeta(ByteBuffer data) throws IOException {
SampleBuffer sampleBuffer = new SampleBuffer();
this.decoder.decodeFrame(NIOUtils.toArray(data), sampleBuffer);
sampleBuffer.setBigEndian(false);
return AudioCodecMeta.fromAudioFormat(toAudioFormat(sampleBuffer));
}
@UsedViaReflection
public static int probe(ByteBuffer data) {
if (data.remaining() < 7)
return 0;
ADTSParser.Header header = ADTSParser.read(data);
if (header != null)
return 100;
return 0;
}
}

View file

@ -0,0 +1,80 @@
package org.jcodec.codecs.aac;
import java.nio.ByteBuffer;
import org.jcodec.codecs.mpeg4.mp4.EsdsBox;
import org.jcodec.common.AudioFormat;
import org.jcodec.common.io.BitReader;
import org.jcodec.common.model.ChannelLabel;
import org.jcodec.containers.mp4.BoxUtil;
import org.jcodec.containers.mp4.boxes.Box;
import org.jcodec.containers.mp4.boxes.NodeBox;
import org.jcodec.containers.mp4.boxes.SampleEntry;
public class AACUtils {
public static class AACMetadata {
private AudioFormat format;
private ChannelLabel[] labels;
public AACMetadata(AudioFormat format, ChannelLabel[] labels) {
this.format = format;
this.labels = labels;
}
public AudioFormat getFormat() {
return this.format;
}
public ChannelLabel[] getLabels() {
return this.labels;
}
}
private static int getObjectType(BitReader reader) {
int objectType = reader.readNBit(5);
if (objectType == ObjectType.AOT_ESCAPE.ordinal())
objectType = 32 + reader.readNBit(6);
return objectType;
}
private static ChannelLabel[][] AAC_DEFAULT_CONFIGS = new ChannelLabel[][] { null, new ChannelLabel[] { ChannelLabel.MONO }, new ChannelLabel[] { ChannelLabel.STEREO_LEFT, ChannelLabel.STEREO_RIGHT }, new ChannelLabel[] { ChannelLabel.CENTER, ChannelLabel.FRONT_LEFT, ChannelLabel.FRONT_RIGHT }, new ChannelLabel[] { ChannelLabel.CENTER, ChannelLabel.FRONT_LEFT, ChannelLabel.FRONT_RIGHT, ChannelLabel.REAR_CENTER }, new ChannelLabel[] { ChannelLabel.CENTER, ChannelLabel.FRONT_LEFT, ChannelLabel.FRONT_RIGHT, ChannelLabel.REAR_LEFT, ChannelLabel.REAR_RIGHT }, new ChannelLabel[] { ChannelLabel.CENTER, ChannelLabel.FRONT_LEFT, ChannelLabel.FRONT_RIGHT, ChannelLabel.REAR_LEFT, ChannelLabel.REAR_RIGHT, ChannelLabel.LFE }, new ChannelLabel[] { ChannelLabel.CENTER, ChannelLabel.FRONT_LEFT, ChannelLabel.FRONT_RIGHT, ChannelLabel.SIDE_LEFT, ChannelLabel.SIDE_RIGHT, ChannelLabel.REAR_LEFT, ChannelLabel.REAR_RIGHT, ChannelLabel.LFE } };
public static AACMetadata parseAudioInfo(ByteBuffer privData) {
BitReader reader = BitReader.createBitReader(privData);
int objectType = getObjectType(reader);
int index = reader.readNBit(4);
int sampleRate = (index == 15) ? reader.readNBit(24) : AACConts.AAC_SAMPLE_RATES[index];
int channelConfig = reader.readNBit(4);
if (channelConfig == 0 || channelConfig >= AAC_DEFAULT_CONFIGS.length)
return null;
ChannelLabel[] channels = AAC_DEFAULT_CONFIGS[channelConfig];
return new AACMetadata(new AudioFormat(sampleRate, 16, channels.length, true, false), channels);
}
public static AACMetadata getMetadata(SampleEntry mp4a) {
if (!"mp4a".equals(mp4a.getFourcc()))
throw new IllegalArgumentException("Not mp4a sample entry");
ByteBuffer b = getCodecPrivate(mp4a);
if (b == null)
return null;
return parseAudioInfo(b);
}
public static ByteBuffer getCodecPrivate(SampleEntry mp4a) {
Box.LeafBox b = NodeBox.<Box.LeafBox>findFirst(mp4a, Box.LeafBox.class, "esds");
if (b == null)
b = NodeBox.<Box.LeafBox>findFirstPath(mp4a, Box.LeafBox.class, new String[] { null, "esds" });
if (b == null)
return null;
EsdsBox esds = BoxUtil.<EsdsBox>as(EsdsBox.class, b);
return esds.getStreamInfo();
}
public static ADTSParser.Header streamInfoToADTS(ByteBuffer si, boolean crcAbsent, int numAACFrames, int frameSize) {
BitReader rd = BitReader.createBitReader(si.duplicate());
int objectType = rd.readNBit(5);
int samplingIndex = rd.readNBit(4);
int chanConfig = rd.readNBit(4);
return new ADTSParser.Header(objectType, chanConfig, crcAbsent ? 1 : 0, numAACFrames, samplingIndex, 7 + frameSize);
}
}

View file

@ -0,0 +1,124 @@
package org.jcodec.codecs.aac;
import java.nio.ByteBuffer;
import org.jcodec.common.io.BitReader;
import org.jcodec.common.io.BitWriter;
public class ADTSParser {
public static ByteBuffer adtsToStreamInfo(Header hdr) {
ByteBuffer si = ByteBuffer.allocate(2);
BitWriter wr = new BitWriter(si);
wr.writeNBit(hdr.getObjectType(), 5);
wr.writeNBit(hdr.getSamplingIndex(), 4);
wr.writeNBit(hdr.getChanConfig(), 4);
wr.flush();
si.clear();
return si;
}
public static class Header {
private int objectType;
private int chanConfig;
private int crcAbsent;
private int numAACFrames;
private int samplingIndex;
private int samples;
private int size;
public Header(int object_type, int chanConfig, int crcAbsent, int numAACFrames, int samplingIndex, int size) {
this.objectType = object_type;
this.chanConfig = chanConfig;
this.crcAbsent = crcAbsent;
this.numAACFrames = numAACFrames;
this.samplingIndex = samplingIndex;
this.size = size;
}
public int getObjectType() {
return this.objectType;
}
public int getChanConfig() {
return this.chanConfig;
}
public int getCrcAbsent() {
return this.crcAbsent;
}
public int getNumAACFrames() {
return this.numAACFrames;
}
public int getSamplingIndex() {
return this.samplingIndex;
}
public int getSamples() {
return this.samples;
}
public int getSize() {
return this.size;
}
public int getSampleRate() {
return AACConts.AAC_SAMPLE_RATES[this.samplingIndex];
}
}
public static Header read(ByteBuffer data) {
ByteBuffer dup = data.duplicate();
BitReader br = BitReader.createBitReader(dup);
if (br.readNBit(12) != 4095)
return null;
int id = br.read1Bit();
int layer = br.readNBit(2);
int crc_abs = br.read1Bit();
int aot = br.readNBit(2);
int sr = br.readNBit(4);
int pb = br.read1Bit();
int ch = br.readNBit(3);
int origCopy = br.read1Bit();
int home = br.read1Bit();
int copy = br.read1Bit();
int copyStart = br.read1Bit();
int size = br.readNBit(13);
if (size < 7)
return null;
int buffer = br.readNBit(11);
int rdb = br.readNBit(2);
br.stop();
data.position(dup.position());
return new Header(aot + 1, ch, crc_abs, rdb + 1, sr, size);
}
public static ByteBuffer write(Header header, ByteBuffer buf) {
ByteBuffer data = buf.duplicate();
BitWriter br = new BitWriter(data);
br.writeNBit(4095, 12);
br.write1Bit(1);
br.writeNBit(0, 2);
br.write1Bit(header.getCrcAbsent());
br.writeNBit(header.getObjectType() - 1, 2);
br.writeNBit(header.getSamplingIndex(), 4);
br.write1Bit(0);
br.writeNBit(header.getChanConfig(), 3);
br.write1Bit(0);
br.write1Bit(0);
br.write1Bit(0);
br.write1Bit(0);
br.writeNBit(header.getSize(), 13);
br.writeNBit(0, 11);
br.writeNBit(header.getNumAACFrames() - 1, 2);
br.flush();
data.flip();
return data;
}
}

View file

@ -0,0 +1,14 @@
package org.jcodec.codecs.aac;
import org.jcodec.codecs.aac.blocks.Block;
import org.jcodec.common.io.BitReader;
public class BlockReader {
public Block nextBlock(BitReader bits) {
BlockType type = BlockType.values()[(int)(long)bits.readNBit(3)];
if (type == BlockType.TYPE_END)
return null;
int id = bits.readNBit(4);
return null;
}
}

View file

@ -0,0 +1,5 @@
package org.jcodec.codecs.aac;
public enum BlockType {
TYPE_SCE, TYPE_CPE, TYPE_CCE, TYPE_LFE, TYPE_DSE, TYPE_PCE, TYPE_FIL, TYPE_END;
}

View file

@ -0,0 +1,12 @@
package org.jcodec.codecs.aac;
import org.jcodec.codecs.aac.blocks.Block;
import org.jcodec.common.io.BitWriter;
public class BlockWriter {
public void nextBlock(BitWriter bits, Block block) {
bits.writeNBit(block.getType().ordinal(), 3);
if (block.getType() == BlockType.TYPE_END)
return;
}
}

View file

@ -0,0 +1,5 @@
package org.jcodec.codecs.aac;
public enum ChannelPosition {
AAC_CHANNEL_FRONT, AAC_CHANNEL_SIDE, AAC_CHANNEL_BACK, AAC_CHANNEL_LFE, AAC_CHANNEL_CC;
}

View file

@ -0,0 +1,5 @@
package org.jcodec.codecs.aac;
public enum ObjectType {
AOT_NULL, AOT_AAC_MAIN, AOT_AAC_LC, AOT_AAC_SSR, AOT_AAC_LTP, AOT_SBR, AOT_AAC_SCALABLE, AOT_TWINVQ, AOT_CELP, AOT_HVXC, CRAP1, CRAP2, AOT_TTSI, AOT_MAINSYNTH, AOT_WAVESYNTH, AOT_MIDI, AOT_SAFX, AOT_ER_AAC_LC, CRAP3, AOT_ER_AAC_LTP, AOT_ER_AAC_SCALABLE, AOT_ER_TWINVQ, AOT_ER_BSAC, AOT_ER_AAC_LD, AOT_ER_CELP, AOT_ER_HVXC, AOT_ER_HILN, AOT_ER_PARAM, AOT_SSC, AOT_PS, AOT_SURROUND, AOT_ESCAPE, AOT_L1, AOT_L2, AOT_L3, AOT_DST, AOT_ALS, AOT_SLS, AOT_SLS_NON_CORE, AOT_ER_AAC_ELD, AOT_SMR_SIMPLE, AOT_SMR_MAIN, AOT_USAC_NOSBR, AOT_SAOC, AOT_LD_SURROUND, AOT_USAC;
}

View file

@ -0,0 +1,5 @@
package org.jcodec.codecs.aac;
public enum Profile {
MAIN, LC, OTHER;
}

View file

@ -0,0 +1,532 @@
package org.jcodec.codecs.aac.blocks;
public class AACTab {
static int[] codes1 = new int[] {
2040, 497, 2045, 1013, 104, 1008, 2039, 492, 2037, 1009,
114, 1012, 116, 17, 118, 491, 108, 1014, 2044, 481,
2033, 496, 97, 502, 2034, 490, 2043, 498, 105, 493,
119, 23, 111, 486, 100, 485, 103, 21, 98, 18,
0, 20, 101, 22, 109, 489, 99, 484, 107, 19,
113, 483, 112, 499, 2046, 487, 2035, 495, 96, 494,
2032, 482, 2042, 1011, 106, 488, 117, 16, 115, 500,
110, 1015, 2038, 480, 2041, 1010, 102, 501, 2047, 503,
2036 };
static int[] bits1 = new int[] {
11, 9, 11, 10, 7, 10, 11, 9, 11, 10,
7, 10, 7, 5, 7, 9, 7, 10, 11, 9,
11, 9, 7, 9, 11, 9, 11, 9, 7, 9,
7, 5, 7, 9, 7, 9, 7, 5, 7, 5,
1, 5, 7, 5, 7, 9, 7, 9, 7, 5,
7, 9, 7, 9, 11, 9, 11, 9, 7, 9,
11, 9, 11, 10, 7, 9, 7, 5, 7, 9,
7, 10, 11, 9, 11, 10, 7, 9, 11, 9,
11 };
static int[] codes2 = new int[] {
499, 111, 509, 235, 35, 234, 503, 232, 506, 242,
45, 112, 32, 6, 43, 110, 40, 233, 505, 102,
248, 231, 27, 241, 500, 107, 501, 236, 42, 108,
44, 10, 39, 103, 26, 245, 36, 8, 31, 9,
0, 7, 29, 11, 48, 239, 28, 100, 30, 12,
41, 243, 47, 240, 508, 113, 498, 244, 33, 230,
247, 104, 504, 238, 34, 101, 49, 2, 38, 237,
37, 106, 507, 114, 510, 105, 46, 246, 511, 109,
502 };
static int[] bits2 = new int[] {
9, 7, 9, 8, 6, 8, 9, 8, 9, 8,
6, 7, 6, 5, 6, 7, 6, 8, 9, 7,
8, 8, 6, 8, 9, 7, 9, 8, 6, 7,
6, 5, 6, 7, 6, 8, 6, 5, 6, 5,
3, 5, 6, 5, 6, 8, 6, 7, 6, 5,
6, 8, 6, 8, 9, 7, 9, 8, 6, 8,
8, 7, 9, 8, 6, 7, 6, 4, 6, 8,
6, 7, 9, 7, 9, 7, 6, 8, 9, 7,
9 };
static int[] codes3 = new int[] {
0, 9, 239, 11, 25, 240, 491, 486, 1010, 10,
53, 495, 52, 55, 489, 493, 487, 1011, 494, 1005,
8186, 492, 498, 2041, 2040, 1016, 4088, 8, 56, 1014,
54, 117, 1009, 1003, 1004, 4084, 24, 118, 2036, 57,
116, 1007, 499, 500, 2038, 488, 1002, 8188, 242, 497,
4091, 1013, 2035, 4092, 238, 1015, 32766, 496, 2037, 32765,
8187, 16378, 65535, 241, 1008, 16380, 490, 1006, 16379, 4086,
4090, 32764, 2034, 4085, 65534, 1012, 2039, 32763, 4087, 4089,
32762 };
static int[] bits3 = new int[] {
1, 4, 8, 4, 5, 8, 9, 9, 10, 4,
6, 9, 6, 6, 9, 9, 9, 10, 9, 10,
13, 9, 9, 11, 11, 10, 12, 4, 6, 10,
6, 7, 10, 10, 10, 12, 5, 7, 11, 6,
7, 10, 9, 9, 11, 9, 10, 13, 8, 9,
12, 10, 11, 12, 8, 10, 15, 9, 11, 15,
13, 14, 16, 8, 10, 14, 9, 10, 14, 12,
12, 15, 11, 12, 16, 10, 11, 15, 12, 12,
15 };
static int[] codes4 = new int[] {
7, 22, 246, 24, 8, 239, 495, 243, 2040, 25,
23, 237, 21, 1, 226, 240, 112, 1008, 494, 241,
2042, 238, 228, 1010, 2038, 1007, 2045, 5, 20, 242,
9, 4, 229, 244, 232, 1012, 6, 2, 231, 3,
0, 107, 227, 105, 499, 235, 230, 1014, 110, 106,
500, 1004, 496, 1017, 245, 236, 2043, 234, 111, 1015,
2041, 1011, 4095, 233, 109, 1016, 108, 104, 501, 1006,
498, 2036, 2039, 1009, 4094, 1005, 497, 2037, 2046, 1013,
2044 };
static int[] bits4 = new int[] {
4, 5, 8, 5, 4, 8, 9, 8, 11, 5,
5, 8, 5, 4, 8, 8, 7, 10, 9, 8,
11, 8, 8, 10, 11, 10, 11, 4, 5, 8,
4, 4, 8, 8, 8, 10, 4, 4, 8, 4,
4, 7, 8, 7, 9, 8, 8, 10, 7, 7,
9, 10, 9, 10, 8, 8, 11, 8, 7, 10,
11, 10, 12, 8, 7, 10, 7, 7, 9, 10,
9, 11, 11, 10, 12, 10, 9, 11, 11, 10,
11 };
static int[] codes5 = new int[] {
8191, 4087, 2036, 2024, 1009, 2030, 2041, 4088, 8189, 4093,
2033, 1000, 488, 240, 492, 1006, 2034, 4090, 4084, 1007,
498, 232, 112, 236, 496, 1002, 2035, 2027, 491, 234,
26, 8, 25, 238, 495, 2029, 1008, 242, 115, 11,
0, 10, 113, 243, 2025, 2031, 494, 239, 24, 9,
27, 235, 489, 2028, 2038, 1003, 499, 237, 114, 233,
497, 1005, 2039, 4086, 2032, 1001, 493, 241, 490, 1004,
2040, 4089, 8188, 4092, 4085, 2026, 1011, 1010, 2037, 4091,
8190 };
static int[] bits5 = new int[] {
13, 12, 11, 11, 10, 11, 11, 12, 13, 12,
11, 10, 9, 8, 9, 10, 11, 12, 12, 10,
9, 8, 7, 8, 9, 10, 11, 11, 9, 8,
5, 4, 5, 8, 9, 11, 10, 8, 7, 4,
1, 4, 7, 8, 11, 11, 9, 8, 5, 4,
5, 8, 9, 11, 11, 10, 9, 8, 7, 8,
9, 10, 11, 12, 11, 10, 9, 8, 9, 10,
11, 12, 13, 12, 12, 11, 10, 10, 11, 12,
13 };
static int[] codes6 = new int[] {
2046, 1021, 497, 491, 500, 490, 496, 1020, 2045, 1014,
485, 234, 108, 113, 104, 240, 486, 1015, 499, 239,
50, 39, 40, 38, 49, 235, 503, 488, 111, 46,
8, 4, 6, 41, 107, 494, 495, 114, 45, 2,
0, 3, 47, 115, 506, 487, 110, 43, 7, 1,
5, 44, 109, 492, 505, 238, 48, 36, 42, 37,
51, 236, 498, 1016, 484, 237, 106, 112, 105, 116,
241, 1018, 2047, 1017, 502, 493, 504, 489, 501, 1019,
2044 };
static int[] bits6 = new int[] {
11, 10, 9, 9, 9, 9, 9, 10, 11, 10,
9, 8, 7, 7, 7, 8, 9, 10, 9, 8,
6, 6, 6, 6, 6, 8, 9, 9, 7, 6,
4, 4, 4, 6, 7, 9, 9, 7, 6, 4,
4, 4, 6, 7, 9, 9, 7, 6, 4, 4,
4, 6, 7, 9, 9, 8, 6, 6, 6, 6,
6, 8, 9, 10, 9, 8, 7, 7, 7, 7,
8, 10, 11, 10, 9, 9, 9, 9, 9, 10,
11 };
static int[] codes7 = new int[] {
0, 5, 55, 116, 242, 491, 1005, 2039, 4, 12,
53, 113, 236, 238, 494, 501, 54, 52, 114, 234,
241, 489, 499, 1013, 115, 112, 235, 240, 497, 496,
1004, 1018, 243, 237, 488, 495, 1007, 1009, 1017, 2043,
493, 239, 490, 498, 1011, 1016, 2041, 2044, 1006, 492,
500, 1012, 1015, 2040, 4093, 4094, 2038, 1008, 1010, 1014,
2042, 2045, 4092, 4095 };
static int[] bits7 = new int[] {
1, 3, 6, 7, 8, 9, 10, 11, 3, 4,
6, 7, 8, 8, 9, 9, 6, 6, 7, 8,
8, 9, 9, 10, 7, 7, 8, 8, 9, 9,
10, 10, 8, 8, 9, 9, 10, 10, 10, 11,
9, 8, 9, 9, 10, 10, 11, 11, 10, 9,
9, 10, 10, 11, 12, 12, 11, 10, 10, 10,
11, 11, 12, 12 };
static int[] codes8 = new int[] {
14, 5, 16, 48, 111, 241, 506, 1022, 3, 0,
4, 18, 44, 106, 117, 248, 15, 2, 6, 20,
46, 105, 114, 245, 47, 17, 19, 42, 50, 108,
236, 250, 113, 43, 45, 49, 109, 112, 242, 505,
239, 104, 51, 107, 110, 238, 249, 1020, 504, 116,
115, 237, 240, 246, 502, 509, 1021, 243, 244, 247,
503, 507, 508, 1023 };
static int[] bits8 = new int[] {
5, 4, 5, 6, 7, 8, 9, 10, 4, 3,
4, 5, 6, 7, 7, 8, 5, 4, 4, 5,
6, 7, 7, 8, 6, 5, 5, 6, 6, 7,
8, 8, 7, 6, 6, 6, 7, 7, 8, 9,
8, 7, 6, 7, 7, 8, 8, 10, 9, 7,
7, 8, 8, 8, 9, 9, 10, 8, 8, 8,
9, 9, 9, 10 };
static int[] codes9 = new int[] {
0, 5, 55, 231, 478, 974, 985, 1992, 1997, 4040,
4061, 8164, 8172, 4, 12, 53, 114, 234, 237, 482,
977, 979, 992, 2008, 4047, 4053, 54, 52, 113, 232,
236, 481, 975, 989, 987, 2000, 4039, 4052, 4068, 230,
112, 233, 477, 483, 978, 988, 1996, 1994, 2014, 4056,
4074, 8155, 479, 235, 476, 486, 981, 990, 1995, 2013,
2012, 4045, 4066, 4071, 8161, 976, 480, 484, 982, 1989,
2001, 2011, 4050, 2016, 4057, 4075, 8163, 8169, 1988, 485,
983, 1990, 1999, 2010, 4043, 4058, 4067, 4073, 8166, 8179,
8183, 2003, 984, 993, 2004, 2009, 4051, 4062, 8157, 8153,
8162, 8170, 8177, 8182, 2002, 980, 986, 1991, 2007, 2018,
4046, 4059, 8152, 8174, 16368, 8180, 16370, 2017, 991, 1993,
2006, 4042, 4048, 4069, 4070, 8171, 8175, 16371, 16372, 16373,
4064, 1998, 2005, 4038, 4049, 4065, 8160, 8168, 8176, 16369,
16376, 16374, 32764, 4072, 2015, 4041, 4055, 4060, 8156, 8159,
8173, 8181, 16377, 16379, 32765, 32766, 8167, 4044, 4054, 4063,
8158, 8154, 8165, 8178, 16378, 16375, 16380, 16381, 32767 };
static int[] bits9 = new int[] {
1, 3, 6, 8, 9, 10, 10, 11, 11, 12,
12, 13, 13, 3, 4, 6, 7, 8, 8, 9,
10, 10, 10, 11, 12, 12, 6, 6, 7, 8,
8, 9, 10, 10, 10, 11, 12, 12, 12, 8,
7, 8, 9, 9, 10, 10, 11, 11, 11, 12,
12, 13, 9, 8, 9, 9, 10, 10, 11, 11,
11, 12, 12, 12, 13, 10, 9, 9, 10, 11,
11, 11, 12, 11, 12, 12, 13, 13, 11, 9,
10, 11, 11, 11, 12, 12, 12, 12, 13, 13,
13, 11, 10, 10, 11, 11, 12, 12, 13, 13,
13, 13, 13, 13, 11, 10, 10, 11, 11, 11,
12, 12, 13, 13, 14, 13, 14, 11, 10, 11,
11, 12, 12, 12, 12, 13, 13, 14, 14, 14,
12, 11, 11, 12, 12, 12, 13, 13, 13, 14,
14, 14, 15, 12, 11, 12, 12, 12, 13, 13,
13, 13, 14, 14, 15, 15, 13, 12, 12, 12,
13, 13, 13, 13, 14, 14, 14, 14, 15 };
static int[] codes10 = new int[] {
34, 8, 29, 38, 95, 211, 463, 976, 983, 1005,
2032, 2038, 4093, 7, 0, 1, 9, 32, 84, 96,
213, 220, 468, 973, 990, 2023, 28, 2, 6, 12,
30, 40, 91, 205, 217, 462, 476, 985, 1009, 37,
11, 10, 13, 36, 87, 97, 204, 221, 460, 478,
979, 999, 93, 33, 31, 35, 39, 89, 100, 216,
223, 466, 482, 989, 1006, 209, 85, 41, 86, 88,
98, 206, 224, 226, 474, 980, 995, 2027, 457, 94,
90, 92, 99, 202, 218, 455, 458, 480, 987, 1000,
2028, 483, 210, 203, 208, 215, 219, 454, 469, 472,
970, 986, 2026, 2033, 481, 212, 207, 214, 222, 225,
464, 470, 977, 981, 1010, 2030, 2043, 1001, 461, 456,
459, 465, 471, 479, 975, 992, 1007, 2022, 2040, 4090,
1003, 477, 467, 473, 475, 978, 972, 988, 1002, 2029,
2035, 2041, 4089, 2034, 974, 484, 971, 984, 982, 994,
997, 2024, 2036, 2037, 2039, 4091, 2042, 1004, 991, 993,
996, 998, 1008, 2025, 2031, 4088, 4094, 4092, 4095 };
static int[] bits10 = new int[] {
6, 5, 6, 6, 7, 8, 9, 10, 10, 10,
11, 11, 12, 5, 4, 4, 5, 6, 7, 7,
8, 8, 9, 10, 10, 11, 6, 4, 5, 5,
6, 6, 7, 8, 8, 9, 9, 10, 10, 6,
5, 5, 5, 6, 7, 7, 8, 8, 9, 9,
10, 10, 7, 6, 6, 6, 6, 7, 7, 8,
8, 9, 9, 10, 10, 8, 7, 6, 7, 7,
7, 8, 8, 8, 9, 10, 10, 11, 9, 7,
7, 7, 7, 8, 8, 9, 9, 9, 10, 10,
11, 9, 8, 8, 8, 8, 8, 9, 9, 9,
10, 10, 11, 11, 9, 8, 8, 8, 8, 8,
9, 9, 10, 10, 10, 11, 11, 10, 9, 9,
9, 9, 9, 9, 10, 10, 10, 11, 11, 12,
10, 9, 9, 9, 9, 10, 10, 10, 10, 11,
11, 11, 12, 11, 10, 9, 10, 10, 10, 10,
10, 11, 11, 11, 11, 12, 11, 10, 10, 10,
10, 10, 10, 11, 11, 12, 12, 12, 12 };
static int[] codes11 = new int[] {
0, 6, 25, 61, 156, 198, 423, 912, 962, 991,
2022, 2035, 4091, 2028, 4090, 4094, 910, 5, 1, 8,
20, 55, 66, 146, 175, 401, 421, 437, 926, 960,
930, 973, 2006, 174, 23, 7, 9, 24, 57, 64,
142, 163, 184, 409, 428, 449, 945, 918, 958, 970,
157, 60, 21, 22, 26, 59, 68, 145, 165, 190,
406, 430, 441, 929, 913, 933, 981, 148, 154, 54,
56, 58, 65, 140, 155, 176, 195, 414, 427, 444,
927, 911, 937, 975, 147, 191, 62, 63, 67, 69,
158, 167, 185, 404, 418, 442, 451, 934, 935, 955,
980, 159, 416, 143, 141, 144, 152, 166, 182, 196,
415, 431, 447, 921, 959, 948, 969, 999, 168, 438,
171, 164, 170, 178, 194, 197, 408, 420, 440, 908,
932, 964, 966, 989, 1000, 173, 943, 402, 189, 188,
398, 407, 410, 419, 433, 909, 920, 951, 979, 977,
987, 2013, 180, 990, 425, 411, 412, 417, 426, 429,
435, 907, 946, 952, 974, 993, 992, 2002, 2021, 183,
2019, 443, 424, 422, 432, 434, 439, 923, 922, 954,
949, 982, 2007, 996, 2008, 2026, 186, 2024, 928, 445,
436, 906, 452, 914, 938, 944, 956, 983, 2004, 2012,
2011, 2005, 2032, 193, 2043, 968, 931, 917, 925, 940,
942, 965, 984, 994, 998, 2020, 2023, 2016, 2025, 2039,
400, 2034, 915, 446, 448, 916, 919, 941, 963, 961,
978, 2010, 2009, 2015, 2027, 2036, 2042, 405, 2040, 957,
924, 939, 936, 947, 953, 976, 995, 997, 2018, 2014,
2029, 2033, 2041, 2044, 403, 4093, 988, 950, 967, 972,
971, 985, 986, 2003, 2017, 2030, 2031, 2037, 2038, 4092,
4095, 413, 450, 181, 161, 150, 151, 149, 153, 160,
162, 172, 169, 177, 179, 187, 192, 399, 4 };
static int[] bits11 = new int[] {
4, 5, 6, 7, 8, 8, 9, 10, 10, 10,
11, 11, 12, 11, 12, 12, 10, 5, 4, 5,
6, 7, 7, 8, 8, 9, 9, 9, 10, 10,
10, 10, 11, 8, 6, 5, 5, 6, 7, 7,
8, 8, 8, 9, 9, 9, 10, 10, 10, 10,
8, 7, 6, 6, 6, 7, 7, 8, 8, 8,
9, 9, 9, 10, 10, 10, 10, 8, 8, 7,
7, 7, 7, 8, 8, 8, 8, 9, 9, 9,
10, 10, 10, 10, 8, 8, 7, 7, 7, 7,
8, 8, 8, 9, 9, 9, 9, 10, 10, 10,
10, 8, 9, 8, 8, 8, 8, 8, 8, 8,
9, 9, 9, 10, 10, 10, 10, 10, 8, 9,
8, 8, 8, 8, 8, 8, 9, 9, 9, 10,
10, 10, 10, 10, 10, 8, 10, 9, 8, 8,
9, 9, 9, 9, 9, 10, 10, 10, 10, 10,
10, 11, 8, 10, 9, 9, 9, 9, 9, 9,
9, 10, 10, 10, 10, 10, 10, 11, 11, 8,
11, 9, 9, 9, 9, 9, 9, 10, 10, 10,
10, 10, 11, 10, 11, 11, 8, 11, 10, 9,
9, 10, 9, 10, 10, 10, 10, 10, 11, 11,
11, 11, 11, 8, 11, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 11, 11, 11, 11, 11,
9, 11, 10, 9, 9, 10, 10, 10, 10, 10,
10, 11, 11, 11, 11, 11, 11, 9, 11, 10,
10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
11, 11, 11, 11, 9, 12, 10, 10, 10, 10,
10, 10, 10, 11, 11, 11, 11, 11, 11, 12,
12, 9, 9, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 9, 5 };
static int[] ff_aac_scalefactor_code = new int[] {
262120, 262118, 262119, 262117, 524277, 524273, 524269, 524278, 524270, 524271,
524272, 524284, 524285, 524287, 524286, 524279, 524280, 524283, 524281, 262116,
524282, 262115, 131055, 131056, 65525, 131054, 65522, 65523, 65524, 65521,
32758, 32759, 16377, 16373, 16375, 16371, 16374, 16370, 8183, 8181,
4089, 4087, 4086, 2041, 4084, 2040, 1017, 1015, 1013, 504,
503, 250, 248, 246, 121, 58, 56, 26, 11, 4,
0, 10, 12, 27, 57, 59, 120, 122, 247, 249,
502, 505, 1012, 1014, 1016, 2037, 2036, 2038, 2039, 4085,
4088, 8180, 8182, 8184, 16376, 16372, 65520, 32756, 65526, 32757,
262114, 524249, 524250, 524251, 524252, 524253, 524254, 524248, 524242, 524243,
524244, 524245, 524246, 524274, 524255, 524263, 524264, 524265, 524266, 524267,
524262, 524256, 524257, 524258, 524259, 524260, 524261, 524247, 524268, 524276,
524275 };
static int[] ff_aac_scalefactor_bits = new int[] {
18, 18, 18, 18, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 18,
19, 18, 17, 17, 16, 17, 16, 16, 16, 16,
15, 15, 14, 14, 14, 14, 14, 14, 13, 13,
12, 12, 12, 11, 12, 11, 10, 10, 10, 9,
9, 8, 8, 8, 7, 6, 6, 5, 4, 3,
1, 4, 4, 5, 6, 6, 7, 7, 8, 8,
9, 9, 10, 10, 10, 11, 11, 11, 11, 12,
12, 13, 13, 13, 14, 14, 16, 15, 16, 15,
18, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19 };
static int[] maxSfbTab = new int[] {
33, 33, 38, 40, 40, 40, 41, 41, 37, 37,
37, 34, 34 };
static float[] ltpCoefTab = new float[] { 0.570829F, 0.696616F, 0.813004F, 0.911304F, 0.9849F, 1.067894F, 1.194601F, 1.369533F };
static final int[] ff_aac_num_swb_1024 = new int[] {
41, 41, 47, 49, 49, 51, 47, 47, 43, 43,
43, 40, 40 };
static final int[] ff_aac_num_swb_128 = new int[] {
12, 12, 12, 14, 14, 14, 15, 15, 15, 15,
15, 15, 15 };
static final int[] swb_offset_1024_96 = new int[] {
0, 4, 8, 12, 16, 20, 24, 28, 32, 36,
40, 44, 48, 52, 56, 64, 72, 80, 88, 96,
108, 120, 132, 144, 156, 172, 188, 212, 240, 276,
320, 384, 448, 512, 576, 640, 704, 768, 832, 896,
960, 1024 };
static final int[] swb_offset_128_96 = new int[] {
0, 4, 8, 12, 16, 20, 24, 32, 40, 48,
64, 92, 128 };
static final int[] swb_offset_1024_64 = new int[] {
0, 4, 8, 12, 16, 20, 24, 28, 32, 36,
40, 44, 48, 52, 56, 64, 72, 80, 88, 100,
112, 124, 140, 156, 172, 192, 216, 240, 268, 304,
344, 384, 424, 464, 504, 544, 584, 624, 664, 704,
744, 784, 824, 864, 904, 944, 984, 1024 };
static final int[] swb_offset_1024_48 = new int[] {
0, 4, 8, 12, 16, 20, 24, 28, 32, 36,
40, 48, 56, 64, 72, 80, 88, 96, 108, 120,
132, 144, 160, 176, 196, 216, 240, 264, 292, 320,
352, 384, 416, 448, 480, 512, 544, 576, 608, 640,
672, 704, 736, 768, 800, 832, 864, 896, 928, 1024 };
static final int[] swb_offset_128_48 = new int[] {
0, 4, 8, 12, 16, 20, 28, 36, 44, 56,
68, 80, 96, 112, 128 };
static final int[] swb_offset_1024_32 = new int[] {
0, 4, 8, 12, 16, 20, 24, 28, 32, 36,
40, 48, 56, 64, 72, 80, 88, 96, 108, 120,
132, 144, 160, 176, 196, 216, 240, 264, 292, 320,
352, 384, 416, 448, 480, 512, 544, 576, 608, 640,
672, 704, 736, 768, 800, 832, 864, 896, 928, 960,
992, 1024 };
static final int[] swb_offset_1024_24 = new int[] {
0, 4, 8, 12, 16, 20, 24, 28, 32, 36,
40, 44, 52, 60, 68, 76, 84, 92, 100, 108,
116, 124, 136, 148, 160, 172, 188, 204, 220, 240,
260, 284, 308, 336, 364, 396, 432, 468, 508, 552,
600, 652, 704, 768, 832, 896, 960, 1024 };
static final int[] swb_offset_128_24 = new int[] {
0, 4, 8, 12, 16, 20, 24, 28, 36, 44,
52, 64, 76, 92, 108, 128 };
static final int[] swb_offset_1024_16 = new int[] {
0, 8, 16, 24, 32, 40, 48, 56, 64, 72,
80, 88, 100, 112, 124, 136, 148, 160, 172, 184,
196, 212, 228, 244, 260, 280, 300, 320, 344, 368,
396, 424, 456, 492, 532, 572, 616, 664, 716, 772,
832, 896, 960, 1024 };
static final int[] swb_offset_128_16 = new int[] {
0, 4, 8, 12, 16, 20, 24, 28, 32, 40,
48, 60, 72, 88, 108, 128 };
static final int[] swb_offset_1024_8 = new int[] {
0, 12, 24, 36, 48, 60, 72, 84, 96, 108,
120, 132, 144, 156, 172, 188, 204, 220, 236, 252,
268, 288, 308, 328, 348, 372, 396, 420, 448, 476,
508, 544, 580, 620, 664, 712, 764, 820, 880, 944,
1024 };
static final int[] swb_offset_128_8 = new int[] {
0, 4, 8, 12, 16, 20, 24, 28, 36, 44,
52, 60, 72, 88, 108, 128 };
static final int[][] ff_swb_offset_1024 = new int[][] {
swb_offset_1024_96, swb_offset_1024_96, swb_offset_1024_64, swb_offset_1024_48, swb_offset_1024_48, swb_offset_1024_32, swb_offset_1024_24, swb_offset_1024_24, swb_offset_1024_16, swb_offset_1024_16,
swb_offset_1024_16, swb_offset_1024_8, swb_offset_1024_8 };
static final int[][] ff_swb_offset_128 = new int[][] {
swb_offset_128_96, swb_offset_128_96, swb_offset_128_96, swb_offset_128_48, swb_offset_128_48, swb_offset_128_48, swb_offset_128_24, swb_offset_128_24, swb_offset_128_16, swb_offset_128_16,
swb_offset_128_16, swb_offset_128_8, swb_offset_128_8 };
static final float[] tns_tmp2_map_1_3 = new float[] { 0.0F, -0.43388373F, 0.6427876F, 0.34202015F };
static final float[] tns_tmp2_map_0_3 = new float[] { 0.0F, -0.43388373F, -0.7818315F, -0.9749279F, 0.9848077F, 0.8660254F, 0.6427876F, 0.34202015F };
static final float[] tns_tmp2_map_1_4 = new float[] { 0.0F, -0.2079117F, -0.40673664F, -0.58778524F, 0.6736956F, 0.52643216F, 0.36124167F, 0.18374951F };
static final float[] tns_tmp2_map_0_4 = new float[] {
0.0F, -0.2079117F, -0.40673664F, -0.58778524F, -0.7431448F, -0.8660254F, -0.95105654F, -0.9945219F, 0.99573416F, 0.9618256F,
0.8951633F, 0.7980172F, 0.6736956F, 0.52643216F, 0.36124167F, 0.18374951F };
static final float[][] tns_tmp2_map = new float[][] { tns_tmp2_map_0_3, tns_tmp2_map_0_4, tns_tmp2_map_1_3, tns_tmp2_map_1_4 };
static float[] codebook_vector0_vals = new float[] { -1.0F, 0.0F, 1.0F };
static int[] codebook_vector02_idx = new int[] {
0, 33088, 33152, 16656, 49744, 49808, 16672, 49760, 49824, 8452,
41540, 41604, 25108, 58196, 58260, 25124, 58212, 58276, 8456, 41544,
41608, 25112, 58200, 58264, 25128, 58216, 58280, 4353, 37441, 37505,
21009, 54097, 54161, 21025, 54113, 54177, 12805, 45893, 45957, 29461,
62549, 62613, 29477, 62565, 62629, 12809, 45897, 45961, 29465, 62553,
62617, 29481, 62569, 62633, 4354, 37442, 37506, 21010, 54098, 54162,
21026, 54114, 54178, 12806, 45894, 45958, 29462, 62550, 62614, 29478,
62566, 62630, 12810, 45898, 45962, 29466, 62554, 62618, 29482, 62570,
62634 };
static float[] codebook_vector4_vals = new float[] { -6.349604F, -4.326749F, -2.5198421F, -1.0F, 0.0F, 1.0F, 2.5198421F, 4.326749F, 6.349604F };
static int[] codebook_vector4_idx = new int[] {
0, 16, 32, 48, 64, 80, 96, 112, 128, 1,
17, 33, 49, 65, 81, 97, 113, 129, 2, 18,
34, 50, 66, 82, 98, 114, 130, 3, 19, 35,
51, 67, 83, 99, 115, 131, 4, 20, 36, 52,
68, 84, 100, 116, 132, 5, 21, 37, 53, 69,
85, 101, 117, 133, 6, 22, 38, 54, 70, 86,
102, 118, 134, 7, 23, 39, 55, 71, 87, 103,
119, 135, 8, 24, 40, 56, 72, 88, 104, 120,
136 };
static int[] codebook_vector6_idx = new int[] {
0, 272, 288, 304, 320, 336, 352, 368, 4353, 529,
545, 561, 577, 593, 609, 625, 4354, 530, 546, 562,
578, 594, 610, 626, 4355, 531, 547, 563, 579, 595,
611, 627, 4356, 532, 548, 564, 580, 596, 612, 628,
4357, 533, 549, 565, 581, 597, 613, 629, 4358, 534,
550, 566, 582, 598, 614, 630, 4359, 535, 551, 567,
583, 599, 615, 631 };
static int[] codebook_vector8_idx = new int[] {
0, 272, 288, 304, 320, 336, 352, 368, 384, 400,
416, 432, 448, 4353, 529, 545, 561, 577, 593, 609,
625, 641, 657, 673, 689, 705, 4354, 530, 546, 562,
578, 594, 610, 626, 642, 658, 674, 690, 706, 4355,
531, 547, 563, 579, 595, 611, 627, 643, 659, 675,
691, 707, 4356, 532, 548, 564, 580, 596, 612, 628,
644, 660, 676, 692, 708, 4357, 533, 549, 565, 581,
597, 613, 629, 645, 661, 677, 693, 709, 4358, 534,
550, 566, 582, 598, 614, 630, 646, 662, 678, 694,
710, 4359, 535, 551, 567, 583, 599, 615, 631, 647,
663, 679, 695, 711, 4360, 536, 552, 568, 584, 600,
616, 632, 648, 664, 680, 696, 712, 4361, 537, 553,
569, 585, 601, 617, 633, 649, 665, 681, 697, 713,
4362, 538, 554, 570, 586, 602, 618, 634, 650, 666,
682, 698, 714, 4363, 539, 555, 571, 587, 603, 619,
635, 651, 667, 683, 699, 715, 4364, 540, 556, 572,
588, 604, 620, 636, 652, 668, 684, 700, 716 };
static float[] codebook_vector10_vals = new float[] {
0.0F, 1.0F, 2.5198421F, 4.326749F, 6.349604F, 8.54988F, 10.902723F, 13.390518F, 16.0F, 18.720755F,
21.544348F, 24.463781F, 27.473143F, 30.56735F, 33.741993F, 36.99318F };
static int[] codebook_vector10_idx = new int[] {
0, 4112, 4128, 4144, 4160, 4176, 4192, 4208, 4224, 4240,
4256, 4272, 4288, 4304, 4320, 4336, 4608, 4097, 8209, 8225,
8241, 8257, 8273, 8289, 8305, 8321, 8337, 8353, 8369, 8385,
8401, 8417, 8433, 8705, 4098, 8210, 8226, 8242, 8258, 8274,
8290, 8306, 8322, 8338, 8354, 8370, 8386, 8402, 8418, 8434,
8706, 4099, 8211, 8227, 8243, 8259, 8275, 8291, 8307, 8323,
8339, 8355, 8371, 8387, 8403, 8419, 8435, 8707, 4100, 8212,
8228, 8244, 8260, 8276, 8292, 8308, 8324, 8340, 8356, 8372,
8388, 8404, 8420, 8436, 8708, 4101, 8213, 8229, 8245, 8261,
8277, 8293, 8309, 8325, 8341, 8357, 8373, 8389, 8405, 8421,
8437, 8709, 4102, 8214, 8230, 8246, 8262, 8278, 8294, 8310,
8326, 8342, 8358, 8374, 8390, 8406, 8422, 8438, 8710, 4103,
8215, 8231, 8247, 8263, 8279, 8295, 8311, 8327, 8343, 8359,
8375, 8391, 8407, 8423, 8439, 8711, 4104, 8216, 8232, 8248,
8264, 8280, 8296, 8312, 8328, 8344, 8360, 8376, 8392, 8408,
8424, 8440, 8712, 4105, 8217, 8233, 8249, 8265, 8281, 8297,
8313, 8329, 8345, 8361, 8377, 8393, 8409, 8425, 8441, 8713,
4106, 8218, 8234, 8250, 8266, 8282, 8298, 8314, 8330, 8346,
8362, 8378, 8394, 8410, 8426, 8442, 8714, 4107, 8219, 8235,
8251, 8267, 8283, 8299, 8315, 8331, 8347, 8363, 8379, 8395,
8411, 8427, 8443, 8715, 4108, 8220, 8236, 8252, 8268, 8284,
8300, 8316, 8332, 8348, 8364, 8380, 8396, 8412, 8428, 8444,
8716, 4109, 8221, 8237, 8253, 8269, 8285, 8301, 8317, 8333,
8349, 8365, 8381, 8397, 8413, 8429, 8445, 8717, 4110, 8222,
8238, 8254, 8270, 8286, 8302, 8318, 8334, 8350, 8366, 8382,
8398, 8414, 8430, 8446, 8718, 4111, 8223, 8239, 8255, 8271,
8287, 8303, 8319, 8335, 8351, 8367, 8383, 8399, 8415, 8431,
8447, 8719, 4352, 8464, 8480, 8496, 8512, 8528, 8544, 8560,
8576, 8592, 8608, 8624, 8640, 8656, 8672, 8688, 8960 };
}

View file

@ -0,0 +1,14 @@
package org.jcodec.codecs.aac.blocks;
import org.jcodec.codecs.aac.BlockType;
import org.jcodec.common.io.BitReader;
public abstract class Block {
private BlockType type;
public BlockType getType() {
return this.type;
}
public abstract void parse(BitReader paramBitReader);
}

View file

@ -0,0 +1,77 @@
package org.jcodec.codecs.aac.blocks;
import org.jcodec.codecs.aac.BlockType;
import org.jcodec.common.io.BitReader;
import org.jcodec.common.io.VLC;
public class BlockCCE extends Block {
private int coupling_point;
private int num_coupled;
private BlockType[] type;
private int[] id_select;
private int[] ch_select;
private int sign;
private Object scale;
private Object[] cce_scale;
private BlockICS blockICS;
private BlockICS.BandType[] bandType;
static VLC vlc = new VLC(AACTab.ff_aac_scalefactor_code, AACTab.ff_aac_scalefactor_bits);
public BlockCCE(BlockICS.BandType[] bandType) {
this.bandType = bandType;
}
public void parse(BitReader _in) {
int num_gain = 0;
this.coupling_point = 2 * _in.read1Bit();
this.num_coupled = _in.readNBit(3);
for (int i = 0; i <= this.num_coupled; i++) {
num_gain++;
this.type[i] = (_in.read1Bit() != 0) ? BlockType.TYPE_CPE : BlockType.TYPE_SCE;
this.id_select[i] = _in.readNBit(4);
if (this.type[i] == BlockType.TYPE_CPE) {
this.ch_select[i] = _in.readNBit(2);
if (this.ch_select[i] == 3)
num_gain++;
} else {
this.ch_select[i] = 2;
}
}
this.coupling_point += _in.read1Bit() | this.coupling_point >> 1;
this.sign = _in.read1Bit();
this.scale = this.cce_scale[_in.readNBit(2)];
this.blockICS = new BlockICS();
this.blockICS.parse(_in);
for (int c = 0; c < num_gain; c++) {
int idx = 0;
int cge = 1;
int gain = 0;
if (c != 0) {
cge = (this.coupling_point == CouplingPoint.AFTER_IMDCT.ordinal()) ? 1 : _in.read1Bit();
gain = (cge != 0) ? (vlc.readVLC(_in) - 60) : 0;
}
if (this.coupling_point != CouplingPoint.AFTER_IMDCT.ordinal())
for (int g = 0; g < this.blockICS.num_window_groups; g++) {
for (int sfb = 0; sfb < this.blockICS.maxSfb; sfb++, idx++) {
if (this.bandType[idx] != BlockICS.BandType.ZERO_BT &&
cge == 0)
int j = vlc.readVLC(_in) - 60;
}
}
}
}
enum CouplingPoint {
BEFORE_TNS, BETWEEN_TNS_AND_IMDCT, UNDEF, AFTER_IMDCT;
}
}

View file

@ -0,0 +1,29 @@
package org.jcodec.codecs.aac.blocks;
import org.jcodec.common.io.BitReader;
public class BlockCPE extends BlockICS {
private int[] ms_mask;
public void parse(BitReader _in) {
int common_window = _in.read1Bit();
if (common_window != 0) {
parseICSInfo(_in);
int ms_present = _in.readNBit(2);
if (ms_present == 3)
throw new RuntimeException("ms_present = 3 is reserved.");
if (ms_present != 0)
decodeMidSideStereo(_in, ms_present, 0, 0);
}
BlockICS ics1 = new BlockICS();
ics1.parse(_in);
BlockICS ics2 = new BlockICS();
ics2.parse(_in);
}
private void decodeMidSideStereo(BitReader _in, int ms_present, int numWindowGroups, int maxSfb) {
if (ms_present == 1)
for (int idx = 0; idx < numWindowGroups * maxSfb; idx++)
this.ms_mask[idx] = _in.read1Bit();
}
}

View file

@ -0,0 +1,17 @@
package org.jcodec.codecs.aac.blocks;
import org.jcodec.common.io.BitReader;
public class BlockDSE extends Block {
public void parse(BitReader _in) {
int elemType = _in.readNBit(4);
int byte_align = _in.read1Bit();
int count = _in.readNBit(8);
if (count == 255)
count += _in.readNBit(8);
if (byte_align != 0)
_in.align();
if (_in.skip(8 * count) != 8 * count)
throw new RuntimeException("Overread");
}
}

View file

@ -0,0 +1,14 @@
package org.jcodec.codecs.aac.blocks;
import org.jcodec.common.io.BitReader;
public class BlockFil extends Block {
public void parse(BitReader _in) {
int num = _in.readNBit(4);
if (num == 15)
num += _in.readNBit(8) - 1;
if (num > 0 &&
_in.skip(8 * num) != 8 * num)
throw new RuntimeException("Overread");
}
}

View file

@ -0,0 +1,516 @@
package org.jcodec.codecs.aac.blocks;
import org.jcodec.codecs.aac.Profile;
import org.jcodec.codecs.prores.ProresDecoder;
import org.jcodec.common.io.BitReader;
import org.jcodec.common.io.VLC;
import org.jcodec.common.io.VLCBuilder;
import org.jcodec.common.tools.MathUtil;
public class BlockICS extends Block {
private static VLC vlc = new VLC(AACTab.ff_aac_scalefactor_code, AACTab.ff_aac_scalefactor_bits);
private static VLC[] spectral = new VLC[] {
VLCBuilder.createVLCBuilder(AACTab.codes1, AACTab.bits1, AACTab.codebook_vector02_idx).getVLC(),
VLCBuilder.createVLCBuilder(AACTab.codes2, AACTab.bits2, AACTab.codebook_vector02_idx).getVLC(),
VLCBuilder.createVLCBuilder(AACTab.codes3, AACTab.bits3, AACTab.codebook_vector02_idx).getVLC(),
VLCBuilder.createVLCBuilder(AACTab.codes4, AACTab.bits4, AACTab.codebook_vector02_idx).getVLC(),
VLCBuilder.createVLCBuilder(AACTab.codes5, AACTab.bits5, AACTab.codebook_vector4_idx).getVLC(),
VLCBuilder.createVLCBuilder(AACTab.codes6, AACTab.bits6, AACTab.codebook_vector4_idx).getVLC(),
VLCBuilder.createVLCBuilder(AACTab.codes7, AACTab.bits7, AACTab.codebook_vector6_idx).getVLC(),
VLCBuilder.createVLCBuilder(AACTab.codes8, AACTab.bits8, AACTab.codebook_vector6_idx).getVLC(),
VLCBuilder.createVLCBuilder(AACTab.codes9, AACTab.bits9, AACTab.codebook_vector8_idx).getVLC(),
VLCBuilder.createVLCBuilder(AACTab.codes10, AACTab.bits10, AACTab.codebook_vector8_idx).getVLC(),
VLCBuilder.createVLCBuilder(AACTab.codes11, AACTab.bits11, AACTab.codebook_vector10_idx).getVLC() };
float[][] ff_aac_codebook_vector_vals = new float[][] {
AACTab.codebook_vector0_vals, AACTab.codebook_vector0_vals, AACTab.codebook_vector10_vals, AACTab.codebook_vector10_vals, AACTab.codebook_vector4_vals, AACTab.codebook_vector4_vals, AACTab.codebook_vector10_vals, AACTab.codebook_vector10_vals, AACTab.codebook_vector10_vals, AACTab.codebook_vector10_vals,
AACTab.codebook_vector10_vals };
private int[] group_len = new int[8];
private int[] band_type = new int[120];
private int[] band_type_run_end = new int[120];
private enum WindowSequence {
ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE, EIGHT_SHORT_SEQUENCE, LONG_STOP_SEQUENCE;
}
protected int parseICSInfo(BitReader _in) {
_in.read1Bit();
this.windowSequence = _in.readNBit(2);
int useKbWindow = _in.read1Bit();
this.num_window_groups = 1;
this.group_len[0] = 1;
if (this.windowSequence == WindowSequence.EIGHT_SHORT_SEQUENCE.ordinal()) {
int max_sfb = _in.readNBit(4);
for (int i = 0; i < 7; i++) {
if (_in.read1Bit() != 0) {
this.group_len[this.num_window_groups - 1] = this.group_len[this.num_window_groups - 1] + 1;
} else {
this.num_window_groups++;
this.group_len[this.num_window_groups - 1] = 1;
}
}
this.numSwb = AACTab.ff_aac_num_swb_128[this.samplingIndex];
this.swbOffset = AACTab.ff_swb_offset_128[this.samplingIndex];
this.numWindows = 8;
} else {
this.maxSfb = _in.readNBit(6);
this.numSwb = AACTab.ff_aac_num_swb_1024[this.samplingIndex];
this.swbOffset = AACTab.ff_swb_offset_1024[this.samplingIndex];
this.numWindows = 1;
int predictor_present = _in.read1Bit();
if (predictor_present != 0)
if (this.profile == Profile.MAIN) {
decodePrediction(_in, this.maxSfb);
} else {
if (this.profile == Profile.LC)
throw new RuntimeException("Prediction is not allowed _in AAC-LC.\n");
int ltpPresent = _in.read1Bit();
if (ltpPresent != 0)
decodeLtp(_in, this.maxSfb);
}
}
return 0;
}
private void decodePrediction(BitReader _in, int maxSfb) {
if (_in.read1Bit() != 0)
int i = _in.readNBit(5);
for (int sfb = 0; sfb < Math.min(maxSfb, AACTab.maxSfbTab[this.samplingIndex]); sfb++)
_in.read1Bit();
}
private void decodeLtp(BitReader _in, int maxSfb) {
int lag = _in.readNBit(11);
float coef = AACTab.ltpCoefTab[_in.readNBit(3)];
for (int sfb = 0; sfb < Math.min(maxSfb, 40); sfb++)
_in.read1Bit();
}
private void decodeBandTypes(BitReader _in) {
int idx = 0;
int bits = (this.windowSequence == WindowSequence.EIGHT_SHORT_SEQUENCE.ordinal()) ? 3 : 5;
for (int g = 0; g < this.num_window_groups; g++) {
int k = 0;
while (k < this.maxSfb) {
int sect_end = k;
int sect_band_type = _in.readNBit(4);
if (sect_band_type == 12)
throw new RuntimeException("invalid band type");
int sect_len_incr;
while ((sect_len_incr = _in.readNBit(bits)) == (1 << bits) - 1)
sect_end += sect_len_incr;
sect_end += sect_len_incr;
if (!_in.moreData() || sect_len_incr == (1 << bits) - 1)
throw new RuntimeException("Overread");
if (sect_end > this.maxSfb)
throw new RuntimeException(String.format("Number of bands (%d) exceeds limit (%d).\n", sect_end, this.maxSfb));
for (; k < sect_end; k++) {
this.band_type[idx] = sect_band_type;
this.band_type_run_end[idx++] = sect_end;
}
}
}
}
enum BandType {
ZERO_BT, BT_1, BT_2, BT_3, BT_4, FIRST_PAIR_BT, BT_6, BT_7, BT_8, BT_9, BT_10, ESC_BT, BT_12, NOISE_BT, INTENSITY_BT2, INTENSITY_BT;
}
static float[] ff_aac_pow2sf_tab = new float[428];
private boolean commonWindow;
private boolean scaleFlag;
private Profile profile;
private int samplingIndex;
private static final int MAX_LTP_LONG_SFB = 40;
private int windowSequence;
int num_window_groups;
int maxSfb;
private int globalGain;
private static final int POW_SF2_ZERO = 200;
private double[] sfs;
private int numSwb;
private int[] swbOffset;
private int numWindows;
static {
for (int i = 0; i < 428; i++)
ff_aac_pow2sf_tab[i] = (float)Math.pow(2.0D, (double)(i - 200) / 4.0D);
}
private void decodeScalefactors(BitReader _in) {
int[] offset = { this.globalGain, this.globalGain - 90, 0 };
int noise_flag = 1;
String[] sf_str = { "Global gain", "Noise gain", "Intensity stereo position" };
int idx = 0;
for (int g = 0; g < this.num_window_groups; g++) {
for (int i = 0; i < this.maxSfb; ) {
int run_end = this.band_type_run_end[idx];
if (this.band_type[idx] == BandType.ZERO_BT.ordinal()) {
for (; i < run_end; i++, idx++)
this.sfs[idx] = 0.0D;
continue;
}
if (this.band_type[idx] == BandType.INTENSITY_BT.ordinal() || this.band_type[idx] == BandType.INTENSITY_BT2.ordinal()) {
for (; i < run_end; i++, idx++) {
offset[2] = offset[2] + vlc.readVLC(_in) - 60;
int clipped_offset = MathUtil.clip(offset[2], -155, 100);
if (offset[2] != clipped_offset)
System.out.println(String.format("Intensity stereo position clipped (%d -> %d).\nIf you heard an audible artifact, there may be a bug _in the decoder. ", offset[2],
clipped_offset));
this.sfs[idx] = (double)ff_aac_pow2sf_tab[-clipped_offset + 200];
}
continue;
}
if (this.band_type[idx] == BandType.NOISE_BT.ordinal()) {
for (; i < run_end; i++, idx++) {
if (noise_flag-- > 0) {
offset[1] = offset[1] + _in.readNBit(9) - 256;
} else {
offset[1] = offset[1] + vlc.readVLC(_in) - 60;
}
int clipped_offset = MathUtil.clip(offset[1], -100, 155);
if (offset[1] != clipped_offset)
System.out.println(String.format("Noise gain clipped (%d -> %d).\nIf you heard an audible artifact, there may be a bug _in the decoder. ", offset[1],
clipped_offset));
this.sfs[idx] = (double)-ff_aac_pow2sf_tab[clipped_offset + 200];
}
continue;
}
for (; i < run_end; i++, idx++) {
offset[0] = offset[0] + vlc.readVLC(_in) - 60;
if (offset[0] > 255)
throw new RuntimeException(String.format("%s (%d) out of range.\n", sf_str[0], offset[0]));
this.sfs[idx] = (double)-ff_aac_pow2sf_tab[offset[0] - 100 + 200];
}
}
}
}
public static class Pulse {
private int numPulse;
private int[] pos;
private int[] amp;
public Pulse(int numPulse, int[] pos, int[] amp) {
this.numPulse = numPulse;
this.pos = pos;
this.amp = amp;
}
public int getNumPulse() {
return this.numPulse;
}
public int[] getPos() {
return this.pos;
}
public int[] getAmp() {
return this.amp;
}
}
private Pulse decodePulses(BitReader _in) {
int[] pos = new int[4];
int[] amp = new int[4];
int numPulse = _in.readNBit(2) + 1;
int pulseSwb = _in.readNBit(6);
if (pulseSwb >= this.numSwb)
throw new RuntimeException("pulseSwb >= numSwb");
pos[0] = this.swbOffset[pulseSwb];
pos[0] = pos[0] + _in.readNBit(5);
if (pos[0] > 1023)
throw new RuntimeException("pos[0] > 1023");
amp[0] = _in.readNBit(4);
for (int i = 1; i < numPulse; i++) {
pos[i] = _in.readNBit(5) + pos[i - 1];
if (pos[i] > 1023)
throw new RuntimeException("pos[" + i + "] > 1023");
amp[i] = _in.readNBit(5);
}
return new Pulse(numPulse, pos, amp);
}
public static class Tns {
private int[] nFilt;
private int[][] length;
private int[][] order;
private int[][] direction;
private float[][][] coeff;
public Tns(int[] nFilt, int[][] length, int[][] order, int[][] direction, float[][][] coeff) {
this.nFilt = nFilt;
this.length = length;
this.order = order;
this.direction = direction;
this.coeff = coeff;
}
}
private Tns decodeTns(BitReader _in) {
int is8 = (this.windowSequence == WindowSequence.EIGHT_SHORT_SEQUENCE.ordinal()) ? 1 : 0;
int tns_max_order = (is8 != 0) ? 7 : ((this.profile == Profile.MAIN) ? 20 : 12);
int[] nFilt = new int[this.numWindows];
int[][] length = new int[this.numWindows][2];
int[][] order = new int[this.numWindows][2];
int[][] direction = new int[this.numWindows][2];
float[][][] coeff = new float[this.numWindows][2][1 << 5 - 2 * is8];
for (int w = 0; w < this.numWindows; w++) {
nFilt[w] = _in.readNBit(2 - is8);
if (_in.readNBit(2 - is8) != 0) {
int coefRes = _in.read1Bit();
for (int filt = 0; filt < nFilt[w]; filt++) {
length[w][filt] = _in.readNBit(6 - 2 * is8);
order[w][filt] = _in.readNBit(5 - 2 * is8);
if (_in.readNBit(5 - 2 * is8) > tns_max_order)
throw new RuntimeException(String.format("TNS filter order %d is greater than maximum %d.\n", order[w][filt],
tns_max_order));
if (order[w][filt] != 0) {
direction[w][filt] = _in.read1Bit();
int coefCompress = _in.read1Bit();
int coefLen = coefRes + 3 - coefCompress;
int tmp2_idx = 2 * coefCompress + coefRes;
for (int i = 0; i < order[w][filt]; i++)
coeff[w][filt][i] = AACTab.tns_tmp2_map[tmp2_idx][_in.readNBit(coefLen)];
}
}
}
}
return new Tns(nFilt, length, order, direction, coeff);
}
void VMUL4(float[] result, int idx, float[] v, int code, float scale) {
result[idx] = v[code & 0x3] * scale;
result[idx + 1] = v[code >> 2 & 0x3] * scale;
result[idx + 2] = v[code >> 4 & 0x3] * scale;
result[idx + 3] = v[code >> 6 & 0x3] * scale;
}
void VMUL4S(float[] result, int idx, float[] v, int code, int sign, float scale) {
int nz = code >> 12;
result[idx + 0] = v[idx & 0x3] * scale;
sign <<= nz & 0x1;
nz >>= 1;
result[idx + 1] = v[idx >> 2 & 0x3] * scale;
sign <<= nz & 0x1;
nz >>= 1;
result[idx + 2] = v[idx >> 4 & 0x3] * scale;
sign <<= nz & 0x1;
nz >>= 1;
result[idx + 3] = v[idx >> 6 & 0x3] * scale;
}
void VMUL2(float[] result, int idx, float[] v, int code, float scale) {
result[idx] = v[code & 0xF] * scale;
result[idx + 1] = v[code >> 4 & 0xF] * scale;
}
void VMUL2S(float[] result, int idx, float[] v, int code, int sign, float scale) {
result[idx] = v[code & 0xF] * scale;
result[idx + 1] = v[code >> 4 & 0xF] * scale;
}
private void decodeSpectrum(BitReader _in) {
float[] coef = new float[1024];
int idx = 0;
for (int g = 0; g < this.num_window_groups; g++) {
for (int i = 0; i < this.maxSfb; i++, idx++) {
int cbt_m1 = this.band_type[idx] - 1;
if (cbt_m1 < BandType.INTENSITY_BT2.ordinal() - 1 && cbt_m1 != BandType.NOISE_BT.ordinal() - 1) {
float[] vq = this.ff_aac_codebook_vector_vals[cbt_m1];
VLC vlc = spectral[cbt_m1];
switch (cbt_m1 >> 1) {
case 0:
readBandType1And2(_in, coef, idx, g, i, vq, vlc);
break;
case 1:
readBandType3And4(_in, coef, idx, g, i, vq, vlc);
break;
case 2:
readBandType5And6(_in, coef, idx, g, i, vq, vlc);
break;
case 3:
case 4:
readBandType7Through10(_in, coef, idx, g, i, vq, vlc);
break;
default:
readOther(_in, coef, idx, g, i, vq, vlc);
break;
}
}
}
}
}
private void readBandType3And4(BitReader _in, float[] coef, int idx, int g, int sfb, float[] vq, VLC vlc) {
int g_len = this.group_len[g];
int cfo = this.swbOffset[sfb];
int off_len = this.swbOffset[sfb + 1] - this.swbOffset[sfb];
for (int group = 0; group < g_len; ) {
int cf = cfo;
int len = off_len;
while (true) {
int cb_idx = vlc.readVLC(_in);
int nnz = cb_idx >> 8 & 0xF;
int bits = (nnz == 0) ? 0 : _in.readNBit(nnz);
VMUL4S(coef, cf, vq, cb_idx, bits, (float)this.sfs[idx]);
cf += 4;
len -= 4;
if (len <= 0) {
group++;
cfo += 128;
}
}
}
}
private void readBandType7Through10(BitReader _in, float[] coef, int idx, int g, int sfb, float[] vq, VLC vlc) {
int g_len = this.group_len[g];
int cfo = this.swbOffset[sfb];
int off_len = this.swbOffset[sfb + 1] - this.swbOffset[sfb];
for (int group = 0; group < g_len; ) {
int cf = cfo;
int len = off_len;
while (true) {
int cb_idx = vlc.readVLC(_in);
int nnz = cb_idx >> 8 & 0xF;
int bits = (nnz == 0) ? 0 : (_in.readNBit(nnz) << cb_idx >> 12);
VMUL2S(coef, cf, vq, cb_idx, bits, (float)this.sfs[idx]);
cf += 2;
len -= 2;
if (len <= 0) {
group++;
cfo += 128;
}
}
}
}
private void readOther(BitReader _in, float[] coef, int idx, int g, int sfb, float[] vq, VLC vlc) {
int g_len = this.group_len[g];
int cfo = this.swbOffset[sfb];
int off_len = this.swbOffset[sfb + 1] - this.swbOffset[sfb];
for (int group = 0; group < g_len; ) {
int cf = cfo;
int len = off_len;
while (true) {
int cb_idx = vlc.readVLC(_in);
if (cb_idx != 0) {
int nnz = cb_idx >> 12;
int nzt = cb_idx >> 8;
int bits = _in.readNBit(nnz) << 32 - nnz;
for (int j = 0; j < 2; j++) {
if ((nzt & 1 << j) != 0) {
int b = ProresDecoder.nZeros(_in.checkNBit(14) ^ 0xFFFFFFFF);
if (b > 8)
throw new RuntimeException("error _in spectral data, ESC overflow\n");
_in.skip(b + 1);
b += 4;
int n = (1 << b) + _in.readNBit(b);
coef[cf++] = (float)(MathUtil.cubeRoot(n) | bits & Integer.MIN_VALUE);
bits <<= 1;
} else {
int v = (int)vq[cb_idx & 0xF];
coef[cf++] = (float)(bits & Integer.MIN_VALUE | v);
}
cb_idx >>= 4;
}
cf += 2;
len += 2;
}
if (len <= 0) {
group++;
cfo += 128;
}
}
}
}
private void readBandType1And2(BitReader _in, float[] coef, int idx, int g, int sfb, float[] vq, VLC vlc) {
int g_len = this.group_len[g];
int cfo = this.swbOffset[sfb];
int off_len = this.swbOffset[sfb + 1] - this.swbOffset[sfb];
for (int group = 0; group < g_len; ) {
int cf = cfo;
int len = off_len;
while (true) {
int cb_idx = vlc.readVLC(_in);
VMUL4(coef, cf, vq, cb_idx, (float)this.sfs[idx]);
cf += 4;
len -= 4;
if (len <= 0) {
group++;
cfo += 128;
}
}
}
}
private void readBandType5And6(BitReader _in, float[] coef, int idx, int g, int sfb, float[] vq, VLC vlc) {
int g_len = this.group_len[g];
int cfo = this.swbOffset[sfb];
int off_len = this.swbOffset[sfb + 1] - this.swbOffset[sfb];
for (int group = 0; group < g_len; ) {
int cf = cfo;
int len = off_len;
while (true) {
int cb_idx = vlc.readVLC(_in);
VMUL2(coef, cf, vq, cb_idx, (float)this.sfs[idx]);
cf += 2;
len -= 2;
if (len <= 0) {
group++;
cfo += 128;
}
}
}
}
public void parse(BitReader _in) {
this.globalGain = _in.readNBit(8);
if (!this.commonWindow && !this.scaleFlag)
parseICSInfo(_in);
decodeBandTypes(_in);
decodeScalefactors(_in);
int pulse_present = 0;
if (!this.scaleFlag) {
if ((pulse_present = _in.read1Bit()) != 0) {
if (this.windowSequence == WindowSequence.EIGHT_SHORT_SEQUENCE.ordinal())
throw new RuntimeException("Pulse tool not allowed _in eight short sequence.");
decodePulses(_in);
}
int tns_present;
if ((tns_present = _in.read1Bit()) != 0)
decodeTns(_in);
if (_in.read1Bit() != 0)
throw new RuntimeException("SSR is not supported");
}
decodeSpectrum(_in);
}
}

View file

@ -0,0 +1,73 @@
package org.jcodec.codecs.aac.blocks;
import org.jcodec.codecs.aac.ChannelPosition;
import org.jcodec.common.io.BitReader;
public class BlockPCE extends Block {
private static final int MAX_ELEM_ID = 16;
public static class ChannelMapping {
RawDataBlockType syn_ele;
int someInt;
ChannelPosition position;
}
public void parse(BitReader _in) {
_in.readNBit(2);
int samplingIndex = _in.readNBit(4);
int num_front = _in.readNBit(4);
int num_side = _in.readNBit(4);
int num_back = _in.readNBit(4);
int num_lfe = _in.readNBit(2);
int num_assoc_data = _in.readNBit(3);
int num_cc = _in.readNBit(4);
if (_in.read1Bit() != 0)
_in.readNBit(4);
if (_in.read1Bit() != 0)
_in.readNBit(4);
if (_in.read1Bit() != 0)
_in.readNBit(3);
ChannelMapping[] layout_map = new ChannelMapping[64];
int tags = 0;
decodeChannelMap(layout_map, tags, ChannelPosition.AAC_CHANNEL_FRONT, _in, num_front);
tags = num_front;
decodeChannelMap(layout_map, tags, ChannelPosition.AAC_CHANNEL_SIDE, _in, num_side);
tags += num_side;
decodeChannelMap(layout_map, tags, ChannelPosition.AAC_CHANNEL_BACK, _in, num_back);
tags += num_back;
decodeChannelMap(layout_map, tags, ChannelPosition.AAC_CHANNEL_LFE, _in, num_lfe);
tags += num_lfe;
_in.skip(4 * num_assoc_data);
decodeChannelMap(layout_map, tags, ChannelPosition.AAC_CHANNEL_CC, _in, num_cc);
tags += num_cc;
_in.align();
int comment_len = _in.readNBit(8) * 8;
_in.skip(comment_len);
}
private void decodeChannelMap(ChannelMapping[] layout_map, int offset, ChannelPosition type, BitReader _in, int n) {
while (n-- > 0) {
RawDataBlockType syn_ele = null;
switch (type) {
case AAC_CHANNEL_FRONT:
case AAC_CHANNEL_BACK:
case AAC_CHANNEL_SIDE:
syn_ele = RawDataBlockType.values()[_in.read1Bit()];
break;
case AAC_CHANNEL_CC:
_in.read1Bit();
syn_ele = RawDataBlockType.TYPE_CCE;
break;
case AAC_CHANNEL_LFE:
syn_ele = RawDataBlockType.TYPE_LFE;
break;
}
(layout_map[offset]).syn_ele = syn_ele;
(layout_map[offset]).someInt = _in.readNBit(4);
(layout_map[offset]).position = type;
offset++;
}
}
}

View file

@ -0,0 +1,5 @@
package org.jcodec.codecs.aac.blocks;
public enum RawDataBlockType {
TYPE_SCE, TYPE_CPE, TYPE_CCE, TYPE_LFE, TYPE_DSE, TYPE_PCE, TYPE_FIL, TYPE_END;
}