0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

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.
This commit is contained in:
wm4 2014-03-27 21:12:22 +01:00
parent e8d952c807
commit cd2d4ebf3b

View File

@ -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;