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

Side by Side Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 1868983004: Fixing AudioBuffer params and channel layout bugs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Returning after pipeline error Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/ffmpeg_audio_decoder.h" 5 #include "media/filters/ffmpeg_audio_decoder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 packet.data += result; 293 packet.data += result;
294 294
295 scoped_refptr<AudioBuffer> output; 295 scoped_refptr<AudioBuffer> output;
296 296
297 bool config_changed = false; 297 bool config_changed = false;
298 if (frame_decoded) { 298 if (frame_decoded) {
299 const int channels = DetermineChannels(av_frame_.get()); 299 const int channels = DetermineChannels(av_frame_.get());
300 ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout( 300 ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout(
301 codec_context_->channel_layout, codec_context_->channels); 301 codec_context_->channel_layout, codec_context_->channels);
302 302
303 if (av_frame_->sample_rate != config_.samples_per_second() || 303 bool is_config_stale =
304 channel_layout != config_.channel_layout() || 304 av_frame_->sample_rate != config_.samples_per_second() ||
305 channels != ChannelLayoutToChannelCount(config_.channel_layout()) || 305 channels != ChannelLayoutToChannelCount(config_.channel_layout()) ||
306 av_frame_->format != av_sample_format_) { 306 av_frame_->format != av_sample_format_;
307
308 // Only consider channel layout changes for AAC.
309 // TODO(tguilbert, dalecurtis): Due to http://crbug.com/600538 we need to
310 // allow channel layout changes for the moment. See if ffmpeg is fixable.
chcunningham 2016/04/19 00:28:56 Just to confirm my understanding, we initially hav
tguilbert 2016/04/19 18:17:56 I do not know if this is a bug per-say in Ffmpeg.
311 if (config_.codec() == kCodecAAC)
312 is_config_stale |= channel_layout != config_.channel_layout();
313
314 if (is_config_stale) {
307 // Only allow midstream configuration changes for AAC. Sample format is 315 // Only allow midstream configuration changes for AAC. Sample format is
308 // not expected to change between AAC profiles. 316 // not expected to change between AAC profiles.
309 if (config_.codec() == kCodecAAC && 317 if (config_.codec() == kCodecAAC &&
310 av_frame_->format == av_sample_format_) { 318 av_frame_->format == av_sample_format_) {
311 MEDIA_LOG(DEBUG, media_log_) 319 MEDIA_LOG(DEBUG, media_log_)
312 << " Detected AAC midstream configuration change" 320 << " Detected AAC midstream configuration change"
313 << " PTS:" << buffer->timestamp().InMicroseconds() 321 << " PTS:" << buffer->timestamp().InMicroseconds()
314 << " Sample Rate: " << av_frame_->sample_rate << " vs " 322 << " Sample Rate: " << av_frame_->sample_rate << " vs "
315 << config_.samples_per_second() 323 << config_.samples_per_second()
316 << ", ChannelLayout: " << channel_layout << " vs " 324 << ", ChannelLayout: " << channel_layout << " vs "
317 << config_.channel_layout() << ", Channels: " << channels 325 << config_.channel_layout() << ", Channels: " << channels
318 << " vs " 326 << " vs "
319 << ChannelLayoutToChannelCount(config_.channel_layout()); 327 << ChannelLayoutToChannelCount(config_.channel_layout());
320 config_.Initialize(config_.codec(), config_.sample_format(), 328 config_.Initialize(config_.codec(), config_.sample_format(),
321 channel_layout, av_frame_->sample_rate, 329 channel_layout, av_frame_->sample_rate,
322 config_.extra_data(), config_.encryption_scheme(), 330 config_.extra_data(), config_.encryption_scheme(),
323 config_.seek_preroll(), config_.codec_delay()); 331 config_.seek_preroll(), config_.codec_delay());
324 config_changed = true; 332 config_changed = true;
325 ResetTimestampState(); 333 if (av_frame_->sample_rate != config_.samples_per_second())
334 ResetTimestampState();
326 } else { 335 } else {
327 MEDIA_LOG(ERROR, media_log_) 336 MEDIA_LOG(ERROR, media_log_)
328 << "Unsupported midstream configuration change!" 337 << "Unsupported midstream configuration change!"
329 << " Sample Rate: " << av_frame_->sample_rate << " vs " 338 << " Sample Rate: " << av_frame_->sample_rate << " vs "
330 << config_.samples_per_second() << ", Channels: " << channels 339 << config_.samples_per_second() << ", Channels: " << channels
331 << " vs " << ChannelLayoutToChannelCount(config_.channel_layout()) 340 << " vs " << ChannelLayoutToChannelCount(config_.channel_layout())
332 << ", Sample Format: " << av_frame_->format << " vs " 341 << ", Sample Format: " << av_frame_->format << " vs "
333 << av_sample_format_; 342 << av_sample_format_;
334 // This is an unrecoverable error, so bail out. 343 // This is an unrecoverable error, so bail out.
335 av_frame_unref(av_frame_.get()); 344 av_frame_unref(av_frame_.get());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 return true; 429 return true;
421 } 430 }
422 431
423 void FFmpegAudioDecoder::ResetTimestampState() { 432 void FFmpegAudioDecoder::ResetTimestampState() {
424 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(), 433 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(),
425 config_.codec_delay())); 434 config_.codec_delay()));
426 discard_helper_->Reset(config_.codec_delay()); 435 discard_helper_->Reset(config_.codec_delay());
427 } 436 }
428 437
429 } // namespace media 438 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/renderers/audio_renderer_impl.cc » ('j') | media/renderers/audio_renderer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698