From patchwork Thu Apr 18 12:46:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 19907 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 9B1A8C32C9 for ; Thu, 18 Apr 2024 12:46:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 615F7633F7; Thu, 18 Apr 2024 14:46:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="A8ywHBYC"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 74E07633F3 for ; Thu, 18 Apr 2024 14:46:43 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C62C727C; Thu, 18 Apr 2024 14:45:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1713444355; bh=6XqyCQqXki+3gyfZzJ7+4a2JpEiAEDmlubddBrbgCs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A8ywHBYC4dr1XN+at5x/ZyV7C6FKlDkk2yN4PhKXjHQNdCsxkJxcotWyCQJXE1jUk lYDyM7ar+nj3JMPHyxnoKtdA+weVhF4TXoCJZsGxgPxufEf1fDBFLvxmjIGo3NXry+ amcfoADrjmSr6nn4Spmfrnr6PxdmQa6FTMa9xADI= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 3/3] ipa: ipu3: Use a Y histogram instead of green Date: Thu, 18 Apr 2024 13:46:32 +0100 Message-Id: <20240418124632.652163-4-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240418124632.652163-1-dan.scally@ideasonboard.com> References: <20240418124632.652163-1-dan.scally@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" The IPU3 IPA module uses a green histogram for the AGC algorithm's constraint mode calculations. Switch instead to a luminance histogram calculated using the Rec.601 coefficients. Signed-off-by: Daniel Scally Reviewed-by: Kieran Bingham --- src/ipa/ipu3/algorithms/agc.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index a59b73fb..76d2bb60 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -152,18 +152,19 @@ Histogram Agc::parseStatistics(const ipu3_uapi_stats_3a *stats, reinterpret_cast( &stats->awb_raw_buffer.meta_data[cellPosition]); - rgbTriples_.push_back({ - cell->R_avg, - (cell->Gr_avg + cell->Gb_avg) / 2, - cell->B_avg - }); + uint8_t G_avg = (cell->Gr_avg + cell->Gb_avg) / 2; + + rgbTriples_.push_back({cell->R_avg, G_avg, cell->B_avg}); /* - * Store the average green value to estimate the + * Store the average luminance value to estimate the * brightness. Even the overexposed pixels are * taken into account. */ - hist[(cell->Gr_avg + cell->Gb_avg) / 2]++; + uint8_t y = (cell->R_avg * .299) + + (G_avg * .587) + + (cell->B_avg * .114); + hist[y]++; } }