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 "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "media/base/audio_buffer.h" | 9 #include "media/base/audio_buffer.h" |
10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 // Now create an AVBufferRef for the data just allocated. It will own the | 119 // Now create an AVBufferRef for the data just allocated. It will own the |
120 // reference to the AudioBuffer object. | 120 // reference to the AudioBuffer object. |
121 void* opaque = NULL; | 121 void* opaque = NULL; |
122 buffer.swap(reinterpret_cast<AudioBuffer**>(&opaque)); | 122 buffer.swap(reinterpret_cast<AudioBuffer**>(&opaque)); |
123 frame->buf[0] = av_buffer_create( | 123 frame->buf[0] = av_buffer_create( |
124 frame->data[0], buffer_size_in_bytes, ReleaseAudioBufferImpl, opaque, 0); | 124 frame->data[0], buffer_size_in_bytes, ReleaseAudioBufferImpl, opaque, 0); |
125 return 0; | 125 return 0; |
126 } | 126 } |
127 | 127 |
128 FFmpegAudioDecoder::FFmpegAudioDecoder( | 128 FFmpegAudioDecoder::FFmpegAudioDecoder( |
129 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) | 129 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
130 : task_runner_(task_runner), state_(kUninitialized), av_sample_format_(0) { | 130 const LogCB& log_cb) |
131 : task_runner_(task_runner), | |
132 state_(kUninitialized), | |
133 av_sample_format_(0), | |
134 log_cb_(log_cb) { | |
131 } | 135 } |
132 | 136 |
133 FFmpegAudioDecoder::~FFmpegAudioDecoder() { | 137 FFmpegAudioDecoder::~FFmpegAudioDecoder() { |
134 DCHECK_EQ(state_, kUninitialized); | 138 DCHECK_EQ(state_, kUninitialized); |
135 DCHECK(!codec_context_); | 139 DCHECK(!codec_context_); |
136 DCHECK(!av_frame_); | 140 DCHECK(!av_frame_); |
137 } | 141 } |
138 | 142 |
139 void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config, | 143 void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config, |
140 const PipelineStatusCB& status_cb) { | 144 const PipelineStatusCB& status_cb) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 channels != ChannelLayoutToChannelCount(config_.channel_layout()) || | 348 channels != ChannelLayoutToChannelCount(config_.channel_layout()) || |
345 av_frame_->format != av_sample_format_) { | 349 av_frame_->format != av_sample_format_) { |
346 DLOG(ERROR) << "Unsupported midstream configuration change!" | 350 DLOG(ERROR) << "Unsupported midstream configuration change!" |
347 << " Sample Rate: " << av_frame_->sample_rate << " vs " | 351 << " Sample Rate: " << av_frame_->sample_rate << " vs " |
348 << config_.samples_per_second() | 352 << config_.samples_per_second() |
349 << ", Channels: " << channels << " vs " | 353 << ", Channels: " << channels << " vs " |
350 << ChannelLayoutToChannelCount(config_.channel_layout()) | 354 << ChannelLayoutToChannelCount(config_.channel_layout()) |
351 << ", Sample Format: " << av_frame_->format << " vs " | 355 << ", Sample Format: " << av_frame_->format << " vs " |
352 << av_sample_format_; | 356 << av_sample_format_; |
353 | 357 |
358 if ((config_.codec() == kCodecAAC) && | |
359 av_frame_->sample_rate == 2 * config_.samples_per_second()) { | |
scherkus (not reviewing)
2014/05/08 00:26:14
nit: it's funny you put the ()'s around the simple
acolwell GONE FROM CHROMIUM
2014/05/08 00:57:01
Yeah. Not sure why I did that. () removed.
| |
360 MEDIA_LOG(log_cb_) << "Implicit HE-AAC signalling is being used." | |
scherkus (not reviewing)
2014/05/07 20:25:53
should this be moved closer to MSE code instead of
acolwell GONE FROM CHROMIUM
2014/05/07 20:47:45
We can't. Implict signalling of HE-AAC can only be
| |
361 << " Please use mp4a.40.5 instead of mp4a.40.2 in" | |
362 << " the mimetype."; | |
363 } | |
354 // This is an unrecoverable error, so bail out. | 364 // This is an unrecoverable error, so bail out. |
355 queued_audio_.clear(); | 365 queued_audio_.clear(); |
356 av_frame_unref(av_frame_.get()); | 366 av_frame_unref(av_frame_.get()); |
357 return false; | 367 return false; |
358 } | 368 } |
359 | 369 |
360 // Get the AudioBuffer that the data was decoded into. Adjust the number | 370 // Get the AudioBuffer that the data was decoded into. Adjust the number |
361 // of frames, in case fewer than requested were actually decoded. | 371 // of frames, in case fewer than requested were actually decoded. |
362 output = reinterpret_cast<AudioBuffer*>( | 372 output = reinterpret_cast<AudioBuffer*>( |
363 av_buffer_get_opaque(av_frame_->buf[0])); | 373 av_buffer_get_opaque(av_frame_->buf[0])); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 | 454 |
445 ResetTimestampState(); | 455 ResetTimestampState(); |
446 return true; | 456 return true; |
447 } | 457 } |
448 | 458 |
449 void FFmpegAudioDecoder::ResetTimestampState() { | 459 void FFmpegAudioDecoder::ResetTimestampState() { |
450 discard_helper_->Reset(config_.codec_delay()); | 460 discard_helper_->Reset(config_.codec_delay()); |
451 } | 461 } |
452 | 462 |
453 } // namespace media | 463 } // namespace media |
OLD | NEW |