Commit afd9014b by tonihei Committed by Toni

Ignore AC-3 tracks with fscod=3.

3 ("11") is the reserved code for fscod in AC3. The spec says that "If the
reserved code is indicated, the decoder should not attempt to decode audio and
should mute."

We currently throw an exception as we try to access an array with an invalid
index. Now ignoring the track instead by invalidating the format.

Issue:#5638
PiperOrigin-RevId: 240106255
parent 5da4c67c
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.audio; package com.google.android.exoplayer2.audio;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.audio.Ac3Util.SyncFrameInfo.StreamType; import com.google.android.exoplayer2.audio.Ac3Util.SyncFrameInfo.StreamType;
...@@ -55,10 +56,10 @@ public final class Ac3Util { ...@@ -55,10 +56,10 @@ public final class Ac3Util {
public static final int STREAM_TYPE_TYPE2 = 2; public static final int STREAM_TYPE_TYPE2 = 2;
/** /**
* The sample mime type of the bitstream. One of {@link MimeTypes#AUDIO_AC3} and * The sample mime type of the bitstream. One of {@link MimeTypes#AUDIO_AC3} and {@link
* {@link MimeTypes#AUDIO_E_AC3}. * MimeTypes#AUDIO_E_AC3}.
*/ */
public final String mimeType; @Nullable public final String mimeType;
/** /**
* The type of the stream if {@link #mimeType} is {@link MimeTypes#AUDIO_E_AC3}, or {@link * The type of the stream if {@link #mimeType} is {@link MimeTypes#AUDIO_E_AC3}, or {@link
* #STREAM_TYPE_UNDEFINED} otherwise. * #STREAM_TYPE_UNDEFINED} otherwise.
...@@ -82,7 +83,7 @@ public final class Ac3Util { ...@@ -82,7 +83,7 @@ public final class Ac3Util {
public final int sampleCount; public final int sampleCount;
private SyncFrameInfo( private SyncFrameInfo(
String mimeType, @Nullable String mimeType,
@StreamType int streamType, @StreamType int streamType,
int channelCount, int channelCount,
int sampleRate, int sampleRate,
...@@ -433,6 +434,11 @@ public final class Ac3Util { ...@@ -433,6 +434,11 @@ public final class Ac3Util {
mimeType = MimeTypes.AUDIO_AC3; mimeType = MimeTypes.AUDIO_AC3;
data.skipBits(16 + 16); // syncword, crc1 data.skipBits(16 + 16); // syncword, crc1
int fscod = data.readBits(2); int fscod = data.readBits(2);
if (fscod == 3) {
// fscod '11' indicates that the decoder should not attempt to decode audio. We invalidate
// the mime type to prevent association with a renderer.
mimeType = null;
}
int frmsizecod = data.readBits(6); int frmsizecod = data.readBits(6);
frameSize = getAc3SyncframeSize(fscod, frmsizecod); frameSize = getAc3SyncframeSize(fscod, frmsizecod);
data.skipBits(5 + 3); // bsid, bsmod data.skipBits(5 + 3); // bsid, bsmod
...@@ -446,7 +452,8 @@ public final class Ac3Util { ...@@ -446,7 +452,8 @@ public final class Ac3Util {
if (acmod == 2) { if (acmod == 2) {
data.skipBits(2); // dsurmod data.skipBits(2); // dsurmod
} }
sampleRate = SAMPLE_RATE_BY_FSCOD[fscod]; sampleRate =
fscod < SAMPLE_RATE_BY_FSCOD.length ? SAMPLE_RATE_BY_FSCOD[fscod] : Format.NO_VALUE;
sampleCount = AC3_SYNCFRAME_AUDIO_SAMPLE_COUNT; sampleCount = AC3_SYNCFRAME_AUDIO_SAMPLE_COUNT;
lfeon = data.readBit(); lfeon = data.readBit();
channelCount = CHANNEL_COUNT_BY_ACMOD[acmod] + (lfeon ? 1 : 0); channelCount = CHANNEL_COUNT_BY_ACMOD[acmod] + (lfeon ? 1 : 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment