mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
video: Add support for 4:2:2 10 bit video.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=683838
This commit is contained in:
parent
ec27f4e13c
commit
79f0210aed
4 changed files with 207 additions and 2 deletions
|
@ -1129,3 +1129,59 @@ Formats
|
|||
default size: size (component0) +
|
||||
size (component1) +
|
||||
size (component2)
|
||||
|
||||
"I422_10LE" planar 4:2:2 YUV, 10 bits per channel LE
|
||||
|
||||
Component 0: Y
|
||||
depth: 10 LE
|
||||
pstride: 2
|
||||
default offset: 0
|
||||
default rstride: RU4 (width * 2)
|
||||
default size: rstride (component0) * RU2 (height)
|
||||
|
||||
Component 1: U
|
||||
depth: 10 LE
|
||||
pstride: 2
|
||||
default offset: size (component0)
|
||||
default rstride: RU4 (width)
|
||||
default size: rstride (component1) * RU2 (height)
|
||||
|
||||
Component 2: V
|
||||
depth 10 LE
|
||||
pstride: 2
|
||||
default offset: offset (component1) + size (component1)
|
||||
default rstride: RU4 (width)
|
||||
default size: rstride (component2) * RU2 (height)
|
||||
|
||||
Image
|
||||
default size: size (component0) +
|
||||
size (component1) +
|
||||
size (component2)
|
||||
|
||||
"I422_10BE" planar 4:2:2 YUV, 10 bits per channel BE
|
||||
|
||||
Component 0: Y
|
||||
depth: 10 BE
|
||||
pstride: 2
|
||||
default offset: 0
|
||||
default rstride: RU4 (width * 2)
|
||||
default size: rstride (component0) * RU2 (height)
|
||||
|
||||
Component 1: U
|
||||
depth: 10 BE
|
||||
pstride: 2
|
||||
default offset: size (component0)
|
||||
default rstride: RU4 (width)
|
||||
default size: rstride (component1) * RU2 (height)
|
||||
|
||||
Component 2: V
|
||||
depth 10 BE
|
||||
pstride: 2
|
||||
default offset: offset (component1) + size (component1)
|
||||
default rstride: RU4 (width)
|
||||
default size: rstride (component2) * RU2 (height)
|
||||
|
||||
Image
|
||||
default size: size (component0) +
|
||||
size (component1) +
|
||||
size (component2)
|
||||
|
|
|
@ -1354,6 +1354,136 @@ pack_I420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
|
|||
}
|
||||
}
|
||||
|
||||
#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 +1703,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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue