PR #21612 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21612 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21612.patch
>From 3703d78fd55bab1a5316d47ef90f74861288d200 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 30 Jan 2026 16:48:06 +0100 Subject: [PATCH 1/9] fftools/ffmpeg_mux_init: Improve type-safety This makes fftools -fshort-enums compatible. Signed-off-by: Andreas Rheinhardt <[email protected]> --- fftools/ffmpeg_mux_init.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 4cb8f91d6e..5c0c8ca36f 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -482,9 +482,9 @@ static int parse_matrix_coeffs(void *logctx, uint16_t *dest, const char *str) return 0; } -static int fmt_in_list(const int *formats, int format) +static int pixfmt_in_list(const enum AVPixelFormat *formats, enum AVPixelFormat format) { - for (; *formats != -1; formats++) + for (; *formats != AV_PIX_FMT_NONE; formats++) if (*formats == format) return 1; return 0; @@ -544,7 +544,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) * endianness by av_get_pix_fmt(); * the following code handles the case when the native endianness is not * supported by the encoder, but the other one is */ - if (fmts && !fmt_in_list(fmts, fmt)) { + if (fmts && !pixfmt_in_list(fmts, fmt)) { const char *name_canonical = av_get_pix_fmt_name(fmt); int len = strlen(name_canonical); @@ -557,7 +557,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) snprintf(name_other, sizeof(name_other), "%s%ce", name, name_canonical[len - 2] == 'l' ? 'b' : 'l'); fmt_other = av_get_pix_fmt(name_other); - if (fmt_other != AV_PIX_FMT_NONE && fmt_in_list(fmts, fmt_other)) { + if (fmt_other != AV_PIX_FMT_NONE && pixfmt_in_list(fmts, fmt_other)) { av_log(ost, AV_LOG_VERBOSE, "Mapping pixel format %s->%s\n", name, name_other); fmt = fmt_other; @@ -565,7 +565,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) } } - if (fmts && !fmt_in_list(fmts, fmt)) + if (fmts && !pixfmt_in_list(fmts, fmt)) fmt = choose_pixel_fmt(ost->enc->enc_ctx, fmt); return fmt; -- 2.52.0 >From e9198f3b48e5f9b416750fdf2e9d24dc8955ccf1 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 30 Jan 2026 17:01:30 +0100 Subject: [PATCH 2/9] avfilter/filters: Restrict ff_fmt_is_in() to enum AVPixelFormat Also rename it to ff_pixfmt_is_in(). This is more type-safe; in particular, it is required to support -fshort-enum. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavfilter/filters.h | 9 ++++----- libavfilter/formats.c | 8 +++----- libavfilter/vf_blackdetect.c | 2 +- libavfilter/vf_fade.c | 2 +- libavfilter/vf_lut.c | 4 ++-- libavfilter/vf_overlay.c | 4 ++-- libavfilter/vf_tinterlace.c | 4 ++-- 7 files changed, 15 insertions(+), 18 deletions(-) diff --git a/libavfilter/filters.h b/libavfilter/filters.h index bc79527b87..3a3bdb9b1c 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -26,6 +26,7 @@ */ #include "avfilter.h" +#include "libavutil/pixfmt.h" /** * Special return code when activate() did not do anything. @@ -807,15 +808,13 @@ int ff_append_inpad_free_name (AVFilterContext *f, AVFilterPad *p); int ff_append_outpad_free_name(AVFilterContext *f, AVFilterPad *p); /** - * Tell if an integer is contained in the provided -1-terminated list of integers. - * This is useful for determining (for instance) if an AVPixelFormat is in an - * array of supported formats. + * Tell if a pixel format is contained the provided AV_PIX_FMT_NONE-terminated list. * * @param fmt provided format - * @param fmts -1-terminated list of formats + * @param fmts AV_PIX_FMT_NONE-terminated list of formats * @return 1 if present, 0 if absent */ -int ff_fmt_is_in(int fmt, const int *fmts); +int ff_pixfmt_is_in(enum AVPixelFormat fmt, const enum AVPixelFormat *fmts); int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs); diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 6fbdeb2d26..3315922cc7 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -468,12 +468,10 @@ const AVFilterNegotiation *ff_filter_get_negotiation(const AVFilterLink *link) } } -int ff_fmt_is_in(int fmt, const int *fmts) +int ff_pixfmt_is_in(enum AVPixelFormat fmt, const enum AVPixelFormat *fmts) { - const int *p; - - for (p = fmts; *p != -1; p++) { - if (fmt == *p) + for (; *fmts != AV_PIX_FMT_NONE; ++fmts) { + if (fmt == *fmts) return 1; } return 0; diff --git a/libavfilter/vf_blackdetect.c b/libavfilter/vf_blackdetect.c index df11a2140e..d39b2df006 100644 --- a/libavfilter/vf_blackdetect.c +++ b/libavfilter/vf_blackdetect.c @@ -187,7 +187,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) const int max = (1 << s->depth) - 1; const int factor = (1 << (s->depth - 8)); const int full = picref->color_range == AVCOL_RANGE_JPEG || - ff_fmt_is_in(picref->format, yuvj_formats) || + ff_pixfmt_is_in(picref->format, yuvj_formats) || s->alpha; s->pixel_black_th_i = full ? s->pixel_black_th * max : diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c index a9026992f1..efe0ea380d 100644 --- a/libavfilter/vf_fade.c +++ b/libavfilter/vf_fade.c @@ -447,7 +447,7 @@ static int config_input(AVFilterLink *inlink) /* use CCIR601/709 black level for studio-level pixel non-alpha components */ s->black_level = - ff_fmt_is_in(inlink->format, studio_level_pix_fmts) && !s->alpha ? 16 * (1 << (s->depth - 8)): 0; + ff_pixfmt_is_in(inlink->format, studio_level_pix_fmts) && !s->alpha ? 16 * (1 << (s->depth - 8)): 0; /* 32768 = 1 << 15, it is an integer representation * of 0.5 and is for rounding. */ s->black_level_scaled = (s->black_level << 16) + 32768; diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index ed00969e75..14c9964751 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -285,8 +285,8 @@ static int config_props(AVFilterLink *inlink) s->is_yuv = s->is_rgb = 0; s->is_planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR; - if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) s->is_yuv = 1; - else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) s->is_rgb = 1; + if (ff_pixfmt_is_in(inlink->format, yuv_pix_fmts)) s->is_yuv = 1; + else if (ff_pixfmt_is_in(inlink->format, rgb_pix_fmts)) s->is_rgb = 1; if (s->is_rgb) { ff_fill_rgba_map(rgba_map, inlink->format); diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index cdd5448076..d627db0889 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -316,7 +316,7 @@ static int config_input_overlay(AVFilterLink *inlink) s->overlay_is_packed_rgb = ff_fill_rgba_map(s->overlay_rgba_map, inlink->format) >= 0; - s->overlay_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts); + s->overlay_has_alpha = ff_pixfmt_is_in(inlink->format, alpha_pix_fmts); if (s->eval_mode == EVAL_MODE_INIT) { eval_expr(ctx); @@ -753,7 +753,7 @@ static int config_input_main(AVFilterLink *inlink) s->main_is_packed_rgb = ff_fill_rgba_map(s->main_rgba_map, inlink->format) >= 0; - s->main_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts); + s->main_has_alpha = ff_pixfmt_is_in(inlink->format, alpha_pix_fmts); return 0; } diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c index 59fe82abe3..2806e55752 100644 --- a/libavfilter/vf_tinterlace.c +++ b/libavfilter/vf_tinterlace.c @@ -235,7 +235,7 @@ static int config_out_props(AVFilterLink *outlink) } ff_draw_color(&tinterlace->draw, &tinterlace->color, black); /* limited range */ - if (!ff_fmt_is_in(outlink->format, full_scale_yuvj_pix_fmts)) { + if (!ff_pixfmt_is_in(outlink->format, full_scale_yuvj_pix_fmts)) { ret = av_image_alloc(tinterlace->black_data[0], tinterlace->black_linesize, outlink->w, outlink->h, outlink->format, 16); if (ret < 0) @@ -444,7 +444,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio, av_make_q(2, 1)); field = (1 + l->frame_count_in) & 1 ? FIELD_UPPER : FIELD_LOWER; - full = out->color_range == AVCOL_RANGE_JPEG || ff_fmt_is_in(out->format, full_scale_yuvj_pix_fmts); + full = out->color_range == AVCOL_RANGE_JPEG || ff_pixfmt_is_in(out->format, full_scale_yuvj_pix_fmts); /* copy upper and lower fields */ copy_picture_field(tinterlace, out->data, out->linesize, (const uint8_t **)cur->data, cur->linesize, -- 2.52.0 >From 5e255985fe1737ef3ffffec2e04135ac733e1778 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 30 Jan 2026 17:34:13 +0100 Subject: [PATCH 3/9] avfilter/vf_removelogo: Properly handle allocation error Don't rely on av_image_copy_plane() handling a NULL dst gracefully. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavfilter/vf_removelogo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_removelogo.c b/libavfilter/vf_removelogo.c index 70e4eef0a0..87cbc09233 100644 --- a/libavfilter/vf_removelogo.c +++ b/libavfilter/vf_removelogo.c @@ -223,8 +223,10 @@ static int load_mask(uint8_t **mask, int *w, int *h, /* copy mask to a newly allocated array */ *mask = av_malloc(*w * *h); - if (!*mask) + if (!*mask) { ret = AVERROR(ENOMEM); + goto end; + } av_image_copy_plane(*mask, *w, gray_data[0], gray_linesize[0], *w, *h); end: -- 2.52.0 >From a7efd04e42d35dff7eb893f8e66753836b8476c0 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 30 Jan 2026 18:24:05 +0100 Subject: [PATCH 4/9] avfilter/lavfutils: Avoid copying frame in ff_load_image() Return the data in an AVFrame instead. This is what several users ({find,cover}_rect*) want anyway. This also avoids accessing AVFrame.format (an int) via an enum AVPixelFormat*. *: This commit actually avoids two frame copies For find_rect: av_frame_clone() contained an implicit alloc+copy. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavfilter/avf_showcqt.c | 28 +++++++++++++--------------- libavfilter/lavfutils.c | 36 +++++++++++++----------------------- libavfilter/lavfutils.h | 13 +++++-------- libavfilter/vf_cover_rect.c | 9 ++------- libavfilter/vf_find_rect.c | 12 ++---------- libavfilter/vf_removelogo.c | 20 ++++++++++++-------- 6 files changed, 47 insertions(+), 71 deletions(-) diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c index bea311cd19..7395b0bfc2 100644 --- a/libavfilter/avf_showcqt.c +++ b/libavfilter/avf_showcqt.c @@ -404,33 +404,31 @@ static int init_axis_empty(ShowCQTContext *s) static int init_axis_from_file(ShowCQTContext *s) { - uint8_t *tmp_data[4] = { NULL }; - int tmp_linesize[4]; - enum AVPixelFormat tmp_format; - int tmp_w, tmp_h, ret; - - if ((ret = ff_load_image(tmp_data, tmp_linesize, &tmp_w, &tmp_h, &tmp_format, - s->axisfile, s->ctx)) < 0) - goto error; + AVFrame *tmp_frame; + int ret = ff_load_image(&tmp_frame, s->axisfile, s->ctx); + if (ret < 0) + return ret; ret = AVERROR(ENOMEM); if (!(s->axis_frame = av_frame_alloc())) goto error; - if ((ret = ff_scale_image(s->axis_frame->data, s->axis_frame->linesize, s->width, s->axis_h, - convert_axis_pixel_format(s->format), tmp_data, tmp_linesize, tmp_w, tmp_h, - tmp_format, s->ctx)) < 0) + ret = ff_scale_image(s->axis_frame->data, s->axis_frame->linesize, s->width, s->axis_h, + convert_axis_pixel_format(s->format), + tmp_frame->data, tmp_frame->linesize, tmp_frame->width, tmp_frame->height, + tmp_frame->format, s->ctx); + if (ret < 0) { + av_frame_free(&s->axis_frame); goto error; + } s->axis_frame->width = s->width; s->axis_frame->height = s->axis_h; s->axis_frame->format = convert_axis_pixel_format(s->format); - av_freep(tmp_data); - return 0; + ret = 0; error: - av_frame_free(&s->axis_frame); - av_freep(tmp_data); + av_frame_free(&tmp_frame); return ret; } diff --git a/libavfilter/lavfutils.c b/libavfilter/lavfutils.c index 6130f21e7f..cc1b5de722 100644 --- a/libavfilter/lavfutils.c +++ b/libavfilter/lavfutils.c @@ -21,9 +21,8 @@ #include <stdint.h> #include "libavutil/dict.h" -#include "libavutil/imgutils.h" +#include "libavutil/frame.h" #include "libavutil/log.h" -#include "libavutil/pixfmt.h" #include "libavformat/avformat.h" @@ -31,8 +30,7 @@ #include "lavfutils.h" -int ff_load_image(uint8_t *data[4], int linesize[4], - int *w, int *h, enum AVPixelFormat *pix_fmt, +int ff_load_image(struct AVFrame **outframe, const char *filename, void *log_ctx) { const AVInputFormat *iformat = NULL; @@ -45,6 +43,8 @@ int ff_load_image(uint8_t *data[4], int linesize[4], AVPacket pkt; AVDictionary *opt=NULL; + *outframe = NULL; + iformat = av_find_input_format("image2pipe"); if ((ret = avformat_open_input(&format_ctx, filename, iformat, NULL)) < 0) { av_log(log_ctx, AV_LOG_ERROR, @@ -84,12 +84,6 @@ int ff_load_image(uint8_t *data[4], int linesize[4], goto end; } - if (!(frame = av_frame_alloc()) ) { - av_log(log_ctx, AV_LOG_ERROR, "Failed to alloc frame\n"); - ret = AVERROR(ENOMEM); - goto end; - } - ret = av_read_frame(format_ctx, &pkt); if (ret < 0) { av_log(log_ctx, AV_LOG_ERROR, "Failed to read frame from file\n"); @@ -103,27 +97,23 @@ int ff_load_image(uint8_t *data[4], int linesize[4], goto end; } - ret = avcodec_receive_frame(codec_ctx, frame); - if (ret < 0) { - av_log(log_ctx, AV_LOG_ERROR, "Failed to decode image from file\n"); + if (!(frame = av_frame_alloc()) ) { + av_log(log_ctx, AV_LOG_ERROR, "Failed to alloc frame\n"); + ret = AVERROR(ENOMEM); goto end; } - *w = frame->width; - *h = frame->height; - *pix_fmt = frame->format; - - if ((ret = av_image_alloc(data, linesize, *w, *h, *pix_fmt, 16)) < 0) + ret = avcodec_receive_frame(codec_ctx, frame); + if (ret < 0) { + av_frame_free(&frame); + av_log(log_ctx, AV_LOG_ERROR, "Failed to decode image from file\n"); goto end; - ret = 0; - - av_image_copy2(data, linesize, frame->data, frame->linesize, - *pix_fmt, *w, *h); + } + *outframe = frame; end: avcodec_free_context(&codec_ctx); avformat_close_input(&format_ctx); - av_frame_free(&frame); av_dict_free(&opt); if (ret < 0) diff --git a/libavfilter/lavfutils.h b/libavfilter/lavfutils.h index 96738cead1..3b603f3fc7 100644 --- a/libavfilter/lavfutils.h +++ b/libavfilter/lavfutils.h @@ -24,21 +24,18 @@ #ifndef AVFILTER_LAVFUTILS_H #define AVFILTER_LAVFUTILS_H -#include <stdint.h> -#include "libavutil/pixfmt.h" +struct AVFrame; /** - * Load image from filename and put the resulting image in data. + * Load image from filename and put the resulting image in an AVFrame. * - * @param w pointer to the width of the loaded image - * @param h pointer to the height of the loaded image - * @param pix_fmt pointer to the pixel format of the loaded image + * @param outframe pointer to a pointer to an AVFrame; *outframe will + * point to a new allocated AVFrame on success * @param filename the name of the image file to load * @param log_ctx log context * @return >= 0 in case of success, a negative error code otherwise. */ -int ff_load_image(uint8_t *data[4], int linesize[4], - int *w, int *h, enum AVPixelFormat *pix_fmt, +int ff_load_image(struct AVFrame **outframe, const char *filename, void *log_ctx); #endif /* AVFILTER_LAVFUTILS_H */ diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c index 410869d9c3..3a35def0e1 100644 --- a/libavfilter/vf_cover_rect.c +++ b/libavfilter/vf_cover_rect.c @@ -205,13 +205,8 @@ static av_cold int init(AVFilterContext *ctx) return AVERROR(EINVAL); } - cover->cover_frame = av_frame_alloc(); - if (!cover->cover_frame) - return AVERROR(ENOMEM); - - if ((ret = ff_load_image(cover->cover_frame->data, cover->cover_frame->linesize, - &cover->cover_frame->width, &cover->cover_frame->height, - &cover->cover_frame->format, cover->cover_filename, ctx)) < 0) + ret = ff_load_image(&cover->cover_frame, cover->cover_filename, ctx); + if (ret < 0) return ret; if (cover->cover_frame->format != AV_PIX_FMT_YUV420P && cover->cover_frame->format != AV_PIX_FMT_YUVJ420P) { diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c index b0be1a6f11..9276bb46d4 100644 --- a/libavfilter/vf_find_rect.c +++ b/libavfilter/vf_find_rect.c @@ -22,7 +22,6 @@ * @todo switch to dualinput */ -#include "libavutil/mem.h" #include "libavutil/opt.h" #include "filters.h" @@ -254,8 +253,6 @@ static av_cold void uninit(AVFilterContext *ctx) av_frame_free(&foc->haystack_frame[i]); } - if (foc->obj_frame) - av_freep(&foc->obj_frame->data[0]); av_frame_free(&foc->obj_frame); } @@ -269,13 +266,8 @@ static av_cold int init(AVFilterContext *ctx) return AVERROR(EINVAL); } - foc->obj_frame = av_frame_alloc(); - if (!foc->obj_frame) - return AVERROR(ENOMEM); - - if ((ret = ff_load_image(foc->obj_frame->data, foc->obj_frame->linesize, - &foc->obj_frame->width, &foc->obj_frame->height, - &foc->obj_frame->format, foc->obj_filename, ctx)) < 0) + ret = ff_load_image(&foc->obj_frame, foc->obj_filename, ctx); + if (ret < 0) return ret; if (foc->obj_frame->format != AV_PIX_FMT_GRAY8) { diff --git a/libavfilter/vf_removelogo.c b/libavfilter/vf_removelogo.c index 87cbc09233..1da5f5d0c7 100644 --- a/libavfilter/vf_removelogo.c +++ b/libavfilter/vf_removelogo.c @@ -207,18 +207,22 @@ static int load_mask(uint8_t **mask, int *w, int *h, const char *filename, void *log_ctx) { int ret; - enum AVPixelFormat pix_fmt; - uint8_t *src_data[4], *gray_data[4]; - int src_linesize[4], gray_linesize[4]; + uint8_t *gray_data[4]; + AVFrame *src_frame; + int gray_linesize[4]; /* load image from file */ - if ((ret = ff_load_image(src_data, src_linesize, w, h, &pix_fmt, filename, log_ctx)) < 0) + ret = ff_load_image(&src_frame, filename, log_ctx); + if (ret < 0) return ret; + *w = src_frame->width; + *h = src_frame->height; /* convert the image to GRAY8 */ - if ((ret = ff_scale_image(gray_data, gray_linesize, *w, *h, AV_PIX_FMT_GRAY8, - src_data, src_linesize, *w, *h, pix_fmt, - log_ctx)) < 0) + ret = ff_scale_image(gray_data, gray_linesize, *w, *h, AV_PIX_FMT_GRAY8, + src_frame->data, src_frame->linesize, *w, *h, + src_frame->format, log_ctx); + if (ret < 0) goto end; /* copy mask to a newly allocated array */ @@ -230,8 +234,8 @@ static int load_mask(uint8_t **mask, int *w, int *h, av_image_copy_plane(*mask, *w, gray_data[0], gray_linesize[0], *w, *h); end: - av_freep(&src_data[0]); av_freep(&gray_data[0]); + av_frame_free(&src_frame); return ret; } -- 2.52.0 >From 383773ef244082c6fc2864ede6bc6e0bc96a89ba Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 30 Jan 2026 18:40:32 +0100 Subject: [PATCH 5/9] avutil/opt: Improve type-safety In particular, make this code -fshort-enums compatible. The branch can be optimized away by compilers when sizeof(enum AVPixelFormat) == sizeof(enum AVSampleFormat). Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavutil/opt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 911e064914..7c6a01068a 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1336,7 +1336,7 @@ int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRatio return av_opt_get_q(obj, name, search_flags, out_val); } -static int get_format(void *obj, const char *name, int search_flags, int *out_fmt, +static int get_format(void *obj, const char *name, int search_flags, void *out_fmt, enum AVOptionType type, const char *desc) { void *dst, *target_obj; @@ -1350,7 +1350,11 @@ static int get_format(void *obj, const char *name, int search_flags, int *out_fm } dst = ((uint8_t*)target_obj) + o->offset; - *out_fmt = *(int *)dst; + if (type == AV_OPT_TYPE_PIXEL_FMT) + *(enum AVPixelFormat *)out_fmt = *(enum AVPixelFormat *)dst; + else + *(enum AVSampleFormat*)out_fmt = *(enum AVSampleFormat*)dst; + return 0; } -- 2.52.0 >From 82ffbf80988bf8dc1d6c6c8ccc772664ad953bb2 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 30 Jan 2026 18:44:40 +0100 Subject: [PATCH 6/9] swscale/utils: Improve type-safety SwsContext.{src,dst}_format is int (but uses enum AVPixelFormat) values, so the accesses need to be performed using an int for -fshort-enums support. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libswscale/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 195af846d4..52095ab2c7 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -766,7 +766,7 @@ av_cold int ff_sws_fill_xyztables(SwsInternal *c) return 0; } -static int handle_jpeg(enum AVPixelFormat *format) +static int handle_jpeg(/* enum AVPixelFormat */ int *format) { switch (*format) { case AV_PIX_FMT_YUVJ420P: @@ -804,7 +804,7 @@ static int handle_jpeg(enum AVPixelFormat *format) } } -static int handle_0alpha(enum AVPixelFormat *format) +static int handle_0alpha(/* enum AVPixelFormat */ int *format) { switch (*format) { case AV_PIX_FMT_0BGR : *format = AV_PIX_FMT_ABGR ; return 1; @@ -815,7 +815,7 @@ static int handle_0alpha(enum AVPixelFormat *format) } } -static int handle_xyz(enum AVPixelFormat *format) +static int handle_xyz(/* enum AVPixelFormat */ int *format) { switch (*format) { case AV_PIX_FMT_XYZ12BE : *format = AV_PIX_FMT_RGB48BE; return 1; -- 2.52.0 >From 5b155073e707be09b242c2850b93668415eefc67 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 30 Jan 2026 18:48:12 +0100 Subject: [PATCH 7/9] avfilter/lavfutils: Avoid AVDictionary Set thread_type directly instead. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavfilter/lavfutils.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavfilter/lavfutils.c b/libavfilter/lavfutils.c index cc1b5de722..b86c31d4ee 100644 --- a/libavfilter/lavfutils.c +++ b/libavfilter/lavfutils.c @@ -20,7 +20,6 @@ #include <stdint.h> -#include "libavutil/dict.h" #include "libavutil/frame.h" #include "libavutil/log.h" @@ -41,7 +40,6 @@ int ff_load_image(struct AVFrame **outframe, AVFrame *frame = NULL; int ret = 0; AVPacket pkt; - AVDictionary *opt=NULL; *outframe = NULL; @@ -78,8 +76,8 @@ int ff_load_image(struct AVFrame **outframe, goto end; } - av_dict_set(&opt, "thread_type", "slice", 0); - if ((ret = avcodec_open2(codec_ctx, codec, &opt)) < 0) { + codec_ctx->thread_type = FF_THREAD_SLICE; + if ((ret = avcodec_open2(codec_ctx, codec, NULL)) < 0) { av_log(log_ctx, AV_LOG_ERROR, "Failed to open codec\n"); goto end; } @@ -114,7 +112,6 @@ int ff_load_image(struct AVFrame **outframe, end: avcodec_free_context(&codec_ctx); avformat_close_input(&format_ctx); - av_dict_free(&opt); if (ret < 0) av_log(log_ctx, AV_LOG_ERROR, "Error loading image file '%s'\n", filename); -- 2.52.0 >From 132f0d02a995fce78b1a2306a6e9f7208c5c49aa Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 30 Jan 2026 19:11:24 +0100 Subject: [PATCH 8/9] avcodec/flacenc: Use int for AV_OPT_TYPE_INT Necessary for -fshort-enums. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/flacenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 48478749d9..ead2c55f10 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -57,7 +57,7 @@ enum CodingMode { typedef struct CompressionOptions { int compression_level; int block_time_ms; - enum FFLPCType lpc_type; + int /* enum FFLPCType */ lpc_type; int lpc_passes; int lpc_coeff_precision; int min_prediction_order; -- 2.52.0 >From fa77beb6ffefc22302a2c3794f2874d8c9e244f3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 30 Jan 2026 19:36:01 +0100 Subject: [PATCH 9/9] avformat/spdif: Make enum IEC61937DataType at least 16bits Fixes the spdif-dca-master FATE-test when compiling with -fshort-enums. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavformat/spdif.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/spdif.h b/libavformat/spdif.h index 0039fcfe5c..0b6567fac8 100644 --- a/libavformat/spdif.h +++ b/libavformat/spdif.h @@ -50,6 +50,7 @@ enum IEC61937DataType { IEC61937_MPEG2_AAC_LSF_4096 = 0x13 | 0x20, ///< MPEG-2 AAC ADTS quarter-rate low sampling frequency IEC61937_EAC3 = 0x15, ///< E-AC-3 data IEC61937_TRUEHD = 0x16, ///< TrueHD data + IEC61937_MAX_ENUM = 0xFFFF ///< to force the underlying type to be at least 16bits }; static const uint16_t spdif_mpeg_pkt_offset[2][3] = { -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
