summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-10-09 15:15:53 +0200
committerwm4 <wm4@nowhere>2017-10-09 15:15:53 +0200
commit622610bad50c48da106b58d458b3598aaf4a493b (patch)
treea91b67d306ebcccf08f29cd7078a44a8dbbe0f99
parent4c7c8daf9ccea7ac6a9089be362d254771c50811 (diff)
downloadmpv-622610bad50c48da106b58d458b3598aaf4a493b.tar.bz2
mpv-622610bad50c48da106b58d458b3598aaf4a493b.tar.xz
img_format: AV_PIX_FMT_PAL8 is RGB
This partiular format is not marked as AV_PIX_FMT_FLAG_RGB in FFmpeg's pixdesc table, so mpv assumed it's a YUV format. This is a regression, since the old code in mp_imgfmt_get_desc() also treated this format specially to avoid this problem. Another format which was special-cased in the old code was AV_PIX_FMT_MONOBLACK, so make an exception for it as well. Maybe this problem could be avoided by mp_image_params_guess_csp() not forcing certain colorimetric parameters by the implied colorspace, but certainly that would cause other problems. At least there are mistagged files out there that would break. (Do we actually care?) Fixes #4965.
-rw-r--r--video/img_format.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/video/img_format.c b/video/img_format.c
index 39bb751ddb..52319104df 100644
--- a/video/img_format.c
+++ b/video/img_format.c
@@ -321,8 +321,8 @@ static bool validate_regular_imgfmt(const struct mp_regular_imgfmt *fmt)
enum mp_csp mp_imgfmt_get_forced_csp(int imgfmt)
{
- const AVPixFmtDescriptor *pixdesc =
- av_pix_fmt_desc_get(imgfmt2pixfmt(imgfmt));
+ enum AVPixelFormat pixfmt = imgfmt2pixfmt(imgfmt);
+ const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(pixfmt);
// FFmpeg does not provide a flag for XYZ, so this is the best we can do.
if (pixdesc && strncmp(pixdesc->name, "xyz", 3) == 0)
@@ -331,6 +331,9 @@ enum mp_csp mp_imgfmt_get_forced_csp(int imgfmt)
if (pixdesc && (pixdesc->flags & AV_PIX_FMT_FLAG_RGB))
return MP_CSP_RGB;
+ if (pixfmt == AV_PIX_FMT_PAL8 || pixfmt == AV_PIX_FMT_MONOBLACK)
+ return MP_CSP_RGB;
+
return MP_CSP_AUTO;
}