]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_edgedetect.c
doc/filters: Documentation to add sess_config option for tensorflow backend
[ffmpeg] / libavfilter / vf_edgedetect.c
index a0ddcbbf5c69c6b68a9faab3f516f10b67211323..e21d341fd292d5dd18375bbebe02dfa3d260166a 100644 (file)
@@ -150,10 +150,13 @@ static void gaussian_blur(AVFilterContext *ctx, int w, int h,
     int i, j;
 
     memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
-    memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
+    if (h > 1) {
+        memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
+    }
     for (j = 2; j < h - 2; j++) {
         dst[0] = src[0];
-        dst[1] = src[1];
+        if (w > 1)
+            dst[1] = src[1];
         for (i = 2; i < w - 2; i++) {
             /* Gaussian mask of size 5x5 with sigma = 1.4 */
             dst[i] = ((src[-2*src_linesize + i-2] + src[2*src_linesize + i-2]) * 2
@@ -174,14 +177,19 @@ static void gaussian_blur(AVFilterContext *ctx, int w, int h,
                     + src[i+1] * 12
                     + src[i+2] *  5) / 159;
         }
-        dst[i    ] = src[i    ];
-        dst[i + 1] = src[i + 1];
+        if (w > 2)
+            dst[i    ] = src[i    ];
+        if (w > 3)
+            dst[i + 1] = src[i + 1];
 
         dst += dst_linesize;
         src += src_linesize;
     }
-    memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
-    memcpy(dst, src, w);
+    if (h > 2) {
+        memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
+    }
+    if (h > 3)
+        memcpy(dst, src, w);
 }
 
 enum {
@@ -208,7 +216,7 @@ static int get_rounded_direction(int gx, int gy)
 
         if (gx < 0)
             gx = -gx, gy = -gy;
-        gy <<= 16;
+        gy *= (1 << 16);
         tanpi8gx  =  27146 * gx;
         tan3pi8gx = 158218 * gx;
         if (gy > -tan3pi8gx && gy < -tanpi8gx)  return DIRECTION_45UP;
@@ -286,7 +294,7 @@ static void double_threshold(int low, int high, int w, int h,
                 continue;
             }
 
-            if ((!i || i == w - 1 || !j || j == h - 1) &&
+            if (!(!i || i == w - 1 || !j || j == h - 1) &&
                 src[i] > low &&
                 (src[-src_linesize + i-1] > high ||
                  src[-src_linesize + i  ] > high ||
@@ -423,7 +431,7 @@ static const AVFilterPad edgedetect_outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vf_edgedetect = {
+const AVFilter ff_vf_edgedetect = {
     .name          = "edgedetect",
     .description   = NULL_IF_CONFIG_SMALL("Detect and draw edge."),
     .priv_size     = sizeof(EdgeDetectContext),