@@ -73,6 +73,12 @@ static const std::map<ColorSpace::Range, GstVideoColorRange> ToGstVideoColorRang
{ ColorSpace::Range::Limited, GST_VIDEO_COLOR_RANGE_16_235 },
};
+static const std::map<std::string, ColorSpace> colorimetryToColorSpace = {
+ { GST_VIDEO_COLORIMETRY_SRGB, ColorSpace::Srgb },
+ { GST_VIDEO_COLORIMETRY_BT709, ColorSpace::Rec709 },
+ { GST_VIDEO_COLORIMETRY_BT2020, ColorSpace::Rec2020 },
+};
+
static GstVideoFormat
pixel_format_to_gst_format(const PixelFormat &format)
{
@@ -158,6 +164,15 @@ colorimerty_from_colorspace(std::optional<ColorSpace> colorSpace)
return colorimetry_str;
}
+void colorspace_form_colorimetry(std::optional<ColorSpace> &colorspace, const gchar *colorimetry)
+{
+ auto iterColorSpace = colorimetryToColorSpace.find(colorimetry);
+ if (iterColorSpace != colorimetryToColorSpace.end()) {
+ colorspace = iterColorSpace->second;
+ return;
+ }
+}
+
GstCaps *
gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)
{
@@ -20,6 +20,7 @@ void gst_libcamera_configure_stream_from_caps(libcamera::StreamConfiguration &st
GstCaps *caps);
void gst_libcamera_resume_task(GstTask *task);
std::shared_ptr<libcamera::CameraManager> gst_libcamera_get_camera_manager(int &ret);
+void colorspace_form_colorimetry(std::optional<libcamera::ColorSpace> &colorspace, const gchar *colorimetry);
/**
* \class GLibLocker
Add map colorimetryToColorSpace and the function colorspace_form_colorimetry() to convert from gstreamer colorimetry to libcamera colorspace. The obtained colorspace form the conversion will be applied to the colorSpace field of the StreamConfiguration. Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com> --- src/gstreamer/gstlibcamera-utils.cpp | 15 +++++++++++++++ src/gstreamer/gstlibcamera-utils.h | 1 + 2 files changed, 16 insertions(+)