video: add VUYA pixel format

AYUV in gstreamer was defined in A-Y-U-V order in memory[1], however
Microsoft defined another AYUV format in V-U-Y-A order in memory[2]. Add
VUYA format for the latter in order to distinguish the two formats

[1] https://gstreamer.freedesktop.org/documentation/design/mediatype-video-raw.html#formats
[2] https://docs.microsoft.com/en-us/windows/desktop/medfound/recommended-8-bit-yuv-formats-for-video-rendering#ayuv)
This commit is contained in:
Haihao Xiang 2019-03-15 13:13:52 +08:00 committed by Tim-Philipp Müller
parent c1a5a36bba
commit 90f8cca04e
5 changed files with 49 additions and 1 deletions

View file

@ -5826,6 +5826,7 @@ get_scale_format (GstVideoFormat format, gint plane)
case GST_VIDEO_FORMAT_VYUY: case GST_VIDEO_FORMAT_VYUY:
case GST_VIDEO_FORMAT_YVYU: case GST_VIDEO_FORMAT_YVYU:
case GST_VIDEO_FORMAT_AYUV: case GST_VIDEO_FORMAT_AYUV:
case GST_VIDEO_FORMAT_VUYA:
case GST_VIDEO_FORMAT_RGBx: case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_BGRx: case GST_VIDEO_FORMAT_BGRx:
case GST_VIDEO_FORMAT_xRGB: case GST_VIDEO_FORMAT_xRGB:

View file

@ -5209,6 +5209,32 @@ pack_NV12_10LE40 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
} }
} }
#define PACK_VUYA GST_VIDEO_FORMAT_AYUV, unpack_VUYA, 1, pack_VUYA
static void
unpack_VUYA (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 s = GET_LINE (y);
guint8 *restrict d = dest;
s += x * 4;
video_orc_unpack_VUYA (d, s, width);
}
static void
pack_VUYA (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)
{
const guint8 *restrict s = src;
guint8 *restrict d = GET_LINE (y);
video_orc_pack_VUYA (d, s, width);
}
typedef struct typedef struct
{ {
guint32 fourcc; guint32 fourcc;
@ -5536,6 +5562,8 @@ static const VideoFormat formats[] = {
DPTH10_10_10, PSTR488, PLANE0, OFFS0, SUB422, PACK_Y210), DPTH10_10_10, PSTR488, PLANE0, OFFS0, SUB422, PACK_Y210),
MAKE_YUV_FORMAT (Y410, "raw video", GST_MAKE_FOURCC ('Y', '4', '1', '0'), 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, PSTR0, 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),
}; };
static GstVideoFormat static GstVideoFormat
@ -5780,6 +5808,8 @@ gst_video_format_from_fourcc (guint32 fourcc)
return GST_VIDEO_FORMAT_NV12_10LE40; return GST_VIDEO_FORMAT_NV12_10LE40;
case GST_MAKE_FOURCC ('Y', '4', '1', '0'): case GST_MAKE_FOURCC ('Y', '4', '1', '0'):
return GST_VIDEO_FORMAT_Y410; return GST_VIDEO_FORMAT_Y410;
case GST_MAKE_FOURCC ('V', 'U', 'Y', 'A'):
return GST_VIDEO_FORMAT_VUYA;
default: default:
return GST_VIDEO_FORMAT_UNKNOWN; return GST_VIDEO_FORMAT_UNKNOWN;

View file

@ -116,6 +116,7 @@ G_BEGIN_DECLS
* @GST_VIDEO_FORMAT_NV12_10LE40: Fully packed variant of NV12_10LE32 (Since: 1.16) * @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_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) * @GST_VIDEO_FORMAT_Y410: packed 4:4:4 YUV, 10 bits per channel(A-V-Y-U...) (Since: 1.16)
* @GST_VIDEO_FORMAT_VUYA: packed 4:4:4 YUV with alpha channel (V0-U0-Y0-A0...) (Since: 1.16)
* *
* Enum value describing the most common video formats. * Enum value describing the most common video formats.
* *
@ -207,6 +208,7 @@ typedef enum {
GST_VIDEO_FORMAT_NV12_10LE40, GST_VIDEO_FORMAT_NV12_10LE40,
GST_VIDEO_FORMAT_Y210, GST_VIDEO_FORMAT_Y210,
GST_VIDEO_FORMAT_Y410, GST_VIDEO_FORMAT_Y410,
GST_VIDEO_FORMAT_VUYA,
} GstVideoFormat; } GstVideoFormat;
#define GST_VIDEO_MAX_PLANES 4 #define GST_VIDEO_MAX_PLANES 4
@ -549,7 +551,7 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
# define GST_VIDEO_OE(s) G_STRINGIFY(s)"_LE" # define GST_VIDEO_OE(s) G_STRINGIFY(s)"_LE"
#endif #endif
#define GST_VIDEO_FORMATS_ALL "{ I420, YV12, YUY2, UYVY, AYUV, RGBx, " \ #define GST_VIDEO_FORMATS_ALL "{ I420, YV12, YUY2, UYVY, AYUV, VUYA, RGBx, " \
"BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, YVYU, " \ "BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, YVYU, " \
"Y444, v210, v216, Y210, Y410, 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, " \ "BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, IYU1, ARGB64, " \

View file

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

View file

@ -538,6 +538,20 @@ select0lw ay, ayuv
select1wb y, ay select1wb y, ay
select0wb a, ay select0wb a, ay
.function video_orc_unpack_VUYA
.dest 4 ayuv guint8
.source 4 vuya guint8
swapl ayuv, vuya
.function video_orc_pack_VUYA
.dest 4 vuya guint8
.source 4 ayuv guint8
swapl vuya, ayuv
.function video_orc_unpack_RGB15_le .function video_orc_unpack_RGB15_le
.dest 4 argb guint32 .dest 4 argb guint32
.source 2 rgb15 guint16 .source 2 rgb15 guint16