comparison mpegvideo.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 a5e1cc69033d
children 4393e09e32ec
comparison
equal deleted inserted replaced
5273:101f20612a94 5274:c6bc608d2659
737 if(static_store) 737 if(static_store)
738 rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2; 738 rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2;
739 else 739 else
740 rl->index_run[last] = av_malloc(MAX_RUN + 1); 740 rl->index_run[last] = av_malloc(MAX_RUN + 1);
741 memcpy(rl->index_run[last], index_run, MAX_RUN + 1); 741 memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
742 }
743 }
744
745 void init_vlc_rl(RLTable *rl, int use_static)
746 {
747 int i, q;
748
749 /* Return if static table is already initialized */
750 if(use_static && rl->rl_vlc[0])
751 return;
752
753 init_vlc(&rl->vlc, 9, rl->n + 1,
754 &rl->table_vlc[0][1], 4, 2,
755 &rl->table_vlc[0][0], 4, 2, use_static);
756
757
758 for(q=0; q<32; q++){
759 int qmul= q*2;
760 int qadd= (q-1)|1;
761
762 if(q==0){
763 qmul=1;
764 qadd=0;
765 }
766 if(use_static)
767 rl->rl_vlc[q]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
768 else
769 rl->rl_vlc[q]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
770 for(i=0; i<rl->vlc.table_size; i++){
771 int code= rl->vlc.table[i][0];
772 int len = rl->vlc.table[i][1];
773 int level, run;
774
775 if(len==0){ // illegal code
776 run= 66;
777 level= MAX_LEVEL;
778 }else if(len<0){ //more bits needed
779 run= 0;
780 level= code;
781 }else{
782 if(code==rl->n){ //esc
783 run= 66;
784 level= 0;
785 }else{
786 run= rl->table_run [code] + 1;
787 level= rl->table_level[code] * qmul + qadd;
788 if(code >= rl->last) run+=192;
789 }
790 }
791 rl->rl_vlc[q][i].len= len;
792 rl->rl_vlc[q][i].level= level;
793 rl->rl_vlc[q][i].run= run;
794 }
742 } 795 }
743 } 796 }
744 797
745 /* draw the edges of width 'w' of an image of size width, height */ 798 /* draw the edges of width 'w' of an image of size width, height */
746 //FIXME check that this is ok for mpeg4 interlaced 799 //FIXME check that this is ok for mpeg4 interlaced