use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project ExoPlayer by google.
the class AdtsReader method parseAdtsHeader.
/**
* Parses the sample header.
*/
@RequiresNonNull("output")
private void parseAdtsHeader() throws ParserException {
adtsScratch.setPosition(0);
if (!hasOutputFormat) {
int audioObjectType = adtsScratch.readBits(2) + 1;
if (audioObjectType != 2) {
// The stream indicates AAC-Main (1), AAC-SSR (3) or AAC-LTP (4). When the stream indicates
// AAC-Main it's more likely that the stream contains HE-AAC (5), which cannot be
// represented correctly in the 2 bit audio_object_type field in the ADTS header. In
// practice when the stream indicates AAC-SSR or AAC-LTP it more commonly contains AAC-LC or
// HE-AAC. Since most Android devices don't support AAC-Main, AAC-SSR or AAC-LTP, and since
// indicating AAC-LC works for HE-AAC streams, we pretend that we're dealing with AAC-LC and
// hope for the best. In practice this often works.
// See: https://github.com/google/ExoPlayer/issues/774
// See: https://github.com/google/ExoPlayer/issues/1383
Log.w(TAG, "Detected audio object type: " + audioObjectType + ", but assuming AAC LC.");
audioObjectType = 2;
}
adtsScratch.skipBits(5);
int channelConfig = adtsScratch.readBits(3);
byte[] audioSpecificConfig = AacUtil.buildAudioSpecificConfig(audioObjectType, firstFrameSampleRateIndex, channelConfig);
AacUtil.Config aacConfig = AacUtil.parseAudioSpecificConfig(audioSpecificConfig);
Format format = new Format.Builder().setId(formatId).setSampleMimeType(MimeTypes.AUDIO_AAC).setCodecs(aacConfig.codecs).setChannelCount(aacConfig.channelCount).setSampleRate(aacConfig.sampleRateHz).setInitializationData(Collections.singletonList(audioSpecificConfig)).setLanguage(language).build();
// In this class a sample is an access unit, but the MediaFormat sample rate specifies the
// number of PCM audio samples per second.
sampleDurationUs = (C.MICROS_PER_SECOND * 1024) / format.sampleRate;
output.format(format);
hasOutputFormat = true;
} else {
adtsScratch.skipBits(10);
}
adtsScratch.skipBits(4);
int sampleSize = adtsScratch.readBits(13) - 2 - /* the sync word */
HEADER_SIZE;
if (hasCrc) {
sampleSize -= CRC_SIZE;
}
setReadingSampleState(output, sampleDurationUs, 0, sampleSize);
}
use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project ExoPlayer by google.
the class LatmReader method parseStreamMuxConfig.
/**
* Parses a StreamMuxConfig as defined in ISO/IEC 14496-3:2009 Section 1.7.3.1, Table 1.42.
*/
@RequiresNonNull("output")
private void parseStreamMuxConfig(ParsableBitArray data) throws ParserException {
int audioMuxVersion = data.readBits(1);
audioMuxVersionA = audioMuxVersion == 1 ? data.readBits(1) : 0;
if (audioMuxVersionA == 0) {
if (audioMuxVersion == 1) {
// Skip taraBufferFullness.
latmGetValue(data);
}
if (!data.readBit()) {
throw ParserException.createForMalformedContainer(/* message= */
null, /* cause= */
null);
}
numSubframes = data.readBits(6);
int numProgram = data.readBits(4);
int numLayer = data.readBits(3);
if (numProgram != 0 || numLayer != 0) {
throw ParserException.createForMalformedContainer(/* message= */
null, /* cause= */
null);
}
if (audioMuxVersion == 0) {
int startPosition = data.getPosition();
int readBits = parseAudioSpecificConfig(data);
data.setPosition(startPosition);
byte[] initData = new byte[(readBits + 7) / 8];
data.readBits(initData, 0, readBits);
Format format = new Format.Builder().setId(formatId).setSampleMimeType(MimeTypes.AUDIO_AAC).setCodecs(codecs).setChannelCount(channelCount).setSampleRate(sampleRateHz).setInitializationData(Collections.singletonList(initData)).setLanguage(language).build();
if (!format.equals(this.format)) {
this.format = format;
sampleDurationUs = (C.MICROS_PER_SECOND * 1024) / format.sampleRate;
output.format(format);
}
} else {
int ascLen = (int) latmGetValue(data);
int bitsRead = parseAudioSpecificConfig(data);
// fillBits.
data.skipBits(ascLen - bitsRead);
}
parseFrameLength(data);
otherDataPresent = data.readBit();
otherDataLenBits = 0;
if (otherDataPresent) {
if (audioMuxVersion == 1) {
otherDataLenBits = latmGetValue(data);
} else {
boolean otherDataLenEsc;
do {
otherDataLenEsc = data.readBit();
otherDataLenBits = (otherDataLenBits << 8) + data.readBits(8);
} while (otherDataLenEsc);
}
}
boolean crcCheckPresent = data.readBit();
if (crcCheckPresent) {
// crcCheckSum.
data.skipBits(8);
}
} else {
// This is not defined by ISO/IEC 14496-3:2009.
throw ParserException.createForMalformedContainer(/* message= */
null, /* cause= */
null);
}
}
use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project beam by apache.
the class ExternalTest method expandMultiOutputTest.
@Test
@Category({ ValidatesRunner.class, UsesCrossLanguageTransforms.class })
@RequiresNonNull("localExpansionAddr")
public void expandMultiOutputTest() {
PCollectionTuple pTuple = testPipeline.apply(Create.of(1, 2, 3, 4, 5, 6)).apply(External.of(TEST_URN_MULTI, new byte[] {}, localExpansionAddr).withMultiOutputs());
PAssert.that(pTuple.get(new TupleTag<Integer>("even") {
})).containsInAnyOrder(2, 4, 6);
PAssert.that(pTuple.get(new TupleTag<Integer>("odd") {
})).containsInAnyOrder(1, 3, 5);
pipelineResult = testPipeline.run();
}
Aggregations