mirror of
https://github.com/mpv-player/mpv
synced 2024-12-11 09:25:56 +00:00
af_lavrresample: add normalize suboption
This commit is contained in:
parent
0eb72d786c
commit
4eae4a5da7
@ -59,6 +59,13 @@ Available filters are:
|
|||||||
(If you just want to set defaults for this filter that will be used
|
(If you just want to set defaults for this filter that will be used
|
||||||
even by automatically inserted lavrresample instances, you should
|
even by automatically inserted lavrresample instances, you should
|
||||||
prefer setting them with ``--af-defaults=lavrresample:...``.)
|
prefer setting them with ``--af-defaults=lavrresample:...``.)
|
||||||
|
``normalize=<yes|no>``
|
||||||
|
Whether to normalize when remixing channel layouts (default: yes). This
|
||||||
|
is e.g. applied when downmixing surround audio to stereo. The advantage
|
||||||
|
is that this guarantees that no clipping can happen. Unfortunately,
|
||||||
|
this can also lead to too low volume levels. Whether you enable or
|
||||||
|
disable this is essentially a matter of taste, but the default uses
|
||||||
|
the safer choice.
|
||||||
``o=<string>``
|
``o=<string>``
|
||||||
Set AVOptions on the SwrContext or AVAudioResampleContext. These should
|
Set AVOptions on the SwrContext or AVAudioResampleContext. These should
|
||||||
be documented by FFmpeg or Libav.
|
be documented by FFmpeg or Libav.
|
||||||
|
@ -65,6 +65,7 @@ struct af_resample_opts {
|
|||||||
int phase_shift;
|
int phase_shift;
|
||||||
int linear;
|
int linear;
|
||||||
double cutoff;
|
double cutoff;
|
||||||
|
int normalize;
|
||||||
|
|
||||||
int in_rate_af; // filter input sample rate
|
int in_rate_af; // filter input sample rate
|
||||||
int in_rate; // actual rate (used by lavr), adjusted for playback speed
|
int in_rate; // actual rate (used by lavr), adjusted for playback speed
|
||||||
@ -234,7 +235,9 @@ static int configure_lavrr(struct af_instance *af, struct mp_audio *in,
|
|||||||
av_opt_set_double(s->avrctx, "cutoff", s->ctx.cutoff, 0);
|
av_opt_set_double(s->avrctx, "cutoff", s->ctx.cutoff, 0);
|
||||||
|
|
||||||
#if HAVE_LIBSWRESAMPLE
|
#if HAVE_LIBSWRESAMPLE
|
||||||
av_opt_set_double(s->avrctx, "rematrix_maxval", 1.0, 0);
|
av_opt_set_double(s->avrctx, "rematrix_maxval", s->opts.normalize ? 1 : 1000, 0);
|
||||||
|
#else
|
||||||
|
av_opt_set_int(s->avrctx, "normalize_mix_level", s->opts.normalize, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mp_set_avopts(af->log, s->avrctx, s->avopts) < 0)
|
if (mp_set_avopts(af->log, s->avrctx, s->avopts) < 0)
|
||||||
@ -546,6 +549,7 @@ const struct af_info af_info_lavrresample = {
|
|||||||
.filter_size = 16,
|
.filter_size = 16,
|
||||||
.cutoff = 0.0,
|
.cutoff = 0.0,
|
||||||
.phase_shift = 10,
|
.phase_shift = 10,
|
||||||
|
.normalize = 1,
|
||||||
},
|
},
|
||||||
.playback_speed = 1.0,
|
.playback_speed = 1.0,
|
||||||
.allow_detach = 1,
|
.allow_detach = 1,
|
||||||
@ -556,6 +560,7 @@ const struct af_info af_info_lavrresample = {
|
|||||||
OPT_FLAG("linear", opts.linear, 0),
|
OPT_FLAG("linear", opts.linear, 0),
|
||||||
OPT_DOUBLE("cutoff", opts.cutoff, M_OPT_RANGE, .min = 0, .max = 1),
|
OPT_DOUBLE("cutoff", opts.cutoff, M_OPT_RANGE, .min = 0, .max = 1),
|
||||||
OPT_FLAG("detach", allow_detach, 0),
|
OPT_FLAG("detach", allow_detach, 0),
|
||||||
|
OPT_FLAG("normalize", opts.normalize, 0),
|
||||||
OPT_KEYVALUELIST("o", avopts, 0),
|
OPT_KEYVALUELIST("o", avopts, 0),
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user