From 565e4993c63f797e2d50ad2f1e8f62fdbe299666 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 27 Nov 2012 07:49:45 +0100 Subject: 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. --- libavfilter/vf_hflip.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'libavfilter/vf_hflip.c') diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c index 3ae0fc6..85a1d92 100644 --- a/libavfilter/vf_hflip.c +++ b/libavfilter/vf_hflip.c @@ -84,22 +84,30 @@ static int config_props(AVFilterLink *inlink) return 0; } -static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in) { - FlipContext *flip = inlink->dst->priv; - AVFilterBufferRef *inpic = inlink->cur_buf; - AVFilterBufferRef *outpic = inlink->dst->outputs[0]->out_buf; + AVFilterContext *ctx = inlink->dst; + FlipContext *flip = ctx->priv; + AVFilterLink *outlink = ctx->outputs[0]; + AVFilterBufferRef *out; uint8_t *inrow, *outrow; int i, j, plane, step, hsub, vsub; - for (plane = 0; plane < 4 && inpic->data[plane]; plane++) { + 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); + + for (plane = 0; plane < 4 && in->data[plane]; plane++) { step = flip->max_step[plane]; hsub = (plane == 1 || plane == 2) ? flip->hsub : 0; vsub = (plane == 1 || plane == 2) ? flip->vsub : 0; - outrow = outpic->data[plane] + (y>>vsub) * outpic->linesize[plane]; - inrow = inpic ->data[plane] + (y>>vsub) * inpic ->linesize[plane] + ((inlink->w >> hsub) - 1) * step; - for (i = 0; i < h>>vsub; i++) { + outrow = out->data[plane]; + inrow = in ->data[plane] + ((inlink->w >> hsub) - 1) * step; + for (i = 0; i < in->video->h >> vsub; i++) { switch (step) { case 1: for (j = 0; j < (inlink->w >> hsub); j++) @@ -140,19 +148,20 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) memcpy(outrow + j*step, inrow - j*step, step); } - inrow += inpic ->linesize[plane]; - outrow += outpic->linesize[plane]; + inrow += in ->linesize[plane]; + outrow += out->linesize[plane]; } } - return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); + avfilter_unref_bufferp(&in); + return ff_filter_frame(outlink, out); } static const AVFilterPad avfilter_vf_hflip_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .draw_slice = draw_slice, + .filter_frame = filter_frame, .config_props = config_props, .min_perms = AV_PERM_READ, }, -- cgit v1.1