73 const uint16_t *src16 = (
const uint16_t *)src;
78 total += src[ 0] + src[ stride] + src[2*stride] + src[3*stride]
79 + src[4*stride] + src[5*stride] + src[6*stride] + src[7*stride];
91 total += src16[ 0] + src16[ stride] + src16[2*stride] + src16[3*stride]
92 + src16[4*stride] + src16[5*stride] + src16[6*stride] + src16[7*stride];
104 total += src[0] + src[1 ] + src[2 ]
105 + src[ stride] + src[1+ stride] + src[2+ stride]
106 + src[2*stride] + src[1+2*stride] + src[2+2*stride]
107 + src[3*stride] + src[1+3*stride] + src[2+3*stride];
112 total += src[0] + src[1] + src[2];
147 s->
x1 = inlink->
w - 1;
148 s->
y1 = inlink->
h - 1;
155 #define SET_META(key, value) \
156 av_dict_set_int(metadata, key, value, 0)
163 int w, h, x,
y, shrink_by;
165 int outliers, last_y;
181 #define FIND(DST, FROM, NOEND, INC, STEP0, STEP1, LEN) \
183 for (last_y = y = FROM; NOEND; y = y INC) {\
184 if (checkline(ctx, frame->data[0] + STEP0 * y, STEP1, LEN, bpp) > limit) {\
185 if (++outliers > s->max_outliers) { \
214 shrink_by = w % s->
round;
216 x += (shrink_by/2 + 1) & ~1;
218 shrink_by = h % s->
round;
220 y += (shrink_by/2 + 1) & ~1;
232 "x1:%d x2:%d y1:%d y2:%d w:%d h:%d x:%d y:%d pts:%"PRId64
" t:%f crop=%d:%d:%d:%d\n",
233 s->
x1, s->
x2, s->
y1, s->
y2, w, h, x, y, frame->
pts,
241 #define OFFSET(x) offsetof(CropDetectContext, x)
242 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
245 {
"limit",
"Threshold below which the pixel is considered black",
OFFSET(limit),
AV_OPT_TYPE_FLOAT, { .dbl = 24.0/255 }, 0, 65535,
FLAGS },
247 {
"reset",
"Recalculate the crop area after this many frames",
OFFSET(reset_count),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
FLAGS },
248 {
"reset_count",
"Recalculate the crop area after this many frames",
OFFSET(reset_count),
AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX,
FLAGS },
274 .
name =
"cropdetect",
277 .priv_class = &cropdetect_class,
280 .
inputs = avfilter_vf_cropdetect_inputs,
281 .
outputs = avfilter_vf_cropdetect_outputs,