lavfi/edgedetect: add direct path.
authorClément Bœsch <ubitux@gmail.com>
Tue, 2 Apr 2013 22:21:11 +0000 (00:21 +0200)
committerClément Bœsch <ubitux@gmail.com>
Tue, 2 Apr 2013 22:30:48 +0000 (00:30 +0200)
libavfilter/vf_edgedetect.c
tests/lavfi-regression.sh

index b582ab9..16c6414 100644 (file)
@@ -256,14 +256,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     AVFilterLink *outlink = inlink->dst->outputs[0];
     uint8_t  *tmpbuf    = edgedetect->tmpbuf;
     uint16_t *gradients = edgedetect->gradients;
+    int direct = 0;
     AVFrame *out;
 
+    if (av_frame_is_writable(in)) {
+        direct = 1;
+        out = in;
+    } else {
     out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     if (!out) {
         av_frame_free(&in);
         return AVERROR(ENOMEM);
     }
     av_frame_copy_props(out, in);
+    }
 
     /* gaussian filter to reduce noise  */
     gaussian_blur(ctx, inlink->w, inlink->h,
@@ -287,7 +293,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                      out->data[0], out->linesize[0],
                      tmpbuf,       inlink->w);
 
-    av_frame_free(&in);
+    if (!direct)
+        av_frame_free(&in);
     return ff_filter_frame(outlink, out);
 }
 
index 6460742..bb023e4 100755 (executable)
@@ -42,7 +42,7 @@ do_lavfi "crop_scale"         "crop=iw-100:ih-100:100:100,scale=400:-1"
 do_lavfi "crop_scale_vflip"   "null,null,crop=iw-200:ih-200:200:200,crop=iw-20:ih-20:20:20,scale=200:200,scale=250:250,vflip,vflip,null,scale=200:200,crop=iw-100:ih-100:100:100,vflip,scale=200:200,null,vflip,crop=iw-100:ih-100:100:100,null"
 do_lavfi "crop_vflip"         "crop=iw-100:ih-100:100:100,vflip"
 do_lavfi "drawbox"            "drawbox=224:24:88:72:#FF8010@0.5"
-do_lavfi "edgedetect"         "edgedetect"
+do_lavfi "edgedetect"         "format=gray,perms=random,edgedetect"
 do_lavfi "fade"               "fade=in:5:15,fade=out:30:15"
 do_lavfi "hue"                "perms=random,hue=s=sin(2*PI*t)+1"
 do_lavfi "idet"               "idet"