21 #ifndef AVFILTER_BLEND_INIT_H
22 #define AVFILTER_BLEND_INIT_H
56 #define COPY(src, depth) \
57 static void blend_copy ## src##_##depth(const uint8_t *top, ptrdiff_t top_linesize, \
58 const uint8_t *bottom, ptrdiff_t bottom_linesize,\
59 uint8_t *dst, ptrdiff_t dst_linesize, \
60 ptrdiff_t width, ptrdiff_t height, \
61 FilterParams *param, double *values, int starty) \
63 av_image_copy_plane(dst, dst_linesize, src, src ## _linesize, \
64 width * depth / 8, height); \
78 #define BLEND_NORMAL(name, type) \
79 static void blend_normal_##name(const uint8_t *_top, ptrdiff_t top_linesize, \
80 const uint8_t *_bottom, ptrdiff_t bottom_linesize,\
81 uint8_t *_dst, ptrdiff_t dst_linesize, \
82 ptrdiff_t width, ptrdiff_t height, \
83 FilterParams *param, double *values, int starty) \
85 const type *top = (type*)_top; \
86 const type *bottom = (type*)_bottom; \
87 type *dst = (type*)_dst; \
88 const float opacity = param->opacity; \
90 dst_linesize /= sizeof(type); \
91 top_linesize /= sizeof(type); \
92 bottom_linesize /= sizeof(type); \
94 for (int i = 0; i < height; i++) { \
95 for (int j = 0; j < width; j++) { \
96 dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity); \
98 dst += dst_linesize; \
99 top += top_linesize; \
100 bottom += bottom_linesize; \
108 #define DEFINE_INIT_BLEND_FUNC(depth, nbits) \
109 static av_cold void init_blend_func_##depth##_##nbits##bit(FilterParams *param) \
111 switch (param->mode) { \
112 case BLEND_ADDITION: param->blend = blend_addition_##depth##bit; break; \
113 case BLEND_GRAINMERGE: param->blend = blend_grainmerge_##depth##bit; break; \
114 case BLEND_AND: param->blend = blend_and_##depth##bit; break; \
115 case BLEND_AVERAGE: param->blend = blend_average_##depth##bit; break; \
116 case BLEND_BURN: param->blend = blend_burn_##depth##bit; break; \
117 case BLEND_DARKEN: param->blend = blend_darken_##depth##bit; break; \
118 case BLEND_DIFFERENCE: param->blend = blend_difference_##depth##bit; break; \
119 case BLEND_GRAINEXTRACT: param->blend = blend_grainextract_##depth##bit; break; \
120 case BLEND_DIVIDE: param->blend = blend_divide_##depth##bit; break; \
121 case BLEND_DODGE: param->blend = blend_dodge_##depth##bit; break; \
122 case BLEND_EXCLUSION: param->blend = blend_exclusion_##depth##bit; break; \
123 case BLEND_EXTREMITY: param->blend = blend_extremity_##depth##bit; break; \
124 case BLEND_FREEZE: param->blend = blend_freeze_##depth##bit; break; \
125 case BLEND_GLOW: param->blend = blend_glow_##depth##bit; break; \
126 case BLEND_HARDLIGHT: param->blend = blend_hardlight_##depth##bit; break; \
127 case BLEND_HARDMIX: param->blend = blend_hardmix_##depth##bit; break; \
128 case BLEND_HEAT: param->blend = blend_heat_##depth##bit; break; \
129 case BLEND_LIGHTEN: param->blend = blend_lighten_##depth##bit; break; \
130 case BLEND_LINEARLIGHT: param->blend = blend_linearlight_##depth##bit; break; \
131 case BLEND_MULTIPLY: param->blend = blend_multiply_##depth##bit; break; \
132 case BLEND_MULTIPLY128: param->blend = blend_multiply128_##depth##bit; break; \
133 case BLEND_NEGATION: param->blend = blend_negation_##depth##bit; break; \
134 case BLEND_NORMAL: param->blend = blend_normal_##nbits##bit; break; \
135 case BLEND_OR: param->blend = blend_or_##depth##bit; break; \
136 case BLEND_OVERLAY: param->blend = blend_overlay_##depth##bit; break; \
137 case BLEND_PHOENIX: param->blend = blend_phoenix_##depth##bit; break; \
138 case BLEND_PINLIGHT: param->blend = blend_pinlight_##depth##bit; break; \
139 case BLEND_REFLECT: param->blend = blend_reflect_##depth##bit; break; \
140 case BLEND_SCREEN: param->blend = blend_screen_##depth##bit; break; \
141 case BLEND_SOFTLIGHT: param->blend = blend_softlight_##depth##bit; break; \
142 case BLEND_SUBTRACT: param->blend = blend_subtract_##depth##bit; break; \
143 case BLEND_VIVIDLIGHT: param->blend = blend_vividlight_##depth##bit; break; \
144 case BLEND_XOR: param->blend = blend_xor_##depth##bit; break; \
145 case BLEND_SOFTDIFFERENCE:param->blend=blend_softdifference_##depth##bit;break; \
146 case BLEND_GEOMETRIC: param->blend = blend_geometric_##depth##bit; break; \
147 case BLEND_HARMONIC: param->blend = blend_harmonic_##depth##bit; break; \
148 case BLEND_BLEACH: param->blend = blend_bleach_##depth##bit; break; \
149 case BLEND_STAIN: param->blend = blend_stain_##depth##bit; break; \
150 case BLEND_INTERPOLATE: param->blend = blend_interpolate_##depth##bit; break; \
151 case BLEND_HARDOVERLAY: param->blend = blend_hardoverlay_##depth##bit; break; \
166 init_blend_func_8_8bit(param);
169 init_blend_func_9_16bit(param);
172 init_blend_func_10_16bit(param);
175 init_blend_func_12_16bit(param);
178 init_blend_func_14_16bit(param);
181 init_blend_func_16_16bit(param);
184 init_blend_func_32_32bit(param);
188 if (param->opacity == 0 && param->mode !=
BLEND_NORMAL) {
189 param->blend = depth > 8 ? depth > 16 ? blend_copytop_32 : blend_copytop_16 : blend_copytop_8;
191 if (param->opacity == 1)
192 param->blend = depth > 8 ? depth > 16 ? blend_copytop_32 : blend_copytop_16 : blend_copytop_8;
193 else if (param->opacity == 0)
194 param->blend = depth > 8 ? depth > 16 ? blend_copybottom_32 : blend_copybottom_16 : blend_copybottom_8;