diff options
author | Clément Bœsch <ubitux@gmail.com> | 2012-11-28 22:56:18 +0400 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2012-11-28 23:03:01 +0400 |
commit | 57d9c86bf34e81fb6f94b576dcae06766dce7047 (patch) | |
tree | 19015fae388671188ddebc2b690123f9d379e94d /libavfilter | |
parent | 92b57e8dac76ee633a59c4e8d256f1247f13c095 (diff) |
lavfi/edgedetect: switch to filter_frame.
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_edgedetect.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/libavfilter/vf_edgedetect.c b/libavfilter/vf_edgedetect.c index d3d8ca1380..6f89e52aea 100644 --- a/libavfilter/vf_edgedetect.c +++ b/libavfilter/vf_edgedetect.c @@ -249,20 +249,26 @@ static void double_threshold(AVFilterContext *ctx, int w, int h, } } -static int end_frame(AVFilterLink *inlink) +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in) { AVFilterContext *ctx = inlink->dst; EdgeDetectContext *edgedetect = ctx->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; - AVFilterBufferRef *inpicref = inlink->cur_buf; - AVFilterBufferRef *outpicref = outlink->out_buf; uint8_t *tmpbuf = edgedetect->tmpbuf; uint16_t *gradients = edgedetect->gradients; + AVFilterBufferRef *out; + + out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); + if (!out) { + avfilter_unref_bufferp(&in); + return AVERROR(ENOMEM); + } + avfilter_copy_buffer_ref_props(out, in); /* gaussian filter to reduce noise */ gaussian_blur(ctx, inlink->w, inlink->h, - tmpbuf, inlink->w, - inpicref->data[0], inpicref->linesize[0]); + tmpbuf, inlink->w, + in->data[0], in->linesize[0]); /* compute the 16-bits gradients and directions for the next step */ sobel(ctx, inlink->w, inlink->h, @@ -278,11 +284,11 @@ static int end_frame(AVFilterLink *inlink) /* keep high values, or low values surrounded by high values */ double_threshold(ctx, inlink->w, inlink->h, - outpicref->data[0], outpicref->linesize[0], - tmpbuf, inlink->w); + out->data[0], out->linesize[0], + tmpbuf, inlink->w); - ff_draw_slice(outlink, 0, outlink->h, 1); - return ff_end_frame(outlink); + avfilter_unref_bufferp(&in); + return ff_filter_frame(outlink, out); } static av_cold void uninit(AVFilterContext *ctx) @@ -293,8 +299,6 @@ static av_cold void uninit(AVFilterContext *ctx) av_freep(&edgedetect->directions); } -static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { return 0; } - AVFilter avfilter_vf_edgedetect = { .name = "edgedetect", .description = NULL_IF_CONFIG_SMALL("Detect and draw edge."), @@ -307,9 +311,8 @@ AVFilter avfilter_vf_edgedetect = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .draw_slice = null_draw_slice, .config_props = config_props, - .end_frame = end_frame, + .filter_frame = filter_frame, .min_perms = AV_PERM_READ }, { .name = NULL } |