From patchwork Wed Oct 6 14:00:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 14054 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 5EA52C323E for ; Wed, 6 Oct 2021 14:01:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E00C8691B6; Wed, 6 Oct 2021 16:01:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="otsK2Fqc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7161C6023D for ; Wed, 6 Oct 2021 16:01:00 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:843b:c831:54de:6e8c]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 124DCFFD; Wed, 6 Oct 2021 16:01:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1633528860; bh=wp2mtBkCWJ/KMsIULlgdp8anEXDjtWDqXmTYVyimxeM=; h=From:To:Cc:Subject:Date:From; b=otsK2Fqc+ENgxcvFlVHvDlS8U/5AGvHYQmGQwq7Hj1yjN/4Si1x2WX8HsRguqfFJ2 qKcGbZLpNAhHivlILey8Utyhs8g/qqAwW4X6S9F+BPUGd6FSPjLZGYnvVkRGrA89FD HR87BIpDvPgpnInD9dgZVDmoRAXF7zh49fPTC5Hg= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Oct 2021 16:00:30 +0200 Message-Id: <20211006140041.964542-1-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 00/12] Improve ImgU statistics usage 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" Hello everybody ! Here is a series, solving quite a few issues and clarifying most of the ImgU statistics format. Changes in v3: - renamed black_correction into blc and the class is now named BlackLevelCorrection - small comments adressed - Updated kernel patch in 12/12 in v2: - stride is now a IPASessionConfiguration parameter - Optical Black Correction is an algorithm The first part has already been sent before and was titled "Move and improve AWB structures" and those did not change since the latest v8 of it: - Patch 1/12 moves the AWB structures to be able to use those from the ipa::ipu3::algorithms namespace (by AGC at least). - Patch 2/12 renames the stats region structure to make it clear it is an accumulator structure. - Patch 3/12 is improving the Accumulator structure to have the same layout as the IPAFrameContext::awb structure. - Patch 4/12 is now only focusing on AWB name usage. We worked, together with Laurent (thanks !) on the AWB grid limits, and ImgU statistics format. There was differences between public API [0] and the kernel doc which needed clarifications (who is correct ?). After quite a few investigations, we discovered a bug in the kernel, for low resolutions [1] and this leads to patches 5/12 and 6/12, the latest reusing the proposal from Laurent in "ipa: ipu3: Split width and height loops in calculateBdsGrid()" but adapting it to the limit names. Next patches are here to solve bugs in AWB by configuring the proportion of unsaturated zones (7/12), using the right gain multipliers (8/12) and taking care of padding in the AWB loop (9/12). As we are improving AWB, I cherry-picked patch 10/12 from another branch already proposed before to use the black level correction in the ImgU with default values (probably good enough for now). Next, as AGC is using the AWB statistics for its algorithm, rewrite the loop to simplify it and take care of padding too (11/12). And we can finally move the Ipu3AwbCell out from the Awb class, to use it with the (yet to be in v2) patch from the kernel [2]. [0] https://chromium.googlesource.com/chromiumos/platform/arc-camera/+/refs/heads/master/hal/intel/include/ia_imaging/awb_public.h [1] https://lore.kernel.org/linux-media/20210916172504.677919-1-jeanmichel.hautbois@ideasonboard.com/ [2] https://lore.kernel.org/linux-media/20210831185140.77400-1-jeanmichel.hautbois@ideasonboard.com/ Jean-Michel Hautbois (12): ipa: ipu3: Move the AWB stats structures ipa: ipu3: Rename IspStatsRegion to Accumulator ipa: ipu3: Change Accumulator structure layout ipa: ipu3: awb: Make the naming consistent ipa: ipu3: Change the limits of the AWB stats ipa: ipu3: Change limits and split loops in calculateBdsGrid() ipa: ipu3: awb: Correct the relevant zones proportion ipa: ipu3: awb: Correct the gain multipliers ipa: ipu3: awb: Use the line stride for the stats ipa: ipu3: awb: Introduce Black Level Correction ipa: ipu3: agc: Rewrite and simplify the brightness loop ipa: ipu3: Replace ipa::ipu3::algorithms::Ipu3AwbCell include/linux/intel-ipu3.h | 32 ++++- src/ipa/ipu3/algorithms/agc.cpp | 52 +++----- src/ipa/ipu3/algorithms/agc.h | 2 + src/ipa/ipu3/algorithms/awb.cpp | 199 ++++++++++++++++------------ src/ipa/ipu3/algorithms/awb.h | 42 +++--- src/ipa/ipu3/algorithms/blc.cpp | 66 +++++++++ src/ipa/ipu3/algorithms/blc.h | 28 ++++ src/ipa/ipu3/algorithms/meson.build | 1 + src/ipa/ipu3/ipa_context.h | 1 + src/ipa/ipu3/ipu3.cpp | 78 +++++++---- 10 files changed, 330 insertions(+), 171 deletions(-) create mode 100644 src/ipa/ipu3/algorithms/blc.cpp create mode 100644 src/ipa/ipu3/algorithms/blc.h