From patchwork Tue Dec 27 23:17:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= X-Patchwork-Id: 39779 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3761671pzb; Tue, 27 Dec 2022 15:20:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXtmoGe3MNCLHmYzFWf5GUPyId2+efr9b8RxsR5DIoXVeVVA1LyaO36BakHCio9j9BNH1BHA X-Received: by 2002:a17:906:8447:b0:7c8:9f04:ae7e with SMTP id e7-20020a170906844700b007c89f04ae7emr21246025ejy.22.1672183215210; Tue, 27 Dec 2022 15:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672183215; cv=none; d=google.com; s=arc-20160816; b=upJxaGW+FEySFjQ7C3Ryi/rN13Cffp+jOpPleVEOv+NWa7UgsX5GxOsCWiJzSxIpFo 2RCHRVqjuM3I0qTokNBk1diZBuWlyhS26jlJ4Nd5kzXMZOhE/usyh9O2UP4ctEHy6caq Q6D2nuBBzpKaeYM3hvkkzt7b1/GD6hm4QyEokjSR2Vczh6FUTBkrh2SGwMt4IJwsf80j RDKUDcezsWU8RRyef1i397BTGt+OpHVH+AaR1tkjOsOkU6mdFRaCP1QRlA7crVvSTN0h y9+FpHnagoTxq71KPkqGJ6ede+xawC8Ad+85CTxFJ73KlCR1Hl/D9fn6WDnKhaHFwQAA tSDA== 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=23IQNqQDYAxFydKYDLQI8i4Nq4wVQbTm6Hc+OkRlb24=; b=ofl0t4VAnx4v8IWI175lrfuyQfgTKU/88/NoXudBItenRhUshGnMB44lQye7u0fagt i4ndOlG/9VzDS7Qg9Vqtif1cph8r4R96tDJ9Dca9qA9azC9MLWh5z0H0+GEzvD24Q7J4 lauTjiFdlxiCqVCrYOt5zQjsmtMEyfp/iije9uvg2NeIpbShbG+8CpfCf3re8S/4gbPV 8oCTuXlW3PSBAHKZWA6jxZL0QudfV9BetuucBGfw/Kbk1b5PPTPwkiZCboyYgDIIweog tKaX3Ugwxj6CQeQKriqZBm2+LWhdUNo4LqpSTTEQaw1kqv+/1CN6u0YKxcZWJ0qJPaqw 0pdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@pkh.me header.s=selector1 header.b=Fu1juKhW; 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 xa8-20020a170906fd8800b007c1fa1e907csi11951520ejb.992.2022.12.27.15.20.14; Tue, 27 Dec 2022 15:20:15 -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=Fu1juKhW; 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 CE70568BD26; Wed, 28 Dec 2022 01:18:40 +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 A625468BCAE for ; Wed, 28 Dec 2022 01:18:33 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pkh.me; s=selector1; t=1672183098; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ED6TFr6VSQnIOD3d1aLtzbT4foGYfrfvVw4J0CsGYyE=; b=Fu1juKhWXcARJA+D1JxZOKQvjdXef0LwVslI793Mr7jyss+gyw2mjEIQ/RJGtFdB3/Jyn4 G+QmbMAJVUf59RbnV9LQGum2Bg154yErUpsAkHp16wUoJJv7TenJnDnW+h63ev3tCye5Yk z+1RGCQaFMrvCro9UNUtK6ecob89YFE= Received: from localhost (ssq0.pkh.me [local]) by ssq0.pkh.me (OpenSMTPD) with ESMTPA id ec643d7b; Tue, 27 Dec 2022 23:18:18 +0000 (UTC) From: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Dec 2022 00:17:57 +0100 Message-Id: <20221227231814.2520181-16-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] =?utf-8?q?=5BPATCH_v2_15/32=5D_avfilter/palettegen?= =?utf-8?q?=3A_change_cut_score_from_=E2=88=91e=C2=B2_to_max_e=C2=B2?= 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: 0NzkbwyyUOTr This is following the results from personal research¹. ¹: https://github.com/ubitux/research/tree/main/color-quantization#results --- libavfilter/vf_palettegen.c | 3 ++- tests/ref/fate/filter-palettegen-1 | 2 +- tests/ref/fate/filter-palettegen-2 | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c index 7ecb1211ba..00b5f88c49 100644 --- a/libavfilter/vf_palettegen.c +++ b/libavfilter/vf_palettegen.c @@ -171,7 +171,8 @@ static void compute_box_stats(PaletteGenContext *s, struct range_box *box) if (er2[0] >= er2[1] && er2[0] >= er2[2]) box->major_axis = 0; if (er2[1] >= er2[0] && er2[1] >= er2[2]) box->major_axis = 1; // prefer green again - box->cut_score = er2[0] + er2[1] + er2[2]; + /* The box that has the axis with the biggest error amongst all boxes will but cut down */ + box->cut_score = FFMAX3(er2[0], er2[1], er2[2]); } /** diff --git a/tests/ref/fate/filter-palettegen-1 b/tests/ref/fate/filter-palettegen-1 index 278d831846..57be338b42 100644 --- a/tests/ref/fate/filter-palettegen-1 +++ b/tests/ref/fate/filter-palettegen-1 @@ -3,4 +3,4 @@ #codec_id 0: rawvideo #dimensions 0: 16x16 #sar 0: 1/1 -0, 0, 0, 1, 1024, 0x394ee723 +0, 0, 0, 1, 1024, 0x21c6e6c4 diff --git a/tests/ref/fate/filter-palettegen-2 b/tests/ref/fate/filter-palettegen-2 index e9bc635c81..bcdf54af95 100644 --- a/tests/ref/fate/filter-palettegen-2 +++ b/tests/ref/fate/filter-palettegen-2 @@ -3,4 +3,4 @@ #codec_id 0: rawvideo #dimensions 0: 16x16 #sar 0: 1/1 -0, 0, 0, 1, 1024, 0xc54d773d +0, 0, 0, 1, 1024, 0x630d76b1