[{"id":16971,"web_url":"https://patchwork.libcamera.org/comment/16971/","msgid":"<CAO5uPHMt_s0Lj_JJbvmzLv-oB-4XAm4cTCBQ47E__TRJJ0PjCw@mail.gmail.com>","date":"2021-05-17T03:58:56","subject":"Re: [libcamera-devel] [PATCH v3 4/8] libcamera: ipu3: imgu: Fix BDS\n\theight calculation","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Jacopo, thank you for the patch.\n\nOn Fri, May 14, 2021 at 12:20 AM Jacopo Mondi <jacopo@jmondi.org> wrote:\n\n> The IF rectangle height is iteratively computed by first subtracting\n> the scaling factor to the estimated height, then in a successive loop\n> by adding the same scaling factor until the maximum IF size is not\n> reached.\n>\n> As the computed IF height is not cached in any variable, the second\n> loop over-writes the result of the first one, even if the BDS alignment\n> condition is not satisfied.\n>\n> Fix this by caching the result of the two iterations, and use the one\n> that produced any result, with a preference for the one produced by the\n> second loop, as implemented in the reference python script.\n>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n>\n\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n\n>\n\n> ---\n>  src/libcamera/pipeline/ipu3/imgu.cpp | 10 +++++-----\n>  1 file changed, 5 insertions(+), 5 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp\n> b/src/libcamera/pipeline/ipu3/imgu.cpp\n> index d878a029ad84..a325b787d916 100644\n> --- a/src/libcamera/pipeline/ipu3/imgu.cpp\n> +++ b/src/libcamera/pipeline/ipu3/imgu.cpp\n> @@ -129,10 +129,10 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe,\n> const Size &iif, const Size &gdc\n>         float bdsHeight;\n>\n>         if (!isSameRatio(pipe->input, gdc)) {\n> +               unsigned int foundIfHeight = 0;\n>                 float estIFHeight = (iif.width * gdc.height) /\n>                                     static_cast<float>(gdc.width);\n>                 estIFHeight = std::clamp<float>(estIFHeight, minIFHeight,\n> iif.height);\n> -               bool found = false;\n>\n>                 ifHeight = utils::alignUp(estIFHeight, IF_ALIGN_H);\n>                 while (ifHeight >= minIFHeight && ifHeight / bdsSF >=\n> minBDSHeight) {\n> @@ -142,7 +142,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const\n> Size &iif, const Size &gdc\n>                                 unsigned int bdsIntHeight =\n> static_cast<unsigned int>(bdsHeight);\n>\n>                                 if (!(bdsIntHeight % BDS_ALIGN_H)) {\n> -                                       found = true;\n> +                                       foundIfHeight = ifHeight;\n>                                         break;\n>                                 }\n>                         }\n> @@ -158,7 +158,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const\n> Size &iif, const Size &gdc\n>                                 unsigned int bdsIntHeight =\n> static_cast<unsigned int>(bdsHeight);\n>\n>                                 if (!(bdsIntHeight % BDS_ALIGN_H)) {\n> -                                       found = true;\n> +                                       foundIfHeight = ifHeight;\n>                                         break;\n>                                 }\n>                         }\n> @@ -166,10 +166,10 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe,\n> const Size &iif, const Size &gdc\n>                         ifHeight += IF_ALIGN_H;\n>                 }\n>\n> -               if (found) {\n> +               if (foundIfHeight) {\n>                         unsigned int bdsIntHeight = static_cast<unsigned\n> int>(bdsHeight);\n>\n> -                       pipeConfigs.push_back({ bdsSF, { iif.width,\n> ifHeight },\n> +                       pipeConfigs.push_back({ bdsSF, { iif.width,\n> foundIfHeight },\n>                                                 { bdsWidth, bdsIntHeight\n> }, gdc });\n>                         return;\n>                 }\n> --\n> 2.31.1\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 81B28C31FB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 May 2021 03:59:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4B3DB602B1;\n\tMon, 17 May 2021 05:59:08 +0200 (CEST)","from mail-ed1-x533.google.com (mail-ed1-x533.google.com\n\t[IPv6:2a00:1450:4864:20::533])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 49C75602B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 May 2021 05:59:07 +0200 (CEST)","by mail-ed1-x533.google.com with SMTP id s6so5115202edu.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 16 May 2021 20:59:07 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"nxHvByXR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=3O97/Py3GJWUewTDNPpAKeZi5fmCFZl09B4R1j6p9lg=;\n\tb=nxHvByXRn7xLTNJYSqZXl0CdhMJxMmzj/iCwv/82PcP2kE/7hYglP3vV9D2IEdGmL4\n\tzRIS7nUKwO/oaA1/8sxB5SG7T85JDfDjt9xXDVU8G82UiKIARYHx6BCa3dqz+zdhgRAn\n\tMfeXQ5OUmN94sUdvwG9ey6UqyRgajuaNAHKis=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=3O97/Py3GJWUewTDNPpAKeZi5fmCFZl09B4R1j6p9lg=;\n\tb=h1RDbuj+CmEEPcNqhfN27GDk+PbVcfKQ2Ch4gYkoOgZlnACXqtb/EeaedPPdjFnxAj\n\tswovhp3R5UL3fgNS0KOUViMYjLyVWXpvClUXRD1CvkCdiPlHK0fNp6zVUeCwqvnGA5Jg\n\tANCbeahSU4sQ2MkIoKV2NEXj+Swe+6+qBwATo7dGsq97O0X+fy3FTMIs8GawFtb95r6V\n\tvX3bnsLreAChJDd7fYvsY32hWN42eNfBGvcQf8hhao/3pPLMVvGyd1pfEVPdJgLIKT4m\n\txz8rqECZlai2GRrqzz5+BvACCQ8fUqXzYtKgohsFmyLqDFy8L5lkF6dWm8FK5cxXAPvb\n\tcuAA==","X-Gm-Message-State":"AOAM533lVPKc+pcR3qMuOad5+72jX0XyBIgUIJW4vQRVQ6l4mFkPuf5g\n\tw4Vw212W6Wygy5KOUNjIJ7A22DUCLfzZjhlYIoSGIjyDw/WyIg==","X-Google-Smtp-Source":"ABdhPJztaLPJ3gJRfbhnDiuYyJLzTJVo2Ys+NjRpXAWwc49UqAaviPPkWrwB0Ln4D49jjreOrcL2u/PrV2CFGUVceOQ=","X-Received":"by 2002:a05:6402:3585:: with SMTP id\n\ty5mr69260305edc.233.1621223947039; \n\tSun, 16 May 2021 20:59:07 -0700 (PDT)","MIME-Version":"1.0","References":"<20210513152116.17666-1-jacopo@jmondi.org>\n\t<20210513152116.17666-5-jacopo@jmondi.org>","In-Reply-To":"<20210513152116.17666-5-jacopo@jmondi.org>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 17 May 2021 12:58:56 +0900","Message-ID":"<CAO5uPHMt_s0Lj_JJbvmzLv-oB-4XAm4cTCBQ47E__TRJJ0PjCw@mail.gmail.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Content-Type":"multipart/alternative; boundary=\"00000000000077085605c27e9d26\"","Subject":"Re: [libcamera-devel] [PATCH v3 4/8] libcamera: ipu3: imgu: Fix BDS\n\theight calculation","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]