mirror of https://github.com/mpv-player/mpv
af_volume: add detach option
Maybe this should be default. On the other hand, this filter does something even if the volume is neutral: it clips samples against the allowed range, should the decoder or a previous filter output garbage.
This commit is contained in:
parent
b72ba3f744
commit
dc0f2308d1
|
@ -301,6 +301,12 @@ Available filters are:
|
|||
``s16``
|
||||
Force S16 sample format if set. Lower quality, but might be faster
|
||||
in some situations.
|
||||
``detach``
|
||||
Remove the filter if the volume is not changed at audio filter config
|
||||
time. Useful with replaygain: if the current file has no replaygain
|
||||
tags, then the filter will be removed if this option is enabled.
|
||||
(If ``--softvol=yes`` is used and the player volume controls are used
|
||||
during playback, a different volume filter will be inserted.)
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ struct priv {
|
|||
int rgain_clip; // Enable/disable clipping prevention
|
||||
int soft; // Enable/disable soft clipping
|
||||
int fast; // Use fix-point volume control
|
||||
int detach; // Detach if gain volume is neutral
|
||||
float cfg_volume;
|
||||
};
|
||||
|
||||
|
@ -136,6 +137,8 @@ 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)
|
||||
return AF_DETACH;
|
||||
return af_test_output(af, in);
|
||||
}
|
||||
case AF_CONTROL_SET_VOLUME:
|
||||
|
@ -209,6 +212,7 @@ struct af_info af_info_volume = {
|
|||
OPT_FLAG("replaygain-clip", rgain_clip, 0),
|
||||
OPT_FLAG("softclip", soft, 0),
|
||||
OPT_FLAG("s16", fast, 0),
|
||||
OPT_FLAG("detach", detach, 0),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue