video: add IYU2 format
authorJoan Pau Beltran <joanpau.beltran@socib.cat>
Mon, 30 May 2016 14:40:26 +0000 (16:40 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Wed, 1 Jun 2016 11:07:05 +0000 (12:07 +0100)
This existed in 0.10 and is needed by dc1394src.

IYU2 format is a YUV fully-sampled packed format similar to v308
but with different component order (U-Y-V instead of Y-U-V).

http://www.fourcc.org/yuv.php#IYU2

https://bugzilla.gnome.org/show_bug.cgi?id=763026#c5

gst-libs/gst/video/video-converter.c
gst-libs/gst/video/video-format.c
gst-libs/gst/video/video-format.h
gst-libs/gst/video/video-info.c
gst-libs/gst/video/video-scaler.c
tests/check/libs/video.c

index 3a620d7..ccdee43 100644 (file)
@@ -4052,6 +4052,7 @@ get_scale_format (GstVideoFormat format, gint plane)
     case GST_VIDEO_FORMAT_RGB:
     case GST_VIDEO_FORMAT_BGR:
     case GST_VIDEO_FORMAT_v308:
+    case GST_VIDEO_FORMAT_IYU2:
     case GST_VIDEO_FORMAT_ARGB64:
     case GST_VIDEO_FORMAT_AYUV64:
       res = format;
@@ -4779,6 +4780,8 @@ static const VideoTransform transforms[] = {
       FALSE, FALSE, FALSE, 0, 0, convert_scale_planes},
   {GST_VIDEO_FORMAT_v308, GST_VIDEO_FORMAT_v308, TRUE, FALSE, FALSE, TRUE, TRUE,
       FALSE, FALSE, FALSE, 0, 0, convert_scale_planes},
+  {GST_VIDEO_FORMAT_IYU2, GST_VIDEO_FORMAT_IYU2, TRUE, FALSE, FALSE, TRUE, TRUE,
+      FALSE, FALSE, FALSE, 0, 0, convert_scale_planes},
 
   {GST_VIDEO_FORMAT_ARGB, GST_VIDEO_FORMAT_ARGB, TRUE, FALSE, FALSE, TRUE, TRUE,
       TRUE, FALSE, FALSE, 0, 0, convert_scale_planes},
index f757725..1369d6a 100644 (file)
@@ -416,6 +416,43 @@ pack_v308 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
   }
 }
 
+#define PACK_IYU2 GST_VIDEO_FORMAT_AYUV, unpack_IYU2, 1, pack_IYU2
+static void
+unpack_IYU2 (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 guint8 *restrict s = GET_LINE (y);
+  guint8 *restrict d = dest;
+
+  s += x * 3;
+
+  for (i = 0; i < width; i++) {
+    d[i * 4 + 0] = 0xff;
+    d[i * 4 + 1] = s[i * 3 + 1];
+    d[i * 4 + 2] = s[i * 3 + 0];
+    d[i * 4 + 3] = s[i * 3 + 2];
+  }
+}
+
+static void
+pack_IYU2 (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;
+  guint8 *restrict d = GET_LINE (y);
+  const guint8 *restrict s = src;
+
+  for (i = 0; i < width; i++) {
+    d[i * 3 + 0] = s[i * 4 + 2];
+    d[i * 3 + 1] = s[i * 4 + 1];
+    d[i * 3 + 2] = s[i * 4 + 3];
+  }
+}
+
 #define PACK_AYUV GST_VIDEO_FORMAT_AYUV, unpack_copy4, 1, pack_copy4
 #define PACK_ARGB GST_VIDEO_FORMAT_ARGB, unpack_copy4, 1, pack_copy4
 static void
@@ -3825,6 +3862,8 @@ static const VideoFormat formats[] = {
       PSTR244, PLANE011, OFFS001, SUB420, PACK_P010_10BE),
   MAKE_YUV_LE_FORMAT (P010_10LE, "raw video", 0x00000000, DPTH10_10_10_HI,
       PSTR244, PLANE011, OFFS001, SUB420, PACK_P010_10LE),
+  MAKE_YUV_FORMAT (IYU2, "raw video", GST_MAKE_FOURCC ('I', 'Y', 'U', '2'),
+      DPTH888, PSTR333, PLANE0, OFFS102, SUB444, PACK_IYU2),
 };
 
 static GstVideoFormat
@@ -4035,6 +4074,8 @@ gst_video_format_from_fourcc (guint32 fourcc)
       return GST_VIDEO_FORMAT_NV24;
     case GST_MAKE_FOURCC ('v', '3', '0', '8'):
       return GST_VIDEO_FORMAT_v308;
