From patchwork Thu Aug 10 11:46:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 4676 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp2308119vsu; Thu, 10 Aug 2017 04:47:48 -0700 (PDT) X-Received: by 10.28.66.18 with SMTP id p18mr8937418wma.60.1502365668810; Thu, 10 Aug 2017 04:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502365668; cv=none; d=google.com; s=arc-20160816; b=bQXCcu9FcbLFJLEr9A7drjNW2f8eqhJzTHro8lTi3HXLqvKBZKKdopMuzAAhvGX/XY AS9fujnazuzY0odOihxDzKzb+isjbDiZwoSzEqY/zlp6o217XtL5TN0s78/Wl3LmZJEK mBdS91JXVRs06YNgTJ/lBbH0KR5uO/QDjxJneowvQLTV1tnsSjfAR+BSHdFDjsYHQ/Dv ChNWvj+aeD9E4GPOn68m3G0GfNpeAmRHdQYwev5xMl8IDk9DT29zN/JeVxavq03sPcbO KYXh8nDvWWliXMSHwmJpTheO3ghJr/C7TifP3RedzZ8ZTM1a4ESa2fJJOP6MkA9v7PXj 8Qew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=tFe+kH/CI67/yq1zgtIWStHuLBOWHwV6O7tZ5PgVTOE=; b=IPJ/Ue8+TN79YMQlxux6mDoWbFSsDPIqygNUEG3+SZGwKxyU+aGYHXh2MnrWbyVdaS dk8aKcRasFvsovf71c9NcGJ44yN4hR9/Ljcr8mJWLJ2kSaSzpcsFKmaUVxyO1AOCk0Q0 aMBQuvgzTWe5KSFV3TLqKHCli8XeeECGR1K7xrlQgQ/BigMdoqxYr5Abgo33l8wzO+Eg hQUCzGnskHxQ62vDhbpA9me5vTWboWP+vSfn/hagFtiSYvaa7zRBT8Gqj3gv2+eAIsiR T8brP2gEFBFek9INlyzeHhXoHl4rJ07bsvL1bxl/8ExqxZUlxKvAfkD3pgEMgJFJOg2z XPxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c14si5058188wrb.102.2017.08.10.04.47.48; Thu, 10 Aug 2017 04:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 61AD3689C84; Thu, 10 Aug 2017 14:46:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef2.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BECD7689C1B for ; Thu, 10 Aug 2017 14:46:51 +0300 (EEST) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id v7ABksWD043733 for ; Thu, 10 Aug 2017 13:46:54 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id F2974E00F5; Thu, 10 Aug 2017 13:46:53 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Aug 2017 13:46:37 +0200 Message-Id: <20170810114642.26779-11-george@nsup.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170810114642.26779-1-george@nsup.org> References: <20170810114642.26779-1-george@nsup.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Thu, 10 Aug 2017 13:46:54 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 11/16] lavfi/vf_lut3d: convert to framesync2. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Nicolas George --- libavfilter/Makefile | 2 +- libavfilter/vf_lut3d.c | 49 ++++++++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 24 deletions(-) Unchanged. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 47e649cdc4..21a88954bb 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -197,7 +197,7 @@ OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o OBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o OBJS-$(CONFIG_GEQ_FILTER) += vf_geq.o OBJS-$(CONFIG_GRADFUN_FILTER) += vf_gradfun.o -OBJS-$(CONFIG_HALDCLUT_FILTER) += vf_lut3d.o dualinput.o framesync.o +OBJS-$(CONFIG_HALDCLUT_FILTER) += vf_lut3d.o framesync2.o OBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o OBJS-$(CONFIG_HISTOGRAM_FILTER) += vf_histogram.o diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c index 7a294b0761..5ba91f7e47 100644 --- a/libavfilter/vf_lut3d.c +++ b/libavfilter/vf_lut3d.c @@ -31,8 +31,8 @@ #include "libavutil/avstring.h" #include "avfilter.h" #include "drawutils.h" -#include "dualinput.h" #include "formats.h" +#include "framesync2.h" #include "internal.h" #include "video.h" @@ -70,7 +70,7 @@ typedef struct LUT3DContext { int clut_step; int clut_is16bit; int clut_width; - FFDualInputContext dinput; + FFFrameSync fs; #endif } LUT3DContext; @@ -681,24 +681,21 @@ static int config_output(AVFilterLink *outlink) LUT3DContext *lut3d = ctx->priv; int ret; + ret = ff_framesync2_init_dualinput(&lut3d->fs, ctx); + if (ret < 0) + return ret; outlink->w = ctx->inputs[0]->w; outlink->h = ctx->inputs[0]->h; outlink->time_base = ctx->inputs[0]->time_base; - if ((ret = ff_dualinput_init(ctx, &lut3d->dinput)) < 0) + if ((ret = ff_framesync2_configure(&lut3d->fs)) < 0) return ret; return 0; } -static int filter_frame_hald(AVFilterLink *inlink, AVFrame *inpicref) -{ - LUT3DContext *s = inlink->dst->priv; - return ff_dualinput_filter_frame(&s->dinput, inlink, inpicref); -} - -static int request_frame(AVFilterLink *outlink) +static int activate(AVFilterContext *ctx) { - LUT3DContext *s = outlink->src->priv; - return ff_dualinput_request_frame(&s->dinput, outlink); + LUT3DContext *s = ctx->priv; + return ff_framesync2_activate(&s->fs); } static int config_clut(AVFilterLink *inlink) @@ -751,45 +748,50 @@ static int config_clut(AVFilterLink *inlink) return 0; } -static AVFrame *update_apply_clut(AVFilterContext *ctx, AVFrame *main, - const AVFrame *second) +static int update_apply_clut(FFFrameSync *fs) { + AVFilterContext *ctx = fs->parent; AVFilterLink *inlink = ctx->inputs[0]; + AVFrame *main, *second, *out; + int ret; + + ret = ff_framesync2_dualinput_get(fs, &main, &second); + if (ret < 0) + return ret; + if (!second) + return ff_filter_frame(ctx->outputs[0], main); update_clut(ctx->priv, second); - return apply_lut(inlink, main); + out = apply_lut(inlink, main); + return ff_filter_frame(ctx->outputs[0], out); } static av_cold int haldclut_init(AVFilterContext *ctx) { LUT3DContext *lut3d = ctx->priv; - lut3d->dinput.process = update_apply_clut; + lut3d->fs.on_event = update_apply_clut; return 0; } static av_cold void haldclut_uninit(AVFilterContext *ctx) { LUT3DContext *lut3d = ctx->priv; - ff_dualinput_uninit(&lut3d->dinput); + ff_framesync2_uninit(&lut3d->fs); } static const AVOption haldclut_options[] = { - { "shortest", "force termination when the shortest input terminates", OFFSET(dinput.shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, - { "repeatlast", "continue applying the last clut after eos", OFFSET(dinput.repeatlast), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, COMMON_OPTIONS }; -AVFILTER_DEFINE_CLASS(haldclut); +FRAMESYNC_DEFINE_CLASS(haldclut, LUT3DContext, fs); static const AVFilterPad haldclut_inputs[] = { { .name = "main", .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = filter_frame_hald, .config_props = config_input, },{ .name = "clut", .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = filter_frame_hald, .config_props = config_clut, }, { NULL } @@ -799,7 +801,6 @@ static const AVFilterPad haldclut_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = config_output, }, { NULL } @@ -809,9 +810,11 @@ AVFilter ff_vf_haldclut = { .name = "haldclut", .description = NULL_IF_CONFIG_SMALL("Adjust colors using a Hald CLUT."), .priv_size = sizeof(LUT3DContext), + .preinit = haldclut_framesync_preinit, .init = haldclut_init, .uninit = haldclut_uninit, .query_formats = query_formats, + .activate = activate, .inputs = haldclut_inputs, .outputs = haldclut_outputs, .priv_class = &haldclut_class,