| OLD | NEW |
| 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/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "media/base/audio_buffer.h" | 9 #include "media/base/audio_buffer.h" |
| 10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // AVCodecContext.opaque to get the object reference in order to call | 51 // AVCodecContext.opaque to get the object reference in order to call |
| 52 // GetAudioBuffer() to do the actual allocation. | 52 // GetAudioBuffer() to do the actual allocation. |
| 53 static int GetAudioBuffer(struct AVCodecContext* s, AVFrame* frame, int flags) { | 53 static int GetAudioBuffer(struct AVCodecContext* s, AVFrame* frame, int flags) { |
| 54 DCHECK(s->codec->capabilities & CODEC_CAP_DR1); | 54 DCHECK(s->codec->capabilities & CODEC_CAP_DR1); |
| 55 DCHECK_EQ(s->codec_type, AVMEDIA_TYPE_AUDIO); | 55 DCHECK_EQ(s->codec_type, AVMEDIA_TYPE_AUDIO); |
| 56 | 56 |
| 57 // Since this routine is called by FFmpeg when a buffer is required for audio | 57 // Since this routine is called by FFmpeg when a buffer is required for audio |
| 58 // data, use the values supplied by FFmpeg (ignoring the current settings). | 58 // data, use the values supplied by FFmpeg (ignoring the current settings). |
| 59 // FFmpegDecode() gets to determine if the buffer is useable or not. | 59 // FFmpegDecode() gets to determine if the buffer is useable or not. |
| 60 AVSampleFormat format = static_cast<AVSampleFormat>(frame->format); | 60 AVSampleFormat format = static_cast<AVSampleFormat>(frame->format); |
| 61 SampleFormat sample_format = AVSampleFormatToSampleFormat(format); | 61 SampleFormat sample_format = |
| 62 AVSampleFormatToSampleFormat(format, s->codec_id); |
| 62 int channels = DetermineChannels(frame); | 63 int channels = DetermineChannels(frame); |
| 63 if (channels <= 0 || channels >= limits::kMaxChannels) { | 64 if (channels <= 0 || channels >= limits::kMaxChannels) { |
| 64 DLOG(ERROR) << "Requested number of channels (" << channels | 65 DLOG(ERROR) << "Requested number of channels (" << channels |
| 65 << ") exceeds limit."; | 66 << ") exceeds limit."; |
| 66 return AVERROR(EINVAL); | 67 return AVERROR(EINVAL); |
| 67 } | 68 } |
| 68 | 69 |
| 69 int bytes_per_channel = SampleFormatToBytesPerChannel(sample_format); | 70 int bytes_per_channel = SampleFormatToBytesPerChannel(sample_format); |
| 70 if (frame->nb_samples <= 0) | 71 if (frame->nb_samples <= 0) |
| 71 return AVERROR(EINVAL); | 72 return AVERROR(EINVAL); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 return true; | 385 return true; |
| 385 } | 386 } |
| 386 | 387 |
| 387 void FFmpegAudioDecoder::ResetTimestampState() { | 388 void FFmpegAudioDecoder::ResetTimestampState() { |
| 388 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(), | 389 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(), |
| 389 config_.codec_delay())); | 390 config_.codec_delay())); |
| 390 discard_helper_->Reset(config_.codec_delay()); | 391 discard_helper_->Reset(config_.codec_delay()); |
| 391 } | 392 } |
| 392 | 393 |
| 393 } // namespace media | 394 } // namespace media |
| OLD | NEW |