35 #define RADIUS_MIN 0.1
36 #define RADIUS_MAX 5.0
38 #define STRENGTH_MIN -1.0
39 #define STRENGTH_MAX 1.0
41 #define THRESHOLD_MIN -30
42 #define THRESHOLD_MAX 30
60 #define CHECK_PARAM(param, name, min, max, format, ret) \
61 if (param < min || param > max) { \
62 av_log(ctx, AV_LOG_ERROR, \
63 "Invalid " #name " value " #format ": " \
64 "must be included between range " #format " and " #format "\n",\
66 ret = AVERROR(EINVAL); \
73 float lradius, lstrength, cradius, cstrength;
74 int lthreshold, cthreshold;
77 n = sscanf(args,
"%f:%f:%d:%f:%f:%d",
78 &lradius, &lstrength, <hreshold,
79 &cradius, &cstrength, &cthreshold);
81 if (n != 3 && n != 6) {
83 "Incorrect number of parameters or invalid syntax: "
84 "must be luma_radius:luma_strength:luma_threshold"
85 "[:chroma_radius:chroma_strength:chroma_threshold]\n");
154 sws_filter.
lumH = sws_filter.
lumV = vec;
179 inlink->
w >> sblur->
hsub, inlink->
h >> sblur->
vsub,
186 const uint8_t *src,
const int src_linesize,
187 const int w,
const int h,
const int threshold,
194 const uint8_t*
const src_array[4] = {src};
196 int src_linesize_array[4] = {src_linesize};
197 int dst_linesize_array[4] = {dst_linesize};
199 sws_scale(filter_context, src_array, src_linesize_array,
200 0, h, dst_array, dst_linesize_array);
203 for (y = 0; y < h; ++
y) {
204 for (x = 0; x < w; ++x) {
205 orig = src[x + y * src_linesize];
206 filtered = dst[x + y * dst_linesize];
207 diff = orig - filtered;
210 if (diff > 2 * threshold)
211 dst[x + y * dst_linesize] = orig;
212 else if (diff > threshold)
214 dst[x + y * dst_linesize] = orig - threshold;
216 if (-diff > 2 * threshold)
217 dst[x + y * dst_linesize] = orig;
218 else if (-diff > threshold)
220 dst[x + y * dst_linesize] = orig + threshold;
224 }
else if (threshold < 0) {
225 for (y = 0; y < h; ++
y) {
226 for (x = 0; x < w; ++x) {
227 orig = src[x + y * src_linesize];
228 filtered = dst[x + y * dst_linesize];
229 diff = orig - filtered;
232 if (diff <= -threshold)
233 dst[x + y * dst_linesize] = orig;
234 else if (diff <= -2 * threshold)
236 dst[x + y * dst_linesize] = filtered - threshold;
238 if (diff >= threshold)
239 dst[x + y * dst_linesize] = orig;
240 else if (diff >= 2 * threshold)
242 dst[x + y * dst_linesize] = filtered + threshold;
254 int cw = inlink->
w >> sblur->
hsub;
255 int ch = inlink->
h >> sblur->
vsub;
269 if (inpic->
data[2]) {
312 .
inputs = smartblur_inputs,