Repository navigation
Take opus output gain into account when checking replaygain_limit peak - #1201
Conversation
gavtroy
left a comment
There was a problem hiding this comment.
Okay. I'm not sure if it's the scenario you encountered but here's the one I see this benefitting:
Some loudness scanners set R128_TRACK_GAIN=0 and encode the replaygain information as an output_gain targeting -23 LUFS. Replaygain is based on -18 LUFS so we add +5 dB. However the limiter needs to know the decoder gain to check the combined gain is not positive, otherwise it will simply refuse to apply the +5 and opus files will play quieter.
I'm still tempted to just disable the limit for opus files. -_-
| db = replaygain_preamp + gain; | ||
|
|
||
| scale = pow(10.0, db / 20.0); | ||
| check_scale = pow(10.0, (db + player_info_priv.ti->output_gain) / 20.0); |
There was a problem hiding this comment.
Wouldn't it make more sense to adjust the fallback peak value (line 384)? Along the lines of
if (isnan(peak))
peak = pow(10.0, player_info_priv.ti->output_gain / 20);
Where output_gain is 0 this will still result in a fallback peak of 1.
There was a problem hiding this comment.
I felt like this made sense because I use the output gain and R128 as a "combined replaygain" such that players that don't respect R128 tags play at -18 LUFS and those that do play at -23 LUFS + preamp. The decision to calculate a separate scale to be used when checking the limit came from this. I don't know if you suggestion results in the same calculation. I think that the assumed peak at 1.0 idea is good, since that way the combination of output gain + R128 is guaranteed to never exceed the original volume of the file.
There was a problem hiding this comment.
Besides, what if there exist both an older replaygain peak tag and output gain? Wouldn't it make more sense not to rely on the non-existence of the peak tag when taking the output gain into consideration? I don't know if the standard allows it, but you could probably make some programs tag the file with rg1.0 tags.
There was a problem hiding this comment.
It's technically possible for an opus file to have a REPLAYGAIN_TRACK_PEAK tag but it's not going to happen in practice and not really worth trying to account for in the code. If it did occur, the output gain would probably be 0 anyway, and if both occurred together, would it describe the peak before or after the output gain is applied?
Using check_scale isn't ideal because when it's exceeded we apply replaygain_scale = limit, and limit won't account for the output_gain. I'm not 100% confident in any of the maths for my suggestion but the results were at least roughly what I was expecting. 🤷
There was a problem hiding this comment.
You're right. The limit wouldn't denote the full volume if output_gain is applied. Your idea to calculate the peak based on output_gain is much better. Changed in 967ebe2.
|
Merged (finally), thanks! |
https://build.opensuse.org/request/show/1176840 by user mia + anag+factory - Update to 2.11.0 * Add support for .nomedia file gh#cmus/cmus#1190 * Fix a typo in an error message gh#cmus/cmus#1206 * Take opus output gain into account when checking replaygain_limit peak gh#cmus/cmus#1201 * #1219: Update Unofficial IRC channel gh#cmus/cmus#1220 * Recognize artist/album sort keys from ffmpeg plugin gh#cmus/cmus#1165 * Fix missing combining marks on last character in a field gh#cmus/cmus#1151 * Use wcwidth for u_char_width gh#cmus/cmus#1198 * Fix under-allocation when many zero-width characters are present gh#cmus/cmus#1152 * Draw title and command lines on first update gh#cmus/cmus#1257 * Switch to -latest os in build workflow gh#cmus/cmus#1265 * ip/mp4: Use MP4FindTrackId() rather than assuming it's
This pull request incorporates the output gain value from opus files when deciding if the replaygain adjustment would go over the 1.0 peak limit. (Issue #1200)
I don't know if this is a good solution to this problem and would appreciate any feedback.