From patchwork Mon Oct 3 14:23:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 17503 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C5727C327C for ; Mon, 3 Oct 2022 14:24:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 611FE601C5; Mon, 3 Oct 2022 16:24:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664807048; bh=DKOUnhShlLbKrYV5cyjtaWMvckcaHAjGmf1dKW30C2g=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mPI8RaQTw5+j116Tz5IRs8bt2WMd1CBF6nJHM5FwJZcF3Kz5op+B32R9odbbNtzMJ 9ri31vpDHNZNQV1GPOkvxMgYlaKVoVuPcc/QZcmNufum8VzA4g9oFxgHZsEIQnUDIt hcvXXTvxXfzL1cE2wEWVov9kXHzrYAiVy+GvO19Mdsb1FzXruHTO4ZHhBLIVmQlc1F mmpUGb3hIx5+Dz3hQa0LoltsMzeIWT0r4Iwok+GaYG24/FZ3hASe6s9csqNjdPmWvn U315lkIeReMG8fOvEp+vheaLx6goyF0xDiTyG6gd2/kVe1MB6JUaCnSdO+WtWyvJ1J t1oLhNsq447Jg== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E571600E9 for ; Mon, 3 Oct 2022 16:24:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="qbCZPSwx"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id a10so4651968wrm.12 for ; Mon, 03 Oct 2022 07:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=1viFbPOyJM227fdqsP6Fo0vsMl1d6/JhNbzsfoPk6I4=; b=qbCZPSwxsR3kTAYEOssZomgR4WRaeXvkWTYoq5xZvW4iCpc+vPLhhGj+ks5ycg+KSA 3Wx/wJrA9dm8ki6FANFPkbhG0M7O6/VcblPFg9+AddOYChzV+84MCfDZYwvY3kkTjcec XwDl7yjUyuinGwPqIq5LAvI0yE2VKS/q+/0aDJsIArWplljW8zxacV+g/SnMVRNjr2Au 8dRQ0ZjgfW0H7plNs8L3gyMdmc2BAgaiq87QjSTKNPnlX53ppEg4DWVWsvXl82evgsQ+ Ib2RoY3RYlTOiYVSMMWo/hMn3JzNDm3oSo0WykVtVXxsRJALI83UEgNa3nHXXWs5V8H0 vAbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=1viFbPOyJM227fdqsP6Fo0vsMl1d6/JhNbzsfoPk6I4=; b=f2VDRhJM9Ex24j7XXsm1u+AMwMdZ6k6YoRF3vHiMjeeGFVoFqBfOrvqa7Ui3WPYaDJ WbCHgEsvq0lQ8yFOgDdCHRp8oT226ovR5v9D0xD+748iKgHFai36t0jWM+/zE6yXEBb4 IOI4ckRDzbL1ZioSdfjiFLvVaG/grQRdKuvpU9pTLnDGhBV5axd27VnWbpTTX5NV4Ylj wDDIshTUuStWTUUdryXG3gJJ3uN83teAkn9nGCOodJNt7Tt6VtMys0/sMqPuHW2GSAJ+ CYAiC1npVOGx/76RhfRm6hC19IUE5kC0vcXsBZm8jUCHIaKx8spO5FQwMWSbqbCLLA3P 3nDw== X-Gm-Message-State: ACrzQf2C9cZjZT/84xboXFWmV1O3N3Zeujrld6SV4qGqaZX0Uy7vy3Et tHZWXO3wc9gerd9PkhhZHldkJ5OUROTsLg== X-Google-Smtp-Source: AMsMyM7Mwmh52NdC9n6M0I9nnPSyx5D0vSu+B43zxrQDoSRvQ/ZeL0c+3XGxqFHpuIXrySpl7j8uMw== X-Received: by 2002:adf:fec6:0:b0:22e:3218:f7e1 with SMTP id q6-20020adffec6000000b0022e3218f7e1mr5800072wrs.522.1664807045699; Mon, 03 Oct 2022 07:24:05 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:b89c:8d5f:fc22:ea71]) by smtp.gmail.com with ESMTPSA id bt4-20020a056000080400b0022cd96b3ba6sm12814031wrb.90.2022.10.03.07.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 07:24:05 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 16:23:56 +0200 Message-Id: <20221003142357.602633-2-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221003142357.602633-1-fsylvestre@baylibre.com> References: <20221003142357.602633-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/2] ipa: rkisp1: Compute LSC algorithm parameter during configure X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Sylvestre via libcamera-devel From: Florian Sylvestre Reply-To: Florian Sylvestre Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" LSC gradient parameters are currently computed during prepare() phase. Because these parameters can be computed only one time and stay constant for each frame after, move the computation to the configure() function. Signed-off-by: Florian Sylvestre Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/lsc.cpp | 61 +++++++++++++++++-------------- src/ipa/rkisp1/algorithms/lsc.h | 4 ++ 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp index 102535bd..ad64aeb4 100644 --- a/src/ipa/rkisp1/algorithms/lsc.cpp +++ b/src/ipa/rkisp1/algorithms/lsc.cpp @@ -122,27 +122,12 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context, int LensShadingCorrection::configure(IPAContext &context, [[maybe_unused]] const IPACameraSensorInfo &configInfo) { - context.configuration.lsc.enabled = true; - return 0; -} - -/** - * \copydoc libcamera::ipa::Algorithm::prepare - */ -void LensShadingCorrection::prepare(IPAContext &context, const uint32_t frame, - [[maybe_unused]] IPAFrameContext &frameContext, - rkisp1_params_cfg *params) -{ - if (frame > 0) - return; - - struct rkisp1_cif_isp_lsc_config &config = params->others.lsc_config; const Size &size = context.configuration.sensor.size; Size totalSize{}; for (unsigned int i = 0; i < RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE; ++i) { - config.x_size_tbl[i] = xSize_[i] * size.width; - config.y_size_tbl[i] = ySize_[i] * size.height; + xSizes_[i] = xSize_[i] * size.width; + ySizes_[i] = ySize_[i] * size.height; /* * To prevent unexpected behavior of the ISP, the sum of x_size_tbl and @@ -151,25 +136,47 @@ void LensShadingCorrection::prepare(IPAContext &context, const uint32_t frame, * rounding-induced errors. */ if (i == RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE - 1) { - config.x_size_tbl[i] = size.width / 2 - totalSize.width; - config.y_size_tbl[i] = size.height / 2 - totalSize.height; + xSizes_[i] = size.width / 2 - totalSize.width; + ySizes_[i] = size.height / 2 - totalSize.height; } - totalSize.width += config.x_size_tbl[i]; - totalSize.height += config.y_size_tbl[i]; + totalSize.width += xSizes_[i]; + totalSize.height += ySizes_[i]; - config.x_grad_tbl[i] = std::round(32768 / config.x_size_tbl[i]); - config.y_grad_tbl[i] = std::round(32768 / config.y_size_tbl[i]); + xGrad_[i] = std::round(32768 / xSizes_[i]); + yGrad_[i] = std::round(32768 / ySizes_[i]); } + context.configuration.lsc.enabled = true; + return 0; +} + +/** + * \copydoc libcamera::ipa::Algorithm::prepare + */ +void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context, + const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + rkisp1_params_cfg *params) +{ + if (frame > 0) + return; + + struct rkisp1_cif_isp_lsc_config &config = params->others.lsc_config; + + memcpy(config.x_grad_tbl, xGrad_, sizeof(config.x_grad_tbl)); + memcpy(config.y_grad_tbl, yGrad_, sizeof(config.y_grad_tbl)); + memcpy(config.x_size_tbl, xSizes_, sizeof(config.x_size_tbl)); + memcpy(config.y_size_tbl, ySizes_, sizeof(config.y_size_tbl)); + std::copy(rData_.begin(), rData_.end(), - ¶ms->others.lsc_config.r_data_tbl[0][0]); + &config.r_data_tbl[0][0]); std::copy(grData_.begin(), grData_.end(), - ¶ms->others.lsc_config.gr_data_tbl[0][0]); + &config.gr_data_tbl[0][0]); std::copy(gbData_.begin(), gbData_.end(), - ¶ms->others.lsc_config.gb_data_tbl[0][0]); + &config.gb_data_tbl[0][0]); std::copy(bData_.begin(), bData_.end(), - ¶ms->others.lsc_config.b_data_tbl[0][0]); + &config.b_data_tbl[0][0]); params->module_en_update |= RKISP1_CIF_ISP_MODULE_LSC; params->module_ens |= RKISP1_CIF_ISP_MODULE_LSC; diff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h index 6c052669..da81ea53 100644 --- a/src/ipa/rkisp1/algorithms/lsc.h +++ b/src/ipa/rkisp1/algorithms/lsc.h @@ -33,6 +33,10 @@ private: std::vector xSize_; std::vector ySize_; + uint16_t xGrad_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; + uint16_t yGrad_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; + uint16_t xSizes_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; + uint16_t ySizes_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; }; } /* namespace ipa::rkisp1::algorithms */