19#ifndef AVFILTER_COLORDETECTDSP_H
20#define AVFILTER_COLORDETECTDSP_H
43 int mpeg_min,
int mpeg_max);
47 const uint8_t *
alpha, ptrdiff_t alpha_stride,
49 int alpha_max,
int mpeg_range,
int offset);
57#define DECL_DETECT_RANGE_IMPL(TYPE, NAME) \
58static inline int NAME(const uint8_t* data, ptrdiff_t stride, \
59 ptrdiff_t width, ptrdiff_t height, \
60 int mpeg_min, int mpeg_max) \
62 const TYPE min = mpeg_min; \
63 const TYPE max = mpeg_max; \
64 av_assume(min == mpeg_min); \
65 av_assume(max == mpeg_max); \
68 const TYPE *row = (const TYPE *) data; \
70 for (int x = 0; x < width; x++) { \
71 const TYPE val = row[x]; \
72 cond |= val < min || val > max; \
85#define DECL_DETECT_ALPHA_FULL_IMPL(TYPE, INTER, NAME) \
86static inline int NAME(const uint8_t* color, ptrdiff_t color_stride, \
87 const uint8_t* alpha, ptrdiff_t alpha_stride, \
88 ptrdiff_t width, ptrdiff_t height, int alpha_max, \
89 int mpeg_range, int offset) \
91 const TYPE max = alpha_max; \
92 const INTER off = offset; \
93 av_assume(max == alpha_max); \
94 av_assume(off == offset); \
97 uint8_t transparent = 0; \
99 const TYPE *col = (const TYPE *) color; \
100 const TYPE *alp = (const TYPE *) alpha; \
101 uint8_t straight = 0; \
102 for (int x = 0; x < width; x++) { \
103 straight |= col[x] > alp[x] + off; \
104 transparent |= alp[x] != max; \
107 return FF_ALPHA_STRAIGHT; \
108 color += color_stride; \
109 alpha += alpha_stride; \
111 return transparent ? FF_ALPHA_TRANSPARENT : 0; \
117#define DECL_DETECT_ALPHA_LIMITED_IMPL(TYPE, INTER, NAME) \
118static inline int NAME(const uint8_t* color, ptrdiff_t color_stride, \
119 const uint8_t* alpha, ptrdiff_t alpha_stride, \
120 ptrdiff_t width, ptrdiff_t height, int alpha_max, \
121 int mpeg_range, int offset) \
123 const TYPE max = alpha_max; \
124 const INTER off = offset; \
125 const INTER range = mpeg_range; \
126 av_assume(max == alpha_max); \
127 av_assume(off == offset); \
128 av_assume(range == mpeg_range); \
130 uint8_t transparent = 0; \
132 const TYPE *col = (const TYPE *) color; \
133 const TYPE *alp = (const TYPE *) alpha; \
134 uint8_t straight = 0; \
135 for (int x = 0; x < width; x++) { \
136 straight |= (INTER) max * col[x] - off > range * alp[x]; \
137 transparent |= alp[x] != max; \
140 return FF_ALPHA_STRAIGHT; \
141 color += color_stride; \
142 alpha += alpha_stride; \
144 return transparent ? FF_ALPHA_TRANSPARENT : 0; \
154 dsp->
detect_range = depth > 8 ? ff_detect_range16_c : ff_detect_range_c;
156 dsp->
detect_alpha = depth > 8 ? ff_detect_alpha16_full_c : ff_detect_alpha_full_c;
158 dsp->
detect_alpha = depth > 8 ? ff_detect_alpha16_limited_c : ff_detect_alpha_limited_c;
163#elif ARCH_X86 && HAVE_X86ASM
simple assert() macros that are a bit more flexible than ISO C assert().
static const int16_t alpha[]
Macro definitions for various function/variable attributes.
AVColorRange
Visual content value range.
@ AVCOL_RANGE_JPEG
Full range content.
int(* detect_range)(const uint8_t *data, ptrdiff_t stride, ptrdiff_t width, ptrdiff_t height, int mpeg_min, int mpeg_max)
int(* detect_alpha)(const uint8_t *color, ptrdiff_t color_stride, const uint8_t *alpha, ptrdiff_t alpha_stride, ptrdiff_t width, ptrdiff_t height, int alpha_max, int mpeg_range, int offset)
#define DECL_DETECT_ALPHA_LIMITED_IMPL(TYPE, INTER, NAME)
#define DECL_DETECT_RANGE_IMPL(TYPE, NAME)
@ FF_ALPHA_TRANSPARENT
alpha < alpha_max
@ FF_ALPHA_STRAIGHT
alpha < pixel
void ff_color_detect_dsp_init_x86(FFColorDetectDSPContext *dsp, int depth, int offset, enum AVColorRange color_range)
void ff_color_detect_dsp_init_aarch64(FFColorDetectDSPContext *dsp, int depth, enum AVColorRange color_range)
#define DECL_DETECT_ALPHA_FULL_IMPL(TYPE, INTER, NAME)
static av_cold void ff_color_detect_dsp_init(FFColorDetectDSPContext *dsp, int depth, int offset, enum AVColorRange color_range)