[x264-devel] Apply zone options a little bit earlier

Anton Mitrofanov git at videolan.org
Mon Jun 13 23:44:53 CEST 2016


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Sat Apr 23 23:10:03 2016 +0300| [740a8c556bd9b68e899d6991f3f987a443aa14aa] | committer: Henrik Gramner

Apply zone options a little bit earlier

This way things like SAR changes will have full effect from the start frame.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=740a8c556bd9b68e899d6991f3f987a443aa14aa
---

 encoder/encoder.c     |    1 +
 encoder/ratecontrol.c |   13 +++++++++----
 encoder/ratecontrol.h |    1 +
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index b614198..f733adf 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -3344,6 +3344,7 @@ int     x264_encoder_encode( x264_t *h,
             h->fenc->param = NULL;
         }
     }
+    x264_ratecontrol_zone_init( h );
 
     // ok to call this before encoding any frames, since the initial values of fdec have b_kept_as_ref=0
     if( x264_reference_update( h ) )
diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index 723350c..99277f1 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -1409,6 +1409,15 @@ static void accum_p_qp_update( x264_t *h, float qp )
         rc->accum_p_qp += qp;
 }
 
+void x264_ratecontrol_zone_init( x264_t *h )
+{
+    x264_ratecontrol_t *rc = h->rc;
+    x264_zone_t *zone = get_zone( h, h->fenc->i_frame );
+    if( zone && (!rc->prev_zone || zone->param != rc->prev_zone->param) )
+        x264_encoder_reconfig_apply( h, zone->param );
+    rc->prev_zone = zone;
+}
+
 /* Before encoding a frame, choose a QP for it */
 void x264_ratecontrol_start( x264_t *h, int i_force_qp, int overhead )
 {
@@ -1419,10 +1428,6 @@ void x264_ratecontrol_start( x264_t *h, int i_force_qp, int overhead )
 
     x264_emms();
 
-    if( zone && (!rc->prev_zone || zone->param != rc->prev_zone->param) )
-        x264_encoder_reconfig_apply( h, zone->param );
-    rc->prev_zone = zone;
-
     if( h->param.rc.b_stat_read )
     {
         int frame = h->fenc->i_frame;
diff --git a/encoder/ratecontrol.h b/encoder/ratecontrol.h
index 490a1ed..9f7e227 100644
--- a/encoder/ratecontrol.h
+++ b/encoder/ratecontrol.h
@@ -49,6 +49,7 @@ void x264_adaptive_quant_frame( x264_t *h, x264_frame_t *frame, float *quant_off
 int  x264_macroblock_tree_read( x264_t *h, x264_frame_t *frame, float *quant_offsets );
 int  x264_reference_build_list_optimal( x264_t *h );
 void x264_thread_sync_ratecontrol( x264_t *cur, x264_t *prev, x264_t *next );
+void x264_ratecontrol_zone_init( x264_t * );
 void x264_ratecontrol_start( x264_t *, int i_force_qp, int overhead );
 int  x264_ratecontrol_slice_type( x264_t *, int i_frame );
 void x264_ratecontrol_set_weights( x264_t *h, x264_frame_t *frm );



More information about the x264-devel mailing list