commit 4079a39d7d69a77390d8668db99a1c1c7c3b6af1
Author: Michael Smith <msmith@rdio.com>
Date:   Tue Sep 11 17:49:39 2012 -0700

    Add support for 4:2:2 10 bit video.

diff --git a/gst-libs/gst/video/video-format.c b/gst-libs/gst/video/video-format.c
index 5cff107..127d674 100644
--- a/gst-libs/gst/video/video-format.c
+++ b/gst-libs/gst/video/video-format.c
@@ -1354,6 +1354,137 @@ pack_I420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
   }
 }
 
+//msmith
+#define PACK_I422_10LE GST_VIDEO_FORMAT_AYUV64, unpack_I422_10LE, 1, pack_I422_10LE
+static void
+unpack_I422_10LE (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;
+  guint16 *srcY = GET_Y_LINE (y);
+  guint16 *srcU = GET_U_LINE (y);
+  guint16 *srcV = GET_V_LINE (y);
+  guint16 *d = dest, Y, U, V;
+
+  for (i = 0; i < width; i++) {
+    Y = GST_READ_UINT16_LE (srcY + i) << 6;
+    U = GST_READ_UINT16_LE (srcU + (i >> 1)) << 6;
+    V = GST_READ_UINT16_LE (srcV + (i >> 1)) << 6;
+
+    if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+      Y |= (Y >> 10);
+      U |= (U >> 10);
+      V |= (V >> 10);
+    }
+
+    d[i * 4 + 0] = 0xffff;
+    d[i * 4 + 1] = Y;
+    d[i * 4 + 2] = U;
+    d[i * 4 + 3] = V;
+  }
+}
+
+static void
+pack_I422_10LE (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 *destY = GET_Y_LINE (y);
+  guint16 *destU = GET_U_LINE (y);
+  guint16 *destV = GET_V_LINE (y);
+  guint16 Y0, Y1, U, V;
+  const guint16 *s = src;
+
+  for (i = 0; i < width - 1; i += 2) {
+    Y0 = (s[i * 4 + 1]) >> 6;
+    Y1 = (s[i * 4 + 5]) >> 6;
+    U = ((s[i * 4 + 2] + s[i * 4 + 6] + 1) >> 1) >> 6;
+    V = ((s[i * 4 + 3] + s[i * 4 + 7] + 1) >> 1) >> 6;
+
+    GST_WRITE_UINT16_LE (destY + i + 0, Y0);
+    GST_WRITE_UINT16_LE (destY + i + 1, Y1);
+    GST_WRITE_UINT16_LE (destU + (i >> 1), U);
+    GST_WRITE_UINT16_LE (destV + (i >> 1), V);
+  }
+  if (i == width - 1) {
+    Y0 = s[i * 4 + 1] >> 6;
+    U = s[i * 4 + 2] >> 6;
+    V = s[i * 4 + 3] >> 6;
+
+    GST_WRITE_UINT16_LE (destY + i, Y0);
+    GST_WRITE_UINT16_LE (destU + (i >> 1), U);
+    GST_WRITE_UINT16_LE (destV + (i >> 1), V);
+  }
+}
+
+#define PACK_I422_10BE GST_VIDEO_FORMAT_AYUV64, unpack_I422_10BE, 1, pack_I422_10BE
+static void
+unpack_I422_10BE (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;
+  guint16 *srcY = GET_Y_LINE (y);
+  guint16 *srcU = GET_U_LINE (y);
+  guint16 *srcV = GET_V_LINE (y);
+  guint16 *d = dest, Y, U, V;
+
+  for (i = 0; i < width; i++) {
+    Y = GST_READ_UINT16_BE (srcY + i) << 6;
+    U = GST_READ_UINT16_BE (srcU + (i >> 1)) << 6;
+    V = GST_READ_UINT16_BE (srcV + (i >> 1)) << 6;
+
+    if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+      Y |= (Y >> 10);
+      U |= (U >> 10);
+      V |= (V >> 10);
+    }
+
+    d[i * 4 + 0] = 0xffff;
+    d[i * 4 + 1] = Y;
+    d[i * 4 + 2] = U;
+    d[i * 4 + 3] = V;
+  }
+}
+
+static void
+pack_I422_10BE (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 *destY = GET_Y_LINE (y);
+  guint16 *destU = GET_U_LINE (y);
+  guint16 *destV = GET_V_LINE (y);
+  guint16 Y0, Y1, U, V;
+  const guint16 *s = src;
+
+  for (i = 0; i < width - 1; i += 2) {
+    Y0 = s[i * 4 + 1] >> 6;
+    Y1 = s[i * 4 + 5] >> 6;
+    U = ((s[i * 4 + 2] + s[i * 4 + 6] + 1) >> 1) >> 6;
+    V = ((s[i * 4 + 3] + s[i * 4 + 7] + 1) >> 1) >> 6;
+
+    GST_WRITE_UINT16_BE (destY + i + 0, Y0);
+    GST_WRITE_UINT16_BE (destY + i + 1, Y1);
+    GST_WRITE_UINT16_BE (destU + (i >> 1), U);
+    GST_WRITE_UINT16_BE (destV + (i >> 1), V);
+  }
+  if (i == width - 1) {
+    Y0 = s[i * 4 + 1] >> 6;
+    U = s[i * 4 + 2] >> 6;
+    V = s[i * 4 + 3] >> 6;
+
+    GST_WRITE_UINT16_BE (destY + i, Y0);
+    GST_WRITE_UINT16_BE (destU + (i >> 1), U);
+    GST_WRITE_UINT16_BE (destV + (i >> 1), V);
+  }
+}
+
 typedef struct
 {
   guint32 fourcc;
@@ -1573,6 +1704,10 @@ static VideoFormat formats[] = {
       PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_10BE),
   MAKE_YUV_LE_FORMAT (I420_10LE, "raw video", 0x00000000, DPTH10_10_10,
       PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_10LE),
+  MAKE_YUV_FORMAT (I422_10BE, "raw video", 0x00000000, DPTH10_10_10,
+      PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_10BE),
+  MAKE_YUV_LE_FORMAT (I422_10LE, "raw video", 0x00000000, DPTH10_10_10,
+      PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_10LE),
 };
 
 static GstVideoFormat
