Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 config_is_stale = |
|
DaleCurtis
2016/04/07 20:05:04
Naming style in chrome is typically "is_config_sta
tguilbert
2016/04/07 21:08:50
Done.
| |
| 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. | |
|
DaleCurtis
2016/04/07 20:05:04
Add a comment why, something like:
// TODO(tguilb
tguilbert
2016/04/07 21:08:50
Done.
| |
| 309 if(config_.codec() == kCodecAAC){ | |
|
DaleCurtis
2016/04/07 20:05:04
run git cl format to fix formatting errors. notabl
tguilbert
2016/04/07 21:08:50
Done.
| |
| 310 config_is_stale |= channel_layout != config_.channel_layout(); | |
| 311 } | |
| 312 | |
| 313 if (config_is_stale) { | |
| 307 // Only allow midstream configuration changes for AAC. Sample format is | 314 // Only allow midstream configuration changes for AAC. Sample format is |
| 308 // not expected to change between AAC profiles. | 315 // not expected to change between AAC profiles. |
| 309 if (config_.codec() == kCodecAAC && | 316 if (config_.codec() == kCodecAAC && |
| 310 av_frame_->format == av_sample_format_) { | 317 av_frame_->format == av_sample_format_) { |
| 311 MEDIA_LOG(DEBUG, media_log_) | 318 MEDIA_LOG(DEBUG, media_log_) |
| 312 << " Detected AAC midstream configuration change" | 319 << " Detected AAC midstream configuration change" |
| 313 << " PTS:" << buffer->timestamp().InMicroseconds() | 320 << " PTS:" << buffer->timestamp().InMicroseconds() |
| 314 << " Sample Rate: " << av_frame_->sample_rate << " vs " | 321 << " Sample Rate: " << av_frame_->sample_rate << " vs " |
| 315 << config_.samples_per_second() | 322 << config_.samples_per_second() |
| 316 << ", ChannelLayout: " << channel_layout << " vs " | 323 << ", ChannelLayout: " << channel_layout << " vs " |
| 317 << config_.channel_layout() << ", Channels: " << channels | 324 << config_.channel_layout() << ", Channels: " << channels |
| 318 << " vs " | 325 << " vs " |
| 319 << ChannelLayoutToChannelCount(config_.channel_layout()); | 326 << ChannelLayoutToChannelCount(config_.channel_layout()); |
| 320 config_.Initialize(config_.codec(), config_.sample_format(), | 327 config_.Initialize(config_.codec(), config_.sample_format(), |
| 321 channel_layout, av_frame_->sample_rate, | 328 channel_layout, av_frame_->sample_rate, |
| 322 config_.extra_data(), config_.encryption_scheme(), | 329 config_.extra_data(), config_.encryption_scheme(), |
| 323 config_.seek_preroll(), config_.codec_delay()); | 330 config_.seek_preroll(), config_.codec_delay()); |
| 324 config_changed = true; | 331 config_changed = true; |
| 325 ResetTimestampState(); | 332 ResetTimestampState(); |
|
DaleCurtis
2016/04/07 20:05:04
This only needs to be called when sample_rate chan
tguilbert
2016/04/07 21:08:50
Does this need to be called before discard_helper_
| |
| 326 } else { | 333 } else { |
| 327 MEDIA_LOG(ERROR, media_log_) | 334 MEDIA_LOG(ERROR, media_log_) |
| 328 << "Unsupported midstream configuration change!" | 335 << "Unsupported midstream configuration change!" |
| 329 << " Sample Rate: " << av_frame_->sample_rate << " vs " | 336 << " Sample Rate: " << av_frame_->sample_rate << " vs " |
| 330 << config_.samples_per_second() << ", Channels: " << channels | 337 << config_.samples_per_second() << ", Channels: " << channels |
| 331 << " vs " << ChannelLayoutToChannelCount(config_.channel_layout()) | 338 << " vs " << ChannelLayoutToChannelCount(config_.channel_layout()) |
| 332 << ", Sample Format: " << av_frame_->format << " vs " | 339 << ", Sample Format: " << av_frame_->format << " vs " |
| 333 << av_sample_format_; | 340 << av_sample_format_; |
| 334 // This is an unrecoverable error, so bail out. | 341 // This is an unrecoverable error, so bail out. |
| 335 av_frame_unref(av_frame_.get()); | 342 av_frame_unref(av_frame_.get()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 return true; | 427 return true; |
| 421 } | 428 } |
| 422 | 429 |
| 423 void FFmpegAudioDecoder::ResetTimestampState() { | 430 void FFmpegAudioDecoder::ResetTimestampState() { |
| 424 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(), | 431 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(), |
| 425 config_.codec_delay())); | 432 config_.codec_delay())); |
| 426 discard_helper_->Reset(config_.codec_delay()); | 433 discard_helper_->Reset(config_.codec_delay()); |
| 427 } | 434 } |
| 428 | 435 |
| 429 } // namespace media | 436 } // namespace media |
| OLD | NEW |