comparison mpegvideo.c @ 1757:3906ddbaffec libavcodec

optimization & bugfix extracted from the 4k line diff between ffmpeg 0.4.7 and http://www.alicestreet.com/ffh263.html the other parts of the diff where 1. spelling fixes (rejected as only a small part of it could be applied automatically) 2. cosmetics (reindention, function reordering, var renaming, ...) with bugs (rejected) 3. rtp related stuff (rejetced as it breaks several codecs) 4. some changes to the intra/inter decission & scene change detection (quality tests needed first)
author michael
date Sat, 24 Jan 2004 23:47:33 +0000
parents bdf3927bf8c5
children ebe7fa49ddcc
comparison
equal deleted inserted replaced
1756:43a856190778 1757:3906ddbaffec
3832 if((s->avctx->pre_me && s->last_non_b_pict_type==I_TYPE) || s->avctx->pre_me==2){ 3832 if((s->avctx->pre_me && s->last_non_b_pict_type==I_TYPE) || s->avctx->pre_me==2){
3833 s->me.pre_pass=1; 3833 s->me.pre_pass=1;
3834 s->me.dia_size= s->avctx->pre_dia_size; 3834 s->me.dia_size= s->avctx->pre_dia_size;
3835 3835
3836 for(mb_y=s->mb_height-1; mb_y >=0 ; mb_y--) { 3836 for(mb_y=s->mb_height-1; mb_y >=0 ; mb_y--) {
3837 s->mb_y = mb_y;
3837 for(mb_x=s->mb_width-1; mb_x >=0 ; mb_x--) { 3838 for(mb_x=s->mb_width-1; mb_x >=0 ; mb_x--) {
3838 s->mb_x = mb_x; 3839 s->mb_x = mb_x;
3839 s->mb_y = mb_y;
3840 ff_pre_estimate_p_frame_motion(s, mb_x, mb_y); 3840 ff_pre_estimate_p_frame_motion(s, mb_x, mb_y);
3841 } 3841 }
3842 } 3842 }
3843 s->me.pre_pass=0; 3843 s->me.pre_pass=0;
3844 } 3844 }
3845 } 3845 }
3846 3846
3847 s->me.dia_size= s->avctx->dia_size; 3847 s->me.dia_size= s->avctx->dia_size;
3848 for(mb_y=0; mb_y < s->mb_height; mb_y++) { 3848 for(mb_y=0; mb_y < s->mb_height; mb_y++) {
3849 s->mb_y = mb_y;
3849 s->block_index[0]= s->block_wrap[0]*(mb_y*2 + 1) - 1; 3850 s->block_index[0]= s->block_wrap[0]*(mb_y*2 + 1) - 1;
3850 s->block_index[1]= s->block_wrap[0]*(mb_y*2 + 1); 3851 s->block_index[1]= s->block_wrap[0]*(mb_y*2 + 1);
3851 s->block_index[2]= s->block_wrap[0]*(mb_y*2 + 2) - 1; 3852 s->block_index[2]= s->block_wrap[0]*(mb_y*2 + 2) - 1;
3852 s->block_index[3]= s->block_wrap[0]*(mb_y*2 + 2); 3853 s->block_index[3]= s->block_wrap[0]*(mb_y*2 + 2);
3853 for(mb_x=0; mb_x < s->mb_width; mb_x++) { 3854 for(mb_x=0; mb_x < s->mb_width; mb_x++) {
3854 s->mb_x = mb_x; 3855 s->mb_x = mb_x;
3855 s->mb_y = mb_y;
3856 s->block_index[0]+=2; 3856 s->block_index[0]+=2;
3857 s->block_index[1]+=2; 3857 s->block_index[1]+=2;
3858 s->block_index[2]+=2; 3858 s->block_index[2]+=2;
3859 s->block_index[3]+=2; 3859 s->block_index[3]+=2;
3860 3860
3865 ff_estimate_p_frame_motion(s, mb_x, mb_y); 3865 ff_estimate_p_frame_motion(s, mb_x, mb_y);
3866 } 3866 }
3867 } 3867 }
3868 }else /* if(s->pict_type == I_TYPE) */{ 3868 }else /* if(s->pict_type == I_TYPE) */{
3869 /* I-Frame */ 3869 /* I-Frame */
3870 //FIXME do we need to zero them?
3871 memset(s->current_picture.motion_val[0][0], 0, sizeof(int16_t)*(s->mb_width*2 + 2)*(s->mb_height*2 + 2)*2);
3872 memset(s->p_mv_table , 0, sizeof(int16_t)*(s->mb_stride)*s->mb_height*2);
3873 for(i=0; i<s->mb_stride*s->mb_height; i++) 3870 for(i=0; i<s->mb_stride*s->mb_height; i++)
3874 s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; 3871 s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
3875 3872
3876 if(!s->fixed_qscale){ 3873 if(!s->fixed_qscale){
3877 /* finding spatial complexity for I-frame rate control */ 3874 /* finding spatial complexity for I-frame rate control */
4024 case FMT_MPEG1: 4021 case FMT_MPEG1:
4025 mpeg1_encode_picture_header(s, picture_number); 4022 mpeg1_encode_picture_header(s, picture_number);
4026 break; 4023 break;
4027 case FMT_H264: 4024 case FMT_H264:
4028 break; 4025 break;
4026 default:
4027 assert(0);
4029 } 4028 }
4030 bits= get_bit_count(&s->pb); 4029 bits= get_bit_count(&s->pb);
4031 s->header_bits= bits - s->last_bits; 4030 s->header_bits= bits - s->last_bits;
4032 s->last_bits= bits; 4031 s->last_bits= bits;
4033 s->mv_bits=0; 4032 s->mv_bits=0;