From patchwork Thu Sep 29 09:12:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 17461 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 C7F8EC327E for ; Thu, 29 Sep 2022 09:12:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 768A562385; Thu, 29 Sep 2022 11:12:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664442773; bh=/nXzcIwh0WjaDeVdEBkTG/iCyOsx3J39uCvha8qjNGQ=; 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=MgIPHs3H6c9J3PG6QT+yvPHCy/WZ7qe3FjJl81xgMHS+rSFVFZglbhKeBMMoKTY+Q Mlo7kHFJrhvDa6KZrGGBg3Q4VJmnxE7bWmmTJLKPwIdSY9RbOIDM1bIcTi0nNtmjUn R4RyH3Ggq44M6UTVN8qmNxU7kxPiTZjn/X+62bLqyoE7c+QMxkkLXuyxCylhVZ7C3a pIYf5KVzkYmPHGmXaAsS2wSoHtC9Jj/l5t+WprHC0ReSNwQrN+zqJg1uPpwoQXDN84 VL/gF2YYfyiQid68b9GEY9JXeIrU2gd/Za8yomazoxPNhNkQ0e2dgXkSRkKE3hBddo +FwXOQJMr2SGg== Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CF4B86237B for ; Thu, 29 Sep 2022 11:12:50 +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="33x4sdSy"; dkim-atps=neutral Received: by mail-wm1-x332.google.com with SMTP id l8so515271wmi.2 for ; Thu, 29 Sep 2022 02:12:50 -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=/mGt/gGFBqmEZ4w4ZlbeLCfqAr4w+gUPiNzwljHm4Nw=; b=33x4sdSyu5xCK74B3vFJA9lTPrTdBkNdLZdlapQ7dLlabS74gXxLeLDOrazZv/BSvn 1fJukvBjF8fwGbrBaqbULDEveYr4RNVcHZJn9bggZ0rdkpK6lmNMI45W/i16zH5WzHFM iOBrVORwgeqzNu0OieSbPjDqGvq5njNRHZpM/weA6umiInePvt3Yo3pNU2e5Jsr8H/pY WaBUEyBhSfkIJAG4S3emfTLc20K4D/Ft2jrHAYJrgnhdT9Q/U6YkJ7BOnm7Al+/Ww4nE kCMUWjcJnYpEbJgQDEP18s/8ieR+z7X+F6YNOsasP9ExoGtB36FTWTIfBqAc5qJv5pXt seQA== 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=/mGt/gGFBqmEZ4w4ZlbeLCfqAr4w+gUPiNzwljHm4Nw=; b=ld8qkHLXjxUS4S4X9savrWdnkrxuUafTpvBmtwZFobXAhCgjhrHKd/SQr0kRCzhtbA XSNqS0LhX6oakfWhEHLevbNqzDQqkgqx9b8GYcahsMsuCVh9P07/x0SW7dmYCIZOQpa/ QMHWB6W6MQOnbKFvHqa3YqCbsTMGSQiD66WQtJgZ8Y+fMPbLKA3hbOn1S0RZd3LsryGP WU+T4LP8wVqU5XJzROSFKkvFwMlm6fCakd6sWZk9SBVG4+MBuGGbSMTUBUhsNXht+OuQ g/vUWdbUmDOpIQHVA/sHihihhfKc09u+4CaQOSUkdncGKH3wMYaE9mRC977wd1N1wIWe rsgg== X-Gm-Message-State: ACrzQf2ZaqxzQmMu6Ictg4uzOVW2RSmkg7fyoqAnyS7es2bI8GelhDJk 08HnNn4UFdNpi2/HsD//hUUCTJahFzKUjw== X-Google-Smtp-Source: AMsMyM4PDZnsIT2ejEJGmPM10zI9RKAyAWWlkK0GAP9YzMOAIi4gBF6H2i3/MQASB5ARq/l4Y9G2SA== X-Received: by 2002:a05:600c:a48:b0:3b3:3256:63c with SMTP id c8-20020a05600c0a4800b003b33256063cmr1477117wmq.34.1664442770253; Thu, 29 Sep 2022 02:12:50 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:71fe:49b1:81cf:acfb]) by smtp.gmail.com with ESMTPSA id g15-20020a5d554f000000b0022cc7c32309sm2454588wrw.115.2022.09.29.02.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 02:12:49 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 29 Sep 2022 11:12:44 +0200 Message-Id: <20220929091245.2159838-2-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220929091245.2159838-1-fsylvestre@baylibre.com> References: <20220929091245.2159838-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 where initially computed during prepare() phase. Because these parameters can be computed only one time and stays 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 --- src/ipa/rkisp1/algorithms/lsc.cpp | 66 ++++++++++++++++++------------- src/ipa/rkisp1/algorithms/lsc.h | 4 ++ 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp index 44245caa..b1f39dfd 100644 --- a/src/ipa/rkisp1/algorithms/lsc.cpp +++ b/src/ipa/rkisp1/algorithms/lsc.cpp @@ -125,30 +125,15 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context, int LensShadingCorrection::configure(IPAContext &context, [[maybe_unused]] const IPACameraSensorInfo &configInfo) { - context.configuration.lsc.enabled = initialized_; - 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; - if (!initialized_) - return; + return EINVAL; - 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 @@ -157,25 +142,50 @@ 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; + + if (!initialized_) + 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 da957d3e..b5cd5047 100644 --- a/src/ipa/rkisp1/algorithms/lsc.h +++ b/src/ipa/rkisp1/algorithms/lsc.h @@ -35,6 +35,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 */