Mercurial > libavcodec.hg
comparison bink.c @ 11245:1e9ff636c3db libavcodec
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.
author | kostya |
---|---|
date | Mon, 22 Feb 2010 12:35:12 +0000 |
parents | eb773ca000d9 |
children | b48dd9213016 |
comparison
equal
deleted
inserted
replaced
11244:eb773ca000d9 | 11245:1e9ff636c3db |
---|---|
679 const uint8_t *scan; | 679 const uint8_t *scan; |
680 int xoff, yoff; | 680 int xoff, yoff; |
681 DECLARE_ALIGNED_16(DCTELEM, block[64]); | 681 DECLARE_ALIGNED_16(DCTELEM, block[64]); |
682 DECLARE_ALIGNED_16(uint8_t, ublock[64]); | 682 DECLARE_ALIGNED_16(uint8_t, ublock[64]); |
683 int coordmap[64]; | 683 int coordmap[64]; |
684 int bits_count = pkt->size << 3; | |
684 | 685 |
685 if(c->pic.data[0]) | 686 if(c->pic.data[0]) |
686 avctx->release_buffer(avctx, &c->pic); | 687 avctx->release_buffer(avctx, &c->pic); |
687 | 688 |
688 if(avctx->get_buffer(avctx, &c->pic) < 0){ | 689 if(avctx->get_buffer(avctx, &c->pic) < 0){ |
689 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | 690 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
690 return -1; | 691 return -1; |
691 } | 692 } |
692 | 693 |
693 init_get_bits(&gb, pkt->data, pkt->size*8); | 694 init_get_bits(&gb, pkt->data, bits_count); |
694 if (c->version >= 'i') | 695 if (c->version >= 'i') |
695 skip_bits_long(&gb, 32); | 696 skip_bits_long(&gb, 32); |
696 | 697 |
697 for (plane = 0; plane < 3; plane++) { | 698 for (plane = 0; plane < 3; plane++) { |
698 const int stride = c->pic.linesize[plane]; | 699 const int stride = c->pic.linesize[plane]; |
899 } | 900 } |
900 } | 901 } |
901 } | 902 } |
902 if (get_bits_count(&gb) & 0x1F) //next plane data starts at 32-bit boundary | 903 if (get_bits_count(&gb) & 0x1F) //next plane data starts at 32-bit boundary |
903 skip_bits_long(&gb, 32 - (get_bits_count(&gb) & 0x1F)); | 904 skip_bits_long(&gb, 32 - (get_bits_count(&gb) & 0x1F)); |
905 if (get_bits_count(&gb) >= bits_count) | |
906 break; | |
904 } | 907 } |
905 emms_c(); | 908 emms_c(); |
906 | 909 |
907 *data_size = sizeof(AVFrame); | 910 *data_size = sizeof(AVFrame); |
908 *(AVFrame*)data = c->pic; | 911 *(AVFrame*)data = c->pic; |