Index: media/ffmpeg/ffmpeg_common.cc |
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc |
index 3d3a8b89957d36be73c1480b1a63788dee3049d9..1794df152a3c40a8f0cbbc9d0d352dd45f864c8a 100644 |
--- a/media/ffmpeg/ffmpeg_common.cc |
+++ b/media/ffmpeg/ffmpeg_common.cc |
@@ -14,6 +14,7 @@ |
#include "media/base/decoder_buffer.h" |
#include "media/base/video_decoder_config.h" |
#include "media/base/video_util.h" |
+#include "media/media_features.h" |
namespace media { |
@@ -67,6 +68,12 @@ static AudioCodec CodecIDToAudioCodec(AVCodecID codec_id) { |
switch (codec_id) { |
case AV_CODEC_ID_AAC: |
return kCodecAAC; |
+#if BUILDFLAG(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: |
@@ -323,6 +330,18 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context, |
sample_rate = 48000; |
} |
+#if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
+ // For AC3/EAC3 we enable only demuxing, but not decoding, so FFmpeg does not |
+ // fill |sample_fmt|. |
+ if (codec == kCodecAC3 || codec == kCodecEAC3) { |
+ // The spec for AC3/EAC3 audio is ETSI TS 102 366. According to sections |
+ // F.3.1 and F.5.1 in that spec the sample_format for AC3/EAC3 must be 16. |
+ sample_format = kSampleFormatS16; |
+ } |
+#else |
+ DCHECK(codec != kCodecAC3 && codec != kCodecEAC3); |
+#endif |
+ |
base::TimeDelta seek_preroll; |
if (codec_context->seek_preroll > 0) { |
seek_preroll = base::TimeDelta::FromMicroseconds( |
@@ -352,8 +371,9 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context, |
is_encrypted, |
seek_preroll, |
codec_context->delay); |
- |
- if (codec != kCodecOpus) { |
+ if (codec != kCodecOpus && codec != kCodecAC3 && codec != kCodecEAC3) { |
ddorwin
2016/01/08 18:11:02
That leaves this as the only code in this file not
servolk
2016/01/08 20:02:32
Done (and converted to switch to avoid splitting t
|
+ // Verify that AudioConfig.bits_per_channel was calculated correctly for |
+ // codecs that have |sample_fmt| set by FFmpeg. |
DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8, |
config->bits_per_channel()); |
} |