From patchwork Mon Jul 31 11:32:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Darnley X-Patchwork-Id: 4529 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.85 with SMTP id 82csp2301533vsb; Mon, 31 Jul 2017 04:38:25 -0700 (PDT) X-Received: by 10.223.155.222 with SMTP id e30mr11400573wrc.55.1501501105138; Mon, 31 Jul 2017 04:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501501105; cv=none; d=google.com; s=arc-20160816; b=syGgYqbYxrkeQlLbkPl+YuFWdorYQsIx3mzk6bg3LbiXS3n20ioiK0uINRfddXXZaB 4507CYmQPQmkHy/TwSzJuVbkxAFVvqwsToExCYnk3i8tKrM0QgF2r+8NTfAMV0bJUkVe zRLILgYD7AwCWo+6Ux1ljjxfDWS2e1tA+uXVbQJrKcPBWBaR5ubPCIxU2vQQ2cin3FeV 5Q0jcR/3h00StFRy704pU4Gt3yxWMwMEfoAIEwcWH4m9KWMguHl56P/NTqL2DK8sz3Q/ Q/BQO/3qid/Hcwzhau2xB1/x0D6fnDq0rCNjE4f5WUxyRxTU2urLe5H2z4J5JLd74TpM 96GA== 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:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=nV9Qmwg7QZPTZ7dDAa/4KfHMBJhGQu36JJExZTyPfiE=; b=SSt1POvg6Bj+SS4FppRGq20N6RMI/Ir+DZAOqVa1QKZEJgl4FqRYqrRWwZaWLCUffj syGWMW4Tbz2e4XkqTLB/81ttXglyJZSZoGDsd9by7mdZpFdUvHSj5DiwM6mE0KTfwdOA EL/ISsC8UR4C1XdP8+LPrReRrOyF2LGa506j+ulu5de+c5sKiBpzTFAz5CmF0+MEM7qG nK+YoKkpIHNabl4v8w0UA9wGglGpQpzjJyIcq4QklbfMKW2ePUzS0mdah32qA+r81khH 0sFrEisGX0AE1FV8OUwjtORM1ENro+jM5npWwSsmUFNENQKTBbJqEIKBaDpP0eZfLsSx DsOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ob-encoder-com.20150623.gappssmtp.com header.b=aVb1jc5j; 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 u18si25680515wra.269.2017.07.31.04.38.24; Mon, 31 Jul 2017 04:38:25 -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=@ob-encoder-com.20150623.gappssmtp.com header.b=aVb1jc5j; 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 BFDBA68A1AF; Mon, 31 Jul 2017 14:38:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C012068A1AA for ; Mon, 31 Jul 2017 14:38:11 +0300 (EEST) Received: by mail-wm0-f65.google.com with SMTP id y206so12211563wmd.5 for ; Mon, 31 Jul 2017 04:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ob-encoder-com.20150623.gappssmtp.com; s=20150623; h=sender:from:to:subject:date:message-id; bh=lGgA1PNGiTiyA2nBPBcy6JRaneoC7QeaXlDVNSNFdeY=; b=aVb1jc5jWYod096ct/jjpESwMXLmRr8pardxiS8vG2HLKOg//C572+RFQA65p8gBNU NAXaCpG7Ngph8Ws+G1/lzCcgu23TzweYxFNjyJ5pWugzLGKrcoxTNOtrIHcz3UAPQg0Z HI0n/b/2DXMQiiex5Z47yoUQKA/RVCsiRWXsSZ1RCjM8zx7GTbLeR1CPzkVgE0sfnEHD J64BFwSumq1HfLvQJMrIsbMAD+M3Agfud5PTJrWwArgt3KjojsrNzIedUH34c/BvUdR3 Ht7Z/15RFmPOFSWWQ3LSdvh8mrHI5CvagivfGKyM6dO+lNn6LjgDIH9PcXWM6Ec1F4C9 lZJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=lGgA1PNGiTiyA2nBPBcy6JRaneoC7QeaXlDVNSNFdeY=; b=TRzUDUqnHFAR442nM/ViFjY7YDfQNlw9iCFetMocKSUoNfUOM/yfImPtFy7vw9snz4 suFUUpA0IOs4uLwWLW0p0h5l6Ch1isnwEJ/lRSYGkM2n8CUhKnBMS6GUEBtThqDg6yBl iwwmRv6LGBZThSpqTBTp5D1es9hTCkMWj2gxBgXZATSPDHXKMV8xCFmZRgx/sXtLl2B8 lQOS522IAh4hUjlpI57FjRPLueaoB7weTOg65WJEp72fLEgHUnNsDsSovpJHajAdiKBK AeMUI8lVpkTWUyL1fELT3h+HQUHchGTE0NBLIFgyBqmPAyjRtPIM3WKTMpJLqywklWgT bhng== X-Gm-Message-State: AIVw111Kd63u13Z6sL3YLNnewXsNgPDg6nsWSFVbiKzJWi34+zQIlT3o NbS8H7qxsjoxhWj6QyI= X-Received: by 10.28.208.202 with SMTP id h193mr10465933wmg.101.1501500781908; Mon, 31 Jul 2017 04:33:01 -0700 (PDT) Received: from Highwind.systemlords.lan (d51A44418.access.telenet.be. [81.164.68.24]) by smtp.gmail.com with ESMTPSA id l8sm10328711wmd.15.2017.07.31.04.33.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Jul 2017 04:33:01 -0700 (PDT) From: James Darnley To: FFmpeg development discussions and patches Date: Mon, 31 Jul 2017 13:32:55 +0200 Message-Id: <20170731113255.6129-1-jdarnley@obe.tv> X-Mailer: git-send-email 2.13.3 Subject: [FFmpeg-devel] [PATCH] avfilter: add differencemax mode to the blend video filter 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" --- Changelog | 1 + doc/filters.texi | 1 + libavfilter/blend.h | 1 + libavfilter/vf_blend.c | 4 ++++ 4 files changed, 7 insertions(+) diff --git a/Changelog b/Changelog index 187ae7950a..894776d63a 100644 --- a/Changelog +++ b/Changelog @@ -29,6 +29,7 @@ version : - limiter video filter - libvmaf video filter - Dolby E decoder and SMPTE 337M demuxer +- blend video filter gets differencemax mode version 3.3: - CrystalHD decoder moved to new decode API diff --git a/doc/filters.texi b/doc/filters.texi index 4c1ef0f485..149be70245 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -4859,6 +4859,7 @@ Available values for component modes are: @item darken @item difference @item difference128 +@item differencemax @item divide @item dodge @item freeze diff --git a/libavfilter/blend.h b/libavfilter/blend.h index 0f27b4d29d..97d2145eb7 100644 --- a/libavfilter/blend.h +++ b/libavfilter/blend.h @@ -34,6 +34,7 @@ enum BlendMode { BLEND_DARKEN, BLEND_DIFFERENCE, BLEND_DIFFERENCE128, + BLEND_DIFFERENCEMAX, BLEND_DIVIDE, BLEND_DODGE, BLEND_EXCLUSION, diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c index 9bde3b22a1..efbb936961 100644 --- a/libavfilter/vf_blend.c +++ b/libavfilter/vf_blend.c @@ -73,6 +73,7 @@ typedef struct ThreadData { { "darken", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DARKEN}, 0, 0, FLAGS, "mode" },\ { "difference", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIFFERENCE}, 0, 0, FLAGS, "mode" },\ { "difference128", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIFFERENCE128}, 0, 0, FLAGS, "mode" },\ + { "differencemax", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIFFERENCEMAX}, 0, 0, FLAGS, "mode" },\ { "divide", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIVIDE}, 0, 0, FLAGS, "mode" },\ { "dodge", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DODGE}, 0, 0, FLAGS, "mode" },\ { "exclusion", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXCLUSION}, 0, 0, FLAGS, "mode" },\ @@ -245,6 +246,7 @@ DEFINE_BLEND8(negation, 255 - FFABS(255 - A - B)) DEFINE_BLEND8(extremity, FFABS(255 - A - B)) DEFINE_BLEND8(difference, FFABS(A - B)) DEFINE_BLEND8(difference128, av_clip_uint8(128 + A - B)) +DEFINE_BLEND8(differencemax, (A < B ? 0 : B > A ? 255 : 128)) DEFINE_BLEND8(screen, SCREEN(1, A, B)) DEFINE_BLEND8(overlay, (A < 128) ? MULTIPLY(2, A, B) : SCREEN(2, A, B)) DEFINE_BLEND8(hardlight, (B < 128) ? MULTIPLY(2, B, A) : SCREEN(2, B, A)) @@ -288,6 +290,7 @@ DEFINE_BLEND16(negation, 65535 - FFABS(65535 - A - B)) DEFINE_BLEND16(extremity, FFABS(65535 - A - B)) DEFINE_BLEND16(difference, FFABS(A - B)) DEFINE_BLEND16(difference128, av_clip_uint16(32768 + A - B)) +DEFINE_BLEND16(differencemax, (A < B ? 0 : B > A ? 65535 : 32768)) DEFINE_BLEND16(screen, SCREEN(1, A, B)) DEFINE_BLEND16(overlay, (A < 32768) ? MULTIPLY(2, A, B) : SCREEN(2, A, B)) DEFINE_BLEND16(hardlight, (B < 32768) ? MULTIPLY(2, B, A) : SCREEN(2, B, A)) @@ -457,6 +460,7 @@ void ff_blend_init(FilterParams *param, int is_16bit) case BLEND_DARKEN: param->blend = is_16bit ? blend_darken_16bit : blend_darken_8bit; break; case BLEND_DIFFERENCE: param->blend = is_16bit ? blend_difference_16bit : blend_difference_8bit; break; case BLEND_DIFFERENCE128: param->blend = is_16bit ? blend_difference128_16bit: blend_difference128_8bit; break; + case BLEND_DIFFERENCEMAX: param->blend = is_16bit ? blend_differencemax_16bit: blend_differencemax_8bit; break; case BLEND_DIVIDE: param->blend = is_16bit ? blend_divide_16bit : blend_divide_8bit; break; case BLEND_DODGE: param->blend = is_16bit ? blend_dodge_16bit : blend_dodge_8bit; break; case BLEND_EXCLUSION: param->blend = is_16bit ? blend_exclusion_16bit : blend_exclusion_8bit; break;