From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 5EB9344E3D for ; Tue, 27 Dec 2022 23:21:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 89AC068BD64; Wed, 28 Dec 2022 01:18:51 +0200 (EET) 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 C7E5A68BC9D for ; Wed, 28 Dec 2022 01:18:35 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pkh.me; s=selector1; t=1672183100; 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=ou4MJHzF7K8lH+/EeTZULSIRbyDezN+OcHzUTOywVM0=; b=Wjxb9v45eg8pJAfYD4OPU5r00ts/dYIjrewxl92zjTiZBnn+x7BNp+9h4aKVvOUd4Rew5k TSs7R7rvhQ+Ek2vR7pdJUOSJ/nBaFHkdSXLUxiU4x7ayyamJp5aBHCXW47emIniVISK0AR 0OiTtfU70wHB3MUD0oZ1z1u8ePlhptY= Received: from localhost (ssq0.pkh.me [local]) by ssq0.pkh.me (OpenSMTPD) with ESMTPA id 78164afd; Tue, 27 Dec 2022 23:18:20 +0000 (UTC) From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Dec 2022 00:18:08 +0100 Message-Id: <20221227231814.2520181-27-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 26/32] avfilter/palettegen: use lowbias32 for color hashing 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?q?Cl=C3=A9ment=20B=C5=93sch?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 1.12x faster overall in palettegen on my machine. --- libavfilter/vf_palettegen.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c index 6301cf6358..97e12f7274 100644 --- a/libavfilter/vf_palettegen.c +++ b/libavfilter/vf_palettegen.c @@ -63,8 +63,7 @@ enum { NB_STATS_MODE }; -#define NBITS 5 -#define HIST_SIZE (1<<(3*NBITS)) +#define HIST_SIZE (1<<15) typedef struct PaletteGenContext { const AVClass *class; @@ -387,27 +386,13 @@ static AVFrame *get_palette_frame(AVFilterContext *ctx) return out; } -/** - * Hashing function for the color. - * It keeps the NBITS least significant bit of each component to make it - * "random" even if the scene doesn't have much different colors. - */ -static inline unsigned color_hash(uint32_t color) -{ - const uint8_t r = color >> 16 & ((1<> 8 & ((1<