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

Unified 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: Move opus support behind a flag, and add canPlayType support. 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 side-by-side diff with in-line comments
Download patch
Index: media/ffmpeg/ffmpeg_common.cc
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
index c79e4807faf66c09006ba6508e66fc5c3bfa0822..0aacc5288d1b22bd5256c3b00035034359937045 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;
}
@@ -230,6 +234,14 @@ void AVCodecContextToAudioDecoderConfig(
codec_context->channels);
int samples_per_second = codec_context->sample_rate;
+ 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.
+ bytes_per_channel = av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
+ }
+
config->Initialize(codec,
bytes_per_channel << 3,
channel_layout,

Powered by Google App Engine
This is Rietveld 408576698