mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Don't read GaSpecificConfig unless required
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=164125579
This commit is contained in:
parent
ccd05cbd04
commit
72daef7a4c
@ -256,7 +256,7 @@ public final class LatmReader implements ElementaryStreamReader {
|
||||
|
||||
private int parseAudioSpecificConfig(ParsableBitArray data) throws ParserException {
|
||||
int bitsLeft = data.bitsLeft();
|
||||
Pair<Integer, Integer> config = CodecSpecificDataUtil.parseAacAudioSpecificConfig(data);
|
||||
Pair<Integer, Integer> config = CodecSpecificDataUtil.parseAacAudioSpecificConfig(data, true);
|
||||
sampleRateHz = config.first;
|
||||
channelCount = config.second;
|
||||
return bitsLeft - data.bitsLeft();
|
||||
|
@ -90,7 +90,7 @@ public final class CodecSpecificDataUtil {
|
||||
*/
|
||||
public static Pair<Integer, Integer> parseAacAudioSpecificConfig(byte[] audioSpecificConfig)
|
||||
throws ParserException {
|
||||
return parseAacAudioSpecificConfig(new ParsableBitArray(audioSpecificConfig));
|
||||
return parseAacAudioSpecificConfig(new ParsableBitArray(audioSpecificConfig), false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,11 +98,13 @@ public final class CodecSpecificDataUtil {
|
||||
*
|
||||
* @param bitArray A {@link ParsableBitArray} containing the AudioSpecificConfig to parse. The
|
||||
* position is advanced to the end of the AudioSpecificConfig.
|
||||
* @param forceReadToEnd Whether the entire AudioSpecificConfig should be read. Required for
|
||||
* knowing the length of the configuration payload.
|
||||
* @return A pair consisting of the sample rate in Hz and the channel count.
|
||||
* @throws ParserException If the AudioSpecificConfig cannot be parsed as it's not supported.
|
||||
*/
|
||||
public static Pair<Integer, Integer> parseAacAudioSpecificConfig(ParsableBitArray bitArray)
|
||||
throws ParserException {
|
||||
public static Pair<Integer, Integer> parseAacAudioSpecificConfig(ParsableBitArray bitArray,
|
||||
boolean forceReadToEnd) throws ParserException {
|
||||
int audioObjectType = getAacAudioObjectType(bitArray);
|
||||
int sampleRate = getAacSamplingFrequency(bitArray);
|
||||
int channelConfiguration = bitArray.readBits(4);
|
||||
@ -120,36 +122,38 @@ public final class CodecSpecificDataUtil {
|
||||
}
|
||||
}
|
||||
|
||||
switch (audioObjectType) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 6:
|
||||
case 7:
|
||||
case 17:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
parseGaSpecificConfig(bitArray, audioObjectType, channelConfiguration);
|
||||
break;
|
||||
default:
|
||||
throw new ParserException("Unsupported audio object type: " + audioObjectType);
|
||||
}
|
||||
switch (audioObjectType) {
|
||||
case 17:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
int epConfig = bitArray.readBits(2);
|
||||
if (epConfig == 2 || epConfig == 3) {
|
||||
throw new ParserException("Unsupported epConfig: " + epConfig);
|
||||
}
|
||||
break;
|
||||
if (forceReadToEnd) {
|
||||
switch (audioObjectType) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 6:
|
||||
case 7:
|
||||
case 17:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
parseGaSpecificConfig(bitArray, audioObjectType, channelConfiguration);
|
||||
break;
|
||||
default:
|
||||
throw new ParserException("Unsupported audio object type: " + audioObjectType);
|
||||
}
|
||||
switch (audioObjectType) {
|
||||
case 17:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
int epConfig = bitArray.readBits(2);
|
||||
if (epConfig == 2 || epConfig == 3) {
|
||||
throw new ParserException("Unsupported epConfig: " + epConfig);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// For supported containers, bits_to_decode() is always 0.
|
||||
int channelCount = AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE[channelConfiguration];
|
||||
|
Loading…
x
Reference in New Issue
Block a user