mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 12:02:23 +02:00
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.
This commit is contained in:
parent
8767c46873
commit
fe2178160d
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user