Index: media/ffmpeg/ffmpeg_common.cc |
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc |
index 772b41dbf6cc77b1c46ada545add2c18d94d4378..608b5bee9074d857f0cfa55d8f80e873d3a8f9ff 100644 |
--- a/media/ffmpeg/ffmpeg_common.cc |
+++ b/media/ffmpeg/ffmpeg_common.cc |
@@ -67,6 +67,12 @@ static AudioCodec CodecIDToAudioCodec(AVCodecID codec_id) { |
switch (codec_id) { |
case AV_CODEC_ID_AAC: |
return kCodecAAC; |
+#if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
+ case AV_CODEC_ID_AC3: |
+ return kCodecAC3; |
+ case AV_CODEC_ID_EAC3: |
+ return kCodecEAC3; |
+#endif |
case AV_CODEC_ID_MP3: |
return kCodecMP3; |
case AV_CODEC_ID_VORBIS: |
@@ -302,8 +308,12 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context, |
AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); |
- SampleFormat sample_format = AVSampleFormatToSampleFormat( |
- codec_context->sample_fmt, codec_context->codec_id); |
+ // For AC3/EAC3, FFmpeg does not fill |sample_fmt|. |
+ SampleFormat sample_format = |
+ (codec == kCodecAC3 || codec == kCodecEAC3) |
+ ? kSampleFormatS16 |
+ : AVSampleFormatToSampleFormat(codec_context->sample_fmt, |
+ codec_context->codec_id); |
ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout( |
codec_context->channel_layout, codec_context->channels); |
@@ -352,8 +362,7 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context, |
is_encrypted, |
seek_preroll, |
codec_context->delay); |
- |
- if (codec != kCodecOpus) { |
+ if (codec != kCodecOpus && codec != kCodecAC3 && codec != kCodecEAC3) { |
DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8, |
config->bits_per_channel()); |
} |