From patchwork Sat Nov 5 15:26:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= X-Patchwork-Id: 39167 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp1085169pzb; Sat, 5 Nov 2022 08:27:09 -0700 (PDT) X-Google-Smtp-Source: AA0mqf6b0vYt+/EKAiJBs+lz6Otn7xvEOWx1YdZ/qNC02r6l793yGwtjQ26hT+2bjDt7nWGuT6T0 X-Received: by 2002:a17:907:7faa:b0:7ad:e8e4:6ac7 with SMTP id qk42-20020a1709077faa00b007ade8e46ac7mr290087ejc.21.1667662029609; Sat, 05 Nov 2022 08:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667662029; cv=none; d=google.com; s=arc-20160816; b=z4l+/+gCLF8nXuHEpyLYCDiChlSlhWLYQS5rtgw27mSrVMJhm0f+vCQscQLzkg2Im/ AyIwd/WVuC6GbC+uCRgKr/IxkKQuEbi8VKvFD1IdkA1qcqZjP+TpbUiMn8EOb2MXJ0bI d15pplqyVhOdnIl+TCzYtl3upiWYD6IO6+JLmLeHmO57Vxy3RZRAqH98yrnQV9qT1D/q sRLGNm6ExjPCaeV+/1NC8hXyNemT8qLfGOT4lYWIIRa39bV48O+rEZb9L/fJMFRW98Dr BiZOiGbt0h3LvGYCZxdm/302rfrl66Mrdesqu8pDWQTypg3Smil74Aii37/71Y7us8s6 3Bgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=F7I5ONgNm4pIBug/0ubSf4W6y8gnOS9ywDspPsODoyk=; b=Y1cqU+Ob78FDL20DY7up9H4rNIROV3BWWQWzo3q4JKMMea8Wi7purYeWzKiUZPxV3/ KkLINuuHzn29vTqAplkdtCD10xQNBhhBpsCHzYik8QqK3MacVe7dR5Atj6gRAh1Yiz+B 6wrzoJbsecmCWgQFYY+48G0HvqpN74ojOKA/wAA4xy2uXxGnxrPGfBtXvFH5NNpm6KOK Ag6X6j4XCuI+UUM/JfkuQ52DXNrhg9vt+ZNWi6gqGyPRMrcC+CmSYaRMIIW93uqE94xI sMcnExy7/D2QlAlIImAM/J73Lm8ed31bmoMyJFNBVI/WHUpRzUOHZMHc4wgeUt1oRJOM OccQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@pkh.me header.s=selector1 header.b=BJi8Lk3i; 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=NONE dis=NONE) header.from=pkh.me Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hz5-20020a1709072ce500b007878c9d73a2si2542979ejc.426.2022.11.05.08.27.09; Sat, 05 Nov 2022 08:27:09 -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=@pkh.me header.s=selector1 header.b=BJi8Lk3i; 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=NONE dis=NONE) header.from=pkh.me Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 90B0168B1F1; Sat, 5 Nov 2022 17:26:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ssq0.pkh.me (laubervilliers-656-1-228-164.w92-154.abo.wanadoo.fr [92.154.28.164]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E8B3368B1F1 for ; Sat, 5 Nov 2022 17:26:30 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pkh.me; s=selector1; t=1667661980; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h9pdBe3KUbkAZXh5/Hn4OcGopvr2f2OLyDeT3XJvQE4=; b=BJi8Lk3ivhilGoW9thsxFQU5k029gZlHfuhdAh6ZRtXPYwc6DGwqDqmlCyDNIi/1N9zQdG 30Z1WMXpD/xH6aW0uOphxleoUIrt85mpMqTe2xcENXBOEzDkOYOOIluDfPzGWTq5yxnRSi ZxuNNkkdx6ZUAfZEvcbcnhCbbNpjKiQ= Received: from localhost (ssq0.pkh.me [local]) by ssq0.pkh.me (OpenSMTPD) with ESMTPA id ec590acb; Sat, 5 Nov 2022 15:26:20 +0000 (UTC) From: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Nov 2022 16:26:05 +0100 Message-Id: <20221105152617.1809282-4-u@pkh.me> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221105152617.1809282-1-u@pkh.me> References: <20221105152617.1809282-1-u@pkh.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/15] avfilter/palette{use, gen}: simplify a few alpha masks 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 Cc: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6ivnAazgyGUv --- libavfilter/vf_paletteuse.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c index cb18329bb7..f9d8a1cdfc 100644 --- a/libavfilter/vf_paletteuse.c +++ b/libavfilter/vf_paletteuse.c @@ -156,7 +156,7 @@ static int query_formats(AVFilterContext *ctx) static av_always_inline uint32_t dither_color(uint32_t px, int er, int eg, int eb, int scale, int shift) { - return px >> 24 << 24 + return (px & 0xff000000) | av_clip_uint8((px >> 16 & 0xff) + ((er * scale) / (1<> 8 & 0xff) + ((eg * scale) / (1<> 24 >= trans_thresh) { // ignore transparent entry const uint8_t palargb[] = { - palette[i]>>24 & 0xff, + palette[i]>>24, palette[i]>>16 & 0xff, palette[i]>> 8 & 0xff, palette[i] & 0xff, @@ -372,7 +372,7 @@ static av_always_inline int get_dst_color_err(PaletteUseContext *s, uint32_t c, int *er, int *eg, int *eb, const enum color_search_method search_method) { - const uint8_t a = c >> 24 & 0xff; + const uint8_t a = c >> 24; const uint8_t r = c >> 16 & 0xff; const uint8_t g = c >> 8 & 0xff; const uint8_t b = c & 0xff; @@ -411,7 +411,7 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram if (dither == DITHERING_BAYER) { const int d = s->ordered_dither[(y & 7)<<3 | (x & 7)]; - const uint8_t a8 = src[x] >> 24 & 0xff; + const uint8_t a8 = src[x] >> 24; const uint8_t r8 = src[x] >> 16 & 0xff; const uint8_t g8 = src[x] >> 8 & 0xff; const uint8_t b8 = src[x] & 0xff; @@ -483,7 +483,7 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram if ( down) src[src_linesize + x ] = dither_color(src[src_linesize + x ], er, eg, eb, 1, 2); } else { - const uint8_t a = src[x] >> 24 & 0xff; + const uint8_t a = src[x] >> 24; const uint8_t r = src[x] >> 16 & 0xff; const uint8_t g = src[x] >> 8 & 0xff; const uint8_t b = src[x] & 0xff; @@ -630,7 +630,7 @@ static int get_next_color(const uint8_t *color_used, const uint32_t *palette, for (i = 0; i < AVPALETTE_COUNT; i++) { const uint32_t c = palette[i]; - const uint8_t a = c >> 24 & 0xff; + const uint8_t a = c >> 24; const uint8_t r = c >> 16 & 0xff; const uint8_t g = c >> 8 & 0xff; const uint8_t b = c & 0xff; @@ -700,7 +700,7 @@ static int colormap_insert(struct color_node *map, node = &map[cur_id]; node->split = component; node->palette_id = pal_id; - node->val[0] = c>>24 & 0xff; + node->val[0] = c>>24; node->val[1] = c>>16 & 0xff; node->val[2] = c>> 8 & 0xff; node->val[3] = c & 0xff;