# HG changeset patch # User michael # Date 1135871183 0 # Node ID 188f4ef688f2e19059b2b2ef07de68096aab99a9 # Parent bf34de4233a08419c27ba1ae441187434b550450 second try of improved lambda/qp guessing for motion estimation RD in first pass diff -r bf34de4233a0 -r 188f4ef688f2 mpegvideo.c --- a/mpegvideo.c Thu Dec 29 07:24:23 2005 +0000 +++ b/mpegvideo.c Thu Dec 29 15:46:23 2005 +0000 @@ -1594,6 +1594,7 @@ emms_c(); s->last_pict_type = s->pict_type; + s->last_lambda_for[s->pict_type]= s->current_picture_ptr->quality; if(s->pict_type!=B_TYPE){ s->last_non_b_pict_type= s->pict_type; } @@ -2204,7 +2205,7 @@ int is_p= i % (j+1) == j || i==s->max_b_frames; input[i+1].pict_type= is_p ? P_TYPE : B_TYPE; - input[i+1].quality= s->rc_context.last_qscale_for[input[i+1].pict_type]; + input[i+1].quality= s->last_lambda_for[input[i+1].pict_type]; out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[i+1]); rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT; } @@ -5398,12 +5399,10 @@ estimate_qp(s, 1); ff_get_2pass_fcode(s); }else if(!(s->flags & CODEC_FLAG_QSCALE)){ - RateControlContext *rcc= &s->rc_context; - if(s->pict_type==B_TYPE) - s->lambda= rcc->last_qscale_for[s->pict_type]; + s->lambda= s->last_lambda_for[s->pict_type]; else - s->lambda= rcc->last_qscale_for[rcc->last_non_b_pict_type]; + s->lambda= s->last_lambda_for[s->last_non_b_pict_type]; update_qscale(s); } diff -r bf34de4233a0 -r 188f4ef688f2 mpegvideo.h --- a/mpegvideo.h Thu Dec 29 07:24:23 2005 +0000 +++ b/mpegvideo.h Thu Dec 29 15:46:23 2005 +0000 @@ -374,6 +374,7 @@ int last_non_b_pict_type; ///< used for mpeg4 gmc b-frames & ratecontrol int dropable; int frame_rate_index; + int last_lambda_for[5]; ///< last lambda for a specific pict type /* motion compensation */ int unrestricted_mv; ///< mv can point outside of the coded picture