summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2021-05-10 14:21:51 +0800
committerHaihao Xiang <haihao.xiang@intel.com>2021-05-11 12:24:41 +0800
commitca046ca73cf5e673f669a382a1589fe3c2ce8752 (patch)
tree0edd0a8aa96be40c673cc9a5a90ee07cf124dfc6
parentc778686a3c933d40ac244b8660afa50e73d03bf0 (diff)
downloadgstreamer-plugins-base-ca046ca73cf5e673f669a382a1589fe3c2ce8752.tar.gz
video: add support for RGBP and BGRP formats
The two RGB planar formats are used in OpenVino [1] gst-launch-1.0 videotestsrc ! video/x-raw,format=BGRP ! fakesink gst-launch-1.0 videotestsrc ! video/x-raw,format=RGBP ! fakesink [1] https://docs.openvinotoolkit.org/latest/openvino_docs_optimization_guide_dldt_optimization_guide.html Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1141>
-rw-r--r--gst-libs/gst/video/video-converter.c6
-rw-r--r--gst-libs/gst/video/video-format.c65
-rw-r--r--gst-libs/gst/video/video-format.h23
-rw-r--r--gst-libs/gst/video/video-info.c2
4 files changed, 94 insertions, 2 deletions
diff --git a/gst-libs/gst/video/video-converter.c b/gst-libs/gst/video/video-converter.c
index 473d0f156..b1b471622 100644
--- a/gst-libs/gst/video/video-converter.c
+++ b/gst-libs/gst/video/video-converter.c
@@ -6396,6 +6396,8 @@ get_scale_format (GstVideoFormat format, gint plane)
case GST_VIDEO_FORMAT_YVU9:
case GST_VIDEO_FORMAT_GBR:
case GST_VIDEO_FORMAT_GBRA:
+ case GST_VIDEO_FORMAT_RGBP:
+ case GST_VIDEO_FORMAT_BGRP:
res = GST_VIDEO_FORMAT_GRAY8;
break;
case GST_VIDEO_FORMAT_GRAY16_BE:
@@ -7203,6 +7205,10 @@ static const VideoTransform transforms[] = {
TRUE, FALSE, FALSE, FALSE, 0, 0, convert_scale_planes},
{GST_VIDEO_FORMAT_GBRA, GST_VIDEO_FORMAT_GBRA, TRUE, FALSE, FALSE, TRUE,
TRUE, TRUE, FALSE, FALSE, 0, 0, convert_scale_planes},
+ {GST_VIDEO_FORMAT_RGBP, GST_VIDEO_FORMAT_RGBP, TRUE, FALSE, FALSE, TRUE,
+ TRUE, FALSE, FALSE, FALSE, 0, 0, convert_scale_planes},
+ {GST_VIDEO_FORMAT_BGRP, GST_VIDEO_FORMAT_BGRP, TRUE, FALSE, FALSE, TRUE,
+ TRUE, FALSE, FALSE, FALSE, 0, 0, convert_scale_planes},
{GST_VIDEO_FORMAT_YVYU, GST_VIDEO_FORMAT_YVYU, TRUE, FALSE, FALSE, TRUE,
TRUE, FALSE, FALSE, FALSE, 0, 0, convert_scale_planes},
diff --git a/gst-libs/gst/video/video-format.c b/gst-libs/gst/video/video-format.c
index 394ad9919..e87dc622b 100644
--- a/gst-libs/gst/video/video-format.c
+++ b/gst-libs/gst/video/video-format.c
@@ -6279,6 +6279,66 @@ pack_Y412_LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
}
}
+#define PACK_RGBP GST_VIDEO_FORMAT_ARGB, unpack_RGBP, 1, pack_RGBP
+static void
+unpack_RGBP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
+ gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
+ const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
+{
+ const guint8 *restrict sr = GET_R_LINE (y);
+ const guint8 *restrict sg = GET_G_LINE (y);
+ const guint8 *restrict sb = GET_B_LINE (y);
+
+ sr += x;
+ sg += x;
+ sb += x;
+
+ video_orc_unpack_Y444 (dest, sr, sg, sb, width);
+}
+
+static void
+pack_RGBP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
+ const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
+ const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
+ gint y, gint width)
+{
+ guint8 *restrict dr = GET_R_LINE (y);
+ guint8 *restrict dg = GET_G_LINE (y);
+ guint8 *restrict db = GET_B_LINE (y);
+
+ video_orc_pack_Y444 (dr, dg, db, src, width);
+}
+
+#define PACK_BGRP GST_VIDEO_FORMAT_ARGB, unpack_BGRP, 1, pack_BGRP
+static void
+unpack_BGRP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
+ gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
+ const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
+{
+ const guint8 *restrict sr = GET_R_LINE (y);
+ const guint8 *restrict sg = GET_G_LINE (y);
+ const guint8 *restrict sb = GET_B_LINE (y);
+
+ sr += x;
+ sg += x;
+ sb += x;
+
+ video_orc_unpack_Y444 (dest, sr, sg, sb, width);
+}
+
+static void
+pack_BGRP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
+ const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
+ const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
+ gint y, gint width)
+{
+ guint8 *restrict dr = GET_R_LINE (y);
+ guint8 *restrict dg = GET_G_LINE (y);
+ guint8 *restrict db = GET_B_LINE (y);
+
+ video_orc_pack_Y444 (dr, dg, db, src, width);
+}
+
typedef struct
{
guint32 fourcc;
@@ -6334,6 +6394,7 @@ typedef struct
#define PLANE021 3, { 0, 2, 1, 0 }
#define PLANE201 3, { 2, 0, 1, 0 }
#define PLANE2013 4, { 2, 0, 1, 3 }
+#define PLANE210 3, { 2, 1, 0, 0 }
/* offsets */
#define OFFS0 { 0, 0, 0, 0 }
@@ -6643,6 +6704,10 @@ static const VideoFormat formats[] = {
MAKE_YUV_T_FORMAT (NV12_32L32, "raw video",
GST_MAKE_FOURCC ('S', 'T', '1', '2'), DPTH888, PSTR122, PLANE011,
OFFS001, SUB420, PACK_NV12_TILED, TILE_32x32 (LINEAR)),
+ MAKE_RGB_FORMAT (RGBP, "raw video", DPTH888, PSTR111, PLANE012, OFFS0, SUB444,
+ PACK_RGBP),
+ MAKE_RGB_FORMAT (BGRP, "raw video", DPTH888, PSTR111, PLANE210, OFFS0, SUB444,
+ PACK_BGRP),
};
static GstVideoFormat
diff --git a/gst-libs/gst/video/video-format.h b/gst-libs/gst/video/video-format.h
index bebfceaeb..cfbb17f16 100644
--- a/gst-libs/gst/video/video-format.h
+++ b/gst-libs/gst/video/video-format.h
@@ -131,6 +131,8 @@ G_BEGIN_DECLS
* @GST_VIDEO_FORMAT_Y412_LE: packed 4:4:4:4 YUV, 12 bits per channel(U-Y-V-A...) (Since: 1.18)
* @GST_VIDEO_FORMAT_NV12_4L4: NV12 with 4x4 tiles in linear order (Since: 1.18)
* @GST_VIDEO_FORMAT_NV12_32L32: NV12 with 32x32 tiles in linear order (Since: 1.18)
+ * @GST_VIDEO_FORMAT_RGBP: planar 4:4:4 RGB, 8 bits per channel (Since: 1.20)
+ * @GST_VIDEO_FORMAT_BGRP: planar 4:4:4 RGB, 8 bits per channel (Since: 1.20)
*
* Enum value describing the most common video formats.
*
@@ -252,6 +254,23 @@ typedef enum {
*/
GST_VIDEO_FORMAT_NV12_32L32,
+ /**
+ * GST_VIDEO_FORMAT_RGBP:
+ *
+ * Planar 4:4:4 RGB, R-G-B order
+ *
+ * Since: 1.20
+ */
+ GST_VIDEO_FORMAT_RGBP,
+
+ /**
+ * GST_VIDEO_FORMAT_BGRP:
+ *
+ * Planar 4:4:4 RGB, B-G-R order
+ *
+ * Since: 1.20
+ */
+ GST_VIDEO_FORMAT_BGRP,
} GstVideoFormat;
#define GST_VIDEO_MAX_PLANES 4
@@ -624,7 +643,7 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
"GBR_12BE, Y444_12LE, GBR_12LE, I422_12BE, I422_12LE, Y212_BE, Y212_LE, I420_12BE, " \
"I420_12LE, P012_BE, P012_LE, Y444_10BE, GBR_10BE, Y444_10LE, GBR_10LE, r210, " \
"I422_10BE, I422_10LE, NV16_10LE32, Y210, v210, UYVP, I420_10BE, I420_10LE, " \
- "P010_10BE, P010_10LE, NV12_10LE32, NV12_10LE40, Y444, GBR, NV24, xBGR, BGRx, " \
+ "P010_10BE, P010_10LE, NV12_10LE32, NV12_10LE40, Y444, GBR, RGBP, BGRP, NV24, xBGR, BGRx, " \
"xRGB, RGBx, BGR, IYU2, v308, RGB, Y42B, NV61, NV16, VYUY, UYVY, YVYU, YUY2, I420, " \
"YV12, NV21, NV12, NV12_64Z32, NV12_4L4, NV12_32L32, Y41B, IYU1, YVU9, YUV9, RGB16, " \
"BGR16, RGB15, BGR15, RGB8P, GRAY16_BE, GRAY16_LE, GRAY10_LE32, GRAY8 }"
@@ -636,7 +655,7 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
"GBR_12LE, Y444_12BE, GBR_12BE, I422_12LE, I422_12BE, Y212_LE, Y212_BE, I420_12LE, " \
"I420_12BE, P012_LE, P012_BE, Y444_10LE, GBR_10LE, Y444_10BE, GBR_10BE, r210, " \
"I422_10LE, I422_10BE, NV16_10LE32, Y210, v210, UYVP, I420_10LE, I420_10BE, " \
- "P010_10LE, NV12_10LE32, NV12_10LE40, P010_10BE, Y444, GBR, NV24, xBGR, BGRx, " \
+ "P010_10LE, NV12_10LE32, NV12_10LE40, P010_10BE, Y444, GBR, RGBP, BGRP, NV24, xBGR, BGRx, " \
"xRGB, RGBx, BGR, IYU2, v308, RGB, Y42B, NV61, NV16, VYUY, UYVY, YVYU, YUY2, I420, " \
"YV12, NV21, NV12, NV12_64Z32, NV12_4L4, NV12_32L32, Y41B, IYU1, YVU9, YUV9, RGB16, " \
"BGR16, RGB15, BGR15, RGB8P, GRAY16_LE, GRAY16_BE, GRAY10_LE32, GRAY8 }"
diff --git a/gst-libs/gst/video/video-info.c b/gst-libs/gst/video/video-info.c
index faf6adbf3..6f9fc7b38 100644
--- a/gst-libs/gst/video/video-info.c
+++ b/gst-libs/gst/video/video-info.c
@@ -912,6 +912,8 @@ fill_planes (GstVideoInfo * info, gsize plane_size[GST_VIDEO_MAX_PLANES])
break;
case GST_VIDEO_FORMAT_Y444:
case GST_VIDEO_FORMAT_GBR:
+ case GST_VIDEO_FORMAT_RGBP:
+ case GST_VIDEO_FORMAT_BGRP:
info->stride[0] = GST_ROUND_UP_4 (width);
info->stride[1] = info->stride[0];
info->stride[2] = info->stride[0];