Revision 4f68b084 libavcodec/mpeg12.c

View differences:

libavcodec/mpeg12.c
33 33
#define EXT_START_CODE		0x000001b5
34 34
#define USER_START_CODE		0x000001b2
35 35

  
36
#define DC_VLC_BITS 9
37
#define MV_VLC_BITS 9
38
#define MBINCR_VLC_BITS 9
39
#define MB_PAT_VLC_BITS 9
40
#define MB_PTYPE_VLC_BITS 6
41
#define MB_BTYPE_VLC_BITS 6
42
#define TEX_VLC_BITS 9
43

  
36 44
static void mpeg1_encode_block(MpegEncContext *s, 
37 45
                         DCTELEM *block, 
38 46
                         int component);
......
52 60
static UINT16 mv_penalty[MAX_FCODE+1][MAX_MV*2+1];
53 61
static UINT8 fcode_tab[MAX_MV*2+1];
54 62

  
63
static void init_2d_vlc_rl(RLTable *rl)
64
{
65
    int i, q;
66
    
67
    init_vlc(&rl->vlc, TEX_VLC_BITS, rl->n + 2, 
68
             &rl->table_vlc[0][1], 4, 2,
69
             &rl->table_vlc[0][0], 4, 2);
70

  
71
    
72
    rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
73
    for(i=0; i<rl->vlc.table_size; i++){
74
        int code= rl->vlc.table[i][0];
75
        int len = rl->vlc.table[i][1];
76
        int level, run;
77
    
78
        if(len==0){ // illegal code
79
            run= 65;
80
            level= MAX_LEVEL;
81
        }else if(len<0){ //more bits needed
82
            run= 0;
83
            level= code;
84
        }else{
85
            if(code==rl->n){ //esc
86
                run= 65;
87
                level= 0;
88
            }else if(code==rl->n+1){ //eob
89
                run= 192;
90
                level= 1;
91
            }else{
92
                run=   rl->table_run  [code] + 1;
93
                level= rl->table_level[code];
94
            }
95
        }
96
        rl->rl_vlc[0][i].len= len;
97
        rl->rl_vlc[0][i].level= level;
98
        rl->rl_vlc[0][i].run= run;
99
    }
100
}
101

  
102

  
55 103
static void put_header(MpegEncContext *s, int header)
56 104
{
57 105
    align_put_bits(&s->pb);
......
533 581
static VLC mb_btype_vlc;
534 582
static VLC mb_pat_vlc;
535 583

  
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

  
544 584
void mpeg1_init_vlc(MpegEncContext *s)
545 585
{
546 586
    static int done = 0;
......
572 612
                 &table_mb_btype[0][0], 2, 1);
573 613
        init_rl(&rl_mpeg1);
574 614
        init_rl(&rl_mpeg2);
575
        /* cannot use generic init because we must add the EOB code */
576
        init_vlc(&rl_mpeg1.vlc, TEX_VLC_BITS, rl_mpeg1.n + 2, 
577
                 &rl_mpeg1.table_vlc[0][1], 4, 2,
578
                 &rl_mpeg1.table_vlc[0][0], 4, 2);
579
        init_vlc(&rl_mpeg2.vlc, TEX_VLC_BITS, rl_mpeg2.n + 2, 
580
                 &rl_mpeg2.table_vlc[0][1], 4, 2,
581
                 &rl_mpeg2.table_vlc[0][0], 4, 2);
615

  
616
        init_2d_vlc_rl(&rl_mpeg1);
617
        init_2d_vlc_rl(&rl_mpeg2);
582 618
    }
583 619
}
584 620

  
......
1416 1452
    /* start frame decoding */
1417 1453
    if (s->first_slice) {
1418 1454
        s->first_slice = 0;
1419
        MPV_frame_start(s);
1455
        MPV_frame_start(s, avctx);
1420 1456
    }
1421 1457

  
1422 1458
    init_get_bits(&s->gb, buf, buf_size);

Also available in: Unified diff