aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mjpegdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-04-03 01:28:07 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-04-03 01:50:08 +0200
commitde0bcea664c8ac59c524164c98b437d9935f7b52 (patch)
tree7544095b04207f17838661d66c68721be67cd5be /libavcodec/mjpegdec.c
parentc1f9734f977f59bc0034096afbe8e43e40d93a5d (diff)
downloadffmpeg-de0bcea664c8ac59c524164c98b437d9935f7b52.tar.gz
avcodec/mjpegdec: Do not permute quantization tables
This fixes issues if the permutation changes, as quantizations tables would need to be reread Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/mjpegdec.c')
-rw-r--r--libavcodec/mjpegdec.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index a6fb41043f..138e3a7730 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -166,7 +166,7 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
/* quantize tables */
int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
{
- int len, index, i, j;
+ int len, index, i;
len = get_bits(&s->gb, 16) - 2;
@@ -187,13 +187,12 @@ int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
av_log(s->avctx, AV_LOG_DEBUG, "index=%d\n", index);
/* read quant table */
for (i = 0; i < 64; i++) {
- j = s->scantable.permutated[i];
- s->quant_matrixes[index][j] = get_bits(&s->gb, pr ? 16 : 8);
+ s->quant_matrixes[index][i] = get_bits(&s->gb, pr ? 16 : 8);
}
// XXX FIXME finetune, and perhaps add dc too
- s->qscale[index] = FFMAX(s->quant_matrixes[index][s->scantable.permutated[1]],
- s->quant_matrixes[index][s->scantable.permutated[8]]) >> 1;
+ s->qscale[index] = FFMAX(s->quant_matrixes[index][1],
+ s->quant_matrixes[index][8]) >> 1;
av_log(s->avctx, AV_LOG_DEBUG, "qscale[%d]: %d\n",
index, s->qscale[index]);
len -= 1 + 64 * (1+pr);
@@ -723,7 +722,7 @@ static int decode_block(MJpegDecodeContext *s, int16_t *block, int component,
return AVERROR_INVALIDDATA;
}
j = s->scantable.permutated[i];
- block[j] = level * quant_matrix[j];
+ block[j] = level * quant_matrix[i];
}
} while (i < 63);
CLOSE_READER(re, &s->gb);}
@@ -785,14 +784,14 @@ static int decode_block_progressive(MJpegDecodeContext *s, int16_t *block,
if (i >= se) {
if (i == se) {
j = s->scantable.permutated[se];
- block[j] = level * (quant_matrix[j] << Al);
+ block[j] = level * (quant_matrix[se] << Al);
break;
}
av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
return AVERROR_INVALIDDATA;
}
j = s->scantable.permutated[i];
- block[j] = level * (quant_matrix[j] << Al);
+ block[j] = level * (quant_matrix[i] << Al);
} else {
if (run == 0xF) {// ZRL - skip 15 coefficients
i += 15;
@@ -825,7 +824,7 @@ static int decode_block_progressive(MJpegDecodeContext *s, int16_t *block,
UPDATE_CACHE(re, &s->gb); \
sign = block[j] >> 15; \
block[j] += SHOW_UBITS(re, &s->gb, 1) * \
- ((quant_matrix[j] ^ sign) - sign) << Al; \
+ ((quant_matrix[i] ^ sign) - sign) << Al; \
LAST_SKIP_BITS(re, &s->gb, 1); \
}
@@ -871,7 +870,7 @@ static int decode_block_refinement(MJpegDecodeContext *s, int16_t *block,
ZERO_RUN;
j = s->scantable.permutated[i];
val--;
- block[j] = ((quant_matrix[j] << Al) ^ val) - val;
+ block[j] = ((quant_matrix[i] << Al) ^ val) - val;
if (i == se) {
if (i > *last_nnz)
*last_nnz = i;