summaryrefslogtreecommitdiffstats
path: root/video/img_format.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-01 20:45:44 +0100
committerwm4 <wm4@nowhere>2013-12-01 20:45:44 +0100
commitf12ed5fd8f4d044ad245edf8b14c02f42638b73f (patch)
tree754e52b809297ac038a7029cf05e1923b0cbcc2a /video/img_format.c
parent317f2399a7aee5f1a0acd1db1d96595ceaa341a8 (diff)
downloadmpv-f12ed5fd8f4d044ad245edf8b14c02f42638b73f.tar.bz2
mpv-f12ed5fd8f4d044ad245edf8b14c02f42638b73f.tar.xz
mp_image: deal with FFmpeg PSEUDOPAL braindeath
We got a crash in libavutil when encoding with Y8 (GRAY8). The reason was that libavutil was copying an Y8 image allocated by us, and expected a palette. This is because GRAY8 is a PSEUDOPAL format. It's not clear what PSEUDOPAL means, and it makes literally no sense at all. However, it does expect a palette allocated for some formats that are not paletted, and libavutil crashed when trying to access the non-existent palette.
Diffstat (limited to 'video/img_format.c')
-rw-r--r--video/img_format.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/video/img_format.c b/video/img_format.c
index 0316261393..b317a08bd3 100644
--- a/video/img_format.c
+++ b/video/img_format.c
@@ -226,6 +226,11 @@ static struct mp_imgfmt_desc get_avutil_fmt(enum PixelFormat fmt)
desc.bytes[p] = desc.bpp[p] / 8;
}
+ // PSEUDOPAL is a complete braindeath nightmare, however it seems various
+ // parts of FFmpeg expect that it has a palette allocated.
+ if (pd->flags & (PIX_FMT_PAL | PIX_FMT_PSEUDOPAL))
+ desc.flags |= MP_IMGFLAG_PAL;
+
if ((desc.flags & MP_IMGFLAG_YUV) && (desc.flags & MP_IMGFLAG_BYTE_ALIGNED))
{
bool same_depth = true;