<div dir="ltr"><div dir="ltr">Hi Jacopo, thank you for the patch.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 14, 2021 at 12:20 AM Jacopo Mondi <<a href="mailto:jacopo@jmondi.org">jacopo@jmondi.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The IF rectangle height is iteratively computed by first subtracting<br>
the scaling factor to the estimated height, then in a successive loop<br>
by adding the same scaling factor until the maximum IF size is not<br>
reached.<br>
<br>
As the computed IF height is not cached in any variable, the second<br>
loop over-writes the result of the first one, even if the BDS alignment<br>
condition is not satisfied.<br>
<br>
Fix this by caching the result of the two iterations, and use the one<br>
that produced any result, with a preference for the one produced by the<br>
second loop, as implemented in the reference python script.<br>
<br>
Signed-off-by: Jacopo Mondi <<a href="mailto:jacopo@jmondi.org" target="_blank">jacopo@jmondi.org</a>><br>
Tested-by: Jean-Michel Hautbois <<a href="mailto:jeanmichel.hautbois@ideasonboard.com" target="_blank">jeanmichel.hautbois@ideasonboard.com</a>><br>
Reviewed-by: Jean-Michel Hautbois <<a href="mailto:jeanmichel.hautbois@ideasonboard.com" target="_blank">jeanmichel.hautbois@ideasonboard.com</a>><br>
Reviewed-by: Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.com</a>><br>
Reviewed-by: Niklas Söderlund <<a href="mailto:niklas.soderlund@ragnatech.se" target="_blank">niklas.soderlund@ragnatech.se</a>><br></blockquote><div><br></div><div>Reviewed-by: Hirokazu Honda <<a href="mailto:hiroh@chromium.org">hiroh@chromium.org</a>> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
 src/libcamera/pipeline/ipu3/imgu.cpp | 10 +++++-----<br>
 1 file changed, 5 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp<br>
index d878a029ad84..a325b787d916 100644<br>
--- a/src/libcamera/pipeline/ipu3/imgu.cpp<br>
+++ b/src/libcamera/pipeline/ipu3/imgu.cpp<br>
@@ -129,10 +129,10 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc<br>
        float bdsHeight;<br>
<br>
        if (!isSameRatio(pipe->input, gdc)) {<br>
+               unsigned int foundIfHeight = 0;<br>
                float estIFHeight = (iif.width * gdc.height) /<br>
                                    static_cast<float>(gdc.width);<br>
                estIFHeight = std::clamp<float>(estIFHeight, minIFHeight, iif.height);<br>
-               bool found = false;<br>
<br>
                ifHeight = utils::alignUp(estIFHeight, IF_ALIGN_H);<br>
                while (ifHeight >= minIFHeight && ifHeight / bdsSF >= minBDSHeight) {<br>
@@ -142,7 +142,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc<br>
                                unsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);<br>
<br>
                                if (!(bdsIntHeight % BDS_ALIGN_H)) {<br>
-                                       found = true;<br>
+                                       foundIfHeight = ifHeight;<br>
                                        break;<br>
                                }<br>
                        }<br>
@@ -158,7 +158,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc<br>
                                unsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);<br>
<br>
                                if (!(bdsIntHeight % BDS_ALIGN_H)) {<br>
-                                       found = true;<br>
+                                       foundIfHeight = ifHeight;<br>
                                        break;<br>
                                }<br>
                        }<br>
@@ -166,10 +166,10 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc<br>
                        ifHeight += IF_ALIGN_H;<br>
                }<br>
<br>
-               if (found) {<br>
+               if (foundIfHeight) {<br>
                        unsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);<br>
<br>
-                       pipeConfigs.push_back({ bdsSF, { iif.width, ifHeight },<br>
+                       pipeConfigs.push_back({ bdsSF, { iif.width, foundIfHeight },<br>
                                                { bdsWidth, bdsIntHeight }, gdc });<br>
                        return;<br>
                }<br>
-- <br>
2.31.1<br>
<br>
_______________________________________________<br>
libcamera-devel mailing list<br>
<a href="mailto:libcamera-devel@lists.libcamera.org" target="_blank">libcamera-devel@lists.libcamera.org</a><br>
<a href="https://lists.libcamera.org/listinfo/libcamera-devel" rel="noreferrer" target="_blank">https://lists.libcamera.org/listinfo/libcamera-devel</a><br>
</blockquote></div></div>