Commit b5852e8a authored by Maxim Poliakovski's avatar Maxim Poliakovski Committed by Kostya Shishkov

Make Indeo 5 decoder more robust on bitstream errors.

Patch by Maxim ($indeo5dec_author)

Originally committed as revision 22319 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 5f1654b2
...@@ -549,7 +549,7 @@ static int decode_mb_info(IVI5DecContext *ctx, IVIBandDesc *band, ...@@ -549,7 +549,7 @@ static int decode_mb_info(IVI5DecContext *ctx, IVIBandDesc *band,
static int decode_band(IVI5DecContext *ctx, int plane_num, static int decode_band(IVI5DecContext *ctx, int plane_num,
IVIBandDesc *band, AVCodecContext *avctx) IVIBandDesc *band, AVCodecContext *avctx)
{ {
int result, i, t, idx1, idx2; int result, i, t, idx1, idx2, pos;
IVITile *tile; IVITile *tile;
band->buf = band->bufs[ctx->dst_buf]; band->buf = band->bufs[ctx->dst_buf];
...@@ -590,6 +590,8 @@ static int decode_band(IVI5DecContext *ctx, int plane_num, ...@@ -590,6 +590,8 @@ static int decode_band(IVI5DecContext *ctx, int plane_num,
FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]); FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
} }
pos = get_bits_count(&ctx->gb);
for (t = 0; t < band->num_tiles; t++) { for (t = 0; t < band->num_tiles; t++) {
tile = &band->tiles[t]; tile = &band->tiles[t];
...@@ -597,7 +599,6 @@ static int decode_band(IVI5DecContext *ctx, int plane_num, ...@@ -597,7 +599,6 @@ static int decode_band(IVI5DecContext *ctx, int plane_num,
if (tile->is_empty) { if (tile->is_empty) {
ff_ivi_process_empty_tile(avctx, band, tile, ff_ivi_process_empty_tile(avctx, band, tile,
(ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3)); (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));
align_get_bits(&ctx->gb);
} else { } else {
tile->data_size = ff_ivi_dec_tile_data_size(&ctx->gb); tile->data_size = ff_ivi_dec_tile_data_size(&ctx->gb);
...@@ -606,10 +607,11 @@ static int decode_band(IVI5DecContext *ctx, int plane_num, ...@@ -606,10 +607,11 @@ static int decode_band(IVI5DecContext *ctx, int plane_num,
break; break;
result = ff_ivi_decode_blocks(&ctx->gb, band, tile); result = ff_ivi_decode_blocks(&ctx->gb, band, tile);
if (result < 0) { if (result < 0 || (get_bits_count(&ctx->gb) - pos) >> 3 != tile->data_size) {
av_log(avctx, AV_LOG_ERROR, "Corrupted blocks data encountered!\n"); av_log(avctx, AV_LOG_ERROR, "Corrupted tile data encountered!\n");
break; break;
} }
pos += tile->data_size << 3; // skip to next tile
} }
} }
...@@ -632,6 +634,8 @@ static int decode_band(IVI5DecContext *ctx, int plane_num, ...@@ -632,6 +634,8 @@ static int decode_band(IVI5DecContext *ctx, int plane_num,
} }
#endif #endif
align_get_bits(&ctx->gb);
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment