From patchwork Sat Sep 25 19:20:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 30573 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp2697440iob; Sat, 25 Sep 2021 12:20:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ5mI8LnLVLhxoQoz+zuCzD8Ns2qyvC117ySfnjrUS6Z6mWN7X2dVyvZT2ZbbwjvAm3u5p X-Received: by 2002:a50:fb8f:: with SMTP id e15mr12772846edq.162.1632597644789; Sat, 25 Sep 2021 12:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632597644; cv=none; d=google.com; s=arc-20160816; b=XeLH9L6QXDnOqQDPws5M/qO2MGo/T4ZMfeNhpb6x01G508Eejjlq4BL/PyHjz0UvFr 7jP+tQExV1LzX858rgPiQqTXJaeu2aR2499IxwYmQDC8Q4DACB6qWymZB3Y73gW3P3HH JRjSPpZ0illZThiBSMk24O49nkD6ANY8xf+capwmU6139BaBS7y7Cs+vMzHU07UkxLta j3P4feiayX7DHs1hGscz6Gh1CgQdA0wSyfPmW6KfthAEgd/iJeleo/4q/wQ3Nn3aYad2 EgkdBLIs9+bpPnx5tvIr/Qz4iw3WUQj1LZTowT2z4hHaUHENblvRqTB2Pm/FVjkzytBy m+bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=ph309RuPsfI6E0j0L/C4sCP43PC+azkZvqj9oC8DUtA=; b=yN6YHX2UEKugODeGaiHyAxdSz1mT2nhUrclfJKHWMjD8+0sKUfaIcACmRf1/ruRJLb 7jaJxduszZcA+Tn5gt8V2LnaQLaosHMEkPRjGKF+REha5rRrjRPoDBgYDtQ6L2xUbL8u eW9xKj+qkNHGJJGItLFxinn5/yjq6Oxyur+byJ0CcAe1qraiLOPzjDdiiBEmm5HVz/xJ qesxJkuwKN60RixHvsAFy0WXtnr0QkihMQ/DGLbwbRWYO82mt2U2eQBYrBguI70tSBL6 GUn6mVfCmr/2DhtiNi76vH+VxkcTWoKyRnEHvMK/djwc2iUJsHlhO+g8ZHCoii28riIL 7rSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=I2QWzuVB; 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 m22si3261303ejl.537.2021.09.25.12.20.43; Sat, 25 Sep 2021 12:20:44 -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=I2QWzuVB; 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 8FB9268A8DB; Sat, 25 Sep 2021 22:20:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 976B268A858 for ; Sat, 25 Sep 2021 22:20:32 +0300 (EEST) Received: by mail-wr1-f54.google.com with SMTP id t28so24540229wra.7 for ; Sat, 25 Sep 2021 12:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=npOrk34bXPXtHwiZkbPxXq3tdU6yjpj2647MKff7KI0=; b=I2QWzuVBkEYS85d/v24dkm59rjAEmuEnV6Grn6pv08+kBswj0QQ4oF4Or6LlUX2aBY X25Qj2mXIoYDGaT4fCu3OYab8KB+vpgRBhrEKEJD0wsrkLZ+AD/mr/Ik+O8nSYvG/aqK CBBKlGtjhlDvXWUJwplDQv3LiRZhjxNKoZcaj4R5cRFG6E9ICv8AeTILi/iC7qqf7qL9 OLXXVgHKN9WIiDQO1qWfQ1TbjYSL2jOVrnA+b31DE0zRlk40dH9Gq4yChGuMcMjAFEWc DO7cCvCHahLdhas7buWc4XOOPLWDRdgggmGAxL3VEH+ZBidZbZGbSdOrqdrrlb69ity2 weGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=npOrk34bXPXtHwiZkbPxXq3tdU6yjpj2647MKff7KI0=; b=L2O7SIVirgZ8mRBBkfonkdCDw4USeQ1FWgR8OyLRhdSYHuI2JTkP9M5YAXpiPOctam MsslgRiAy2NeWIY0lolMOYCbK/MnwnJAK0ZPKv9ahicFKcwpL4Bkgeo+aRCvecyUds41 oHEcxS2br32QdPvTbSPD9DsGMZS4W5kPEgAJWKhcbg3AAIm/VomHrOI+9WbDfLwQ1bOu Z0hYErg5sYyyIuRJjqlvAcqEze7Y3D8W7mlvVaVqqVA1nIbNmDcL1NbSknPh7miZVHHX nI+26l/rsET92uwaSzovPC+6Z4PWIzcl6+VNeiv0Z8WmFeXchgtfHT4Jk7Rh7GQeO9ig Q5lQ== X-Gm-Message-State: AOAM531y2TkSjpBLt/o4457FGMG7CCnN0syCUsezRCvUymK3Bn8Bh2vH nQhs/KFIXX9LPs0GH936BwWCAmCNS/k= X-Received: by 2002:a7b:c5c7:: with SMTP id n7mr8090439wmk.5.1632597631798; Sat, 25 Sep 2021 12:20:31 -0700 (PDT) Received: from localhost.localdomain ([95.168.121.82]) by smtp.gmail.com with ESMTPSA id y7sm9430649wrs.95.2021.09.25.12.20.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Sep 2021 12:20:31 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sat, 25 Sep 2021 21:20:20 +0200 Message-Id: <20210925192021.58523-1-onemda@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avfilter/vf_selectivecolor: refactor some repeating calculations 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: 0CJ/KoSmHeuL Signed-off-by: Paul B Mahol --- libavfilter/vf_selectivecolor.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libavfilter/vf_selectivecolor.c b/libavfilter/vf_selectivecolor.c index ebbba9157f..9d789a6d8b 100644 --- a/libavfilter/vf_selectivecolor.c +++ b/libavfilter/vf_selectivecolor.c @@ -328,6 +328,9 @@ static inline int selective_color_##nbits(AVFilterContext *ctx, ThreadData *td, const uint8_t goffset = s->rgba_map[G]; \ const uint8_t boffset = s->rgba_map[B]; \ const uint8_t aoffset = s->rgba_map[A]; \ + const int mid = 1<<(nbits-1); \ + const int max = (1<data[0] + y * dst_linesize); \ @@ -339,10 +342,10 @@ static inline int selective_color_##nbits(AVFilterContext *ctx, ThreadData *td, const int b = src[x + boffset]; \ const int min_color = FFMIN3(r, g, b); \ const int max_color = FFMAX3(r, g, b); \ - const int is_white = (r > 1<<(nbits-1) && g > 1<<(nbits-1) && b > 1<<(nbits-1)); \ + const int is_white = (r > mid && g > mid && b > mid); \ const int is_neutral = (r || g || b) && \ - (r != (1<nb_process_ranges; i++) { \