[libcamera-devel] gstreamer: Add support for additional RGB formats
diff mbox series

Message ID 20220823183856.17944-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 868ab2287da2def1cc6414c27d9e26fd1547f353
Headers show
Series
  • [libcamera-devel] gstreamer: Add support for additional RGB formats
Related show

Commit Message

Laurent Pinchart Aug. 23, 2022, 6:38 p.m. UTC
libcamerasrc only supports three RGB formats. Adding the other RGB
formats supported by libcamera is trivial, do so.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
I haven't tested this yet as I don't have a board hooked up that can
capture these formats. If someone can test it with an OV5640 sensor on
an i.MX8MP, that would be great, otherwise I'll get to it in the not too
distant future.
---
 src/gstreamer/gstlibcamera-utils.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Umang Jain Aug. 23, 2022, 10:36 p.m. UTC | #1
Hi Laurent,

Thank you for the patch.

On 8/24/22 12:08 AM, Laurent Pinchart via libcamera-devel wrote:
> libcamerasrc only supports three RGB formats. Adding the other RGB
> formats supported by libcamera is trivial, do so.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> I haven't tested this yet as I don't have a board hooked up that can
> capture these formats. If someone can test it with an OV5640 sensor on
> an i.MX8MP, that would be great, otherwise I'll get to it in the not too
> distant future.
> ---
>   src/gstreamer/gstlibcamera-utils.cpp | 14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
> index c97c0d438de2..5a21a391c698 100644
> --- a/src/gstreamer/gstlibcamera-utils.cpp
> +++ b/src/gstreamer/gstlibcamera-utils.cpp
> @@ -19,9 +19,21 @@ static struct {
>   	/* Compressed */
>   	{ GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },
>   
> -	/* RGB */
> +	/* RGB16 */
> +	{ GST_VIDEO_FORMAT_RGB16, formats::RGB565 },
> +
> +	/* RGB24 */
>   	{ GST_VIDEO_FORMAT_RGB, formats::BGR888 },
>   	{ GST_VIDEO_FORMAT_BGR, formats::RGB888 },
> +
> +	/* RGB32 */
> +	{ GST_VIDEO_FORMAT_BGRx, formats::XRGB8888 },
> +	{ GST_VIDEO_FORMAT_RGBx, formats::XBGR8888 },
> +	{ GST_VIDEO_FORMAT_xBGR, formats::RGBX8888 },
> +	{ GST_VIDEO_FORMAT_xRGB, formats::BGRX8888 },
> +	{ GST_VIDEO_FORMAT_BGRA, formats::ARGB8888 },
> +	{ GST_VIDEO_FORMAT_RGBA, formats::ABGR8888 },
> +	{ GST_VIDEO_FORMAT_ABGR, formats::RGBA8888 },

I have individually cross referenced each entry with V4L2 pixel format 
and seems correct to me,

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
>   	{ GST_VIDEO_FORMAT_ARGB, formats::BGRA8888 },
>   
>   	/* YUV Semiplanar */
Kieran Bingham Aug. 24, 2022, 9:18 a.m. UTC | #2
Quoting Umang Jain via libcamera-devel (2022-08-23 23:36:40)
> Hi Laurent,
> 
> Thank you for the patch.
> 
> On 8/24/22 12:08 AM, Laurent Pinchart via libcamera-devel wrote:
> > libcamerasrc only supports three RGB formats. Adding the other RGB
> > formats supported by libcamera is trivial, do so.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > I haven't tested this yet as I don't have a board hooked up that can
> > capture these formats. If someone can test it with an OV5640 sensor on
> > an i.MX8MP, that would be great, otherwise I'll get to it in the not too
> > distant future.
> > ---
> >   src/gstreamer/gstlibcamera-utils.cpp | 14 +++++++++++++-
> >   1 file changed, 13 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
> > index c97c0d438de2..5a21a391c698 100644
> > --- a/src/gstreamer/gstlibcamera-utils.cpp
> > +++ b/src/gstreamer/gstlibcamera-utils.cpp
> > @@ -19,9 +19,21 @@ static struct {
> >       /* Compressed */
> >       { GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },
> >   
> > -     /* RGB */
> > +     /* RGB16 */
> > +     { GST_VIDEO_FORMAT_RGB16, formats::RGB565 },
> > +
> > +     /* RGB24 */
> >       { GST_VIDEO_FORMAT_RGB, formats::BGR888 },
> >       { GST_VIDEO_FORMAT_BGR, formats::RGB888 },
> > +
> > +     /* RGB32 */
> > +     { GST_VIDEO_FORMAT_BGRx, formats::XRGB8888 },
> > +     { GST_VIDEO_FORMAT_RGBx, formats::XBGR8888 },
> > +     { GST_VIDEO_FORMAT_xBGR, formats::RGBX8888 },
> > +     { GST_VIDEO_FORMAT_xRGB, formats::BGRX8888 },
> > +     { GST_VIDEO_FORMAT_BGRA, formats::ARGB8888 },
> > +     { GST_VIDEO_FORMAT_RGBA, formats::ABGR8888 },
> > +     { GST_VIDEO_FORMAT_ABGR, formats::RGBA8888 },
> 
> I have individually cross referenced each entry with V4L2 pixel format 
> and seems correct to me,
> 
> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

I'll be happy to see this patch in and support extended.

What pixelformats do we support that are not supported by the gstreamer
element, or perhaps are not supported by gstreamer at all? Or are all
formats covered with this?

All the above formats match my expectations with ordering.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

--
Kieran



> >       { GST_VIDEO_FORMAT_ARGB, formats::BGRA8888 },
> >   
> >       /* YUV Semiplanar */
>
Laurent Pinchart Aug. 24, 2022, 9:25 a.m. UTC | #3
On Wed, Aug 24, 2022 at 10:18:52AM +0100, Kieran Bingham wrote:
> Quoting Umang Jain via libcamera-devel (2022-08-23 23:36:40)
> > Hi Laurent,
> > 
> > Thank you for the patch.
> > 
> > On 8/24/22 12:08 AM, Laurent Pinchart via libcamera-devel wrote:
> > > libcamerasrc only supports three RGB formats. Adding the other RGB
> > > formats supported by libcamera is trivial, do so.
> > >
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > ---
> > > I haven't tested this yet as I don't have a board hooked up that can
> > > capture these formats. If someone can test it with an OV5640 sensor on
> > > an i.MX8MP, that would be great, otherwise I'll get to it in the not too
> > > distant future.
> > > ---
> > >   src/gstreamer/gstlibcamera-utils.cpp | 14 +++++++++++++-
> > >   1 file changed, 13 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
> > > index c97c0d438de2..5a21a391c698 100644
> > > --- a/src/gstreamer/gstlibcamera-utils.cpp
> > > +++ b/src/gstreamer/gstlibcamera-utils.cpp
> > > @@ -19,9 +19,21 @@ static struct {
> > >       /* Compressed */
> > >       { GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },
> > >   
> > > -     /* RGB */
> > > +     /* RGB16 */
> > > +     { GST_VIDEO_FORMAT_RGB16, formats::RGB565 },
> > > +
> > > +     /* RGB24 */
> > >       { GST_VIDEO_FORMAT_RGB, formats::BGR888 },
> > >       { GST_VIDEO_FORMAT_BGR, formats::RGB888 },
> > > +
> > > +     /* RGB32 */
> > > +     { GST_VIDEO_FORMAT_BGRx, formats::XRGB8888 },
> > > +     { GST_VIDEO_FORMAT_RGBx, formats::XBGR8888 },
> > > +     { GST_VIDEO_FORMAT_xBGR, formats::RGBX8888 },
> > > +     { GST_VIDEO_FORMAT_xRGB, formats::BGRX8888 },
> > > +     { GST_VIDEO_FORMAT_BGRA, formats::ARGB8888 },
> > > +     { GST_VIDEO_FORMAT_RGBA, formats::ABGR8888 },
> > > +     { GST_VIDEO_FORMAT_ABGR, formats::RGBA8888 },
> > 
> > I have individually cross referenced each entry with V4L2 pixel format 
> > and seems correct to me,
> > 
> > Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
> 
> I'll be happy to see this patch in and support extended.
> 
> What pixelformats do we support that are not supported by the gstreamer
> element, or perhaps are not supported by gstreamer at all? Or are all
> formats covered with this?

The above list covers all our RGB formats. I haven't checked the other
ones.

> All the above formats match my expectations with ordering.
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> > >       { GST_VIDEO_FORMAT_ARGB, formats::BGRA8888 },
> > >   
> > >       /* YUV Semiplanar */
Kieran Bingham Aug. 24, 2022, 9:47 a.m. UTC | #4
Quoting Laurent Pinchart (2022-08-24 10:25:09)
> On Wed, Aug 24, 2022 at 10:18:52AM +0100, Kieran Bingham wrote:
> > Quoting Umang Jain via libcamera-devel (2022-08-23 23:36:40)
> > > Hi Laurent,
> > > 
> > > Thank you for the patch.
> > > 
> > > On 8/24/22 12:08 AM, Laurent Pinchart via libcamera-devel wrote:
> > > > libcamerasrc only supports three RGB formats. Adding the other RGB
> > > > formats supported by libcamera is trivial, do so.
> > > >
> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > > ---
> > > > I haven't tested this yet as I don't have a board hooked up that can
> > > > capture these formats. If someone can test it with an OV5640 sensor on
> > > > an i.MX8MP, that would be great, otherwise I'll get to it in the not too
> > > > distant future.
> > > > ---
> > > >   src/gstreamer/gstlibcamera-utils.cpp | 14 +++++++++++++-
> > > >   1 file changed, 13 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
> > > > index c97c0d438de2..5a21a391c698 100644
> > > > --- a/src/gstreamer/gstlibcamera-utils.cpp
> > > > +++ b/src/gstreamer/gstlibcamera-utils.cpp
> > > > @@ -19,9 +19,21 @@ static struct {
> > > >       /* Compressed */
> > > >       { GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },
> > > >   
> > > > -     /* RGB */
> > > > +     /* RGB16 */
> > > > +     { GST_VIDEO_FORMAT_RGB16, formats::RGB565 },
> > > > +
> > > > +     /* RGB24 */
> > > >       { GST_VIDEO_FORMAT_RGB, formats::BGR888 },
> > > >       { GST_VIDEO_FORMAT_BGR, formats::RGB888 },
> > > > +
> > > > +     /* RGB32 */
> > > > +     { GST_VIDEO_FORMAT_BGRx, formats::XRGB8888 },
> > > > +     { GST_VIDEO_FORMAT_RGBx, formats::XBGR8888 },
> > > > +     { GST_VIDEO_FORMAT_xBGR, formats::RGBX8888 },
> > > > +     { GST_VIDEO_FORMAT_xRGB, formats::BGRX8888 },
> > > > +     { GST_VIDEO_FORMAT_BGRA, formats::ARGB8888 },
> > > > +     { GST_VIDEO_FORMAT_RGBA, formats::ABGR8888 },
> > > > +     { GST_VIDEO_FORMAT_ABGR, formats::RGBA8888 },
> > > 
> > > I have individually cross referenced each entry with V4L2 pixel format 
> > > and seems correct to me,
> > > 
> > > Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
> > 
> > I'll be happy to see this patch in and support extended.
> > 
> > What pixelformats do we support that are not supported by the gstreamer
> > element, or perhaps are not supported by gstreamer at all? Or are all
> > formats covered with this?
> 
> The above list covers all our RGB formats. I haven't checked the other
> ones.

It looks like these are the unsupported formats. I haven't looked to see
which are actually supported by Gstreamer, but if anyone wants to - this
is the list to add:

        R8, R10, R12
        RGB565_BE
        AVUY8888, XVUY8888
        NV42
        YVU422, YUV444, YVU444

        All raw formats. (I expect gstreamer won't handle RAW?)

Kieran

> 
> > All the above formats match my expectations with ordering.
> > 
> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > 
> > > >       { GST_VIDEO_FORMAT_ARGB, formats::BGRA8888 },
> > > >   
> > > >       /* YUV Semiplanar */
> 
> -- 
> Regards,
> 
> Laurent Pinchart
Xavier Roumegue Aug. 24, 2022, 11:08 a.m. UTC | #5
On 8/23/22 20:38, Laurent Pinchart wrote:
> libcamerasrc only supports three RGB formats. Adding the other RGB
> formats supported by libcamera is trivial, do so.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> I haven't tested this yet as I don't have a board hooked up that can
> capture these formats. If someone can test it with an OV5640 sensor on
> an i.MX8MP, that would be great, otherwise I'll get to it in the not too
> distant future.
> ---
>   src/gstreamer/gstlibcamera-utils.cpp | 14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
> index c97c0d438de2..5a21a391c698 100644
> --- a/src/gstreamer/gstlibcamera-utils.cpp
> +++ b/src/gstreamer/gstlibcamera-utils.cpp
> @@ -19,9 +19,21 @@ static struct {
>   	/* Compressed */
>   	{ GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },
>   
> -	/* RGB */
> +	/* RGB16 */
> +	{ GST_VIDEO_FORMAT_RGB16, formats::RGB565 },
> +
> +	/* RGB24 */
>   	{ GST_VIDEO_FORMAT_RGB, formats::BGR888 },
>   	{ GST_VIDEO_FORMAT_BGR, formats::RGB888 },
> +
> +	/* RGB32 */
> +	{ GST_VIDEO_FORMAT_BGRx, formats::XRGB8888 },
> +	{ GST_VIDEO_FORMAT_RGBx, formats::XBGR8888 },
> +	{ GST_VIDEO_FORMAT_xBGR, formats::RGBX8888 },
> +	{ GST_VIDEO_FORMAT_xRGB, formats::BGRX8888 },
> +	{ GST_VIDEO_FORMAT_BGRA, formats::ARGB8888 },
> +	{ GST_VIDEO_FORMAT_RGBA, formats::ABGR8888 },
> +	{ GST_VIDEO_FORMAT_ABGR, formats::RGBA8888 },
>   	{ GST_VIDEO_FORMAT_ARGB, formats::BGRA8888 },
>   
>   	/* YUV Semiplanar */
GST formats RGB16, RGB, BGR, BGRx, BGRA tested successfully on i.MX8MP 
platform with ov5640 sensors so:

Tested-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
Nicolas Dufresne via libcamera-devel Aug. 24, 2022, 5:45 p.m. UTC | #6
On Tue, Aug 23, 2022 at 09:38:56PM +0300, Laurent Pinchart via libcamera-devel wrote:
> libcamerasrc only supports three RGB formats. Adding the other RGB
> formats supported by libcamera is trivial, do so.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
> I haven't tested this yet as I don't have a board hooked up that can
> capture these formats. If someone can test it with an OV5640 sensor on
> an i.MX8MP, that would be great, otherwise I'll get to it in the not too
> distant future.
> ---
>  src/gstreamer/gstlibcamera-utils.cpp | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
> index c97c0d438de2..5a21a391c698 100644
> --- a/src/gstreamer/gstlibcamera-utils.cpp
> +++ b/src/gstreamer/gstlibcamera-utils.cpp
> @@ -19,9 +19,21 @@ static struct {
>  	/* Compressed */
>  	{ GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },
>  
> -	/* RGB */
> +	/* RGB16 */
> +	{ GST_VIDEO_FORMAT_RGB16, formats::RGB565 },
> +
> +	/* RGB24 */
>  	{ GST_VIDEO_FORMAT_RGB, formats::BGR888 },
>  	{ GST_VIDEO_FORMAT_BGR, formats::RGB888 },
> +
> +	/* RGB32 */
> +	{ GST_VIDEO_FORMAT_BGRx, formats::XRGB8888 },
> +	{ GST_VIDEO_FORMAT_RGBx, formats::XBGR8888 },
> +	{ GST_VIDEO_FORMAT_xBGR, formats::RGBX8888 },
> +	{ GST_VIDEO_FORMAT_xRGB, formats::BGRX8888 },
> +	{ GST_VIDEO_FORMAT_BGRA, formats::ARGB8888 },
> +	{ GST_VIDEO_FORMAT_RGBA, formats::ABGR8888 },
> +	{ GST_VIDEO_FORMAT_ABGR, formats::RGBA8888 },
>  	{ GST_VIDEO_FORMAT_ARGB, formats::BGRA8888 },
>  
>  	/* YUV Semiplanar */

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
index c97c0d438de2..5a21a391c698 100644
--- a/src/gstreamer/gstlibcamera-utils.cpp
+++ b/src/gstreamer/gstlibcamera-utils.cpp
@@ -19,9 +19,21 @@  static struct {
 	/* Compressed */
 	{ GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },
 
-	/* RGB */
+	/* RGB16 */
+	{ GST_VIDEO_FORMAT_RGB16, formats::RGB565 },
+
+	/* RGB24 */
 	{ GST_VIDEO_FORMAT_RGB, formats::BGR888 },
 	{ GST_VIDEO_FORMAT_BGR, formats::RGB888 },
+
+	/* RGB32 */
+	{ GST_VIDEO_FORMAT_BGRx, formats::XRGB8888 },
+	{ GST_VIDEO_FORMAT_RGBx, formats::XBGR8888 },
+	{ GST_VIDEO_FORMAT_xBGR, formats::RGBX8888 },
+	{ GST_VIDEO_FORMAT_xRGB, formats::BGRX8888 },
+	{ GST_VIDEO_FORMAT_BGRA, formats::ARGB8888 },
+	{ GST_VIDEO_FORMAT_RGBA, formats::ABGR8888 },
+	{ GST_VIDEO_FORMAT_ABGR, formats::RGBA8888 },
 	{ GST_VIDEO_FORMAT_ARGB, formats::BGRA8888 },
 
 	/* YUV Semiplanar */