[libcamera-devel] [PATCH 04/10] libcamera: ipu3: Propagate image format
Jacopo Mondi
jacopo at jmondi.org
Mon Mar 11 19:11:01 CET 2019
Hi Laurent,
two updates so that v2 comes with no surprises
On Sun, Mar 03, 2019 at 12:44:23AM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
[snip]
> > + for (SizeRange &size : it->second) {
> > + if (size.maxWidth < config.width ||
> > + size.maxHeight < config.height)
> > + continue;
> > +
> > + unsigned int diff =
> > + (abs(size.maxWidth - config.width) +
> > + abs(size.maxHeight - config.height));
>
> No need for abs() as you check that maxWidth >= config.width above.
>
> Should you use the difference of area instead of the difference of
> lengths ?
>
I suggested moving this to geometry, but as in this pipeline
implementation we often compare SizeRanges with other structure, it's
actually nicer to calculate areas here directly. It's a basic
multiplication after all...
> > + if (diff >= best)
> > + continue;
> > +
> > + best = diff;
> > + found = true;
>
> No need for the found variable, you can just check best != -1.
>
I went down a path of casts between signed and unsigned int this way.
I'm keeping the extra variable.
Thanks
j
> > +
> > + format->width = size.maxWidth;
> > + format->height = size.maxHeight;
> > + format->mbus_code = it->first;
> > + }
> > +
> > + ++it;
> > + }
> > + if (!found)
> > + return -EINVAL;
> > +
> > + ret = sensor->setFormat(0, format);
> > + if (ret)
> > + return ret;
> > +
> > + /*
> > + * Make sure everything is all right and the format did not get
> > + * adjusted.
> > + */
> > + if (format->width < config.width ||
> > + format->height < config.height)
> > + return -EINVAL;
> > +
> > + return 0;
> > +}
> > +
> > /* Link entities in the ImgU unit to prepare for capture operations. */
> > int PipelineHandlerIPU3::linkImgu(ImguDevice *imguDevice)
> > {
>
> --
> Regards,
>
> Laurent Pinchart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20190311/49058f0f/attachment.sig>
More information about the libcamera-devel
mailing list