diff --git a/gst-libs/gst/video/video-format.h b/gst-libs/gst/video/video-format.h
index e748161..25229cc 100644
--- a/gst-libs/gst/video/video-format.h
+++ b/gst-libs/gst/video/video-format.h
@@ -72,6 +72,8 @@ G_BEGIN_DECLS
  * @GST_VIDEO_FORMAT_r210: packed 4:4:4 RGB, 10 bits per channel
  * @GST_VIDEO_FORMAT_I420_10BE: planar 4:2:0 YUV, 10 bits per channel
  * @GST_VIDEO_FORMAT_I420_10LE: planar 4:2:0 YUV, 10 bits per channel
+ * @GST_VIDEO_FORMAT_I422_10BE: planar 4:2:2 YUV, 10 bits per channel
+ * @GST_VIDEO_FORMAT_I422_10LE: planar 4:2:2 YUV, 10 bits per channel
  *
  * Enum value describing the most common video formats.
  */
@@ -119,7 +121,9 @@ typedef enum {
   GST_VIDEO_FORMAT_AYUV64,
   GST_VIDEO_FORMAT_r210,
   GST_VIDEO_FORMAT_I420_10BE,
-  GST_VIDEO_FORMAT_I420_10LE
+  GST_VIDEO_FORMAT_I420_10LE,
+  GST_VIDEO_FORMAT_I422_10BE,
+  GST_VIDEO_FORMAT_I422_10LE,
 } GstVideoFormat;
 
 #define GST_VIDEO_MAX_PLANES 4
@@ -433,7 +437,7 @@ const GstVideoFormatInfo *
     "BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, "  \
     "YVYU, Y444, v210, v216, NV12, NV21, GRAY8, GRAY16_BE, GRAY16_LE, " \
     "v308, RGB16, BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, " \
-    "IYU1, ARGB64, AYUV64, r210, I420_10LE, I420_10BE }"
+    "IYU1, ARGB64, AYUV64, r210, I420_10LE, I420_10BE, I422_10LE, I422_10BE }"
 
 /**
  * GST_VIDEO_CAPS_MAKE:
diff --git a/gst-libs/gst/video/video-info.c b/gst-libs/gst/video/video-info.c
index 20406dc..305c947 100644
--- a/gst-libs/gst/video/video-info.c
+++ b/gst-libs/gst/video/video-info.c
@@ -531,6 +531,17 @@ fill_planes (GstVideoInfo * info)
       info->size = info->offset[2] +
           info->stride[2] * (GST_ROUND_UP_2 (height) / 2);
       break;
+    case GST_VIDEO_FORMAT_I422_10LE:
+    case GST_VIDEO_FORMAT_I422_10BE:
+      info->stride[0] = GST_ROUND_UP_4 (width * 2);
+      info->stride[1] = GST_ROUND_UP_4 (width);
+      info->stride[2] = info->stride[1];
+      info->offset[0] = 0;
+      info->offset[1] = info->stride[0] * GST_ROUND_UP_2 (height);
+      info->offset[2] = info->offset[1] +
+          info->stride[1] * GST_ROUND_UP_2 (height);
+      info->size = info->offset[2] + info->stride[2] * GST_ROUND_UP_2 (height);
+      break;
     case GST_VIDEO_FORMAT_ENCODED:
       break;
     case GST_VIDEO_FORMAT_UNKNOWN:
