mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
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 <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -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 in 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 pixel 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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 :
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user