From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id 006474F74C
	for <ffmpegdev@gitmailbox.com>; Sun, 22 Jun 2025 10:16:00 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 927AC68C3B4;
	Sun, 22 Jun 2025 13:15:47 +0300 (EEST)
Received: from haasn.dev (haasn.dev [78.46.187.166])
 by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 6080268C416
 for <ffmpeg-devel@ffmpeg.org>; Sun, 22 Jun 2025 13:15:39 +0300 (EEST)
Received: from haasn.dev (unknown [10.30.1.1])
 by haasn.dev (Postfix) with UTF8SMTP id CE61741E45;
 Sun, 22 Jun 2025 12:15:38 +0200 (CEST)
From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Date: Sun, 22 Jun 2025 12:15:37 +0200
Message-ID: <20250622101537.27956-2-ffmpeg@haasn.xyz>
X-Mailer: git-send-email 2.49.0
In-Reply-To: <20250622101537.27956-1-ffmpeg@haasn.xyz>
References: <20250622101537.27956-1-ffmpeg@haasn.xyz>
MIME-Version: 1.0
Subject: [FFmpeg-devel] [PATCH v3 2/2] avfilter/vf_thumbnail: switch to
 query_func2
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Niklas Haas <git@haasn.dev>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250622101537.27956-2-ffmpeg@haasn.xyz/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

From: Niklas Haas <git@haasn.dev>

Instead of enumerating a static list of planar formats to support, walk
through the format list and enable all supported formats.

As of writing, this generates the following format list:
- gbrap
- gbrap10le
- gbrap12le
- gbrap14le
- gbrap16le
- gbrp
- gbrp10le
- gbrp12le
- gbrp14le
- gbrp16le
- gbrp9le
- gray
- gray10le
- gray12le
- gray14le
- gray16le
- gray9le
- ya16le
- ya8
- yuv410p
- yuv411p
- yuv420p
- yuv420p10le
- yuv420p12le
- yuv420p14le
- yuv420p16le
- yuv420p9le
- yuv422p
- yuv422p10le
- yuv422p12le
- yuv422p14le
- yuv422p16le
- yuv422p9le
- yuv440p
- yuv440p10le
- yuv440p12le
- yuv444p
- yuv444p10le
- yuv444p12le
- yuv444p14le
- yuv444p16le
- yuv444p9le
- yuva420p
- yuva420p10le
- yuva420p16le
- yuva420p9le
- yuva422p
- yuva422p10le
- yuva422p12le
- yuva422p16le
- yuva422p9le
- yuva444p
- yuva444p10le
- yuva444p12le
- yuva444p16le
- yuva444p9le
- yuvj411p
- yuvj420p
- yuvj422p
- yuvj440p
- yuvj444p
---
 libavfilter/vf_thumbnail.c | 42 +++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/libavfilter/vf_thumbnail.c b/libavfilter/vf_thumbnail.c
index 55a0598e50..aff25d19c5 100644
--- a/libavfilter/vf_thumbnail.c
+++ b/libavfilter/vf_thumbnail.c
@@ -32,6 +32,7 @@
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "filters.h"
+#include "formats.h"
 
 #define HIST_SIZE (3*256)
 
@@ -305,23 +306,44 @@ static int config_props(AVFilterLink *inlink)
     return 0;
 }
 
-static const enum AVPixelFormat pix_fmts[] = {
+static const enum AVPixelFormat packed_rgb_fmts[] = {
     AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
     AV_PIX_FMT_RGBA,  AV_PIX_FMT_BGRA,
     AV_PIX_FMT_RGB0,  AV_PIX_FMT_BGR0,
     AV_PIX_FMT_ABGR,  AV_PIX_FMT_ARGB,
     AV_PIX_FMT_0BGR,  AV_PIX_FMT_0RGB,
-    AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
-    AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
-    AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
-    AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
-    AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
-    AV_PIX_FMT_YUVJ411P,
-    AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
-    AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
     AV_PIX_FMT_NONE
 };
 
+static int query_formats(const AVFilterContext *ctx,
+                         AVFilterFormatsConfig **cfg_in,
+                         AVFilterFormatsConfig **cfg_out)
+{
+    const AVPixFmtDescriptor *desc = NULL;
+    AVFilterFormats *formats;
+
+    formats = ff_make_format_list(packed_rgb_fmts);
+    if (!formats)
+        return AVERROR(ENOMEM);
+
+
+    while ((desc = av_pix_fmt_desc_next(desc))) {
+        int color_comps = desc->nb_components - !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
+        if ((color_comps == 1 || (desc->flags & AV_PIX_FMT_FLAG_PLANAR)) &&
+            !(desc->flags & (AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_BITSTREAM)) &&
+            (desc->comp[0].depth <= 8 || HAVE_BIGENDIAN == !!(desc->flags & AV_PIX_FMT_FLAG_BE)) &&
+            (desc->nb_components < 3 || desc->comp[1].plane != desc->comp[2].plane) &&
+            desc->comp[0].depth <= 16)
+        {
+            int ret = ff_add_format(&formats, av_pix_fmt_desc_get_id(desc));
+            if (ret < 0)
+                return ret;
+        }
+    }
+
+    return ff_set_common_formats2(ctx, cfg_in, cfg_out, formats);
+}
+
 static const AVFilterPad thumbnail_inputs[] = {
     {
         .name         = "default",
@@ -350,5 +372,5 @@ const FFFilter ff_vf_thumbnail = {
     .uninit        = uninit,
     FILTER_INPUTS(thumbnail_inputs),
     FILTER_OUTPUTS(thumbnail_outputs),
-    FILTER_PIXFMTS_ARRAY(pix_fmts),
+    FILTER_QUERY_FUNC2(query_formats),
 };
-- 
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".