[{"id":25565,"web_url":"https://patchwork.libcamera.org/comment/25565/","msgid":"<20221025015340.GJ3874866@pyrite.rasen.tech>","date":"2022-10-25T01:53:40","subject":"Re: [libcamera-devel] [PATCH v3 1/2] ipa: rkisp1: Compute LSC\n\talgorithm parameter during configure","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"On Mon, Oct 03, 2022 at 04:23:56PM +0200, Florian Sylvestre via libcamera-devel wrote:\n> LSC gradient parameters are currently computed during prepare() phase.\n> Because these parameters can be computed only one time and stay constant for\n> each frame after, move the computation to the configure() function.\n> \n> Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nLooks good to me.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/ipa/rkisp1/algorithms/lsc.cpp | 61 +++++++++++++++++--------------\n>  src/ipa/rkisp1/algorithms/lsc.h   |  4 ++\n>  2 files changed, 38 insertions(+), 27 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\n> index 102535bd..ad64aeb4 100644\n> --- a/src/ipa/rkisp1/algorithms/lsc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n> @@ -122,27 +122,12 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,\n>  int LensShadingCorrection::configure(IPAContext &context,\n>  \t\t\t\t     [[maybe_unused]] const IPACameraSensorInfo &configInfo)\n>  {\n> -\tcontext.configuration.lsc.enabled = true;\n> -\treturn 0;\n> -}\n> -\n> -/**\n> - * \\copydoc libcamera::ipa::Algorithm::prepare\n> - */\n> -void LensShadingCorrection::prepare(IPAContext &context, const uint32_t frame,\n> -\t\t\t\t    [[maybe_unused]] IPAFrameContext &frameContext,\n> -\t\t\t\t    rkisp1_params_cfg *params)\n> -{\n> -\tif (frame > 0)\n> -\t\treturn;\n> -\n> -\tstruct rkisp1_cif_isp_lsc_config &config = params->others.lsc_config;\n>  \tconst Size &size = context.configuration.sensor.size;\n>  \tSize totalSize{};\n>  \n>  \tfor (unsigned int i = 0; i < RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE; ++i) {\n> -\t\tconfig.x_size_tbl[i] = xSize_[i] * size.width;\n> -\t\tconfig.y_size_tbl[i] = ySize_[i] * size.height;\n> +\t\txSizes_[i] = xSize_[i] * size.width;\n> +\t\tySizes_[i] = ySize_[i] * size.height;\n>  \n>  \t\t/*\n>  \t\t * To prevent unexpected behavior of the ISP, the sum of x_size_tbl and\n> @@ -151,25 +136,47 @@ void LensShadingCorrection::prepare(IPAContext &context, const uint32_t frame,\n>  \t\t * rounding-induced errors.\n>  \t\t */\n>  \t\tif (i == RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE - 1) {\n> -\t\t\tconfig.x_size_tbl[i] = size.width / 2 - totalSize.width;\n> -\t\t\tconfig.y_size_tbl[i] = size.height / 2 - totalSize.height;\n> +\t\t\txSizes_[i] = size.width / 2 - totalSize.width;\n> +\t\t\tySizes_[i] = size.height / 2 - totalSize.height;\n>  \t\t}\n>  \n> -\t\ttotalSize.width += config.x_size_tbl[i];\n> -\t\ttotalSize.height += config.y_size_tbl[i];\n> +\t\ttotalSize.width += xSizes_[i];\n> +\t\ttotalSize.height += ySizes_[i];\n>  \n> -\t\tconfig.x_grad_tbl[i] = std::round(32768 / config.x_size_tbl[i]);\n> -\t\tconfig.y_grad_tbl[i] = std::round(32768 / config.y_size_tbl[i]);\n> +\t\txGrad_[i] = std::round(32768 / xSizes_[i]);\n> +\t\tyGrad_[i] = std::round(32768 / ySizes_[i]);\n>  \t}\n>  \n> +\tcontext.configuration.lsc.enabled = true;\n> +\treturn 0;\n> +}\n> +\n> +/**\n> + * \\copydoc libcamera::ipa::Algorithm::prepare\n> + */\n> +void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,\n> +\t\t\t\t    const uint32_t frame,\n> +\t\t\t\t    [[maybe_unused]] IPAFrameContext &frameContext,\n> +\t\t\t\t    rkisp1_params_cfg *params)\n> +{\n> +\tif (frame > 0)\n> +\t\treturn;\n> +\n> +\tstruct rkisp1_cif_isp_lsc_config &config = params->others.lsc_config;\n> +\n> +\tmemcpy(config.x_grad_tbl, xGrad_, sizeof(config.x_grad_tbl));\n> +\tmemcpy(config.y_grad_tbl, yGrad_, sizeof(config.y_grad_tbl));\n> +\tmemcpy(config.x_size_tbl, xSizes_, sizeof(config.x_size_tbl));\n> +\tmemcpy(config.y_size_tbl, ySizes_, sizeof(config.y_size_tbl));\n> +\n>  \tstd::copy(rData_.begin(), rData_.end(),\n> -\t\t  &params->others.lsc_config.r_data_tbl[0][0]);\n> +\t\t  &config.r_data_tbl[0][0]);\n>  \tstd::copy(grData_.begin(), grData_.end(),\n> -\t\t  &params->others.lsc_config.gr_data_tbl[0][0]);\n> +\t\t  &config.gr_data_tbl[0][0]);\n>  \tstd::copy(gbData_.begin(), gbData_.end(),\n> -\t\t  &params->others.lsc_config.gb_data_tbl[0][0]);\n> +\t\t  &config.gb_data_tbl[0][0]);\n>  \tstd::copy(bData_.begin(), bData_.end(),\n> -\t\t  &params->others.lsc_config.b_data_tbl[0][0]);\n> +\t\t  &config.b_data_tbl[0][0]);\n>  \n>  \tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_LSC;\n>  \tparams->module_ens |= RKISP1_CIF_ISP_MODULE_LSC;\n> diff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h\n> index 6c052669..da81ea53 100644\n> --- a/src/ipa/rkisp1/algorithms/lsc.h\n> +++ b/src/ipa/rkisp1/algorithms/lsc.h\n> @@ -33,6 +33,10 @@ private:\n>  \n>  \tstd::vector<double> xSize_;\n>  \tstd::vector<double> ySize_;\n> +\tuint16_t xGrad_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];\n> +\tuint16_t yGrad_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];\n> +\tuint16_t xSizes_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];\n> +\tuint16_t ySizes_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];\n>  };\n>  \n>  } /* namespace ipa::rkisp1::algorithms */\n> -- \n> 2.34.1\n> \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 00E34BDB16\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Oct 2022 01:53:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0D1D462F2E;\n\tTue, 25 Oct 2022 03:53:49 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B60DF62EAE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Oct 2022 03:53:47 +0200 (CEST)","from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 197288A9;\n\tTue, 25 Oct 2022 03:53:45 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666662829;\n\tbh=hCsYQKSYActaVAJROwQY0Zj+Tx7/2KOTVKW3oyA9/f4=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=paNkUSS02ThVIbANpW47gDWebvFmZGmIbktzayVjrV2hI3SCOnuOnF0LmcUpn2Ugb\n\tF6Djr5O8pW0mp5FatAJU/CPx5+WrRZKx7Gbm5Cadp9P1eRwodTPVwDYTCvZ2uRil+a\n\tBb3ozEaf6wdbN6iCggkAwTUg2Npq9FYl9HK5nTE1vS2thYyOktGAVh+LuV8hahuLQc\n\tWCdbFGn3PiNqNQaVvwd5idn1MCxA+BfHeB/plce8IdLFLw1clHAgG/hI2mpSkExSBQ\n\tfF+Ng65kXHAqwpC+0cr2DvzhJVpOEJY44tCHcwxwA7y8s5sEYaqdkyj1oEeYzZjm1f\n\tu837WHLyZU1ZA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1666662827;\n\tbh=hCsYQKSYActaVAJROwQY0Zj+Tx7/2KOTVKW3oyA9/f4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=MVG65lCFvBiRdfUbYMjGL6mvYM8WNtKsFGJtiXuYGTMFcfyfBT06J1rNMnwsbtw++\n\txWVuxO2B4P7Q76jV6TA9N90Y18hxlsfM0CzHaqQ5nrUpRxFvexXaDt5/qNar9Z1otr\n\tl7KbWhbAjV5WxdGtoe67NeUqNs8M0ya5UWUxZYq8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"MVG65lCF\"; dkim-atps=neutral","Date":"Tue, 25 Oct 2022 10:53:40 +0900","To":"Florian Sylvestre <fsylvestre@baylibre.com>","Message-ID":"<20221025015340.GJ3874866@pyrite.rasen.tech>","References":"<20221003142357.602633-1-fsylvestre@baylibre.com>\n\t<20221003142357.602633-2-fsylvestre@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20221003142357.602633-2-fsylvestre@baylibre.com>","Subject":"Re: [libcamera-devel] [PATCH v3 1/2] ipa: rkisp1: Compute LSC\n\talgorithm parameter during configure","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]