From 98352362ea17075400818e9439f9740c4c19bbbc Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 3 Nov 2019 23:18:35 +0100 Subject: img_format: remove some unused format flags They were used at some point, but then fell into disuse. In general, these old flags are all a bit fuzzy, so it's a good idea to remove them as much as possible. The comment about MP_IMGFLAG_PAL isn't true anymore. The old meaning was deprecated at some point, and the flag was removed from "pseudo paletted" formats. I think mpv at one point changed its own flag from AV_PIX_FMT_FLAG_PSEUDOPAL to AV_PIX_FMT_FLAG_PAL, when the former was deprecated, and it became unnecessary to allocate a palette for non-paletted formats. (The one who deprecated in FFmpeg was me, if you wonder.) MP_IMGFLAG_PLANAR was used in command.c, use a relatively similar flag as replacement. --- player/command.c | 2 +- video/img_format.c | 10 +--------- video/img_format.h | 17 +---------------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/player/command.c b/player/command.c index 1d0da8e105..ac49157aee 100644 --- a/player/command.c +++ b/player/command.c @@ -2359,7 +2359,7 @@ static int property_imgparams(struct mp_image_params p, int action, void *arg) {"average-bpp", SUB_PROP_INT(bpp), .unavailable = !bpp}, {"plane-depth", SUB_PROP_INT(desc.plane_bits), - .unavailable = !(desc.flags & MP_IMGFLAG_PLANAR)}, + .unavailable = !(desc.flags & MP_IMGFLAG_YUV_P)}, {"w", SUB_PROP_INT(p.w)}, {"h", SUB_PROP_INT(p.h)}, {"dw", SUB_PROP_INT(d_w)}, diff --git a/video/img_format.c b/video/img_format.c index 80838a82a2..ace8159ecf 100644 --- a/video/img_format.c +++ b/video/img_format.c @@ -199,7 +199,7 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt) if ((pd->flags & AV_PIX_FMT_FLAG_HWACCEL)) { desc.flags |= MP_IMGFLAG_HWACCEL; } else if (fmt == AV_PIX_FMT_XYZ12LE || fmt == AV_PIX_FMT_XYZ12BE) { - desc.flags |= MP_IMGFLAG_XYZ; + /* nothing */ } else if (!(pd->flags & AV_PIX_FMT_FLAG_RGB) && fmt != AV_PIX_FMT_MONOBLACK && fmt != AV_PIX_FMT_PAL8) @@ -215,9 +215,6 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt) if (mpfmt >= IMGFMT_RGB0_START && mpfmt <= IMGFMT_RGB0_END) desc.flags &= ~MP_IMGFLAG_ALPHA; - if (desc.num_planes == pd->nb_components) - desc.flags |= MP_IMGFLAG_PLANAR; - if (!(pd->flags & AV_PIX_FMT_FLAG_HWACCEL) && !(pd->flags & AV_PIX_FMT_FLAG_BITSTREAM)) { @@ -254,8 +251,6 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt) { desc.flags |= MP_IMGFLAG_YUV_NV; - if (fmt == AV_PIX_FMT_NV21) - desc.flags |= MP_IMGFLAG_YUV_NV_SWAP; } if (desc.flags & (MP_IMGFLAG_YUV_P | MP_IMGFLAG_RGB_P | MP_IMGFLAG_YUV_NV)) desc.component_bits += shift; @@ -564,13 +559,10 @@ int main(int argc, char **argv) #define FLAG(t, c) if (d.flags & (t)) printf("[%s]", c); FLAG(MP_IMGFLAG_BYTE_ALIGNED, "BA") FLAG(MP_IMGFLAG_ALPHA, "a") - FLAG(MP_IMGFLAG_PLANAR, "P") FLAG(MP_IMGFLAG_YUV_P, "YUVP") FLAG(MP_IMGFLAG_YUV_NV, "NV") - FLAG(MP_IMGFLAG_YUV_NV_SWAP, "NVSWAP") FLAG(MP_IMGFLAG_YUV, "yuv") FLAG(MP_IMGFLAG_RGB, "rgb") - FLAG(MP_IMGFLAG_XYZ, "xyz") FLAG(MP_IMGFLAG_LE, "le") FLAG(MP_IMGFLAG_BE, "be") FLAG(MP_IMGFLAG_PAL, "pal") diff --git a/video/img_format.h b/video/img_format.h index 67de42f3f4..5d4cebd892 100644 --- a/video/img_format.h +++ b/video/img_format.h @@ -36,14 +36,10 @@ #define MP_IMGFLAG_BYTE_ALIGNED 0x1 // set if (possibly) alpha is included (might be not definitive for packed RGB) #define MP_IMGFLAG_ALPHA 0x80 -// Uses one component per plane (set even if it's just one plane) -#define MP_IMGFLAG_PLANAR 0x100 // set if it's YUV colorspace #define MP_IMGFLAG_YUV 0x200 // set if it's RGB colorspace #define MP_IMGFLAG_RGB 0x400 -// set if it's XYZ colorspace -#define MP_IMGFLAG_XYZ 0x800 // set if the format is in a standard YUV format: // - planar and yuv colorspace // - chroma shift 0-2 @@ -57,12 +53,7 @@ #define MP_IMGFLAG_BE 0x4000 // set if in native (host) endian, or endian independent #define MP_IMGFLAG_NE MP_SELECT_LE_BE(MP_IMGFLAG_LE, MP_IMGFLAG_BE) -// Carries a palette in plane[1] (see IMGFMT_PAL8 for format of the palette). -// Note that some non-paletted formats have this flag set, because FFmpeg -// mysteriously expects some formats to carry a palette plane for no apparent -// reason. FFmpeg developer braindeath? -// The only real paletted format we support is IMGFMT_PAL8, so check for that -// format directly if you want an actual paletted format. +// Carries a palette in plane[1] (see AV_PIX_FMT_PAL8 for format of the palette). #define MP_IMGFLAG_PAL 0x8000 // planes don't contain real data #define MP_IMGFLAG_HWACCEL 0x10000 @@ -70,13 +61,7 @@ // are always shuffled (G - B - R [- A]). #define MP_IMGFLAG_RGB_P 0x40000 // Semi-planar YUV formats, like AV_PIX_FMT_NV12. -// The flag MP_IMGFLAG_YUV_NV_SWAP is set for AV_PIX_FMT_NV21. #define MP_IMGFLAG_YUV_NV 0x80000 -#define MP_IMGFLAG_YUV_NV_SWAP 0x100000 - -// Exactly one of these bits is set in mp_imgfmt_desc.flags -#define MP_IMGFLAG_COLOR_CLASS_MASK \ - (MP_IMGFLAG_YUV | MP_IMGFLAG_RGB | MP_IMGFLAG_XYZ) struct mp_imgfmt_desc { int id; // IMGFMT_* -- cgit v1.2.3