X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fvf_alphamerge.c;h=f3800db409d3edabd1400fa9a423167a60c95543;hb=1374b5e15b5dd900bb5a69d78491b793db1c7f38;hp=51868dee0197d25406dae840084e8f4d5865fbea;hpb=2581d9bcbb2e45fa1f8538d038099f6e673d9566;p=ffmpeg diff --git a/libavfilter/vf_alphamerge.c b/libavfilter/vf_alphamerge.c index 51868dee019..f3800db409d 100644 --- a/libavfilter/vf_alphamerge.c +++ b/libavfilter/vf_alphamerge.c @@ -95,9 +95,6 @@ static int config_output(AVFilterLink *outlink) return 0; } -static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) {return 0;} -static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) {return 0;} - static void draw_frame(AVFilterContext *ctx, AVFilterBufferRef *main_buf, AVFilterBufferRef *alpha_buf) @@ -127,10 +124,9 @@ static void draw_frame(AVFilterContext *ctx, FFMIN(main_linesize, alpha_linesize)); } } - ff_draw_slice(ctx->outputs[0], 0, h, 1); } -static int end_frame(AVFilterLink *inlink) +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf) { AVFilterContext *ctx = inlink->dst; AlphaMergeContext *merge = ctx->priv; @@ -138,8 +134,7 @@ static int end_frame(AVFilterLink *inlink) int is_alpha = (inlink == ctx->inputs[1]); struct FFBufQueue *queue = (is_alpha ? &merge->queue_alpha : &merge->queue_main); - ff_bufqueue_add(ctx, queue, inlink->cur_buf); - inlink->cur_buf = NULL; + ff_bufqueue_add(ctx, queue, buf); while (1) { AVFilterBufferRef *main_buf, *alpha_buf; @@ -150,11 +145,9 @@ static int end_frame(AVFilterLink *inlink) main_buf = ff_bufqueue_get(&merge->queue_main); alpha_buf = ff_bufqueue_get(&merge->queue_alpha); - ctx->outputs[0]->out_buf = main_buf; - ff_start_frame(ctx->outputs[0], avfilter_ref_buffer(main_buf, ~0)); merge->frame_requested = 0; draw_frame(ctx, main_buf, alpha_buf); - ff_end_frame(ctx->outputs[0]); + ff_filter_frame(ctx->outputs[0], main_buf); avfilter_unref_buffer(alpha_buf); } return 0; @@ -176,6 +169,33 @@ static int request_frame(AVFilterLink *outlink) return 0; } +static const AVFilterPad alphamerge_inputs[] = { + { + .name = "main", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_input_main, + .get_video_buffer = ff_null_get_video_buffer, + .filter_frame = filter_frame, + .min_perms = AV_PERM_READ | AV_PERM_WRITE | AV_PERM_PRESERVE, + },{ + .name = "alpha", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + .min_perms = AV_PERM_READ | AV_PERM_PRESERVE, + }, + { NULL } +}; + +static const AVFilterPad alphamerge_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_output, + .request_frame = request_frame, + }, + { NULL } +}; + AVFilter avfilter_vf_alphamerge = { .name = "alphamerge", .description = NULL_IF_CONFIG_SMALL("Copy the luma value of the second " @@ -183,29 +203,6 @@ AVFilter avfilter_vf_alphamerge = { .uninit = uninit, .priv_size = sizeof(AlphaMergeContext), .query_formats = query_formats, - - .inputs = (const AVFilterPad[]) { - { .name = "main", - .type = AVMEDIA_TYPE_VIDEO, - .config_props = config_input_main, - .get_video_buffer = ff_null_get_video_buffer, - .start_frame = start_frame, - .draw_slice = draw_slice, - .end_frame = end_frame, - .min_perms = AV_PERM_READ | AV_PERM_WRITE | AV_PERM_PRESERVE }, - { .name = "alpha", - .type = AVMEDIA_TYPE_VIDEO, - .start_frame = start_frame, - .draw_slice = draw_slice, - .end_frame = end_frame, - .min_perms = AV_PERM_READ | AV_PERM_PRESERVE }, - { .name = NULL } - }, - .outputs = (const AVFilterPad[]) { - { .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .config_props = config_output, - .request_frame = request_frame }, - { .name = NULL } - }, + .inputs = alphamerge_inputs, + .outputs = alphamerge_outputs, };