summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authordatasone <datasone@datasone.moe>2022-04-20 21:56:51 +0800
committerDudemanguy <random342@airmail.cc>2022-04-28 20:13:36 +0000
commitee62a1a56e5d0b9cdf121a17577c9838148e885d (patch)
treeeeb45b06f9fb4540e63a96b401ff82e3800503e2 /demux
parent05f0ff304ee5c6b7b531ce3b89a8793987c4fe1c (diff)
downloadmpv-ee62a1a56e5d0b9cdf121a17577c9838148e885d.tar.bz2
mpv-ee62a1a56e5d0b9cdf121a17577c9838148e885d.tar.xz
demux: add support for r128 replaygain tags
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/demux/demux.c b/demux/demux.c
index d9216e16d2..f6b0448791 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -2942,6 +2942,19 @@ static struct replaygain_data *decode_rgain(struct mp_log *log,
return talloc_dup(NULL, &rg);
}
+ // The r128 replaygain tags declared in RFC 7845 for opus files. The tags
+ // are generated with EBU-R128, which does not use peak meters. And the
+ // values are stored as a Q7.8 fixed point number in dB.
+ if (decode_gain(log, tags, "R128_TRACK_GAIN", &rg.track_gain) >= 0) {
+ if (decode_gain(log, tags, "R128_ALBUM_GAIN", &rg.album_gain) < 0) {
+ // Album gain is undefined; fall back to track gain.
+ rg.album_gain = rg.track_gain;
+ }
+ rg.track_gain /= 256.;
+ rg.album_gain /= 256.;
+ return talloc_dup(NULL, &rg);
+ }
+
return NULL;
}