diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-11-27 07:49:45 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-11-28 08:50:19 +0100 |
commit | 565e4993c63f797e2d50ad2f1e8f62fdbe299666 (patch) | |
tree | bae5282b2ee875de4b01467f3cfaab54b0ab6ec0 /libavfilter/vf_hqdn3d.c | |
parent | bb6c67bb36b136de10256f0999128df4a42f9ffc (diff) |
lavfi: merge start_frame/draw_slice/end_frame
Any alleged performance benefits gained from the split are purely
mythological and do not justify added code complexity.
Diffstat (limited to 'libavfilter/vf_hqdn3d.c')
-rw-r--r-- | libavfilter/vf_hqdn3d.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c index 4ed8905979..7365b8d502 100644 --- a/libavfilter/vf_hqdn3d.c +++ b/libavfilter/vf_hqdn3d.c @@ -322,42 +322,49 @@ static int config_input(AVFilterLink *inlink) return 0; } -static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) -{ - return 0; -} - -static int end_frame(AVFilterLink *inlink) +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in) { HQDN3DContext *hqdn3d = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; - AVFilterBufferRef *inpic = inlink ->cur_buf; - AVFilterBufferRef *outpic = outlink->out_buf; - int ret, c; + AVFilterBufferRef *out; + int direct, c; + + if ((in->perms & AV_PERM_WRITE) && !(in->perms & AV_PERM_PRESERVE)) { + direct = 1; + out = in; + } else { + 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); + out->video->w = outlink->w; + out->video->h = outlink->h; + } for (c = 0; c < 3; c++) { - denoise(hqdn3d, inpic->data[c], outpic->data[c], + denoise(hqdn3d, in->data[c], out->data[c], hqdn3d->line, &hqdn3d->frame_prev[c], - inpic->video->w >> (!!c * hqdn3d->hsub), - inpic->video->h >> (!!c * hqdn3d->vsub), - inpic->linesize[c], outpic->linesize[c], + in->video->w >> (!!c * hqdn3d->hsub), + in->video->h >> (!!c * hqdn3d->vsub), + in->linesize[c], out->linesize[c], hqdn3d->coefs[c?2:0], hqdn3d->coefs[c?3:1]); } - if ((ret = ff_draw_slice(outlink, 0, inpic->video->h, 1)) < 0 || - (ret = ff_end_frame(outlink)) < 0) - return ret; - return 0; + if (!direct) + avfilter_unref_bufferp(&in); + + return ff_filter_frame(outlink, out); } static const AVFilterPad avfilter_vf_hqdn3d_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .start_frame = ff_inplace_start_frame, - .draw_slice = null_draw_slice, .config_props = config_input, - .end_frame = end_frame + .filter_frame = filter_frame, }, { NULL } }; |