diff --git a/libavcodec/jpegtables.c b/libavcodec/jpegtables.c index fa5c6f9fc5..e44bc7a22a 100644 --- a/libavcodec/jpegtables.c +++ b/libavcodec/jpegtables.c @@ -130,25 +130,14 @@ void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, { int i, j, k,nb, code, sym; - /* Some badly encoded files [1] map 2 different codes to symbol 0. - Only the first one is valid, so we zero-initialize this here and - make sure we only set it once (the first time) in the loop below. - - [1]: Embedded JPEGs in "X7 RAW" and "X7 CinemaDNG" samples here: - https://www.dji.com/gr/zenmuse-x7/info#downloads - */ - huff_size[0] = 0; - k = 0; code = 0; for(i=1;i<=16;i++) { nb = bits_table[i]; for(j=0;j 256) return AVERROR_INVALIDDATA; - code_max = 0; for (i = 0; i < n; i++) { v = get_bits(&s->gb, 8); - if (v > code_max) - code_max = v; val_table[i] = v; } len -= n; @@ -282,15 +295,15 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s) /* build VLC and flush previous vlc if present */ ff_free_vlc(&s->vlcs[class][index]); av_log(s->avctx, AV_LOG_DEBUG, "class=%d index=%d nb_codes=%d\n", - class, index, code_max + 1); + class, index, n + 1); if ((ret = build_vlc(&s->vlcs[class][index], bits_table, val_table, - code_max + 1, 0, class > 0)) < 0) + n + 1, 0, class > 0)) < 0) return ret; if (class > 0) { ff_free_vlc(&s->vlcs[2][index]); if ((ret = build_vlc(&s->vlcs[2][index], bits_table, val_table, - code_max + 1, 0, 0)) < 0) + n + 1, 0, 0)) < 0) return ret; }