From patchwork Sat Nov 5 15:26:16 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: 39178 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a05:6a11:561f:b0:33d:fc04:f431 with SMTP id rr31csp1406317pxb; Sat, 5 Nov 2022 08:28:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5FtYxr3kLCLYXLVE057AoKiRFL2YFuSNaXVxx1MSm2huQFos1grAGi1fgiNI8P9cKZf72e X-Received: by 2002:a17:907:7e9b:b0:7ad:c003:78a3 with SMTP id qb27-20020a1709077e9b00b007adc00378a3mr35587366ejc.342.1667662119611; Sat, 05 Nov 2022 08:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667662119; cv=none; d=google.com; s=arc-20160816; b=XOQ0Jv/sz3FQMDa54e+ciEmwVK44Z7bPOW+K2jD9xWU/NZAl9I88+gQi57aEKqztVJ zJD/mEjpO6XLcya8p6b8GHVc0VlHlpUn8secsE//pvKS3emsBSWY+haqVA0vg9uQGgg9 sN4t4buV+Tdja/C+L74abJC6s1yni53Nf+9OjA+bIFtm5JP/MRWqPFhIVlwNjVEejEc+ lPJyqL1Si6iQz0Myq3AbPAdDQMiFsnheGsBoj5Onh91mw1vLU28Hei4bHsAKDQ+b/nO4 lArlB3BC6Hldj/3U19CAhJDEk0s3NzOqe5FSWAJZDeqH8ScphyKQ2aJth6lxrBZOLo2a Q5NA== 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=S7YfoCMtWV8o/H4zW+ecBwOFzjSR/ZJIjx4hz/vcJ4I=; b=ew+sJK6l1r00/2j5nSSJ1qcFleVND0sZ8SWK3MXTAxG/1LWlhdCWNoyrVBifZR5QZP mCD1La4HM/iAvrHrAxGP8Ju4yMEL29kBpR6OUbn7fEkT2JIaIbKQU7FGtx6V9TEbOXag P6h2ORQnC3J4A5v7QtNK+CEu+bFqrykWwZw7Rgup3Mxz/n7jtqxFTs17gxJda1m0pAOc kY3Z/KNcm3e6va4WKzHQdnAvA+n5VkBiFUSCEnNneX+aOvyUfp1d3z//OPOY9kniXkTG V/iQfE9nMBQQKPvbCB2C6HboKc8iSTIsdoIN2prSjUNSmA4gz9aqYUg6CKQV3ZsYnmOH 5e9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@pkh.me header.s=selector1 header.b=YL9HY+oq; 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-20020a1709072ce500b0078c9dd279b6si2524646ejc.345.2022.11.05.08.28.39; Sat, 05 Nov 2022 08:28:39 -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=YL9HY+oq; 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 2A3AA68B83A; Sat, 5 Nov 2022 17:26:49 +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 824A868B4BB for ; Sat, 5 Nov 2022 17:26:41 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pkh.me; s=selector1; t=1667661983; 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=NwZfvrBilWpFfUhEOzve9x5SFeWbMCPVdq3yWFen5uQ=; b=YL9HY+oqFkzdFBxLJ35LzISYPBfiPIQl5RjG4ORbwbY+QwQs3m7MpKqqVPOFktkL5pZjLV UxOCspvif+Jy5mrflG3qnQhtfUIHA2bqPcxO1YfoqMaZZpbsM1ZZwBwCzRqA80XlqkKeAj UJ7BbvG54Eh9P5EliEunZirLTW+DZLw= Received: from localhost (ssq0.pkh.me [local]) by ssq0.pkh.me (OpenSMTPD) with ESMTPA id f925775e; Sat, 5 Nov 2022 15:26:23 +0000 (UTC) From: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Nov 2022 16:26:16 +0100 Message-Id: <20221105152617.1809282-15-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 14/15] avfilter/palettegen: rename longest to split_axis 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: 7exgHcgpV7FT Content-Length: 2370 The split heuristic is not based on the length property of the axis anymore. --- libavfilter/vf_palettegen.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c index 2976012512..9d537f8f37 100644 --- a/libavfilter/vf_palettegen.c +++ b/libavfilter/vf_palettegen.c @@ -360,7 +360,7 @@ static AVFrame *get_palette_frame(AVFilterContext *ctx) s->nb_boxes = 1; while (box && box->len > 1) { - int i, longest; + int i, split_axis; double Lv, av, bv; uint64_t median, box_weight = 0; @@ -375,20 +375,20 @@ static AVFrame *get_palette_frame(AVFilterContext *ctx) Lv = box->axis_variance[0]; av = box->axis_variance[1]; bv = box->axis_variance[2]; - longest = 0; - if (bv >= Lv && bv >= av) longest = 2; - if (av >= Lv && av >= bv) longest = 1; - if (Lv >= av && Lv >= bv) longest = 0; + split_axis = 0; + if (bv >= Lv && bv >= av) split_axis = 2; + if (av >= Lv && av >= bv) split_axis = 1; + if (Lv >= av && Lv >= bv) split_axis = 0; ff_dlog(ctx, "box #%02X [%6d..%-6d] (%6d) w:%-6"PRIu64" var:[%.3f %.3f %.3f] sort by %c (already sorted:%c) ", box_id, box->start, box->start + box->len - 1, box->len, box_weight, - Lv, av, bv, "Lab"[longest], box->sorted_by == longest ? 'y':'n'); + Lv, av, bv, "Lab"[split_axis], box->sorted_by == split_axis ? 'y':'n'); - /* sort the range by its longest axis if it's not already sorted */ - if (box->sorted_by != longest) { - cmp_func cmpf = cmp_funcs[longest]; + /* sort the range by its split axis if it's not already sorted */ + if (box->sorted_by != split_axis) { + cmp_func cmpf = cmp_funcs[split_axis]; AV_QSORT(&s->refs[box->start], box->len, const struct color_ref *, cmpf); - box->sorted_by = longest; + box->sorted_by = split_axis; } /* locate the median where to split */