Revision 60867312 libavcodec/vp3.c

View differences:

libavcodec/vp3.c
379 379

  
380 380
        /* unpack the list of partially-coded superblocks */
381 381
        bit = get_bits1(gb);
382
        while (current_superblock < s->superblock_count) {
382
        while (current_superblock < s->superblock_count && get_bits_left(gb) > 0) {
383 383
                current_run = get_vlc2(gb,
384 384
                    s->superblock_run_length_vlc.table, 6, 2) + 1;
385 385
                if (current_run == 34)
......
409 409

  
410 410
            current_superblock = 0;
411 411
            bit = get_bits1(gb);
412
            while (superblocks_decoded < s->superblock_count - num_partial_superblocks) {
412
            while (superblocks_decoded < s->superblock_count - num_partial_superblocks
413
                   && get_bits_left(gb) > 0) {
413 414
                        current_run = get_vlc2(gb,
414 415
                            s->superblock_run_length_vlc.table, 6, 2) + 1;
415 416
                        if (current_run == 34)
......
458 459
        int sb_end = sb_start + (plane ? s->c_superblock_count : s->y_superblock_count);
459 460
        int num_coded_frags = 0;
460 461

  
461
    for (i = sb_start; i < sb_end; i++) {
462
    for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
462 463

  
463 464
        /* iterate through all 16 fragments in a superblock */
464 465
        for (j = 0; j < 16; j++) {
......
542 543
         * coded fragments */
543 544
        for (sb_y = 0; sb_y < s->y_superblock_height; sb_y++) {
544 545
            for (sb_x = 0; sb_x < s->y_superblock_width; sb_x++) {
546
                if (get_bits_left(gb) <= 0)
547
                    return -1;
545 548

  
546 549
            for (j = 0; j < 4; j++) {
547 550
                int mb_x = 2*sb_x +   (j>>1);
......
636 639
     * coded fragments */
637 640
    for (sb_y = 0; sb_y < s->y_superblock_height; sb_y++) {
638 641
        for (sb_x = 0; sb_x < s->y_superblock_width; sb_x++) {
642
            if (get_bits_left(gb) <= 0)
643
                return -1;
639 644

  
640 645
        for (j = 0; j < 4; j++) {
641 646
            int mb_x = 2*sb_x +   (j>>1);
......
820 825
                bit = get_bits1(gb);
821 826
            else
822 827
                bit ^= 1;
823
        } while (blocks_decoded < num_blocks);
828
        } while (blocks_decoded < num_blocks && get_bits_left(gb) > 0);
824 829

  
825 830
        num_blocks -= num_blocks_at_qpi;
826 831
    }

Also available in: Unified diff