Ac3Util
@UnstableApi
class Ac3Util
Utility methods for parsing Dolby TrueHD and (E-)AC-3 syncframes. (E-)AC-3 parsing follows the definition in ETSI TS 102 366 V1.4.1.
Summary
Nested types |
|---|
class Ac3Util.SyncFrameInfoHolds sample format information as presented by a syncframe header. |
@DocumentedAC3 stream types. |
Constants |
|
|---|---|
const Int |
AC3_MAX_RATE_BYTES_PER_SECOND = 80000Maximum rate for an AC-3 audio stream, in bytes per second. |
const Int |
E_AC3_MAX_RATE_BYTES_PER_SECOND = 768000Maximum rate for an E-AC-3 audio stream, in bytes per second. |
const Int |
TRUEHD_MAX_RATE_BYTES_PER_SECOND = 3062500Maximum rate for a TrueHD audio stream, in bytes per second. |
const Int |
The number of samples to store in each output chunk when rechunking TrueHD streams. |
const Int |
The number of bytes that must be parsed from a TrueHD syncframe to calculate the sample count. |
Public functions |
|
|---|---|
java-static Int |
findTrueHdSyncframeOffset(buffer: ByteBuffer!)Returns the offset relative to the buffer's position of the start of a TrueHD syncframe, or |
java-static Format! |
parseAc3AnnexFFormat(Returns the AC-3 format given |
java-static Int |
parseAc3SyncframeAudioSampleCount(buffer: ByteBuffer!)Reads the number of audio samples represented by the given (E-)AC-3 syncframe. |
java-static Ac3Util.SyncFrameInfo! |
Returns (E-)AC-3 format information given |
java-static Int |
parseAc3SyncframeSize(data: ByteArray!)Returns the size in bytes of the given (E-)AC-3 syncframe. |
java-static Format! |
parseEAc3AnnexFFormat(Returns the E-AC-3 format given |
java-static Int |
parseTrueHdSyncframeAudioSampleCount(syncframe: ByteArray!)Returns the number of audio samples represented by the given TrueHD syncframe, or 0 if the buffer is not the start of a syncframe. |
java-static Int |
parseTrueHdSyncframeAudioSampleCount(buffer: ByteBuffer!, offset: Int)Reads the number of audio samples represented by a TrueHD syncframe. |
Constants
AC3_MAX_RATE_BYTES_PER_SECOND
const val AC3_MAX_RATE_BYTES_PER_SECOND = 80000: Int
Maximum rate for an AC-3 audio stream, in bytes per second.
E_AC3_MAX_RATE_BYTES_PER_SECOND
const val E_AC3_MAX_RATE_BYTES_PER_SECOND = 768000: Int
Maximum rate for an E-AC-3 audio stream, in bytes per second.
TRUEHD_MAX_RATE_BYTES_PER_SECOND
const val TRUEHD_MAX_RATE_BYTES_PER_SECOND = 3062500: Int
Maximum rate for a TrueHD audio stream, in bytes per second.
TRUEHD_RECHUNK_SAMPLE_COUNT
const val TRUEHD_RECHUNK_SAMPLE_COUNT = 16: Int
The number of samples to store in each output chunk when rechunking TrueHD streams. The number of samples extracted from the container corresponding to one syncframe must be an integer multiple of this value.
TRUEHD_SYNCFRAME_PREFIX_LENGTH
const val TRUEHD_SYNCFRAME_PREFIX_LENGTH = 10: Int
The number of bytes that must be parsed from a TrueHD syncframe to calculate the sample count.
Public functions
findTrueHdSyncframeOffset
java-static fun findTrueHdSyncframeOffset(buffer: ByteBuffer!): Int
Returns the offset relative to the buffer's position of the start of a TrueHD syncframe, or INDEX_UNSET if no syncframe was found. The buffer's position is not modified.
| Parameters | |
|---|---|
buffer: ByteBuffer! |
The |
| Returns | |
|---|---|
Int |
The offset relative to the buffer's position of the start of a TrueHD syncframe, or |
parseAc3AnnexFFormat
java-static fun parseAc3AnnexFFormat(
data: ParsableByteArray!,
trackId: String!,
language: String?,
drmInitData: DrmInitData?
): Format!
Returns the AC-3 format given data containing the AC3SpecificBox according to Annex F. The reading position of data will be modified.
| Parameters | |
|---|---|
data: ParsableByteArray! |
The AC3SpecificBox to parse. |
trackId: String! |
The track identifier to set on the format. |
language: String? |
The language to set on the format, or |
drmInitData: DrmInitData? |
|
| Returns | |
|---|---|
Format! |
The AC-3 format parsed from data in the header. |
parseAc3SyncframeAudioSampleCount
java-static fun parseAc3SyncframeAudioSampleCount(buffer: ByteBuffer!): Int
Reads the number of audio samples represented by the given (E-)AC-3 syncframe. The buffer's position is not modified.
| Parameters | |
|---|---|
buffer: ByteBuffer! |
The |
| Returns | |
|---|---|
Int |
The number of audio samples represented by the syncframe. |
parseAc3SyncframeInfo
java-static fun parseAc3SyncframeInfo(data: ParsableBitArray!): Ac3Util.SyncFrameInfo!
Returns (E-)AC-3 format information given data containing a syncframe. The reading position of data will be modified.
| Parameters | |
|---|---|
data: ParsableBitArray! |
The data to parse, positioned at the start of the syncframe. |
| Returns | |
|---|---|
Ac3Util.SyncFrameInfo! |
The (E-)AC-3 format data parsed from the header. |
parseAc3SyncframeSize
java-static fun parseAc3SyncframeSize(data: ByteArray!): Int
Returns the size in bytes of the given (E-)AC-3 syncframe.
| Parameters | |
|---|---|
data: ByteArray! |
The syncframe to parse. |
| Returns | |
|---|---|
Int |
The syncframe size in bytes. |
parseEAc3AnnexFFormat
java-static fun parseEAc3AnnexFFormat(
data: ParsableByteArray!,
trackId: String!,
language: String?,
drmInitData: DrmInitData?
): Format!
Returns the E-AC-3 format given data containing the EC3SpecificBox according to Annex F. The reading position of data will be modified.
| Parameters | |
|---|---|
data: ParsableByteArray! |
The EC3SpecificBox to parse. |
trackId: String! |
The track identifier to set on the format. |
language: String? |
The language to set on the format, or |
drmInitData: DrmInitData? |
|
| Returns | |
|---|---|
Format! |
The E-AC-3 format parsed from data in the header. |
parseTrueHdSyncframeAudioSampleCount
java-static fun parseTrueHdSyncframeAudioSampleCount(syncframe: ByteArray!): Int
Returns the number of audio samples represented by the given TrueHD syncframe, or 0 if the buffer is not the start of a syncframe.
| Parameters | |
|---|---|
syncframe: ByteArray! |
The bytes from which to read the syncframe. Must be at least |
| Returns | |
|---|---|
Int |
The number of audio samples represented by the syncframe, or 0 if the buffer doesn't contain the start of a syncframe. |
parseTrueHdSyncframeAudioSampleCount
java-static fun parseTrueHdSyncframeAudioSampleCount(buffer: ByteBuffer!, offset: Int): Int
Reads the number of audio samples represented by a TrueHD syncframe. The buffer's position is not modified.
| Parameters | |
|---|---|
buffer: ByteBuffer! |
The |
offset: Int |
The offset of the start of the syncframe relative to the buffer's position. |
| Returns | |
|---|---|
Int |
The number of audio samples represented by the syncframe. |