From a5f53da229f0f3f5b7e248c47061a67f6d61d81e Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 12 Jan 2018 04:16:39 +0100 Subject: af_lavrresample: deprecate this filter The future direction might be not having such a user-visible filter at all, similar to how vf_scale went away (or actually, redirects to libavfilter's vf_scale). --- DOCS/interface-changes.rst | 2 ++ DOCS/man/af.rst | 6 ++++++ audio/filter/af.c | 6 ++++-- audio/filter/af_lavrresample.c | 8 ++++++++ player/audio.c | 10 +++++++--- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index a269859c39..ce60e72f6d 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -33,6 +33,8 @@ Interface changes its defaults), and various hw deinterlacing filters (like vf_vavpp), for which you will have to stop using --deinterlace=yes, and instead use the vf toggle commands and the filter enable/disable flag to customize it. + - deprecate --af=lavrresample. Use the ``--audio-resample-...`` options to + customize resampling, or the libavfilter ``--af=aresample`` filter. --- mpv 0.28.0 --- - rename --hwdec=mediacodec option to mediacodec-copy, to reflect conventions followed by other hardware video decoding APIs diff --git a/DOCS/man/af.rst b/DOCS/man/af.rst index e0431713fa..5a13bb4495 100644 --- a/DOCS/man/af.rst +++ b/DOCS/man/af.rst @@ -29,6 +29,12 @@ Available filters are: This filter is automatically enabled if the audio output does not support the audio configuration of the file being played. + .. warning:: + + Deprecated. Either use the ``--audio-resample-...`` options to customize + resampling, or the libavfilter ``--af=aresample`` filter, which has its + own options. + It supports only the following sample formats: u8, s16, s32, float. ``filter-size=`` diff --git a/audio/filter/af.c b/audio/filter/af.c index 35525d0774..cf200bbb84 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -341,8 +341,9 @@ static int filter_reinit_with_conversion(struct af_stream *s, struct af_instance } if (!mp_audio_config_equals(af->prev->data, &in)) { // Retry with conversion filter added. + char *opts[] = {"deprecation-warning", "no", NULL}; struct af_instance *new = - af_prepend(s, af, "lavrresample", NULL); + af_prepend(s, af, "lavrresample", opts); if (!new) return AF_ERROR; new->auto_inserted = true; @@ -408,7 +409,8 @@ static int af_do_reinit(struct af_stream *s, bool second_pass) s->first->fmt_in = s->first->fmt_out = s->input; if (mp_audio_config_valid(&convert_early)) { - struct af_instance *new = af_prepend(s, s->first, "lavrresample", NULL); + char *opts[] = {"deprecation-warning", "no", NULL}; + struct af_instance *new = af_prepend(s, s->first, "lavrresample", opts); if (!new) return AF_ERROR; new->auto_inserted = true; diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index 96387060b1..f13093da40 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -45,6 +45,7 @@ struct af_resample { struct mp_resample_opts opts; int global_normalize; struct mp_aconverter *converter; + int deprecation_warning; }; static int control(struct af_instance *af, int cmd, void *arg) @@ -149,6 +150,11 @@ static int af_open(struct af_instance *af) s->converter = mp_aconverter_create(af->global, af->log, &s->opts); + if (s->deprecation_warning) { + MP_WARN(af, "This filter is deprecated! Use the --audio-resample- options" + " to customize resampling, or the --af=aresample filter.\n"); + } + return AF_OK; } @@ -183,6 +189,7 @@ const struct af_info af_info_lavrresample = { .opts = MP_RESAMPLE_OPTS_DEF, .playback_speed = 1.0, .allow_detach = 1, + .deprecation_warning = 1, }, .options = (const struct m_option[]) { OPT_INTRANGE("filter-size", opts.filter_size, 0, 0, 32), @@ -193,6 +200,7 @@ const struct af_info af_info_lavrresample = { OPT_CHOICE("normalize", opts.normalize, 0, ({"no", 0}, {"yes", 1}, {"auto", -1})), OPT_KEYVALUELIST("o", opts.avopts, 0), + OPT_FLAG("deprecation-warning", deprecation_warning, 0), {0} }, .set_defaults = set_defaults, diff --git a/player/audio.c b/player/audio.c index 598e145147..9b842a9003 100644 --- a/player/audio.c +++ b/player/audio.c @@ -110,10 +110,14 @@ static void recreate_speed_filters(struct MPContext *mpctx) return; int method = get_speed_method(mpctx); - char *filter = method == AF_CONTROL_SET_PLAYBACK_SPEED - ? "scaletempo" : "lavrresample"; + char *filter = "lavrresample"; + char *args[] = {"deprecation-warning", "no", NULL}; + if (method == AF_CONTROL_SET_PLAYBACK_SPEED) { + filter = "scaletempo"; + args[0] = NULL; + } - if (!af_add(afs, filter, "playback-speed", NULL)) + if (!af_add(afs, filter, "playback-speed", args)) goto fail; if (!update_speed_filters(mpctx)) -- cgit v1.2.3