Merge pull request #1011 from cedricxperi:dts-lbr-hls-bitrate-unknown-fix

PiperOrigin-RevId: 603302863
This commit is contained in:
Copybara-Service 2024-02-01 02:09:02 -08:00
commit f85860c041
2 changed files with 13 additions and 1 deletions

View File

@ -765,6 +765,15 @@ public final class DefaultAudioSink implements AudioSink {
"Invalid output channel config (mode=" + outputMode + ") for: " + inputFormat,
inputFormat);
}
// Replace unknown bitrate by maximum allowed bitrate for DTS Express to avoid allocating an
// AudioTrack buffer for the much larger maximum bitrate of the underlying DTS-HD encoding.
int bitrate = inputFormat.bitrate;
if (MimeTypes.AUDIO_DTS_EXPRESS.equals(inputFormat.sampleMimeType)
&& bitrate == Format.NO_VALUE) {
bitrate = DtsUtil.DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND;
}
int bufferSize =
specifiedBufferSize != 0
? specifiedBufferSize
@ -774,7 +783,7 @@ public final class DefaultAudioSink implements AudioSink {
outputMode,
outputPcmFrameSize != C.LENGTH_UNSET ? outputPcmFrameSize : 1,
outputSampleRate,
inputFormat.bitrate,
bitrate,
enableAudioTrackPlaybackParams ? MAX_PLAYBACK_SPEED : DEFAULT_PLAYBACK_SPEED);
offloadDisabledUntilNextConfiguration = false;
Configuration pendingConfiguration =

View File

@ -143,6 +143,9 @@ public final class DtsUtil {
/** Maximum rate for a DTS-HD audio stream, in bytes per second. */
public static final int DTS_HD_MAX_RATE_BYTES_PER_SECOND = 18000 * 1000 / 8;
/** Maximum bit-rate for a DTS Express audio stream, in bits per second. */
public static final int DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND = 768000;
/**
* DTS Core Syncword (in different Endianness). See ETSI TS 102 114 V1.6.1 (2019-08), Section 5.3.
*/