diff options
author | Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com> | 2014-06-28 02:58:57 +0300 |
---|---|---|
committer | Alessandro Ghedini <alessandro@ghedini.me> | 2014-07-05 00:25:04 +0200 |
commit | 950ef5b75b4f771b017215eaeafd97658352c7d6 (patch) | |
tree | 071405ee473fce9a457dd171d874536c0c0962a7 | |
parent | 0075f8e0cfbeabf927d326f611a1af07595dbafc (diff) | |
download | mpv-950ef5b75b4f771b017215eaeafd97658352c7d6.tar.bz2 mpv-950ef5b75b4f771b017215eaeafd97658352c7d6.tar.xz |
af_volume: fix calculations including replay-gain
rgain is not an additive value. It's a multiplier/gain.
Previous behaviour produced negative level values in some cases
(when rgain < 1.0) which caused volume to be louder when its value
was lowered.
CC: @mpv-player/stable
Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com>
Signed-off-by: wm4 <wm4@nowhere>
-rw-r--r-- | audio/filter/af_volume.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/audio/filter/af_volume.c b/audio/filter/af_volume.c index f07914313b..f9f4a4ac40 100644 --- a/audio/filter/af_volume.c +++ b/audio/filter/af_volume.c @@ -79,7 +79,7 @@ static int control(struct af_instance *af, int cmd, void *arg) if (!s->rgain_clip) // clipping prevention s->rgain = MPMIN(s->rgain, 1.0 / peak); } - if (s->detach && fabs(s->level + s->rgain - 2.0) < 0.00001) + if (s->detach && fabs(s->level * s->rgain - 1.0) < 0.00001) return AF_DETACH; return af_test_output(af, in); } @@ -97,7 +97,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 - 1.0; + float level = s->level * s->rgain; if (af_fmt_from_planar(af->data->format) == AF_FORMAT_S16) { int16_t *a = ptr; |