From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH] avfilter/vf_setparams: use YUV colorspace negotiation API
Date: Sat, 10 Feb 2024 11:56:29 +0100
Message-ID: <20240210105629.11095-1-ffmpeg@haasn.xyz> (raw)
From: Niklas Haas <git@haasn.dev>
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.
---
libavfilter/vf_setparams.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
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 */
--
2.43.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2024-02-10 10:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-10 10:56 Niklas Haas [this message]
2024-02-11 20:48 ` Niklas Haas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240210105629.11095-1-ffmpeg@haasn.xyz \
--to=ffmpeg@haasn.xyz \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=git@haasn.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git