public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	Mehdi Djait <mehdi.djait@linux.intel.com>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Subject: Re: [raw2rgbpnm PATCH v4 04/11] Support long options and improve help text
Date: Tue, 17 Mar 2026 12:49:54 +0200	[thread overview]
Message-ID: <20260317104954.GA302774@killaraus.ideasonboard.com> (raw)
In-Reply-To: <abkjmuuQvBG12qBJ@kekkonen.localdomain>

On Tue, Mar 17, 2026 at 11:49:14AM +0200, Sakari Ailus wrote:
> Moi,
> 
> On Mon, Mar 16, 2026 at 04:41:51PM +0200, Laurent Pinchart wrote:
> > On Tue, Mar 10, 2026 at 10:46:10AM +0200, Sakari Ailus wrote:
> > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > > ---
> > >  raw2rgbpnm.c | 34 +++++++++++++++++++++++++---------
> > >  1 file changed, 25 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/raw2rgbpnm.c b/raw2rgbpnm.c
> > > index 14cfa7e7a46c..16ef64e984b9 100644
> > > --- a/raw2rgbpnm.c
> > > +++ b/raw2rgbpnm.c
> > > @@ -24,6 +24,7 @@
> > >   */
> > >  
> > >  #include <ctype.h>
> > > +#include <getopt.h>
> > >  #include <stdio.h>
> > >  #include <stdint.h>
> > >  #include <stdlib.h>
> > > @@ -836,6 +837,17 @@ static int parse_format(const char *p, int *w, int *h)
> > >  	return 0;
> > >  }
> > >  
> > > +static struct option options[] = {
> > > +	{ "algo", required_argument, NULL, 'a', },
> > > +	{ "brightness", required_argument, NULL, 'b', },
> > > +	{ "format", required_argument, NULL, 'f', },
> > > +	{ "help", no_argument, NULL, 'h', },
> > > +	{ "high-bits", no_argument, NULL, 'g', },
> > > +	{ "size", required_argument, NULL, 's', },
> > > +	{ "swap-rb", no_argument, NULL, 'w', },
> > > +	{ 0 },
> > > +};
> > > +
> > >  int main(int argc, char *argv[])
> > >  {
> > >  	FILE *f;
> > > @@ -849,7 +861,7 @@ int main(int argc, char *argv[])
> > >  	int width = -1;
> > >  
> > >  	for (;;) {
> > > -		int c = getopt(argc, argv, "a:b:f:ghs:w");
> > > +		int c = getopt_long(argc, argv, "a:b:f:ghs:w", options, NULL);
> > >  		if (c==-1) break;
> > >  		switch (c) {
> > >  		case 'a':
> > > @@ -889,14 +901,18 @@ int main(int argc, char *argv[])
> > >  			break;
> > >  		case 'h':
> > >  			printf("%s - Convert headerless raw image to RGB file (PNM)\n"
> > > -			       "Usage: %s [-h] [-w] [-s XxY] <inputfile> <outputfile>\n"
> > > -			       "-a <algo>     Select algorithm, use \"-a ?\" for a list\n"
> > > -			       "-b <bright>   Set brightness (multiplier) to output image (float, default 1.0)\n"
> > > -			       "-f <format>   Specify input file format format (-f ? for list, default UYVY)\n"
> > > -			       "-g            Use high bits for Bayer RAW 10 data\n"
> > > -			       "-h            Show this help\n"
> > > -			       "-s <XxY>      Specify image size\n"
> > > -			       "-w            Swap R and B channels\n", progname, argv[0]);
> > > +			       "Usage: %s [--algo|-a <algo>] [--brightness|-b <brightness>]\n"
> > > +			       "       [--format|-f <format>] [--help|-h] [--high-bits|-g] [--size|-s XxY]\n"
> > > +			       "       [--swap-rb|-w] <inputfile> <outputfile>\n\n"
> > 
> > That won't scale nicely, but I don't want to implement an options
> > handling framework in C right now :-)
> > 
> > > +			       "--algo, -a <algo>         Select algorithm, use \"-a ?\" for a list\n"
> > > +			       "--brightness, -b <bright> Set brightness (multiplier) to output image\n"
> > > +			       "                          (float, default 1.0)\n"
> > 
> > Do you know if this option is used by anyone ? It seems a bit out of
> > place. Not an issue with this patch of course.
> 
> I have no idea. But keeping it won't do any harm, will it?

It's just an opportunity for cleaning up an unused feature :-) It looks
out of place, as nothing else in raw2rgbpnm performs post-processing on
the converted image (and rightfully so).

> > > +			       "--format, -f <format>     Specify input file format format\n"
> > > +			       "                          (-f ? for list, default UYVY)\n"
> > > +			       "--help, -h                Show this help\n"
> > > +			       "--high-bits, -g           Use high bits for Bayer RAW 10 data\n"
> > > +			       "--size, -s <XxY>          Specify image size\n"
> > > +			       "--swap-rb, -w             Swap R and B channels\n", progname, argv[0]);
> > 
> > I'd add a line break before progname.
> 
> Sounds good.
> 
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > 
> > >  			exit(0);
> > >  		case 's':
> > >  			if (parse_format(optarg, &width, &height) < 0) {

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2026-03-17 10:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10  8:46 [raw2rgbpnm PATCH v4 00/11] 10-bit packed raw support, other fixes and improvements Sakari Ailus
2026-03-10  8:46 ` [raw2rgbpnm PATCH v4 01/11] Add explicit switch fallthrough notation Sakari Ailus
2026-03-10  8:46 ` [raw2rgbpnm PATCH v4 02/11] Add compiler options to avoid warnings Sakari Ailus
2026-03-16 14:28   ` Laurent Pinchart
2026-03-10  8:46 ` [raw2rgbpnm PATCH v4 03/11] Add 10-bit CSI-2 packed format support Sakari Ailus
2026-03-16 14:38   ` Laurent Pinchart
2026-03-16 19:00     ` Sakari Ailus
2026-03-10  8:46 ` [raw2rgbpnm PATCH v4 04/11] Support long options and improve help text Sakari Ailus
2026-03-16 14:41   ` Laurent Pinchart
2026-03-17  9:49     ` Sakari Ailus
2026-03-17 10:49       ` Laurent Pinchart [this message]
2026-03-17 13:17         ` Sakari Ailus
2026-03-10  8:46 ` [raw2rgbpnm PATCH v4 05/11] Add "help" for listing formats and de-Bayering algos, document it Sakari Ailus
2026-03-16 14:44   ` Laurent Pinchart
2026-03-10  8:46 ` [raw2rgbpnm PATCH v4 06/11] The program has been called raw2rgbpnm, not yuv_to_rgbpnm awhile now Sakari Ailus
2026-03-16 14:46   ` Laurent Pinchart
2026-03-10  8:46 ` [raw2rgbpnm PATCH v4 07/11] Arrange headers alphabetically Sakari Ailus
2026-03-16 14:47   ` Laurent Pinchart
2026-03-10  8:46 ` [raw2rgbpnm PATCH v4 08/11] Add --stride (-S) option for setting stride Sakari Ailus
2026-03-16 14:50   ` Laurent Pinchart
2026-03-10  8:46 ` [raw2rgbpnm PATCH v4 09/11] Improve input validation Sakari Ailus
2026-03-16 14:54   ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260317104954.GA302774@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mehdi.djait@linux.intel.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomi.valkeinen@ideasonboard.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox