[libcamera-devel,v2,4/4] gstreamer: Configure the colorSpace in the Stream configuration.
diff mbox series

Message ID 20220707094402.28730-5-rishikeshdonadkar@gmail.com
State Superseded
Headers show
Series
  • Add colorimetry support to libcamera gstreamer element.
Related show

Commit Message

Rishikesh Donadkar July 7, 2022, 9:44 a.m. UTC
Get the colorimetry if requested in the gstreamer pipeline and pass
that to the function colorspace_form_colorimetry() which will set
the colorspace corresponding to the requested colorimetry in the
stream configuration.

Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>
---
 src/gstreamer/gstlibcamera-utils.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Vedant Paranjape July 7, 2022, 1:09 p.m. UTC | #1
Hello Rishikesh,

Thanks for the patch

On Thu, Jul 7, 2022 at 11:45 AM Rishikesh Donadkar
<rishikeshdonadkar@gmail.com> wrote:
>
> Get the colorimetry if requested in the gstreamer pipeline and pass

s/and pass that to the function colorspace_form_colorimetry()/and
convert it to colorspace using the function
colorspace_from_colorimetry()

> that to the function colorspace_form_colorimetry() which will set

s/form/from. Also, given the name of the function, and its usage don't
ally much. I mean to say, colorspace_from_colorimetry should simply
return the colorspace and not try to set it.

> the colorspace corresponding to the requested colorimetry in the
> stream configuration.
>
> Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>
> ---
>  src/gstreamer/gstlibcamera-utils.cpp | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
> index feefead9..229a29cd 100644
> --- a/src/gstreamer/gstlibcamera-utils.cpp
> +++ b/src/gstreamer/gstlibcamera-utils.cpp
> @@ -279,6 +279,13 @@ gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg,
>                 g_critical("Unsupported media type: %s", gst_structure_get_name(s));
>         }
>
> +       /* Configure colorSpace */
> +       if (gst_structure_has_field(s, "colorimetry")) {
> +               const gchar *colorimetry = gst_structure_get_string(s, "colorimetry");
> +               std::optional<ColorSpace> &colorSpace = stream_cfg.colorSpace;
> +               colorspace_form_colorimetry(colorSpace, colorimetry);
> +       }
> +

If you do the changes to the function discussed in the patch 3 thread,
this code snip will be simplified.

<snip>
if (gst_structure_has_field(s, "colorimetry")) {
    const gchar *colorimetry = gst_structure_get_string(s, "colorimetry");
    stream_cfg.colorSpace = colorspace_from_colorimetry(colorimetry);
}
</snip>

Regards,
Vedant Paranjape


>         gint width, height;
>         gst_structure_get_int(s, "width", &width);
>         gst_structure_get_int(s, "height", &height);
> --
> 2.25.1
>

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
index feefead9..229a29cd 100644
--- a/src/gstreamer/gstlibcamera-utils.cpp
+++ b/src/gstreamer/gstlibcamera-utils.cpp
@@ -279,6 +279,13 @@  gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg,
 		g_critical("Unsupported media type: %s", gst_structure_get_name(s));
 	}
 
+	/* Configure colorSpace */
+	if (gst_structure_has_field(s, "colorimetry")) {
+		const gchar *colorimetry = gst_structure_get_string(s, "colorimetry");
+		std::optional<ColorSpace> &colorSpace = stream_cfg.colorSpace;
+		colorspace_form_colorimetry(colorSpace, colorimetry);
+	}
+
 	gint width, height;
 	gst_structure_get_int(s, "width", &width);
 	gst_structure_get_int(s, "height", &height);