diff --git a/libavfilter/vf_selectivecolor.c b/libavfilter/vf_selectivecolor.c index 26fd8ebc70..5dce3ebd15 100644 --- a/libavfilter/vf_selectivecolor.c +++ b/libavfilter/vf_selectivecolor.c @@ -64,12 +64,12 @@ static const char *color_names[NB_RANGES] = { "red", "yellow", "green", "cyan", "blue", "magenta", "white", "neutral", "black" }; -typedef int (*get_adjust_range_func)(int r, int g, int b, int min_val, int max_val); +typedef int (*get_range_scale_func)(int r, int g, int b, int min_val, int max_val); struct process_range { int range_id; uint32_t mask; - get_adjust_range_func get_adjust_range; + get_range_scale_func get_scale; }; typedef struct ThreadData { @@ -113,38 +113,38 @@ static const AVOption selectivecolor_options[] = { AVFILTER_DEFINE_CLASS(selectivecolor); -static int get_rgb_adjust_range(int r, int g, int b, int min_val, int max_val) +static int get_rgb_scale(int r, int g, int b, int min_val, int max_val) { return max_val - mid_pred(r, g, b); } -static int get_cmy_adjust_range(int r, int g, int b, int min_val, int max_val) +static int get_cmy_scale(int r, int g, int b, int min_val, int max_val) { return mid_pred(r, g, b) - min_val; } -#define DECLARE_ADJUST_RANGE_FUNCS(nbits) \ -static int get_neutrals_adjust_range##nbits(int r, int g, int b, int min_val, int max_val) \ +#define DECLARE_RANGE_SCALE_FUNCS(nbits) \ +static int get_neutrals_scale##nbits(int r, int g, int b, int min_val, int max_val) \ { \ /* 1 - (|max-0.5| + |min-0.5|) */ \ return (((1<> 1; \ } \ \ -static int get_whites_adjust_range##nbits(int r, int g, int b, int min_val, int max_val) \ +static int get_whites_scale##nbits(int r, int g, int b, int min_val, int max_val) \ { \ /* (min - 0.5) * 2 */ \ return (min_val<<1) - ((1<range_id = range_id; pr->mask = 1 << range_id; - if (pr->mask & (1<get_adjust_range = get_rgb_adjust_range; - else if (pr->mask & (1<get_adjust_range = get_cmy_adjust_range; - else if (!s->is_16bit && (pr->mask & 1<get_adjust_range = get_whites_adjust_range8; - else if (!s->is_16bit && (pr->mask & 1<get_adjust_range = get_neutrals_adjust_range8; - else if (!s->is_16bit && (pr->mask & 1<get_adjust_range = get_blacks_adjust_range8; - else if ( s->is_16bit && (pr->mask & 1<get_adjust_range = get_whites_adjust_range16; - else if ( s->is_16bit && (pr->mask & 1<get_adjust_range = get_neutrals_adjust_range16; - else if ( s->is_16bit && (pr->mask & 1<get_adjust_range = get_blacks_adjust_range16; + if (pr->mask & (1<get_scale = get_rgb_scale; + else if (pr->mask & (1<get_scale = get_cmy_scale; + else if (!s->is_16bit && (pr->mask & 1<get_scale = get_whites_scale8; + else if (!s->is_16bit && (pr->mask & 1<get_scale = get_neutrals_scale8; + else if (!s->is_16bit && (pr->mask & 1<get_scale = get_blacks_scale8; + else if ( s->is_16bit && (pr->mask & 1<get_scale = get_whites_scale16; + else if ( s->is_16bit && (pr->mask & 1<get_scale = get_neutrals_scale16; + else if ( s->is_16bit && (pr->mask & 1<get_scale = get_blacks_scale16; else av_assert0(0); } @@ -302,14 +302,14 @@ static int query_formats(AVFilterContext *ctx) return ff_set_common_formats(ctx, fmts_list); } -static inline int comp_adjust(int adjust_range, float value, float adjust, float k, int correction_method) +static inline int comp_adjust(int scale, float value, float adjust, float k, int correction_method) { const float min = -value; const float max = 1. - value; float res = (-1. - adjust) * k - adjust; if (correction_method == CORRECTION_METHOD_RELATIVE) res *= max; - return lrint(av_clipf(res, min, max) * adjust_range); + return lrint(av_clipf(res, min, max) * scale); } #define DECLARE_SELECTIVE_COLOR_FUNC(nbits) \ @@ -364,18 +364,18 @@ static inline int selective_color_##nbits(AVFilterContext *ctx, ThreadData *td, const struct process_range *pr = &s->process_ranges[i]; \ \ if (range_flag & pr->mask) { \ - const int adjust_range = pr->get_adjust_range(r, g, b, min_color, max_color); \ + const int scale = pr->get_scale(r, g, b, min_color, max_color); \ \ - if (adjust_range > 0) { \ + if (scale > 0) { \ const float *cmyk_adjust = s->cmyk_adjust[pr->range_id]; \ const float adj_c = cmyk_adjust[0]; \ const float adj_m = cmyk_adjust[1]; \ const float adj_y = cmyk_adjust[2]; \ const float k = cmyk_adjust[3]; \ \ - adjust_r += comp_adjust(adjust_range, rnorm, adj_c, k, correction_method); \ - adjust_g += comp_adjust(adjust_range, gnorm, adj_m, k, correction_method); \ - adjust_b += comp_adjust(adjust_range, bnorm, adj_y, k, correction_method); \ + adjust_r += comp_adjust(scale, rnorm, adj_c, k, correction_method); \ + adjust_g += comp_adjust(scale, gnorm, adj_m, k, correction_method); \ + adjust_b += comp_adjust(scale, bnorm, adj_y, k, correction_method); \ } \ } \ } \