mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
video: Add RGB10A2_LE pixel format
Packed 10 bits per each R, G and B channel with MSB 2bits alpha channel. This format is mapped to Windows' DXGI_FORMAT_R10G10B10A2_UNORM format which is required for 10bits HDR rendering. Note that this RGB10A2_LE format is R - B channel swapped version of BGR10A2_LE
This commit is contained in:
parent
b47fe55f1d
commit
f4b054d349
4 changed files with 71 additions and 2 deletions
|
@ -5900,6 +5900,7 @@ get_scale_format (GstVideoFormat format, gint plane)
|
|||
case GST_VIDEO_FORMAT_NV16_10LE32:
|
||||
case GST_VIDEO_FORMAT_NV12_10LE40:
|
||||
case GST_VIDEO_FORMAT_BGR10A2_LE:
|
||||
case GST_VIDEO_FORMAT_RGB10A2_LE:
|
||||
res = format;
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
|
|
|
@ -5338,6 +5338,66 @@ pack_bgr10a2_le (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
|
|||
}
|
||||
}
|
||||
|
||||
#define PACK_RGB10A2_LE GST_VIDEO_FORMAT_ARGB64, unpack_rgb10a2_le, 1, pack_rgb10a2_le
|
||||
static void
|
||||
unpack_rgb10a2_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 guint8 *restrict s = GET_LINE (y);
|
||||
guint16 *restrict d = dest;
|
||||
guint32 ARGB;
|
||||
guint16 A, R, G, B;
|
||||
|
||||
s += x * 4;
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
ARGB = GST_READ_UINT32_LE (s + 4 * i);
|
||||
|
||||
R = ((ARGB >> 0) & 0x3ff) << 6;
|
||||
G = ((ARGB >> 10) & 0x3ff) << 6;
|
||||
B = ((ARGB >> 20) & 0x3ff) << 6;
|
||||
A = ((ARGB >> 30) & 0x03) << 14;
|
||||
|
||||
if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
|
||||
R |= (R >> 10);
|
||||
G |= (G >> 10);
|
||||
B |= (B >> 10);
|
||||
A |= (A >> 10);
|
||||
}
|
||||
|
||||
d[4 * i + 0] = A;
|
||||
d[4 * i + 1] = R;
|
||||
d[4 * i + 2] = G;
|
||||
d[4 * i + 3] = B;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pack_rgb10a2_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;
|
||||
guint32 *restrict d = GET_LINE (y);
|
||||
const guint16 *restrict s = src;
|
||||
guint32 ARGB;
|
||||
guint16 A, R, G, B;
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
A = s[4 * i] & 0xc000;
|
||||
R = s[4 * i + 1] & 0xffc0;
|
||||
G = s[4 * i + 2] & 0xffc0;
|
||||
B = s[4 * i + 3] & 0xffc0;
|
||||
|
||||
ARGB = (R >> 6) | (G << 4) | (B << 14) | (A << 16);
|
||||
|
||||
GST_WRITE_UINT32_LE (d + i, ARGB);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
guint32 fourcc;
|
||||
|
@ -5670,6 +5730,8 @@ static const VideoFormat formats[] = {
|
|||
MAKE_RGBA_LE_PACK_FORMAT (BGR10A2_LE, "raw video", DPTH10_10_10_2, PSTR4444,
|
||||
PLANE0,
|
||||
OFFS0, SUB4444, PACK_BGR10A2_LE),
|
||||
MAKE_RGBA_LE_PACK_FORMAT (RGB10A2_LE, "raw video", DPTH10_10_10_2, PSTR4444,
|
||||
PLANE0, OFFS0, SUB4444, PACK_RGB10A2_LE),
|
||||
};
|
||||
|
||||
static GstVideoFormat
|
||||
|
@ -5804,6 +5866,9 @@ gst_video_format_from_masks (gint depth, gint bpp, gint endianness,
|
|||
|
||||
if (depth == 32 && bpp == 32 && alpha_mask == 0xc0000000 &&
|
||||
endianness == G_LITTLE_ENDIAN) {
|
||||
if (red_mask == 0x3ff00000)
|
||||
format = GST_VIDEO_FORMAT_RGB10A2_LE;
|
||||
else
|
||||
format = GST_VIDEO_FORMAT_BGR10A2_LE;
|
||||
} else if (depth == 30 && bpp == 32) {
|
||||
format = GST_VIDEO_FORMAT_r210;
|
||||
|
|
|
@ -118,6 +118,7 @@ G_BEGIN_DECLS
|
|||
* @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)
|
||||
* @GST_VIDEO_FORMAT_BGR10A2_LE: packed 4:4:4 RGB with alpha channel(B-G-R-A), 10 bits for R/G/B channel and MSB 2 bits for alpha channel (Since: 1.16)
|
||||
* @GST_VIDEO_FORMAT_RGB10A2_LE: packed 4:4:4 RGB with alpha channel(R-G-B-A), 10 bits for R/G/B channel and MSB 2 bits for alpha channel (Since: 1.18)
|
||||
*
|
||||
* Enum value describing the most common video formats.
|
||||
*
|
||||
|
@ -211,6 +212,7 @@ typedef enum {
|
|||
GST_VIDEO_FORMAT_Y410,
|
||||
GST_VIDEO_FORMAT_VUYA,
|
||||
GST_VIDEO_FORMAT_BGR10A2_LE,
|
||||
GST_VIDEO_FORMAT_RGB10A2_LE,
|
||||
} GstVideoFormat;
|
||||
|
||||
#define GST_VIDEO_MAX_PLANES 4
|
||||
|
@ -560,7 +562,7 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
|
|||
"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, " \
|
||||
"A420_10LE, A422_10BE, A422_10LE, A444_10BE, A444_10LE, NV61, P010_10BE, " \
|
||||
"P010_10LE, IYU2, VYUY, GBRA, GBRA_10BE, GBRA_10LE, BGR10A2_LE, GBR_12BE, GBR_12LE, " \
|
||||
"P010_10LE, IYU2, VYUY, GBRA, GBRA_10BE, GBRA_10LE, BGR10A2_LE, RGB10A2_LE, GBR_12BE, GBR_12LE, " \
|
||||
"GBRA_12BE, GBRA_12LE, I420_12BE, I420_12LE, I422_12BE, I422_12LE, " \
|
||||
"Y444_12BE, Y444_12LE, GRAY10_LE32, NV12_10LE32, NV16_10LE32, NV12_10LE40 }"
|
||||
|
||||
|
|
|
@ -791,6 +791,7 @@ fill_planes (GstVideoInfo * info)
|
|||
case GST_VIDEO_FORMAT_Y410:
|
||||
case GST_VIDEO_FORMAT_VUYA:
|
||||
case GST_VIDEO_FORMAT_BGR10A2_LE:
|
||||
case GST_VIDEO_FORMAT_RGB10A2_LE:
|
||||
info->stride[0] = width * 4;
|
||||
info->offset[0] = 0;
|
||||
info->size = info->stride[0] * height;
|
||||
|
|
Loading…
Reference in a new issue