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

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

Issue 11888011: media: Fix Opus support, and handle bad timestamps correctly in the Opus wrapper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/filters/opus_audio_decoder.cc » ('j') | media/filters/opus_audio_decoder.cc » ('J')
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/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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 const AVCodecContext* codec_context, 265 const AVCodecContext* codec_context,
266 AudioDecoderConfig* config) { 266 AudioDecoderConfig* config) {
267 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); 267 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO);
268 268
269 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); 269 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id);
270 270
271 SampleFormat sample_format = 271 SampleFormat sample_format =
272 AVSampleFormatToSampleFormat(codec_context->sample_fmt); 272 AVSampleFormatToSampleFormat(codec_context->sample_fmt);
273 273
274 if (codec == kCodecOpus) { 274 if (codec == kCodecOpus) {
275 // TODO(tomfinegan): |sample_fmt| in |codec_context| is -1... because 275 // TODO(tomfinegan): |sample_fmt| in |codec_context| is -1... because
fbarchard1 2013/01/15 23:10:17 Should be // TODO(finegan): ? I didnt see this com
Tom Finegan 2013/01/15 23:22:28 I'm tomfinegan@ for chromium and google-- this is
276 // libopusdec.c isn't built into ffmpegsumo...? Maybe it's not *that* big 276 // libopusdec.c isn't built into ffmpegsumo...? Maybe it's not *that* big
277 // a deal since libopus will produce either float or S16 samples, and 277 // a deal since libopus will produce either float or S16 samples, and
278 // OpusAudioDecoder is the only provider of Opus support. 278 // OpusAudioDecoder is the only provider of Opus support.
279 sample_format = kSampleFormatS16; 279 sample_format = kSampleFormatS16;
280 } 280 }
281 281
282 ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout( 282 ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout(
283 codec_context->channel_layout, codec_context->channels); 283 codec_context->channel_layout, codec_context->channels);
284 config->Initialize(codec, 284 config->Initialize(codec,
285 sample_format, 285 sample_format,
286 channel_layout, 286 channel_layout,
287 codec_context->sample_rate, 287 codec_context->sample_rate,
288 codec_context->extradata, 288 codec_context->extradata,
289 codec_context->extradata_size, 289 codec_context->extradata_size,
290 false, // Not encrypted. 290 false, // Not encrypted.
291 true); 291 true);
292 DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8, 292 if (codec != kCodecOpus) {
fbarchard1 2013/01/14 20:42:30 add a comment or todo to remove this.
fbarchard1 2013/01/15 02:26:50 Isn't Opus already in current ffmpeg? I ran some
Tom Finegan 2013/01/15 02:44:51 Disabled in chromium's version.
293 config->bits_per_channel()); 293 DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8,
294 config->bits_per_channel());
295 }
294 } 296 }
295 297
296 void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config, 298 void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config,
297 AVCodecContext* codec_context) { 299 AVCodecContext* codec_context) {
298 codec_context->codec_type = AVMEDIA_TYPE_AUDIO; 300 codec_context->codec_type = AVMEDIA_TYPE_AUDIO;
299 codec_context->codec_id = AudioCodecToCodecID(config.codec(), 301 codec_context->codec_id = AudioCodecToCodecID(config.codec(),
300 config.sample_format()); 302 config.sample_format());
301 codec_context->sample_fmt = SampleFormatToAVSampleFormat( 303 codec_context->sample_fmt = SampleFormatToAVSampleFormat(
302 config.sample_format()); 304 config.sample_format());
303 305
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 return PIX_FMT_YUV422P; 478 return PIX_FMT_YUV422P;
477 case VideoFrame::YV12: 479 case VideoFrame::YV12:
478 return PIX_FMT_YUV420P; 480 return PIX_FMT_YUV420P;
479 default: 481 default:
480 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; 482 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format;
481 } 483 }
482 return PIX_FMT_NONE; 484 return PIX_FMT_NONE;
483 } 485 }
484 486
485 } // namespace media 487 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/opus_audio_decoder.cc » ('j') | media/filters/opus_audio_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698