aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-02-10 11:54:57 +0100
committerNiklas Haas <git@haasn.dev>2024-02-13 15:56:03 +0100
commit3bf80df3ccd32aed23f09a7e1b3b9e6700e65b15 (patch)
treec681700e75235b77feaf4e536922fb847ca5c8b9 /libavfilter
parentaa3bf6d41c1a78262244766c517084bfef953666 (diff)
downloadffmpeg-3bf80df3ccd32aed23f09a7e1b3b9e6700e65b15.tar.gz
avfilter/vf_setparams: use YUV colorspace negotiation API
When this filter overrides frame properties, the outgoing frames have a different YUV colorspace than the incoming ones. This requires signalling the new colorspace on the outlink, and in particular, making sure it's *not* set to a common ref with the input - otherwise the point of this filter would be destroyed. Untouched fields will continue being passed through, so we don't need to do anything there.
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_setparams.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
index ae4c937518..a33c35a942 100644
--- a/libavfilter/vf_setparams.c
+++ b/libavfilter/vf_setparams.c
@@ -23,6 +23,7 @@
#include "libavutil/pixfmt.h"
#include "libavutil/opt.h"
#include "avfilter.h"
+#include "formats.h"
#include "internal.h"
#include "video.h"
@@ -120,6 +121,29 @@ static const AVOption setparams_options[] = {
AVFILTER_DEFINE_CLASS(setparams);
+static int query_formats(AVFilterContext *ctx)
+{
+ SetParamsContext *s = ctx->priv;
+ AVFilterLink *outlink = ctx->outputs[0];
+ int ret;
+
+ if (s->colorspace >= 0) {
+ ret = ff_formats_ref(ff_make_formats_list_singleton(s->colorspace),
+ &outlink->incfg.color_spaces);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (s->color_range >= 0) {
+ ret = ff_formats_ref(ff_make_formats_list_singleton(s->color_range),
+ &outlink->incfg.color_ranges);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
AVFilterContext *ctx = inlink->dst;
@@ -177,6 +201,7 @@ const AVFilter ff_vf_setparams = {
.flags = AVFILTER_FLAG_METADATA_ONLY,
FILTER_INPUTS(inputs),
FILTER_OUTPUTS(ff_video_default_filterpad),
+ FILTER_QUERY_FUNC(query_formats),
};
#if CONFIG_SETRANGE_FILTER
@@ -217,6 +242,7 @@ const AVFilter ff_vf_setrange = {
.flags = AVFILTER_FLAG_METADATA_ONLY,
FILTER_INPUTS(inputs),
FILTER_OUTPUTS(ff_video_default_filterpad),
+ FILTER_QUERY_FUNC(query_formats),
};
#endif /* CONFIG_SETRANGE_FILTER */