video: add VUYA pixel format
authorHaihao Xiang <haihao.xiang@intel.com>
Fri, 15 Mar 2019 05:13:52 +0000 (13:13 +0800)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 21 Mar 2019 23:05:09 +0000 (23:05 +0000)
AYUV in gstreamer was defined in A-Y-U-V order in memory[1], however
Microsoft defined another AYUV format in V-U-Y-A order in memory[2]. Add
VUYA format for the latter in order to distinguish the two formats

[1] https://gstreamer.freedesktop.org/documentation/design/mediatype-video-raw.html#formats
[2] https://docs.microsoft.com/en-us/windows/desktop/medfound/recommended-8-bit-yuv-formats-for-video-rendering#ayuv)

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-orc.orc

index 5935f12..f8775c5 100644 (file)
@@ -5826,6 +5826,7 @@ get_scale_format (GstVideoFormat format, gint plane)
     case GST_VIDEO_FORMAT_VYUY:
     case GST_VIDEO_FORMAT_YVYU:
     case GST_VIDEO_FORMAT_AYUV:
+    case GST_VIDEO_FORMAT_VUYA:
     case GST_VIDEO_FORMAT_RGBx:
     case GST_VIDEO_FORMAT_BGRx:
     case GST_VIDEO_FORMAT_xRGB:
index 112bbeb..ff813d0 100644 (file)
@@ -5209,6 +5209,32 @@ pack_NV12_10LE40 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
   }
 }
 
+#define PACK_VUYA GST_VIDEO_FORMAT_AYUV, unpack_VUYA, 1, pack_VUYA
+static void
+unpack_VUYA (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 s = GET_LINE (y);
+  guint8 *restrict d = dest;
+
+  s += x * 4;
+
+  video_orc_unpack_VUYA (d, s, width);
+}
+
+static void
+pack_VUYA (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)
+{
+  const guint8 *restrict s = src;
+  guint8 *restrict d = GET_LINE (y);
+
+  video_orc_pack_VUYA (d, s, width);
+}
+
 typedef struct
 {
   guint32 fourcc;
@@ -5536,6 +5562,8 @@ static const VideoFormat formats[] = {
       DPTH10_10_10, PSTR488, PLANE0, OFFS0, SUB422, PACK_Y210),
   MAKE_YUV_FORMAT (Y410, "raw video", GST_MAKE_FOURCC ('Y', '4', '1', '0'),
       DPTH10_10_10_2, PSTR0, PLANE0, OFFS0, SUB4444, PACK_Y410),
+  MAKE_YUVA_PACK_FORMAT (VUYA, "raw video", GST_MAKE_FOURCC ('V', 'U', 'Y',
+          'A'), DPTH8888, PSTR4444, PLANE0, OFFS2103, SUB4444, PACK_VUYA),
 };
 
 static GstVideoFormat
@@ -5780,6 +5808,8 @@ gst_video_format_from_fourcc (guint32 fourcc)
       return GST_VIDEO_FORMAT_NV12_10LE40;
     case GST_MAKE_FOURCC ('Y', '4', '1', '0'):
       return GST_VIDEO_FORMAT_Y410;
+    case GST_MAKE_FOURCC ('V', 'U', 'Y', 'A'):
+      return GST_VIDEO_FORMAT_VUYA;
 
     default:
       return GST_VIDEO_FORMAT_UNKNOWN;
index 86af714..bc392b6 100644 (file)
@@ -116,6 +116,7 @@ G_BEGIN_DECLS
  * @GST_VIDEO_FORMAT_NV12_10LE40: Fully packed variant of NV12_10LE32 (Since: 1.16)
  * @GST_VIDEO_FORMAT_Y210: packed 4:2:2 YUV, 10 bits per channel (Since: 1.16)
  * @GST_VIDEO_FORMAT_Y410: packed 4:4:4 YUV, 10 bits per channel(A-V-Y-U...) (Since: 1.16)
+ * @GST_VIDEO_FORMAT_VUYA: packed 4:4:4 YUV with alpha channel (V0-U0-Y0-A0...) (Since: 1.16)
  *
  * Enum value describing the most common video formats.
  *
@@ -207,6 +208,7 @@ typedef enum {
   GST_VIDEO_FORMAT_NV12_10LE40,
   GST_VIDEO_FORMAT_Y210,
   GST_VIDEO_FORMAT_Y410,
+  GST_VIDEO_FORMAT_VUYA,
 } GstVideoFormat;
 
 #define GST_VIDEO_MAX_PLANES 4
@@ -549,7 +551,7 @@ gconstpointer  gst_video_format_get_palette          (GstVideoFormat format, gsi
 # define GST_VIDEO_OE(s) G_STRINGIFY(s)"_LE"
 #endif
 
-#define GST_VIDEO_FORMATS_ALL "{ I420, YV12, YUY2, UYVY, AYUV, RGBx, "  \
+#define GST_VIDEO_FORMATS_ALL "{ I420, YV12, YUY2, UYVY, AYUV, VUYA, RGBx, "  \
   "BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, YVYU, " \
   "Y444, v210, v216, Y210, Y410, NV12, NV21, GRAY8, GRAY16_BE, GRAY16_LE, v308, RGB16, " \
   "BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, IYU1, ARGB64, " \
index d8cf622..2abbc74 100644 (file)
@@ -763,6 +763,7 @@ fill_planes (GstVideoInfo * info)
     case GST_VIDEO_FORMAT_ABGR:
     case GST_VIDEO_FORMAT_r210:
     case GST_VIDEO_FORMAT_Y410:
+    case GST_VIDEO_FORMAT_VUYA:
       info->stride[0] = width * 4;
       info->offset[0] = 0;
       info->size = info->stride[0] * height;
index f855fd7..6edc16f 100644 (file)
@@ -538,6 +538,20 @@ select0lw ay, ayuv
 select1wb y, ay
 select0wb a, ay
 
+
+.function video_orc_unpack_VUYA
+.dest 4 ayuv guint8
+.source 4 vuya guint8
+
+swapl ayuv, vuya
+
+
+.function video_orc_pack_VUYA
+.dest 4 vuya guint8
+.source 4 ayuv guint8
+
+swapl vuya, ayuv
+
 .function video_orc_unpack_RGB15_le
 .dest 4 argb guint32
 .source 2 rgb15 guint16