From patchwork Wed Jun 26 07:21:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 20411 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 968E1BD87C for ; Wed, 26 Jun 2024 07:21:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 43D73654C2; Wed, 26 Jun 2024 09:21:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="AxIsdkTZ"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 25483654C9 for ; Wed, 26 Jun 2024 09:21:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719386508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dw+Xm6qnLKyAnt+RsGrdnpTqaaF6AqT57ojMpeKNQnk=; b=AxIsdkTZ2Sf+tx0pmz0lyMzYV7IJBnbdyERbfzACBfBPT/eUPyZ22ZeB87ilouMKDSRBCI de5ElU4FNe801rbdPm+pntZ4dXWKxqyEeDt2OC3IzcYySftU0F6BS9s3VeVRAP8HGPOeIr gqKeXxld/3KhpJGtKzfFcaVz1ohuFEI= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-26-vhaZQbWBN2Whx4iwfCkEdQ-1; Wed, 26 Jun 2024 03:21:46 -0400 X-MC-Unique: vhaZQbWBN2Whx4iwfCkEdQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E293F19560AB for ; Wed, 26 Jun 2024 07:21:45 +0000 (UTC) Received: from nuthatch.brq.redhat.com (unknown [10.43.17.159]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E9DEB3000225; Wed, 26 Jun 2024 07:21:44 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [PATCH 19/19] libcamera: software_isp: Update black level only on exposure changes Date: Wed, 26 Jun 2024 09:21:00 +0200 Message-ID: <20240626072100.55497-20-mzamazal@redhat.com> In-Reply-To: <20240626072100.55497-1-mzamazal@redhat.com> References: <20240626072100.55497-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 black level is likely to get updated, if ever, only after exposure or gain changes. Don't compute its possible updates if exposure and gain are unchanged. It's probably not worth trying to implement something more sophisticated. Better to spend the effort on supporting tuning files. Signed-off-by: Milan Zamazal --- src/ipa/simple/algorithms/blc.cpp | 9 +++++++-- src/ipa/simple/algorithms/blc.h | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp index 82c89dbb..9025cb3a 100644 --- a/src/ipa/simple/algorithms/blc.cpp +++ b/src/ipa/simple/algorithms/blc.cpp @@ -32,11 +32,13 @@ int BlackLevel::init(IPAContext &context, void BlackLevel::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, - [[maybe_unused]] IPAFrameContext &frameContext, + IPAFrameContext &frameContext, const SwIspStats *stats, [[maybe_unused]] ControlList &metadata) { - if (context.configuration.black.set) { + if (context.configuration.black.set && + frameContext.sensor.exposure == exposure_ && + frameContext.sensor.gain == gain_) { context.configuration.black.changed = false; return; } @@ -61,7 +63,10 @@ void BlackLevel::process(IPAContext &context, if (seen >= pixelThreshold) { context.configuration.black.level = static_cast(i) / SwIspStats::kYHistogramSize; + context.configuration.black.set = true; context.configuration.black.changed = true; + exposure_ = frameContext.sensor.exposure; + gain_ = frameContext.sensor.gain; LOG(IPASoftBL, Debug) << "Auto-set black level: " << i << "/" << SwIspStats::kYHistogramSize diff --git a/src/ipa/simple/algorithms/blc.h b/src/ipa/simple/algorithms/blc.h index c8b8d92d..4ddd2c94 100644 --- a/src/ipa/simple/algorithms/blc.h +++ b/src/ipa/simple/algorithms/blc.h @@ -30,6 +30,10 @@ public: IPAFrameContext &frameContext, const SwIspStats *stats, ControlList &metadata) override; + +private: + uint32_t exposure_; + double gain_; }; } /* namespace ipa::soft::algorithms */