comparison mpegvideo.c @ 815:78accc54493b libavcodec

put a few large tables under #ifdef CONFIG_ENCODERS or dynamically allocate them
author michaelni
date Thu, 31 Oct 2002 16:11:03 +0000
parents 8f31ed5bacd1
children ace3ccd18dd2
comparison
equal deleted inserted replaced
814:8f31ed5bacd1 815:78accc54493b
83 83
84 static UINT8 h263_chroma_roundtab[16] = { 84 static UINT8 h263_chroma_roundtab[16] = {
85 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 85 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
86 }; 86 };
87 87
88 static UINT16 default_mv_penalty[MAX_FCODE+1][MAX_MV*2+1]; 88 static UINT16 (*default_mv_penalty)[MAX_MV*2+1]=NULL;
89 static UINT8 default_fcode_tab[MAX_MV*2+1]; 89 static UINT8 default_fcode_tab[MAX_MV*2+1];
90 90
91 /* default motion estimation */ 91 /* default motion estimation */
92 int motion_estimation_method = ME_EPZS; 92 int motion_estimation_method = ME_EPZS;
93 93
682 { /* set up some save defaults, some codecs might override them later */ 682 { /* set up some save defaults, some codecs might override them later */
683 static int done=0; 683 static int done=0;
684 if(!done){ 684 if(!done){
685 int i; 685 int i;
686 done=1; 686 done=1;
687
688 default_mv_penalty= av_mallocz( sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1) );
687 memset(default_mv_penalty, 0, sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1)); 689 memset(default_mv_penalty, 0, sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1));
688 memset(default_fcode_tab , 0, sizeof(UINT8)*(2*MAX_MV+1)); 690 memset(default_fcode_tab , 0, sizeof(UINT8)*(2*MAX_MV+1));
689 691
690 for(i=-16; i<16; i++){ 692 for(i=-16; i<16; i++){
691 default_fcode_tab[i + MAX_MV]= 1; 693 default_fcode_tab[i + MAX_MV]= 1;
704 706
705 /* init */ 707 /* init */
706 if (MPV_common_init(s) < 0) 708 if (MPV_common_init(s) < 0)
707 return -1; 709 return -1;
708 710
711 #ifdef CONFIG_ENCODERS
709 if (s->out_format == FMT_H263) 712 if (s->out_format == FMT_H263)
710 h263_encode_init(s); 713 h263_encode_init(s);
711 else if (s->out_format == FMT_MPEG1) 714 else if (s->out_format == FMT_MPEG1)
712 ff_mpeg1_encode_init(s); 715 ff_mpeg1_encode_init(s);
713 if(s->msmpeg4_version) 716 if(s->msmpeg4_version)
714 ff_msmpeg4_encode_init(s); 717 ff_msmpeg4_encode_init(s);
718 #endif
715 719
716 /* init default q matrix */ 720 /* init default q matrix */
717 for(i=0;i<64;i++) { 721 for(i=0;i<64;i++) {
718 int j= s->idct_permutation[i]; 722 int j= s->idct_permutation[i];
719 if(s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){ 723 if(s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){
2387 s->block_last_index[5]= 0; 2391 s->block_last_index[5]= 0;
2388 s->block[4][0]= 2392 s->block[4][0]=
2389 s->block[5][0]= 128; 2393 s->block[5][0]= 128;
2390 } 2394 }
2391 2395
2396 #ifdef CONFIG_ENCODERS
2392 /* huffman encode */ 2397 /* huffman encode */
2393 switch(s->out_format) { 2398 switch(s->out_format) {
2394 case FMT_MPEG1: 2399 case FMT_MPEG1:
2395 mpeg1_encode_mb(s, s->block, motion_x, motion_y); 2400 mpeg1_encode_mb(s, s->block, motion_x, motion_y);
2396 break; 2401 break;
2404 break; 2409 break;
2405 case FMT_MJPEG: 2410 case FMT_MJPEG:
2406 mjpeg_encode_mb(s, s->block); 2411 mjpeg_encode_mb(s, s->block);
2407 break; 2412 break;
2408 } 2413 }
2414 #endif
2409 } 2415 }
2410 2416
2411 void ff_copy_bits(PutBitContext *pb, UINT8 *src, int length) 2417 void ff_copy_bits(PutBitContext *pb, UINT8 *src, int length)
2412 { 2418 {
2413 int bytes= length>>4; 2419 int bytes= length>>4;