Revision 9ac7ecd6

View differences:

libavcodec/mpeg12.c
588 588
    if (!done) {
589 589
        done = 1;
590 590

  
591
        init_vlc(&dc_lum_vlc, DC_VLC_BITS, 10/*12*/, 
591
        init_vlc(&dc_lum_vlc, DC_VLC_BITS, 12, 
592 592
                 vlc_dc_lum_bits, 1, 1,
593 593
                 vlc_dc_lum_code, 2, 2);
594
        init_vlc(&dc_chroma_vlc,  DC_VLC_BITS, 10/*12*/, 
594
        init_vlc(&dc_chroma_vlc,  DC_VLC_BITS, 12, 
595 595
                 vlc_dc_chroma_bits, 1, 1,
596 596
                 vlc_dc_chroma_code, 2, 2);
597 597
        init_vlc(&mv_vlc, MV_VLC_BITS, 17, 
......
674 674
    }
675 675
    if (++s->mb_x >= s->mb_width) {
676 676
        s->mb_x = 0;
677
        if (s->mb_y >= (s->mb_height - 1))
677
        if (s->mb_y >= (s->mb_height - 1)){
678
            fprintf(stderr, "slice too long\n");
678 679
            return -1;
680
        }
679 681
        s->mb_y++;
680 682
    }
681 683
    dprintf("decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
......
716 718
        break;
717 719
    case P_TYPE:
718 720
        mb_type = get_vlc2(&s->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
719
        if (mb_type < 0)
721
        if (mb_type < 0){
722
            fprintf(stderr, "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
720 723
            return -1;
724
        }
721 725
        break;
722 726
    case B_TYPE:
723 727
        mb_type = get_vlc2(&s->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
724
        if (mb_type < 0)
728
        if (mb_type < 0){
729
            fprintf(stderr, "invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
725 730
            return -1;
731
        }
726 732
        break;
727 733
    }
728 734
    dprintf("mb_type=%x\n", mb_type);
......
891 897
    
892 898
    if (mb_type & MB_PAT) {
893 899
        cbp = get_vlc2(&s->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
894
        if (cbp < 0)
900
        if (cbp < 0){
901
            fprintf(stderr, "invalid cbp at %d %d\n", s->mb_x, s->mb_y);
895 902
            return -1;
903
        }
896 904
        cbp++;
897 905
    }
898 906
    dprintf("cbp=%x\n", cbp);
......
968 976
    int code, diff;
969 977

  
970 978
    if (component == 0) {
971
        code = get_vlc2(&s->gb, dc_lum_vlc.table, DC_VLC_BITS, 1);
979
        code = get_vlc2(&s->gb, dc_lum_vlc.table, DC_VLC_BITS, 2);
972 980
    } else {
973
        code = get_vlc2(&s->gb, dc_chroma_vlc.table, DC_VLC_BITS, 1);
981
        code = get_vlc2(&s->gb, dc_chroma_vlc.table, DC_VLC_BITS, 2);
974 982
    }
975
    if (code < 0)
983
    if (code < 0){
984
        fprintf(stderr, "invalid dc code at %d %d\n", s->mb_x, s->mb_y);
976 985
        return 0xffff;
986
    }
977 987
    if (code == 0) {
978 988
        diff = 0;
979 989
    } else {
......
1102 1112
    /* now quantify & encode AC coefs */
1103 1113
    for(;;) {
1104 1114
        code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2);
1105
        if (code < 0)
1115
        if (code < 0){
1116
            fprintf(stderr, "invalid ac code at %d %d\n", s->mb_x, s->mb_y);
1106 1117
            return -1;
1118
        }
1107 1119
        if (code == 112) {
1108 1120
            break;
1109 1121
        } else if (code == 111) {
......
1118 1130
                level = -level;
1119 1131
        }
1120 1132
        i += run;
1121
        if (i >= 64)
1133
        if (i >= 64){
1134
            fprintf(stderr, "run too long at %d %d\n", s->mb_x, s->mb_y);
1122 1135
            return -1;
1136
        }
1123 1137
    add_coef:
1124 1138
	j = scan_table[i];
1125 1139
        dprintf("%d: run=%d level=%d\n", n, run, level);
......
1181 1195
    /* now quantify & encode AC coefs */
1182 1196
    for(;;) {
1183 1197
        code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2);
1184
        if (code < 0)
1198
        if (code < 0){
1199
            fprintf(stderr, "invalid ac code at %d %d\n", s->mb_x, s->mb_y);
1185 1200
            return -1;
1201
        }
1186 1202
        if (code == 112) {
1187 1203
            break;
1188 1204
        } else if (code == 111) {
......
1197 1213
                level = -level;
1198 1214
        }
1199 1215
        i += run;
1200
        if (i >= 64)
1216
        if (i >= 64){
1217
            fprintf(stderr, "run too long at %d %d\n", s->mb_x, s->mb_y);
1201 1218
            return -1;
1219
        }
1202 1220
	j = scan_table[i];
1203 1221
        dprintf("%d: run=%d level=%d\n", n, run, level);
1204 1222
        level = (level * s->qscale * matrix[j]) / 16;
......
1440 1458
    int ret;
1441 1459

  
1442 1460
    start_code = (start_code - 1) & 0xff;
1443
    if (start_code >= s->mb_height)
1461
    if (start_code >= s->mb_height){
1462
        fprintf(stderr, "slice below image\n");
1444 1463
        return -1;
1464
    }
1445 1465
    s->last_dc[0] = 1 << (7 + s->intra_dc_precision);
1446 1466
    s->last_dc[1] = s->last_dc[0];
1447 1467
    s->last_dc[2] = s->last_dc[0];
......
1735 1755
                            }         
1736 1756
                            *data_size = sizeof(AVPicture);
1737 1757
                            goto the_end;
1758
                        }else if(ret==-1){
1759
                            printf("Error while decoding slice\n");
1738 1760
                        }
1739 1761
                    }
1740 1762
                    break;

Also available in: Unified diff