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

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

Issue 1422113002: Enable pcm_s32le audio decoding. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: DEPS roll Created 5 years 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/ffmpeg/ffmpeg_common_unittest.cc ('k') | media/mojo/interfaces/media_types.mojom » ('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) 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
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
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
OLDNEW
« no previous file with comments | « media/ffmpeg/ffmpeg_common_unittest.cc ('k') | media/mojo/interfaces/media_types.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698