43 #define OFFSET(x) offsetof(EdgeDetectContext, x)
44 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
57 edgedetect->
low_u8 = edgedetect->
low * 255. + .5;
88 memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
89 memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
90 for (j = 2; j < h - 2; j++) {
93 for (i = 2; i < w - 2; i++) {
95 dst[i] = ((src[-2*src_linesize + i-2] + src[2*src_linesize + i-2]) * 2
96 + (src[-2*src_linesize + i-1] + src[2*src_linesize + i-1]) * 4
97 + (src[-2*src_linesize + i ] + src[2*src_linesize + i ]) * 5
98 + (src[-2*src_linesize + i+1] + src[2*src_linesize + i+1]) * 4
99 + (src[-2*src_linesize + i+2] + src[2*src_linesize + i+2]) * 2
101 + (src[ -src_linesize + i-2] + src[ src_linesize + i-2]) * 4
102 + (src[ -src_linesize + i-1] + src[ src_linesize + i-1]) * 9
103 + (src[ -src_linesize + i ] + src[ src_linesize + i ]) * 12
104 + (src[ -src_linesize + i+1] + src[ src_linesize + i+1]) * 9
105 + (src[ -src_linesize + i+2] + src[ src_linesize + i+2]) * 4
111 + src[i+2] * 5) / 159;
114 dst[i + 1] = src[i + 1];
119 memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
143 int tanpi8gx, tan3pi8gx;
148 tanpi8gx = 27146 * gx;
149 tan3pi8gx = 158218 * gx;
158 uint16_t *dst,
int dst_linesize,
164 for (j = 1; j < h - 1; j++) {
167 for (i = 1; i < w - 1; i++) {
169 -1*src[-src_linesize + i-1] + 1*src[-src_linesize + i+1]
170 -2*src[ i-1] + 2*src[ i+1]
171 -1*src[ src_linesize + i-1] + 1*src[ src_linesize + i+1];
173 -1*src[-src_linesize + i-1] + 1*src[ src_linesize + i-1]
174 -2*src[-src_linesize + i ] + 2*src[ src_linesize + i ]
175 -1*src[-src_linesize + i+1] + 1*src[ src_linesize + i+1];
184 uint8_t *dst,
int dst_linesize,
185 const uint16_t *
src,
int src_linesize)
190 #define COPY_MAXIMA(ay, ax, by, bx) do { \
191 if (src[i] > src[(ay)*src_linesize + i+(ax)] && \
192 src[i] > src[(by)*src_linesize + i+(bx)]) \
193 dst[i] = av_clip_uint8(src[i]); \
196 for (j = 1; j < h - 1; j++) {
199 for (i = 1; i < w - 1; i++) {
211 uint8_t *dst,
int dst_linesize,
216 const int low = edgedetect->
low_u8;
217 const int high = edgedetect->
high_u8;
219 for (j = 0; j < h; j++) {
220 for (i = 0; i < w; i++) {
226 if ((!i || i == w - 1 || !j || j == h - 1) &&
228 (src[-src_linesize + i-1] > high ||
229 src[-src_linesize + i ] > high ||
230 src[-src_linesize + i+1] > high ||
233 src[ src_linesize + i-1] > high ||
234 src[ src_linesize + i ] > high ||
235 src[ src_linesize + i+1] > high))
251 uint16_t *gradients = edgedetect->
gradients;
273 sobel(ctx, inlink->
w, inlink->
h,
274 gradients, inlink->
w,
279 memset(tmpbuf, 0, inlink->
w * inlink->
h);
282 gradients, inlink->
w);
321 .
name =
"edgedetect",
327 .
inputs = edgedetect_inputs,
329 .priv_class = &edgedetect_class,