GeezerVison is showing github.com — Merge remote-tracking branch 'origin/stjs-prepare' into h264decode_optim · codice/jcodec@485ceb3
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/main/java/net/sourceforge/jaad/aac/DecoderConfig.java +45-51Lines changed: 45 additions & 51 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | package net.sourceforge.jaad.aac; | 2 | 2 |
| | 3 | +import static net.sourceforge.jaad.aac.Profile.*; | | 4 | + | 3 | 5 | import net.sourceforge.jaad.aac.syntax.BitStream; | 4 | 6 | import net.sourceforge.jaad.aac.syntax.SyntaxConstants; | 5 | 7 | import net.sourceforge.jaad.aac.syntax.IBitStream; | @@ -154,57 +156,49 @@ public static DecoderConfig parseMP4DecoderSpecificInfo(byte[] data) throws AACE | 154 | 156 | else config.sampleFrequency = SampleFrequency.forInt(sf); | 155 | 157 | config.channelConfiguration = ChannelConfiguration.forInt(_in.readBits(4)); | 156 | 158 |
| 157 | | - switch(config.profile) { | 158 | | - case AAC_SBR: | 159 | | - config.extProfile = config.profile; | 160 | | - config.sbrPresent = true; | 161 | | - sf = _in.readBits(4); | 162 | | - //TODO: 24 bits already read; read again? | 163 | | - //if(sf==0xF) config.sampleFrequency = SampleFrequency.forFrequency(_in.readBits(24)); | 164 | | - //if sample frequencies are the same: downsample SBR | 165 | | - config.downSampledSBR = config.sampleFrequency.getIndex()==sf; | 166 | | - config.sampleFrequency = SampleFrequency.forInt(sf); | 167 | | - config.profile = readProfile(_in); | 168 | | - break; | 169 | | - case AAC_MAIN: | 170 | | - case AAC_LC: | 171 | | - case AAC_SSR: | 172 | | - case AAC_LTP: | 173 | | - case ER_AAC_LC: | 174 | | - case ER_AAC_LTP: | 175 | | - case ER_AAC_LD: | 176 | | - //ga-specific info: | 177 | | - config.frameLengthFlag = _in.readBool(); | 178 | | - if(config.frameLengthFlag) throw new AACException("config uses 960-sample frames, not yet supported"); //TODO: are 960-frames working yet? | 179 | | - config.dependsOnCoreCoder = _in.readBool(); | 180 | | - if(config.dependsOnCoreCoder) config.coreCoderDelay = _in.readBits(14); | 181 | | - else config.coreCoderDelay = 0; | 182 | | - config.extensionFlag = _in.readBool(); | 183 | | - | 184 | | - if(config.extensionFlag) { | 185 | | - if(config.profile.isErrorResilientProfile()) { | 186 | | - config.sectionDataResilience = _in.readBool(); | 187 | | - config.scalefactorResilience = _in.readBool(); | 188 | | - config.spectralDataResilience = _in.readBool(); | 189 | | - } | 190 | | - //extensionFlag3 | 191 | | - _in.skipBit(); | 192 | | - } | 193 | | - | 194 | | - if(config.channelConfiguration==ChannelConfiguration.CHANNEL_CONFIG_NONE) { | 195 | | - //TODO: is this working correct? -> ISO 14496-3 part 1: 1.A.4.3 | 196 | | - _in.skipBits(3); //PCE | 197 | | - PCE pce = new PCE(); | 198 | | - pce.decode(_in); | 199 | | - config.profile = pce.getProfile(); | 200 | | - config.sampleFrequency = pce.getSampleFrequency(); | 201 | | - config.channelConfiguration = ChannelConfiguration.forInt(pce.getChannelCount()); | 202 | | - } | 203 | | - | 204 | | - if(_in.getBitsLeft()>10) readSyncExtension(_in, config); | 205 | | - break; | 206 | | - default: | 207 | | - throw new AACException("profile not supported: "+config.profile.getIndex()); | | 159 | + Profile cp = config.profile; | | 160 | + if (AAC_SBR == cp) { | | 161 | + config.extProfile = cp; | | 162 | + config.sbrPresent = true; | | 163 | + sf = _in.readBits(4); | | 164 | + //TODO: 24 bits already read; read again? | | 165 | + //if(sf==0xF) config.sampleFrequency = SampleFrequency.forFrequency(_in.readBits(24)); | | 166 | + //if sample frequencies are the same: downsample SBR | | 167 | + config.downSampledSBR = config.sampleFrequency.getIndex()==sf; | | 168 | + config.sampleFrequency = SampleFrequency.forInt(sf); | | 169 | + config.profile = readProfile(_in); | | 170 | + } else if (AAC_MAIN == cp || AAC_LC == cp || AAC_SSR == cp || AAC_LTP == cp || ER_AAC_LC == cp || ER_AAC_LTP == cp || ER_AAC_LD == cp ) { | | 171 | + //ga-specific info: | | 172 | + config.frameLengthFlag = _in.readBool(); | | 173 | + if(config.frameLengthFlag) throw new AACException("config uses 960-sample frames, not yet supported"); //TODO: are 960-frames working yet? | | 174 | + config.dependsOnCoreCoder = _in.readBool(); | | 175 | + if(config.dependsOnCoreCoder) config.coreCoderDelay = _in.readBits(14); | | 176 | + else config.coreCoderDelay = 0; | | 177 | + config.extensionFlag = _in.readBool(); | | 178 | + | | 179 | + if(config.extensionFlag) { | | 180 | + if(cp.isErrorResilientProfile()) { | | 181 | + config.sectionDataResilience = _in.readBool(); | | 182 | + config.scalefactorResilience = _in.readBool(); | | 183 | + config.spectralDataResilience = _in.readBool(); | | 184 | + } | | 185 | + //extensionFlag3 | | 186 | + _in.skipBit(); | | 187 | + } | | 188 | + | | 189 | + if(config.channelConfiguration==ChannelConfiguration.CHANNEL_CONFIG_NONE) { | | 190 | + //TODO: is this working correct? -> ISO 14496-3 part 1: 1.A.4.3 | | 191 | + _in.skipBits(3); //PCE | | 192 | + PCE pce = new PCE(); | | 193 | + pce.decode(_in); | | 194 | + config.profile = pce.getProfile(); | | 195 | + config.sampleFrequency = pce.getSampleFrequency(); | | 196 | + config.channelConfiguration = ChannelConfiguration.forInt(pce.getChannelCount()); | | 197 | + } | | 198 | + | | 199 | + if(_in.getBitsLeft()>10) readSyncExtension(_in, config); | | 200 | + } else { | | 201 | + throw new AACException("profile not supported: "+cp.getIndex()); | 208 | 202 | } | 209 | 203 | return config; | 210 | 204 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/net/sourceforge/jaad/aac/Profile.java +18-17Lines changed: 18 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 11 | 11 | * More precisely, the ISO standard calls these 'object types'. | 12 | 12 | * @author in-somnia | 13 | 13 | */ | 14 | | -public enum Profile { | | 14 | +public final class Profile { | 15 | 15 |
| 16 | | - UNKNOWN(-1, "unknown", false), | 17 | | - AAC_MAIN(1, "AAC Main Profile", true), | 18 | | - AAC_LC(2, "AAC Low Complexity", true), | 19 | | - AAC_SSR(3, "AAC Scalable Sample Rate", false), | 20 | | - AAC_LTP(4, "AAC Long Term Prediction", false), | 21 | | - AAC_SBR(5, "AAC SBR", true), | 22 | | - AAC_SCALABLE(6, "Scalable AAC", false), | 23 | | - TWIN_VQ(7, "TwinVQ", false), | 24 | | - AAC_LD(11, "AAC Low Delay", false), | 25 | | - ER_AAC_LC(17, "Error Resilient AAC Low Complexity", true), | 26 | | - ER_AAC_SSR(18, "Error Resilient AAC SSR", false), | 27 | | - ER_AAC_LTP(19, "Error Resilient AAC Long Term Prediction", false), | 28 | | - ER_AAC_SCALABLE(20, "Error Resilient Scalable AAC", false), | 29 | | - ER_TWIN_VQ(21, "Error Resilient TwinVQ", false), | 30 | | - ER_BSAC(22, "Error Resilient BSAC", false), | 31 | | - ER_AAC_LD(23, "Error Resilient AAC Low Delay", false); | | 16 | +public final static Profile UNKNOWN = new Profile(-1, "unknown", false); | | 17 | +public final static Profile AAC_MAIN = new Profile(1, "AAC Main Profile", true); | | 18 | +public final static Profile AAC_LC = new Profile(2, "AAC Low Complexity", true); | | 19 | +public final static Profile AAC_SSR = new Profile(3, "AAC Scalable Sample Rate", false); | | 20 | +public final static Profile AAC_LTP = new Profile(4, "AAC Long Term Prediction", false); | | 21 | +public final static Profile AAC_SBR = new Profile(5, "AAC SBR", true); | | 22 | +public final static Profile AAC_SCALABLE = new Profile(6, "Scalable AAC", false); | | 23 | +public final static Profile TWIN_VQ = new Profile(7, "TwinVQ", false); | | 24 | +public final static Profile AAC_LD = new Profile(11, "AAC Low Delay", false); | | 25 | +public final static Profile ER_AAC_LC = new Profile(17, "Error Resilient AAC Low Complexity", true); | | 26 | +public final static Profile ER_AAC_SSR = new Profile(18, "Error Resilient AAC SSR", false); | | 27 | +public final static Profile ER_AAC_LTP = new Profile(19, "Error Resilient AAC Long Term Prediction", false); | | 28 | +public final static Profile ER_AAC_SCALABLE = new Profile(20, "Error Resilient Scalable AAC", false); | | 29 | +public final static Profile ER_TWIN_VQ = new Profile(21, "Error Resilient TwinVQ", false); | | 30 | +public final static Profile ER_BSAC = new Profile(22, "Error Resilient BSAC", false); | | 31 | +public final static Profile ER_AAC_LD = new Profile(23, "Error Resilient AAC Low Delay", false); | | 32 | + | 32 | 33 | private static final Profile[] ALL = { | 33 | 34 | AAC_MAIN, AAC_LC, AAC_SSR, AAC_LTP, AAC_SBR, AAC_SCALABLE, TWIN_VQ, | 34 | 35 | null, null, null, AAC_LD, null, null, null, null, null, ER_AAC_LC, ER_AAC_SSR, | |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/net/sourceforge/jaad/aac/syntax/ICSInfo.java +26-28Lines changed: 26 additions & 28 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | package net.sourceforge.jaad.aac.syntax; | 2 | 2 |
| | 3 | +import static net.sourceforge.jaad.aac.Profile.*; | | 4 | + | 3 | 5 | import org.jcodec.platform.Platform; | 4 | 6 |
| 5 | 7 | import net.sourceforge.jaad.aac.AACException; | @@ -101,34 +103,30 @@ public void decode(IBitStream _in, DecoderConfig conf, boolean commonWindow) thr | 101 | 103 | } | 102 | 104 |
| 103 | 105 | private void readPredictionData(IBitStream _in, Profile profile, SampleFrequency sf, boolean commonWindow) throws AACException { | 104 | | - switch(profile) { | 105 | | - case AAC_MAIN: | 106 | | - if(icPredict==null) icPredict = new ICPrediction(); | 107 | | - icPredict.decode(_in, maxSFB, sf); | 108 | | - break; | 109 | | - case AAC_LTP: | 110 | | - if(ltpData1Present = _in.readBool()) { | 111 | | - if(ltPredict1==null) ltPredict1 = new LTPrediction(frameLength); | 112 | | - ltPredict1.decode(_in, this, profile); | 113 | | - } | 114 | | - if(commonWindow) { | 115 | | - if(ltpData2Present = _in.readBool()) { | 116 | | - if(ltPredict2==null) ltPredict2 = new LTPrediction(frameLength); | 117 | | - ltPredict2.decode(_in, this, profile); | 118 | | - } | 119 | | - } | 120 | | - break; | 121 | | - case ER_AAC_LTP: | 122 | | - if(!commonWindow) { | 123 | | - if(ltpData1Present = _in.readBool()) { | 124 | | - if(ltPredict1==null) ltPredict1 = new LTPrediction(frameLength); | 125 | | - ltPredict1.decode(_in, this, profile); | 126 | | - } | 127 | | - } | 128 | | - break; | 129 | | - default: | 130 | | - throw new AACException("unexpected profile for LTP: "+profile); | 131 | | - } | | 106 | + if (AAC_MAIN == profile) { | | 107 | + if(icPredict==null) icPredict = new ICPrediction(); | | 108 | + icPredict.decode(_in, maxSFB, sf); | | 109 | + } else if (AAC_LTP == profile) { | | 110 | + if(ltpData1Present = _in.readBool()) { | | 111 | + if(ltPredict1==null) ltPredict1 = new LTPrediction(frameLength); | | 112 | + ltPredict1.decode(_in, this, profile); | | 113 | + } | | 114 | + if(commonWindow) { | | 115 | + if(ltpData2Present = _in.readBool()) { | | 116 | + if(ltPredict2==null) ltPredict2 = new LTPrediction(frameLength); | | 117 | + ltPredict2.decode(_in, this, profile); | | 118 | + } | | 119 | + } | | 120 | + } else if(ER_AAC_LTP == profile) { | | 121 | + if(!commonWindow) { | | 122 | + if(ltpData1Present = _in.readBool()) { | | 123 | + if(ltPredict1==null) ltPredict1 = new LTPrediction(frameLength); | | 124 | + ltPredict1.decode(_in, this, profile); | | 125 | + } | | 126 | + } | | 127 | + } else { | | 128 | + throw new AACException("unexpected profile for LTP: "+profile); | | 129 | + } | 132 | 130 | } | 133 | 131 |
| 134 | 132 | /* =========== gets ============ */ | |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/codecs/aac/blocks/BlockPCE.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -89,7 +89,7 @@ private void decodeChannelMap(ChannelMapping layout_map[], int offset, ChannelPo | 89 | 89 | case AAC_CHANNEL_FRONT: | 90 | 90 | case AAC_CHANNEL_BACK: | 91 | 91 | case AAC_CHANNEL_SIDE: | 92 | | - syn_ele = RawDataBlockType.fromOrdinal(_in.read1Bit()); | | 92 | + syn_ele = RawDataBlockType.values()[_in.read1Bit()]; | 93 | 93 | break; | 94 | 94 | case AAC_CHANNEL_CC: | 95 | 95 | _in.read1Bit(); | |
Collapse file Copy file name to clipboard +1-11Lines changed: 1 addition & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | package org.jcodec.codecs.aac.blocks; | 2 | 2 |
| 3 | | -import java.util.EnumSet; | 4 | | - | 5 | 3 | /** | 6 | 4 | * This class is part of JCodec ( www.jcodec.org ) This software is distributed | 7 | 5 | * under FreeBSD License | | 10 | 8 | * | 11 | 9 | */ | 12 | 10 | public enum RawDataBlockType { | 13 | | - TYPE_SCE, TYPE_CPE, TYPE_CCE, TYPE_LFE, TYPE_DSE, TYPE_PCE, TYPE_FIL, TYPE_END; | 14 | | - | 15 | | - public static RawDataBlockType fromOrdinal(int ordinal) { | 16 | | - for (RawDataBlockType val : EnumSet.allOf(RawDataBlockType.class)) { | 17 | | - if (val.ordinal() == ordinal) | 18 | | - return val; | 19 | | - } | 20 | | - return null; | 21 | | - } | | 11 | + TYPE_SCE, TYPE_CPE, TYPE_CCE, TYPE_LFE, TYPE_DSE, TYPE_PCE, TYPE_FIL, TYPE_END | 22 | 12 | } |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/codecs/h264/io/model/SliceType.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | * | 9 | 9 | */ | 10 | 10 | public final class SliceType { | | 11 | + private final static SliceType _values[] = new SliceType[5]; | 11 | 12 | public final static SliceType P = new SliceType("P", 0); | 12 | 13 | public final static SliceType B = new SliceType("B", 1); | 13 | 14 | public final static SliceType I = new SliceType("I", 2); | 14 | 15 | public final static SliceType SP = new SliceType("SP", 3); | 15 | 16 | public final static SliceType SI = new SliceType("SI", 4); | 16 | 17 | private String _name; | 17 | 18 | private int _ordinal; | 18 | | - private final static SliceType _values[] = new SliceType[5]; | 19 | 19 |
| 20 | 20 | private SliceType(String name, int ordinal) { | 21 | 21 | this._name = name; | |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/codecs/prores/ProresEncoder.java +12-4Lines changed: 12 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,10 +45,17 @@ public class ProresEncoder extends VideoEncoder { | 45 | 45 | private static final int LOG_DEFAULT_SLICE_MB_WIDTH = 3; | 46 | 46 | private static final int DEFAULT_SLICE_MB_WIDTH = 1 << LOG_DEFAULT_SLICE_MB_WIDTH; | 47 | 47 |
| 48 | | - public static enum Profile { | 49 | | - PROXY(QMAT_LUMA_APCO, QMAT_CHROMA_APCO, "apco", 1000, 4, 8), LT(QMAT_LUMA_APCS, QMAT_CHROMA_APCS, "apcs", 2100, | 50 | | - 1, 9), STANDARD(QMAT_LUMA_APCN, QMAT_CHROMA_APCN, "apcn", 3500, 1, 6), HQ(QMAT_LUMA_APCH, | 51 | | - QMAT_CHROMA_APCH, "apch", 5400, 1, 6); | | 48 | + public final static class Profile { | | 49 | + public final static Profile PROXY = new Profile(QMAT_LUMA_APCO, QMAT_CHROMA_APCO, "apco", 1000, 4, 8); | | 50 | + public final static Profile LT = new Profile(QMAT_LUMA_APCS, QMAT_CHROMA_APCS, "apcs", 2100, 1, 9); | | 51 | + public final static Profile STANDARD = new Profile(QMAT_LUMA_APCN, QMAT_CHROMA_APCN, "apcn", 3500, 1, 6); | | 52 | + public final static Profile HQ = new Profile(QMAT_LUMA_APCH, QMAT_CHROMA_APCH, "apch", 5400, 1, 6); | | 53 | + | | 54 | + private final static Profile[] _values = new Profile[] { PROXY, LT, STANDARD, HQ }; | | 55 | + | | 56 | + public static Profile[] values() { | | 57 | + return _values; | | 58 | + } | 52 | 59 |
| 53 | 60 | final int[] qmatLuma; | 54 | 61 | final int[] qmatChroma; | @@ -66,6 +73,7 @@ private Profile(int[] qmatLuma, int[] qmatChroma, String fourcc, int bitrate, in | 66 | 73 | this.firstQp = firstQp; | 67 | 74 | this.lastQp = lastQp; | 68 | 75 | } | | 76 | + | 69 | 77 | }; | 70 | 78 |
| 71 | 79 | protected Profile profile; | |
|