demux: boost read EBU R128 gain values to ReplayGain's reference level

Without this change the same track encoded as Opus - which requires R128
tagging - and e.g. Vorbis with ReplayGain tagging have different volumes.
This is caused by ReplayGain 2 having a higher reference level of -18 dB
LUFS, while EBU R128 has a lower reference level of -23 dB LUFS.

For the results of gain application to match, the read EBU R128
values need to be boosted according to the difference in reference
levels.

Patch inspired by mpd's source code.
This commit is contained in:
Simon Ruderich 2023-01-03 09:14:17 +01:00 committed by Jan Ekström
parent aa8ddfcdf3
commit c153eb7d01
1 changed files with 5 additions and 0 deletions

View File

@ -2963,6 +2963,11 @@ static struct replaygain_data *decode_rgain(struct mp_log *log,
}
rg.track_gain /= 256.;
rg.album_gain /= 256.;
// Add 5dB to compensate for the different reference levels between
// our reference of ReplayGain 2 (-18 LUFS) and EBU R128 (-23 LUFS).
rg.track_gain += 5.;
rg.album_gain += 5.;
return talloc_dup(NULL, &rg);
}