diff options
author | tomfinegan@chromium.org <tomfinegan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-18 07:07:50 +0000 |
---|---|---|
committer | tomfinegan@chromium.org <tomfinegan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-18 07:07:50 +0000 |
commit | f88628791d00eaf5ae34aff349bf32e39f7a462e (patch) | |
tree | 2e33379cef02113403d30d78bc009ae01cc7636d /media/ffmpeg | |
parent | 8a614b898d1804c79d7e7bb9bded8670b5d74866 (diff) | |
download | chromium_src-f88628791d00eaf5ae34aff349bf32e39f7a462e.zip chromium_src-f88628791d00eaf5ae34aff349bf32e39f7a462e.tar.gz chromium_src-f88628791d00eaf5ae34aff349bf32e39f7a462e.tar.bz2 |
Add wrapper class to media for support of Opus audio, and add a command line flag to enable the support.
This initial version of the wrapper provides support for decoding Opus audio in WebM container files, and is disabled by default.
New flag added: --enable-opus-playback
BUG=166094
TEST=Opus audio in WebM containers plays back in <video> elements when --enable-opus-playback is specified on the command line.
Review URL: https://codereview.chromium.org/11416367
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173663 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/ffmpeg')
-rw-r--r-- | media/ffmpeg/ffmpeg_common.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc index c79e480..1fd5cd9 100644 --- a/media/ffmpeg/ffmpeg_common.cc +++ b/media/ffmpeg/ffmpeg_common.cc @@ -83,6 +83,8 @@ AudioCodec CodecIDToAudioCodec(CodecID codec_id) { return kCodecGSM_MS; case CODEC_ID_PCM_MULAW: return kCodecPCM_MULAW; + case CODEC_ID_OPUS: + return kCodecOpus; default: DVLOG(1) << "Unknown audio CodecID: " << codec_id; } @@ -124,6 +126,8 @@ static CodecID AudioCodecToCodecID(AudioCodec audio_codec, return CODEC_ID_GSM_MS; case kCodecPCM_MULAW: return CODEC_ID_PCM_MULAW; + case kCodecOpus: + return CODEC_ID_OPUS; default: DVLOG(1) << "Unknown AudioCodec: " << audio_codec; } @@ -224,7 +228,17 @@ void AVCodecContextToAudioDecoderConfig( DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); - int bytes_per_channel = av_get_bytes_per_sample(codec_context->sample_fmt); + + AVSampleFormat sample_format = codec_context->sample_fmt; + if (codec == kCodecOpus) { + // TODO(tomfinegan): |sample_fmt| in |codec_context| is -1... because + // libopusdec.c isn't built into ffmpegsumo...? Maybe it's not *that* big + // a deal since libopus will produce either float or S16 samples, and + // OpusAudioDecoder is the only provider of Opus support. + sample_format = AV_SAMPLE_FMT_S16; + } + + int bytes_per_channel = av_get_bytes_per_sample(sample_format); ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout(codec_context->channel_layout, codec_context->channels); |