summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2022-01-07 06:41:55 +0100
committerNiklas Haas <github-daiK1o@haasn.dev>2022-01-09 13:06:27 +0100
commit05ccc51d53424a771ece5bb818713d474d7874ce (patch)
tree62ceba70b76d8ab33ff081c45477400103f9dc83
parent88047f7654f4b83ad9c4dc9e0a21221e7b380ee0 (diff)
downloadmpv-05ccc51d53424a771ece5bb818713d474d7874ce.tar.bz2
mpv-05ccc51d53424a771ece5bb818713d474d7874ce.tar.xz
vf_format: add dolbyvision sub-option
Useful to strip dolbyvision from the output, in cases where the user does not want it applied. Doing this as a video filter gives users the abiilty to easily toggle this stripping at runtime in a way that properly propagates to any (potentially stateful) VO. It also thematically fits the rest of the options in vf_format, which are similarly concerned with modifying the video image parameters.
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/vf.rst4
-rw-r--r--video/filter/vf_format.c10
3 files changed, 13 insertions, 2 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 48c5b62881..63a08071ec 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -38,6 +38,7 @@ Interface changes
- add `--gamut-mapping-mode`, replacing `--gamut-clipping` and `--gamut-warning`
- add `--tone-mapping-mode`, replacing `--tone-mapping-desaturate` and
`--tone-mapping-desaturate-exponent`.
+ - add `dolbyvision` 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 d80a8aa988..69454c5cd2 100644
--- a/DOCS/man/vf.rst
+++ b/DOCS/man/vf.rst
@@ -308,6 +308,10 @@ Available mpv-only filters are:
:709-1886: Scene-referred using the BT709+BT1886 interaction
:gamma1.2: Scene-referred using a pure power OOTF (gamma=1.2)
+ ``<dolbyvision=yes|no>``
+ Whether or not to include Dolby Vision metadata (default: yes). If
+ disabled, any Dolby Vision metadata will be stripped from frames.
+
``<stereo-in>``
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 b0cf04db7a..8aea1d5498 100644
--- a/video/filter/vf_format.c
+++ b/video/filter/vf_format.c
@@ -22,6 +22,7 @@
#include <math.h>
#include <libavutil/rational.h>
+#include <libavutil/buffer.h>
#include "common/msg.h"
#include "common/common.h"
@@ -56,6 +57,7 @@ struct vf_format_opts {
double dar;
int convert;
int force_scaler;
+ int dovi;
};
static void set_params(struct vf_format_opts *p, struct mp_image_params *out,
@@ -141,14 +143,16 @@ static void vf_format_process(struct mp_filter *f)
if (mp_pin_can_transfer_data(f->ppins[1], priv->conv->f->pins[1])) {
struct mp_frame frame = mp_pin_out_read(priv->conv->f->pins[1]);
+ struct mp_image *img = frame.data;
if (!priv->opts->convert && frame.type == MP_FRAME_VIDEO) {
- struct mp_image *img = frame.data;
-
set_params(priv->opts, &img->params, false);
mp_image_params_guess_csp(&img->params);
}
+ if (!priv->opts->dovi)
+ av_buffer_unref(&img->dovi);
+
mp_pin_in_write(f->ppins[1], frame);
}
}
@@ -206,6 +210,7 @@ static const m_option_t vf_opts_fields[] = {
{"dh", OPT_INT(dh)},
{"dar", OPT_DOUBLE(dar)},
{"convert", OPT_FLAG(convert)},
+ {"dolbyvision", OPT_FLAG(dovi)},
{"force-scaler", OPT_CHOICE(force_scaler,
{"auto", MP_SWS_AUTO},
{"sws", MP_SWS_SWS},
@@ -222,6 +227,7 @@ const struct mp_user_filter_entry vf_format = {
.priv_size = sizeof(OPT_BASE_STRUCT),
.priv_defaults = &(const OPT_BASE_STRUCT){
.rotate = -1,
+ .dovi = 1,
},
.options = vf_opts_fields,
},