36 #define RADIUS_MIN 0.1
37 #define RADIUS_MAX 5.0
39 #define STRENGTH_MIN -1.0
40 #define STRENGTH_MAX 1.0
42 #define THRESHOLD_MIN -30
43 #define THRESHOLD_MAX 30
62 #define OFFSET(x) offsetof(SmartblurContext, x)
63 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
101 "luma_radius:%f luma_strength:%f luma_threshold:%d "
102 "chroma_radius:%f chroma_strength:%f chroma_threshold:%d\n",
144 sws_filter.
lumH = sws_filter.
lumV = vec;
145 sws_filter.
chrH = sws_filter.
chrV = NULL;
149 flags, &sws_filter, NULL, NULL);
178 const int w,
const int h,
const int threshold,
185 const uint8_t*
const src_array[4] = {src};
187 int src_linesize_array[4] = {src_linesize};
188 int dst_linesize_array[4] = {dst_linesize};
190 sws_scale(filter_context, src_array, src_linesize_array,
191 0, h, dst_array, dst_linesize_array);
194 for (y = 0; y < h; ++
y) {
195 for (x = 0; x < w; ++x) {
196 orig = src[x + y * src_linesize];
197 filtered = dst[x + y * dst_linesize];
198 diff = orig - filtered;
201 if (diff > 2 * threshold)
202 dst[x + y * dst_linesize] = orig;
203 else if (diff > threshold)
205 dst[x + y * dst_linesize] = orig - threshold;
207 if (-diff > 2 * threshold)
208 dst[x + y * dst_linesize] = orig;
209 else if (-diff > threshold)
211 dst[x + y * dst_linesize] = orig + threshold;
215 }
else if (threshold < 0) {
216 for (y = 0; y < h; ++
y) {
217 for (x = 0; x < w; ++x) {
218 orig = src[x + y * src_linesize];
219 filtered = dst[x + y * dst_linesize];
220 diff = orig - filtered;
223 if (diff <= -threshold)
224 dst[x + y * dst_linesize] = orig;
225 else if (diff <= -2 * threshold)
227 dst[x + y * dst_linesize] = filtered - threshold;
229 if (diff >= threshold)
230 dst[x + y * dst_linesize] = orig;
231 else if (diff >= 2 * threshold)
233 dst[x + y * dst_linesize] = filtered + threshold;
260 if (inpic->
data[2]) {
302 .
inputs = smartblur_inputs,
304 .priv_class = &smartblur_class,