mirror of https://github.com/mpv-player/mpv
img_format: add some mpv-only helper formats
Utterly useless, but the intention is to make dealing with corner case pixel formats (forced upon us by FFmpeg, very rarely) less of a pain. The zimg wrapper will use them. (It already supports these formats automatically, but it will help with its internals.) Y1 is considered RGB, even though gray formats are generally treated as YUV for various reasons. mpv will default all YUV formats to limited range internally, which makes no sense for a 1 bit format, so this is a problem. I wanted to avoid that mp_image_params_guess_csp() (which applies the default) explicitly checks for an image format, so although a bit janky, this seems to be a good solution, especially because I really don't give a shit about these formats, other than having to handle them. It's notable that AV_PIX_FMT_MONOBLACK (also 1 bit gray, just packed) already explicitly marked itself as RGB.
This commit is contained in:
parent
3e84b48a6f
commit
8767c46873
|
@ -440,6 +440,14 @@ gbrp: [GENERIC] fcsp=rgb ctype=uint
|
||||||
0: p=2 st=1 o=0 sh=0 d=8
|
0: p=2 st=1 o=0 sh=0 d=8
|
||||||
1: p=0 st=1 o=0 sh=0 d=8
|
1: p=0 st=1 o=0 sh=0 d=8
|
||||||
2: p=1 st=1 o=0 sh=0 d=8
|
2: p=1 st=1 o=0 sh=0 d=8
|
||||||
|
gbrp1: fcsp=rgb ctype=uint
|
||||||
|
Legacy desc: [ba][rgb][le]
|
||||||
|
planes=3, chroma=0:0 align=1:1 bits=1 cbits=1
|
||||||
|
{1/8/[0:0] 1/8/[0:0] 1/8/[0:0] 0/0/[0:0] }
|
||||||
|
Regular: planes=3 compbytes=1 bitpad=-7 chroma=1x1 ctype=uint
|
||||||
|
0: {2}
|
||||||
|
1: {3}
|
||||||
|
2: {1}
|
||||||
gbrp10: [GENERIC] fcsp=rgb ctype=uint
|
gbrp10: [GENERIC] fcsp=rgb ctype=uint
|
||||||
Legacy desc: [ba][rgb][le]
|
Legacy desc: [ba][rgb][le]
|
||||||
planes=3, chroma=0:0 align=1:1 bits=10 cbits=10
|
planes=3, chroma=0:0 align=1:1 bits=10 cbits=10
|
||||||
|
@ -520,6 +528,46 @@ gbrp16be: [GENERIC] fcsp=rgb ctype=uint
|
||||||
0: p=2 st=2 o=0 sh=0 d=16
|
0: p=2 st=2 o=0 sh=0 d=16
|
||||||
1: p=0 st=2 o=0 sh=0 d=16
|
1: p=0 st=2 o=0 sh=0 d=16
|
||||||
2: p=1 st=2 o=0 sh=0 d=16
|
2: p=1 st=2 o=0 sh=0 d=16
|
||||||
|
gbrp2: fcsp=rgb ctype=uint
|
||||||
|
Legacy desc: [ba][rgb][le]
|
||||||
|
planes=3, chroma=0:0 align=1:1 bits=2 cbits=2
|
||||||
|
{1/8/[0:0] 1/8/[0:0] 1/8/[0:0] 0/0/[0:0] }
|
||||||
|
Regular: planes=3 compbytes=1 bitpad=-6 chroma=1x1 ctype=uint
|
||||||
|
0: {2}
|
||||||
|
1: {3}
|
||||||
|
2: {1}
|
||||||
|
gbrp3: fcsp=rgb ctype=uint
|
||||||
|
Legacy desc: [ba][rgb][le]
|
||||||
|
planes=3, chroma=0:0 align=1:1 bits=3 cbits=3
|
||||||
|
{1/8/[0:0] 1/8/[0:0] 1/8/[0:0] 0/0/[0:0] }
|
||||||
|
Regular: planes=3 compbytes=1 bitpad=-5 chroma=1x1 ctype=uint
|
||||||
|
0: {2}
|
||||||
|
1: {3}
|
||||||
|
2: {1}
|
||||||
|
gbrp4: fcsp=rgb ctype=uint
|
||||||
|
Legacy desc: [ba][rgb][le]
|
||||||
|
planes=3, chroma=0:0 align=1:1 bits=4 cbits=4
|
||||||
|
{1/8/[0:0] 1/8/[0:0] 1/8/[0:0] 0/0/[0:0] }
|
||||||
|
Regular: planes=3 compbytes=1 bitpad=-4 chroma=1x1 ctype=uint
|
||||||
|
0: {2}
|
||||||
|
1: {3}
|
||||||
|
2: {1}
|
||||||
|
gbrp5: fcsp=rgb ctype=uint
|
||||||
|
Legacy desc: [ba][rgb][le]
|
||||||
|
planes=3, chroma=0:0 align=1:1 bits=5 cbits=5
|
||||||
|
{1/8/[0:0] 1/8/[0:0] 1/8/[0:0] 0/0/[0:0] }
|
||||||
|
Regular: planes=3 compbytes=1 bitpad=-3 chroma=1x1 ctype=uint
|
||||||
|
0: {2}
|
||||||
|
1: {3}
|
||||||
|
2: {1}
|
||||||
|
gbrp6: fcsp=rgb ctype=uint
|
||||||
|
Legacy desc: [ba][rgb][le]
|
||||||
|
planes=3, chroma=0:0 align=1:1 bits=6 cbits=6
|
||||||
|
{1/8/[0:0] 1/8/[0:0] 1/8/[0:0] 0/0/[0:0] }
|
||||||
|
Regular: planes=3 compbytes=1 bitpad=-2 chroma=1x1 ctype=uint
|
||||||
|
0: {2}
|
||||||
|
1: {3}
|
||||||
|
2: {1}
|
||||||
gbrp9: [GENERIC] fcsp=rgb ctype=uint
|
gbrp9: [GENERIC] fcsp=rgb ctype=uint
|
||||||
Legacy desc: [ba][rgb][le]
|
Legacy desc: [ba][rgb][le]
|
||||||
planes=3, chroma=0:0 align=1:1 bits=9 cbits=9
|
planes=3, chroma=0:0 align=1:1 bits=9 cbits=9
|
||||||
|
@ -1019,6 +1067,12 @@ xyz12be: [GENERIC] fcsp=xyz ctype=uint
|
||||||
0: p=0 st=6 o=0 sh=4 d=12
|
0: p=0 st=6 o=0 sh=4 d=12
|
||||||
1: p=0 st=6 o=2 sh=4 d=12
|
1: p=0 st=6 o=2 sh=4 d=12
|
||||||
2: p=0 st=6 o=4 sh=4 d=12
|
2: p=0 st=6 o=4 sh=4 d=12
|
||||||
|
y1: fcsp=rgb ctype=uint
|
||||||
|
Legacy desc: [ba][rgb][le]
|
||||||
|
planes=1, chroma=0:0 align=1:1 bits=1 cbits=1
|
||||||
|
{1/8/[0:0] 0/0/[0:0] 0/0/[0:0] 0/0/[0:0] }
|
||||||
|
Regular: planes=1 compbytes=1 bitpad=-7 chroma=1x1 ctype=uint
|
||||||
|
0: {1}
|
||||||
y210: [GENERIC] ctype=uint
|
y210: [GENERIC] ctype=uint
|
||||||
Legacy desc: [ba][yuv][le]
|
Legacy desc: [ba][yuv][le]
|
||||||
planes=1, chroma=1:0 align=2:1 bits=30 cbits=10
|
planes=1, chroma=1:0 align=2:1 bits=30 cbits=10
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
gbrapf32 Zin Zout |
|
gbrapf32 Zin Zout |
|
||||||
gbrapf32be Zin Zout |
|
gbrapf32be Zin Zout |
|
||||||
gbrp Zin Zout SWSin SWSout |
|
gbrp Zin Zout SWSin SWSout |
|
||||||
|
gbrp1 Zin Zout |
|
||||||
gbrp10 Zin Zout SWSin SWSout |
|
gbrp10 Zin Zout SWSin SWSout |
|
||||||
gbrp10be Zin Zout SWSin SWSout |
|
gbrp10be Zin Zout SWSin SWSout |
|
||||||
gbrp12 Zin Zout SWSin SWSout |
|
gbrp12 Zin Zout SWSin SWSout |
|
||||||
|
@ -55,6 +56,11 @@
|
||||||
gbrp14be Zin Zout SWSin SWSout |
|
gbrp14be Zin Zout SWSin SWSout |
|
||||||
gbrp16 Zin Zout SWSin SWSout |
|
gbrp16 Zin Zout SWSin SWSout |
|
||||||
gbrp16be Zin Zout SWSin SWSout |
|
gbrp16be Zin Zout SWSin SWSout |
|
||||||
|
gbrp2 Zin Zout |
|
||||||
|
gbrp3 Zin Zout |
|
||||||
|
gbrp4 Zin Zout |
|
||||||
|
gbrp5 Zin Zout |
|
||||||
|
gbrp6 Zin Zout |
|
||||||
gbrp9 Zin Zout SWSin SWSout |
|
gbrp9 Zin Zout SWSin SWSout |
|
||||||
gbrp9be Zin Zout SWSin SWSout |
|
gbrp9be Zin Zout SWSin SWSout |
|
||||||
gbrpf32 Zin Zout |
|
gbrpf32 Zin Zout |
|
||||||
|
@ -119,6 +125,7 @@
|
||||||
xvmc |
|
xvmc |
|
||||||
xyz12 Zin Zout SWSin SWSout |
|
xyz12 Zin Zout SWSin SWSout |
|
||||||
xyz12be Zin Zout SWSin SWSout |
|
xyz12be Zin Zout SWSin SWSout |
|
||||||
|
y1 Zin Zout |
|
||||||
y210 Zin Zout SWSin |
|
y210 Zin Zout SWSin |
|
||||||
y210be Zin Zout |
|
y210be Zin Zout |
|
||||||
ya16 Zin Zout SWSin SWSout |
|
ya16 Zin Zout SWSin SWSout |
|
||||||
|
|
|
@ -39,6 +39,14 @@ struct mp_imgfmt_entry {
|
||||||
enum mp_component_type ctype;
|
enum mp_component_type ctype;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define FRINGE_GBRP(def, dname, bits) \
|
||||||
|
[def - IMGFMT_CUST_BASE] = { \
|
||||||
|
.name = dname, \
|
||||||
|
.reg_desc = { .component_type = MP_COMPONENT_TYPE_UINT, \
|
||||||
|
.component_size = 1, .component_pad = bits - 8, \
|
||||||
|
.num_planes = 3, .forced_csp = MP_CSP_RGB, \
|
||||||
|
.planes = { {1, {2}}, {1, {3}}, {1, {1}} }, }, }
|
||||||
|
|
||||||
static const struct mp_imgfmt_entry mp_imgfmt_list[] = {
|
static const struct mp_imgfmt_entry mp_imgfmt_list[] = {
|
||||||
// not in ffmpeg
|
// not in ffmpeg
|
||||||
[IMGFMT_VDPAU_OUTPUT - IMGFMT_CUST_BASE] = {
|
[IMGFMT_VDPAU_OUTPUT - IMGFMT_CUST_BASE] = {
|
||||||
|
@ -85,6 +93,23 @@ static const struct mp_imgfmt_entry mp_imgfmt_list[] = {
|
||||||
.planes = { {1, {1}}, {1, {4}} },
|
.planes = { {1, {1}}, {1, {4}} },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
[IMGFMT_Y1 - IMGFMT_CUST_BASE] = {
|
||||||
|
.name = "y1",
|
||||||
|
.reg_desc = {
|
||||||
|
.component_type = MP_COMPONENT_TYPE_UINT,
|
||||||
|
.component_size = 1,
|
||||||
|
.component_pad = -7,
|
||||||
|
.num_planes = 1,
|
||||||
|
.forced_csp = MP_CSP_RGB,
|
||||||
|
.planes = { {1, {1}} },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
FRINGE_GBRP(IMGFMT_GBRP1, "gbrp1", 1),
|
||||||
|
FRINGE_GBRP(IMGFMT_GBRP2, "gbrp2", 2),
|
||||||
|
FRINGE_GBRP(IMGFMT_GBRP3, "gbrp3", 3),
|
||||||
|
FRINGE_GBRP(IMGFMT_GBRP4, "gbrp4", 4),
|
||||||
|
FRINGE_GBRP(IMGFMT_GBRP5, "gbrp5", 5),
|
||||||
|
FRINGE_GBRP(IMGFMT_GBRP6, "gbrp6", 6),
|
||||||
// in FFmpeg, but FFmpeg names have an annoying "_vld" suffix
|
// in FFmpeg, but FFmpeg names have an annoying "_vld" suffix
|
||||||
[IMGFMT_VIDEOTOOLBOX - IMGFMT_CUST_BASE] = {
|
[IMGFMT_VIDEOTOOLBOX - IMGFMT_CUST_BASE] = {
|
||||||
.name = "videotoolbox",
|
.name = "videotoolbox",
|
||||||
|
|
|
@ -214,6 +214,15 @@ enum mp_imgfmt {
|
||||||
// Accessed with bit-shifts, uint32_t units.
|
// Accessed with bit-shifts, uint32_t units.
|
||||||
IMGFMT_RGB30, // 2pad 10r 10g 10b (MSG to LSB)
|
IMGFMT_RGB30, // 2pad 10r 10g 10b (MSG to LSB)
|
||||||
|
|
||||||
|
// Fringe formats for fringe RGB format repacking.
|
||||||
|
IMGFMT_Y1, // gray with 1 bit per pixel
|
||||||
|
IMGFMT_GBRP1, // planar RGB with N bits per color component
|
||||||
|
IMGFMT_GBRP2,
|
||||||
|
IMGFMT_GBRP3,
|
||||||
|
IMGFMT_GBRP4,
|
||||||
|
IMGFMT_GBRP5,
|
||||||
|
IMGFMT_GBRP6,
|
||||||
|
|
||||||
// Hardware accelerated formats (again).
|
// Hardware accelerated formats (again).
|
||||||
IMGFMT_VDPAU_OUTPUT, // VdpOutputSurface
|
IMGFMT_VDPAU_OUTPUT, // VdpOutputSurface
|
||||||
IMGFMT_VAAPI,
|
IMGFMT_VAAPI,
|
||||||
|
|
Loading…
Reference in New Issue