Skip to content

Commit 127d0b5

Browse files
copybara-githubSheenaChhabra
authored andcommitted
Merge pull request #1011 from cedricxperi:dts-lbr-hls-bitrate-unknown-fix
PiperOrigin-RevId: 603302863 (cherry picked from commit f85860c)
1 parent ad519e2 commit 127d0b5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,15 @@ public void configure(Format inputFormat, int specifiedBufferSize, @Nullable int
765765
"Invalid output channel config (mode=" + outputMode + ") for: " + inputFormat,
766766
inputFormat);
767767
}
768+
769+
// Replace unknown bitrate by maximum allowed bitrate for DTS Express to avoid allocating an
770+
// AudioTrack buffer for the much larger maximum bitrate of the underlying DTS-HD encoding.
771+
int bitrate = inputFormat.bitrate;
772+
if (MimeTypes.AUDIO_DTS_EXPRESS.equals(inputFormat.sampleMimeType)
773+
&& bitrate == Format.NO_VALUE) {
774+
bitrate = DtsUtil.DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND;
775+
}
776+
768777
int bufferSize =
769778
specifiedBufferSize != 0
770779
? specifiedBufferSize
@@ -774,7 +783,7 @@ public void configure(Format inputFormat, int specifiedBufferSize, @Nullable int
774783
outputMode,
775784
outputPcmFrameSize != C.LENGTH_UNSET ? outputPcmFrameSize : 1,
776785
outputSampleRate,
777-
inputFormat.bitrate,
786+
bitrate,
778787
enableAudioTrackPlaybackParams ? MAX_PLAYBACK_SPEED : DEFAULT_PLAYBACK_SPEED);
779788
offloadDisabledUntilNextConfiguration = false;
780789
Configuration pendingConfiguration =

‎libraries/extractor/src/main/java/androidx/media3/extractor/DtsUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ private DtsHeader(
143143
/** Maximum rate for a DTS-HD audio stream, in bytes per second. */
144144
public static final int DTS_HD_MAX_RATE_BYTES_PER_SECOND = 18000 * 1000 / 8;
145145

146+
/** Maximum bit-rate for a DTS Express audio stream, in bits per second. */
147+
public static final int DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND = 768000;
148+
146149
/**
147150
* DTS Core Syncword (in different Endianness). See ETSI TS 102 114 V1.6.1 (2019-08), Section 5.3.
148151
*/

0 commit comments

Comments
 (0)