From: Niklas Haas <ffmpeg@haasn.xyz> To: ffmpeg-devel@ffmpeg.org Cc: Niklas Haas <git@haasn.dev> Subject: [FFmpeg-devel] [PATCH 1/3] avfilter/vf_libplacebo: list AV_PIX_FMT_VULKAN first Date: Mon, 16 Jun 2025 20:05:28 +0200 Message-ID: <20250616180530.140914-1-ffmpeg@haasn.xyz> (raw) From: Niklas Haas <git@haasn.dev> Under normal circumstances, this change does not affect anything, as the vast majority of filters either support only vulkan or only software formats. However, when a filter supports both (such as vf_libplacebo itself, and possibly vf_scale in the future), linking together two such filter instances without an explicit format will default matching the input format, resulting in a redundant round trip through host RAM. This change bumps up AV_PIX_FMT_VULKAN to the first entry in the format list, ensuring that it gets preferred whenever possible. --- libavfilter/vf_libplacebo.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 9ff64053cc..c7a1b15f92 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -1150,8 +1150,17 @@ static int libplacebo_query_format(const AVFilterContext *ctx, const AVPixFmtDescriptor *desc = NULL; AVFilterFormats *infmts = NULL, *outfmts = NULL; + /* List AV_PIX_FMT_VULKAN first to prefer it when possible */ + if (s->have_hwdevice) { + RET(ff_add_format(&infmts, AV_PIX_FMT_VULKAN)); + if (s->out_format == AV_PIX_FMT_NONE || av_vkfmt_from_pixfmt(s->out_format)) + RET(ff_add_format(&outfmts, AV_PIX_FMT_VULKAN)); + } + while ((desc = av_pix_fmt_desc_next(desc))) { enum AVPixelFormat pixfmt = av_pix_fmt_desc_get_id(desc); + if (pixfmt == AV_PIX_FMT_VULKAN) + continue; /* Handled above */ #if PL_API_VER < 232 // Older libplacebo can't handle >64-bit pixel formats, so safe-guard @@ -1160,9 +1169,6 @@ static int libplacebo_query_format(const AVFilterContext *ctx, continue; #endif - if (pixfmt == AV_PIX_FMT_VULKAN && !s->have_hwdevice) - continue; - if (!pl_test_pixfmt(s->gpu, pixfmt)) continue; @@ -1173,15 +1179,8 @@ static int libplacebo_query_format(const AVFilterContext *ctx, continue; /* BE formats are not supported by pl_download_avframe */ /* Mask based on user specified format */ - if (s->out_format != AV_PIX_FMT_NONE) { - if (pixfmt == AV_PIX_FMT_VULKAN && av_vkfmt_from_pixfmt(s->out_format)) { - /* OK */ - } else if (pixfmt == s->out_format) { - /* OK */ - } else { - continue; /* Not OK */ - } - } + if (pixfmt != s->out_format && s->out_format != AV_PIX_FMT_NONE) + continue; #if PL_API_VER >= 293 if (!pl_test_pixfmt_caps(s->gpu, pixfmt, PL_FMT_CAP_RENDERABLE)) -- 2.49.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:[~2025-06-16 18:05 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-06-16 18:05 Niklas Haas [this message] 2025-06-16 18:05 ` [FFmpeg-devel] [PATCH 2/3] avfilter/vf_libplacebo: correctly update SAR to reflect scaled result Niklas Haas 2025-06-16 18:05 ` [FFmpeg-devel] [PATCH 3/3] avfilter/vf_libplaceb: add `reset_sar` option 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=20250616180530.140914-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