mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
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.
This commit is contained in:
@@ -233,6 +233,11 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt)
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user