[libcamera-devel] [PATCH v2 1/7] libcamera: ipu3: imgu: Update BDS calculation process
Hirokazu Honda
hiroh at chromium.org
Thu May 6 07:34:30 CEST 2021
Hi Jacopo, thank you for the patch.
On Mon, May 3, 2021 at 7:56 PM Niklas Söderlund <
niklas.soderlund at ragnatech.se> wrote:
> Hi Jacopo,
>
> Thanks for your work.
>
> On 2021-05-03 11:26:59 +0200, Jacopo Mondi wrote:
> > Apply the last three hunks of commit 243d134 ("Fix some bug for some
> > resolutions") from https://github.com/intel/intel-ipu3-pipecfg.git
> > to the BDS calculation procedure.
> >
> > The BDS calculation is now perfomed by scaling both width and height,
> > and repeated by scaling width first.
> >
> > Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
> > Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
> > Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
>
> Acked-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
>
> > ---
> > src/libcamera/pipeline/ipu3/imgu.cpp | 34 ++++++++++++++++++++++++----
> > 1 file changed, 29 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp
> b/src/libcamera/pipeline/ipu3/imgu.cpp
> > index d5cf05b0c421..8373dc165a61 100644
> > --- a/src/libcamera/pipeline/ipu3/imgu.cpp
> > +++ b/src/libcamera/pipeline/ipu3/imgu.cpp
> > @@ -394,19 +394,43 @@ ImgUDevice::PipeConfig
> ImgUDevice::calculatePipeConfig(Pipe *pipe)
> > const Size &in = pipe->input;
> > Size gdc = calculateGDC(pipe);
> >
> > - unsigned int ifWidth = utils::alignUp(in.width, IF_ALIGN_W);
> > - unsigned int ifHeight = in.height;
> > - unsigned int minIfWidth = in.width - IF_CROP_MAX_W;
> > float bdsSF = static_cast<float>(in.width) / gdc.width;
> > float sf = findScaleFactor(bdsSF, bdsScalingFactors, true);
> >
> > + /* Populate the configurations vector by scaling width and height.
> */
> > + unsigned int ifWidth = utils::alignUp(in.width, IF_ALIGN_W);
> > + unsigned int ifHeight = utils::alignUp(in.height, IF_ALIGN_H);
> > + unsigned int minIfWidth = in.width - IF_CROP_MAX_W;
> > + unsigned int minIfHeight = in.height - IF_CROP_MAX_H;
>
Should we std::max(0u, in.width - IF_CROP_MAX_W)?
If in.width < IF_CROP_MAX_W, an overflow happens and minIfWidth becomes
very large.
Ditto to height.
> > while (ifWidth >= minIfWidth) {
> > - Size iif{ ifWidth, ifHeight };
> > - calculateBDS(pipe, iif, gdc, sf);
> > + while (ifHeight >= minIfHeight) {
> > + Size iif{ ifWidth, ifHeight };
> > + calculateBDS(pipe, iif, gdc, sf);
> > + ifHeight -= IF_ALIGN_H;
> > + }
> >
> > ifWidth -= IF_ALIGN_W;
> > }
> >
> > + /* Repeat search by scaling width first. */
> > + ifWidth = utils::alignUp(in.width, IF_ALIGN_W);
> > + ifHeight = utils::alignUp(in.height, IF_ALIGN_H);
> > + minIfWidth = in.width - IF_CROP_MAX_W;
> > + minIfHeight = in.height - IF_CROP_MAX_H;
> > + while (ifHeight >= minIfHeight) {
> > + /*
> > + * \todo This procedure is probably broken:
> > + * https://github.com/intel/intel-ipu3-pipecfg/issues/2
> > + */
> > + while (ifWidth >= minIfWidth) {
> > + Size iif{ ifWidth, ifHeight };
> > + calculateBDS(pipe, iif, gdc, sf);
> > + ifWidth -= IF_ALIGN_W;
> > + }
> > +
> > + ifHeight -= IF_ALIGN_H;
> > + }
> > +
> > if (pipeConfigs.size() == 0) {
> > LOG(IPU3, Error) << "Failed to calculate pipe
> configuration";
> > return {};
> > --
> > 2.31.1
> >
> > _______________________________________________
> > libcamera-devel mailing list
> > libcamera-devel at lists.libcamera.org
> > https://lists.libcamera.org/listinfo/libcamera-devel
>
> --
> Regards,
> Niklas Söderlund
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20210506/42e4d51d/attachment.htm>
More information about the libcamera-devel
mailing list