]> git.sesse.net Git - ffmpeg/commit
avcodec/mjpegdec: postpone calling ff_get_buffer() until the SOS marker
authorJames Almer <jamrial@gmail.com>
Wed, 21 Apr 2021 16:33:33 +0000 (13:33 -0300)
committerJames Almer <jamrial@gmail.com>
Sun, 25 Apr 2021 13:57:29 +0000 (10:57 -0300)
commitc8197f73e684b0edc450f3dc2b2b4b3fb9dedd0d
tree0dd3921c76bcbe30e1862591e0cdcdde11326cf5
parentbc2726969400e1e57d25d1042f860eb2cbdf7465
avcodec/mjpegdec: postpone calling ff_get_buffer() until the SOS marker

With JPEG-LS PAL8 samples, the JPEG-LS extension parameters signaled with
the LSE marker show up after SOF but before SOS. For those, the pixel format
chosen by get_format() in SOF is GRAY8, and then replaced by PAL8 in LSE.
This has not been an issue given both pixel formats allocate the second data
plane for the palette, but after the upcoming soname bump, GRAY8 will no longer
do that. This will result in segfauls when ff_jpegls_decode_lse() attempts to
write the palette on a buffer originally allocated as a GRAY8 one.

Work around this by calling ff_get_buffer() after the actual pixel format is
known.

Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/jpeglsdec.c
libavcodec/mjpegbdec.c
libavcodec/mjpegdec.c
libavcodec/mjpegdec.h
libavcodec/mxpegdec.c