DtsUtil
@UnstableApi
public final class DtsUtil
Utility methods for parsing DTS frames.
Summary
Nested types |
|---|
@DocumentedThe possible MIME types for DTS that can be used. |
public final class DtsUtil.DtsHeaderInformation parsed from a DTS frame header. |
@DocumentedFrame types for a DTS stream. |
Constants |
|
|---|---|
static final int |
DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND = 768000Maximum bit-rate for a DTS Express audio stream, in bits per second. |
static final int |
DTS_HD_MAX_RATE_BYTES_PER_SECOND = 2250000Maximum rate for a DTS-HD audio stream, in bytes per second. |
static final int |
DTS_MAX_RATE_BYTES_PER_SECOND = 192000Maximum rate for a DTS audio stream, in bytes per second. |
static final int |
FRAME_TYPE_CORE = 1Represents a DTS core frame. |
static final int |
Represents a DTS extension substream frame. |
static final int |
Represents a DTS UHD non-sync frame. |
static final int |
Represents a DTS UHD sync frame. |
static final int |
Represents a DTS frame for which type is unknown. |
Public methods |
|
|---|---|
static int |
getDtsFrameSize(byte[] data)Returns the size in bytes of the given DTS Core frame. |
static int |
@DtsUtil.FrameTypeReturns the |
static boolean |
isSampleDtsHd(ExtractorInput input, int sampleSize)Returns whether the sample data at the current |
static int |
parseDtsAudioSampleCount(ByteBuffer buffer)Like |
static int |
parseDtsAudioSampleCount(byte[] data)Returns the number of audio samples represented by the given DTS Core frame. |
static Format |
parseDtsFormat(Returns the DTS format given |
static DtsUtil.DtsHeader |
parseDtsHdHeader(byte[] header)Parses the |
static int |
parseDtsHdHeaderSize(byte[] headerPrefix)Returns the size of the extension substream header in a DTS-HD frame according to ETSI TS 102 114 V1.6.1 (2019-08), Section 7.5.2. |
static DtsUtil.DtsHeader |
parseDtsUhdHeader(byte[] header, AtomicInteger uhdAudioChunkId)Parses the |
static int |
parseDtsUhdHeaderSize(byte[] headerPrefix)Returns the size of frame header in a DTS-UHD(Profile 2) frame according to ETSI TS 103 491 V1.2.1 (2019-05), Section 6.4.3. |
Constants
DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND
public static final int DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND = 768000
Maximum bit-rate for a DTS Express audio stream, in bits per second.
DTS_HD_MAX_RATE_BYTES_PER_SECOND
public static final int DTS_HD_MAX_RATE_BYTES_PER_SECOND = 2250000
Maximum rate for a DTS-HD audio stream, in bytes per second.
DTS_MAX_RATE_BYTES_PER_SECOND
public static final int DTS_MAX_RATE_BYTES_PER_SECOND = 192000
Maximum rate for a DTS audio stream, in bytes per second.
DTS allows an 'open' bitrate, but we assume the maximum listed value: 1536 kbit/s.
FRAME_TYPE_EXTENSION_SUBSTREAM
public static final int FRAME_TYPE_EXTENSION_SUBSTREAM = 2
Represents a DTS extension substream frame.
FRAME_TYPE_UHD_NON_SYNC
public static final int FRAME_TYPE_UHD_NON_SYNC = 4
Represents a DTS UHD non-sync frame.
FRAME_TYPE_UHD_SYNC
public static final int FRAME_TYPE_UHD_SYNC = 3
Represents a DTS UHD sync frame.
FRAME_TYPE_UNKNOWN
public static final int FRAME_TYPE_UNKNOWN = 0
Represents a DTS frame for which type is unknown.
Public methods
getDtsFrameSize
public static int getDtsFrameSize(byte[] data)
Returns the size in bytes of the given DTS Core frame.
| Parameters | |
|---|---|
byte[] data |
The frame to parse. |
| Returns | |
|---|---|
int |
The frame's size in bytes. |
getFrameType
@DtsUtil.FrameType
public static int getFrameType(int word)
Returns the FrameType if word is a DTS sync word, otherwise FRAME_TYPE_UNKNOWN.
isSampleDtsHd
public static boolean isSampleDtsHd(ExtractorInput input, int sampleSize)
Returns whether the sample data at the current ExtractorInput is a DTS-HD sample.
| Throws | |
|---|---|
java.io.IOException |
parseDtsAudioSampleCount
public static int parseDtsAudioSampleCount(ByteBuffer buffer)
Like parseDtsAudioSampleCount but reads from a ByteBuffer. The buffer's position is not modified.
| Parameters | |
|---|---|
ByteBuffer buffer |
The |
| Returns | |
|---|---|
int |
The number of audio samples represented by the syncframe. |
parseDtsAudioSampleCount
public static int parseDtsAudioSampleCount(byte[] data)
Returns the number of audio samples represented by the given DTS Core frame.
| Parameters | |
|---|---|
byte[] data |
The frame to parse. |
| Returns | |
|---|---|
int |
The number of audio samples represented by the frame. |
parseDtsFormat
public static Format parseDtsFormat(
byte[] frame,
@Nullable String trackId,
@Nullable String language,
@C.RoleFlags int roleFlags,
String containerMimeType,
@Nullable DrmInitData drmInitData
)
Returns the DTS format given data containing the DTS Core frame according to ETSI TS 102 114 V1.6.1 (2019-08) subsections 5.3/5.4.
| Parameters | |
|---|---|
byte[] frame |
The DTS Core frame to parse. |
@Nullable String trackId |
The track identifier to set on the format. |
@Nullable String language |
The language to set on the format. |
@C.RoleFlags int roleFlags |
The role flags to set on the format. |
String containerMimeType |
The MIME type of the container to set on the format. |
@Nullable DrmInitData drmInitData |
|
| Returns | |
|---|---|
Format |
The DTS format parsed from data in the header. |
parseDtsHdHeader
public static DtsUtil.DtsHeader parseDtsHdHeader(byte[] header)
Parses the DtsHeader data from the extension substream header of a DTS-HD frame according to ETSI TS 102 114 V1.6.1 (2019-08), Section 7.5.2.
| Parameters | |
|---|---|
byte[] header |
The DTS-HD extension substream header to parse. |
| Returns | |
|---|---|
DtsUtil.DtsHeader |
The |
parseDtsHdHeaderSize
public static int parseDtsHdHeaderSize(byte[] headerPrefix)
Returns the size of the extension substream header in a DTS-HD frame according to ETSI TS 102 114 V1.6.1 (2019-08), Section 7.5.2.
| Parameters | |
|---|---|
byte[] headerPrefix |
A byte array containing at least the first 55 bits of a DTS-HD frame. |
| Returns | |
|---|---|
int |
Size of the DTS-HD frame header in bytes. |
parseDtsUhdHeader
public static DtsUtil.DtsHeader parseDtsUhdHeader(byte[] header, AtomicInteger uhdAudioChunkId)
Parses the DtsHeader data from the headers of a DTS-UHD(Profile 2) frame according to ETSI TS 103 491 V1.2.1 (2019-05), Section 6.4.3.
| Parameters | |
|---|---|
byte[] header |
The DTS-UHD header to parse. |
AtomicInteger uhdAudioChunkId |
An |
| Returns | |
|---|---|
DtsUtil.DtsHeader |
The |
parseDtsUhdHeaderSize
public static int parseDtsUhdHeaderSize(byte[] headerPrefix)
Returns the size of frame header in a DTS-UHD(Profile 2) frame according to ETSI TS 103 491 V1.2.1 (2019-05), Section 6.4.3.
| Parameters | |
|---|---|
byte[] headerPrefix |
A byte array containing at least the first 47 bits of a DTS-UHD frame. |
| Returns | |
|---|---|
int |
Size of the DTS-UHD frame header in bytes. |