Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Unified Diff: media/ffmpeg/ffmpeg_common.cc

Issue 812643005: Re-add AC3/EAC3 audio demuxing support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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());
}

Powered by Google App Engine
This is Rietveld 408576698