[libcamera-devel] qcam: format_convertor: Extend 32 bit ARGB format combinations

Message ID 20200224130855.4858-1-kieran.bingham@ideasonboard.com
State Accepted
Commit 32ccaf458f1137b717c5a66c77d3e7dede9aa7a2
Headers show
Series
  • [libcamera-devel] qcam: format_convertor: Extend 32 bit ARGB format combinations
Related show

Commit Message

Kieran Bingham Feb. 24, 2020, 1:08 p.m. UTC
Add further support to the pixel format convertor to allow ARGB, RGBA,
and ABGR formats to be displayed in qcam.

Blank lines are added between the sections for NV, RGB, YUV, and MJPEG
configurations.

The implementation of the RGB conversions are highly inefficient, and
where possible should be extended to use hardware accellerations such as
OpenGL, or in the event that the input format is identical (or
compatible) with the output format - a more optimised memcpy should be
implemented.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/qcam/format_converter.cpp | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Laurent Pinchart Feb. 26, 2020, 1:41 a.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Mon, Feb 24, 2020 at 01:08:55PM +0000, Kieran Bingham wrote:
> Add further support to the pixel format convertor to allow ARGB, RGBA,
> and ABGR formats to be displayed in qcam.
> 
> Blank lines are added between the sections for NV, RGB, YUV, and MJPEG
> configurations.
> 
> The implementation of the RGB conversions are highly inefficient, and
> where possible should be extended to use hardware accellerations such as

s/accellerations/accelerations/

> OpenGL, or in the event that the input format is identical (or
> compatible) with the output format - a more optimised memcpy should be
> implemented.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

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

> ---
>  src/qcam/format_converter.cpp | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp
> index 383d48223140..4604143419dd 100644
> --- a/src/qcam/format_converter.cpp
> +++ b/src/qcam/format_converter.cpp
> @@ -67,6 +67,7 @@ int FormatConverter::configure(unsigned int format, unsigned int width,
>  		vertSubSample_ = 1;
>  		nvSwap_ = true;
>  		break;
> +
>  	case DRM_FORMAT_RGB888:
>  		formatFamily_ = RGB;
>  		r_pos_ = 2;
> @@ -81,6 +82,27 @@ int FormatConverter::configure(unsigned int format, unsigned int width,
>  		b_pos_ = 2;
>  		bpp_ = 3;
>  		break;
> +	case DRM_FORMAT_ARGB8888:
> +		formatFamily_ = RGB;
> +		r_pos_ = 2;
> +		g_pos_ = 1;
> +		b_pos_ = 0;
> +		bpp_ = 4;
> +		break;
> +	case DRM_FORMAT_RGBA8888:
> +		formatFamily_ = RGB;
> +		r_pos_ = 3;
> +		g_pos_ = 2;
> +		b_pos_ = 1;
> +		bpp_ = 4;
> +		break;
> +	case DRM_FORMAT_ABGR8888:
> +		formatFamily_ = RGB;
> +		r_pos_ = 0;
> +		g_pos_ = 1;
> +		b_pos_ = 2;
> +		bpp_ = 4;
> +		break;
>  	case DRM_FORMAT_BGRA8888:
>  		formatFamily_ = RGB;
>  		r_pos_ = 1;
> @@ -88,6 +110,7 @@ int FormatConverter::configure(unsigned int format, unsigned int width,
>  		b_pos_ = 3;
>  		bpp_ = 4;
>  		break;
> +
>  	case DRM_FORMAT_VYUY:
>  		formatFamily_ = YUV;
>  		y_pos_ = 1;
> @@ -108,9 +131,11 @@ int FormatConverter::configure(unsigned int format, unsigned int width,
>  		y_pos_ = 0;
>  		cb_pos_ = 1;
>  		break;
> +
>  	case DRM_FORMAT_MJPEG:
>  		formatFamily_ = MJPEG;
>  		break;
> +
>  	default:
>  		return -EINVAL;
>  	};

Patch

diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp
index 383d48223140..4604143419dd 100644
--- a/src/qcam/format_converter.cpp
+++ b/src/qcam/format_converter.cpp
@@ -67,6 +67,7 @@  int FormatConverter::configure(unsigned int format, unsigned int width,
 		vertSubSample_ = 1;
 		nvSwap_ = true;
 		break;
+
 	case DRM_FORMAT_RGB888:
 		formatFamily_ = RGB;
 		r_pos_ = 2;
@@ -81,6 +82,27 @@  int FormatConverter::configure(unsigned int format, unsigned int width,
 		b_pos_ = 2;
 		bpp_ = 3;
 		break;
+	case DRM_FORMAT_ARGB8888:
+		formatFamily_ = RGB;
+		r_pos_ = 2;
+		g_pos_ = 1;
+		b_pos_ = 0;
+		bpp_ = 4;
+		break;
+	case DRM_FORMAT_RGBA8888:
+		formatFamily_ = RGB;
+		r_pos_ = 3;
+		g_pos_ = 2;
+		b_pos_ = 1;
+		bpp_ = 4;
+		break;
+	case DRM_FORMAT_ABGR8888:
+		formatFamily_ = RGB;
+		r_pos_ = 0;
+		g_pos_ = 1;
+		b_pos_ = 2;
+		bpp_ = 4;
+		break;
 	case DRM_FORMAT_BGRA8888:
 		formatFamily_ = RGB;
 		r_pos_ = 1;
@@ -88,6 +110,7 @@  int FormatConverter::configure(unsigned int format, unsigned int width,
 		b_pos_ = 3;
 		bpp_ = 4;
 		break;
+
 	case DRM_FORMAT_VYUY:
 		formatFamily_ = YUV;
 		y_pos_ = 1;
@@ -108,9 +131,11 @@  int FormatConverter::configure(unsigned int format, unsigned int width,
 		y_pos_ = 0;
 		cb_pos_ = 1;
 		break;
+
 	case DRM_FORMAT_MJPEG:
 		formatFamily_ = MJPEG;
 		break;
+
 	default:
 		return -EINVAL;
 	};