* [FFmpeg-devel] [PR] avfilter/formats,vsrc_testsrc: use type-safe formats functions (PR #21606)
@ 2026-01-30 0:24 mkver via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: mkver via ffmpeg-devel @ 2026-01-30 0:24 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: mkver
PR #21606 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21606
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21606.patch
>From 53a0e6e90bd5c54cf0a9423d9272a69dc9bcfef9 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Fri, 30 Jan 2026 00:56:49 +0100
Subject: [PATCH 1/2] avfilter/formats,vsrc_testsrc: use type-safe formats
functions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavfilter/formats.c | 4 ++--
libavfilter/vsrc_testsrc.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 2186eb1619..6fbdeb2d26 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -1179,11 +1179,11 @@ int ff_default_query_formats(AVFilterContext *ctx)
switch (f->formats_state) {
case FF_FILTER_FORMATS_PIXFMT_LIST:
type = AVMEDIA_TYPE_VIDEO;
- formats = ff_make_format_list(f->formats.pixels_list);
+ formats = ff_make_pixel_format_list(f->formats.pixels_list);
break;
case FF_FILTER_FORMATS_SAMPLEFMTS_LIST:
type = AVMEDIA_TYPE_AUDIO;
- formats = ff_make_format_list(f->formats.samples_list);
+ formats = ff_make_sample_format_list(f->formats.samples_list);
break;
case FF_FILTER_FORMATS_SINGLE_PIXFMT:
type = AVMEDIA_TYPE_VIDEO;
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 4d7288f18a..bfc3491596 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -1493,7 +1493,7 @@ static int smptebars_query_formats(const AVFilterContext *ctx,
if ((ret = ff_set_common_color_ranges2(ctx, cfg_in, cfg_out,
ff_make_formats_list_singleton(AVCOL_RANGE_MPEG))))
return ret;
- return ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, smptebars_pix_fmts);
+ return ff_set_pixel_formats_from_list2(ctx, cfg_in, cfg_out, smptebars_pix_fmts);
}
AVFILTER_DEFINE_CLASS_EXT(palbars, "pal(75|100)bars", options);
@@ -2260,7 +2260,7 @@ static int zoneplate_query_formats(const AVFilterContext *ctx,
if ((ret = ff_set_common_color_ranges2(ctx, cfg_in, cfg_out,
ff_make_formats_list_singleton(AVCOL_RANGE_JPEG))))
return ret;
- return ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, zoneplate_pix_fmts);
+ return ff_set_pixel_formats_from_list2(ctx, cfg_in, cfg_out, zoneplate_pix_fmts);
}
static const AVFilterPad avfilter_vsrc_zoneplate_outputs[] = {
--
2.52.0
>From 32793f755fb605bbf7f4970adc1566fb4ba761ca Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Fri, 30 Jan 2026 01:01:45 +0100
Subject: [PATCH 2/2] fftools/ffmpeg_{filter,mux_init}: Improve type-safety
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
fftools/ffmpeg.h | 5 ++++-
fftools/ffmpeg_filter.c | 15 +++++++++------
fftools/ffmpeg_mux_init.c | 4 ++--
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7720dd9c59..3e66534d48 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -347,7 +347,10 @@ typedef struct OutputFilterOptions {
int sample_rate;
AVChannelLayout ch_layout;
- const int *formats;
+ union {
+ const enum AVPixelFormat *pix_fmts;
+ const enum AVSampleFormat *sample_fmts;
+ };
const int *sample_rates;
const AVChannelLayout *ch_layouts;
const AVRational *frame_rates;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 4387c992da..765b65d0ec 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -223,7 +223,10 @@ typedef struct OutputFilterPriv {
// those are only set if no format is specified and the encoder gives us multiple options
// They point directly to the relevant lists of the encoder.
- const int *formats;
+ union {
+ const enum AVPixelFormat *pix_fmts;
+ const enum AVSampleFormat *sample_fmts;
+ };
const AVChannelLayout *ch_layouts;
const int *sample_rates;
const enum AVColorSpace *color_spaces;
@@ -399,10 +402,10 @@ static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \
av_bprint_chars(bprint, ':', 1); \
}
-DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, formats,
+DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, pix_fmts,
AV_PIX_FMT_NONE, "%s", av_get_pix_fmt_name)
-DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats,
+DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, sample_fmts,
AV_SAMPLE_FMT_NONE, "%s", av_get_sample_fmt_name)
DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0,
@@ -859,7 +862,7 @@ int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc,
if (opts->format != AV_PIX_FMT_NONE) {
ofp->format = opts->format;
} else
- ofp->formats = opts->formats;
+ ofp->pix_fmts = opts->pix_fmts;
if (opts->color_space != AVCOL_SPC_UNSPECIFIED)
ofp->color_space = opts->color_space;
@@ -898,7 +901,7 @@ int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc,
if (opts->format != AV_SAMPLE_FMT_NONE) {
ofp->format = opts->format;
} else {
- ofp->formats = opts->formats;
+ ofp->sample_fmts = opts->sample_fmts;
}
if (opts->sample_rate) {
ofp->sample_rate = opts->sample_rate;
@@ -1702,7 +1705,7 @@ static int configure_output_video_filter(FilterGraphPriv *fgp, AVFilterGraph *gr
}
av_assert0(!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT) ||
- ofp->format != AV_PIX_FMT_NONE || !ofp->formats);
+ ofp->format != AV_PIX_FMT_NONE || !ofp->pix_fmts);
av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
choose_pix_fmts(ofp, &bprint);
choose_color_spaces(ofp, &bprint);
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 0569f62836..4cb8f91d6e 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -949,7 +949,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
if (!keep_pix_fmt) {
ret = avcodec_get_supported_config(enc_ctx, NULL,
AV_CODEC_CONFIG_PIX_FORMAT, 0,
- (const void **) &opts.formats, NULL);
+ (const void **) &opts.pix_fmts, NULL);
if (ret < 0)
return ret;
}
@@ -978,7 +978,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
} else {
ret = avcodec_get_supported_config(enc_ctx, NULL,
AV_CODEC_CONFIG_SAMPLE_FORMAT, 0,
- (const void **) &opts.formats, NULL);
+ (const void **) &opts.sample_fmts, NULL);
if (ret < 0)
return ret;
ret = avcodec_get_supported_config(enc_ctx, NULL,
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-30 0:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-30 0:24 [FFmpeg-devel] [PR] avfilter/formats,vsrc_testsrc: use type-safe formats functions (PR #21606) mkver via ffmpeg-devel
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