mirror of https://github.com/mpv-player/mpv
video: add yuv float formats
Adding all these so I can use them for obscure processing purposes (see later draw_bmp commit). There isn't really a reason why they should exist. On the other hand, they're just labels for formats that can be handled in a generic way, and this commit adds support for them in the zimg wrapper and vo_gpu just by making the formats exist. (Well, vo_gpu had to be fixed in the previous commit.)
This commit is contained in:
parent
9e48085043
commit
56dbbc3847
|
@ -686,6 +686,13 @@ gray9be: [GENERIC] ctype=uint
|
|||
{2/16/[0:0] 0/0/[0:0] 0/0/[0:0] 0/0/[0:0] }
|
||||
AVD: name=gray9be chroma=0:0 flags=0x1 [be]
|
||||
0: p=0 st=2 o=0 sh=0 d=9
|
||||
grayaf32: ctype=float
|
||||
Legacy desc: [ba][a][yuvp][yuv][le]
|
||||
planes=2, chroma=0:0 align=1:1 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[0:0] 0/0/[0:0] 0/0/[0:0] }
|
||||
Regular: planes=2 compbytes=4 bitpad=0 chroma=1x1 ctype=float
|
||||
0: {1}
|
||||
1: {4}
|
||||
grayf32: [GENERIC] ctype=float
|
||||
Legacy desc: [ba][yuv][le]
|
||||
planes=1, chroma=0:0 align=1:1 bits=32 cbits=32
|
||||
|
@ -1140,6 +1147,14 @@ yuv410p: [GENERIC] ctype=uint
|
|||
0: p=0 st=1 o=0 sh=0 d=8
|
||||
1: p=1 st=1 o=0 sh=0 d=8
|
||||
2: p=2 st=1 o=0 sh=0 d=8
|
||||
yuv410pf: ctype=float
|
||||
Legacy desc: [ba][yuvp][yuv][le]
|
||||
planes=3, chroma=2:2 align=4:4 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[2:2] 4/32/[2:2] 0/0/[0:0] }
|
||||
Regular: planes=3 compbytes=4 bitpad=0 chroma=4x4 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
yuv411p: [GENERIC] ctype=uint
|
||||
Legacy desc: [ba][yuvp][yuv][le][be]
|
||||
planes=3, chroma=2:0 align=4:1 bits=8 cbits=8
|
||||
|
@ -1152,6 +1167,14 @@ yuv411p: [GENERIC] ctype=uint
|
|||
0: p=0 st=1 o=0 sh=0 d=8
|
||||
1: p=1 st=1 o=0 sh=0 d=8
|
||||
2: p=2 st=1 o=0 sh=0 d=8
|
||||
yuv411pf: ctype=float
|
||||
Legacy desc: [ba][yuvp][yuv][le]
|
||||
planes=3, chroma=2:0 align=4:1 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[2:0] 4/32/[2:0] 0/0/[0:0] }
|
||||
Regular: planes=3 compbytes=4 bitpad=0 chroma=4x1 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
yuv420p: ctype=uint
|
||||
Legacy desc: [ba][yuvp][yuv][le][be]
|
||||
planes=3, chroma=1:1 align=2:2 bits=8 cbits=8
|
||||
|
@ -1265,6 +1288,14 @@ yuv420p9be: [GENERIC] ctype=uint
|
|||
0: p=0 st=2 o=0 sh=0 d=9
|
||||
1: p=1 st=2 o=0 sh=0 d=9
|
||||
2: p=2 st=2 o=0 sh=0 d=9
|
||||
yuv420pf: ctype=float
|
||||
Legacy desc: [ba][yuvp][yuv][le]
|
||||
planes=3, chroma=1:1 align=2:2 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[1:1] 4/32/[1:1] 0/0/[0:0] }
|
||||
Regular: planes=3 compbytes=4 bitpad=0 chroma=2x2 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
yuv422p: [GENERIC] ctype=uint
|
||||
Legacy desc: [ba][yuvp][yuv][le][be]
|
||||
planes=3, chroma=1:0 align=2:1 bits=8 cbits=8
|
||||
|
@ -1377,6 +1408,14 @@ yuv422p9be: [GENERIC] ctype=uint
|
|||
0: p=0 st=2 o=0 sh=0 d=9
|
||||
1: p=1 st=2 o=0 sh=0 d=9
|
||||
2: p=2 st=2 o=0 sh=0 d=9
|
||||
yuv422pf: ctype=float
|
||||
Legacy desc: [ba][yuvp][yuv][le]
|
||||
planes=3, chroma=1:0 align=2:1 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[1:0] 4/32/[1:0] 0/0/[0:0] }
|
||||
Regular: planes=3 compbytes=4 bitpad=0 chroma=2x1 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
yuv440p: [GENERIC] ctype=uint
|
||||
Legacy desc: [ba][yuvp][yuv][le][be]
|
||||
planes=3, chroma=0:1 align=1:2 bits=8 cbits=8
|
||||
|
@ -1429,6 +1468,14 @@ yuv440p12be: [GENERIC] ctype=uint
|
|||
0: p=0 st=2 o=0 sh=0 d=12
|
||||
1: p=1 st=2 o=0 sh=0 d=12
|
||||
2: p=2 st=2 o=0 sh=0 d=12
|
||||
yuv440pf: ctype=float
|
||||
Legacy desc: [ba][yuvp][yuv][le]
|
||||
planes=3, chroma=0:1 align=1:2 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[0:1] 4/32/[0:1] 0/0/[0:0] }
|
||||
Regular: planes=3 compbytes=4 bitpad=0 chroma=1x2 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
yuv444p: ctype=uint
|
||||
Legacy desc: [ba][yuvp][yuv][le][be]
|
||||
planes=3, chroma=0:0 align=1:1 bits=8 cbits=8
|
||||
|
@ -1542,6 +1589,32 @@ yuv444p9be: [GENERIC] ctype=uint
|
|||
0: p=0 st=2 o=0 sh=0 d=9
|
||||
1: p=1 st=2 o=0 sh=0 d=9
|
||||
2: p=2 st=2 o=0 sh=0 d=9
|
||||
yuv444pf: ctype=float
|
||||
Legacy desc: [ba][yuvp][yuv][le]
|
||||
planes=3, chroma=0:0 align=1:1 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[0:0] 4/32/[0:0] 0/0/[0:0] }
|
||||
Regular: planes=3 compbytes=4 bitpad=0 chroma=1x1 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
yuva410pf: ctype=float
|
||||
Legacy desc: [ba][a][yuvp][yuv][le]
|
||||
planes=4, chroma=2:2 align=4:4 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[2:2] 4/32/[2:2] 4/32/[0:0] }
|
||||
Regular: planes=4 compbytes=4 bitpad=0 chroma=4x4 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
3: {4}
|
||||
yuva411pf: ctype=float
|
||||
Legacy desc: [ba][a][yuvp][yuv][le]
|
||||
planes=4, chroma=2:0 align=4:1 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[2:0] 4/32/[2:0] 4/32/[0:0] }
|
||||
Regular: planes=4 compbytes=4 bitpad=0 chroma=4x1 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
3: {4}
|
||||
yuva420p: [GENERIC] ctype=uint
|
||||
Legacy desc: [ba][a][yuvp][yuv][le][be]
|
||||
planes=4, chroma=1:1 align=2:2 bits=8 cbits=8
|
||||
|
@ -1625,6 +1698,15 @@ yuva420p9be: [GENERIC] ctype=uint
|
|||
1: p=1 st=2 o=0 sh=0 d=9
|
||||
2: p=2 st=2 o=0 sh=0 d=9
|
||||
3: p=3 st=2 o=0 sh=0 d=9
|
||||
yuva420pf: ctype=float
|
||||
Legacy desc: [ba][a][yuvp][yuv][le]
|
||||
planes=4, chroma=1:1 align=2:2 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[1:1] 4/32/[1:1] 4/32/[0:0] }
|
||||
Regular: planes=4 compbytes=4 bitpad=0 chroma=2x2 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
3: {4}
|
||||
yuva422p: [GENERIC] ctype=uint
|
||||
Legacy desc: [ba][a][yuvp][yuv][le][be]
|
||||
planes=4, chroma=1:0 align=2:1 bits=8 cbits=8
|
||||
|
@ -1731,6 +1813,24 @@ yuva422p9be: [GENERIC] ctype=uint
|
|||
1: p=1 st=2 o=0 sh=0 d=9
|
||||
2: p=2 st=2 o=0 sh=0 d=9
|
||||
3: p=3 st=2 o=0 sh=0 d=9
|
||||
yuva422pf: ctype=float
|
||||
Legacy desc: [ba][a][yuvp][yuv][le]
|
||||
planes=4, chroma=1:0 align=2:1 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[1:0] 4/32/[1:0] 4/32/[0:0] }
|
||||
Regular: planes=4 compbytes=4 bitpad=0 chroma=2x1 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
3: {4}
|
||||
yuva440pf: ctype=float
|
||||
Legacy desc: [ba][a][yuvp][yuv][le]
|
||||
planes=4, chroma=0:1 align=1:2 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[0:1] 4/32/[0:1] 4/32/[0:0] }
|
||||
Regular: planes=4 compbytes=4 bitpad=0 chroma=1x2 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
3: {4}
|
||||
yuva444p: [GENERIC] ctype=uint
|
||||
Legacy desc: [ba][a][yuvp][yuv][le][be]
|
||||
planes=4, chroma=0:0 align=1:1 bits=8 cbits=8
|
||||
|
@ -1837,6 +1937,15 @@ yuva444p9be: [GENERIC] ctype=uint
|
|||
1: p=1 st=2 o=0 sh=0 d=9
|
||||
2: p=2 st=2 o=0 sh=0 d=9
|
||||
3: p=3 st=2 o=0 sh=0 d=9
|
||||
yuva444pf: ctype=float
|
||||
Legacy desc: [ba][a][yuvp][yuv][le]
|
||||
planes=4, chroma=0:0 align=1:1 bits=32 cbits=32
|
||||
{4/32/[0:0] 4/32/[0:0] 4/32/[0:0] 4/32/[0:0] }
|
||||
Regular: planes=4 compbytes=4 bitpad=0 chroma=1x1 ctype=float
|
||||
0: {1}
|
||||
1: {2}
|
||||
2: {3}
|
||||
3: {4}
|
||||
yuvj411p: [GENERIC] ctype=uint
|
||||
Legacy desc: [ba][yuvp][yuv][le][be]
|
||||
planes=3, chroma=2:0 align=4:1 bits=8 cbits=8
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
gray16be Zin Zout SWSin SWSout |
|
||||
gray9 Zin Zout SWSin SWSout |
|
||||
gray9be Zin Zout SWSin SWSout |
|
||||
grayaf32 Zin Zout |
|
||||
grayf32 Zin Zout SWSin SWSout |
|
||||
grayf32be Zin Zout SWSin SWSout |
|
||||
mediacodec |
|
||||
|
@ -134,7 +135,9 @@
|
|||
yap16 Zin Zout |
|
||||
yap8 Zin Zout |
|
||||
yuv410p Zin Zout SWSin SWSout |
|
||||
yuv410pf Zin Zout |
|
||||
yuv411p Zin Zout SWSin SWSout |
|
||||
yuv411pf Zin Zout |
|
||||
yuv420p Zin Zout SWSin SWSout |
|
||||
yuv420p10 Zin Zout SWSin SWSout |
|
||||
yuv420p10be Zin Zout SWSin SWSout |
|
||||
|
@ -146,6 +149,7 @@
|
|||
yuv420p16be Zin Zout SWSin SWSout |
|
||||
yuv420p9 Zin Zout SWSin SWSout |
|
||||
yuv420p9be Zin Zout SWSin SWSout |
|
||||
yuv420pf Zin Zout |
|
||||
yuv422p Zin Zout SWSin SWSout |
|
||||
yuv422p10 Zin Zout SWSin SWSout |
|
||||
yuv422p10be Zin Zout SWSin SWSout |
|
||||
|
@ -157,11 +161,13 @@
|
|||
yuv422p16be Zin Zout SWSin SWSout |
|
||||
yuv422p9 Zin Zout SWSin SWSout |
|
||||
yuv422p9be Zin Zout SWSin SWSout |
|
||||
yuv422pf Zin Zout |
|
||||
yuv440p Zin Zout SWSin SWSout |
|
||||
yuv440p10 Zin Zout SWSin SWSout |
|
||||
yuv440p10be Zin Zout SWSin SWSout |
|
||||
yuv440p12 Zin Zout SWSin SWSout |
|
||||
yuv440p12be Zin Zout SWSin SWSout |
|
||||
yuv440pf Zin Zout |
|
||||
yuv444p Zin Zout SWSin SWSout |
|
||||
yuv444p10 Zin Zout SWSin SWSout |
|
||||
yuv444p10be Zin Zout SWSin SWSout |
|
||||
|
@ -173,6 +179,9 @@
|
|||
yuv444p16be Zin Zout SWSin SWSout |
|
||||
yuv444p9 Zin Zout SWSin SWSout |
|
||||
yuv444p9be Zin Zout SWSin SWSout |
|
||||
yuv444pf Zin Zout |
|
||||
yuva410pf Zin Zout |
|
||||
yuva411pf Zin Zout |
|
||||
yuva420p Zin Zout SWSin SWSout |
|
||||
yuva420p10 Zin Zout SWSin SWSout |
|
||||
yuva420p10be Zin Zout SWSin SWSout |
|
||||
|
@ -180,6 +189,7 @@
|
|||
yuva420p16be Zin Zout SWSin SWSout |
|
||||
yuva420p9 Zin Zout SWSin SWSout |
|
||||
yuva420p9be Zin Zout SWSin SWSout |
|
||||
yuva420pf Zin Zout |
|
||||
yuva422p Zin Zout SWSin SWSout |
|
||||
yuva422p10 Zin Zout SWSin SWSout |
|
||||
yuva422p10be Zin Zout SWSin SWSout |
|
||||
|
@ -189,6 +199,8 @@
|
|||
yuva422p16be Zin Zout SWSin SWSout |
|
||||
yuva422p9 Zin Zout SWSin SWSout |
|
||||
yuva422p9be Zin Zout SWSin SWSout |
|
||||
yuva422pf Zin Zout |
|
||||
yuva440pf Zin Zout |
|
||||
yuva444p Zin Zout SWSin SWSout |
|
||||
yuva444p10 Zin Zout SWSin SWSout |
|
||||
yuva444p10be Zin Zout SWSin SWSout |
|
||||
|
@ -198,6 +210,7 @@
|
|||
yuva444p16be Zin Zout SWSin SWSout |
|
||||
yuva444p9 Zin Zout SWSin SWSout |
|
||||
yuva444p9be Zin Zout SWSin SWSout |
|
||||
yuva444pf Zin Zout |
|
||||
yuvj411p Zin Zout SWSin SWSout |
|
||||
yuvj422p Zin Zout SWSin SWSout |
|
||||
yuvj440p Zin Zout SWSin SWSout |
|
||||
|
|
|
@ -47,6 +47,14 @@ struct mp_imgfmt_entry {
|
|||
.num_planes = 3, .forced_csp = MP_CSP_RGB, \
|
||||
.planes = { {1, {2}}, {1, {3}}, {1, {1}} }, }, }
|
||||
|
||||
#define FLOAT_YUV(def, dname, xs, ys, a_planes) \
|
||||
[def - IMGFMT_CUST_BASE] = { \
|
||||
.name = dname, \
|
||||
.reg_desc = { .component_type = MP_COMPONENT_TYPE_FLOAT, \
|
||||
.component_size = 4, .num_planes = a_planes, \
|
||||
.planes = { {1, {1}}, {1, {2}}, {1, {3}}, {1, {4}} }, \
|
||||
.chroma_xs = xs, .chroma_ys = ys, }}
|
||||
|
||||
static const struct mp_imgfmt_entry mp_imgfmt_list[] = {
|
||||
// not in ffmpeg
|
||||
[IMGFMT_VDPAU_OUTPUT - IMGFMT_CUST_BASE] = {
|
||||
|
@ -104,6 +112,27 @@ static const struct mp_imgfmt_entry mp_imgfmt_list[] = {
|
|||
.planes = { {1, {1}} },
|
||||
},
|
||||
},
|
||||
[IMGFMT_YAPF - IMGFMT_CUST_BASE] = {
|
||||
.name = "grayaf32", // try to mimic ffmpeg naming convention
|
||||
.reg_desc = {
|
||||
.component_type = MP_COMPONENT_TYPE_FLOAT,
|
||||
.component_size = 4,
|
||||
.num_planes = 2,
|
||||
.planes = { {1, {1}}, {1, {4}} },
|
||||
},
|
||||
},
|
||||
FLOAT_YUV(IMGFMT_444PF, "yuv444pf", 0, 0, 3),
|
||||
FLOAT_YUV(IMGFMT_444APF, "yuva444pf", 0, 0, 4),
|
||||
FLOAT_YUV(IMGFMT_420PF, "yuv420pf", 1, 1, 3),
|
||||
FLOAT_YUV(IMGFMT_420APF, "yuva420pf", 1, 1, 4),
|
||||
FLOAT_YUV(IMGFMT_422PF, "yuv422pf", 1, 0, 3),
|
||||
FLOAT_YUV(IMGFMT_422APF, "yuva422pf", 1, 0, 4),
|
||||
FLOAT_YUV(IMGFMT_440PF, "yuv440pf", 0, 1, 3),
|
||||
FLOAT_YUV(IMGFMT_440APF, "yuva440pf", 0, 1, 4),
|
||||
FLOAT_YUV(IMGFMT_410PF, "yuv410pf", 2, 2, 3),
|
||||
FLOAT_YUV(IMGFMT_410APF, "yuva410pf", 2, 2, 4),
|
||||
FLOAT_YUV(IMGFMT_411PF, "yuv411pf", 2, 0, 3),
|
||||
FLOAT_YUV(IMGFMT_411APF, "yuva411pf", 2, 0, 4),
|
||||
FRINGE_GBRP(IMGFMT_GBRP1, "gbrp1", 1),
|
||||
FRINGE_GBRP(IMGFMT_GBRP2, "gbrp2", 2),
|
||||
FRINGE_GBRP(IMGFMT_GBRP3, "gbrp3", 3),
|
||||
|
|
|
@ -212,6 +212,22 @@ enum mp_imgfmt {
|
|||
IMGFMT_YAP8,
|
||||
IMGFMT_YAP16,
|
||||
|
||||
// Planar YUV/alpha formats. Sometimes useful for internal processing. There
|
||||
// should be one for each subsampling factor, with and without alpha, gray.
|
||||
IMGFMT_YAPF, // Note: non-alpha version exists in ffmpeg
|
||||
IMGFMT_444PF,
|
||||
IMGFMT_444APF,
|
||||
IMGFMT_420PF,
|
||||
IMGFMT_420APF,
|
||||
IMGFMT_422PF,
|
||||
IMGFMT_422APF,
|
||||
IMGFMT_440PF,
|
||||
IMGFMT_440APF,
|
||||
IMGFMT_410PF,
|
||||
IMGFMT_410APF,
|
||||
IMGFMT_411PF,
|
||||
IMGFMT_411APF,
|
||||
|
||||
// Accessed with bit-shifts, uint32_t units.
|
||||
IMGFMT_RGB30, // 2pad 10r 10g 10b (MSB to LSB)
|
||||
|
||||
|
|
|
@ -563,24 +563,27 @@ void mp_image_clear(struct mp_image *img, int x0, int y0, int x1, int y1)
|
|||
struct mp_image area = *img;
|
||||
mp_image_crop(&area, x0, y0, x1, y1);
|
||||
|
||||
enum mp_component_type ctype = mp_imgfmt_get_component_type(img->imgfmt);
|
||||
uint32_t plane_clear[MP_MAX_PLANES] = {0};
|
||||
|
||||
if (area.imgfmt == IMGFMT_UYVY) {
|
||||
plane_clear[0] = av_le2ne16(0x0080);
|
||||
} else if (area.fmt.flags & MP_IMGFLAG_YUV_NV) {
|
||||
plane_clear[1] = 0x8080;
|
||||
} else if (area.fmt.flags & MP_IMGFLAG_YUV_P) {
|
||||
uint16_t chroma_clear = (1 << area.fmt.plane_bits) / 2;
|
||||
if (!(area.fmt.flags & MP_IMGFLAG_NE))
|
||||
chroma_clear = av_bswap16(chroma_clear);
|
||||
if (area.num_planes > 2)
|
||||
plane_clear[1] = plane_clear[2] = chroma_clear;
|
||||
if (ctype != MP_COMPONENT_TYPE_FLOAT) {
|
||||
if (area.imgfmt == IMGFMT_UYVY) {
|
||||
plane_clear[0] = av_le2ne16(0x0080);
|
||||
} else if (area.fmt.flags & MP_IMGFLAG_YUV_NV) {
|
||||
plane_clear[1] = 0x8080;
|
||||
} else if (area.fmt.flags & MP_IMGFLAG_YUV_P) {
|
||||
uint16_t chroma_clear = (1 << area.fmt.plane_bits) / 2;
|
||||
if (!(area.fmt.flags & MP_IMGFLAG_NE))
|
||||
chroma_clear = av_bswap16(chroma_clear);
|
||||
if (area.num_planes > 2)
|
||||
plane_clear[1] = plane_clear[2] = chroma_clear;
|
||||
}
|
||||
}
|
||||
|
||||
for (int p = 0; p < area.num_planes; p++) {
|
||||
int bpp = area.fmt.bpp[p];
|
||||
int bytes = (mp_image_plane_w(&area, p) * bpp + 7) / 8;
|
||||
if (bpp <= 8) {
|
||||
if (bpp <= 8 || bpp > 16) {
|
||||
memset_pic(area.planes[p], plane_clear[p], bytes,
|
||||
mp_image_plane_h(&area, p), area.stride[p]);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue