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 4803544E86 for ; Tue, 27 Dec 2022 23:20:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1AEDF68BCAA; Wed, 28 Dec 2022 01:18:43 +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 4312768BCC5 for ; Wed, 28 Dec 2022 01:18:34 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pkh.me; s=selector1; t=1672183099; 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=sXTFNx5WIocPLQUmoJvSZZ9xDxtR9zcSHc8EyBbqWY0=; b=RRLCbMorVMHI9FwktF4cloiej4/ct5uV0nlnMWH/FEnGkwgKNU8VYcxTRzscsHoz0+lIM4 EAdSYjd51c/5YXwbkuCb41FB12PFA5lEIR5WSHkfcFWbXic2jl4GnuCE0f6tkyfKkuLjMw CYpmkXwA1JFT9iy2FZuBAicNb1fFwWI= Received: from localhost (ssq0.pkh.me [local]) by ssq0.pkh.me (OpenSMTPD) with ESMTPA id 206d4a69; Tue, 27 Dec 2022 23:18:19 +0000 (UTC) From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Dec 2022 00:18:00 +0100 Message-Id: <20221227231814.2520181-19-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 18/32] avfilter/palettegen: rename local variable box_weight to weight 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: This variable is used only for the running weight (used to reach the target median). The places where we actually need the box weight are changed to use box->weight. --- libavfilter/vf_palettegen.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c index ad21882df3..b8db234fef 100644 --- a/libavfilter/vf_palettegen.c +++ b/libavfilter/vf_palettegen.c @@ -314,12 +314,10 @@ static AVFrame *get_palette_frame(AVFilterContext *ctx) while (box && box->len > 1) { int i; - uint64_t median, box_weight; - - box_weight = box->weight; + uint64_t median, weight; ff_dlog(ctx, "box #%02X [%6d..%-6d] (%6d) w:%-6"PRIu64" sort by %c (already sorted:%c) ", - box_id, box->start, box->start + box->len - 1, box->len, box_weight, + box_id, box->start, box->start + box->len - 1, box->len, box->weight, "rgb"[box->major_axis], box->sorted_by == box->major_axis ? 'y':'n'); /* sort the range by its major axis if it's not already sorted */ @@ -330,16 +328,16 @@ static AVFrame *get_palette_frame(AVFilterContext *ctx) } /* locate the median where to split */ - median = (box_weight + 1) >> 1; - box_weight = 0; + median = (box->weight + 1) >> 1; + weight = 0; /* if you have 2 boxes, the maximum is actually #0: you must have at * least 1 color on each side of the split, hence the -2 */ for (i = box->start; i < box->start + box->len - 2; i++) { - box_weight += s->refs[i]->count; - if (box_weight > median) + weight += s->refs[i]->count; + if (weight > median) break; } - ff_dlog(ctx, "split @ i=%-6d with w=%-6"PRIu64" (target=%6"PRIu64")\n", i, box_weight, median); + ff_dlog(ctx, "split @ i=%-6d with w=%-6"PRIu64" (target=%6"PRIu64")\n", i, weight, median); split_box(s, box, i); box_id = get_next_box_id_to_split(s); -- 2.39.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".