fftools/ffmpeg_{filter,mux_init}: Improve type-safety

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2026-01-30 01:01:45 +01:00
parent 67c87cde99
commit 39661f9295
3 changed files with 15 additions and 9 deletions
+4 -1
View File
@@ -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;
+9 -6
View File
@@ -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);
+2 -2
View File
@@ -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,