You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avfilter/vf_libplacebo: list AV_PIX_FMT_VULKAN first
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.
This commit is contained in:
@ -1168,8 +1168,17 @@ static int libplacebo_query_format(const AVFilterContext *ctx,
|
|||||||
const AVPixFmtDescriptor *desc = NULL;
|
const AVPixFmtDescriptor *desc = NULL;
|
||||||
AVFilterFormats *infmts = NULL, *outfmts = 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))) {
|
while ((desc = av_pix_fmt_desc_next(desc))) {
|
||||||
enum AVPixelFormat pixfmt = av_pix_fmt_desc_get_id(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
|
#if PL_API_VER < 232
|
||||||
// Older libplacebo can't handle >64-bit pixel formats, so safe-guard
|
// Older libplacebo can't handle >64-bit pixel formats, so safe-guard
|
||||||
@ -1178,9 +1187,6 @@ static int libplacebo_query_format(const AVFilterContext *ctx,
|
|||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pixfmt == AV_PIX_FMT_VULKAN && !s->have_hwdevice)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!pl_test_pixfmt(s->gpu, pixfmt))
|
if (!pl_test_pixfmt(s->gpu, pixfmt))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1191,15 +1197,8 @@ static int libplacebo_query_format(const AVFilterContext *ctx,
|
|||||||
continue; /* BE formats are not supported by pl_download_avframe */
|
continue; /* BE formats are not supported by pl_download_avframe */
|
||||||
|
|
||||||
/* Mask based on user specified format */
|
/* Mask based on user specified format */
|
||||||
if (s->out_format != AV_PIX_FMT_NONE) {
|
if (pixfmt != s->out_format && s->out_format != AV_PIX_FMT_NONE)
|
||||||
if (pixfmt == AV_PIX_FMT_VULKAN && av_vkfmt_from_pixfmt(s->out_format)) {
|
continue;
|
||||||
/* OK */
|
|
||||||
} else if (pixfmt == s->out_format) {
|
|
||||||
/* OK */
|
|
||||||
} else {
|
|
||||||
continue; /* Not OK */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if PL_API_VER >= 293
|
#if PL_API_VER >= 293
|
||||||
if (!pl_test_pixfmt_caps(s->gpu, pixfmt, PL_FMT_CAP_RENDERABLE))
|
if (!pl_test_pixfmt_caps(s->gpu, pixfmt, PL_FMT_CAP_RENDERABLE))
|
||||||
|
Reference in New Issue
Block a user