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

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

Issue 113748: New FFmpeg public API headers to match our source tarball in deps. (Closed)
Patch Set: Fixes Created 11 years, 7 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 | « media/bench/bench.cc ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "media/base/data_buffer.h" 5 #include "media/base/data_buffer.h"
6 #include "media/filters/ffmpeg_audio_decoder.h" 6 #include "media/filters/ffmpeg_audio_decoder.h"
7 #include "media/filters/ffmpeg_common.h" 7 #include "media/filters/ffmpeg_common.h"
8 #include "media/filters/ffmpeg_demuxer.h" 8 #include "media/filters/ffmpeg_demuxer.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 host_->Error(PIPELINE_ERROR_OUT_OF_MEMORY); 67 host_->Error(PIPELINE_ERROR_OUT_OF_MEMORY);
68 return false; 68 return false;
69 } 69 }
70 return true; 70 return true;
71 } 71 }
72 72
73 void FFmpegAudioDecoder::OnStop() { 73 void FFmpegAudioDecoder::OnStop() {
74 } 74 }
75 75
76 void FFmpegAudioDecoder::OnDecode(Buffer* input) { 76 void FFmpegAudioDecoder::OnDecode(Buffer* input) {
77 // Due to FFmpeg API changes we no longer have const read-only pointers.
78 AVPacket packet;
79 av_init_packet(&packet);
80 packet.data = const_cast<uint8*>(input->GetData());
81 packet.size = input->GetDataSize();
82
77 int16_t* output_buffer = reinterpret_cast<int16_t*>(output_buffer_.get()); 83 int16_t* output_buffer = reinterpret_cast<int16_t*>(output_buffer_.get());
78 int output_buffer_size = kOutputBufferSize; 84 int output_buffer_size = kOutputBufferSize;
79 int result = avcodec_decode_audio2(codec_context_, 85 int result = avcodec_decode_audio3(codec_context_,
80 output_buffer, 86 output_buffer,
81 &output_buffer_size, 87 &output_buffer_size,
82 input->GetData(), 88 &packet);
83 input->GetDataSize());
84 89
85 // TODO(ajwong): Consider if kOutputBufferSize should just be an int instead 90 // TODO(ajwong): Consider if kOutputBufferSize should just be an int instead
86 // of a size_t. 91 // of a size_t.
87 if (result < 0 || 92 if (result < 0 ||
88 output_buffer_size < 0 || 93 output_buffer_size < 0 ||
89 static_cast<size_t>(output_buffer_size) > kOutputBufferSize) { 94 static_cast<size_t>(output_buffer_size) > kOutputBufferSize) {
90 host_->Error(PIPELINE_ERROR_DECODE); 95 host_->Error(PIPELINE_ERROR_DECODE);
91 } else if (result == 0) { 96 } else if (result == 0) {
92 // TODO(scherkus): does this mark EOS? Do we want to fulfill a read request 97 // TODO(scherkus): does this mark EOS? Do we want to fulfill a read request
93 // with zero size? 98 // with zero size?
(...skipping 20 matching lines...) Expand all
114 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(size_t size) { 119 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(size_t size) {
115 int64 denominator = codec_context_->channels * 120 int64 denominator = codec_context_->channels *
116 av_get_bits_per_sample_format(codec_context_->sample_fmt) / 8 * 121 av_get_bits_per_sample_format(codec_context_->sample_fmt) / 8 *
117 codec_context_->sample_rate; 122 codec_context_->sample_rate;
118 double microseconds = size / 123 double microseconds = size /
119 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond)); 124 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond));
120 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); 125 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds));
121 } 126 }
122 127
123 } // namespace 128 } // namespace
OLDNEW
« no previous file with comments | « media/bench/bench.cc ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698