History

avfilter/vf_thumbnail: switch to query_func2

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

Niklas Haas committed 1 year ago

Commit 0a5ae741 parent cf18b281 file · +32 −10Browse files

Unified · Split

libavfilter/vf_thumbnail.c+32−10
@@ -32,6 +32,7 @@ · 31 unmodified lines
32#include "libavutil/pixdesc.h"32#include "libavutil/pixdesc.h"
33#include "avfilter.h"33#include "avfilter.h"
34#include "filters.h"34#include "filters.h"
35#include "formats.h"
35 36
36#define HIST_SIZE (3*256)37#define HIST_SIZE (3*256)
37 38
@@ -305,23 +306,44 @@ static int config_props(AVFilterLink *inlink) · 267 unmodified lines
305 return 0;306 return 0;
306}307}
307 308
308static const enum AVPixelFormat pix_fmts[] = {309static const enum AVPixelFormat packed_rgb_fmts[] = {
309 AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,310 AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
310 AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA,311 AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA,
311 AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0,312 AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0,
312 AV_PIX_FMT_ABGR, AV_PIX_FMT_ARGB,313 AV_PIX_FMT_ABGR, AV_PIX_FMT_ARGB,
313 AV_PIX_FMT_0BGR, AV_PIX_FMT_0RGB,314 AV_PIX_FMT_0BGR, AV_PIX_FMT_0RGB,
314 AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
315 AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
316 AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
317 AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
318 AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
319 AV_PIX_FMT_YUVJ411P,
320 AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
321 AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
322 AV_PIX_FMT_NONE315 AV_PIX_FMT_NONE
323};316};
324 317
318static int query_formats(const AVFilterContext *ctx,
319 AVFilterFormatsConfig **cfg_in,
320 AVFilterFormatsConfig **cfg_out)
321{
322 const AVPixFmtDescriptor *desc = NULL;
323 AVFilterFormats *formats;
324
325 formats = ff_make_format_list(packed_rgb_fmts);
326 if (!formats)
327 return AVERROR(ENOMEM);
328
329
330 while ((desc = av_pix_fmt_desc_next(desc))) {
331 int color_comps = desc->nb_components - !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
332 if ((color_comps == 1 || (desc->flags & AV_PIX_FMT_FLAG_PLANAR)) &&
333 !(desc->flags & (AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_BITSTREAM)) &&
334 (desc->comp[0].depth <= 8 || HAVE_BIGENDIAN == !!(desc->flags & AV_PIX_FMT_FLAG_BE)) &&
335 (desc->nb_components < 3 || desc->comp[1].plane != desc->comp[2].plane) &&
336 desc->comp[0].depth <= 16)
337 {
338 int ret = ff_add_format(&formats, av_pix_fmt_desc_get_id(desc));
339 if (ret < 0)
340 return ret;
341 }
342 }
343
344 return ff_set_common_formats2(ctx, cfg_in, cfg_out, formats);
345}
346
325static const AVFilterPad thumbnail_inputs[] = {347static const AVFilterPad thumbnail_inputs[] = {
326 {348 {
327 .name = "default",349 .name = "default",
@@ -350,5 +372,5 @@ const FFFilter ff_vf_thumbnail = { · 22 unmodified lines
350 .uninit = uninit,372 .uninit = uninit,
351 FILTER_INPUTS(thumbnail_inputs),373 FILTER_INPUTS(thumbnail_inputs),
352 FILTER_OUTPUTS(thumbnail_outputs),374 FILTER_OUTPUTS(thumbnail_outputs),
353 FILTER_PIXFMTS_ARRAY(pix_fmts),375 FILTER_QUERY_FUNC2(query_formats),
354};376};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t