video: Add INVZ pixel format
authorsangho park <sangho.g.park@samsung.com>
Wed, 18 Jul 2018 06:45:21 +0000 (15:45 +0900)
committersangho park <sangho.g.park@samsung.com>
Tue, 24 Jul 2018 05:15:43 +0000 (14:15 +0900)
This pixel format is a planar depth 16-bit to use Intel Realsense devices.

Change-Id: I2109b581035e0da589714c4a4ff3af628c554dc1
Signed-off-by: sangho park <sangho.g.park@samsung.com>
gst-libs/gst/video/video-format.c
gst-libs/gst/video/video-format.h
gst-libs/gst/video/video-info.c

index 187b589..4d2a013 100644 (file)
@@ -4549,6 +4549,41 @@ pack_P010_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
   }
 }
 
+#define PACK_INVZ16_LE GST_VIDEO_FORMAT_AYUV64, unpack_INVZ16_LE, 1, pack_INVZ16_LE
+static void
+unpack_INVZ16_LE (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)
+{
+  int i;
+  const guint16 *restrict s = GET_LINE (y);
+  guint16 *restrict d = dest;
+
+  s += x;
+
+  for (i = 0; i < width; i++) {
+    d[i * 4 + 0] = 0xffff;
+    d[i * 4 + 1] = GST_READ_UINT16_LE (s + i);
+    d[i * 4 + 2] = 0x8000;
+    d[i * 4 + 3] = 0x8000;
+  }
+}
+
+static void
+pack_INVZ16_LE (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)
+{
+  int i;
+  guint16 *restrict d = GET_LINE (y);
+  const guint16 *restrict s = src;
+
+  for (i = 0; i < width; i++) {
+    GST_WRITE_UINT16_LE (d + i, s[i * 4 + 1]);
+  }
+}
+
 typedef struct
 {
   guint32 fourcc;
@@ -4672,6 +4707,9 @@ typedef struct
 #define MAKE_GRAY_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
  { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_GRAY | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
 
+#define MAKE_DEPTH_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
+ { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_GRAY | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
+
 static const VideoFormat formats[] = {
   {0x00000000, {GST_VIDEO_FORMAT_UNKNOWN, "UNKNOWN", "unknown video", 0, DPTH0,
           PSTR0, PLANE_NA, OFFS0}},
@@ -4868,6 +4906,8 @@ static const VideoFormat formats[] = {
       PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_12BE),
   MAKE_YUV_LE_FORMAT (Y444_12LE, "raw video", 0x00000000, DPTH12_12_12,
       PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_12LE),
+  MAKE_DEPTH_FORMAT (INVZ, "raw video", GST_MAKE_FOURCC ('I', 'N', 'V', 'Z'),
+      DPTH16, PSTR2, PLANE0, OFFS0, SUB4, PACK_INVZ16_LE),
 #ifdef TIZEN_PROFILE_TV
   MAKE_YUV_FORMAT (STV0, "raw video", GST_MAKE_FOURCC ('S', 'T', 'V', '0'),
       DPTH888, PSTR111, PLANE012, OFFS0, SUB420, PACK_420),
@@ -5122,6 +5162,8 @@ gst_video_format_from_fourcc (guint32 fourcc)
       return GST_VIDEO_FORMAT_IYU1;
     case GST_MAKE_FOURCC ('A', 'Y', '6', '4'):
       return GST_VIDEO_FORMAT_AYUV64;
+    case GST_MAKE_FOURCC ('I', 'N', 'V', 'Z'):
+      return GST_VIDEO_FORMAT_INVZ;
     default:
       return GST_VIDEO_FORMAT_UNKNOWN;
   }
index 9326968..c9c3bbb 100644 (file)
@@ -110,6 +110,7 @@ G_BEGIN_DECLS
  * @GST_VIDEO_FORMAT_I422_12LE: planar 4:2:2 YUV, 12 bits per channel (Since: 1.12)
  * @GST_VIDEO_FORMAT_Y444_12BE: planar 4:4:4 YUV, 12 bits per channel (Since: 1.12)
  * @GST_VIDEO_FORMAT_Y444_12LE: planar 4:4:4 YUV, 12 bits per channel (Since: 1.12)
+ * @GST_VIDEO_FORMAT_INVZ: 16-bit depth data with distance values at each pixel (Since: 1.16)
  *
  * Enum value describing the most common video formats.
  */
@@ -198,6 +199,7 @@ typedef enum {
   GST_VIDEO_FORMAT_I422_12LE,
   GST_VIDEO_FORMAT_Y444_12BE,
   GST_VIDEO_FORMAT_Y444_12LE,
+  GST_VIDEO_FORMAT_INVZ,
   GST_VIDEO_FORMAT_STV0, /* TIZEN_PROFILE_TV */
   GST_VIDEO_FORMAT_STV1, /* TIZEN_PROFILE_TV */  
 } GstVideoFormat;
@@ -541,7 +543,7 @@ gconstpointer  gst_video_format_get_palette          (GstVideoFormat format, gsi
   "A420_10LE, A422_10BE, A422_10LE, A444_10BE, A444_10LE, NV61, P010_10BE, " \
   "P010_10LE, IYU2, VYUY, GBRA, GBRA_10BE, GBRA_10LE, GBR_12BE, GBR_12LE, " \
   "GBRA_12BE, GBRA_12LE, I420_12BE, I420_12LE, I422_12BE, I422_12LE, " \
-  "Y444_12BE, Y444_12LE }"
+  "Y444_12BE, Y444_12LE, INVZ }"
 
 /**
  * GST_VIDEO_CAPS_MAKE:
index f2999af..5c9a744 100644 (file)
@@ -752,6 +752,7 @@ fill_planes (GstVideoInfo * info)
       break;
     case GST_VIDEO_FORMAT_GRAY16_BE:
     case GST_VIDEO_FORMAT_GRAY16_LE:
+    case GST_VIDEO_FORMAT_INVZ:
       info->stride[0] = GST_ROUND_UP_4 (width * 2);
       info->offset[0] = 0;
       info->size = info->stride[0] * height;