From patchwork Thu Sep 30 09:37:03 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: 13983 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 EC59FBDC71 for ; Thu, 30 Sep 2021 09:37:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8B8AF691B2; Thu, 30 Sep 2021 11:37:20 +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="viAfveSs"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9CD5A69189 for ; Thu, 30 Sep 2021 11:37:19 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:bab4:22c5:662d:e478]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 385502A8; Thu, 30 Sep 2021 11:37:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1632994639; bh=1wjBHSTNGR0qVSCbvCE8xhM507lkBZpZ2Nj/vzAhDWE=; h=From:To:Cc:Subject:Date:From; b=viAfveSseZ2HJqBbi2/R3Dm2rehz0UcAEP2ji1+lYUQ4nEMR9+J5B6A+GFDC3nlAV iv9k6ql8UXmRMsWzvQbTZPFF+uyzTHMOoUFH8DXSHHw/v7KlCFjgEUXB8kfMHBwX5z xTVZVvRcfablGvuh8KLHRL8xNpjblMs6B0RUnBDA= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Thu, 30 Sep 2021 11:37:03 +0200 Message-Id: <20210930093715.73293-1-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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. Main changes 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 | 31 ++- src/ipa/ipu3/algorithms/agc.cpp | 53 ++--- src/ipa/ipu3/algorithms/agc.h | 2 + src/ipa/ipu3/algorithms/awb.cpp | 195 +++++++++++-------- src/ipa/ipu3/algorithms/awb.h | 42 ++-- src/ipa/ipu3/algorithms/black_correction.cpp | 67 +++++++ src/ipa/ipu3/algorithms/black_correction.h | 28 +++ src/ipa/ipu3/algorithms/meson.build | 1 + src/ipa/ipu3/ipa_context.h | 1 + src/ipa/ipu3/ipu3.cpp | 75 ++++--- 10 files changed, 325 insertions(+), 170 deletions(-) create mode 100644 src/ipa/ipu3/algorithms/black_correction.cpp create mode 100644 src/ipa/ipu3/algorithms/black_correction.h