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

Unified Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: another fix for unreliable ffmpeg channels vs layout Created 3 years, 7 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
« no previous file with comments | « media/ffmpeg/ffmpeg_common_unittest.cc ('k') | media/formats/webm/webm_audio_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_audio_decoder.cc
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
index 6f3af9322d9deaae52eb78dcf72dc81116fa9554..3d7fdd5864a70de5b484da71fdb76aac1be433d2 100644
--- a/media/filters/ffmpeg_audio_decoder.cc
+++ b/media/filters/ffmpeg_audio_decoder.cc
@@ -232,10 +232,9 @@ bool FFmpegAudioDecoder::FFmpegDecode(
bool is_sample_rate_change =
av_frame_->sample_rate != config_.samples_per_second();
- bool is_config_stale =
- is_sample_rate_change ||
- channels != ChannelLayoutToChannelCount(config_.channel_layout()) ||
- av_frame_->format != av_sample_format_;
+ bool is_config_stale = is_sample_rate_change ||
+ channels != config_.channels() ||
+ av_frame_->format != av_sample_format_;
// Only consider channel layout changes for AAC.
// TODO(tguilbert, dalecurtis): Due to http://crbug.com/600538 we need to
@@ -255,8 +254,7 @@ bool FFmpegAudioDecoder::FFmpegDecode(
<< config_.samples_per_second()
<< ", ChannelLayout: " << channel_layout << " vs "
<< config_.channel_layout() << ", Channels: " << channels
- << " vs "
- << ChannelLayoutToChannelCount(config_.channel_layout());
+ << " vs " << config_.channels();
config_.Initialize(config_.codec(), config_.sample_format(),
channel_layout, av_frame_->sample_rate,
config_.extra_data(), config_.encryption_scheme(),
@@ -269,7 +267,7 @@ bool FFmpegAudioDecoder::FFmpegDecode(
<< "Unsupported midstream configuration change!"
<< " Sample Rate: " << av_frame_->sample_rate << " vs "
<< config_.samples_per_second() << ", Channels: " << channels
- << " vs " << ChannelLayoutToChannelCount(config_.channel_layout())
+ << " vs " << config_.channels()
<< ", Sample Format: " << av_frame_->format << " vs "
<< av_sample_format_;
// This is an unrecoverable error, so bail out.
@@ -283,8 +281,7 @@ bool FFmpegAudioDecoder::FFmpegDecode(
output = reinterpret_cast<AudioBuffer*>(
av_buffer_get_opaque(av_frame_->buf[0]));
- DCHECK_EQ(ChannelLayoutToChannelCount(config_.channel_layout()),
- output->channel_count());
+ DCHECK_EQ(config_.channels(), output->channel_count());
const int unread_frames = output->frame_count() - av_frame_->nb_samples;
DCHECK_GE(unread_frames, 0);
if (unread_frames > 0)
@@ -349,11 +346,9 @@ bool FFmpegAudioDecoder::ConfigureDecoder(const AudioDecoderConfig& config) {
av_frame_.reset(av_frame_alloc());
av_sample_format_ = codec_context_->sample_fmt;
- if (codec_context_->channels !=
- ChannelLayoutToChannelCount(config.channel_layout())) {
+ if (codec_context_->channels != config.channels()) {
MEDIA_LOG(ERROR, media_log_)
- << "Audio configuration specified "
- << ChannelLayoutToChannelCount(config.channel_layout())
+ << "Audio configuration specified " << config.channels()
<< " channels, but FFmpeg thinks the file contains "
<< codec_context_->channels << " channels";
ReleaseFFmpegResources();
@@ -422,9 +417,11 @@ int FFmpegAudioDecoder::GetAudioBuffer(struct AVCodecContext* s,
DCHECK_GE(frames_required, frame->nb_samples);
ChannelLayout channel_layout =
- ChannelLayoutToChromeChannelLayout(s->channel_layout, s->channels);
+ config_.channel_layout() == CHANNEL_LAYOUT_DISCRETE
+ ? CHANNEL_LAYOUT_DISCRETE
+ : ChannelLayoutToChromeChannelLayout(s->channel_layout, s->channels);
- if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED) {
+ if (config_.channel_layout() == CHANNEL_LAYOUT_UNSUPPORTED) {
DLOG(ERROR) << "Unsupported channel layout.";
return AVERROR(EINVAL);
}
« no previous file with comments | « media/ffmpeg/ffmpeg_common_unittest.cc ('k') | media/formats/webm/webm_audio_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698