]> granicus.if.org Git - libx264/commitdiff
Apply zone options a little bit earlier
authorAnton Mitrofanov <BugMaster@narod.ru>
Sat, 23 Apr 2016 20:10:03 +0000 (23:10 +0300)
committerHenrik Gramner <henrik@gramner.com>
Mon, 13 Jun 2016 19:58:37 +0000 (21:58 +0200)
This way things like SAR changes will have full effect from the start frame.

encoder/encoder.c
encoder/ratecontrol.c
encoder/ratecontrol.h

index b614198aa28fb51de365090fa1d90d147799368b..f733adf2d97a7398e676aa7a549b6eb0ee0e9a5a 100644 (file)
@@ -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 ) )
index 723350c5f6af77b2a3dbab5c83e34927e85e4e4f..99277f1d7a4a890730a05ac23d34306bee900ec8 100644 (file)
@@ -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;
index 490a1edb591584e147ff0cb324f16c89261f79bc..9f7e227c88a83a42c586df42e6e8b8f4ceda8899 100644 (file)
@@ -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 );