summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-10-20 16:58:24 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-10-23 16:06:18 +0300
commit7a5d4b83e5d5a2444e62ac5868c9016de43f8f60 (patch)
tree8fdccc0eca7485bf6e9be501fefc2eb35904de0d /src
parent4814d8f1b5b397137da5efedd9a5b4351cbfe836 (diff)
libcamera: camera_sensor: Cache mounting orientation instead of transform
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/camera_sensor.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index f175f8b5..d9261672 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;
}