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

Unified Diff: media/ffmpeg/ffmpeg_common.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: If WebAudio is not used and the input channel layout is discrete, default to the hardware layout Created 3 years, 9 months 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 251fbdfabf440b52f65fb6b36c3fc6cf7317e1e3..ab2de16e1f80edb410cb57c529b393470a7e7a5f 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -327,6 +327,16 @@ bool AVCodecContextToAudioDecoderConfig(
ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout(
codec_context->channel_layout, codec_context->channels);
+ // If it is an Opus channel mapping with discrete channels, or there are more
+ // channels than supported in the renderer, use CHANNEL_LAYOUT_DISCRETE.
+ bool is_opus_discrete = false;
+ if (codec == kCodecOpus && codec_context->extradata_size >= 19) {
+ int mapping_family = codec_context->extradata[18];
+ is_opus_discrete = mapping_family == 2;
+ }
+ if (is_opus_discrete || channel_layout == CHANNEL_LAYOUT_UNSUPPORTED)
DaleCurtis 2017/03/29 22:46:55 Do we need this || clause? Seems like we might all
flim-chromium 2017/03/30 19:35:10 Sorry, I misunderstood your original comment. Fixe
+ channel_layout = CHANNEL_LAYOUT_DISCRETE;
+
int sample_rate = codec_context->sample_rate;
switch (codec) {
// For AC3/EAC3 we enable only demuxing, but not decoding, so FFmpeg does
@@ -371,6 +381,7 @@ bool AVCodecContextToAudioDecoderConfig(
config->Initialize(codec, sample_format, channel_layout, sample_rate,
extra_data, encryption_scheme, seek_preroll,
codec_context->delay);
+ config->SetChannelsForDiscrete(codec_context->channels);
#if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
// These are bitstream formats unknown to ffmpeg, so they don't have
@@ -419,8 +430,7 @@ void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config,
// TODO(scherkus): should we set |channel_layout|? I'm not sure if FFmpeg uses
// said information to decode.
- codec_context->channels =
- ChannelLayoutToChannelCount(config.channel_layout());
+ codec_context->channels = config.channels();
codec_context->sample_rate = config.samples_per_second();
if (config.extra_data().empty()) {

Powered by Google App Engine
This is Rietveld 408576698