From patchwork Fri Jul 12 14:32:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20660 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 E14B5BD87C for ; Fri, 12 Jul 2024 14:32:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D3C1F63372; Fri, 12 Jul 2024 16:32:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SrCvfnB3"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E7B063372 for ; Fri, 12 Jul 2024 16:32:52 +0200 (CEST) Received: from ideasonboard.com (unknown [94.31.101.36]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0D540735; Fri, 12 Jul 2024 16:32:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720794738; bh=1gZQWRmZ893KdtpMNUXNhK9auXPX4O9wMFNsd0gwQuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SrCvfnB3gHXuASzNt0mciO8ldePGwqf4cj4+uBvdUJXmC2yLc5OhFntrhKg+cHmKK gHilq/0R2/4UdncYHW+MO9H6uCcyrBf7d04vfU1lz8+McCkDAuKBjuHWQ3tKaYXcrL s4zBw12tY2QOO11l3xREbK5rOSj1lSQtfNknaO3A= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 5/5] ipa: rkisp1: ccm: Ensure metadata contains valid ccm Date: Fri, 12 Jul 2024 16:32:06 +0200 Message-ID: <20240712143227.3036702-6-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240712143227.3036702-1-stefan.klug@ideasonboard.com> References: <20240712143227.3036702-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When the colour temperature does not change between frames, the ccm inside the frame context is not updated and the metadata contains invalid data. Fix that by caching the ccm inside the active state. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/ccm.cpp | 7 +++++-- src/ipa/rkisp1/ipa_context.h | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp index 4c4e3f5029a4..e9b1e78b7ec1 100644 --- a/src/ipa/rkisp1/algorithms/ccm.cpp +++ b/src/ipa/rkisp1/algorithms/ccm.cpp @@ -101,7 +101,7 @@ void Ccm::setParameters(rkisp1_params_cfg *params, /** * \copydoc libcamera::ipa::Algorithm::prepare */ -void Ccm::prepare(IPAContext &context, const uint32_t frame, +void Ccm::prepare([[maybe_unused]] IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, rkisp1_params_cfg *params) { @@ -111,13 +111,16 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame, * \todo The colour temperature will likely be noisy, add filtering to * avoid updating the CCM matrix all the time. */ - if (frame > 0 && ct == ct_) + if (frame > 0 && ct == ct_) { + frameContext.ccm.ccm = context.activeState.ccm.ccm; return; + } ct_ = ct; Matrix ccm = ccm_.get(ct); Matrix offsets = offsets_.get(ct); + context.activeState.ccm.ccm = ccm; frameContext.ccm.ccm = ccm; setParameters(params, ccm, offsets); diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 27a9bf62fc16..061efc0c578e 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -97,6 +97,10 @@ struct IPAActiveState { bool autoEnabled; } awb; + struct { + Matrix ccm; + } ccm; + struct { int8_t brightness; uint8_t contrast;