43 #define OFFSET(x) offsetof(EdgeDetectContext, x)
44 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
58 edgedetect->
class = &edgedetect_class;
64 edgedetect->
low_u8 = edgedetect->
low * 255. + .5;
91 const uint8_t *src,
int src_linesize)
95 memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
96 memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
97 for (j = 2; j < h - 2; j++) {
100 for (i = 2; i < w - 2; i++) {
102 dst[i] = ((src[-2*src_linesize + i-2] + src[2*src_linesize + i-2]) * 2
103 + (src[-2*src_linesize + i-1] + src[2*src_linesize + i-1]) * 4
104 + (src[-2*src_linesize + i ] + src[2*src_linesize + i ]) * 5
105 + (src[-2*src_linesize + i+1] + src[2*src_linesize + i+1]) * 4
106 + (src[-2*src_linesize + i+2] + src[2*src_linesize + i+2]) * 2
108 + (src[ -src_linesize + i-2] + src[ src_linesize + i-2]) * 4
109 + (src[ -src_linesize + i-1] + src[ src_linesize + i-1]) * 9
110 + (src[ -src_linesize + i ] + src[ src_linesize + i ]) * 12
111 + (src[ -src_linesize + i+1] + src[ src_linesize + i+1]) * 9
112 + (src[ -src_linesize + i+2] + src[ src_linesize + i+2]) * 4
118 + src[i+2] * 5) / 159;
121 dst[i + 1] = src[i + 1];
126 memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
150 int tanpi8gx, tan3pi8gx;
155 tanpi8gx = 27146 * gx;
156 tan3pi8gx = 158218 * gx;
165 uint16_t *
dst,
int dst_linesize,
166 const uint8_t *src,
int src_linesize)
171 for (j = 1; j < h - 1; j++) {
174 for (i = 1; i < w - 1; i++) {
176 -1*src[-src_linesize + i-1] + 1*src[-src_linesize + i+1]
177 -2*src[ i-1] + 2*src[ i+1]
178 -1*src[ src_linesize + i-1] + 1*src[ src_linesize + i+1];
180 -1*src[-src_linesize + i-1] + 1*src[ src_linesize + i-1]
181 -2*src[-src_linesize + i ] + 2*src[ src_linesize + i ]
182 -1*src[-src_linesize + i+1] + 1*src[ src_linesize + i+1];
192 const uint16_t *src,
int src_linesize)
197 #define COPY_MAXIMA(ay, ax, by, bx) do { \
198 if (src[i] > src[(ay)*src_linesize + i+(ax)] && \
199 src[i] > src[(by)*src_linesize + i+(bx)]) \
200 dst[i] = av_clip_uint8(src[i]); \
203 for (j = 1; j < h - 1; j++) {
206 for (i = 1; i < w - 1; i++) {
219 const uint8_t *src,
int src_linesize)
223 const int low = edgedetect->
low_u8;
224 const int high = edgedetect->
high_u8;
226 for (j = 0; j < h; j++) {
227 for (i = 0; i < w; i++) {
233 if ((!i || i == w - 1 || !j || j == h - 1) &&
235 (src[-src_linesize + i-1] > high ||
236 src[-src_linesize + i ] > high ||
237 src[-src_linesize + i+1] > high ||
240 src[ src_linesize + i-1] > high ||
241 src[ src_linesize + i ] > high ||
242 src[ src_linesize + i+1] > high))
258 uint16_t *gradients = edgedetect->
gradients;
274 sobel(ctx, inlink->
w, inlink->
h,
275 gradients, inlink->
w,
280 memset(tmpbuf, 0, inlink->
w * inlink->
h);
283 gradients, inlink->
w);
322 .
name =
"edgedetect",
328 .
inputs = edgedetect_inputs,
330 .priv_class = &edgedetect_class,