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

Side by Side Diff: media/ffmpeg/ffmpeg_common.cc

Issue 11416367: Add Opus decode wrapper to media. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased (changed machines) Address most comments. Added TODO for Opus buffering question. Created 8 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 | Annotate | Revision Log
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/ffmpeg/ffmpeg_common.h" 5 #include "media/ffmpeg/ffmpeg_common.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/base/decoder_buffer.h" 9 #include "media/base/decoder_buffer.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 case CODEC_ID_FLAC: 76 case CODEC_ID_FLAC:
77 return kCodecFLAC; 77 return kCodecFLAC;
78 case CODEC_ID_AMR_NB: 78 case CODEC_ID_AMR_NB:
79 return kCodecAMR_NB; 79 return kCodecAMR_NB;
80 case CODEC_ID_AMR_WB: 80 case CODEC_ID_AMR_WB:
81 return kCodecAMR_WB; 81 return kCodecAMR_WB;
82 case CODEC_ID_GSM_MS: 82 case CODEC_ID_GSM_MS:
83 return kCodecGSM_MS; 83 return kCodecGSM_MS;
84 case CODEC_ID_PCM_MULAW: 84 case CODEC_ID_PCM_MULAW:
85 return kCodecPCM_MULAW; 85 return kCodecPCM_MULAW;
86 case CODEC_ID_OPUS:
87 return kCodecOpus;
86 default: 88 default:
87 DVLOG(1) << "Unknown audio CodecID: " << codec_id; 89 DVLOG(1) << "Unknown audio CodecID: " << codec_id;
88 } 90 }
89 return kUnknownAudioCodec; 91 return kUnknownAudioCodec;
90 } 92 }
91 93
92 static CodecID AudioCodecToCodecID(AudioCodec audio_codec, 94 static CodecID AudioCodecToCodecID(AudioCodec audio_codec,
93 int bits_per_channel) { 95 int bits_per_channel) {
94 switch (audio_codec) { 96 switch (audio_codec) {
95 case kCodecAAC: 97 case kCodecAAC:
(...skipping 21 matching lines...) Expand all
117 case kCodecFLAC: 119 case kCodecFLAC:
118 return CODEC_ID_FLAC; 120 return CODEC_ID_FLAC;
119 case kCodecAMR_NB: 121 case kCodecAMR_NB:
120 return CODEC_ID_AMR_NB; 122 return CODEC_ID_AMR_NB;
121 case kCodecAMR_WB: 123 case kCodecAMR_WB:
122 return CODEC_ID_AMR_WB; 124 return CODEC_ID_AMR_WB;
123 case kCodecGSM_MS: 125 case kCodecGSM_MS:
124 return CODEC_ID_GSM_MS; 126 return CODEC_ID_GSM_MS;
125 case kCodecPCM_MULAW: 127 case kCodecPCM_MULAW:
126 return CODEC_ID_PCM_MULAW; 128 return CODEC_ID_PCM_MULAW;
129 case kCodecOpus:
130 return CODEC_ID_OPUS;
127 default: 131 default:
128 DVLOG(1) << "Unknown AudioCodec: " << audio_codec; 132 DVLOG(1) << "Unknown AudioCodec: " << audio_codec;
129 } 133 }
130 return CODEC_ID_NONE; 134 return CODEC_ID_NONE;
131 } 135 }
132 136
133 VideoCodec CodecIDToVideoCodec(CodecID codec_id) { 137 VideoCodec CodecIDToVideoCodec(CodecID codec_id) {
134 switch (codec_id) { 138 switch (codec_id) {
135 case CODEC_ID_VC1: 139 case CODEC_ID_VC1:
136 return kCodecVC1; 140 return kCodecVC1;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 AudioDecoderConfig* config) { 227 AudioDecoderConfig* config) {
224 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); 228 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO);
225 229
226 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); 230 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id);
227 int bytes_per_channel = av_get_bytes_per_sample(codec_context->sample_fmt); 231 int bytes_per_channel = av_get_bytes_per_sample(codec_context->sample_fmt);
228 ChannelLayout channel_layout = 232 ChannelLayout channel_layout =
229 ChannelLayoutToChromeChannelLayout(codec_context->channel_layout, 233 ChannelLayoutToChromeChannelLayout(codec_context->channel_layout,
230 codec_context->channels); 234 codec_context->channels);
231 int samples_per_second = codec_context->sample_rate; 235 int samples_per_second = codec_context->sample_rate;
232 236
237 if (codec == kCodecOpus) {
238 // TODO(tomfinegan): |sample_fmt| in |codec_context| is -1... because
239 // libopusdec.c isn't built into ffmpegsumo...? Maybe it's not *that* big
240 // a deal since libopus will produce either float or S16 samples, and
241 // |OpusAudioDecoder| is the only provider of Opus support.
scherkus (not reviewing) 2012/12/14 21:13:34 nit: drop || around class names (OpusAudioDecoder
Tom Finegan 2012/12/14 23:19:52 Done.
242 bytes_per_channel = av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
243 }
244
233 config->Initialize(codec, 245 config->Initialize(codec,
234 bytes_per_channel << 3, 246 bytes_per_channel << 3,
235 channel_layout, 247 channel_layout,
236 samples_per_second, 248 samples_per_second,
237 codec_context->extradata, 249 codec_context->extradata,
238 codec_context->extradata_size, 250 codec_context->extradata_size,
239 false, // Not encrypted. 251 false, // Not encrypted.
240 true); 252 true);
241 } 253 }
242 254
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 return PIX_FMT_YUV422P; 433 return PIX_FMT_YUV422P;
422 case VideoFrame::YV12: 434 case VideoFrame::YV12:
423 return PIX_FMT_YUV420P; 435 return PIX_FMT_YUV420P;
424 default: 436 default:
425 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; 437 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format;
426 } 438 }
427 return PIX_FMT_NONE; 439 return PIX_FMT_NONE;
428 } 440 }
429 441
430 } // namespace media 442 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698