@UnstableApi
public final class DtsUtil


Utility methods for parsing DTS frames.

Summary

Nested types

@Documented
@Retention(value = SOURCE)
@Target(value = TYPE_USE)
@StringDef(value = [MimeTypes.AUDIO_DTS, MimeTypes.AUDIO_DTS_EXPRESS, MimeTypes.AUDIO_DTS_X])
public annotation DtsUtil.DtsAudioMimeType

The possible MIME types for DTS that can be used.

public final class DtsUtil.DtsHeader

Information parsed from a DTS frame header.

@Documented
@Retention(value = SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
public annotation DtsUtil.FrameType

Frame types for a DTS stream.

Constants

static final int

Maximum bit-rate for a DTS Express audio stream, in bits per second.

static final int

Maximum rate for a DTS-HD audio stream, in bytes per second.

static final int

Maximum rate for a DTS audio stream, in bytes per second.

static final int

Represents 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

Returns the FrameType if word is a DTS sync word, otherwise FRAME_TYPE_UNKNOWN.

static int

Like parseDtsAudioSampleCount but reads from a ByteBuffer.

static int

Returns the number of audio samples represented by the given DTS Core frame.

static Format
parseDtsFormat(
    byte[] frame,
    @Nullable String trackId,
    @Nullable String language,
    @C.RoleFlags int roleFlags,
    @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.

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.

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 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.

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_CORE

public static final int FRAME_TYPE_CORE = 1

Represents a DTS core frame.

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.

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 ByteBuffer from which to read.

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,
    @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.

@Nullable DrmInitData drmInitData

DrmInitData to be included in the format.

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 DtsHeader data extracted from the header.

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 AtomicInteger containing the last read UHD audio chunk ID from a synchronized frame, or zero if unset. This parameter is both an input and output parameter. In synchronized frames, the input value is not used; instead, the parameter is set to the current UHD audio chunk ID, which becomes the output value. For non-synchronized frames, it is used without any modification.

Returns
DtsUtil.DtsHeader

The DtsHeader data extracted from the header.

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.