summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-04-23 12:47:13 +0200
committerwm4 <wm4@nowhere>2020-04-23 13:24:35 +0200
commit8767c468735f64cdbd4bbbbe83121c2b068255e7 (patch)
treed3a0867487b285bba400aba563e53368dbf5c6aa /video
parent3e84b48a6fb08065d2d880d83938227d5f8ebadd (diff)
downloadmpv-8767c468735f64cdbd4bbbbe83121c2b068255e7.tar.bz2
mpv-8767c468735f64cdbd4bbbbe83121c2b068255e7.tar.xz
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.
Diffstat (limited to 'video')
-rw-r--r--video/img_format.c25
-rw-r--r--video/img_format.h9
2 files changed, 34 insertions, 0 deletions
diff --git a/video/img_format.c b/video/img_format.c
index ed194ef751..6379dd41d1 100644
--- a/video/img_format.c
+++ b/video/img_format.c
@@ -39,6 +39,14 @@ struct mp_imgfmt_entry {
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[] = {
// not in ffmpeg
[IMGFMT_VDPAU_OUTPUT - IMGFMT_CUST_BASE] = {
@@ -85,6 +93,23 @@ static const struct mp_imgfmt_entry mp_imgfmt_list[] = {
.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
[IMGFMT_VIDEOTOOLBOX - IMGFMT_CUST_BASE] = {
.name = "videotoolbox",
diff --git a/video/img_format.h b/video/img_format.h
index 2bd448899b..f422019dec 100644
--- a/video/img_format.h
+++ b/video/img_format.h
@@ -214,6 +214,15 @@ enum mp_imgfmt {
// Accessed with bit-shifts, uint32_t units.
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).
IMGFMT_VDPAU_OUTPUT, // VdpOutputSurface
IMGFMT_VAAPI,