mp_image: copy palette only if allocated

Normally, we assume that IMGFMT_PAL8 always has a palette allocated
in plane 1. But there may be corner cases in ffmpeg where it doesn't
(namely pseudo-pal stuff).
This commit is contained in:
wm4 2013-06-28 20:30:37 +02:00
parent 9e80fe1c15
commit 823e0c511b
1 changed files with 2 additions and 1 deletions

View File

@ -327,7 +327,8 @@ void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src)
dst->levels = src->levels;
}
if (dst->imgfmt == IMGFMT_PAL8 && src->imgfmt == IMGFMT_PAL8) {
memcpy(dst->planes[1], src->planes[1], MP_PALETTE_SIZE);
if (dst->planes[1] && src->planes[1])
memcpy(dst->planes[1], src->planes[1], MP_PALETTE_SIZE);
}
}