diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-04-03 05:26:27 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-04-03 05:26:27 +0400 |
commit | fd2bcfc4d6967588168443849b9bc365c78bb9af (patch) | |
tree | f783b089fc88354bc688e7f3005ac4e8d114bc4d | |
parent | a0258153730ab9a812da2291c491661000af8828 (diff) |
avcodec/jpeglsdec: fix palette parsing code
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/jpeglsdec.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index 003656ff9d..9958903e32 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -80,7 +80,9 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s) return AVERROR_PATCHWELCOME; } - if ((5 + wt*(s->maxval+1)) < 65535) + if (!s->maxval) + maxtab = 255; + else if ((5 + wt*(s->maxval+1)) < 65535) maxtab = s->maxval; else maxtab = 65530/wt - 1; @@ -102,10 +104,10 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s) uint32_t *pal = s->picture_ptr->data[1]; s->picture_ptr->format = s->avctx->pix_fmt = AV_PIX_FMT_PAL8; - for (i=s->palette_index; i<maxtab; i++) { + for (i=s->palette_index; i<=maxtab; i++) { pal[i] = 0; for (j=0; j<wt; j++) { - pal[i] |= get_bits(&s->gb, 8) << (8*wt); + pal[i] |= get_bits(&s->gb, 8) << (8*(wt-j-1)); } } s->palette_index = i; |