changeset 2997:188f4ef688f2 libavcodec

second try of improved lambda/qp guessing for motion estimation RD in first pass
author michael
date Thu, 29 Dec 2005 15:46:23 +0000
parents bf34de4233a0
children 733ceb1e079e
files mpegvideo.c mpegvideo.h
diffstat 2 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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);
     }
 
--- 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