From patchwork Tue Dec 27 23:17:45 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: 39770 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3761068pzb; Tue, 27 Dec 2022 15:18:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXtnz3nFDdzb/tJE9VMnWjm/9nW1UBLiZgdI6gdtAtfhlWDBXaVQkUDQYcjPMjP2WFZ3AhdJ X-Received: by 2002:a05:6402:206c:b0:47c:30aa:ae0e with SMTP id bd12-20020a056402206c00b0047c30aaae0emr19271351edb.11.1672183137215; Tue, 27 Dec 2022 15:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672183137; cv=none; d=google.com; s=arc-20160816; b=HzxfoVgnEV0gRjyLWbUGNFHYKHLpGKC8zctk2FUgBO889sJuiL97BeXtPYmvFQ/S6l Ea9c23qqMq1qjiSG7UkkdY5WW91kiBKrUTBBvZJB3fRm8pBbiaYW8GaJINYrw1LFWZRP RkATX+ucGChtBDSmRjgWQCuOejjAQYgjxij6QbviWC0qoni02Yali9NiPzl8NO1B9o3m S+XtA2HDC/cyNYVt5OgbkujhFcXb+IbE7gEsbaa+NBPNSs7A4OAQfWSsaeTQOkvaFbtE JjjErgn2vBAb2LruODFrfmM4p2mp8lsBato/DzroN18HonLMbamEnwz35xZUfoE31bul MwqQ== 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=Lh9uFblgkeBHytamrKunLUTAy3NnGtH+jqBfgjrAVtk=; b=eZVSvGIvUPXocdYLOGXX9dxhJZXPsGPnqd0NnH/MY9zfnuZvsorBTDyKFKOW7a99E5 FdPgPPP//CIyB5J8hqF0Q+5M7aqcSaZ1t9WC9HjCAi4YJCOUDLuNKrS4+kP798TDcEwY SftjDrFmbMOokJGEPrluQqIFXJvNudJ6XG+Wyha2PpSj1sl2pufbp9uTt6HaynAcTKJb P7zLfIA87ma1Dd32DdhGHh0TkQaOMurDZNNgl5qcS2m8+a+zCptu98zICwCM70Q/0kA+ QZ+JjHGmnkKyyvEKdzNiW9HQ5deiTSgFC8AaCWylFUmVCRr/HOxdZQKN6MmdgzEElSgk hRMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@pkh.me header.s=selector1 header.b="A2f/SBcj"; 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 hz2-20020a1709072ce200b007c0db556798si12714408ejc.994.2022.12.27.15.18.56; Tue, 27 Dec 2022 15:18:57 -0800 (PST) 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="A2f/SBcj"; 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 F1C7568BC88; Wed, 28 Dec 2022 01:18:32 +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 8706268BC71 for ; Wed, 28 Dec 2022 01:18:26 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pkh.me; s=selector1; t=1672183096; 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=Lt3jaQNk+00moqJ7nySfGL74CJdayCR4kxvNEsJL4+M=; b=A2f/SBcj2JIPmfVXOGjDEMU4pDna8mv2j1iGCo8Ir8QvS5i7eEPZOaj+2dIa1mecBmIB2s 7A/+M5n43V4mPYFSTJSZLP2ZViHFljtXrxJjtbIWYV9QXxmtJ9e6O3H7ywIq9XZ+S2LYfq 7zurgUoIvIPGYIMMBEVnUWuOATke5g8= Received: from localhost (ssq0.pkh.me [local]) by ssq0.pkh.me (OpenSMTPD) with ESMTPA id c7d52716; Tue, 27 Dec 2022 23:18:16 +0000 (UTC) From: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Dec 2022 00:17:45 +0100 Message-Id: <20221227231814.2520181-4-u@pkh.me> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221227231814.2520181-1-u@pkh.me> References: <20221105152617.1809282-1-u@pkh.me> <20221227231814.2520181-1-u@pkh.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 03/32] avfilter/palette{gen, use}: 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: cK1Lm8GodenI --- 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;