[libcamera-devel] libcamerasrc on librem 5: bayer support missing

Nicolas Dufresne nicolas at ndufresne.ca
Mon Dec 19 17:53:45 CET 2022


Le samedi 17 décembre 2022 à 22:48 +0100, Pavel Machek a écrit :
> Hi!
> 
> > > Is there any way to get libcamerasrc (gstreamer glue) to work on
> > > Librem 5?
> > > 
> > > As far as I can tell, libcamerasrc does not support bayer formats,
> > > thus I can't really use gstreamer glue on Librem 5.
> > > 
> > > Would it be simple to add such support?
> 
> 
> > Note that "some" patterns are already supported. If it's the case, you just
> > need to map these into libcamerasrc.
> 
> This gets me going. I don't know how to pass details of bayer format,
> so help would be welcome there.


      video/x-bayer
                 format: { (string)bggr, (string)grbg, (string)gbrg, (string)rggb }


So in you case, create caps that looks like video/x-bayer, format=grbg, width=X,
height=Y. Stride must match the Width * 4, cause there is no custom stride
support yet.

Nicolas

> 
> Best regards,
> 								Pavel
> 
> 
> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
> index 36b9564c..ed5f4449 100644
> --- a/src/gstreamer/gstlibcamera-utils.cpp
> +++ b/src/gstreamer/gstlibcamera-utils.cpp
> @@ -55,6 +55,10 @@ static struct {
>  	{ GST_VIDEO_FORMAT_YUY2, formats::YUYV },
>  	{ GST_VIDEO_FORMAT_YVYU, formats::YVYU },
>  
> +	/* Lie about bayer */
> +	{ GST_VIDEO_FORMAT_ENCODED, formats::SGRBG8 },
> +
> +
>  	/* \todo NV42 is used in libcamera but is not mapped in GStreamer yet. */
>  };
>  
> @@ -233,6 +237,8 @@ bare_structure_from_format(const PixelFormat &format)
>  {
>  	GstVideoFormat gst_format = pixel_format_to_gst_format(format);
>  
> +	printf("bare_structure_from_format: XXX\n");
> +
>  	if (gst_format == GST_VIDEO_FORMAT_UNKNOWN)
>  		return nullptr;
>  
> @@ -243,6 +249,8 @@ bare_structure_from_format(const PixelFormat &format)
>  	switch (format) {
>  	case formats::MJPEG:
>  		return gst_structure_new_empty("image/jpeg");
> +	case formats::SGRBG8:
> +		return gst_structure_new_empty("video/x-bayer");
>  	default:
>  		return nullptr;
>  	}
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> index 8d97d7c2..2ceeeb99 100644
> --- a/src/gstreamer/gstlibcamerasrc.cpp
> +++ b/src/gstreamer/gstlibcamerasrc.cpp
> @@ -161,7 +161,7 @@ G_DEFINE_TYPE_WITH_CODE(GstLibcameraSrc, gst_libcamera_src, GST_TYPE_ELEMENT,
>  			GST_DEBUG_CATEGORY_INIT(source_debug, "libcamerasrc", 0,
>  						"libcamera Source"))
>  
> -#define TEMPLATE_CAPS GST_STATIC_CAPS("video/x-raw; image/jpeg")
> +#define TEMPLATE_CAPS GST_STATIC_CAPS("video/x-raw; video/x-bayer; image/jpeg")
>  
>  /* For the simple case, we have a src pad that is always present. */
>  GstStaticPadTemplate src_template = {
> 
> 



More information about the libcamera-devel mailing list