From patchwork Wed Jan 16 12:40:20 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: 11769 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 3E15344DAA8 for ; Wed, 16 Jan 2019 14:40:26 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 561BF68AA22; Wed, 16 Jan 2019 14:40:14 +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 87E0668AA08 for ; Wed, 16 Jan 2019 14:40:08 +0200 (EET) Received: from localhost (localhost.localdomain [127.0.0.1]) by amavisd-new (Postfix) with ESMTP id 43D1644B8D for ; Wed, 16 Jan 2019 13:40:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=acc.umu.se; s=mail1; t=1547642422; bh=OplPmPFEwuZ8GEMl++EILW9DXmUwMHt2/QVE6odxs9E=; h=Subject:From:To:Date:From; b=KLZoMZgqdKjoBceNlwWhHmRws8a0sDqObrLRkqfqtLQW3LWHVB4fAt4sLCRaXhLRd +EVVR9OlthCkHxG/kdlkfuuonosGC1nnKzjDFOGXeHSUAJ+1WbHaxFvpSFyw9JVD7D 6lm62K7jrrMgANrbK/kcPAPu++2QbeRmK1aB2syj+G1PYvMcx9AsrhqHC+a32WM2lk qKrLmY+YOl+DujcQa4k9BTyt2CwnRuYfoDzVS8pwJnSkICWpZ6XjUYfiadOxMS6uxN lbcCWTARDl4fhH8sqwNoj9kZ/QZOT5fxktykxfJGkrB2Axkd6DrCi7U4+koN//AP7S HlOlFaxwykGpA== Received: from [192.168.1.245] (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 483A344B8B for ; Wed, 16 Jan 2019 13:40:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=acc.umu.se; s=mail1; t=1547642421; bh=OplPmPFEwuZ8GEMl++EILW9DXmUwMHt2/QVE6odxs9E=; h=Subject:From:To:Date:From; b=VWgPHwbpYpPiu0tCbJ3d0Ej3I4YUU+KJf/UD33quRIc9IxdIBE7FaXRuw5PVy56Yc pmcaHe7vNQtBkqU4+zCIbRQ+8zU7xzkbm1jXbtORoCSsv41tb8HFCAB6uf3p4sHRPt xkxaAtOxBKpaprgeD5F3T2BbJ3G+J9Ykkje2j8n4BQ8fZeRDCEQKoVQZwFRvcAuDNL XzjXLlVBlYxt1h+zHoYipNGm0RjvUlXvTver9R0V60ICnwg315OsUEq4dRMKguDdr4 jwFsItSOz3qFbXUI+yR2yQP1cAPJ1D3hM2zlLiOZVpkrCpX5bWuIHohLKfSXrOuFbJ V7d6Pckw+Vaxg== Message-ID: <1547642420.30920.1.camel@acc.umu.se> From: Tomas =?ISO-8859-1?Q?H=E4rdin?= To: ffmpeg-devel Date: Wed, 16 Jan 2019 13:40:20 +0100 X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Subject: [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" 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; -- 2.11.0