Skip to content

Commit 2dbf8a4

Browse files
committed
opus: do not add 5 dB to Opus header playback gain
The playback gain in the Opus header is not related to any reference like ReplayGain or EBU R128. It thus does not need converting into the ReplayGain "space". This patch thus removes the 5 dB offset from the fallback path in MPDOpusDecoder::HandleAudio (where the Opus header gain is converted into ReplayGain metadata). Otherwise, an Opus file without replay gain tags and with an output gain of 0 dB would get a gain of 5 dB. This leads to clipping if the audio data has less than 5 dB of headroom. The clipping can be reproduced with something as simple as an amplitude 1.0 sine file. One way to create such a file is via audacity: 1. Generate -> Tone... - Waveform = Sine - Frequency = 440 Hz - Amplitude = 1 - Duration = 1m 2. File -> Export Audio - Channels = mono - Sample rate = 48000 Hz - Encoding = signed 16-bit PCM 3. Run opusenc on the resulting file
1 parent 98c06a9 commit 2dbf8a4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/decoder/plugins/OpusDecoderPlugin.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
312312
gain" value */
313313
ReplayGainInfo rgi;
314314
rgi.Clear();
315-
rgi.track.gain = EbuR128ToReplayGain(output_gain);
315+
rgi.track.gain = output_gain;
316316
client.SubmitReplayGain(&rgi);
317317
submitted_replay_gain = true;
318318
}

0 commit comments

Comments
 (0)