changeset 2981:33d4fb0df0d3 libavcodec

better f_code guessing in 2nd pass
author michael
date Thu, 22 Dec 2005 22:48:09 +0000
parents 529163f99474
children 16f0f957e6ac
files mpegvideo.c mpegvideo.h ratecontrol.c
diffstat 3 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mpegvideo.c	Thu Dec 22 14:17:54 2005 +0000
+++ b/mpegvideo.c	Thu Dec 22 22:48:09 2005 +0000
@@ -5298,9 +5298,10 @@
             s->no_rounding ^= 1;
     }
 
-    if(s->flags & CODEC_FLAG_PASS2)
+    if(s->flags & CODEC_FLAG_PASS2){
         estimate_qp(s, 1);
-    else if(!(s->flags & CODEC_FLAG_QSCALE)){
+        ff_get_2pass_fcode(s);
+    }else if(!(s->flags & CODEC_FLAG_QSCALE)){
         RateControlContext *rcc= &s->rc_context;
 
         if(s->pict_type==B_TYPE)
--- a/mpegvideo.h	Thu Dec 22 14:17:54 2005 +0000
+++ b/mpegvideo.h	Thu Dec 22 22:48:09 2005 +0000
@@ -980,6 +980,6 @@
                double (**func2)(void *, double, double), char **func2_name,
                void *opaque);
 int ff_vbv_update(MpegEncContext *s, int frame_size);
-
+void ff_get_2pass_fcode(MpegEncContext *s);
 
 #endif /* AVCODEC_MPEGVIDEO_H */
--- a/ratecontrol.c	Thu Dec 22 14:17:54 2005 +0000
+++ b/ratecontrol.c	Thu Dec 22 22:48:09 2005 +0000
@@ -607,6 +607,17 @@
         s->lambda_table[mb_xy]= intq;
     }
 }
+
+void ff_get_2pass_fcode(MpegEncContext *s){
+    RateControlContext *rcc= &s->rc_context;
+    int picture_number= s->picture_number;
+    RateControlEntry *rce;
+
+    rce= &rcc->entry[picture_number];
+    s->f_code= rce->f_code;
+    s->b_code= rce->b_code;
+}
+
 //FIXME rd or at least approx for dquant
 
 float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)