Mercurial > libavcodec.hg
comparison ratecontrol.c @ 915:75ee49a4a516 libavcodec
fixing 2pass assert failure
better dynamic b frame selection, still not very good though allthough it works fine without 2pass now
author | michaelni |
---|---|
date | Fri, 06 Dec 2002 13:30:13 +0000 |
parents | 22ee74da2cd3 |
children | 6bcb214d6a17 |
comparison
equal
deleted
inserted
replaced
914:22cec68e6f01 | 915:75ee49a4a516 |
---|---|
712 | 712 |
713 /* find complexity & const_bits & decide the pict_types */ | 713 /* find complexity & const_bits & decide the pict_types */ |
714 for(i=0; i<rcc->num_entries; i++){ | 714 for(i=0; i<rcc->num_entries; i++){ |
715 RateControlEntry *rce= &rcc->entry[i]; | 715 RateControlEntry *rce= &rcc->entry[i]; |
716 | 716 |
717 if(s->b_frame_strategy==0 || s->max_b_frames==0){ | 717 rce->new_pict_type= rce->pict_type; |
718 rce->new_pict_type= rce->pict_type; | |
719 }else{ | |
720 int j; | |
721 int next_non_b_type=P_TYPE; | |
722 | |
723 switch(rce->pict_type){ | |
724 case I_TYPE: | |
725 if(i-last_i_frame>s->gop_size/2){ //FIXME this is not optimal | |
726 rce->new_pict_type= I_TYPE; | |
727 last_i_frame= i; | |
728 }else{ | |
729 rce->new_pict_type= P_TYPE; // will be caught by the scene detection anyway | |
730 } | |
731 break; | |
732 case P_TYPE: | |
733 rce->new_pict_type= P_TYPE; | |
734 break; | |
735 case B_TYPE: | |
736 for(j=i+1; j<i+s->max_b_frames+2 && j<rcc->num_entries; j++){ | |
737 if(rcc->entry[j].pict_type != B_TYPE){ | |
738 next_non_b_type= rcc->entry[j].pict_type; | |
739 break; | |
740 } | |
741 } | |
742 if(next_non_b_type==I_TYPE) | |
743 rce->new_pict_type= P_TYPE; | |
744 else | |
745 rce->new_pict_type= B_TYPE; | |
746 break; | |
747 } | |
748 } | |
749 rcc->i_cplx_sum [rce->pict_type] += rce->i_tex_bits*rce->qscale; | 718 rcc->i_cplx_sum [rce->pict_type] += rce->i_tex_bits*rce->qscale; |
750 rcc->p_cplx_sum [rce->pict_type] += rce->p_tex_bits*rce->qscale; | 719 rcc->p_cplx_sum [rce->pict_type] += rce->p_tex_bits*rce->qscale; |
751 rcc->mv_bits_sum[rce->pict_type] += rce->mv_bits; | 720 rcc->mv_bits_sum[rce->pict_type] += rce->mv_bits; |
752 rcc->frame_count[rce->pict_type] ++; | 721 rcc->frame_count[rce->pict_type] ++; |
753 | 722 |