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

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

Issue 10795050: Fix MediaSource code so it can handle HE-AAC content that uses implicit signalling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments. Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/mp4/aac.h » ('j') | 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "media/base/audio_decoder_config.h" 9 #include "media/base/audio_decoder_config.h"
10 #include "media/base/data_buffer.h" 10 #include "media/base/data_buffer.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 << input->GetTimestamp().InMicroseconds() << " us, duration: " 216 << input->GetTimestamp().InMicroseconds() << " us, duration: "
217 << input->GetDuration().InMicroseconds() << " us, packet size: " 217 << input->GetDuration().InMicroseconds() << " us, packet size: "
218 << input->GetDataSize() << " bytes"; 218 << input->GetDataSize() << " bytes";
219 219
220 ReadFromDemuxerStream(); 220 ReadFromDemuxerStream();
221 return; 221 return;
222 } 222 }
223 223
224 int decoded_audio_size = 0; 224 int decoded_audio_size = 0;
225 if (frame_decoded) { 225 if (frame_decoded) {
226 int output_sample_rate = av_frame_->sample_rate;
227 if (output_sample_rate != samples_per_second_) {
228 DLOG(ERROR) << "Output sample rate (" << output_sample_rate
229 << ") doesn't match expected rate " << samples_per_second_;
230 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL);
231 return;
232 }
233
226 decoded_audio_size = av_samples_get_buffer_size( 234 decoded_audio_size = av_samples_get_buffer_size(
227 NULL, codec_context_->channels, av_frame_->nb_samples, 235 NULL, codec_context_->channels, av_frame_->nb_samples,
228 codec_context_->sample_fmt, 1); 236 codec_context_->sample_fmt, 1);
229 } 237 }
230 238
231 scoped_refptr<DataBuffer> output; 239 scoped_refptr<DataBuffer> output;
232 240
233 if (decoded_audio_size > 0) { 241 if (decoded_audio_size > 0) {
234 // Copy the audio samples into an output buffer. 242 // Copy the audio samples into an output buffer.
235 output = new DataBuffer(decoded_audio_size); 243 output = new DataBuffer(decoded_audio_size);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 305
298 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(int size) { 306 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(int size) {
299 int64 denominator = ChannelLayoutToChannelCount(channel_layout_) * 307 int64 denominator = ChannelLayoutToChannelCount(channel_layout_) *
300 bits_per_channel_ / 8 * samples_per_second_; 308 bits_per_channel_ / 8 * samples_per_second_;
301 double microseconds = size / 309 double microseconds = size /
302 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond)); 310 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond));
303 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); 311 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds));
304 } 312 }
305 313
306 } // namespace media 314 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/mp4/aac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698