[{"id":5163,"web_url":"https://patchwork.libcamera.org/comment/5163/","msgid":"<20200610142838.GD192296@oden.dyn.berto.se>","date":"2020-06-10T14:28:38","subject":"Re: [libcamera-devel] [PATCH v2 2/7] gst: Replace explicit DRM\n\tFourCCs with libcamera formats","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-06-10 02:23:18 +0300, Laurent Pinchart wrote:\n> Use the new pixel format constants to replace usage of macros from\n> drm_fourcc.h.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/gstreamer/gstlibcamera-utils.cpp | 62 ++++++++++++++--------------\n>  1 file changed, 31 insertions(+), 31 deletions(-)\n> \n> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\n> index a3cb0746e012..61370d5fad56 100644\n> --- a/src/gstreamer/gstlibcamera-utils.cpp\n> +++ b/src/gstreamer/gstlibcamera-utils.cpp\n> @@ -8,56 +8,56 @@\n>  \n>  #include \"gstlibcamera-utils.h\"\n>  \n> -#include <linux/drm_fourcc.h>\n> +#include <libcamera/formats.h>\n>  \n>  using namespace libcamera;\n>  \n>  static struct {\n>  \tGstVideoFormat gst_format;\n> -\tguint drm_fourcc;\n> +\tPixelFormat format;\n>  } format_map[] = {\n> -\t{ GST_VIDEO_FORMAT_ENCODED, DRM_FORMAT_MJPEG },\n> -\t{ GST_VIDEO_FORMAT_RGB, DRM_FORMAT_BGR888 },\n> -\t{ GST_VIDEO_FORMAT_BGR, DRM_FORMAT_RGB888 },\n> -\t{ GST_VIDEO_FORMAT_ARGB, DRM_FORMAT_BGRA8888 },\n> -\t{ GST_VIDEO_FORMAT_NV12, DRM_FORMAT_NV12 },\n> -\t{ GST_VIDEO_FORMAT_NV21, DRM_FORMAT_NV21 },\n> -\t{ GST_VIDEO_FORMAT_NV16, DRM_FORMAT_NV16 },\n> -\t{ GST_VIDEO_FORMAT_NV61, DRM_FORMAT_NV61 },\n> -\t{ GST_VIDEO_FORMAT_NV24, DRM_FORMAT_NV24 },\n> -\t{ GST_VIDEO_FORMAT_UYVY, DRM_FORMAT_UYVY },\n> -\t{ GST_VIDEO_FORMAT_VYUY, DRM_FORMAT_VYUY },\n> -\t{ GST_VIDEO_FORMAT_YUY2, DRM_FORMAT_YUYV },\n> -\t{ GST_VIDEO_FORMAT_YVYU, DRM_FORMAT_YVYU },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },\n> +\t{ GST_VIDEO_FORMAT_RGB, formats::BGR888 },\n> +\t{ GST_VIDEO_FORMAT_BGR, formats::RGB888 },\n> +\t{ GST_VIDEO_FORMAT_ARGB, formats::BGRA8888 },\n> +\t{ GST_VIDEO_FORMAT_NV12, formats::NV12 },\n> +\t{ GST_VIDEO_FORMAT_NV21, formats::NV21 },\n> +\t{ GST_VIDEO_FORMAT_NV16, formats::NV16 },\n> +\t{ GST_VIDEO_FORMAT_NV61, formats::NV61 },\n> +\t{ GST_VIDEO_FORMAT_NV24, formats::NV24 },\n> +\t{ GST_VIDEO_FORMAT_UYVY, formats::UYVY },\n> +\t{ GST_VIDEO_FORMAT_VYUY, formats::VYUY },\n> +\t{ GST_VIDEO_FORMAT_YUY2, formats::YUYV },\n> +\t{ GST_VIDEO_FORMAT_YVYU, formats::YVYU },\n>  \t/* \\todo NV42 is used in libcamera but is not mapped in GStreamer yet. */\n>  };\n>  \n>  static GstVideoFormat\n> -drm_to_gst_format(guint drm_fourcc)\n> +pixel_format_to_gst_format(const PixelFormat &format)\n>  {\n>  \tfor (const auto &item : format_map) {\n> -\t\tif (item.drm_fourcc == drm_fourcc)\n> +\t\tif (item.format == format)\n>  \t\t\treturn item.gst_format;\n>  \t}\n>  \treturn GST_VIDEO_FORMAT_UNKNOWN;\n>  }\n>  \n> -static guint\n> -gst_format_to_drm(GstVideoFormat gst_format)\n> +static PixelFormat\n> +gst_format_to_pixel_format(GstVideoFormat gst_format)\n>  {\n>  \tif (gst_format == GST_VIDEO_FORMAT_ENCODED)\n> -\t\treturn DRM_FORMAT_INVALID;\n> +\t\treturn PixelFormat{};\n>  \n>  \tfor (const auto &item : format_map)\n>  \t\tif (item.gst_format == gst_format)\n> -\t\t\treturn item.drm_fourcc;\n> -\treturn DRM_FORMAT_INVALID;\n> +\t\t\treturn item.format;\n> +\treturn PixelFormat{};\n>  }\n>  \n>  static GstStructure *\n> -bare_structure_from_fourcc(guint fourcc)\n> +bare_structure_from_format(const PixelFormat &format)\n>  {\n> -\tGstVideoFormat gst_format = drm_to_gst_format(fourcc);\n> +\tGstVideoFormat gst_format = pixel_format_to_gst_format(format);\n>  \n>  \tif (gst_format == GST_VIDEO_FORMAT_UNKNOWN)\n>  \t\treturn nullptr;\n> @@ -66,8 +66,8 @@ bare_structure_from_fourcc(guint fourcc)\n>  \t\treturn gst_structure_new(\"video/x-raw\", \"format\", G_TYPE_STRING,\n>  \t\t\t\t\t gst_video_format_to_string(gst_format), nullptr);\n>  \n> -\tswitch (fourcc) {\n> -\tcase DRM_FORMAT_MJPEG:\n> +\tswitch (format) {\n> +\tcase formats::MJPEG:\n>  \t\treturn gst_structure_new_empty(\"image/jpeg\");\n>  \tdefault:\n>  \t\treturn nullptr;\n> @@ -80,7 +80,7 @@ gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)\n>  \tGstCaps *caps = gst_caps_new_empty();\n>  \n>  \tfor (PixelFormat pixelformat : formats.pixelformats()) {\n> -\t\tg_autoptr(GstStructure) bare_s = bare_structure_from_fourcc(pixelformat);\n> +\t\tg_autoptr(GstStructure) bare_s = bare_structure_from_format(pixelformat);\n>  \n>  \t\tif (!bare_s) {\n>  \t\t\tGST_WARNING(\"Unsupported DRM format %\" GST_FOURCC_FORMAT,\n> @@ -120,7 +120,7 @@ GstCaps *\n>  gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg)\n>  {\n>  \tGstCaps *caps = gst_caps_new_empty();\n> -\tGstStructure *s = bare_structure_from_fourcc(stream_cfg.pixelFormat);\n> +\tGstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat);\n>  \n>  \tgst_structure_set(s,\n>  \t\t\t  \"width\", G_TYPE_INT, stream_cfg.size.width,\n> @@ -135,7 +135,7 @@ void\n>  gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg,\n>  \t\t\t\t\t GstCaps *caps)\n>  {\n> -\tGstVideoFormat gst_format = drm_to_gst_format(stream_cfg.pixelFormat);\n> +\tGstVideoFormat gst_format = pixel_format_to_gst_format(stream_cfg.pixelFormat);\n>  \n>  \t/* First fixate the caps using default configuration value. */\n>  \tg_assert(gst_caps_is_writable(caps));\n> @@ -154,9 +154,9 @@ gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg,\n>  \tif (gst_structure_has_name(s, \"video/x-raw\")) {\n>  \t\tconst gchar *format = gst_structure_get_string(s, \"format\");\n>  \t\tgst_format = gst_video_format_from_string(format);\n> -\t\tstream_cfg.pixelFormat = PixelFormat(gst_format_to_drm(gst_format));\n> +\t\tstream_cfg.pixelFormat = gst_format_to_pixel_format(gst_format);\n>  \t} else if (gst_structure_has_name(s, \"image/jpeg\")) {\n> -\t\tstream_cfg.pixelFormat = PixelFormat(DRM_FORMAT_MJPEG);\n> +\t\tstream_cfg.pixelFormat = formats::MJPEG;\n>  \t} else {\n>  \t\tg_critical(\"Unsupported media type: %s\", gst_structure_get_name(s));\n>  \t}\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F3A5B600F7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Jun 2020 16:28:39 +0200 (CEST)","by mail-lj1-x244.google.com with SMTP id a25so2753322ljp.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Jun 2020 07:28:39 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tn23sm5858060lfq.76.2020.06.10.07.28.38\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 10 Jun 2020 07:28:38 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"YO2eZRB6\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=lUOgIBqDLd1w4nYWAj6dBXHV/K7nrLGC/zIESqw4Cvc=;\n\tb=YO2eZRB669F2b8xdMMxMPYEzCMe/0B2nuQ/W5x4ghFcH0KBSJX5eKl2j44Jw7PIh5y\n\teW/vgpT2rUm4SNa4z5Tz2Miz9HJPkP8ToUjcDoOb+ZYRFs3Tv5F5QigJW+u60RpeBbRw\n\tbbEb+hsDrrQ2XUsuNcz8IQhmFxBK0M8I718F7iamHtS4KALs5/eljgFswnky2jxzAJcV\n\t2AjfjpatqZgHwyDqaSbaIEr62zn/mg7GWSS6ca0sPUc08buM9Y9kqaT+6fZKmmPW0APr\n\tS+cu/sT9i09nZYArYbhoAaC55o5oNctom4eIi7Wk0FMQ7GoMb4zRDM/w2vConDuzSRmp\n\t7TFw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=lUOgIBqDLd1w4nYWAj6dBXHV/K7nrLGC/zIESqw4Cvc=;\n\tb=W3wbCu2/xaRg1FYplYT7rnLiOh+76LPBLPhZjGBrBxVEbqsdBcSNX942C9hQhig5yd\n\tSxRSeGcxXemELI2WuCWq1eb94R3GxyBbGfVmlS7xs52YenefBbmqlPwbZ0oQp4mcHDa9\n\t/eI+taa32KHEb8inNK1FtvPuM9/e+hJFtYGguoBg+OAQ9zE/faKshwfvZ78wbmVMFyma\n\teAjZCOSjzcT3q8v0diZ/mxMddugQioiiJQqhjwn20CJP6Z+5ft4LZyPOaYUuifr/FNrR\n\tNiNmD+glp3ER7jCiLtGHFjpB0HLApI+gqjgLASD/fgXdZRdqY06hfzEll+Y3tvgjnmyT\n\tOE/w==","X-Gm-Message-State":"AOAM5318MGe97ssNWa/qdvjdGGr3SkgfXHHGmzfMrM3fRQiUkMx/vgPc\n\tQBIQFC5d6k2Jpp5SLl5PG32345UXSb8=","X-Google-Smtp-Source":"ABdhPJzwRzzzOskGGJ4qKl8ifpZe4+TDsB0mPZT7OzAp6OgDMKVa3+OV0wqacdTqcwME/VqoVYdPfA==","X-Received":"by 2002:a2e:b0ce:: with SMTP id g14mr1905850ljl.49.1591799319277;\n\tWed, 10 Jun 2020 07:28:39 -0700 (PDT)","Date":"Wed, 10 Jun 2020 16:28:38 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200610142838.GD192296@oden.dyn.berto.se>","References":"<20200609232323.29628-1-laurent.pinchart@ideasonboard.com>\n\t<20200609232323.29628-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200609232323.29628-3-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/7] gst: Replace explicit DRM\n\tFourCCs with libcamera formats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Wed, 10 Jun 2020 14:28:40 -0000"}}]