summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Fricke <sebastian.fricke@posteo.net>2021-01-26 19:48:53 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-02-04 21:00:38 +0200
commitd121f6c83f3da5ea6a58556a64d50354ea8efd35 (patch)
tree2b8384aab11001d576fe2d677aa7c8fe53d14969
parentc440c828bc071effb76e60968c9d4a4a74c134df (diff)
libcamera: bayer_format: Add the transpose transformation
To transpose a BayerFormat means to flip it over its main diagonal. For example: G B G R -> R G B G The main diagonal goes from the top left to the bottom right. This means, that the only two orders affected by a transpose are GBRG & GRBG. When a transpose is used in combination with horizontal and/or vertical flips it is performed after the flips. Therefore add the functionality by switching GBRG (index 1) with GRBG (index 2), after the flips have been applied. Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/libcamera/bayer_format.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
index ae730d94..ed61202c 100644
--- a/src/libcamera/bayer_format.cpp
+++ b/src/libcamera/bayer_format.cpp
@@ -272,9 +272,7 @@ BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)
* The transformed image would have a GRBG order. The bit depth and modifiers
* are not affected.
*
- * Note that transpositions are ignored as the order of a transpose with
- * respect to the flips would have to be defined, and sensors are not expected
- * to support transposition.
+ * Horizontal and vertical flips are applied before transpose.
*
* \return The transformed Bayer format
*/
@@ -292,6 +290,11 @@ BayerFormat BayerFormat::transform(Transform t) const
if (!!(t & Transform::VFlip))
result.order = static_cast<Order>(result.order ^ 2);
+ if (!!(t & Transform::Transpose) && result.order == 1)
+ result.order = static_cast<Order>(2);
+ else if (!!(t & Transform::Transpose) && result.order == 2)
+ result.order = static_cast<Order>(1);
+
return result;
}