From patchwork Tue Dec 27 23:18:00 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: 39782 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3761868pzb; Tue, 27 Dec 2022 15:20:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXvXgRR9RsPVeRrF0CIM2gX2ik3ixQfv74PoMYQHBUYtfkdsrnBL6A42OdVVup4dJYhEsZxo X-Received: by 2002:a17:907:6d98:b0:7c1:12b0:7d5d with SMTP id sb24-20020a1709076d9800b007c112b07d5dmr25281813ejc.4.1672183240224; Tue, 27 Dec 2022 15:20:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672183240; cv=none; d=google.com; s=arc-20160816; b=w9QqktazohZ6e4kob3CImvYS8f8ZAGgi40MAygiRwtj3dPyk/xv0iJeeDvbUU7sPBt J0X30/6TdxGa7qms/V8wx5UxcD+hKPtpzAY/0hVcxieg5GaclxdzKf5ow9Y5IkpshkGy VVUca2DC6CFsEsUJNDRwi4l0HOnFPXWcf/Sb6J9PUK5iGHQpObxNe8+WSjIpTrxP6jGE 1De62XxIfiFd3Bu1puS0E+RNMmbZkobndUEWndP+WWSAbv2oJzptCnn8GvFnVuWfW87v 2KcFEvpSMHK6YwDXYaTB2CcxKCgI7dB9SYOJKcO4gMqFe8kf+mG4eK/GVcoAFEwydh8u 6p+g== 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=zoT5J2CY/PTMbhSD38h4W8dOl/3scdqi7Be48tRNJRY=; b=AQMng3BoFp/70jSD2Je6hTx/l3b6W5MY3o04XWjqxl7aAvX/lTmJ8c9cLY/KyV9/EC EX/m0hE5n4OytlgGrRfnIOwTZ7U4Zdjl5l6VVROPNNuTRQ8aFBSCraCtuEvh44N1tUfn jL+e5V5VeVtFtuEq/3P11TcS6GiBj/zpOx8pI/m3TFLZyTFC6Y0w/JKiNtUsv31kgO76 gLEFrobHFaYC+7txqmdka6ZEMiZx+UjXMxcq+Fxf08Daz+3b7a8u3em8XzJA4hannnWB q4fpUb6W/1SaiiRLo6Gq9/2u+CjvZL2Uk+mHqzyEcWilxUSHqMvwGhSNojtkuVcgyaP/ Qm6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@pkh.me header.s=selector1 header.b=RRLCbMor; 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 l2-20020a170906a40200b0082ad5e78975si9694589ejz.803.2022.12.27.15.20.39; Tue, 27 Dec 2022 15:20:40 -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=RRLCbMor; 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 47AA368BCAB; Wed, 28 Dec 2022 01:18:43 +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 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?b?Q2zDqW1lbnQgQsWTc2No?= 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?b?Q2zDqW1lbnQgQsWTc2No?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: NOmun1Eqv3gQ 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);