OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "media/base/callback.h" |
7 #include "media/base/data_buffer.h" | 8 #include "media/base/data_buffer.h" |
8 #include "media/base/limits.h" | 9 #include "media/base/limits.h" |
9 #include "media/ffmpeg/ffmpeg_common.h" | 10 #include "media/ffmpeg/ffmpeg_common.h" |
10 #include "media/filters/ffmpeg_demuxer.h" | 11 #include "media/filters/ffmpeg_demuxer.h" |
11 | 12 |
12 #if !defined(USE_SSE) | 13 #if !defined(USE_SSE) |
13 #if defined(__SSE__) || defined(ARCH_CPU_X86_64) || _M_IX86_FP==1 | 14 #if defined(__SSE__) || defined(ARCH_CPU_X86_64) || _M_IX86_FP==1 |
14 #define USE_SSE 1 | 15 #define USE_SSE 1 |
15 #else | 16 #else |
16 #define USE_SSE 0 | 17 #define USE_SSE 0 |
(...skipping 15 matching lines...) Expand all Loading... |
32 config_(0, CHANNEL_LAYOUT_NONE, 0), | 33 config_(0, CHANNEL_LAYOUT_NONE, 0), |
33 estimated_next_timestamp_(kNoTimestamp) { | 34 estimated_next_timestamp_(kNoTimestamp) { |
34 } | 35 } |
35 | 36 |
36 FFmpegAudioDecoder::~FFmpegAudioDecoder() { | 37 FFmpegAudioDecoder::~FFmpegAudioDecoder() { |
37 } | 38 } |
38 | 39 |
39 void FFmpegAudioDecoder::DoInitialize(DemuxerStream* demuxer_stream, | 40 void FFmpegAudioDecoder::DoInitialize(DemuxerStream* demuxer_stream, |
40 bool* success, | 41 bool* success, |
41 Task* done_cb) { | 42 Task* done_cb) { |
42 base::ScopedTaskRunner done_runner(done_cb); | 43 AutoTaskRunner done_runner(done_cb); |
43 *success = false; | 44 *success = false; |
44 | 45 |
45 AVStream* av_stream = demuxer_stream->GetAVStream(); | 46 AVStream* av_stream = demuxer_stream->GetAVStream(); |
46 if (!av_stream) { | 47 if (!av_stream) { |
47 return; | 48 return; |
48 } | 49 } |
49 | 50 |
50 // Grab the AVStream's codec context and make sure we have sensible values. | 51 // Grab the AVStream's codec context and make sure we have sensible values. |
51 codec_context_ = av_stream->codec; | 52 codec_context_ = av_stream->codec; |
52 int bps = av_get_bits_per_sample_fmt(codec_context_->sample_fmt); | 53 int bps = av_get_bits_per_sample_fmt(codec_context_->sample_fmt); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(size_t size) { | 253 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(size_t size) { |
253 int64 denominator = codec_context_->channels * | 254 int64 denominator = codec_context_->channels * |
254 av_get_bits_per_sample_fmt(codec_context_->sample_fmt) / 8 * | 255 av_get_bits_per_sample_fmt(codec_context_->sample_fmt) / 8 * |
255 codec_context_->sample_rate; | 256 codec_context_->sample_rate; |
256 double microseconds = size / | 257 double microseconds = size / |
257 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond)); | 258 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond)); |
258 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); | 259 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); |
259 } | 260 } |
260 | 261 |
261 } // namespace | 262 } // namespace |
OLD | NEW |