summaryrefslogtreecommitdiff
path: root/libavcodec/mjpegdec.h
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2021-04-21 13:33:33 -0300
committerJames Almer <jamrial@gmail.com>2021-04-25 10:57:29 -0300
commitc8197f73e684b0edc450f3dc2b2b4b3fb9dedd0d (patch)
tree0dd3921c76bcbe30e1862591e0cdcdde11326cf5 /libavcodec/mjpegdec.h
parentbc2726969400e1e57d25d1042f860eb2cbdf7465 (diff)
downloadffmpeg-c8197f73e684b0edc450f3dc2b2b4b3fb9dedd0d.tar.gz
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>
Diffstat (limited to 'libavcodec/mjpegdec.h')
-rw-r--r--libavcodec/mjpegdec.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h
index 2400a179f1..71cacb0b27 100644
--- a/libavcodec/mjpegdec.h
+++ b/libavcodec/mjpegdec.h
@@ -109,6 +109,7 @@ typedef struct MJpegDecodeContext {
int last_dc[MAX_COMPONENTS]; /* last DEQUANTIZED dc (XXX: am I right to do that ?) */
AVFrame *picture; /* picture structure */
AVFrame *picture_ptr; /* pointer to picture structure */
+ int seen_sof; ///< we found a SOF.
int got_picture; ///< we found a SOF and picture is valid, too.
int linesize[MAX_COMPONENTS]; ///< linesize << interlaced
int8_t *qscale_table;
@@ -165,7 +166,9 @@ typedef struct MJpegDecodeContext {
enum AVPixelFormat hwaccel_sw_pix_fmt;
enum AVPixelFormat hwaccel_pix_fmt;
void *hwaccel_picture_private;
+
struct JLSState *jls_state;
+ uint32_t palette[AVPALETTE_COUNT];
} MJpegDecodeContext;
int ff_mjpeg_build_vlc(VLC *vlc, const uint8_t *bits_table,