From cd2d4ebf3b05e9cfefbb868e45ed71728178a99c Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 27 Mar 2014 21:12:22 +0100 Subject: af_volume: fix replaygain This was accidentally broken in commit b72ba3f7. I somehow made the wild assumption that replaygain adjusted the volume relative to 0% instead of 100%. The detach suboption was similarly broken. --- audio/filter/af_volume.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'audio') diff --git a/audio/filter/af_volume.c b/audio/filter/af_volume.c index 8c24568187..20131eb8aa 100644 --- a/audio/filter/af_volume.c +++ b/audio/filter/af_volume.c @@ -115,6 +115,7 @@ static int control(struct af_instance *af, int cmd, void *arg) } if (af_fmt_is_planar(in->format)) mp_audio_set_format(af->data, af_fmt_to_planar(af->data->format)); + s->rgain = 1.0; if ((s->rgain_track || s->rgain_album) && af->metadata) { float gain, peak; char *gain_tag = NULL, *peak_tag = NULL; @@ -137,7 +138,7 @@ static int control(struct af_instance *af, int cmd, void *arg) s->rgain = MPMIN(s->rgain, 1.0 / peak); } } - if (s->detach && fabs(s->level + s->rgain - 1.0) < 0.00001) + if (s->detach && fabs(s->level + s->rgain - 2.0) < 0.00001) return AF_DETACH; return af_test_output(af, in); } @@ -155,7 +156,7 @@ static void filter_plane(struct af_instance *af, void *ptr, int num_samples) { struct priv *s = af->priv; - float level = s->level + s->rgain; + float level = s->level + s->rgain - 1.0; if (af_fmt_from_planar(af->data->format) == AF_FORMAT_S16) { int16_t *a = ptr; -- cgit v1.2.3