From 723055019128a4ab2016e88286d8ecaba64f8497 Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 1 Apr 2022 22:26:23 +0200 Subject: [PATCH] vf_format: support forwarding/stripping film grain metadata --- DOCS/interface-changes.rst | 1 + DOCS/man/vf.rst | 4 ++++ video/filter/vf_format.c | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index c84aed05ca..94c789f4a9 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -40,6 +40,7 @@ Interface changes `--tone-mapping-desaturate-exponent`. - add `dolbyvision` sub-parameter to `format` video filter - `--sub-visibility` no longer has any effect on secondary subtitles + - add `film-grain` sub-parameter to `format` video filter --- mpv 0.34.0 --- - deprecate selecting by card number with `--drm-connector`, add `--drm-device` which can be used instead diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst index 69454c5cd2..10635811df 100644 --- a/DOCS/man/vf.rst +++ b/DOCS/man/vf.rst @@ -312,6 +312,10 @@ Available mpv-only filters are: Whether or not to include Dolby Vision metadata (default: yes). If disabled, any Dolby Vision metadata will be stripped from frames. + ```` + Whether or not to include film grain metadata (default: yes). If + disabled, any film grain metadata will be stripped from frames. + ```` Set the stereo mode the video is assumed to be encoded in. Use ``--vf=format:stereo-in=help`` to list all available modes. Check with diff --git a/video/filter/vf_format.c b/video/filter/vf_format.c index 9cb7ca87aa..8fd43450e3 100644 --- a/video/filter/vf_format.c +++ b/video/filter/vf_format.c @@ -58,6 +58,7 @@ struct vf_format_opts { int convert; int force_scaler; int dovi; + int film_grain; }; static void set_params(struct vf_format_opts *p, struct mp_image_params *out, @@ -156,6 +157,9 @@ static void vf_format_process(struct mp_filter *f) if (!priv->opts->dovi) av_buffer_unref(&img->dovi); + if (!priv->opts->film_grain) + av_buffer_unref(&img->film_grain); + write_out: mp_pin_in_write(f->ppins[1], frame); } @@ -215,6 +219,7 @@ static const m_option_t vf_opts_fields[] = { {"dar", OPT_DOUBLE(dar)}, {"convert", OPT_FLAG(convert)}, {"dolbyvision", OPT_FLAG(dovi)}, + {"film-grain", OPT_FLAG(film_grain)}, {"force-scaler", OPT_CHOICE(force_scaler, {"auto", MP_SWS_AUTO}, {"sws", MP_SWS_SWS}, @@ -232,6 +237,7 @@ const struct mp_user_filter_entry vf_format = { .priv_defaults = &(const OPT_BASE_STRUCT){ .rotate = -1, .dovi = 1, + .film_grain = 1, }, .options = vf_opts_fields, },