video: add Y410 pixel format.

This pixel format is packed format with 4:4:4 sample. And 10
available bits of Y/U/V and 2 available bits of alpha stored
in 4 Bytes.

Format defined in:
https://docs.microsoft.com/en-us/windows/desktop/medfound/10-bit-and-16-bit-yuv-video-formats
This commit is contained in:
Wangfei 2018-11-23 14:40:27 +08:00 committed by Nicolas Dufresne
parent 08ea7d676e
commit 0ac7d1187b
4 changed files with 69 additions and 1 deletions

View file

@ -5851,6 +5851,7 @@ get_scale_format (GstVideoFormat format, gint plane)
case GST_VIDEO_FORMAT_v210:
case GST_VIDEO_FORMAT_v216:
case GST_VIDEO_FORMAT_Y210:
case GST_VIDEO_FORMAT_Y410:
case GST_VIDEO_FORMAT_UYVP:
case GST_VIDEO_FORMAT_RGB8P:
case GST_VIDEO_FORMAT_IYU1:

View file

@ -846,6 +846,64 @@ pack_Y210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
}
}
#define PACK_Y410 GST_VIDEO_FORMAT_AYUV64, unpack_Y410, 1, pack_Y410
static void
unpack_Y410 (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;
guint32 AVYU;
guint16 A, Y, U, V;
for (i = 0; i < width; i++) {
AVYU = GST_READ_UINT32_LE (s + 4 * i);
U = ((AVYU >> 0) & 0x3ff) << 6;
Y = ((AVYU >> 10) & 0x3ff) << 6;
V = ((AVYU >> 20) & 0x3ff) << 6;
A = ((AVYU >> 30) & 0x03) << 14;
if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
U |= (U >> 10);
Y |= (Y >> 10);
V |= (V >> 10);
A |= (A >> 10);
}
d[4 * i + 0] = A;
d[4 * i + 1] = Y;
d[4 * i + 2] = U;
d[4 * i + 3] = V;
}
}
static void
pack_Y410 (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 AVYU;
guint16 A, Y, U, V;
for (i = 0; i < width; i++) {
A = s[4 * i] & 0xc000;
Y = s[4 * i + 1] & 0xffc0;
U = s[4 * i + 2] & 0xffc0;
V = s[4 * i + 3] & 0xffc0;
AVYU = (U >> 6) | (Y << 4) | (V << 14) | (A << 16);
GST_WRITE_UINT32_LE (d + i, AVYU);
}
}
#define PACK_Y41B GST_VIDEO_FORMAT_AYUV, unpack_Y41B, 1, pack_Y41B
static void
unpack_Y41B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
@ -5168,6 +5226,7 @@ typedef struct
#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 }
@ -5476,6 +5535,8 @@ static const VideoFormat formats[] = {
OFFS0, SUB420, PACK_NV12_10LE40),
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),
};
static GstVideoFormat
@ -5718,6 +5779,9 @@ gst_video_format_from_fourcc (guint32 fourcc)
return GST_VIDEO_FORMAT_NV16_10LE32;
case GST_MAKE_FOURCC ('R', 'K', '2', '0'):
return GST_VIDEO_FORMAT_NV12_10LE40;
case GST_MAKE_FOURCC ('Y', '4', '1', '0'):
return GST_VIDEO_FORMAT_Y410;
default:
return GST_VIDEO_FORMAT_UNKNOWN;
}

View file

@ -115,6 +115,7 @@ G_BEGIN_DECLS
* @GST_VIDEO_FORMAT_Y444_12LE: planar 4:4:4 YUV, 12 bits per channel (Since: 1.12)
* @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)
*
* Enum value describing the most common video formats.
*/
@ -202,6 +203,7 @@ typedef enum {
GST_VIDEO_FORMAT_NV16_10LE32,
GST_VIDEO_FORMAT_NV12_10LE40,
GST_VIDEO_FORMAT_Y210,
GST_VIDEO_FORMAT_Y410,
} GstVideoFormat;
#define GST_VIDEO_MAX_PLANES 4
@ -546,7 +548,7 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
#define GST_VIDEO_FORMATS_ALL "{ I420, YV12, YUY2, UYVY, AYUV, RGBx, " \
"BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, YVYU, " \
"Y444, v210, v216, Y210, NV12, NV21, GRAY8, GRAY16_BE, GRAY16_LE, v308, RGB16, " \
"Y444, v210, v216, Y210, Y410, NV12, NV21, GRAY8, GRAY16_BE, GRAY16_LE, v308, RGB16, " \
"BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, IYU1, ARGB64, " \
"AYUV64, r210, I420_10BE, I420_10LE, I422_10BE, I422_10LE, Y444_10BE, " \
"Y444_10LE, GBR, GBR_10BE, GBR_10LE, NV16, NV24, NV12_64Z32, A420_10BE, " \

View file

@ -762,6 +762,7 @@ fill_planes (GstVideoInfo * info)
case GST_VIDEO_FORMAT_xBGR:
case GST_VIDEO_FORMAT_ABGR:
case GST_VIDEO_FORMAT_r210:
case GST_VIDEO_FORMAT_Y410:
info->stride[0] = width * 4;
info->offset[0] = 0;
info->size = info->stride[0] * height;