From patchwork Fri Oct 21 13:25:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 38867 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp772253pzb; Fri, 21 Oct 2022 06:26:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7QecLNNywzSddnicUrvtNyzJCBXklt8DMAJ242WxIFQq3VdWVUCm3nN93tjrurZQ8VgtC7 X-Received: by 2002:a17:907:2bda:b0:78d:9144:fb6d with SMTP id gv26-20020a1709072bda00b0078d9144fb6dmr15565397ejc.238.1666358767232; Fri, 21 Oct 2022 06:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666358767; cv=none; d=google.com; s=arc-20160816; b=ZDiYyKrCuOlvIpY0u22Ghu92L03136KmMKY0u3yFwtQMht+fPzcdyFoPdM+Bq/2WcJ 20C4yntaGT3b1je4s0cBUbvGd6T0tneprCQdUj1VXkwGfERY8Yg61E33MWq3Vx4ziEzp 4SUX3SvQALn8xr1UZCWDwurNr3F56LY8T+B5BRnaU+BRKD5gHMEGw5nuTNTJ3xA4e2WD 1kYzTVXx+r3Q6tAmfXyTqENnKfCdErFTVL26PnY0uj1Y5qRaL0/kMMG8+37vhcSGtuNk RzFManmsuZ7PugAEfRqBWHg32xWl5dped0U5mBdg4Sk7tY7nRVVFwcSu2cAmZMYJL/MW +7kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to; bh=iVI50oZgnYt2u5EmtUXQOFiziB1D3c/Izu/lhm/RdH4=; b=s89lkO7Um8lq4jBdbGrvMCPCIeCUnrpLLrOGsP6Kc/Sb3xufF+ykE2qncWmji/kXc0 LIgWGR8nOHkEl8DI1gg65Ve8GrCZm+njtHczvbFIgIVk05fQX/4hMzCaDSzXAao3HBXl d4jOOSbdP39EHoijHbdS5tfZ/HodJHaw/Du8gGRNSohMqDA8tl+Sth4i81Oyo7zU1CTJ HrokFpgVnjiw3IzvPE012ue8+DO+RSI4X/Ual7nU8o0vQWSvUDLvuoMJDEedeKJJNKK0 hoF4UGJUi0xoE8Xh1W7RMJjF4UVgj24bKt7dffXBaKkGWg1Fv32JvqHkKpcWLddkizdK k7Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=P6AMAJUJ; 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 d27-20020a056402401b00b0046099941bbdsi4382107eda.309.2022.10.21.06.26.06; Fri, 21 Oct 2022 06:26:07 -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=20210112 header.b=P6AMAJUJ; 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 7CA0C68BE8F; Fri, 21 Oct 2022 16:26:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vk1-f178.google.com (mail-vk1-f178.google.com [209.85.221.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4586E68BDFA for ; Fri, 21 Oct 2022 16:25:56 +0300 (EEST) Received: by mail-vk1-f178.google.com with SMTP id y129so1434212vkg.8 for ; Fri, 21 Oct 2022 06:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=c+aW2QxCM/TBtef2e0+HNKWxCuDa4GwWsKvjcLHseZw=; b=P6AMAJUJdhtS32rdLa88P2YSzjDu7UqvnV03p/SD3rwCe1MBNuwwg3JgRUEFuk4NGh Jw4fJ5DZzWMI58VNS2Y7AJhoviSrYNSHz3c/vvzPEYgNPRKLblel6aknmwXYg8adarsR zWMUqINlr06fWd/968KnOg88113Q1XfPwB6lwxkaAH0Oz51GasJTLLcdwz1noqaPWbeg x2twFYw135V+CJ61j4hZyA/CRPNHWQitvr3RQ54CiIQ5wZ86C2UuNF+Fnz30/oErv0/i /7yYXrzY4DFaiGT31x9r4HGiEplGgukdzA7lenbexDB+VjBpk403edc567OFmwNZaO/J GNNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=c+aW2QxCM/TBtef2e0+HNKWxCuDa4GwWsKvjcLHseZw=; b=CsPoYtzyWezrhblRbzxRIBx/VKCkscWvljXGpVYPR93x5nc42Y3uuemIgwR0dcsfNb 0fiZk6zIv8plo6Ztlh7jGSIZEpm3gqxIxpaqwYY6jxbmLxYpppLCCGSo3DYwt+/tDDft dvROG0T1dPFzozwq+nONhP5VBs2+XEOuNJCV9KDwcMSy0lpS+1Qz1Ccu0CBGSBuAf2zw D99FLs44drmXTJ0yQpxTeuUwZO1YaS5BsQolqAVabrbT3oQbmOMmSV59baGO4moXfuW/ DwYi2m4vnAHDi5LDyU03ns9G9EPKxvqp/IEFKz7QoHv9izSarTnYH5fp0mlAH/7hX9YM SKbg== X-Gm-Message-State: ACrzQf2yb6bK6Ds7nXAybpvxcjlQjQitoLWZJc6dP/cCeauLhuiJZVhi ruwSkHalWwh3FpCyiriR7GeVt4j+TXnIikfPJv+kQM6S X-Received: by 2002:a1f:784b:0:b0:3ae:f11f:9438 with SMTP id t72-20020a1f784b000000b003aef11f9438mr12142973vkc.39.1666358754492; Fri, 21 Oct 2022 06:25:54 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:612c:612:b0:314:ac6a:1eb7 with HTTP; Fri, 21 Oct 2022 06:25:52 -0700 (PDT) From: Paul B Mahol Date: Fri, 21 Oct 2022 15:25:52 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avfilter/vf_threshold: fix handling of zero threshold X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PFwa7riBV9vy Patch attached. From 1b4cc348d05677aa844a8c553d9242812dc6890d Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 20 Oct 2022 19:38:55 +0200 Subject: [PATCH] avfilter/vf_threshold: fix handling of zero threshold Signed-off-by: Paul B Mahol --- libavfilter/vf_threshold_init.h | 4 ++-- libavfilter/x86/vf_threshold.asm | 23 ++++++++--------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/libavfilter/vf_threshold_init.h b/libavfilter/vf_threshold_init.h index 7d160ddbb9..64a0a861ba 100644 --- a/libavfilter/vf_threshold_init.h +++ b/libavfilter/vf_threshold_init.h @@ -38,7 +38,7 @@ static void threshold8(const uint8_t *in, const uint8_t *threshold, { for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) - out[x] = in[x] < threshold[x] ? min[x] : max[x]; + out[x] = in[x] <= threshold[x] ? min[x] : max[x]; in += ilinesize; threshold += tlinesize; @@ -64,7 +64,7 @@ static void threshold16(const uint8_t *iin, const uint8_t *tthreshold, for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) - out[x] = in[x] < threshold[x] ? min[x] : max[x]; + out[x] = in[x] <= threshold[x] ? min[x] : max[x]; in += ilinesize / 2; threshold += tlinesize / 2; diff --git a/libavfilter/x86/vf_threshold.asm b/libavfilter/x86/vf_threshold.asm index 098069b083..8977a586c0 100644 --- a/libavfilter/x86/vf_threshold.asm +++ b/libavfilter/x86/vf_threshold.asm @@ -22,15 +22,10 @@ %include "libavutil/x86/x86util.asm" -SECTION_RODATA - -pb_128: times 16 db 128 -pb_128_0 : times 8 db 0, 128 - SECTION .text -;%1 depth (8 or 16) ; %2 b or w ; %3 constant -%macro THRESHOLD 3 +;%1 depth (8 or 16) ; %2 b or w +%macro THRESHOLD 2 %if ARCH_X86_64 cglobal threshold%1, 10, 13, 5, in, threshold, min, max, out, ilinesize, tlinesize, flinesize, slinesize, olinesize, w, h, x mov wd, dword wm @@ -45,7 +40,6 @@ cglobal threshold%1, 5, 7, 5, in, threshold, min, max, out, w, x %define olinesizeq r9mp %define hd r11mp %endif - VBROADCASTI128 m4, [%3] %if %1 == 16 add wq, wq ; w *= 2 (16 bits instead of 8) %endif @@ -63,9 +57,8 @@ cglobal threshold%1, 5, 7, 5, in, threshold, min, max, out, w, x movu m0, [thresholdq + xq] movu m2, [minq + xq] movu m3, [maxq + xq] - pxor m0, m4 - pxor m1, m4 - pcmpgt%2 m0, m1 + pminu%2 m0, m1 + pcmpeq%2 m0, m1 PBLENDVB m3, m2, m0 movu [outq + xq], m3 add xq, mmsize @@ -82,11 +75,11 @@ RET %endmacro INIT_XMM sse4 -THRESHOLD 8, b, pb_128 -THRESHOLD 16, w, pb_128_0 +THRESHOLD 8, b +THRESHOLD 16, w %if HAVE_AVX2_EXTERNAL INIT_YMM avx2 -THRESHOLD 8, b, pb_128 -THRESHOLD 16, w, pb_128_0 +THRESHOLD 8, b +THRESHOLD 16, w %endif -- 2.37.2