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

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

Issue 2903143003: Use ffmpeg_features buildflags (Closed)
Patch Set: trybots Created 3 years, 7 months 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/filters/audio_file_reader.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 16 matching lines...) Expand all
27 const scoped_refptr<DecoderBuffer>& input) { 27 const scoped_refptr<DecoderBuffer>& input) {
28 // Three conditions to meet to declare end of stream for this decoder: 28 // Three conditions to meet to declare end of stream for this decoder:
29 // 1. FFmpeg didn't read anything. 29 // 1. FFmpeg didn't read anything.
30 // 2. FFmpeg didn't output anything. 30 // 2. FFmpeg didn't output anything.
31 // 3. An end of stream buffer is received. 31 // 3. An end of stream buffer is received.
32 return result == 0 && decoded_size == 0 && input->end_of_stream(); 32 return result == 0 && decoded_size == 0 && input->end_of_stream();
33 } 33 }
34 34
35 // Return the number of channels from the data in |frame|. 35 // Return the number of channels from the data in |frame|.
36 static inline int DetermineChannels(AVFrame* frame) { 36 static inline int DetermineChannels(AVFrame* frame) {
37 #if defined(CHROMIUM_NO_AVFRAME_CHANNELS)
38 // When use_system_ffmpeg==1, libav's AVFrame doesn't have channels field.
39 return av_get_channel_layout_nb_channels(frame->channel_layout);
40 #else
41 return frame->channels; 37 return frame->channels;
42 #endif
43 } 38 }
44 39
45 // Called by FFmpeg's allocation routine to allocate a buffer. Uses 40 // Called by FFmpeg's allocation routine to allocate a buffer. Uses
46 // AVCodecContext.opaque to get the object reference in order to call 41 // AVCodecContext.opaque to get the object reference in order to call
47 // GetAudioBuffer() to do the actual allocation. 42 // GetAudioBuffer() to do the actual allocation.
48 static int GetAudioBufferImpl(struct AVCodecContext* s, 43 static int GetAudioBufferImpl(struct AVCodecContext* s,
49 AVFrame* frame, 44 AVFrame* frame,
50 int flags) { 45 int flags) {
51 FFmpegAudioDecoder* decoder = static_cast<FFmpegAudioDecoder*>(s->opaque); 46 FFmpegAudioDecoder* decoder = static_cast<FFmpegAudioDecoder*>(s->opaque);
52 return decoder->GetAudioBuffer(s, frame, flags); 47 return decoder->GetAudioBuffer(s, frame, flags);
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // Now create an AVBufferRef for the data just allocated. It will own the 451 // Now create an AVBufferRef for the data just allocated. It will own the
457 // reference to the AudioBuffer object. 452 // reference to the AudioBuffer object.
458 AudioBuffer* opaque = buffer.get(); 453 AudioBuffer* opaque = buffer.get();
459 opaque->AddRef(); 454 opaque->AddRef();
460 frame->buf[0] = av_buffer_create(frame->data[0], buffer_size_in_bytes, 455 frame->buf[0] = av_buffer_create(frame->data[0], buffer_size_in_bytes,
461 ReleaseAudioBufferImpl, opaque, 0); 456 ReleaseAudioBufferImpl, opaque, 0);
462 return 0; 457 return 0;
463 } 458 }
464 459
465 } // namespace media 460 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/audio_file_reader.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698