From e366aec0305299f8f3e2057cc5a856c737944bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 3 Apr 2013 00:21:11 +0200 Subject: [PATCH] lavfi/edgedetect: add direct path. --- libavfilter/vf_edgedetect.c | 9 ++++++++- tests/lavfi-regression.sh | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_edgedetect.c b/libavfilter/vf_edgedetect.c index b582ab9685..16c6414211 100644 --- a/libavfilter/vf_edgedetect.c +++ b/libavfilter/vf_edgedetect.c @@ -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); } diff --git a/tests/lavfi-regression.sh b/tests/lavfi-regression.sh index 64607426ac..bb023e4567 100755 --- a/tests/lavfi-regression.sh +++ b/tests/lavfi-regression.sh @@ -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"