Commit b83e67dd authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

video: Add Y444_10{LE,BE} video formats

parent d730b0c2
......@@ -1224,6 +1224,114 @@ pack_r210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
}
}
#define PACK_Y444_10LE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_10LE, 1, pack_Y444_10LE
static void
unpack_Y444_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) << 6;
V = GST_READ_UINT16_LE (srcV + i) << 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_Y444_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 Y, U, V;
const guint16 *s = src;
for (i = 0; i < width; i++) {
Y = (s[i * 4 + 1]) >> 6;
U = (s[i * 4 + 2]) >> 6;
V = (s[i * 4 + 3]) >> 6;
GST_WRITE_UINT16_LE (destY + i, Y);
GST_WRITE_UINT16_LE (destU + i, U);
GST_WRITE_UINT16_LE (destV + i, V);
}
}
#define PACK_Y444_10BE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_10BE, 1, pack_Y444_10BE
static void
unpack_Y444_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) << 6;
V = GST_READ_UINT16_BE (srcV + i) << 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_Y444_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 Y, U, V;
const guint16 *s = src;
for (i = 0; i < width; i++) {
Y = s[i * 4 + 1] >> 6;
U = s[i * 4 + 2] >> 6;
V = s[i * 4 + 3] >> 6;
GST_WRITE_UINT16_BE (destY + i, Y);
GST_WRITE_UINT16_BE (destU + i, U);
GST_WRITE_UINT16_BE (destV + i, V);
}
}
#define PACK_I420_10LE GST_VIDEO_FORMAT_AYUV64, unpack_I420_10LE, 1, pack_I420_10LE
static void
unpack_I420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
......@@ -1707,6 +1815,10 @@ static VideoFormat formats[] = {
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),
MAKE_YUV_FORMAT (Y444_10BE, "raw video", 0x00000000, DPTH10_10_10,
PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_10BE),
MAKE_YUV_LE_FORMAT (Y444_10LE, "raw video", 0x00000000, DPTH10_10_10,
PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_10LE),
};
static GstVideoFormat
......
......@@ -74,6 +74,8 @@ G_BEGIN_DECLS
* @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
* @GST_VIDEO_FORMAT_Y444_10BE: planar 4:4:4 YUV, 10 bits per channel
* @GST_VIDEO_FORMAT_Y444_10LE: planar 4:4:4 YUV, 10 bits per channel
*
* Enum value describing the most common video formats.
*/
......@@ -124,6 +126,8 @@ typedef enum {
GST_VIDEO_FORMAT_I420_10LE,
GST_VIDEO_FORMAT_I422_10BE,
GST_VIDEO_FORMAT_I422_10LE,
GST_VIDEO_FORMAT_Y444_10BE,
GST_VIDEO_FORMAT_Y444_10LE,
} GstVideoFormat;
#define GST_VIDEO_MAX_PLANES 4
......@@ -437,7 +441,8 @@ 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, I422_10LE, I422_10BE }"
"IYU1, ARGB64, AYUV64, r210, I420_10LE, I420_10BE, I422_10LE, I422_10BE, " \
" Y444_10LE, Y444_10BE }"
/**
* GST_VIDEO_CAPS_MAKE:
......
......@@ -542,6 +542,16 @@ fill_planes (GstVideoInfo * info)
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_Y444_10LE:
case GST_VIDEO_FORMAT_Y444_10BE:
info->stride[0] = GST_ROUND_UP_4 (width * 2);
info->stride[1] = info->stride[0];
info->stride[2] = info->stride[0];
info->offset[0] = 0;
info->offset[1] = info->stride[0] * height;
info->offset[2] = info->offset[1] * 2;
info->size = info->stride[0] * height * 3;
break;
case GST_VIDEO_FORMAT_ENCODED:
break;
case GST_VIDEO_FORMAT_UNKNOWN:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment