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

Unified Diff: media/ffmpeg/ffmpeg_common.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: +tests 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 91836b87ec573b89ff6e8c50d6ce7e31cf0add1d..41ec439d11db48bce5eac5f2b6e8d6bfdc605b63 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -324,8 +324,17 @@ bool AVCodecContextToAudioDecoderConfig(
SampleFormat sample_format = AVSampleFormatToSampleFormat(
codec_context->sample_fmt, codec_context->codec_id);
- ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout(
- codec_context->channel_layout, codec_context->channels);
+ // If it is an Opus Ambisonics file, always use CHANNEL_LAYOUT_DISCRETE
+ int is_opus_ambisonics = 0;
DaleCurtis 2017/03/20 17:38:58 bool
flim-chromium 2017/03/22 06:20:51 Also renamed to is_opus_discrete to remove focus f
flim-chromium 2017/03/22 06:20:51 Done.
+ if (codec == kCodecOpus && codec_context->extradata_size >= 19) {
+ int mapping_family = codec_context->extradata[18];
+ is_opus_ambisonics = mapping_family == 2;
+ }
+ ChannelLayout channel_layout = is_opus_ambisonics
+ ? CHANNEL_LAYOUT_DISCRETE
DaleCurtis 2017/03/20 17:38:58 This should also include channels > kMaxConcurrent
flim-chromium 2017/03/22 06:20:51 Done. Refactored slightly to avoid having to redef
+ : ChannelLayoutToChromeChannelLayout(
+ codec_context->channel_layout,
+ codec_context->channels);
int sample_rate = codec_context->sample_rate;
switch (codec) {
@@ -371,6 +380,7 @@ bool AVCodecContextToAudioDecoderConfig(
config->Initialize(codec, sample_format, channel_layout, sample_rate,
extra_data, encryption_scheme, seek_preroll,
codec_context->delay);
+ config->set_channels_for_discrete(codec_context->channels);
#if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
// These are bitstream formats unknown to ffmpeg, so they don't have
@@ -419,8 +429,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