From patchwork Sun Feb 17 22:22:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Tomas_H=C3=A4rdin?= X-Patchwork-Id: 12095 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B6A2F448BE2 for ; Mon, 18 Feb 2019 00:22:33 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 956ED68AA6F; Mon, 18 Feb 2019 00:22:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.acc.umu.se (mail.acc.umu.se [130.239.18.156]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D202368AA6F for ; Mon, 18 Feb 2019 00:22:26 +0200 (EET) Received: from localhost (localhost.localdomain [127.0.0.1]) by amavisd-new (Postfix) with ESMTP id 2465644BAF for ; Sun, 17 Feb 2019 23:22:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=acc.umu.se; s=mail1; t=1550442146; bh=RgSU9Uc2HDKXWQGD303pd4WHAgc8AFidLN2yQakTrcw=; h=Subject:From:To:Date:In-Reply-To:References:From; b=aYf1T8GfL2MqwPKH3wCpcreLxim8ESU+Edgx13iDDjJvwXQcG0YEjrJ1bIEDXTYb0 FKGpaHWGUjJa0CgC5Ml5d55PNbZCAy1/q3m+akRORS6jG4HlAhrcGbcYhUrzsmc7sT w0b3gn3GI9hisz7f8gxvtys9yGc2gomplFdjpIZiyhE6AVBgxU+Mg5XZG/uaSm9bN/ HQBw2FiXnM+U1DSZ1+lK/nK4RxisgqLpHll6uOgBZOLlQcwQ9U4rQsRKt1dzzdxsUA H7AnBOrStH1Yjr/Ou6srmNeobKxjjI7ZjVaPtmDtOYhdgdH83aq7wM9GZ3ofnLol6u 6TXydWaOM4bRQ== Received: from [192.168.1.160] (h-39-105.A258.priv.bahnhof.se [79.136.39.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: tjoppen) by mail.acc.umu.se (Postfix) with ESMTPSA id B15BF44BAC for ; Sun, 17 Feb 2019 23:22:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=acc.umu.se; s=mail1; t=1550442144; bh=RgSU9Uc2HDKXWQGD303pd4WHAgc8AFidLN2yQakTrcw=; h=Subject:From:To:Date:In-Reply-To:References:From; b=PC5o+4iSbZ81ysrvnLHN2L5vxEToEOCTDoJZDs3qv5n1SMvvbASMWjkj7Yc2veGqF qSjYph4s+mfxEAyKnwKCHHArJ9Qy9Wrz7npQpn/RTqTB3JngiQTkza5EAj7xkT+KkS S1r3RWDNm5gc0F1VKvdrYI7e8ZEvfzp4kRitlkqa4qWALTZukRAucxtLz+bKNa4jDi JxVe4rA6FL/Y+ef14Hvql1sIJ10doYceiB1GqM2fnoSvGDGES04GPqDZp6Nc9EIfF1 tZj229/eYvoF8P3FEJJKS3/8MzihYzqFCVDniQ/wCNreWkC6GMPhZV50gVsuHBjZGz k1OPNA9orgH8g== Message-ID: <1550442143.11688.1.camel@acc.umu.se> From: Tomas =?ISO-8859-1?Q?H=E4rdin?= To: FFmpeg development discussions and patches Date: Sun, 17 Feb 2019 23:22:23 +0100 In-Reply-To: <20190117101425.GM3501@michaelspb> References: <1547642420.30920.1.camel@acc.umu.se> <20190117084447.GB2336@ssq0.pkh.me> <20190117101425.GM3501@michaelspb> X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] palettegen: Fill with last color, not black X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" tor 2019-01-17 klockan 11:14 +0100 skrev Michael Niedermayer: > On Thu, Jan 17, 2019 at 09:44:47AM +0100, Clément Bœsch wrote: > > On Wed, Jan 16, 2019 at 01:40:20PM +0100, Tomas Härdin wrote: > > > Hi > > > > > > I was helping the fine folks at peppercarrot.com with web video > > > nonsense, and I notice palettegen outputs more colors than it > > > should > > > due to padding the generated palette with pure black. > > > > > > Compare this (ffmpeg version 3.2.12-1~deb9u1): > > > http://www.härdin.se/files/peppercarrot_gif/output-blackspecks-64 > > > .gif > > > with this (282a471 with this patch applied): > > > http://www.härdin.se/files/peppercarrot_gif/output-fixed-64.gif > > > > > > The attached patch fixes this by padding with the last color > > > instead of > > > black. > > > > > > /Tomas > > > From 3a01f62fdcc95cc7afaf5aa6e439b8742cce43bc Mon Sep 17 00:00:00 > > > 2001 > > > From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= > > > Date: Wed, 16 Jan 2019 13:07:48 +0100 > > > Subject: [PATCH] palettegen: Fill with last color, not black > > > > > > If we fill with black then the generated palette will have one > > > color more > > > than what the user requested. This also resulted in unwanted > > > black specks in > > > the output of paletteuse, especially when generating small > > > palettes. > > > --- > > >  libavfilter/vf_palettegen.c | 2 +- > > >  1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/libavfilter/vf_palettegen.c > > > b/libavfilter/vf_palettegen.c > > > index 5ff73e6b2b..44323782d2 100644 > > > --- a/libavfilter/vf_palettegen.c > > > +++ b/libavfilter/vf_palettegen.c > > > @@ -245,7 +245,7 @@ static void write_palette(AVFilterContext > > > *ctx, AVFrame *out) > > >                      av_log(ctx, AV_LOG_WARNING, "Dupped color: > > > %08"PRIX32"\n", pal[x]); > > >                  last_color = pal[x]; > > >              } else { > > > -                pal[x] = 0xff000000; // pad with black > > > +                pal[x] = last_color; // pad with last color > > >              } > > >          } > > >          pal += pal_linesize; > > > > Code LGTM, thanks > > > > No FATE change? > > --- ./tests/ref/fate/filter-palettegen-2 2019-01-15 > 01:24:17.530911114 +0100 > +++ tests/data/fate/filter-palettegen-2 2019-01-17 > 11:13:21.077198948 +0100 > @@ -3,4 +3,4 @@ >  #codec_id 0: rawvideo >  #dimensions 0: 16x16 >  #sar 0: 1/1 > -0,          0,          0,        1,     1024, 0x906ff5aa > +0,          0,          0,        1,     1024, 0x23e072c8 > Test filter-palettegen-2 failed. Look at tests/data/fate/filter- > palettegen-2.err for details. > make: *** [fate-filter-palettegen-2] Error 1 Finally got around to fixing this. Updated patch attached, passes FATE for me. I'll push in a day or two /Tomas From 20b5a4dfe58496eb8dc603b279e178888b8fec07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Wed, 16 Jan 2019 13:07:48 +0100 Subject: [PATCH] palettegen: Fill with last color, not black If we fill with black then the generated palette will have one color more than what the user requested. This also resulted in unwanted black specks in the output of paletteuse, especially when generating small palettes. --- libavfilter/vf_palettegen.c | 2 +- tests/ref/fate/filter-palettegen-2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c index 5ff73e6b2b..44323782d2 100644 --- a/libavfilter/vf_palettegen.c +++ b/libavfilter/vf_palettegen.c @@ -245,7 +245,7 @@ static void write_palette(AVFilterContext *ctx, AVFrame *out) av_log(ctx, AV_LOG_WARNING, "Dupped color: %08"PRIX32"\n", pal[x]); last_color = pal[x]; } else { - pal[x] = 0xff000000; // pad with black + pal[x] = last_color; // pad with last color } } pal += pal_linesize; diff --git a/tests/ref/fate/filter-palettegen-2 b/tests/ref/fate/filter-palettegen-2 index aa07b6cb93..9abec0fe8e 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, 0x906ff5aa +0, 0, 0, 1, 1024, 0x23e072c8 -- 2.11.0