From patchwork Sun Feb 4 17:36:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46021 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:7b08:b0:19e:8a94:b663 with SMTP id s8csp332744pzh; Sun, 4 Feb 2024 09:35:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZzuvVC/Ah4jfRuWGLNTgP/0nUgC5e+Dcz8S4VofFThsNG6y8FUxSrdXaMlL30lEqYQv9U X-Received: by 2002:a17:906:f989:b0:a35:2f7a:385b with SMTP id li9-20020a170906f98900b00a352f7a385bmr8701859ejb.23.1707068111847; Sun, 04 Feb 2024 09:35:11 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXJN+E3/RtNAhsV33NUe9/vg8wPBOSJ6ermx40cBVDtbNSkt+RVZneJaFxVZulgYJ53j7bD5NeKI7usdLpdzJxpRQK4AjTGBknVgQS9Dth6+Rub2x80p6za14b9NwLyB/Vn1v5zTwoqDz/DVre6PWLgoW7CytTG4xT8VPCkoZCU0hyzgo3KU590gE18NFBPjWWTu0QbT6akKlYXdJGr1fPIA8/eAJyj8uo8pbGAC6ZRk1DJuoSaGGwtC6mjv/2SDncxbpIM/JOC1TPPgfR6+MEtE2sFUF7pKXiaQbA+/Z77T3itWX8IH4deJZKxm3o8dWtX/E+p+OS/zeSx+xqxY2X8NWxSH4y6sBx5ZUsQkqvOwMkXtG2fM/sn3Qotg3H9oSUc4xDnsJjo4clwtC9vxDU4tXwXJYQDgdhTuLW9XuBBIb4643ukjQyNiOVVDMUGG/acRD826XbANpVQiXprrNa/0gBb9Nw50hQH9QOw+a4tPTkgSnUq22XiIDFggHgTJZmDsf/armI2mfsKQkrDx78PZXaZnCuTWdgs93j+3Ak02VVcO4Vo0YLJpzlyVisk7+QF93zvzUBNcRNNgGKlQIxdGSGrdMCIO1LdvH9ZSAvUzUV+J0pBiXPV08WvMZO/WquMG1mCfIz/O6D/YK++/1JrU/gZ1ZW0qCWSfF8CshnwdHsx6e+XKR0VbmhNDL+j0z38o1iGxcWSw3Ubr/3EWpRJaNrUEm6u6ry0PxjtimWZffhocNOx9NF8p+yMPZW7cvmeesqVDsTgP4QeJyL/huJD5CVrCZISxOnLwWl9fLv4z3oYGReOI8QnNUQvihiFV16S6TEfqLCHeTuq47yknLLLsOXI7nCzpjTSu9LJWBbeRBxm/IMaupt7FjH9Ydy1+ubNJ2RTQ2EqgCvIsIEjIEeikGAm590pUTJ3bQFmh4KsdVxBIvhg3FIGYrTp+NU71mjHEF sIfd2Okktk/f5jrmaIjeX+KuqAA8SQU0avq3hGULOrKfMRVC8czAC1Eik/b8eDiio8bFR7kwsFnWOmUFr1++MiAkrH7dWL9uQI+0hafbk4SHto755JiqcS8s5VnazpR16Ff6cZvHw3BrWw4uUAqkdbbVdUgbNfjiWtn1htQIbd7EAbFlSxTl04PojJtwFHUrfA5+faK5P7+IhCRb+dbm3WAeF29gwpbuMBIz52o9Z+5AVzk/XPaZSVvN9PZb2LRI4qkQSsc9Z629t5+tQW7p9sTUp7Kt3O2s69FAlFHoLpcyHQf7r3NwFMczpKoo4mBd4jb+xizEi0jTR7/E/CgTZbNXDBaBNdZHL38vziIrk998pTrfAcw52FptGbeJZDjZD0jhXt0I+CzWktP/sMd8fs1HHaLoaPJP1BTQiWrJd5Z/tGwYye1IuQXD/eVBfZ+W28Fuw/5hqidTwL7QdEzUkD4uS9HVOQ3DdRFjOKuurrn1mbE9jakyupr63/LKeIwUkUlWoyL29BIvzqLGPtMtY0yDaT77Y0jiUEYJqX7jbuap1dGUN8uMFdp0TRl89w2Cs3tPRck6dXA83QibJKuIiQz30VLEliNRl09TWy Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ox4-20020a170907100400b00a303ea589desi3019153ejb.382.2024.02.04.09.35.11; Sun, 04 Feb 2024 09:35:11 -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=@outlook.com header.s=selector1 header.b=WbTOvkqY; arc=fail (body hash mismatch); 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=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DBE9768D0B4; Sun, 4 Feb 2024 19:35:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2024.outbound.protection.outlook.com [40.92.59.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 16DDD68CE03 for ; Sun, 4 Feb 2024 19:34:59 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N0iKHAT0MHYt3ytL7P2XoKgYqzaRQIx8UjJ2R26BYJCUZwhETTc87gwtivTmB7M0cyCTgPfDlMRDtgra2Hm21JIvgxX6jX2W6zF7Bo7Yjq1zcYpJYqg88JFcm7cPv/7lpE5gf3X1Wt+JIyVjUEn2xf6jkbY0MfId5tUUVzkgcj2aq1L7X8vkrM2AxWMIWfhCqU5kYy+AT8MILL5eiYR1JoQjMSm1r2+qpDlx7C7/1g+fnaEXxMxlfcOBOf5Gn6uuX23ziK6cpZK5ZzXGi10anqCZPyL47wLdU6l/tWhDqyzaujkUcYt25/ByRnaaYF+3UXCS86swE+sbDb5E6B+TDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j/LDhaoTeCBP66cpE5n6jeaM/xOHGCw8lWOBir9+ZGA=; b=DtJlgCJU46hcUe4Ibe0guXzu51+Ll82iHeH3/L3fUW++7RK11X9f3ibego97a2M4WBeMQU07+Yn80fc4bU380vXRtTza7zUrcFONbKMfoZQA+StxPedf7SQIAXZTsU/RKur/aOm0mvdRLNQgBT3J8L9MeCK1AZSZVi0vJzUpltNI0nrS0Huskn00+zPLheb1NU7k+MmuUdoqxcWAz0aGvmYrlh1lfk+Udeu85nWXjllYNaz/mAqFOn1jYqXICZHgB4dGoir/zyK1TJ1PAdhKuTwZEZva7JIL2T6ODP8MDm7ZTz8iLparbAUJT9bKsvP4bFwmBAKsejIRZzFFF3upDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j/LDhaoTeCBP66cpE5n6jeaM/xOHGCw8lWOBir9+ZGA=; b=WbTOvkqYqGUlVQ/399O0o//C71YUtItqcfEtHcivnbB9uLndsihLYa+jXB35OntrVrflfP6vDE6P8LE/GaDK1enHaCRaWKe77O3VFh4IqSddZKAYa12ZkK6ZNK8X0kid/p6FRU2dRpZL/8prBPpU0hheUFG7TW2fHj4cG80BMxiVP6TWeyY4URxcbhKHYRZEntcLJFxdiWhJ+il5c+KITjuhVeMiOQXjxecnsDCLANKA4pGFvyej7YFyccwnm/k2ZXC5HgaQCdLfPTTr4nZJ0RY2zvf0Xse/xLdlvCzLvgE91I0SYhbJwBVvLEeBDGmjZInWA6NxnCUrqmSYrTg2dQ== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0097.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:170::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.34; Sun, 4 Feb 2024 17:34:57 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7202.031; Sun, 4 Feb 2024 17:34:57 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Feb 2024 18:36:45 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [LUzwZPSLsUKy5PqDeL/vMAEU2TjNDKFrlCSPqc/Amqk=] X-ClientProxiedBy: FR0P281CA0190.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ab::15) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240204173645.2807793-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0097:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c89b2fa-d83a-41f3-0df3-08dc25a79afe X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SmpouWWg45Maf2bLW+XeitVaUGk5awYGWwzBYepECXCzQAhrMRPL5L8DTVzSmeylPLtN4bc/C/30ZUyAG8eZZt3idwFW8sGKlTeVgkObbTJ6OU8MIdDmOxwPFMvNvCzUCP2Jr1/wArtFEJHfjEWzK7hcSfeKtbHZaEoPUKGwd6d7HbfNFfZXRiTbENhbwZjYksn7VPxAv73bR5A2TEozrYcwkyrJKb3Ie2pWoOaRWlOhz5WyMbMf4mmMuCI6yzquAUF3R6K1GEtud75dUqGZAH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8sLenuLee5fMtbXZ92466NOn/xheMarKoss77u0sxLW1I1IniBlPcfp3JK/ttjFaE+VC8SBRioKpOHPO4iZ36jf1PHg8fIpD0vFboNMV9bHoyidL1/qPBucCZSEqNzXooIyf2ueTv5eyGBCXjZJqUZtTenJXjbcEfLfj6vef/6DWKXjBICqSfKoS9EsO0m5fr7RjwiQEKL+TovKJ2AS+huqqFPBrK06H2AAntKzesZV8HS1yR/c/aZKqreInNM46B08yEqBrzXwNskBI2lmT9aB6IjJKT+cuwxOmZNlp9jwfE4RN80XHCsvkVOerTfJg2/T1AOhNWpjS0Qsmq5tbBFUkl+RIaKukwwy65UzwS3LyPoSJspFj76ath2o1DwkOD7XDZRh9DcOiBxvVSzgryup0GqUTHRzEmU7MkKG3IbOogMbHDcuvjzFkSVwj1vN4vNHqYwkE0u3y8SCoFubhPDFFbZyYrcvUA0p399EbEfIS7Y5nM8QOtxg4R3Xdloziqblw2VSdI/y+sUnBwLiEAbgKF4GYf5ktwESMLDIIyi26g7yg3DWG5nnUaTFev9M2kx/sLf5crcxdymA7hN2cm2oTfaPc7Mga+Taw3CUs8aSxgxV+ X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c89b2fa-d83a-41f3-0df3-08dc25a79afe X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2024 17:34:57.1947 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0097 Subject: [FFmpeg-devel] [PATCH] avdevice/caca: Allow to list multiple dither option types at once 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 7c/rTuei6O0G This can be achieved by using AV_OPT_TYPE_FLAGS instead of AV_OPT_TYPE_STRING. It also avoids strcmp() when accessing the option. Signed-off-by: Andreas Rheinhardt --- libavdevice/caca.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libavdevice/caca.c b/libavdevice/caca.c index 6af1649137..c0e09cf6f7 100644 --- a/libavdevice/caca.c +++ b/libavdevice/caca.c @@ -24,6 +24,13 @@ #include "libavformat/mux.h" #include "avdevice.h" +enum { + SHOW_ALGORITHMS = 1 << 0, + SHOW_ANTIALIASES = 1 << 1, + SHOW_CHARSETS = 1 << 2, + SHOW_COLORS = 1 << 3, +}; + typedef struct CACAContext { AVClass *class; AVFormatContext *ctx; @@ -38,7 +45,7 @@ typedef struct CACAContext { char *charset, *color; char *driver; - char *list_dither; + int list_dither; int list_drivers; } CACAContext; @@ -99,21 +106,14 @@ static int caca_write_header(AVFormatContext *s) return AVERROR_EXIT; } if (c->list_dither) { - if (!strcmp(c->list_dither, "colors")) { + if (c->list_dither & SHOW_COLORS) list_dither_color(c); - } else if (!strcmp(c->list_dither, "charsets")) { + if (c->list_dither & SHOW_CHARSETS) list_dither_charset(c); - } else if (!strcmp(c->list_dither, "algorithms")) { + if (c->list_dither & SHOW_ALGORITHMS) list_dither_algorithm(c); - } else if (!strcmp(c->list_dither, "antialiases")) { + if (c->list_dither & SHOW_ANTIALIASES) list_dither_antialias(c); - } else { - av_log(s, AV_LOG_ERROR, - "Invalid argument '%s', for 'list_dither' option\n" - "Argument must be one of 'algorithms, 'antialiases', 'charsets', 'colors'\n", - c->list_dither); - return AVERROR(EINVAL); - } return AVERROR_EXIT; } @@ -205,11 +205,11 @@ static const AVOption options[] = { { "charset", "set charset used to render output", OFFSET(charset), AV_OPT_TYPE_STRING, {.str = "default" }, 0, 0, ENC }, { "color", "set color used to render output", OFFSET(color), AV_OPT_TYPE_STRING, {.str = "default" }, 0, 0, ENC }, { "list_drivers", "list available drivers", OFFSET(list_drivers), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, ENC }, - { "list_dither", "list available dither options", OFFSET(list_dither), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, ENC, "list_dither" }, - { "algorithms", NULL, 0, AV_OPT_TYPE_CONST, {.str = "algorithms"}, 0, 0, ENC, "list_dither" }, - { "antialiases", NULL, 0, AV_OPT_TYPE_CONST, {.str = "antialiases"},0, 0, ENC, "list_dither" }, - { "charsets", NULL, 0, AV_OPT_TYPE_CONST, {.str = "charsets"}, 0, 0, ENC, "list_dither" }, - { "colors", NULL, 0, AV_OPT_TYPE_CONST, {.str = "colors"}, 0, 0, ENC, "list_dither" }, + { "list_dither", "list available dither options", OFFSET(list_dither), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, INT_MAX, ENC, "list_dither" }, + { "algorithms", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SHOW_ALGORITHMS }, 0, 0, ENC, "list_dither" }, + { "antialiases", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SHOW_ANTIALIASES }, 0, 0, ENC, "list_dither" }, + { "charsets", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SHOW_CHARSETS }, 0, 0, ENC, "list_dither" }, + { "colors", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SHOW_COLORS }, 0, 0, ENC, "list_dither" }, { NULL }, };