Merge commit 'cdbaa436042ba59c3b2bd7e9652e9a14136fd604'
* commit 'cdbaa436042ba59c3b2bd7e9652e9a14136fd604': mpeg12dec: Always close reader on error Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
commit
2ec66ff83d
@ -124,9 +124,10 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
|
|||||||
return sign_extend(val, 5 + shift);
|
return sign_extend(val, 5 + shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAX_INDEX (64 - 1)
|
||||||
#define check_scantable_index(ctx, x) \
|
#define check_scantable_index(ctx, x) \
|
||||||
do { \
|
do { \
|
||||||
if ((x) > 63) { \
|
if ((x) > MAX_INDEX) { \
|
||||||
av_log(ctx->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", \
|
av_log(ctx->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", \
|
||||||
ctx->mb_x, ctx->mb_y); \
|
ctx->mb_x, ctx->mb_y); \
|
||||||
return AVERROR_INVALIDDATA; \
|
return AVERROR_INVALIDDATA; \
|
||||||
@ -167,7 +168,8 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
|
|||||||
|
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
check_scantable_index(s, i);
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||||
level = (level - 1) | 1;
|
level = (level - 1) | 1;
|
||||||
@ -189,7 +191,8 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
|
|||||||
SKIP_BITS(re, &s->gb, 8);
|
SKIP_BITS(re, &s->gb, 8);
|
||||||
}
|
}
|
||||||
i += run;
|
i += run;
|
||||||
check_scantable_index(s, i);
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = -level;
|
level = -level;
|
||||||
@ -212,6 +215,9 @@ end:
|
|||||||
LAST_SKIP_BITS(re, &s->gb, 2);
|
LAST_SKIP_BITS(re, &s->gb, 2);
|
||||||
CLOSE_READER(re, &s->gb);
|
CLOSE_READER(re, &s->gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_scantable_index(s, i);
|
||||||
|
|
||||||
s->block_last_index[n] = i;
|
s->block_last_index[n] = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -253,7 +259,8 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s,
|
|||||||
|
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
check_scantable_index(s, i);
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
||||||
level = (level - 1) | 1;
|
level = (level - 1) | 1;
|
||||||
@ -275,7 +282,8 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s,
|
|||||||
SKIP_BITS(re, &s->gb, 8);
|
SKIP_BITS(re, &s->gb, 8);
|
||||||
}
|
}
|
||||||
i += run;
|
i += run;
|
||||||
check_scantable_index(s, i);
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = -level;
|
level = -level;
|
||||||
@ -297,6 +305,9 @@ end:
|
|||||||
LAST_SKIP_BITS(re, &s->gb, 2);
|
LAST_SKIP_BITS(re, &s->gb, 2);
|
||||||
CLOSE_READER(re, &s->gb);
|
CLOSE_READER(re, &s->gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_scantable_index(s, i);
|
||||||
|
|
||||||
s->block_last_index[n] = i;
|
s->block_last_index[n] = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -338,7 +349,8 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s,
|
|||||||
|
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
check_scantable_index(s, i);
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = ((level * 2 + 1) * qscale) >> 1;
|
level = ((level * 2 + 1) * qscale) >> 1;
|
||||||
level = (level - 1) | 1;
|
level = (level - 1) | 1;
|
||||||
@ -360,7 +372,8 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s,
|
|||||||
SKIP_BITS(re, &s->gb, 8);
|
SKIP_BITS(re, &s->gb, 8);
|
||||||
}
|
}
|
||||||
i += run;
|
i += run;
|
||||||
check_scantable_index(s, i);
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = -level;
|
level = -level;
|
||||||
@ -382,6 +395,9 @@ end:
|
|||||||
LAST_SKIP_BITS(re, &s->gb, 2);
|
LAST_SKIP_BITS(re, &s->gb, 2);
|
||||||
CLOSE_READER(re, &s->gb);
|
CLOSE_READER(re, &s->gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_scantable_index(s, i);
|
||||||
|
|
||||||
s->block_last_index[n] = i;
|
s->block_last_index[n] = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -427,7 +443,8 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
|
|||||||
|
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
check_scantable_index(s, i);
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
||||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
|
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
|
||||||
@ -442,7 +459,8 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
|
|||||||
SKIP_BITS(re, &s->gb, 12);
|
SKIP_BITS(re, &s->gb, 12);
|
||||||
|
|
||||||
i += run;
|
i += run;
|
||||||
check_scantable_index(s, i);
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = ((-level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
level = ((-level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
||||||
@ -464,6 +482,8 @@ end:
|
|||||||
}
|
}
|
||||||
block[63] ^= (mismatch & 1);
|
block[63] ^= (mismatch & 1);
|
||||||
|
|
||||||
|
check_scantable_index(s, i);
|
||||||
|
|
||||||
s->block_last_index[n] = i;
|
s->block_last_index[n] = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -502,6 +522,8 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
|
|||||||
|
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = ((level * 2 + 1) * qscale) >> 1;
|
level = ((level * 2 + 1) * qscale) >> 1;
|
||||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
|
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
|
||||||
@ -516,6 +538,8 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
|
|||||||
SKIP_BITS(re, &s->gb, 12);
|
SKIP_BITS(re, &s->gb, 12);
|
||||||
|
|
||||||
i += run;
|
i += run;
|
||||||
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = ((-level * 2 + 1) * qscale) >> 1;
|
level = ((-level * 2 + 1) * qscale) >> 1;
|
||||||
@ -534,6 +558,9 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
|
|||||||
end:
|
end:
|
||||||
LAST_SKIP_BITS(re, &s->gb, 2);
|
LAST_SKIP_BITS(re, &s->gb, 2);
|
||||||
CLOSE_READER(re, &s->gb);
|
CLOSE_READER(re, &s->gb);
|
||||||
|
|
||||||
|
check_scantable_index(s, i);
|
||||||
|
|
||||||
s->block_last_index[n] = i;
|
s->block_last_index[n] = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -584,7 +611,8 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
|
|||||||
break;
|
break;
|
||||||
} else if (level != 0) {
|
} else if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
check_scantable_index(s, i);
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
|
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
|
||||||
@ -598,7 +626,8 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
|
|||||||
level = SHOW_SBITS(re, &s->gb, 12);
|
level = SHOW_SBITS(re, &s->gb, 12);
|
||||||
SKIP_BITS(re, &s->gb, 12);
|
SKIP_BITS(re, &s->gb, 12);
|
||||||
i += run;
|
i += run;
|
||||||
check_scantable_index(s, i);
|
if (i > MAX_INDEX)
|
||||||
|
break;
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = (-level * qscale * quant_matrix[j]) >> 4;
|
level = (-level * qscale * quant_matrix[j]) >> 4;
|
||||||
@ -615,6 +644,8 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
|
|||||||
}
|
}
|
||||||
block[63] ^= mismatch & 1;
|
block[63] ^= mismatch & 1;
|
||||||
|
|
||||||
|
check_scantable_index(s, i);
|
||||||
|
|
||||||
s->block_last_index[n] = i;
|
s->block_last_index[n] = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -694,6 +725,8 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s,
|
|||||||
CLOSE_READER(re, &s->gb);
|
CLOSE_READER(re, &s->gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_scantable_index(s, i);
|
||||||
|
|
||||||
s->block_last_index[n] = i;
|
s->block_last_index[n] = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user