[FFmpeg-cvslog] avcodec/mjpegdec: Do not permute quantization tables
Michael Niedermayer
git at videolan.org
Sun Apr 3 01:55:52 CEST 2016
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Apr 3 01:28:07 2016 +0200| [de0bcea664c8ac59c524164c98b437d9935f7b52] | committer: Michael Niedermayer
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 at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de0bcea664c8ac59c524164c98b437d9935f7b52
---
libavcodec/mjpegdec.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index a6fb410..138e3a7 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;
More information about the ffmpeg-cvslog
mailing list