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