mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 14:06:23 +00:00
video: add support for Y412 format
Y412 is a packed 12 bits 4:4:4:4 format in the order U, Y, V, A, 2 bytes per component with the color value stored in the 12 most significant bits Refer to https://github.com/torvalds/linux/blob/master/include/uapi/drm/drm_fourcc.h#L182 for the LE variant
This commit is contained in:
parent
ea063721d2
commit
7816cbf9a4
4 changed files with 128 additions and 1 deletions
|
@ -5932,6 +5932,8 @@ get_scale_format (GstVideoFormat format, gint plane)
|
|||
case GST_VIDEO_FORMAT_P012_LE:
|
||||
case GST_VIDEO_FORMAT_Y212_BE:
|
||||
case GST_VIDEO_FORMAT_Y212_LE:
|
||||
case GST_VIDEO_FORMAT_Y412_BE:
|
||||
case GST_VIDEO_FORMAT_Y412_LE:
|
||||
res = format;
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
|
|
|
@ -6162,6 +6162,120 @@ pack_Y212_LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
|
|||
}
|
||||
}
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
guint32 fourcc;
|
||||
|
@ -6183,6 +6297,7 @@ typedef struct
|
|||
#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 }
|
||||
|
@ -6513,6 +6628,10 @@ static const VideoFormat formats[] = {
|
|||
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),
|
||||
};
|
||||
|
||||
static GstVideoFormat
|
||||
|
|
|
@ -127,6 +127,8 @@ G_BEGIN_DECLS
|
|||
* @GST_VIDEO_FORMAT_P012_LE: planar 4:2:0 YUV with interleaved UV plane, 12 bits per channel (Since: 1.18)
|
||||
* @GST_VIDEO_FORMAT_Y212_BE: packed 4:2:2 YUV, 12 bits per channel (Y-U-Y-V) (Since: 1.18)
|
||||
* @GST_VIDEO_FORMAT_Y212_LE: packed 4:2:2 YUV, 12 bits per channel (Y-U-Y-V) (Since: 1.18)
|
||||
* @GST_VIDEO_FORMAT_Y412_BE: packed 4:4:4:4 YUV, 12 bits per channel(U-Y-V-A...) (Since: 1.18)
|
||||
* @GST_VIDEO_FORMAT_Y412_LE: packed 4:4:4:4 YUV, 12 bits per channel(U-Y-V-A...) (Since: 1.18)
|
||||
*
|
||||
* Enum value describing the most common video formats.
|
||||
*
|
||||
|
@ -229,6 +231,8 @@ typedef enum {
|
|||
GST_VIDEO_FORMAT_P012_LE,
|
||||
GST_VIDEO_FORMAT_Y212_BE,
|
||||
GST_VIDEO_FORMAT_Y212_LE,
|
||||
GST_VIDEO_FORMAT_Y412_BE,
|
||||
GST_VIDEO_FORMAT_Y412_LE,
|
||||
} GstVideoFormat;
|
||||
|
||||
#define GST_VIDEO_MAX_PLANES 4
|
||||
|
@ -583,7 +587,7 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
|
|||
"A420_10LE, A422_10BE, A422_10LE, A444_10BE, A444_10LE, NV61, P010_10BE, " \
|
||||
"P010_10LE, IYU2, VYUY, GBRA, GBRA_10BE, GBRA_10LE, BGR10A2_LE, RGB10A2_LE, GBR_12BE, GBR_12LE, " \
|
||||
"GBRA_12BE, GBRA_12LE, P012_BE, P012_LE, I420_12BE, I420_12LE, Y212_BE, Y212_LE, I422_12BE, I422_12LE, " \
|
||||
"Y444_12BE, Y444_12LE, GRAY10_LE32, NV12_10LE32, NV16_10LE32, NV12_10LE40, " \
|
||||
"Y412_BE, Y412_LE, Y444_12BE, Y444_12LE, GRAY10_LE32, NV12_10LE32, NV16_10LE32, NV12_10LE40, " \
|
||||
"Y444_16BE, Y444_16LE, P016_BE, P016_LE }"
|
||||
|
||||
/**
|
||||
|
|
|
@ -862,6 +862,8 @@ fill_planes (GstVideoInfo * info, gsize plane_size[GST_VIDEO_MAX_PLANES])
|
|||
break;
|
||||
case GST_VIDEO_FORMAT_ARGB64:
|
||||
case GST_VIDEO_FORMAT_AYUV64:
|
||||
case GST_VIDEO_FORMAT_Y412_BE:
|
||||
case GST_VIDEO_FORMAT_Y412_LE:
|
||||
info->stride[0] = width * 8;
|
||||
info->offset[0] = 0;
|
||||
info->size = info->stride[0] * height;
|
||||
|
|
Loading…
Reference in a new issue