From patchwork Mon Jul 31 12:02:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 4545 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.85 with SMTP id 82csp2324730vsb; Mon, 31 Jul 2017 05:04:13 -0700 (PDT) X-Received: by 10.223.136.212 with SMTP id g20mr12633705wrg.186.1501502653105; Mon, 31 Jul 2017 05:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501502653; cv=none; d=google.com; s=arc-20160816; b=QgkV1Ft4wqAHHzLn83ep2ekz6bIhtnLMwrAtd/ZG0XogYHDOXSQ2DDJxgysHYT0MZ8 zDPUxMjmYGBU28PZVIs0D31BUiccY7XOTCDcugEB1paF8AJTbj1c5W0RkDFg6PdhEUTp 6/Ecm1UCK6C3LcOBgM46s9RXZh22fQPEDGaKEhg38aVy/UYBELkqBJG463AgpzE9VpHt sT0hPbM93QyjuiGw04C4pN/xjSycuxwiEKZr9BDJ/W+/5+tF/vmpIe8NYdGUy1GWp2nH j/eLK1I2pA41LJN/95yellcGPfVtFtfe2CmFPHFhsofd4smupkB2TR1BS9suXbj68HJL G9CQ== 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=XXpDOgIabRrtEwXjll8VY4j8CVaEHhYXu0dfhqIM+l0=; b=x/dt0WED33ip0agf1qEQBCGKVrqHA1yrKJ7q+w6Sx5RqQHdeaBTwGGpxvpk/QcqPHO VMRAAo89RQz0mUEsBJfh6BkzM3vTej8IUWwFmtY4LOJzgWlPskTrxRmyRp1sZTwWP1X/ Sc7dMEL/5ty7LXR2JMmU93eeUHUFIBib2JYplIewHScJA7JxILn9h4EmR27AvxW/x0gc +kCUlhrmjDXJ/hNWh1TA3/3KISrPiQrBQRWaCqA+c8m6LKdYwtniNITg+hwjrgJyJ85X SBvyUb+uHB0yL9EVBn8346brUOqa5RKJbA+7vG97FLRYvAOPjrxZwHxa+RXgQrLP16AC nB7w== 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 b20si8016276wmd.176.2017.07.31.05.04.12; Mon, 31 Jul 2017 05:04:13 -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 2A10A68A241; Mon, 31 Jul 2017 15:02:43 +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 5848E68A1F5 for ; Mon, 31 Jul 2017 15:02:33 +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 v6VC2ZX8071535 for ; Mon, 31 Jul 2017 14:02:35 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id 44F73E00FB; Mon, 31 Jul 2017 14:02:35 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 Jul 2017 14:02:23 +0200 Message-Id: <20170731120227.31047-10-george@nsup.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170731120227.31047-1-george@nsup.org> References: <20170731120227.31047-1-george@nsup.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Mon, 31 Jul 2017 14:02:35 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 10/14] 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(-) diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 4089d910ad..a62339992f 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -196,7 +196,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,