From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 27B4A49181 for ; Sun, 4 Feb 2024 23:47:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2E5D068D10E; Mon, 5 Feb 2024 01:47:20 +0200 (EET) Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A23768B184 for ; Mon, 5 Feb 2024 01:47:13 +0200 (EET) Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a36597a3104so507169866b.2 for ; Sun, 04 Feb 2024 15:47:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707090431; x=1707695231; darn=ffmpeg.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=9EyX56KT0ZehUBZbR+gBs50sB18/7JvxigYNYiFW86A=; b=bpMlHu2ZdA8fHX2H/YmBPN4NvO+4v0QdN0OERx0UUOxPzKdNnEaxOYoexs2QmXm1CF fCgCRlKa0iO2pTRj2ZTt9lw/Cx/WkOInA4tubJ8QqQZkf+hmGLAAOX2KJb1Zf/QosrQr VX1GM3MSyMD2WhwLZgB+2aDaiilx5178rb+FIpaZeA/7E3MyzwA2/BEae8vQw/jIsWEP ZhL4dlcX+jE803URl3m+/i4Y3mGVH6O1gFN7CgiOtT548WjSyJcz0JlIF7vxaJODnUbf CEZ8DKvGniz7cUtQihmGGNQyuP9cRLzXldTN6BfCjun7aENkOFpml43JSc6dserQMktJ 3aNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707090431; x=1707695231; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9EyX56KT0ZehUBZbR+gBs50sB18/7JvxigYNYiFW86A=; b=d81J4cAUfDgUVSNceqxduDVhh/o1fG9VjAq3ZVvQureXtDYmpRycgC9x1gMhYsgcRp RrWpmGf3h5ZfoNpGJ0M4pvR4lOMRi59VAAVnpic4m8sHc3aw/ykDCZUPeqJL3q4YZDwT NIOAlp0DPLkU/RM74GehxYWBkND/d80/haN/n28QEGvx8fs5XWuAkJ2yuMJmCvT2Ky6t CoEYKiB7yEv+BCr92X7RDRl7i6qWozRRHKxlEinCH7cnS0QlTTEwylxl1NONUZgwZou5 iRxEUpZJL+ugoQh0N4hbbixbpTFp8LB8IDk828FSvy6mKJ19A+nP7tl74suIVpJd4/qD v5kQ== X-Gm-Message-State: AOJu0YyYy79t2hWqTxciqPGfqW3Nk7yrhkQPDmkZzGpOn2hghoV/F/16 PBgcBH3lB7YJ3361lMv3DCRmJ7NihhGYC3ulwiPDgA1vtv4J0glQOs/Cn/uf X-Google-Smtp-Source: AGHT+IEoMnVf2LTDQBytMH2itxfAS2ikD6pDbIXzqD15/zqHIzXGJ3omnG5NJ40ycw44E5Oc7D9mzQ== X-Received: by 2002:a17:906:ae8b:b0:a35:a3e2:edcc with SMTP id md11-20020a170906ae8b00b00a35a3e2edccmr5252812ejb.48.1707090431184; Sun, 04 Feb 2024 15:47:11 -0800 (PST) Received: from mariano (dynamic-adsl-84-220-189-10.clienti.tiscali.it. [84.220.189.10]) by smtp.gmail.com with ESMTPSA id d13-20020a170906640d00b00a35d7b6cb63sm3610735ejm.28.2024.02.04.15.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:47:10 -0800 (PST) Received: by mariano (Postfix, from userid 1000) id 47616BFCDC; Mon, 5 Feb 2024 00:47:09 +0100 (CET) Date: Mon, 5 Feb 2024 00:47:09 +0100 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches , Andreas Rheinhardt References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On date Sunday 2024-02-04 18:36:45 +0100, Andreas Rheinhardt wrote: > 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, > +}; nit: LIST_ for consistency? > + > 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 }, > }; LGTM otherwise, thanks. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".