mirror of https://github.com/mpv-player/mpv
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;
|
? MP_IMGFLAG_BE : MP_IMGFLAG_LE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum mp_csp csp = mp_imgfmt_get_forced_csp(mpfmt);
|
||||||
|
|
||||||
if ((pd->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
|
if ((pd->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
|
||||||
desc.flags |= MP_IMGFLAG_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 */
|
/* nothing */
|
||||||
} else if (!(pd->flags & AV_PIX_FMT_FLAG_RGB) &&
|
} else if (csp == MP_CSP_RGB) {
|
||||||
fmt != AV_PIX_FMT_MONOBLACK &&
|
|
||||||
fmt != AV_PIX_FMT_PAL8)
|
|
||||||
{
|
|
||||||
desc.flags |= MP_IMGFLAG_YUV;
|
|
||||||
} else {
|
|
||||||
desc.flags |= MP_IMGFLAG_RGB;
|
desc.flags |= MP_IMGFLAG_RGB;
|
||||||
|
} else {
|
||||||
|
desc.flags |= MP_IMGFLAG_YUV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pd->flags & AV_PIX_FMT_FLAG_ALPHA)
|
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);
|
enum AVPixelFormat pixfmt = imgfmt2pixfmt(imgfmt);
|
||||||
const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(pixfmt);
|
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.
|
// FFmpeg does not provide a flag for XYZ, so this is the best we can do.
|
||||||
if (pixdesc && strncmp(pixdesc->name, "xyz", 3) == 0)
|
if (pixdesc && strncmp(pixdesc->name, "xyz", 3) == 0)
|
||||||
return MP_CSP_XYZ;
|
return MP_CSP_XYZ;
|
||||||
|
|
Loading…
Reference in New Issue