From patchwork Tue Dec 27 23:17:43 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: 39766 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3760925pzb; Tue, 27 Dec 2022 15:18:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXthWQRMr2xDbCN1587BSZWxpjglziBfyfmPm+qfQdpUAbr7zeRtl68L2ZKLF24PGGoDOivP X-Received: by 2002:a17:906:7254:b0:7ad:bc7e:3ffd with SMTP id n20-20020a170906725400b007adbc7e3ffdmr21625539ejk.42.1672183117997; Tue, 27 Dec 2022 15:18:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672183117; cv=none; d=google.com; s=arc-20160816; b=z+NbPH5KyyKTGIuY7uf+xbkJtEBaTmW02LMms+TcC2GJeakhWt7Y2F3jiktckkaiWK +slN7+SW8iZECwY9hNBwppfcAqbAlIX37paMZ4qH3UfkXDu+Ey4Ro1Bg/WNFmHV/3OBN bboaLQDM5LT8iRc8PW0LVZQRF7xhiSNiaHvdqx2Nk1Xg/FZhtGoCdGTF9BmkPFptJ33c 3k2TBShn+/pjJKN4k34LVoUAiaO2OaBSoq7UXkE3D2Glbb9V59w69ckvCF/DTf0TwWA5 KJthvLB77crxU9CmasJ2LUtlfxdfRrJWSlDqGdMCpVN6OBeAKLbtmtuNhUyY9tuR/4Yk h9ug== 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=mapuzmOHRX8Bj4zdO6+MxSMWn0BhG7fDxc1JWjIX0xk=; b=PKAgLTree7iv61uyD7FjHUqLAsKLdxNcn627N7P2NMrr3dCmQkoDUmr0GqwXibHfKf T1xky+lMoisKTAUC5xWdaR7efa+vuSffZTKlZqD+0U/+2Rlz5iz1WE0C/+z8MyhOLQV3 GQ/4HVtErlWuBthj84q05Eif2I9GO5EYC/Ea9dHF9Vk3YL1QZl3y0RWbvFMtcMytwmFH Z+idxYc+0brvMqanO1lqza/f/LOd5YIiilYhtZK3rRQJWbSPvZcCg7KBvpP4mCH8rdV3 Fr0w6HSCfRhl6T+gbit1rD9bUsnqAopdl1hrhgXhtJ5g0WWSpRvbYhJ1IL3PsAoLI4Xc dMUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@pkh.me header.s=selector1 header.b=GzBjqvbB; 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 dd20-20020a1709069b9400b007c175331850si10603555ejc.428.2022.12.27.15.18.37; Tue, 27 Dec 2022 15:18:37 -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=GzBjqvbB; 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 0DF4E68BC53; Wed, 28 Dec 2022 01:18:29 +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 88E5A68BC53 for ; Wed, 28 Dec 2022 01:18:21 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pkh.me; s=selector1; t=1672183096; 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=Oy5zcOG5G18oWEjAEA13JG/XUChDvPy0RptZ0dY5Mog=; b=GzBjqvbBJmZcxSJJAJBm4+4YjV5xYAW8g2iLt2VmJajRFde8JUtuAJIvDIcgd98/yaQ14M Wp23NFYyJ9KQXB6XQ8FGCbX9PrSuG4ec6EO17kYKpRVtCOM5irVPiZzRJ46SNUzjXfLUpZ KlxX/8unWl+x1AgpMG03GucnMjDgR4Y= Received: from localhost (ssq0.pkh.me [local]) by ssq0.pkh.me (OpenSMTPD) with ESMTPA id 2bda8894; Tue, 27 Dec 2022 23:18:16 +0000 (UTC) From: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Dec 2022 00:17:43 +0100 Message-Id: <20221227231814.2520181-2-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 01/32] avfilter/palettegen: allow a minimum of 2 colors 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: n/2hJxGrS1n4 --- libavfilter/vf_palettegen.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c index 27f74fd147..c03f62b942 100644 --- a/libavfilter/vf_palettegen.c +++ b/libavfilter/vf_palettegen.c @@ -82,7 +82,7 @@ typedef struct PaletteGenContext { #define OFFSET(x) offsetof(PaletteGenContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM static const AVOption palettegen_options[] = { - { "max_colors", "set the maximum number of colors to use in the palette", OFFSET(max_colors), AV_OPT_TYPE_INT, {.i64=256}, 4, 256, FLAGS }, + { "max_colors", "set the maximum number of colors to use in the palette", OFFSET(max_colors), AV_OPT_TYPE_INT, {.i64=256}, 2, 256, FLAGS }, { "reserve_transparent", "reserve a palette entry for transparency", OFFSET(reserve_transparent), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS }, { "transparency_color", "set a background color for transparency", OFFSET(transparency_color), AV_OPT_TYPE_COLOR, {.str="lime"}, 0, 0, FLAGS }, { "stats_mode", "set statistics mode", OFFSET(stats_mode), AV_OPT_TYPE_INT, {.i64=STATS_MODE_ALL_FRAMES}, 0, NB_STATS_MODE-1, FLAGS, "mode" }, @@ -586,6 +586,11 @@ static int init(AVFilterContext *ctx) if (s->use_alpha && s->reserve_transparent) s->reserve_transparent = 0; + if (s->max_colors - s->reserve_transparent < 2) { + av_log(ctx, AV_LOG_ERROR, "max_colors=2 is only allowed without reserving a transparent color slot\n"); + return AVERROR(EINVAL); + } + return 0; }