+    case GST_MAKE_FOURCC ('I', 'Y', 'U', '2'):
+      return GST_VIDEO_FORMAT_IYU2;
     case GST_MAKE_FOURCC ('Y', '8', '0', '0'):
     case GST_MAKE_FOURCC ('Y', '8', ' ', ' '):
     case GST_MAKE_FOURCC ('G', 'R', 'E', 'Y'):
index b406cd3..e7f83d8 100644 (file)
@@ -60,7 +60,8 @@ G_BEGIN_DECLS
  * @GST_VIDEO_FORMAT_GRAY8: 8-bit grayscale
  * @GST_VIDEO_FORMAT_GRAY16_BE: 16-bit grayscale, most significant byte first
  * @GST_VIDEO_FORMAT_GRAY16_LE: 16-bit grayscale, least significant byte first
- * @GST_VIDEO_FORMAT_v308: packed 4:4:4 YUV
+ * @GST_VIDEO_FORMAT_v308: packed 4:4:4 YUV (Y-U-V ...)
+ * @GST_VIDEO_FORMAT_IYU2: packed 4:4:4 YUV (U-Y-V ...) (Since 1.10)
  * @GST_VIDEO_FORMAT_RGB16: rgb 5-6-5 bits per component
  * @GST_VIDEO_FORMAT_BGR16: reverse rgb 5-6-5 bits per component
  * @GST_VIDEO_FORMAT_RGB15: rgb 5-5-5 bits per component
@@ -162,6 +163,7 @@ typedef enum {
   GST_VIDEO_FORMAT_NV61,
   GST_VIDEO_FORMAT_P010_10BE,
   GST_VIDEO_FORMAT_P010_10LE,
+  GST_VIDEO_FORMAT_IYU2,
 } GstVideoFormat;
 
 #define GST_VIDEO_MAX_PLANES 4
@@ -497,10 +499,10 @@ gconstpointer  gst_video_format_get_palette          (GstVideoFormat format, gsi
 #define GST_VIDEO_FORMATS_ALL "{ I420, YV12, YUY2, UYVY, AYUV, RGBx, "  \
     "BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, "  \
     "YVYU, Y444, v210, v216, NV12, NV21, NV16, NV61, NV24, GRAY8, GRAY16_BE, " \
-    "GRAY16_LE, v308, RGB16, BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, " \
+    "GRAY16_LE, v308, IYU2, RGB16, BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, " \
     "IYU1, ARGB64, AYUV64, r210, I420_10LE, I420_10BE, I422_10LE, I422_10BE, " \
-    " Y444_10LE, Y444_10BE, GBR, GBR_10LE, GBR_10BE, NV12_64Z32, A420_10LE, "\
-    " A420_10BE, A422_10LE, A422_10BE, A444_10LE, A444_10BE, P010_10LE, P010_10BE }"
+    "Y444_10LE, Y444_10BE, GBR, GBR_10LE, GBR_10BE, NV12_64Z32, A420_10LE, "\
+    "A420_10BE, A422_10LE, A422_10BE, A444_10LE, A444_10BE, P010_10LE, P010_10BE }"
 
 /**
  * GST_VIDEO_CAPS_MAKE:
index 91e50f2..57b9db7 100644 (file)
@@ -644,6 +644,7 @@ fill_planes (GstVideoInfo * info)
     case GST_VIDEO_FORMAT_RGB:
     case GST_VIDEO_FORMAT_BGR:
     case GST_VIDEO_FORMAT_v308:
+    case GST_VIDEO_FORMAT_IYU2:
       info->stride[0] = GST_ROUND_UP_4 (width * 3);
       info->offset[0] = 0;
       info->size = info->stride[0] * height;
index 18bd09c..b633cb4 100644 (file)
@@ -1212,6 +1212,7 @@ get_functions (GstVideoScaler * hscale, GstVideoScaler * vscale,
     case GST_VIDEO_FORMAT_RGB:
     case GST_VIDEO_FORMAT_BGR:
     case GST_VIDEO_FORMAT_v308:
+    case GST_VIDEO_FORMAT_IYU2:
       bits = 8;
       *n_elems = 3;
       break;
index b8decf1..51032f5 100644 (file)
@@ -343,6 +343,7 @@ video_format_is_packed (GstVideoFormat fmt)
     case GST_VIDEO_FORMAT_YVU9:
       return FALSE;
     case GST_VIDEO_FORMAT_IYU1:
+    case GST_VIDEO_FORMAT_IYU2:
     case GST_VIDEO_FORMAT_YUY2:
     case GST_VIDEO_FORMAT_YVYU:
     case GST_VIDEO_FORMAT_UYVY: