Revision 8ed2ddb2

View differences:

libavcodec/mpeg12.c
533 533
static VLC mb_btype_vlc;
534 534
static VLC mb_pat_vlc;
535 535

  
536
#define DC_VLC_BITS 9
537
#define MV_VLC_BITS 9
538
#define MBINCR_VLC_BITS 9
539
#define MB_PAT_VLC_BITS 9
540
#define MB_PTYPE_VLC_BITS 6
541
#define MB_BTYPE_VLC_BITS 6
542
#define TEX_VLC_BITS 9
543

  
536 544
void mpeg1_init_vlc(MpegEncContext *s)
537 545
{
538 546
    static int done = 0;
......
540 548
    if (!done) {
541 549
        done = 1;
542 550

  
543
        init_vlc(&dc_lum_vlc, 9, 12, 
551
        init_vlc(&dc_lum_vlc, DC_VLC_BITS, 10/*12*/, 
544 552
                 vlc_dc_lum_bits, 1, 1,
545 553
                 vlc_dc_lum_code, 2, 2);
546
        init_vlc(&dc_chroma_vlc, 9, 12, 
554
        init_vlc(&dc_chroma_vlc,  DC_VLC_BITS, 10/*12*/, 
547 555
                 vlc_dc_chroma_bits, 1, 1,
548 556
                 vlc_dc_chroma_code, 2, 2);
549
        init_vlc(&mv_vlc, 9, 17, 
557
        init_vlc(&mv_vlc, MV_VLC_BITS, 17, 
550 558
                 &mbMotionVectorTable[0][1], 2, 1,
551 559
                 &mbMotionVectorTable[0][0], 2, 1);
552
        init_vlc(&mbincr_vlc, 9, 35, 
560
        init_vlc(&mbincr_vlc, MBINCR_VLC_BITS, 35, 
553 561
                 &mbAddrIncrTable[0][1], 2, 1,
554 562
                 &mbAddrIncrTable[0][0], 2, 1);
555
        init_vlc(&mb_pat_vlc, 9, 63, 
563
        init_vlc(&mb_pat_vlc, MB_PAT_VLC_BITS, 63, 
556 564
                 &mbPatTable[0][1], 2, 1,
557 565
                 &mbPatTable[0][0], 2, 1);
558 566
        
559
        init_vlc(&mb_ptype_vlc, 6, 32, 
567
        init_vlc(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 32, 
560 568
                 &table_mb_ptype[0][1], 2, 1,
561 569
                 &table_mb_ptype[0][0], 2, 1);
562
        init_vlc(&mb_btype_vlc, 6, 32, 
570
        init_vlc(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 32, 
563 571
                 &table_mb_btype[0][1], 2, 1,
564 572
                 &table_mb_btype[0][0], 2, 1);
565 573
        init_rl(&rl_mpeg1);
566 574
        init_rl(&rl_mpeg2);
567 575
        /* cannot use generic init because we must add the EOB code */
568
        init_vlc(&rl_mpeg1.vlc, 9, rl_mpeg1.n + 2, 
576
        init_vlc(&rl_mpeg1.vlc, TEX_VLC_BITS, rl_mpeg1.n + 2, 
569 577
                 &rl_mpeg1.table_vlc[0][1], 4, 2,
570 578
                 &rl_mpeg1.table_vlc[0][0], 4, 2);
571
        init_vlc(&rl_mpeg2.vlc, 9, rl_mpeg2.n + 2, 
579
        init_vlc(&rl_mpeg2.vlc, TEX_VLC_BITS, rl_mpeg2.n + 2, 
572 580
                 &rl_mpeg2.table_vlc[0][1], 4, 2,
573 581
                 &rl_mpeg2.table_vlc[0][0], 4, 2);
574 582
    }
......
614 622
        /* read again increment */
615 623
        s->mb_incr = 1;
616 624
        for(;;) {
617
            code = get_vlc(&s->gb, &mbincr_vlc);
625
            code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
618 626
            if (code < 0)
619 627
                return 1; /* error = end of slice */
620 628
            if (code >= 33) {
......
671 679
        }
672 680
        break;
673 681
    case P_TYPE:
674
        mb_type = get_vlc(&s->gb, &mb_ptype_vlc);
682
        mb_type = get_vlc2(&s->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
675 683
        if (mb_type < 0)
676 684
            return -1;
677 685
        break;
678 686
    case B_TYPE:
679
        mb_type = get_vlc(&s->gb, &mb_btype_vlc);
687
        mb_type = get_vlc2(&s->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
680 688
        if (mb_type < 0)
681 689
            return -1;
682 690
        break;
......
846 854
    }
847 855
    
848 856
    if (mb_type & MB_PAT) {
849
        cbp = get_vlc(&s->gb, &mb_pat_vlc);
857
        cbp = get_vlc2(&s->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
850 858
        if (cbp < 0)
851 859
            return -1;
852 860
        cbp++;
......
891 899
{
892 900
    int code, sign, val, m, l, shift;
893 901

  
894
    code = get_vlc(&s->gb, &mv_vlc);
902
    code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
895 903
    if (code < 0) {
896 904
        return 0xffff;
897 905
    }
......
924 932
    int code, diff;
925 933

  
926 934
    if (component == 0) {
927
        code = get_vlc(&s->gb, &dc_lum_vlc);
935
        code = get_vlc2(&s->gb, dc_lum_vlc.table, DC_VLC_BITS, 1);
928 936
    } else {
929
        code = get_vlc(&s->gb, &dc_chroma_vlc);
937
        code = get_vlc2(&s->gb, dc_chroma_vlc.table, DC_VLC_BITS, 1);
930 938
    }
931 939
    if (code < 0)
932 940
        return 0xffff;
......
979 987

  
980 988
    /* now quantify & encode AC coefs */
981 989
    for(;;) {
982
        code = get_vlc(&s->gb, &rl->vlc);
990
        code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2);
983 991
        if (code < 0) {
984 992
            return -1;
985 993
        }
......
1057 1065

  
1058 1066
    /* now quantify & encode AC coefs */
1059 1067
    for(;;) {
1060
        code = get_vlc(&s->gb, &rl->vlc);
1068
        code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2);
1061 1069
        if (code < 0)
1062 1070
            return -1;
1063 1071
        if (code == 112) {
......
1136 1144

  
1137 1145
    /* now quantify & encode AC coefs */
1138 1146
    for(;;) {
1139
        code = get_vlc(&s->gb, &rl->vlc);
1147
        code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2);
1140 1148
        if (code < 0)
1141 1149
            return -1;
1142 1150
        if (code == 112) {

Also available in: Unified diff