Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
dd782ef9
authored
Dec 07, 2020
by
kimvde
Committed by
Ian Baker
Dec 14, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Throw ParserException if AAC config is invalid
Issue:#8295 PiperOrigin-RevId: 346064966
parent
0501d471
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
library/common/src/main/java/com/google/android/exoplayer2/audio/AacUtil.java
library/common/src/main/java/com/google/android/exoplayer2/audio/AacUtil.java
View file @
dd782ef9
...
@@ -18,7 +18,6 @@ package com.google.android.exoplayer2.audio;
...
@@ -18,7 +18,6 @@ package com.google.android.exoplayer2.audio;
import
androidx.annotation.IntDef
;
import
androidx.annotation.IntDef
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.ParsableBitArray
;
import
com.google.android.exoplayer2.util.ParsableBitArray
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Documented
;
...
@@ -173,7 +172,8 @@ public final class AacUtil {
...
@@ -173,7 +172,8 @@ public final class AacUtil {
*
*
* @param audioSpecificConfig A byte array containing the AudioSpecificConfig to parse.
* @param audioSpecificConfig A byte array containing the AudioSpecificConfig to parse.
* @return The parsed configuration.
* @return The parsed configuration.
* @throws ParserException If the AudioSpecificConfig cannot be parsed as it's not supported.
* @throws ParserException If the AudioSpecificConfig cannot be parsed because it is invalid or
* unsupported.
*/
*/
public
static
Config
parseAudioSpecificConfig
(
byte
[]
audioSpecificConfig
)
throws
ParserException
{
public
static
Config
parseAudioSpecificConfig
(
byte
[]
audioSpecificConfig
)
throws
ParserException
{
return
parseAudioSpecificConfig
(
return
parseAudioSpecificConfig
(
...
@@ -188,7 +188,8 @@ public final class AacUtil {
...
@@ -188,7 +188,8 @@ public final class AacUtil {
* @param forceReadToEnd Whether the entire AudioSpecificConfig should be read. Required for
* @param forceReadToEnd Whether the entire AudioSpecificConfig should be read. Required for
* knowing the length of the configuration payload.
* knowing the length of the configuration payload.
* @return The parsed configuration.
* @return The parsed configuration.
* @throws ParserException If the AudioSpecificConfig cannot be parsed as it's not supported.
* @throws ParserException If the AudioSpecificConfig cannot be parsed because it is invalid or
* unsupported.
*/
*/
public
static
Config
parseAudioSpecificConfig
(
ParsableBitArray
bitArray
,
boolean
forceReadToEnd
)
public
static
Config
parseAudioSpecificConfig
(
ParsableBitArray
bitArray
,
boolean
forceReadToEnd
)
throws
ParserException
{
throws
ParserException
{
...
@@ -248,7 +249,9 @@ public final class AacUtil {
...
@@ -248,7 +249,9 @@ public final class AacUtil {
}
}
// For supported containers, bits_to_decode() is always 0.
// For supported containers, bits_to_decode() is always 0.
int
channelCount
=
AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE
[
channelConfiguration
];
int
channelCount
=
AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE
[
channelConfiguration
];
Assertions
.
checkArgument
(
channelCount
!=
AUDIO_SPECIFIC_CONFIG_CHANNEL_CONFIGURATION_INVALID
);
if
(
channelCount
==
AUDIO_SPECIFIC_CONFIG_CHANNEL_CONFIGURATION_INVALID
)
{
throw
new
ParserException
();
}
return
new
Config
(
sampleRateHz
,
channelCount
,
codecs
);
return
new
Config
(
sampleRateHz
,
channelCount
,
codecs
);
}
}
...
@@ -336,15 +339,17 @@ public final class AacUtil {
...
@@ -336,15 +339,17 @@ public final class AacUtil {
*
*
* @param bitArray The bit array containing the audio specific configuration.
* @param bitArray The bit array containing the audio specific configuration.
* @return The sampling frequency.
* @return The sampling frequency.
* @throws ParserException If the audio specific configuration is invalid.
*/
*/
private
static
int
getSamplingFrequency
(
ParsableBitArray
bitArray
)
{
private
static
int
getSamplingFrequency
(
ParsableBitArray
bitArray
)
throws
ParserException
{
int
samplingFrequency
;
int
samplingFrequency
;
int
frequencyIndex
=
bitArray
.
readBits
(
4
);
int
frequencyIndex
=
bitArray
.
readBits
(
4
);
if
(
frequencyIndex
==
AUDIO_SPECIFIC_CONFIG_FREQUENCY_INDEX_ARBITRARY
)
{
if
(
frequencyIndex
==
AUDIO_SPECIFIC_CONFIG_FREQUENCY_INDEX_ARBITRARY
)
{
samplingFrequency
=
bitArray
.
readBits
(
24
);
samplingFrequency
=
bitArray
.
readBits
(
24
);
}
else
{
}
else
if
(
frequencyIndex
<
13
)
{
Assertions
.
checkArgument
(
frequencyIndex
<
13
);
samplingFrequency
=
AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE
[
frequencyIndex
];
samplingFrequency
=
AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE
[
frequencyIndex
];
}
else
{
throw
new
ParserException
();
}
}
return
samplingFrequency
;
return
samplingFrequency
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment