summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-04-23 12:55:54 +0200
committerwm4 <wm4@nowhere>2020-04-23 13:24:35 +0200
commitfe2178160d6374136e6ca2f02f12d7f42f9cb531 (patch)
treefb7770c70dfc9bac2d4f6ba1f7fa0bd51ec5f7af
parent8767c468735f64cdbd4bbbbe83121c2b068255e7 (diff)
downloadmpv-fe2178160d6374136e6ca2f02f12d7f42f9cb531.tar.bz2
mpv-fe2178160d6374136e6ca2f02f12d7f42f9cb531.tar.xz
img_format: remove duplication in FFmpeg yuv vs. rgb pixfmt check
mp_imgfmt_get_forced_csp() should be consistent with the MP_CSP_RGB/YUV flags. At least the different handling of the XYZ exception was a mess, even if the result was the same.
-rw-r--r--video/img_format.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/video/img_format.c b/video/img_format.c
index 6379dd41d1..b1247747ea 100644
--- a/video/img_format.c
+++ b/video/img_format.c
@@ -279,17 +279,16 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt)
? MP_IMGFLAG_BE : MP_IMGFLAG_LE;
}
+ enum mp_csp csp = mp_imgfmt_get_forced_csp(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) {
+ } else if (csp == MP_CSP_XYZ) {
/* nothing */
- } else if (!(pd->flags & AV_PIX_FMT_FLAG_RGB) &&
- fmt != AV_PIX_FMT_MONOBLACK &&
- fmt != AV_PIX_FMT_PAL8)
- {
- desc.flags |= MP_IMGFLAG_YUV;
- } else {
+ } else if (csp == MP_CSP_RGB) {
desc.flags |= MP_IMGFLAG_RGB;
+ } else {
+ desc.flags |= MP_IMGFLAG_YUV;
}
if (pd->flags & AV_PIX_FMT_FLAG_ALPHA)
@@ -407,6 +406,9 @@ enum mp_csp mp_imgfmt_get_forced_csp(int imgfmt)
enum AVPixelFormat pixfmt = imgfmt2pixfmt(imgfmt);
const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(pixfmt);
+ if (pixdesc && (pixdesc->flags & AV_PIX_FMT_FLAG_HWACCEL))
+ return MP_CSP_AUTO;
+
// FFmpeg does not provide a flag for XYZ, so this is the best we can do.
if (pixdesc && strncmp(pixdesc->name, "xyz", 3) == 0)
return MP_CSP_XYZ;