Chromium Code Reviews| Index: media/ffmpeg/ffmpeg_common.cc |
| diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc |
| index 3d3a8b89957d36be73c1480b1a63788dee3049d9..c581efc1b616f76a46a084ca562434b54a8143fa 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( |
| @@ -353,9 +372,19 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context, |
| seek_preroll, |
| codec_context->delay); |
| - if (codec != kCodecOpus) { |
| - DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8, |
| - config->bits_per_channel()); |
| + switch (codec) { |
| + case kCodecOpus: |
| +#if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| + case kCodecAC3: |
| + case kCodecEAC3: |
| +#endif |
| + break; |
| + default: |
| + // Verify that AudioConfig.bits_per_channel was calculated correctly for |
|
ddorwin
2016/01/08 20:15:42
nit: Since we're not doing anything else, it might
servolk
2016/01/08 21:55:48
Done.
|
| + // codecs that have |sample_fmt| set by FFmpeg. |
| + DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8, |
| + config->bits_per_channel()); |
| + break; |
| } |
| return true; |