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
7c2889c6
authored
Feb 27, 2020
by
andrewlewis
Committed by
kim-vde
Feb 27, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add ENCODING_ constants for AAC
PiperOrigin-RevId: 297579793
parent
6946170d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
1 deletions
library/common/src/main/java/com/google/android/exoplayer2/C.java
library/common/src/main/java/com/google/android/exoplayer2/util/CodecSpecificDataUtil.java
library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java
library/common/src/main/java/com/google/android/exoplayer2/C.java
View file @
7c2889c6
...
...
@@ -160,6 +160,11 @@ public final class C {
ENCODING_PCM_32BIT
,
ENCODING_PCM_FLOAT
,
ENCODING_MP3
,
ENCODING_AAC_LC
,
ENCODING_AAC_HE_V1
,
ENCODING_AAC_HE_V2
,
ENCODING_AAC_XHE
,
ENCODING_AAC_ELD
,
ENCODING_AC3
,
ENCODING_E_AC3
,
ENCODING_E_AC3_JOC
,
...
...
@@ -205,6 +210,16 @@ public final class C {
public
static
final
int
ENCODING_PCM_FLOAT
=
AudioFormat
.
ENCODING_PCM_FLOAT
;
/** @see AudioFormat#ENCODING_MP3 */
public
static
final
int
ENCODING_MP3
=
AudioFormat
.
ENCODING_MP3
;
/** @see AudioFormat#ENCODING_AAC_LC */
public
static
final
int
ENCODING_AAC_LC
=
AudioFormat
.
ENCODING_AAC_LC
;
/** @see AudioFormat#ENCODING_AAC_HE_V1 */
public
static
final
int
ENCODING_AAC_HE_V1
=
AudioFormat
.
ENCODING_AAC_HE_V1
;
/** @see AudioFormat#ENCODING_AAC_HE_V2 */
public
static
final
int
ENCODING_AAC_HE_V2
=
AudioFormat
.
ENCODING_AAC_HE_V2
;
/** @see AudioFormat#ENCODING_AAC_XHE */
public
static
final
int
ENCODING_AAC_XHE
=
AudioFormat
.
ENCODING_AAC_XHE
;
/** @see AudioFormat#ENCODING_AAC_ELD */
public
static
final
int
ENCODING_AAC_ELD
=
AudioFormat
.
ENCODING_AAC_ELD
;
/** @see AudioFormat#ENCODING_AC3 */
public
static
final
int
ENCODING_AC3
=
AudioFormat
.
ENCODING_AC3
;
/** @see AudioFormat#ENCODING_E_AC3 */
...
...
library/common/src/main/java/com/google/android/exoplayer2/util/CodecSpecificDataUtil.java
View file @
7c2889c6
...
...
@@ -26,6 +26,8 @@ import java.util.List;
/** Provides utilities for handling various types of codec-specific data. */
public
final
class
CodecSpecificDataUtil
{
private
static
final
String
TAG
=
"CodecSpecificDataUtil"
;
/** Holds sample format information for AAC audio. */
public
static
final
class
AacConfig
{
...
...
@@ -43,6 +45,24 @@ public final class CodecSpecificDataUtil {
}
}
// AAC audio sample count constants assume the frameLengthFlag in the access unit is 0.
/**
* Number of raw audio samples that are produced per channel when decoding an AAC LC access unit.
*/
public
static
final
int
AAC_LC_AUDIO_SAMPLE_COUNT
=
1024
;
/**
* Number of raw audio samples that are produced per channel when decoding an AAC XHE access unit.
*/
public
static
final
int
AAC_XHE_AUDIO_SAMPLE_COUNT
=
AAC_LC_AUDIO_SAMPLE_COUNT
;
/**
* Number of raw audio samples that are produced per channel when decoding an AAC HE access unit.
*/
public
static
final
int
AAC_HE_AUDIO_SAMPLE_COUNT
=
2048
;
/**
* Number of raw audio samples that are produced per channel when decoding an AAC LD access unit.
*/
public
static
final
int
AAC_LD_AUDIO_SAMPLE_COUNT
=
512
;
private
static
final
byte
[]
NAL_START_CODE
=
new
byte
[]
{
0
,
0
,
0
,
1
};
private
static
final
int
AUDIO_SPECIFIC_CONFIG_FREQUENCY_INDEX_ARBITRARY
=
0xF
;
...
...
@@ -97,10 +117,14 @@ public final class CodecSpecificDataUtil {
private
static
final
int
AUDIO_OBJECT_TYPE_AAC_SBR
=
5
;
// Error Resilient Bit-Sliced Arithmetic Coding.
private
static
final
int
AUDIO_OBJECT_TYPE_AAC_ER_BSAC
=
22
;
// Enhanced low delay.
private
static
final
int
AUDIO_OBJECT_TYPE_AAC_ELD
=
23
;
// Parametric Stereo.
private
static
final
int
AUDIO_OBJECT_TYPE_AAC_PS
=
29
;
// Escape code for extended audio object types.
private
static
final
int
AUDIO_OBJECT_TYPE_ESCAPE
=
31
;
// Extended high efficiency.
private
static
final
int
AUDIO_OBJECT_TYPE_AAC_XHE
=
42
;
private
CodecSpecificDataUtil
()
{}
...
...
@@ -230,6 +254,25 @@ public final class CodecSpecificDataUtil {
return
specificConfig
;
}
/** Returns the encoding for a given AAC audio object type. */
@C
.
Encoding
public
static
int
getEncodingForAacAudioObjectType
(
int
audioObjectType
)
{
switch
(
audioObjectType
)
{
case
AUDIO_OBJECT_TYPE_AAC_LC:
return
C
.
ENCODING_AAC_LC
;
case
AUDIO_OBJECT_TYPE_AAC_SBR:
return
C
.
ENCODING_AAC_HE_V1
;
case
AUDIO_OBJECT_TYPE_AAC_PS:
return
C
.
ENCODING_AAC_HE_V2
;
case
AUDIO_OBJECT_TYPE_AAC_XHE:
return
C
.
ENCODING_AAC_XHE
;
case
AUDIO_OBJECT_TYPE_AAC_ELD:
return
C
.
ENCODING_AAC_ELD
;
default
:
return
C
.
ENCODING_INVALID
;
}
}
/**
* Parses an ALAC AudioSpecificConfig (i.e. an <a
* href="https://github.com/macosforge/alac/blob/master/ALACMagicCookieDescription.txt">ALACSpecificConfig</a>).
...
...
@@ -406,7 +449,10 @@ public final class CodecSpecificDataUtil {
private
static
void
parseGaSpecificConfig
(
ParsableBitArray
bitArray
,
int
audioObjectType
,
int
channelConfiguration
)
{
bitArray
.
skipBits
(
1
);
// frameLengthFlag.
boolean
frameLengthFlag
=
bitArray
.
readBit
();
if
(
frameLengthFlag
)
{
Log
.
w
(
TAG
,
"Unexpected AAC frameLengthFlag = 1"
);
}
boolean
dependsOnCoreDecoder
=
bitArray
.
readBit
();
if
(
dependsOnCoreDecoder
)
{
bitArray
.
skipBits
(
14
);
// coreCoderDelay.
...
...
library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java
View file @
7c2889c6
...
...
@@ -28,6 +28,7 @@ import com.google.android.exoplayer2.Format;
import
com.google.android.exoplayer2.PlaybackParameters
;
import
com.google.android.exoplayer2.audio.AudioProcessor.UnhandledAudioFormatException
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.CodecSpecificDataUtil
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Util
;
import
java.nio.ByteBuffer
;
...
...
@@ -1217,6 +1218,21 @@ public final class DefaultAudioSink implements AudioSink {
case
C
.
ENCODING_MP3
:
// Maximum bitrate for MPEG-1 layer III: 320 kbit/s.
return
320
*
1000
/
8
;
case
C
.
ENCODING_AAC_LC
:
// Maximum bitrates for AAC profiles from the Fraunhofer FDK AAC encoder documentation:
// https://cs.android.com/android/platform/superproject/+/android-9.0.0_r8:external/aac/libAACenc/include/aacenc_lib.h;l=718
return
800
*
1000
/
8
;
case
C
.
ENCODING_AAC_HE_V1
:
return
128
*
1000
/
8
;
case
C
.
ENCODING_AAC_HE_V2
:
return
56
*
1000
/
8
;
case
C
.
ENCODING_AAC_XHE
:
// Fraunhofer documentation says "500 kbit/s and above" for stereo, so we use a rate
// generously above the 500 kbit/s level.
return
2048
*
1000
/
8
;
case
C
.
ENCODING_AAC_ELD
:
// Fraunhofer documentation shows AAC-ELD as useful for up to ~ 64 kbit/s.
return
64
*
1000
/
8
;
case
C
.
ENCODING_AC3
:
return
640
*
1000
/
8
;
case
C
.
ENCODING_E_AC3
:
...
...
@@ -1248,6 +1264,15 @@ public final class DefaultAudioSink implements AudioSink {
switch
(
encoding
)
{
case
C
.
ENCODING_MP3
:
return
MpegAudioUtil
.
parseMpegAudioFrameSampleCount
(
buffer
.
get
(
buffer
.
position
()));
case
C
.
ENCODING_AAC_LC
:
return
CodecSpecificDataUtil
.
AAC_LC_AUDIO_SAMPLE_COUNT
;
case
C
.
ENCODING_AAC_HE_V1
:
case
C
.
ENCODING_AAC_HE_V2
:
return
CodecSpecificDataUtil
.
AAC_HE_AUDIO_SAMPLE_COUNT
;
case
C
.
ENCODING_AAC_XHE
:
return
CodecSpecificDataUtil
.
AAC_XHE_AUDIO_SAMPLE_COUNT
;
case
C
.
ENCODING_AAC_ELD
:
return
CodecSpecificDataUtil
.
AAC_LD_AUDIO_SAMPLE_COUNT
;
case
C
.
ENCODING_DTS
:
case
C
.
ENCODING_DTS_HD
:
return
DtsUtil
.
parseDtsAudioSampleCount
(
buffer
);
...
...
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