| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/callback.h" |
| 8 #include "media/base/data_buffer.h" | 8 #include "media/base/data_buffer.h" |
| 9 #include "media/base/limits.h" | 9 #include "media/base/limits.h" |
| 10 #include "media/ffmpeg/ffmpeg_common.h" | 10 #include "media/ffmpeg/ffmpeg_common.h" |
| 11 #include "media/filters/ffmpeg_demuxer.h" | 11 #include "media/filters/ffmpeg_demuxer.h" |
| 12 | 12 |
| 13 #if !defined(USE_SSE) | 13 #if !defined(USE_SSE) |
| 14 #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 |
| 15 #define USE_SSE 1 | 15 #define USE_SSE 1 |
| 16 #else | 16 #else |
| 17 #define USE_SSE 0 | 17 #define USE_SSE 0 |
| 18 #endif | 18 #endif |
| 19 #endif | 19 #endif |
| 20 #if USE_SSE | 20 #if USE_SSE |
| 21 #include <xmmintrin.h> | 21 #include <xmmintrin.h> |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace media { | 24 namespace media { |
| 25 | 25 |
| 26 // Size of the decoded audio buffer. | 26 // Size of the decoded audio buffer. |
| 27 const size_t FFmpegAudioDecoder::kOutputBufferSize = | 27 const size_t FFmpegAudioDecoder::kOutputBufferSize = |
| 28 AVCODEC_MAX_AUDIO_FRAME_SIZE; | 28 AVCODEC_MAX_AUDIO_FRAME_SIZE; |
| 29 | 29 |
| 30 FFmpegAudioDecoder::FFmpegAudioDecoder() | 30 FFmpegAudioDecoder::FFmpegAudioDecoder(MessageLoop* message_loop) |
| 31 : codec_context_(NULL), | 31 : DecoderBase<AudioDecoder, Buffer>(message_loop), |
| 32 codec_context_(NULL), |
| 32 estimated_next_timestamp_(kNoTimestamp) { | 33 estimated_next_timestamp_(kNoTimestamp) { |
| 33 } | 34 } |
| 34 | 35 |
| 35 FFmpegAudioDecoder::~FFmpegAudioDecoder() { | 36 FFmpegAudioDecoder::~FFmpegAudioDecoder() { |
| 36 } | 37 } |
| 37 | 38 |
| 38 void FFmpegAudioDecoder::DoInitialize(DemuxerStream* demuxer_stream, | 39 void FFmpegAudioDecoder::DoInitialize(DemuxerStream* demuxer_stream, |
| 39 bool* success, | 40 bool* success, |
| 40 Task* done_cb) { | 41 Task* done_cb) { |
| 41 AutoTaskRunner done_runner(done_cb); | 42 AutoTaskRunner done_runner(done_cb); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(size_t size) { | 247 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(size_t size) { |
| 247 int64 denominator = codec_context_->channels * | 248 int64 denominator = codec_context_->channels * |
| 248 av_get_bits_per_sample_fmt(codec_context_->sample_fmt) / 8 * | 249 av_get_bits_per_sample_fmt(codec_context_->sample_fmt) / 8 * |
| 249 codec_context_->sample_rate; | 250 codec_context_->sample_rate; |
| 250 double microseconds = size / | 251 double microseconds = size / |
| 251 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond)); | 252 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond)); |
| 252 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); | 253 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); |
| 253 } | 254 } |
| 254 | 255 |
| 255 } // namespace | 256 } // namespace |
| OLD | NEW |