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

Unified Diff: media/filters/opus_audio_decoder.cc

Issue 104873011: Add support for setting OPUS header gain. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/opus_audio_decoder.cc
diff --git a/media/filters/opus_audio_decoder.cc b/media/filters/opus_audio_decoder.cc
index e3567209f1a83063e484af89f9222bc693dbe445..c1de6df21586d20806551d53e6b86bdf29d6452a 100644
--- a/media/filters/opus_audio_decoder.cc
+++ b/media/filters/opus_audio_decoder.cc
@@ -157,6 +157,9 @@ static const int kOpusExtraDataChannelsOffset = 9;
// Offset to the pre-skip value in the Opus extra data.
static const int kOpusExtraDataSkipSamplesOffset = 10;
+// Offset to the gain value in the Opus extra data.
+static const int kOpusExtraDataGainOffset = 16;
+
// Offset to the channel mapping byte in the Opus extra data.
static const int kOpusExtraDataChannelMappingOffset = 18;
@@ -179,16 +182,18 @@ struct OpusExtraData {
skip_samples(0),
channel_mapping(0),
num_streams(0),
- num_coupled(0) {
+ num_coupled(0),
+ gain_db(0) {
memcpy(stream_map,
kDefaultOpusChannelLayout,
kMaxChannelsWithDefaultLayout);
}
int channels;
- int skip_samples;
+ uint16 skip_samples;
int channel_mapping;
int num_streams;
int num_coupled;
+ int16 gain_db;
uint8 stream_map[kMaxVorbisChannels];
};
@@ -213,6 +218,8 @@ static bool ParseOpusExtraData(const uint8* data, int data_size,
extra_data->skip_samples =
ReadLE16(data, data_size, kOpusExtraDataSkipSamplesOffset);
+ extra_data->gain_db = static_cast<int16>(
+ ReadLE16(data, data_size, kOpusExtraDataGainOffset));
extra_data->channel_mapping = *(data + kOpusExtraDataChannelMappingOffset);
@@ -502,6 +509,14 @@ bool OpusAudioDecoder::ConfigureDecoder() {
return false;
}
+ status = opus_multistream_decoder_ctl(
+ opus_decoder_, OPUS_SET_GAIN(opus_extra_data.gain_db));
+ if (status != OPUS_OK) {
+ DLOG(ERROR) << "Failed to set OPUS header gain; status="
+ << opus_strerror(status);
+ return false;
+ }
+
channel_layout_ = config.channel_layout();
samples_per_second_ = config.samples_per_second();
output_timestamp_helper_.reset(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698