comparison h263.c @ 5274:c6bc608d2659 libavcodec

move init_vlc_rl from h263.c to mpegvideo.c
author aurel
date Tue, 10 Jul 2007 17:17:42 +0000
parents 101f20612a94
children 91416b4f1929
comparison
equal deleted inserted replaced
5273:101f20612a94 5274:c6bc608d2659
2887 static VLC sprite_trajectory; 2887 static VLC sprite_trajectory;
2888 static VLC mb_type_b_vlc; 2888 static VLC mb_type_b_vlc;
2889 static VLC h263_mbtype_b_vlc; 2889 static VLC h263_mbtype_b_vlc;
2890 static VLC cbpc_b_vlc; 2890 static VLC cbpc_b_vlc;
2891 2891
2892 void init_vlc_rl(RLTable *rl, int use_static)
2893 {
2894 int i, q;
2895
2896 /* Return if static table is already initialized */
2897 if(use_static && rl->rl_vlc[0])
2898 return;
2899
2900 init_vlc(&rl->vlc, 9, rl->n + 1,
2901 &rl->table_vlc[0][1], 4, 2,
2902 &rl->table_vlc[0][0], 4, 2, use_static);
2903
2904
2905 for(q=0; q<32; q++){
2906 int qmul= q*2;
2907 int qadd= (q-1)|1;
2908
2909 if(q==0){
2910 qmul=1;
2911 qadd=0;
2912 }
2913 if(use_static)
2914 rl->rl_vlc[q]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
2915 else
2916 rl->rl_vlc[q]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
2917 for(i=0; i<rl->vlc.table_size; i++){
2918 int code= rl->vlc.table[i][0];
2919 int len = rl->vlc.table[i][1];
2920 int level, run;
2921
2922 if(len==0){ // illegal code
2923 run= 66;
2924 level= MAX_LEVEL;
2925 }else if(len<0){ //more bits needed
2926 run= 0;
2927 level= code;
2928 }else{
2929 if(code==rl->n){ //esc
2930 run= 66;
2931 level= 0;
2932 }else{
2933 run= rl->table_run [code] + 1;
2934 level= rl->table_level[code] * qmul + qadd;
2935 if(code >= rl->last) run+=192;
2936 }
2937 }
2938 rl->rl_vlc[q][i].len= len;
2939 rl->rl_vlc[q][i].level= level;
2940 rl->rl_vlc[q][i].run= run;
2941 }
2942 }
2943 }
2944
2945 /* init vlcs */ 2892 /* init vlcs */
2946 2893
2947 /* XXX: find a better solution to handle static init */ 2894 /* XXX: find a better solution to handle static init */
2948 void h263_decode_init_vlc(MpegEncContext *s) 2895 void h263_decode_init_vlc(MpegEncContext *s)
2949 { 2896 {