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

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

Issue 1889273003: Merge M50: "Fix audio glitch issue introduced by security fix for format changes." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bool is_sample_rate_change =
304 av_frame_->sample_rate != config_.samples_per_second();
303 bool is_config_stale = 305 bool is_config_stale =
304 av_frame_->sample_rate != config_.samples_per_second() || 306 is_sample_rate_change ||
305 channels != ChannelLayoutToChannelCount(config_.channel_layout()) || 307 channels != ChannelLayoutToChannelCount(config_.channel_layout()) ||
306 av_frame_->format != av_sample_format_; 308 av_frame_->format != av_sample_format_;
307 309
308 // Only consider channel layout changes for AAC. 310 // Only consider channel layout changes for AAC.
309 // TODO(tguilbert, dalecurtis): Due to http://crbug.com/600538 we need to 311 // 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. 312 // allow channel layout changes for the moment. See if ffmpeg is fixable.
311 if (config_.codec() == kCodecAAC) 313 if (config_.codec() == kCodecAAC)
312 is_config_stale |= channel_layout != config_.channel_layout(); 314 is_config_stale |= channel_layout != config_.channel_layout();
313 315
314 if (is_config_stale) { 316 if (is_config_stale) {
315 // Only allow midstream configuration changes for AAC. Sample format is 317 // Only allow midstream configuration changes for AAC. Sample format is
316 // not expected to change between AAC profiles. 318 // not expected to change between AAC profiles.
317 if (config_.codec() == kCodecAAC && 319 if (config_.codec() == kCodecAAC &&
318 av_frame_->format == av_sample_format_) { 320 av_frame_->format == av_sample_format_) {
319 MEDIA_LOG(DEBUG, media_log_) 321 MEDIA_LOG(DEBUG, media_log_)
320 << " Detected AAC midstream configuration change" 322 << " Detected AAC midstream configuration change"
321 << " PTS:" << buffer->timestamp().InMicroseconds() 323 << " PTS:" << buffer->timestamp().InMicroseconds()
322 << " Sample Rate: " << av_frame_->sample_rate << " vs " 324 << " Sample Rate: " << av_frame_->sample_rate << " vs "
323 << config_.samples_per_second() 325 << config_.samples_per_second()
324 << ", ChannelLayout: " << channel_layout << " vs " 326 << ", ChannelLayout: " << channel_layout << " vs "
325 << config_.channel_layout() << ", Channels: " << channels 327 << config_.channel_layout() << ", Channels: " << channels
326 << " vs " 328 << " vs "
327 << ChannelLayoutToChannelCount(config_.channel_layout()); 329 << ChannelLayoutToChannelCount(config_.channel_layout());
328 config_.Initialize(config_.codec(), config_.sample_format(), 330 config_.Initialize(config_.codec(), config_.sample_format(),
329 channel_layout, av_frame_->sample_rate, 331 channel_layout, av_frame_->sample_rate,
330 config_.extra_data(), config_.is_encrypted(), 332 config_.extra_data(), config_.is_encrypted(),
331 config_.seek_preroll(), config_.codec_delay()); 333 config_.seek_preroll(), config_.codec_delay());
332 config_changed = true; 334 config_changed = true;
333 if (av_frame_->sample_rate != config_.samples_per_second()) 335 if (is_sample_rate_change)
334 ResetTimestampState(); 336 ResetTimestampState();
335 } else { 337 } else {
336 MEDIA_LOG(ERROR, media_log_) 338 MEDIA_LOG(ERROR, media_log_)
337 << "Unsupported midstream configuration change!" 339 << "Unsupported midstream configuration change!"
338 << " Sample Rate: " << av_frame_->sample_rate << " vs " 340 << " Sample Rate: " << av_frame_->sample_rate << " vs "
339 << config_.samples_per_second() << ", Channels: " << channels 341 << config_.samples_per_second() << ", Channels: " << channels
340 << " vs " << ChannelLayoutToChannelCount(config_.channel_layout()) 342 << " vs " << ChannelLayoutToChannelCount(config_.channel_layout())
341 << ", Sample Format: " << av_frame_->format << " vs " 343 << ", Sample Format: " << av_frame_->format << " vs "
342 << av_sample_format_; 344 << av_sample_format_;
343 // This is an unrecoverable error, so bail out. 345 // This is an unrecoverable error, so bail out.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 return true; 431 return true;
430 } 432 }
431 433
432 void FFmpegAudioDecoder::ResetTimestampState() { 434 void FFmpegAudioDecoder::ResetTimestampState() {
433 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(), 435 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(),
434 config_.codec_delay())); 436 config_.codec_delay()));
435 discard_helper_->Reset(config_.codec_delay()); 437 discard_helper_->Reset(config_.codec_delay());
436 } 438 }
437 439
438 } // namespace media 440 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698