[libcamera-devel,1/2] libcamera: bayer_format: Expand documentation
diff mbox series

Message ID 20230114190135.19703-1-jacopo.mondi@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel,1/2] libcamera: bayer_format: Expand documentation
Related show

Commit Message

Jacopo Mondi Jan. 14, 2023, 7:01 p.m. UTC
The current documentation of the BayerFormat::transform() function
reports examples on the Bayer components ordering transformation for
horizontal flip (mirroring) but not for vertical flip or for the
combination of the two.

It might be useful to complete the documentation to ease understanding
of the transform() function on a sensor's Bayer pattern.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
---
 src/libcamera/bayer_format.cpp | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

--
2.39.0

Comments

Laurent Pinchart Jan. 16, 2023, 12:43 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Sat, Jan 14, 2023 at 08:01:34PM +0100, Jacopo Mondi via libcamera-devel wrote:
> The current documentation of the BayerFormat::transform() function
> reports examples on the Bayer components ordering transformation for
> horizontal flip (mirroring) but not for vertical flip or for the
> combination of the two.
> 
> It might be useful to complete the documentation to ease understanding
> of the transform() function on a sensor's Bayer pattern.

If it only "might" be useful, I "might" have doubts about this patch, so
let's write "It is useful" to make sure I accept it ;-)

> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
> ---
>  src/libcamera/bayer_format.cpp | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
> index f27cc1662d25..d2f6698a67ca 100644
> --- a/src/libcamera/bayer_format.cpp
> +++ b/src/libcamera/bayer_format.cpp
> @@ -356,11 +356,14 @@ BayerFormat BayerFormat::fromPixelFormat(PixelFormat format)
>   * \brief Apply a transform to this BayerFormat
>   * \param[in] t The transform to apply
>   *
> - * Appplying a transform to an image stored in a Bayer format affects the Bayer
> - * order. For example, performing a horizontal flip on the Bayer pattern
> - * RGGB causes the RG rows of pixels to become GR, and the GB rows to become BG.
> - * The transformed image would have a GRBG order. The bit depth and modifiers
> - * are not affected.
> + * Applying a transform to an image stored in a Bayer format affects the Bayer
> + * order. For example, performing an horizontal flip on the Bayer pattern RGGB

s/an horizontal/a horizontal/

> + * causes the RG rows of pixels to become GR, and the GB rows to become BG. The
> + * transformed image would have a GRBG order. Performing a vertical flip on the
> + * Bayer pattern RGGB causes the GB rows to be read before the RG ones and the

Let's keep this generic, avoiding the mention of "read" as it applies to
pixel formats in memory, not just sensor readout order:

"causes the GB rows to come before the RG rows"

or something similar.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> + * transformed image would have GBRG order. Applying both vertical and
> + * horizontal flips on the Bayer patter RGGB results in transformed images with
> + * BGGR order. The bit depth and modifiers are not affected.
>   *
>   * Horizontal and vertical flips are applied before transpose.
>   *
> @@ -375,8 +378,11 @@ BayerFormat BayerFormat::transform(Transform t) const
> 
>  	/*
>  	 * Observe that flipping bit 0 of the Order enum performs a horizontal
> -	 * mirror on the Bayer pattern (e.g. RGGB goes to GRBG). Similarly,
> -	 * flipping bit 1 performs a vertical mirror operation on it. Hence:
> +	 * mirror on the Bayer pattern (e.g. RG/GB goes to GR/BG). Similarly,
> +	 * flipping bit 1 performs a vertical mirror operation on it (e.g RG/GB
> +	 * goes to GB/RG). Applying both vertical and horizontal flips
> +	 * combines vertical and horizontal mirroring on the Bayer pattern
> +	 * (e.g. RG/GB goes to BG/GR). Hence:
>  	 */
>  	if (!!(t & Transform::HFlip))
>  		result.order = static_cast<Order>(result.order ^ 1);

Patch
diff mbox series

diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
index f27cc1662d25..d2f6698a67ca 100644
--- a/src/libcamera/bayer_format.cpp
+++ b/src/libcamera/bayer_format.cpp
@@ -356,11 +356,14 @@  BayerFormat BayerFormat::fromPixelFormat(PixelFormat format)
  * \brief Apply a transform to this BayerFormat
  * \param[in] t The transform to apply
  *
- * Appplying a transform to an image stored in a Bayer format affects the Bayer
- * order. For example, performing a horizontal flip on the Bayer pattern
- * RGGB causes the RG rows of pixels to become GR, and the GB rows to become BG.
- * The transformed image would have a GRBG order. The bit depth and modifiers
- * are not affected.
+ * Applying a transform to an image stored in a Bayer format affects the Bayer
+ * order. For example, performing an horizontal flip on the Bayer pattern RGGB
+ * causes the RG rows of pixels to become GR, and the GB rows to become BG. The
+ * transformed image would have a GRBG order. Performing a vertical flip on the
+ * Bayer pattern RGGB causes the GB rows to be read before the RG ones and the
+ * transformed image would have GBRG order. Applying both vertical and
+ * horizontal flips on the Bayer patter RGGB results in transformed images with
+ * BGGR order. The bit depth and modifiers are not affected.
  *
  * Horizontal and vertical flips are applied before transpose.
  *
@@ -375,8 +378,11 @@  BayerFormat BayerFormat::transform(Transform t) const

 	/*
 	 * Observe that flipping bit 0 of the Order enum performs a horizontal
-	 * mirror on the Bayer pattern (e.g. RGGB goes to GRBG). Similarly,
-	 * flipping bit 1 performs a vertical mirror operation on it. Hence:
+	 * mirror on the Bayer pattern (e.g. RG/GB goes to GR/BG). Similarly,
+	 * flipping bit 1 performs a vertical mirror operation on it (e.g RG/GB
+	 * goes to GB/RG). Applying both vertical and horizontal flips
+	 * combines vertical and horizontal mirroring on the Bayer pattern
+	 * (e.g. RG/GB goes to BG/GR). Hence:
 	 */
 	if (!!(t & Transform::HFlip))
 		result.order = static_cast<Order>(result.order ^ 1);