From patchwork Tue Apr 24 12:53:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 8627 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp1823448jad; Tue, 24 Apr 2018 06:01:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Ge5SQ9jHcdoTeQwBm8rtWGx1n3ibZdcF8PaIX8ym1F3MzoJIgCd8KEuf87X2hp5bxwUDU X-Received: by 10.28.24.76 with SMTP id 73mr12749876wmy.24.1524574861811; Tue, 24 Apr 2018 06:01:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574861; cv=none; d=google.com; s=arc-20160816; b=cilixTT7Hhf3pClqZOqzorXjIQesLGCfihXcU3SZ85rSPp+fRwoXqLVmGqZ7d+9eWq YxP2NDJCqaTdgQZar/Ve+1E4Lkodc9sBYCM1Yl7gZp8kSS6asa2qKELd0TTU6OWOy9Uf ISq0r19nA7LRB2ss4nLypzzGkT+lxxWf13Z36bdGy4+6m8gSpQ8yg+NL6EDVKm9nb2ep FJhGDZ/0+sDar1meBB/aU4bCv0rEj9gtJxr4gLsEx1OBVJz+4Z5serM29Ek5vZ2ZYO1i mNiCGQsIrjqaZlGlYN3YO9rf9fLIOg1wNXFnfDRa8F+EpkG25CqJbFoCFnI4rsLGvrSC pgGg== 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:dkim-signature:delivered-to:arc-authentication-results; bh=42MneDM1L3uO6gDMxwJ9Tnya42GnWJ/tXNApj2jUk30=; b=F1+qM3CefZ4HEeuQz2k4s6w4Ky75mKB6DGDl5ZceytT+Y453f2kig/QCBlJYZlRRWv WI5ijEUAtOykqtXZ3/g08rKzKIJfwhBF0RvKIK8zXphUBP5ycFDdOuFzVYppSZDr2DlD YEdM3vMnhigCGUcZT6nUgOgpOhFvHJ0iy2Alsv6k/t/RP/CRucpEC86mXp/SABkk++k9 nELhg8hsT/Nhqed96VD3xykErq2RNABOjotlyPdhs7WeV1fuIk+xAuKbrlCBtqPSBi6U SIBTJf9g5x++reZvH8ZgqmjQDj705+VaQO6YRAgE1XaWhxndcXUMedSPxxKaGR0ZlDFf H2yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=s6eL7H2N; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v195si6078123wmf.79.2018.04.24.06.01.01; Tue, 24 Apr 2018 06:01:01 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=s6eL7H2N; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 85BB668A042; Tue, 24 Apr 2018 16:00:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0BD98689FB7 for ; Tue, 24 Apr 2018 16:00:24 +0300 (EEST) Received: by mail-wm0-f68.google.com with SMTP id o78so701029wmg.0 for ; Tue, 24 Apr 2018 06:00:53 -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=GQO1rryGF4IfPu1hPClxBG1W1dD9U89bkF/YQESOSDs=; b=s6eL7H2N7QJD4Dzb4GxIYOJeWeltyZe0Vb9E6qwcRWqkhfINYEN/aNFAP+6rzs+L2w 6VWxZqyH8yKwqZnanRfu+Kv8XpMUm17k1v+uHVvWC0iCXRR2RfHLDCcFaoItZBf4nl/D c/cpbObt8zcAm0EhRi+dTrVwV2P3GL7z0lhhdY2Cc3BYSD7K3AIth96n7nMH+D7SIklh SxTxSzKKu5U+AyhvQoicVcpdZ8mouP4e6ak+QjPkMVgVUXFPxA9gRQ7ID/Zz1TcYd32V z+Dcedjw/pDQEcmZu8LWZ/Or5B7GPzrZ+JiB6SzIZtKpHGokB+CjzgqTUmKXlbB+6XnY JI/A== 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=GQO1rryGF4IfPu1hPClxBG1W1dD9U89bkF/YQESOSDs=; b=K9iX5fBnV15akFsqhJv5IVs5ek0dujbWbMLgkxjQHjH4OI5049YKL4gvGC7LdH3Rjw JT54IgWBHmgfeVO9KVNPCxozBWARfBevaxRwgE9csgQGzPEL9As4h6iV7Oaeol0FPPk9 Kh8Bbw+oLybZipZMpVJCSYxl/a70y4aHe7BfqKRful1P995JpYxj5ISMRs7w1kyJJy4U k4JsunvI5/js+4rKPev/FM+826W/1ys1kxtE/W56GKDjI3qxyusAaIwJxPGkOaJK3zAn MIPHDIRBuCJvXK0VcysFBUwv0otzc/p4keO2bzzjE5mP7sknsBjxWrSjrZAdgy3kCqCs fRPQ== X-Gm-Message-State: ALQs6tA8mfBZG0LFKryhOjtJVXxiq7mAWoXnOn9ExzNcyxaWbBxhx7UF l+f3tHhsvh9nXM8Tp7DVgKhBYQ== X-Received: by 10.28.90.197 with SMTP id o188mr12589366wmb.151.1524574455820; Tue, 24 Apr 2018 05:54:15 -0700 (PDT) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id 44-v6sm12727982wrl.83.2018.04.24.05.54.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:54:15 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Apr 2018 14:53:29 +0200 Message-Id: <20180424125329.21212-2-onemda@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180424125329.21212-1-onemda@gmail.com> References: <20180424125329.21212-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_mix: add scale option 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 --- doc/filters.texi | 10 ++++++++++ libavfilter/vf_mix.c | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index 23d6063ef4..db686689ea 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -11154,6 +11154,11 @@ The number of inputs. If unspecified, it defaults to 2. Specify weight of each input video stream as sequence. Each weight is separated by space. +@item scale +Specify scale, if it is set it will be multiplied with sum +of weigths multiplied with pixel values to give final destination +pixel value. By default it is auto scaled to sum of weights. + @item duration Specify how end of stream is determined. @table @samp @@ -15574,6 +15579,11 @@ The number of successive frames to mix. If unspecified, it defaults to 3. @item weights Specify weight of each input video frame. Each weight is separated by space. + +@item scale +Specify scale, if it is set it will be multiplied with sum +of weigths multiplied with pixel values to give final destination +pixel value. By default it is auto scaled to sum of weights. @end table @section tonemap diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c index 3690b03cf8..8932bd53d7 100644 --- a/libavfilter/vf_mix.c +++ b/libavfilter/vf_mix.c @@ -37,6 +37,7 @@ typedef struct MixContext { int nb_inputs; int duration; float *weights; + float scale; float wfactor; int tmix; @@ -109,7 +110,11 @@ static av_cold int init(AVFilterContext *ctx) sscanf(arg, "%f", &s->weights[i]); s->wfactor += s->weights[i]; } - s->wfactor = 1 / s->wfactor; + if (s->scale == 0) { + s->wfactor = 1 / s->wfactor; + } else { + s->wfactor = s->scale; + } return 0; } @@ -275,6 +280,7 @@ static int activate(AVFilterContext *ctx) static const AVOption mix_options[] = { { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=2}, 2, INT_MAX, .flags = FLAGS }, { "weights", "set weight for each input", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1"}, 0, 0, .flags = FLAGS }, + { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = FLAGS }, { "duration", "how to determine end of stream", OFFSET(duration), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, .flags = FLAGS, "duration" }, { "longest", "Duration of longest input", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "duration" }, { "shortest", "Duration of shortest input", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "duration" }, @@ -336,6 +342,7 @@ static int tmix_filter_frame(AVFilterLink *inlink, AVFrame *in) static const AVOption tmix_options[] = { { "frames", "set number of successive frames to mix", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=3}, 2, 128, .flags = FLAGS }, { "weights", "set weight for each frame", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1 1"}, 0, 0, .flags = FLAGS }, + { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = FLAGS }, { NULL }, };