From patchwork Sun Oct 22 22:41:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19175 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 391F3C32B8 for ; Sun, 22 Oct 2023 22:42:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 664DA6298D; Mon, 23 Oct 2023 00:42:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1698014523; bh=vTFhs4od3h0Y/PLNg5ahJow5rZArqfKXmk+S/CiZSmA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ucXVuL5z5xnuSQaDKhLBAl772odByM3+IczXG17HnBMSqfUlldokbgXsHqJKKYNYL Y1UbAJelqc0So3TnyXZbOvfPLKmJxfgY3s75WKJxkT4HYzURLZj+gSI5aHxcXDiws0 fnoeLaDxo4AkmhZKv95i6yYR7ZcMRmu8OvMw8+FZXVtVrMxDWVEfc27HnG7YmF8LAJ AohK1IbLf5KuRuPrq3Um6teiuDKhOUU+LXjbqHDbE5G49luQeEycqZIF9vuTWim5eu ZIoQLo5JnMum/3mO8KvtvNmJJX9dBjdLVc/fi1uoYiOnuY4Beqz3lyD/etoYa33FP6 /mjkA6nP/hLDA== 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 A29B26297F for ; Mon, 23 Oct 2023 00:41:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="bFBfwf6g"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4F242749; Mon, 23 Oct 2023 00:41:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698014509; bh=vTFhs4od3h0Y/PLNg5ahJow5rZArqfKXmk+S/CiZSmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bFBfwf6gOAorqXaLrechhyPKwKUck2nSEGp2biKvIULP2tABTrDlaLCNbf4ArvGOX OaZqQa94zVwzgFiqUiUGkLcqe4QQxJ+0msKcdalcidnW8UtJGmFpwPXP9OOjOxHc4L N2FudP2I5/w4KvgsFgxZHNFrUUdmqz4+s/eNn9sU= To: libcamera-devel@lists.libcamera.org Date: Mon, 23 Oct 2023 01:41:57 +0300 Message-ID: <20231022224159.30298-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019140133.32090-1-jacopo.mondi@ideasonboard.com> References: <20231019140133.32090-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 19/12] libcamera: camera_sensor: Cache mounting orientation instead of transform 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The cached rotationTransform_ value is used in computeTransform() only, to compute the mounting orientation. Cache the mounting orientation instead, removing the need for the intermediate conversion of the rotation to a transform. Signed-off-by: Laurent Pinchart --- include/libcamera/internal/camera_sensor.h | 3 ++- src/libcamera/camera_sensor.cpp | 18 ++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index bcdb2d834dc3..60a8b106d175 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -114,7 +115,7 @@ private: Rectangle activeArea_; const BayerFormat *bayerFormat_; bool supportFlips_; - Transform rotationTransform_; + Orientation mountingOrientation_; ControlList properties_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index f175f8b56077..d92616722bc3 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -470,12 +470,12 @@ int CameraSensor::initProperties() * rotation for later use in computeTransform(). */ bool success; - rotationTransform_ = transformFromRotation(propertyValue, &success); + mountingOrientation_ = orientationFromRotation(propertyValue, &success); if (!success) { LOG(CameraSensor, Warning) << "Invalid rotation of " << propertyValue << " degrees - ignoring"; - rotationTransform_ = Transform::Identity; + mountingOrientation_ = Orientation::Rotate0; } properties_.set(properties::Rotation, propertyValue); @@ -483,7 +483,7 @@ int CameraSensor::initProperties() LOG(CameraSensor, Warning) << "Rotation control not available, default to 0 degrees"; properties_.set(properties::Rotation, 0); - rotationTransform_ = Transform::Identity; + mountingOrientation_ = Orientation::Rotate0; } properties_.set(properties::PixelArraySize, pixelArraySize_); @@ -1137,14 +1137,12 @@ void CameraSensor::updateControlInfo() */ Transform CameraSensor::computeTransform(Orientation *orientation) const { - Orientation mountingOrientation = transformToOrientation(rotationTransform_); - /* * If we cannot do any flips we cannot change the native camera mounting * orientation. */ if (!supportFlips_) { - *orientation = mountingOrientation; + *orientation = mountingOrientation_; return Transform::Identity; } @@ -1153,17 +1151,17 @@ Transform CameraSensor::computeTransform(Orientation *orientation) const * from the mounting rotation. * * As a note: - * orientation / mountingOrientation = transform - * mountingOrientation * transform = orientation + * orientation / mountingOrientation_ = transform + * mountingOrientation_ * transform = orientation */ - Transform transform = *orientation / mountingOrientation; + Transform transform = *orientation / mountingOrientation_; /* * If transform contains any Transpose we cannot do it, so adjust * 'orientation' to report the image native orientation and return Identity. */ if (!!(transform & Transform::Transpose)) { - *orientation = mountingOrientation; + *orientation = mountingOrientation_; return Transform::Identity; }