From patchwork Thu Jan 22 16:19:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 25926 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 1FAFFBDCBF for ; Thu, 22 Jan 2026 16:20:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EFC0361FC9; Thu, 22 Jan 2026 17:20:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="GrNkL8Mh"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B86EC61F84 for ; Thu, 22 Jan 2026 17:20:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769098809; 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; bh=e1ToWIAyxPuvf/e6yXUb8dmiA+UlRn75wM5NZ2xAhhM=; b=GrNkL8MhOJD+nev5vcbqvSST2FVaiv2txj+K6vdEb8sknukF9BgwKYGqtKZRpRLjOBzw3L oxLfxHV52CVpLzsOoI/KqZU6BfoCHrTLMjzTm5EZZYrXe+knOidKA3IoNXIw6YLEb4jPqn odD+g5SFpg+SqpqkmVOiJrDaIQWO3uc= Received: from mx-prod-mc-03.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-55-OWQtyhK_OV2hrdf6AQRwpw-1; Thu, 22 Jan 2026 11:20:06 -0500 X-MC-Unique: OWQtyhK_OV2hrdf6AQRwpw-1 X-Mimecast-MFC-AGG-ID: OWQtyhK_OV2hrdf6AQRwpw_1769098805 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EE1B51956050; Thu, 22 Jan 2026 16:20:04 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.45.224.97]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CA8D11800577; Thu, 22 Jan 2026 16:20:02 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Kieran Bingham , =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v4 00/15] Simple pipeline IPA cleanup Date: Thu, 22 Jan 2026 17:19:20 +0100 Message-ID: <20260122161935.208562-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: o30-qKbhhLPS1QJBHn91OsefGfrpSYfbnvKjPX94aog_1769098805 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 simple pipeline image algorithms inappropriately mix various stuff together. For example, contrast and saturation processing is mixed with CCM and LUT processing, algorithms cannot be disabled without making software ISP malfunctioning and some "algorithms", like lookup table construction, are not algorithms at all. This patch series introduces new algorithm Adjust for contrast, saturation and gamma adjustments, moves lookup table construction to debayering, separates CCM from the combined matrix (which includes white balance and saturation adjustments), and cleans up some other things. Changes in v4: - Remaining redundant include removed from adjust.h. - Gamma value is reported in metadata. - Contrast value is always reported in metadata. - context.activeState.knobs.gamma is no longer std::optional. - gpuIspEnabled removed from everywhere. - Matrix comparison simplified as suggested by Barnabás. - Multiple params_->combinedMatrix assignments replaced by a single one. - Unused context.activeState.ccm removed. - currentCcm_ wrapped by std::optional and ccmAssigned_ removed. - kDefault* constants made constexpr. - kDefaultContrast and kDefaultSaturation moved to adjust.cpp. - Minor corrections in commit messages. Changes in v3: - Rebased on the merged GPU ISP and adjusted for the changes there. - A patch reverting enabling Ccm algorithm by GPU ISP added. Changes in v2: - Commit message of "Generalise tracking matrix changes" improved a bit. - correctionMatrix renamed to combinedMatrix. - combinedMatrix initialisations fixed and Matrix::identity utilised. - gamma made adjustable. - Types of contrast, saturation, gamma set to float (from double in some places). - Symbolic constants are used for contrast, saturation, gamma defaults. - The gain matrix is applied directly in awb.cpp now. - Lut "algorithm" removed; lookup tables construction moved to debayering. Milan Zamazal (15): libcamera: ipa: simple: Remove an unused include from awb.cpp libcamera: ipa: simple: Unwrap IPAFrameContext::ccm libcamera: ipa: simple: Generalize tracking matrix changes libcamera: ipa: simple: Rename "ccm" identifiers not specific to CCM libcamera: ipa: simple: Introduce a general correction matrix libcamera: ipa: simple: Initialise the general correction matrix libcamera: ipa: simple: Separate saturation from CCM libcamera: ipa: simple: Move contrast settings to adjust.cpp libcamera: ipa: simple: Make gamma adjustable libcamera: ipa: simple: Apply gain matrix in awb libcamera: ipa: simple: Use float type for adjustment controls libcamera: ipa: simple: Use symbolic constants for adjust defaults libcamera: ipa: simple: Set contrast metadata unconditionally libcamera: ipa: simple: Remove Lut algorithm libcamera: ipa: simple: Disable Ccm algorithm by default again .../internal/software_isp/debayer_params.h | 45 +---- include/libcamera/ipa/soft.mojom | 3 +- src/ipa/simple/algorithms/adjust.cpp | 134 ++++++++++++++ src/ipa/simple/algorithms/{lut.h => adjust.h} | 28 +-- src/ipa/simple/algorithms/awb.cpp | 14 +- src/ipa/simple/algorithms/ccm.cpp | 80 ++------ src/ipa/simple/algorithms/ccm.h | 12 +- src/ipa/simple/algorithms/lut.cpp | 174 ------------------ src/ipa/simple/algorithms/meson.build | 2 +- src/ipa/simple/data/uncalibrated.yaml | 14 +- src/ipa/simple/ipa_context.h | 27 +-- src/ipa/simple/soft_simple.cpp | 13 +- src/libcamera/software_isp/debayer.cpp | 172 +---------------- src/libcamera/software_isp/debayer.h | 8 - src/libcamera/software_isp/debayer_cpu.cpp | 136 ++++++++++++-- src/libcamera/software_isp/debayer_cpu.h | 26 ++- src/libcamera/software_isp/debayer_egl.cpp | 27 ++- src/libcamera/software_isp/software_isp.cpp | 29 +-- 18 files changed, 370 insertions(+), 574 deletions(-) create mode 100644 src/ipa/simple/algorithms/adjust.cpp rename src/ipa/simple/algorithms/{lut.h => adjust.h} (57%) delete mode 100644 src/ipa/simple/algorithms/lut.cpp Tested-by: Robert Mader