Commit cfb8a20f authored by kostya's avatar kostya

Make Bink decoder to stop decoding planes after all bits are used.

This prevents crashes during decoding grayscale Bink files like
samples from Impossible Creatures game demo.



git-svn-id: file:///var/local/repositories/ffmpeg/trunk@21961 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent e6e5f781
...@@ -681,6 +681,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ...@@ -681,6 +681,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
DECLARE_ALIGNED_16(DCTELEM, block[64]); DECLARE_ALIGNED_16(DCTELEM, block[64]);
DECLARE_ALIGNED_16(uint8_t, ublock[64]); DECLARE_ALIGNED_16(uint8_t, ublock[64]);
int coordmap[64]; int coordmap[64];
int bits_count = pkt->size << 3;
if(c->pic.data[0]) if(c->pic.data[0])
avctx->release_buffer(avctx, &c->pic); avctx->release_buffer(avctx, &c->pic);
...@@ -690,7 +691,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ...@@ -690,7 +691,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
return -1; return -1;
} }
init_get_bits(&gb, pkt->data, pkt->size*8); init_get_bits(&gb, pkt->data, bits_count);
if (c->version >= 'i') if (c->version >= 'i')
skip_bits_long(&gb, 32); skip_bits_long(&gb, 32);
...@@ -901,6 +902,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ...@@ -901,6 +902,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
} }
if (get_bits_count(&gb) & 0x1F) //next plane data starts at 32-bit boundary if (get_bits_count(&gb) & 0x1F) //next plane data starts at 32-bit boundary
skip_bits_long(&gb, 32 - (get_bits_count(&gb) & 0x1F)); skip_bits_long(&gb, 32 - (get_bits_count(&gb) & 0x1F));
if (get_bits_count(&gb) >= bits_count)
break;
} }
emms_c(); emms_c();
......
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