diff options
author | Simon Ruderich <simon@ruderich.org> | 2023-01-03 09:14:17 +0100 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2023-01-04 14:05:22 +0200 |
commit | c153eb7d01508a3cd21f3e90cf7e00ad15b3a5d3 (patch) | |
tree | 157754912a9a15cf0db06e7eaafd314d1741ae38 /demux | |
parent | aa8ddfcdf30c4ffb38f3ec5d6663bbabf0b7b4df (diff) | |
download | mpv-c153eb7d01508a3cd21f3e90cf7e00ad15b3a5d3.tar.bz2 mpv-c153eb7d01508a3cd21f3e90cf7e00ad15b3a5d3.tar.xz |
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.
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/demux/demux.c b/demux/demux.c index e1ef65a733..b6e85330ed 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -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); } |