}
}
+#define PACK_AV12 GST_VIDEO_FORMAT_AYUV, unpack_AV12, 1, pack_AV12
+static void
+unpack_AV12 (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)
+{
+ gint uv = GET_UV_420 (y, flags);
+ const guint8 *restrict sy = GET_PLANE_LINE (0, y);
+ const guint8 *restrict suv = GET_PLANE_LINE (1, uv);
+ const guint8 *restrict sa = GET_PLANE_LINE (2, y); /* a is for 'alpha' */
+ guint8 *restrict d = dest;
+
+ sy += x;
+ sa += x;
+ suv += (x & ~1);
+
+ if (x & 1) {
+ d[0] = *sa++;
+ d[1] = *sy++;
+ d[2] = suv[0];
+ d[3] = suv[1];
+ width--;
+ d += 4;
+ suv += 2;
+ }
+
+ if (IS_ALIGNED (d, 8)) {
+ video_orc_unpack_AV12 (d, sy, suv, sa, width / 2);
+ } else {
+ gint i;
+ for (i = 0; i < width / 2; i++) {
+ d[i * 8 + 0] = sa[i * 2 + 0];
+ d[i * 8 + 1] = sy[i * 2 + 0];
+ d[i * 8 + 2] = suv[i * 2 + 0];
+ d[i * 8 + 3] = suv[i * 2 + 1];
+ d[i * 8 + 4] = sa[i * 2 + 1];
+ d[i * 8 + 5] = sy[i * 2 + 1];
+ d[i * 8 + 6] = suv[i * 2 + 0];
+ d[i * 8 + 7] = suv[i * 2 + 1];
+ }
+ }
+
+ if (width & 1) {
+ gint i = width - 1;
+
+ d[i * 4 + 0] = sa[i];
+ d[i * 4 + 1] = sy[i];
+ d[i * 4 + 2] = suv[i + 0];
+ d[i * 4 + 3] = suv[i + 1];
+ }
+}
+
+static void
+pack_AV12 (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)
+{
+ gint uv = GET_UV_420 (y, flags);
+ guint8 *restrict dy = GET_PLANE_LINE (0, y);
+ guint8 *restrict duv = GET_PLANE_LINE (1, uv);
+ guint8 *restrict da = GET_PLANE_LINE (2, y); /* a is for 'alpha' */
+ const guint8 *restrict s = src;
+
+ if (IS_CHROMA_LINE_420 (y, flags)) {
+ if (IS_ALIGNED (s, 8)) {
+ video_orc_pack_AV12 (dy, duv, da, s, width / 2);
+ } else {
+ gint i;
+ for (i = 0; i < width / 2; i++) {
+ /* AYUV_AYUV: alpha is on bytes 0 and 4 */
+ da[i * 2 + 0] = s[i * 8 + 0];
+ da[i * 2 + 1] = s[i * 8 + 4];
+ dy[i * 2 + 0] = s[i * 8 + 1];
+ dy[i * 2 + 1] = s[i * 8 + 5];
+ duv[i * 2 + 0] = s[i * 8 + 2];
+ duv[i * 2 + 1] = s[i * 8 + 3];
+ }
+ }
+ if (width & 1) {
+ gint i = width - 1;
+
+ da[i] = s[i * 4 + 0]; /* AYUV: alpha is byte 0 */
+ dy[i] = s[i * 4 + 1];
+ duv[i + 0] = s[i * 4 + 2];
+ duv[i + 1] = s[i * 4 + 3];
+ }
+ } else {
+ video_orc_pack_YA (dy, da, s, width);
+ }
+}
+
static void
pack_NV21 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
static void
get_tile_NV12 (gint tile_width, gint ts, gint tx, gint ty,
+ GstVideoTileMode mode,
const gpointer data[GST_VIDEO_MAX_PLANES],
const gint stride[GST_VIDEO_MAX_PLANES],
gpointer tile_data[GST_VIDEO_MAX_PLANES],
gsize offset;
/* index of Y tile */
- offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
+ offset = gst_video_tile_get_index (mode,
tx, ty, GST_VIDEO_TILE_X_TILES (stride[0]),
GST_VIDEO_TILE_Y_TILES (stride[0]));
offset <<= ts;
tile_data[0] = ((guint8 *) data[0]) + offset;
/* index of UV tile */
- offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
+ offset = gst_video_tile_get_index (mode,
tx, ty >> 1, GST_VIDEO_TILE_X_TILES (stride[1]),
GST_VIDEO_TILE_Y_TILES (stride[1]));
offset <<= ts;
tile_stride[0] = tile_stride[1] = tile_width;
}
-#define PACK_NV12_64Z32 GST_VIDEO_FORMAT_AYUV, unpack_NV12_64Z32, 1, pack_NV12_64Z32
+#define PACK_NV12_TILED GST_VIDEO_FORMAT_AYUV, unpack_NV12_TILED, 1, pack_NV12_TILED
static void
-unpack_NV12_64Z32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
+unpack_NV12_TILED (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)
{
gint tstride[GST_VIDEO_MAX_PLANES];
gint unpack_width;
- get_tile_NV12 (tile_width, ts, tx, ty, data, stride, tdata, tstride);
+ get_tile_NV12 (tile_width, ts, tx, ty, info->tile_mode,
+ data, stride, tdata, tstride);
/* the number of bytes left to unpack */
unpack_width = MIN (width - x, tile_width - x);
}
static void
-pack_NV12_64Z32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
+pack_NV12_TILED (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)
gint tstride[GST_VIDEO_MAX_PLANES];
gint pack_width;
- get_tile_NV12 (tile_width, ts, tx, ty, data, stride, tdata, tstride);
+ get_tile_NV12 (tile_width, ts, tx, ty, info->tile_mode,
+ data, stride, tdata, tstride);
/* the number of bytes left to pack */
pack_width = MIN (width, tile_width);
* code is a reduce version of:
* 0: - Read first UV word (UVU)
* Unpack U and V
- * 1: - Resued U/V from 1 (sub-sampling)
+ * 1: - Reused U/V from 1 (sub-sampling)
* 2: - Unpack remaining U value
* - Read following UV word (VUV)
* - Unpack V value
* code is a reduce version of:
* 0: - Read first UV word (UVU)
* Unpack U and V
- * 1: - Resued U/V from 1 (sub-sampling)
+ * 1: - Reused U/V from 1 (sub-sampling)
* 2: - Unpack remaining U value
* - Read following UV word (VUV)
* - Unpack V value
}
}
-typedef struct
+#define PACK_RGB10A2_LE GST_VIDEO_FORMAT_ARGB64, unpack_rgb10a2_le, 1, pack_rgb10a2_le
+static void
+unpack_rgb10a2_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)
{
- guint32 fourcc;
- GstVideoFormatInfo info;
-} VideoFormat;
+ int i;
+ const guint8 *restrict s = GET_LINE (y);
+ guint16 *restrict d = dest;
+ guint32 ARGB;
+ guint16 A, R, G, B;
-/* depths: bits, n_components, shift, depth */
-#define DPTH0 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
-#define DPTH8 8, 1, { 0, 0, 0, 0 }, { 8, 0, 0, 0 }
-#define DPTH8_32 8, 2, { 0, 0, 0, 0 }, { 8, 32, 0, 0 }
-#define DPTH888 8, 3, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
-#define DPTH8888 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 8 }
-#define DPTH8880 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
-#define DPTH10 10, 1, { 0, 0, 0, 0 }, { 10, 0, 0, 0 }
-#define DPTH10_10_10 10, 3, { 0, 0, 0, 0 }, { 10, 10, 10, 0 }
-#define DPTH10_10_10_10 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 10 }
-#define DPTH10_10_10_HI 16, 3, { 6, 6, 6, 0 }, { 10, 10, 10, 0 }
-#define DPTH10_10_10_2 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 2}
-#define DPTH12_12_12 12, 3, { 0, 0, 0, 0 }, { 12, 12, 12, 0 }
-#define DPTH12_12_12_12 12, 4, { 0, 0, 0, 0 }, { 12, 12, 12, 12 }
-#define DPTH16 16, 1, { 0, 0, 0, 0 }, { 16, 0, 0, 0 }
-#define DPTH16_16_16 16, 3, { 0, 0, 0, 0 }, { 16, 16, 16, 0 }
-#define DPTH16_16_16_16 16, 4, { 0, 0, 0, 0 }, { 16, 16, 16, 16 }
-#define DPTH555 16, 3, { 10, 5, 0, 0 }, { 5, 5, 5, 0 }
-#define DPTH565 16, 3, { 11, 5, 0, 0 }, { 5, 6, 5, 0 }
+ s += x * 4;
-/* pixel strides */
-#define PSTR0 { 0, 0, 0, 0 }
-#define PSTR1 { 1, 0, 0, 0 }
-#define PSTR14 { 1, 4, 0, 0 }
-#define PSTR111 { 1, 1, 1, 0 }
-#define PSTR1111 { 1, 1, 1, 1 }
-#define PSTR122 { 1, 2, 2, 0 }
-#define PSTR2 { 2, 0, 0, 0 }
-#define PSTR222 { 2, 2, 2, 0 }
-#define PSTR2222 { 2, 2, 2, 2 }
-#define PSTR244 { 2, 4, 4, 0 }
-#define PSTR444 { 4, 4, 4, 0 }
-#define PSTR4444 { 4, 4, 4, 4 }
-#define PSTR333 { 3, 3, 3, 0 }
-#define PSTR488 { 4, 8, 8, 0 }
-#define PSTR8888 { 8, 8, 8, 8 }
+ for (i = 0; i < width; i++) {
+ ARGB = GST_READ_UINT32_LE (s + 4 * i);
-/* planes, in what plane do we find component N */
-#define PLANE_NA 0, { 0, 0, 0, 0 }
-#define PLANE0 1, { 0, 0, 0, 0 }
-#define PLANE01 2, { 0, 1, 0, 0 }
-#define PLANE011 2, { 0, 1, 1, 0 }
-#define PLANE012 3, { 0, 1, 2, 0 }
-#define PLANE0123 4, { 0, 1, 2, 3 }
-#define PLANE021 3, { 0, 2, 1, 0 }
-#define PLANE201 3, { 2, 0, 1, 0 }
-#define PLANE2013 4, { 2, 0, 1, 3 }
+ R = ((ARGB >> 0) & 0x3ff) << 6;
+ G = ((ARGB >> 10) & 0x3ff) << 6;
+ B = ((ARGB >> 20) & 0x3ff) << 6;
+ A = ((ARGB >> 30) & 0x03) << 14;
-/* offsets */
-#define OFFS0 { 0, 0, 0, 0 }
-#define OFFS013 { 0, 1, 3, 0 }
-#define OFFS102 { 1, 0, 2, 0 }
-#define OFFS1230 { 1, 2, 3, 0 }
-#define OFFS012 { 0, 1, 2, 0 }
-#define OFFS210 { 2, 1, 0, 0 }
-#define OFFS123 { 1, 2, 3, 0 }
-#define OFFS321 { 3, 2, 1, 0 }
-#define OFFS0123 { 0, 1, 2, 3 }
-#define OFFS2103 { 2, 1, 0, 3 }
-#define OFFS3210 { 3, 2, 1, 0 }
-#define OFFS031 { 0, 3, 1, 0 }
-#define OFFS204 { 2, 0, 4, 0 }
-#define OFFS001 { 0, 0, 1, 0 }
-#define OFFS010 { 0, 1, 0, 0 }
-#define OFFS104 { 1, 0, 4, 0 }
-#define OFFS2460 { 2, 4, 6, 0 }
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ R |= (R >> 10);
+ G |= (G >> 10);
+ B |= (B >> 10);
+ A |= (A >> 10);
+ }
-/* subsampling, w_sub, h_sub */
-#define SUB410 { 0, 2, 2, 0 }, { 0, 2, 2, 0 }
-#define SUB411 { 0, 2, 2, 0 }, { 0, 0, 0, 0 }
-#define SUB420 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
-#define SUB422 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
-#define SUB4 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
-#define SUB44 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
-#define SUB444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
-#define SUB4444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
-#define SUB4204 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
-#define SUB4224 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
+ d[4 * i + 0] = A;
+ d[4 * i + 1] = R;
+ d[4 * i + 2] = G;
+ d[4 * i + 3] = B;
+ }
+}
-/* tile_mode, tile_width, tile_height */
-#define TILE_64x32(mode) GST_VIDEO_TILE_MODE_ ##mode, 6, 5
+static void
+pack_rgb10a2_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;
+ guint32 *restrict d = GET_LINE (y);
+ const guint16 *restrict s = src;
+ guint32 ARGB;
+ guint16 A, R, G, B;
-#define MAKE_YUV_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
- { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_YUV_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
- { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_YUVA_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
- { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_YUVA_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
- { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_YUVA_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
- { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_YUVA_LE_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
- { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_YUV_C_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
- { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_COMPLEX, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_YUV_C_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
- { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_COMPLEX | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_YUV_T_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack, tile) \
- { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_COMPLEX | GST_VIDEO_FORMAT_FLAG_TILED, depth, pstride, plane, offs, sub, pack, tile } }
+ for (i = 0; i < width; i++) {
+ A = s[4 * i] & 0xc000;
+ R = s[4 * i + 1] & 0xffc0;
+ G = s[4 * i + 2] & 0xffc0;
+ B = s[4 * i + 3] & 0xffc0;
-#define MAKE_RGB_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
- { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_RGB_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
- { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_RGBA_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
- { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_RGBA_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
- { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_RGBAP_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
- { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_PALETTE, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_RGBA_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
- { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK, depth, pstride, plane, offs, sub, pack } }
-#define MAKE_RGBA_LE_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
- { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
+ ARGB = (R >> 6) | (G << 4) | (B << 14) | (A << 16);
-#define MAKE_GRAY_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
- { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_GRAY, depth, pstride, plane, offs, sub, pack } }
-#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_GRAY_C_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_COMPLEX | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
+ GST_WRITE_UINT32_LE (d + i, ARGB);
+ }
+}
#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}},
- {0x00000000, {GST_VIDEO_FORMAT_ENCODED, "ENCODED", "encoded video",
- GST_VIDEO_FORMAT_FLAG_COMPLEX, DPTH0, PSTR0, PLANE_NA, OFFS0}},
+#define PACK_Y444_16BE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_16BE, 1, pack_Y444_16BE
+static void
+unpack_Y444_16BE (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 *restrict sy = GET_Y_LINE (y);
+ guint16 *restrict su = GET_U_LINE (y);
+ guint16 *restrict sv = GET_V_LINE (y);
+ guint16 *restrict d = dest, Y, U, V;
- MAKE_YUV_FORMAT (I420, "raw video", GST_MAKE_FOURCC ('I', '4', '2', '0'),
- DPTH888, PSTR111, PLANE012, OFFS0, SUB420, PACK_420),
- MAKE_YUV_FORMAT (S420, "raw video", GST_MAKE_FOURCC ('S', '4', '2', '0'),
- DPTH888, PSTR111, PLANE012, OFFS0, SUB420, PACK_420),
- MAKE_YUV_FORMAT (YV12, "raw video", GST_MAKE_FOURCC ('Y', 'V', '1', '2'),
- DPTH888, PSTR111, PLANE021, OFFS0, SUB420, PACK_420),
+ sy += x;
+ su += x;
+ sv += x;
+
+ for (i = 0; i < width; i++) {
+ Y = GST_READ_UINT16_BE (sy + i);
+ U = GST_READ_UINT16_BE (su + i);
+ V = GST_READ_UINT16_BE (sv + i);
+
+ d[i * 4 + 0] = 0xffff;
+ d[i * 4 + 1] = Y;
+ d[i * 4 + 2] = U;
+ d[i * 4 + 3] = V;
+ }
+}
+
+static void
+pack_Y444_16BE (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 dy = GET_Y_LINE (y);
+ guint16 *restrict du = GET_U_LINE (y);
+ guint16 *restrict dv = GET_V_LINE (y);
+ guint16 Y, U, V;
+ const guint16 *restrict s = src;
+
+ for (i = 0; i < width; i++) {
+ Y = s[i * 4 + 1];
+ U = s[i * 4 + 2];
+ V = s[i * 4 + 3];
+
+ GST_WRITE_UINT16_BE (dy + i, Y);
+ GST_WRITE_UINT16_BE (du + i, U);
+ GST_WRITE_UINT16_BE (dv + i, V);
+ }
+}
+
+#define PACK_Y444_16LE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_16LE, 1, pack_Y444_16LE
+static void
+unpack_Y444_16LE (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 *restrict sy = GET_Y_LINE (y);
+ guint16 *restrict su = GET_U_LINE (y);
+ guint16 *restrict sv = GET_V_LINE (y);
+ guint16 *restrict d = dest, Y, U, V;
+
+ sy += x;
+ su += x;
+ sv += x;
+
+ for (i = 0; i < width; i++) {
+ Y = GST_READ_UINT16_LE (sy + i);
+ U = GST_READ_UINT16_LE (su + i);
+ V = GST_READ_UINT16_LE (sv + i);
+
+ d[i * 4 + 0] = 0xffff;
+ d[i * 4 + 1] = Y;
+ d[i * 4 + 2] = U;
+ d[i * 4 + 3] = V;
+ }
+}
+
+static void
+pack_Y444_16LE (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 dy = GET_Y_LINE (y);
+ guint16 *restrict du = GET_U_LINE (y);
+ guint16 *restrict dv = GET_V_LINE (y);
+ guint16 Y, U, V;
+ const guint16 *restrict s = src;
+
+ for (i = 0; i < width; i++) {
+ Y = s[i * 4 + 1];
+ U = s[i * 4 + 2];
+ V = s[i * 4 + 3];
+
+ GST_WRITE_UINT16_LE (dy + i, Y);
+ GST_WRITE_UINT16_LE (du + i, U);
+ GST_WRITE_UINT16_LE (dv + i, V);
+ }
+}
+
+#define PACK_P016_BE GST_VIDEO_FORMAT_AYUV64, unpack_P016_BE, 1, pack_P016_BE
+static void
+unpack_P016_BE (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;
+ gint uv = GET_UV_420 (y, flags);
+ const guint16 *restrict sy = GET_PLANE_LINE (0, y);
+ const guint16 *restrict suv = GET_PLANE_LINE (1, uv);
+ guint16 *restrict d = dest, Y0, Y1, U, V;
+
+ sy += x;
+ suv += (x & ~1);
+
+ if (x & 1) {
+ Y0 = GST_READ_UINT16_BE (sy);
+ U = GST_READ_UINT16_BE (suv);
+ V = GST_READ_UINT16_BE (suv + 1);
+
+ d[0] = 0xffff;
+ d[1] = Y0;
+ d[2] = U;
+ d[3] = V;
+ width--;
+ d += 4;
+ sy += 1;
+ suv += 2;
+ }
+
+ for (i = 0; i < width / 2; i++) {
+ Y0 = GST_READ_UINT16_BE (sy + 2 * i);
+ Y1 = GST_READ_UINT16_BE (sy + 2 * i + 1);
+ U = GST_READ_UINT16_BE (suv + 2 * i);
+ V = GST_READ_UINT16_BE (suv + 2 * i + 1);
+
+ d[i * 8 + 0] = 0xffff;
+ d[i * 8 + 1] = Y0;
+ d[i * 8 + 2] = U;
+ d[i * 8 + 3] = V;
+ d[i * 8 + 4] = 0xffff;
+ d[i * 8 + 5] = Y1;
+ d[i * 8 + 6] = U;
+ d[i * 8 + 7] = V;
+ }
+
+ if (width & 1) {
+ gint i = width - 1;
+
+ Y0 = GST_READ_UINT16_BE (sy + i);
+ U = GST_READ_UINT16_BE (suv + i);
+ V = GST_READ_UINT16_BE (suv + i + 1);
+
+ d[i * 4 + 0] = 0xffff;
+ d[i * 4 + 1] = Y0;
+ d[i * 4 + 2] = U;
+ d[i * 4 + 3] = V;
+ }
+}
+
+static void
+pack_P016_BE (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;
+ gint uv = GET_UV_420 (y, flags);
+ guint16 *restrict dy = GET_PLANE_LINE (0, y);
+ guint16 *restrict duv = GET_PLANE_LINE (1, uv);
+ guint16 Y0, Y1, U, V;
+ const guint16 *restrict s = src;
+
+ if (IS_CHROMA_LINE_420 (y, flags)) {
+ for (i = 0; i < width / 2; i++) {
+ Y0 = s[i * 8 + 1];
+ Y1 = s[i * 8 + 5];
+ U = s[i * 8 + 2];
+ V = s[i * 8 + 3];
+
+ GST_WRITE_UINT16_BE (dy + i * 2 + 0, Y0);
+ GST_WRITE_UINT16_BE (dy + i * 2 + 1, Y1);
+ GST_WRITE_UINT16_BE (duv + i * 2 + 0, U);
+ GST_WRITE_UINT16_BE (duv + i * 2 + 1, V);
+ }
+ if (width & 1) {
+ gint i = width - 1;
+
+ Y0 = s[i * 4 + 1];
+ U = s[i * 4 + 2];
+ V = s[i * 4 + 3];
+
+ GST_WRITE_UINT16_BE (dy + i, Y0);
+ GST_WRITE_UINT16_BE (duv + i + 0, U);
+ GST_WRITE_UINT16_BE (duv + i + 1, V);
+ }
+ } else {
+ for (i = 0; i < width; i++) {
+ Y0 = s[i * 4 + 1];
+ GST_WRITE_UINT16_BE (dy + i, Y0);
+ }
+ }
+}
+
+#define PACK_P016_LE GST_VIDEO_FORMAT_AYUV64, unpack_P016_LE, 1, pack_P016_LE
+static void
+unpack_P016_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;
+ gint uv = GET_UV_420 (y, flags);
+ const guint16 *restrict sy = GET_PLANE_LINE (0, y);
+ const guint16 *restrict suv = GET_PLANE_LINE (1, uv);
+ guint16 *restrict d = dest, Y0, Y1, U, V;
+
+ sy += x;
+ suv += (x & ~1);
+
+ if (x & 1) {
+ Y0 = GST_READ_UINT16_LE (sy);
+ U = GST_READ_UINT16_LE (suv);
+ V = GST_READ_UINT16_LE (suv + 1);
+
+ d[0] = 0xffff;
+ d[1] = Y0;
+ d[2] = U;
+ d[3] = V;
+ width--;
+ d += 4;
+ sy += 1;
+ suv += 2;
+ }
+
+ for (i = 0; i < width / 2; i++) {
+ Y0 = GST_READ_UINT16_LE (sy + 2 * i);
+ Y1 = GST_READ_UINT16_LE (sy + 2 * i + 1);
+ U = GST_READ_UINT16_LE (suv + 2 * i);
+ V = GST_READ_UINT16_LE (suv + 2 * i + 1);
+
+ d[i * 8 + 0] = 0xffff;
+ d[i * 8 + 1] = Y0;
+ d[i * 8 + 2] = U;
+ d[i * 8 + 3] = V;
+ d[i * 8 + 4] = 0xffff;
+ d[i * 8 + 5] = Y1;
+ d[i * 8 + 6] = U;
+ d[i * 8 + 7] = V;
+ }
+
+ if (width & 1) {
+ gint i = width - 1;
+
+ Y0 = GST_READ_UINT16_LE (sy + i);
+ U = GST_READ_UINT16_LE (suv + i);
+ V = GST_READ_UINT16_LE (suv + i + 1);
+
+ d[i * 4 + 0] = 0xffff;
+ d[i * 4 + 1] = Y0;
+ d[i * 4 + 2] = U;
+ d[i * 4 + 3] = V;
+ }
+}
+
+static void
+pack_P016_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;
+ gint uv = GET_UV_420 (y, flags);
+ guint16 *restrict dy = GET_PLANE_LINE (0, y);
+ guint16 *restrict duv = GET_PLANE_LINE (1, uv);
+ guint16 Y0, Y1, U, V;
+ const guint16 *restrict s = src;
+
+ if (IS_CHROMA_LINE_420 (y, flags)) {
+ for (i = 0; i < width / 2; i++) {
+ Y0 = s[i * 8 + 1];
+ Y1 = s[i * 8 + 5];
+ U = s[i * 8 + 2];
+ V = s[i * 8 + 3];
+
+ GST_WRITE_UINT16_LE (dy + i * 2 + 0, Y0);
+ GST_WRITE_UINT16_LE (dy + i * 2 + 1, Y1);
+ GST_WRITE_UINT16_LE (duv + i * 2 + 0, U);
+ GST_WRITE_UINT16_LE (duv + i * 2 + 1, V);
+ }
+ if (width & 1) {
+ gint i = width - 1;
+
+ Y0 = s[i * 4 + 1];
+ U = s[i * 4 + 2];
+ V = s[i * 4 + 3];
+
+ GST_WRITE_UINT16_LE (dy + i, Y0);
+ GST_WRITE_UINT16_LE (duv + i + 0, U);
+ GST_WRITE_UINT16_LE (duv + i + 1, V);
+ }
+ } else {
+ for (i = 0; i < width; i++) {
+ Y0 = s[i * 4 + 1];
+ GST_WRITE_UINT16_LE (dy + i, Y0);
+ }
+ }
+}
+
+#define PACK_P012_BE GST_VIDEO_FORMAT_AYUV64, unpack_P012_BE, 1, pack_P012_BE
+static void
+unpack_P012_BE (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;
+ gint uv = GET_UV_420 (y, flags);
+ const guint16 *restrict sy = GET_PLANE_LINE (0, y);
+ const guint16 *restrict suv = GET_PLANE_LINE (1, uv);
+ guint16 *restrict d = dest, Y0, Y1, U, V;
+
+ sy += x;
+ suv += (x & ~1);
+
+ if (x & 1) {
+ Y0 = GST_READ_UINT16_BE (sy);
+ U = GST_READ_UINT16_BE (suv);
+ V = GST_READ_UINT16_BE (suv + 1);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y0 |= (Y0 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[0] = 0xffff;
+ d[1] = Y0;
+ d[2] = U;
+ d[3] = V;
+ width--;
+ d += 4;
+ sy += 1;
+ suv += 2;
+ }
+
+ for (i = 0; i < width / 2; i++) {
+ Y0 = GST_READ_UINT16_BE (sy + 2 * i);
+ Y1 = GST_READ_UINT16_BE (sy + 2 * i + 1);
+ U = GST_READ_UINT16_BE (suv + 2 * i);
+ V = GST_READ_UINT16_BE (suv + 2 * i + 1);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y0 |= (Y0 >> 12);
+ Y1 |= (Y1 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[i * 8 + 0] = 0xffff;
+ d[i * 8 + 1] = Y0;
+ d[i * 8 + 2] = U;
+ d[i * 8 + 3] = V;
+ d[i * 8 + 4] = 0xffff;
+ d[i * 8 + 5] = Y1;
+ d[i * 8 + 6] = U;
+ d[i * 8 + 7] = V;
+ }
+
+ if (width & 1) {
+ gint i = width - 1;
+
+ Y0 = GST_READ_UINT16_BE (sy + i);
+ U = GST_READ_UINT16_BE (suv + i);
+ V = GST_READ_UINT16_BE (suv + i + 1);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y0 |= (Y0 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[i * 4 + 0] = 0xffff;
+ d[i * 4 + 1] = Y0;
+ d[i * 4 + 2] = U;
+ d[i * 4 + 3] = V;
+ }
+}
+
+static void
+pack_P012_BE (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;
+ gint uv = GET_UV_420 (y, flags);
+ guint16 *restrict dy = GET_PLANE_LINE (0, y);
+ guint16 *restrict duv = GET_PLANE_LINE (1, uv);
+ guint16 Y0, Y1, U, V;
+ const guint16 *restrict s = src;
+
+ if (IS_CHROMA_LINE_420 (y, flags)) {
+ for (i = 0; i < width / 2; i++) {
+ Y0 = s[i * 8 + 1] & 0xfff0;
+ Y1 = s[i * 8 + 5] & 0xfff0;
+ U = s[i * 8 + 2] & 0xfff0;
+ V = s[i * 8 + 3] & 0xfff0;
+
+ GST_WRITE_UINT16_BE (dy + i * 2 + 0, Y0);
+ GST_WRITE_UINT16_BE (dy + i * 2 + 1, Y1);
+ GST_WRITE_UINT16_BE (duv + i * 2 + 0, U);
+ GST_WRITE_UINT16_BE (duv + i * 2 + 1, V);
+ }
+ if (width & 1) {
+ gint i = width - 1;
+
+ Y0 = s[i * 4 + 1] & 0xfff0;
+ U = s[i * 4 + 2] & 0xfff0;
+ V = s[i * 4 + 3] & 0xfff0;
+
+ GST_WRITE_UINT16_BE (dy + i, Y0);
+ GST_WRITE_UINT16_BE (duv + i + 0, U);
+ GST_WRITE_UINT16_BE (duv + i + 1, V);
+ }
+ } else {
+ for (i = 0; i < width; i++) {
+ Y0 = s[i * 4 + 1] & 0xfff0;
+ GST_WRITE_UINT16_BE (dy + i, Y0);
+ }
+ }
+}
+
+#define PACK_P012_LE GST_VIDEO_FORMAT_AYUV64, unpack_P012_LE, 1, pack_P012_LE
+static void
+unpack_P012_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;
+ gint uv = GET_UV_420 (y, flags);
+ const guint16 *restrict sy = GET_PLANE_LINE (0, y);
+ const guint16 *restrict suv = GET_PLANE_LINE (1, uv);
+ guint16 *restrict d = dest, Y0, Y1, U, V;
+
+ sy += x;
+ suv += (x & ~1);
+
+ if (x & 1) {
+ Y0 = GST_READ_UINT16_LE (sy);
+ U = GST_READ_UINT16_LE (suv);
+ V = GST_READ_UINT16_LE (suv + 1);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y0 |= (Y0 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[0] = 0xffff;
+ d[1] = Y0;
+ d[2] = U;
+ d[3] = V;
+ width--;
+ d += 4;
+ sy += 1;
+ suv += 2;
+ }
+
+ for (i = 0; i < width / 2; i++) {
+ Y0 = GST_READ_UINT16_LE (sy + 2 * i);
+ Y1 = GST_READ_UINT16_LE (sy + 2 * i + 1);
+ U = GST_READ_UINT16_LE (suv + 2 * i);
+ V = GST_READ_UINT16_LE (suv + 2 * i + 1);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y0 |= (Y0 >> 12);
+ Y1 |= (Y1 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[i * 8 + 0] = 0xffff;
+ d[i * 8 + 1] = Y0;
+ d[i * 8 + 2] = U;
+ d[i * 8 + 3] = V;
+ d[i * 8 + 4] = 0xffff;
+ d[i * 8 + 5] = Y1;
+ d[i * 8 + 6] = U;
+ d[i * 8 + 7] = V;
+ }
+
+ if (width & 1) {
+ gint i = width - 1;
+
+ Y0 = GST_READ_UINT16_LE (sy + i);
+ U = GST_READ_UINT16_LE (suv + i);
+ V = GST_READ_UINT16_LE (suv + i + 1);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y0 |= (Y0 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[i * 4 + 0] = 0xffff;
+ d[i * 4 + 1] = Y0;
+ d[i * 4 + 2] = U;
+ d[i * 4 + 3] = V;
+ }
+}
+
+static void
+pack_P012_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;
+ gint uv = GET_UV_420 (y, flags);
+ guint16 *restrict dy = GET_PLANE_LINE (0, y);
+ guint16 *restrict duv = GET_PLANE_LINE (1, uv);
+ guint16 Y0, Y1, U, V;
+ const guint16 *restrict s = src;
+
+ if (IS_CHROMA_LINE_420 (y, flags)) {
+ for (i = 0; i < width / 2; i++) {
+ Y0 = s[i * 8 + 1] & 0xfff0;
+ Y1 = s[i * 8 + 5] & 0xfff0;
+ U = s[i * 8 + 2] & 0xfff0;
+ V = s[i * 8 + 3] & 0xfff0;
+
+ GST_WRITE_UINT16_LE (dy + i * 2 + 0, Y0);
+ GST_WRITE_UINT16_LE (dy + i * 2 + 1, Y1);
+ GST_WRITE_UINT16_LE (duv + i * 2 + 0, U);
+ GST_WRITE_UINT16_LE (duv + i * 2 + 1, V);
+ }
+ if (width & 1) {
+ gint i = width - 1;
+
+ Y0 = s[i * 4 + 1] & 0xfff0;
+ U = s[i * 4 + 2] & 0xfff0;
+ V = s[i * 4 + 3] & 0xfff0;
+
+ GST_WRITE_UINT16_LE (dy + i, Y0);
+ GST_WRITE_UINT16_LE (duv + i + 0, U);
+ GST_WRITE_UINT16_LE (duv + i + 1, V);
+ }
+ } else {
+ for (i = 0; i < width; i++) {
+ Y0 = s[i * 4 + 1] & 0xfff0;
+ GST_WRITE_UINT16_LE (dy + i, Y0);
+ }
+ }
+}
+
+#define PACK_Y212_BE GST_VIDEO_FORMAT_AYUV64, unpack_Y212_BE, 1, pack_Y212_BE
+static void
+unpack_Y212_BE (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);
+ guint16 *restrict d = dest;
+ guint Y0, Y1, U, V;
+
+ s += GST_ROUND_DOWN_2 (x) * 4;
+
+ if (x & 1) {
+ Y1 = GST_READ_UINT16_BE (s + 4);
+ U = GST_READ_UINT16_BE (s + 2);
+ V = GST_READ_UINT16_BE (s + 6);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y1 |= (Y1 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[0] = 0xffff;
+ d[1] = Y1;
+ d[2] = U;
+ d[3] = V;
+ s += 8;
+ d += 4;
+ width--;
+ }
+
+ for (i = 0; i < width / 2; i++) {
+ Y0 = GST_READ_UINT16_BE (s + i * 8 + 0);
+ U = GST_READ_UINT16_BE (s + i * 8 + 2);
+ V = GST_READ_UINT16_BE (s + i * 8 + 6);
+ Y1 = GST_READ_UINT16_BE (s + i * 8 + 4);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y0 |= (Y0 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[i * 8 + 0] = 0xffff;
+ d[i * 8 + 1] = Y0;
+ d[i * 8 + 2] = U;
+ d[i * 8 + 3] = V;
+
+ d[i * 8 + 4] = 0xffff;
+ d[i * 8 + 5] = Y1;
+ d[i * 8 + 6] = U;
+ d[i * 8 + 7] = V;
+ }
+
+ if (width & 1) {
+ i = width - 1;
+
+ Y0 = GST_READ_UINT16_BE (s + i * 4 + 0);
+ U = GST_READ_UINT16_BE (s + i * 4 + 2);
+ V = GST_READ_UINT16_BE (s + i * 4 + 6);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y0 |= (Y0 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[i * 4 + 0] = 0xffff;
+ d[i * 4 + 1] = Y0;
+ d[i * 4 + 2] = U;
+ d[i * 4 + 3] = V;
+ }
+}
+
+static void
+pack_Y212_BE (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 Y0, Y1, U, V;
+ guint8 *restrict d = GET_LINE (y);
+ const guint16 *restrict s = src;
+
+ for (i = 0; i < width; i += 2) {
+ Y0 = s[i * 4 + 1] & 0xfff0;
+ U = s[i * 4 + 2] & 0xfff0;
+ V = s[i * 4 + 3] & 0xfff0;
+ if (i == width - 1)
+ Y1 = s[i * 4 + 1] & 0xfff0;
+ else
+ Y1 = s[(i + 1) * 4 + 1] & 0xfff0;
+
+ GST_WRITE_UINT16_BE (d + i * 4 + 0, Y0);
+ GST_WRITE_UINT16_BE (d + i * 4 + 2, U);
+ GST_WRITE_UINT16_BE (d + i * 4 + 4, Y1);
+ GST_WRITE_UINT16_BE (d + i * 4 + 6, V);
+ }
+}
+
+#define PACK_Y212_LE GST_VIDEO_FORMAT_AYUV64, unpack_Y212_LE, 1, pack_Y212_LE
+static void
+unpack_Y212_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 guint8 *restrict s = GET_LINE (y);
+ guint16 *restrict d = dest;
+ guint Y0, Y1, U, V;
+
+ s += GST_ROUND_DOWN_2 (x) * 4;
+
+ if (x & 1) {
+ Y1 = GST_READ_UINT16_LE (s + 4);
+ U = GST_READ_UINT16_LE (s + 2);
+ V = GST_READ_UINT16_LE (s + 6);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y1 |= (Y1 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[0] = 0xffff;
+ d[1] = Y1;
+ d[2] = U;
+ d[3] = V;
+ s += 8;
+ d += 4;
+ width--;
+ }
+
+ for (i = 0; i < width / 2; i++) {
+ Y0 = GST_READ_UINT16_LE (s + i * 8 + 0);
+ U = GST_READ_UINT16_LE (s + i * 8 + 2);
+ V = GST_READ_UINT16_LE (s + i * 8 + 6);
+ Y1 = GST_READ_UINT16_LE (s + i * 8 + 4);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y0 |= (Y0 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[i * 8 + 0] = 0xffff;
+ d[i * 8 + 1] = Y0;
+ d[i * 8 + 2] = U;
+ d[i * 8 + 3] = V;
+
+ d[i * 8 + 4] = 0xffff;
+ d[i * 8 + 5] = Y1;
+ d[i * 8 + 6] = U;
+ d[i * 8 + 7] = V;
+ }
+
+ if (width & 1) {
+ i = width - 1;
+
+ Y0 = GST_READ_UINT16_LE (s + i * 4 + 0);
+ U = GST_READ_UINT16_LE (s + i * 4 + 2);
+ V = GST_READ_UINT16_LE (s + i * 4 + 6);
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ Y0 |= (Y0 >> 12);
+ U |= (U >> 12);
+ V |= (V >> 12);
+ }
+
+ d[i * 4 + 0] = 0xffff;
+ d[i * 4 + 1] = Y0;
+ d[i * 4 + 2] = U;
+ d[i * 4 + 3] = V;
+ }
+}
+
+static void
+pack_Y212_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 Y0, Y1, U, V;
+ guint8 *restrict d = GET_LINE (y);
+ const guint16 *restrict s = src;
+
+ for (i = 0; i < width; i += 2) {
+ Y0 = s[i * 4 + 1] & 0xfff0;
+ U = s[i * 4 + 2] & 0xfff0;
+ V = s[i * 4 + 3] & 0xfff0;
+ if (i == width - 1)
+ Y1 = s[i * 4 + 1] & 0xfff0;
+ else
+ Y1 = s[(i + 1) * 4 + 1] & 0xfff0;
+
+ GST_WRITE_UINT16_LE (d + i * 4 + 0, Y0);
+ GST_WRITE_UINT16_LE (d + i * 4 + 2, U);
+ GST_WRITE_UINT16_LE (d + i * 4 + 4, Y1);
+ GST_WRITE_UINT16_LE (d + i * 4 + 6, V);
+ }
+}
+
+#define PACK_Y412_BE GST_VIDEO_FORMAT_AYUV64, unpack_Y412_BE, 1, pack_Y412_BE
+static void
+unpack_Y412_BE (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;
+ guint16 A, Y, U, V;
+
+ s += x * 4;
+
+ for (i = 0; i < width; i++) {
+ U = GST_READ_UINT16_BE (s + 4 * i + 0) & 0xfff0;
+ Y = GST_READ_UINT16_BE (s + 4 * i + 1) & 0xfff0;
+ V = GST_READ_UINT16_BE (s + 4 * i + 2) & 0xfff0;
+ A = GST_READ_UINT16_BE (s + 4 * i + 3) & 0xfff0;
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ U |= (U >> 12);
+ Y |= (Y >> 12);
+ V |= (V >> 12);
+ A |= (A >> 12);
+ }
+
+ d[4 * i + 0] = A;
+ d[4 * i + 1] = Y;
+ d[4 * i + 2] = U;
+ d[4 * i + 3] = V;
+ }
+}
+
+static void
+pack_Y412_BE (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;
+ guint16 A, Y, U, V;
+
+ for (i = 0; i < width; i++) {
+ A = s[4 * i + 0] & 0xfff0;
+ Y = s[4 * i + 1] & 0xfff0;
+ U = s[4 * i + 2] & 0xfff0;
+ V = s[4 * i + 3] & 0xfff0;
+
+ GST_WRITE_UINT16_BE (d + 4 * i + 0, U);
+ GST_WRITE_UINT16_BE (d + 4 * i + 1, Y);
+ GST_WRITE_UINT16_BE (d + 4 * i + 2, V);
+ GST_WRITE_UINT16_BE (d + 4 * i + 3, A);
+ }
+}
+
+#define PACK_Y412_LE GST_VIDEO_FORMAT_AYUV64, unpack_Y412_LE, 1, pack_Y412_LE
+static void
+unpack_Y412_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;
+ guint16 A, Y, U, V;
+
+ s += x * 4;
+
+ for (i = 0; i < width; i++) {
+ U = GST_READ_UINT16_LE (s + 4 * i + 0) & 0xfff0;
+ Y = GST_READ_UINT16_LE (s + 4 * i + 1) & 0xfff0;
+ V = GST_READ_UINT16_LE (s + 4 * i + 2) & 0xfff0;
+ A = GST_READ_UINT16_LE (s + 4 * i + 3) & 0xfff0;
+
+ if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
+ U |= (U >> 12);
+ Y |= (Y >> 12);
+ V |= (V >> 12);
+ A |= (A >> 12);
+ }
+
+ d[4 * i + 0] = A;
+ d[4 * i + 1] = Y;
+ d[4 * i + 2] = U;
+ d[4 * i + 3] = V;
+ }
+}
+
+static void
+pack_Y412_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;
+ guint16 A, Y, U, V;
+
+ for (i = 0; i < width; i++) {
+ A = s[4 * i + 0] & 0xfff0;
+ Y = s[4 * i + 1] & 0xfff0;
+ U = s[4 * i + 2] & 0xfff0;
+ V = s[4 * i + 3] & 0xfff0;
+
+ GST_WRITE_UINT16_LE (d + 4 * i + 0, U);
+ GST_WRITE_UINT16_LE (d + 4 * i + 1, Y);
+ GST_WRITE_UINT16_LE (d + 4 * i + 2, V);
+ GST_WRITE_UINT16_LE (d + 4 * i + 3, A);
+ }
+}
+
+#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;
+ GstVideoFormatInfo info;
+} VideoFormat;
+
+/* depths: bits, n_components, shift, depth */
+#define DPTH0 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
+#define DPTH8 8, 1, { 0, 0, 0, 0 }, { 8, 0, 0, 0 }
+#define DPTH8_32 8, 2, { 0, 0, 0, 0 }, { 8, 32, 0, 0 }
+#define DPTH888 8, 3, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
+#define DPTH8888 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 8 }
+#define DPTH8880 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
+#define DPTH10 10, 1, { 0, 0, 0, 0 }, { 10, 0, 0, 0 }
+#define DPTH10_10_10 10, 3, { 0, 0, 0, 0 }, { 10, 10, 10, 0 }
+#define DPTH10_10_10_10 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 10 }
+#define DPTH10_10_10_HI 16, 3, { 6, 6, 6, 0 }, { 10, 10, 10, 0 }
+#define DPTH10_10_10_2 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 2}
+#define DPTH12_12_12 12, 3, { 0, 0, 0, 0 }, { 12, 12, 12, 0 }
+#define DPTH12_12_12_HI 16, 3, { 4, 4, 4, 0 }, { 12, 12, 12, 0 }
+#define DPTH12_12_12_12 12, 4, { 0, 0, 0, 0 }, { 12, 12, 12, 12 }
+#define DPTH12_12_12_12_HI 16, 4, { 4, 4, 4, 4 }, { 12, 12, 12, 12 }
+#define DPTH16 16, 1, { 0, 0, 0, 0 }, { 16, 0, 0, 0 }
+#define DPTH16_16_16 16, 3, { 0, 0, 0, 0 }, { 16, 16, 16, 0 }
+#define DPTH16_16_16_16 16, 4, { 0, 0, 0, 0 }, { 16, 16, 16, 16 }
+#define DPTH555 5, 3, { 10, 5, 0, 0 }, { 5, 5, 5, 0 }
+#define DPTH565 6, 3, { 11, 5, 0, 0 }, { 5, 6, 5, 0 }
+
+/* pixel strides */
+#define PSTR0 { 0, 0, 0, 0 }
+#define PSTR1 { 1, 0, 0, 0 }
+#define PSTR14 { 1, 4, 0, 0 }
+#define PSTR111 { 1, 1, 1, 0 }
+#define PSTR1111 { 1, 1, 1, 1 }
+#define PSTR122 { 1, 2, 2, 0 }
+#define PSTR1221 { 1, 2, 2, 1 }
+#define PSTR2 { 2, 0, 0, 0 }
+#define PSTR222 { 2, 2, 2, 0 }
+#define PSTR2222 { 2, 2, 2, 2 }
+#define PSTR244 { 2, 4, 4, 0 }
+#define PSTR444 { 4, 4, 4, 0 }
+#define PSTR4444 { 4, 4, 4, 4 }
+#define PSTR333 { 3, 3, 3, 0 }
+#define PSTR488 { 4, 8, 8, 0 }
+#define PSTR8888 { 8, 8, 8, 8 }
+
+/* planes, in what plane do we find component N */
+#define PLANE_NA 0, { 0, 0, 0, 0 }
+#define PLANE0 1, { 0, 0, 0, 0 }
+#define PLANE01 2, { 0, 1, 0, 0 }
+#define PLANE011 2, { 0, 1, 1, 0 }
+#define PLANE0112 3, { 0, 1, 1, 2 }
+#define PLANE012 3, { 0, 1, 2, 0 }
+#define PLANE0123 4, { 0, 1, 2, 3 }
+#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 }
+#define OFFS013 { 0, 1, 3, 0 }
+#define OFFS102 { 1, 0, 2, 0 }
+#define OFFS1230 { 1, 2, 3, 0 }
+#define OFFS012 { 0, 1, 2, 0 }
+#define OFFS210 { 2, 1, 0, 0 }
+#define OFFS123 { 1, 2, 3, 0 }
+#define OFFS321 { 3, 2, 1, 0 }
+#define OFFS0123 { 0, 1, 2, 3 }
+#define OFFS2103 { 2, 1, 0, 3 }
+#define OFFS3210 { 3, 2, 1, 0 }
+#define OFFS031 { 0, 3, 1, 0 }
+#define OFFS204 { 2, 0, 4, 0 }
+#define OFFS001 { 0, 0, 1, 0 }
+#define OFFS010 { 0, 1, 0, 0 }
+#define OFFS104 { 1, 0, 4, 0 }
+#define OFFS2460 { 2, 4, 6, 0 }
+
+/* subsampling, w_sub, h_sub */
+#define SUB410 { 0, 2, 2, 0 }, { 0, 2, 2, 0 }
+#define SUB411 { 0, 2, 2, 0 }, { 0, 0, 0, 0 }
+#define SUB420 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
+#define SUB422 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
+#define SUB4 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
+#define SUB44 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
+#define SUB444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
+#define SUB4444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
+#define SUB4204 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
+#define SUB4224 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
+
+/* tile_mode, tile_ws (width shift), tile_hs (height shift) */
+#define TILE_4x4(mode) GST_VIDEO_TILE_MODE_ ##mode, 2, 2
+#define TILE_32x32(mode) GST_VIDEO_TILE_MODE_ ##mode, 5, 5
+#define TILE_64x32(mode) GST_VIDEO_TILE_MODE_ ##mode, 6, 5
+
+#define MAKE_YUV_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
+ { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_YUV_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
+ { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_YUVA_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
+ { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_YUVA_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
+ { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_YUVA_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
+ { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_YUVA_LE_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
+ { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_YUV_C_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
+ { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_COMPLEX, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_YUV_C_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
+ { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_COMPLEX | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_YUV_T_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack, tile) \
+ { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_COMPLEX | GST_VIDEO_FORMAT_FLAG_TILED, depth, pstride, plane, offs, sub, pack, tile } }
+
+#define MAKE_RGB_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
+ { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_RGB_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
+ { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_RGBA_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
+ { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_RGBA_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
+ { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_RGBAP_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
+ { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_PALETTE, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_RGBA_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
+ { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK, depth, pstride, plane, offs, sub, pack } }
+#define MAKE_RGBA_LE_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
+ { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
+
+#define MAKE_GRAY_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
+ { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_GRAY, depth, pstride, plane, offs, sub, pack } }
+#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_GRAY_C_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_COMPLEX | 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}},
+ {0x00000000, {GST_VIDEO_FORMAT_ENCODED, "ENCODED", "encoded video",
+ GST_VIDEO_FORMAT_FLAG_COMPLEX, DPTH0, PSTR0, PLANE_NA, OFFS0}},
+
+ MAKE_YUV_FORMAT (I420, "raw video", GST_MAKE_FOURCC ('I', '4', '2', '0'),
+ DPTH888, PSTR111, PLANE012, OFFS0, SUB420, PACK_420),
+ MAKE_YUV_FORMAT (S420, "raw video", GST_MAKE_FOURCC ('S', '4', '2', '0'),
+ DPTH888, PSTR111, PLANE012, OFFS0, SUB420, PACK_420),
+ MAKE_YUV_FORMAT (YV12, "raw video", GST_MAKE_FOURCC ('Y', 'V', '1', '2'),
+ DPTH888, PSTR111, PLANE021, OFFS0, SUB420, PACK_420),
MAKE_YUV_FORMAT (YUY2, "raw video", GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
DPTH888, PSTR244, PLANE0, OFFS013, SUB422, PACK_YUY2),
MAKE_YUV_FORMAT (UYVY, "raw video", GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'),
MAKE_YUV_FORMAT (NV24, "raw video", GST_MAKE_FOURCC ('N', 'V', '2', '4'),
DPTH888, PSTR122, PLANE011, OFFS001, SUB444, PACK_NV24),
MAKE_YUV_T_FORMAT (NV12_64Z32, "raw video",
- GST_MAKE_FOURCC ('T', 'M', '1', '2'), DPTH8880, PSTR122, PLANE011,
- OFFS001, SUB420, PACK_NV12_64Z32, TILE_64x32 (ZFLIPZ_2X2)),
+ GST_MAKE_FOURCC ('T', 'M', '1', '2'), DPTH888, PSTR122, PLANE011,
+ OFFS001, SUB420, PACK_NV12_TILED, TILE_64x32 (ZFLIPZ_2X2)),
MAKE_YUVA_FORMAT (A420_10BE, "raw video", 0x00000000, DPTH10_10_10_10,
PSTR2222, PLANE0123, OFFS0, SUB4204, PACK_A420_10BE),
MAKE_YUVA_LE_FORMAT (A420_10LE, "raw video", 0x00000000, DPTH10_10_10_10,
MAKE_YUV_FORMAT (Y210, "raw video", GST_MAKE_FOURCC ('Y', '2', '1', '0'),
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),
+ DPTH10_10_10_2, PSTR4444, 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),
MAKE_RGBA_LE_PACK_FORMAT (BGR10A2_LE, "raw video", DPTH10_10_10_2, PSTR4444,
MAKE_YUV_FORMAT (STV1, "raw video", GST_MAKE_FOURCC ('S', 'T', 'V', '1'),
DPTH888, PSTR111, PLANE012, OFFS0, SUB420, PACK_420),
#endif
+ MAKE_RGBA_LE_PACK_FORMAT (RGB10A2_LE, "raw video", DPTH10_10_10_2, PSTR4444,
+ PLANE0, OFFS0, SUB4444, PACK_RGB10A2_LE),
+ MAKE_YUV_FORMAT (Y444_16BE, "raw video", 0x00000000, DPTH16_16_16,
+ PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_16BE),
+ MAKE_YUV_LE_FORMAT (Y444_16LE, "raw video", 0x00000000, DPTH16_16_16,
+ PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_16LE),
+ MAKE_YUV_FORMAT (P016_BE, "raw video", 0x00000000, DPTH16_16_16,
+ PSTR244, PLANE011, OFFS001, SUB420, PACK_P016_BE),
+ MAKE_YUV_LE_FORMAT (P016_LE, "raw video", 0x00000000, DPTH16_16_16,
+ PSTR244, PLANE011, OFFS001, SUB420, PACK_P016_LE),
+ MAKE_YUV_FORMAT (P012_BE, "raw video", 0x00000000, DPTH12_12_12_HI,
+ PSTR244, PLANE011, OFFS001, SUB420, PACK_P012_BE),
+ MAKE_YUV_LE_FORMAT (P012_LE, "raw video", 0x00000000, DPTH12_12_12_HI,
+ PSTR244, PLANE011, OFFS001, SUB420, PACK_P012_LE),
+ MAKE_YUV_FORMAT (Y212_BE, "raw video", 0x00000000, DPTH12_12_12_HI,
+ PSTR488, PLANE0, OFFS0, SUB422, PACK_Y212_BE),
+ MAKE_YUV_LE_FORMAT (Y212_LE, "raw video", 0x00000000, DPTH12_12_12_HI,
+ PSTR488, PLANE0, OFFS0, SUB422, PACK_Y212_LE),
+ MAKE_YUV_FORMAT (Y412_BE, "raw video", 0x00000000, DPTH12_12_12_12_HI,
+ PSTR8888, PLANE0, OFFS0, SUB4444, PACK_Y412_BE),
+ MAKE_YUV_LE_FORMAT (Y412_LE, "raw video", 0x00000000, DPTH12_12_12_12_HI,
+ PSTR8888, PLANE0, OFFS0, SUB4444, PACK_Y412_LE),
+ MAKE_YUV_T_FORMAT (NV12_4L4, "raw video",
+ GST_MAKE_FOURCC ('V', 'T', '1', '2'), DPTH888, PSTR122, PLANE011,
+ OFFS001, SUB420, PACK_NV12_TILED, TILE_4x4 (LINEAR)),
+ 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),
+ MAKE_YUV_FORMAT (AV12, "raw video", GST_MAKE_FOURCC ('A', 'V', '1', '2'),
+ DPTH8888, PSTR1221, PLANE0112, OFFS001, SUB4204, PACK_AV12),
};
static GstVideoFormat
if (depth == 32 && bpp == 32 && alpha_mask == 0xc0000000 &&
endianness == G_LITTLE_ENDIAN) {
- format = GST_VIDEO_FORMAT_BGR10A2_LE;
+ if (red_mask == 0x3ff00000)
+ format = GST_VIDEO_FORMAT_RGB10A2_LE;
+ else
+ format = GST_VIDEO_FORMAT_BGR10A2_LE;
} else if (depth == 30 && bpp == 32) {
format = GST_VIDEO_FORMAT_r210;
} else if (depth == 24 && bpp == 32) {
return NULL;
}
}
+
+/**
+ * gst_video_format_info_component:
+ * @info: #GstVideoFormatInfo
+ * @plane: a plane number
+ * @components: (out): array used to store component numbers
+ *
+ * Fill @components with the number of all the components packed in plane @p
+ * for the format @info. A value of -1 in @components indicates that no more
+ * components are packed in the plane.
+ *
+ * Since: 1.18
+ */
+void
+gst_video_format_info_component (const GstVideoFormatInfo * info, guint plane,
+ gint components[GST_VIDEO_MAX_COMPONENTS])
+{
+ guint c, i = 0;
+
+ /* Reverse mapping of info->plane */
+ for (c = 0; c < GST_VIDEO_FORMAT_INFO_N_COMPONENTS (info); c++) {
+ if (GST_VIDEO_FORMAT_INFO_PLANE (info, c) == plane) {
+ components[i] = c;
+ i++;
+ }
+ }
+
+ for (c = i; c < GST_VIDEO_MAX_COMPONENTS; c++)
+ components[c] = -1;
+}
+
+struct RawVideoFormats
+{
+ GstVideoFormat *formats;
+ guint n;
+};
+
+static gpointer
+generate_raw_video_formats (gpointer data)
+{
+ GValue list = G_VALUE_INIT;
+ struct RawVideoFormats *all = g_new (struct RawVideoFormats, 1);
+ gchar *tmp;
+ guint i;
+ gboolean res G_GNUC_UNUSED;
+
+ g_value_init (&list, GST_TYPE_LIST);
+ /* Workaround a bug in our parser that would lead to segfaults
+ * when deserializing container types using static strings,
+ * see https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/446 */
+ tmp = g_strdup (GST_VIDEO_FORMATS_ALL);
+ res = gst_value_deserialize (&list, tmp);
+ g_assert (res);
+ g_free (tmp);
+
+ all->n = gst_value_list_get_size (&list);
+ all->formats = g_new (GstVideoFormat, all->n);
+
+ for (i = 0; i < all->n; i++) {
+ const GValue *v = gst_value_list_get_value (&list, i);
+
+ all->formats[i] = gst_video_format_from_string (g_value_get_string (v));
+ g_assert (all->formats[i] != GST_VIDEO_FORMAT_UNKNOWN
+ && all->formats[i] != GST_VIDEO_FORMAT_ENCODED);
+ }
+
+ g_value_unset (&list);
+
+ return all;
+}
+
+/**
+ * gst_video_formats_raw:
+ * @len: (out): the number of elements in the returned array
+ *
+ * Return all the raw video formats supported by GStreamer.
+ *
+ * Returns: (transfer none) (array length=len): an array of #GstVideoFormat
+ * Since: 1.18
+ */
+const GstVideoFormat *
+gst_video_formats_raw (guint * len)
+{
+ static GOnce raw_video_formats_once = G_ONCE_INIT;
+ struct RawVideoFormats *all;
+
+ g_return_val_if_fail (len, NULL);
+
+ g_once (&raw_video_formats_once, generate_raw_video_formats, NULL);
+
+ all = raw_video_formats_once.retval;
+ *len = all->n;
+ return all->formats;
+}
+
+/**
+ * gst_video_make_raw_caps:
+ * @formats: (array length=len) (nullable): an array of raw #GstVideoFormat, or %NULL
+ * @len: the size of @formats
+ *
+ * Return a generic raw video caps for formats defined in @formats.
+ * If @formats is %NULL returns a caps for all the supported raw video formats,
+ * see gst_video_formats_raw().
+ *
+ * Returns: (transfer full): a video @GstCaps
+ * Since: 1.18
+ */
+GstCaps *
+gst_video_make_raw_caps (const GstVideoFormat formats[], guint len)
+{
+ return gst_video_make_raw_caps_with_features (formats, len, NULL);
+}
+
+/**
+ * gst_video_make_raw_caps_with_features:
+ * @formats: (array length=len) (nullable): an array of raw #GstVideoFormat, or %NULL
+ * @len: the size of @formats
+ * @features: (transfer full) (allow-none): the #GstCapsFeatures to set on the caps
+ *
+ * Return a generic raw video caps for formats defined in @formats with features
+ * @features.
+ * If @formats is %NULL returns a caps for all the supported video formats,
+ * see gst_video_formats_raw().
+ *
+ * Returns: (transfer full): a video @GstCaps
+ * Since: 1.18
+ */
+GstCaps *
+gst_video_make_raw_caps_with_features (const GstVideoFormat formats[],
+ guint len, GstCapsFeatures * features)
+{
+ GstStructure *s;
+ GValue format = G_VALUE_INIT;
+ GstCaps *caps;
+
+ g_return_val_if_fail ((formats && len > 0) || (!formats && len == 0), NULL);
+
+ if (!formats) {
+ formats = gst_video_formats_raw (&len);
+ }
+
+ if (len > 1) {
+ guint i;
+
+ g_value_init (&format, GST_TYPE_LIST);
+
+ for (i = 0; i < len; i++) {
+ GValue v = G_VALUE_INIT;
+
+ g_return_val_if_fail (formats[i] != GST_VIDEO_FORMAT_UNKNOWN
+ && formats[i] != GST_VIDEO_FORMAT_ENCODED, NULL);
+
+ g_value_init (&v, G_TYPE_STRING);
+ g_value_set_static_string (&v, gst_video_format_to_string (formats[i]));
+ gst_value_list_append_and_take_value (&format, &v);
+ }
+ } else {
+ g_value_init (&format, G_TYPE_STRING);
+
+ g_value_set_static_string (&format,
+ gst_video_format_to_string (formats[0]));
+ }
+
+ s = gst_structure_new ("video/x-raw",
+ "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+ "height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
+
+ gst_structure_take_value (s, "format", &format);
+
+ caps = gst_caps_new_full (s, NULL);
+
+ if (features)
+ gst_caps_set_features (caps, 0, features);
+
+ return caps;
+}