From patchwork Wed Oct 9 09:56:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 15611 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4067D44696F for ; Wed, 9 Oct 2019 12:57:19 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 34A616881F4; Wed, 9 Oct 2019 12:57:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3969A6881C6 for ; Wed, 9 Oct 2019 12:57:10 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id j11so2078181wrp.1 for ; Wed, 09 Oct 2019 02:57:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=IVeNUvu5ohUJ50d60sSPUigChq5uvKf6IG4oJOMFTWM=; b=kOrnws9L1IY8NT/5TbiPDGExItqDV0BpQ8NhgRyaqljkwblRW+knBbZs7r4Cf96Ts1 S7ssi10KZnMl10glKW6F+JeSHvvfSaQC4ikcrfwVL+7XKymDL2obDPkMjbzjFpZxBY77 Bmf/poWQqTSG3aDi+ClRDAcpZL1Ncymvf7SpkGehj5r+0zL+dooBJLrl56448iTUZzsp t177cIlO/Puo2tAz/Gv+oOo1GPjNq+O8qO8C3uDV0hGEjEL8jxBRDkilQnSx/8uhGXfv jfY8UQ4tTsVnkXTzY3Hq+aU30/t9yBtwxDlq534MzA48c440NIjQ5Edke22IZCbRC+jo TEsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=IVeNUvu5ohUJ50d60sSPUigChq5uvKf6IG4oJOMFTWM=; b=kE70t6WXOl2RQGxbjn/iYswUf+LOhdfhX+NajNrWdDGbBC64PikSH/qjb85owZsWUq po3XXLfkOL9GhLp19pxMoAsiCYFJV/x+YALznV1gFMIBOj55jWVUYYj795gu+192SsFS H6fsPbjQ8TmS8ok4LvVLx67cS9NxrsXksYZxMAjzGOEBcpDBumLpKVOJNQWZZAQI3CEm 7aGQUnkNaQ7zhmEV87mZXgOQEWVuAg/cMlNsHADH4ng2V5PVEa6v5OAnsmc7nM7y+TkF WQiCak4OWNjON0OBdBnzKixGIWE+OSlXOrHcDckh+GByBR7r7ml8TlcAr5K6FQIirZ/T KmpA== X-Gm-Message-State: APjAAAW5260gqpTQ9n8vKBgUnU5JGzdI4C0lVoRXGQOi9Vn1Mt9heLDC +Yk4r81fGck4jYHZmoibDfK5SYWY X-Google-Smtp-Source: APXvYqzrOKeqtFgIDN0Hcl2zVt42fRFEda7R8Is+Vs15ryVYtr7k38xUgV0HuTg9TI2rjyZ7KzO7HA== X-Received: by 2002:a05:6000:1252:: with SMTP id j18mr2147486wrx.160.1570615029490; Wed, 09 Oct 2019 02:57:09 -0700 (PDT) Received: from localhost.localdomain ([37.244.241.148]) by smtp.gmail.com with ESMTPSA id s9sm1964315wme.36.2019.10.09.02.57.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 02:57:08 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Wed, 9 Oct 2019 11:56:48 +0200 Message-Id: <20191009095651.2928-10-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191009095651.2928-1-onemda@gmail.com> References: <20191009095651.2928-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 10/13] avfilter/vf_colorchannelmixer: add support for commands 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: Paul B Mahol --- libavfilter/vf_colorchannelmixer.c | 31 ++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/libavfilter/vf_colorchannelmixer.c b/libavfilter/vf_colorchannelmixer.c index 3a9cd37b78..074aa5e0f1 100644 --- a/libavfilter/vf_colorchannelmixer.c +++ b/libavfilter/vf_colorchannelmixer.c @@ -52,7 +52,8 @@ typedef struct ColorChannelMixerContext { } ColorChannelMixerContext; #define OFFSET(x) offsetof(ColorChannelMixerContext, x) -#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_COMMAND_PARAM + static const AVOption colorchannelmixer_options[] = { { "rr", "set the red gain for the red channel", OFFSET(rr), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -2, 2, FLAGS }, { "rg", "set the green gain for the red channel", OFFSET(rg), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS }, @@ -408,18 +409,20 @@ static int config_output(AVFilterLink *outlink) ColorChannelMixerContext *s = ctx->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format); const int depth = desc->comp[0].depth; - int i, j, size, *buffer; + int i, j, size, *buffer = s->buffer; ff_fill_rgba_map(s->rgba_map, outlink->format); size = 1 << depth; - s->buffer = buffer = av_malloc(16 * size * sizeof(*s->buffer)); - if (!s->buffer) - return AVERROR(ENOMEM); + if (!s->buffer) { + s->buffer = buffer = av_malloc(16 * size * sizeof(*s->buffer)); + if (!s->buffer) + return AVERROR(ENOMEM); - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++, buffer += size) - s->lut[i][j] = buffer; + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++, buffer += size) + s->lut[i][j] = buffer; + } for (i = 0; i < size; i++) { s->lut[R][R][i] = lrint(i * s->rr); @@ -531,6 +534,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) return ff_filter_frame(outlink, out); } +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, + char *res, int res_len, int flags) +{ + int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags); + + if (ret < 0) + return ret; + + return config_output(ctx->outputs[0]); +} + static av_cold void uninit(AVFilterContext *ctx) { ColorChannelMixerContext *s = ctx->priv; @@ -566,4 +580,5 @@ AVFilter ff_vf_colorchannelmixer = { .inputs = colorchannelmixer_inputs, .outputs = colorchannelmixer_outputs, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, + .process_command = process_command, };