| Index: media/ffmpeg/ffmpeg_common.cc
|
| diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
|
| index 3d3a8b89957d36be73c1480b1a63788dee3049d9..b65ceddeb0fd17185f15843196e3feda31fe6d26 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:
|
| @@ -309,18 +316,37 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context,
|
| codec_context->channel_layout, codec_context->channels);
|
|
|
| int sample_rate = codec_context->sample_rate;
|
| - if (codec == kCodecOpus) {
|
| - // |codec_context->sample_fmt| is not set by FFmpeg because Opus decoding is
|
| - // not enabled in FFmpeg. It doesn't matter what value is set here, so long
|
| - // as it's valid, the true sample format is selected inside the decoder.
|
| - sample_format = kSampleFormatF32;
|
| -
|
| - // Always use 48kHz for OPUS. Technically we should match to the highest
|
| - // supported hardware sample rate among [8, 12, 16, 24, 48] kHz, but we
|
| - // don't know the hardware sample rate at this point and those rates are
|
| - // rarely used for output. See the "Input Sample Rate" section of the spec:
|
| - // http://tools.ietf.org/html/draft-terriberry-oggopus-01#page-11
|
| - sample_rate = 48000;
|
| + switch (codec) {
|
| + case kCodecOpus:
|
| + // |codec_context->sample_fmt| is not set by FFmpeg because Opus decoding
|
| + // is not enabled in FFmpeg. It doesn't matter what value is set here, so
|
| + // long as it's valid, the true sample format is selected inside the
|
| + // decoder.
|
| + sample_format = kSampleFormatF32;
|
| +
|
| + // Always use 48kHz for OPUS. Technically we should match to the highest
|
| + // supported hardware sample rate among [8, 12, 16, 24, 48] kHz, but we
|
| + // don't know the hardware sample rate at this point and those rates are
|
| + // rarely used for output. See the "Input Sample Rate" section of the
|
| + // spec: http://tools.ietf.org/html/draft-terriberry-oggopus-01#page-11
|
| + sample_rate = 48000;
|
| + break;
|
| +
|
| + // For AC3/EAC3 we enable only demuxing, but not decoding, so FFmpeg does
|
| + // not fill |sample_fmt|.
|
| + case kCodecAC3:
|
| + case kCodecEAC3:
|
| +#if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
|
| + // 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
|
| + NOTREACHED();
|
| +#endif
|
| + break;
|
| +
|
| + default:
|
| + break;
|
| }
|
|
|
| base::TimeDelta seek_preroll;
|
| @@ -353,9 +379,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());
|
| + // Verify that AudioConfig.bits_per_channel was calculated correctly for
|
| + // codecs that have |sample_fmt| set by FFmpeg.
|
| + switch (codec) {
|
| + case kCodecOpus:
|
| +#if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
|
| + case kCodecAC3:
|
| + case kCodecEAC3:
|
| +#endif
|
| + break;
|
| + default:
|
| + DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8,
|
| + config->bits_per_channel());
|
| + break;
|
| }
|
|
|
| return true;
|
|
|