apply ip_factor and pb_factor in constant quantiser encodes.
authorLoren Merritt <pengvado@videolan.org>
Wed, 8 Dec 2004 02:28:58 +0000 (02:28 +0000)
committerLoren Merritt <pengvado@videolan.org>
Wed, 8 Dec 2004 02:28:58 +0000 (02:28 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@65 df754926-b1dd-0310-bc7b-ec298dee348c

encoder/ratecontrol.c

index 89680a4..4baf165 100644 (file)
@@ -73,6 +73,7 @@ struct x264_ratecontrol_t
     int buffer_size;
     int rcbufrate;
     int init_qp;
+    int qp_constant[5];
 
     /* 1st pass stuff */
     int gop_qp;
@@ -176,6 +177,10 @@ int x264_ratecontrol_new( x264_t *h )
     rc->qpa = rc->qp;
     rc->qpm = rc->qp;
 
+    rc->qp_constant[SLICE_TYPE_P] = h->param.rc.i_qp_constant;
+    rc->qp_constant[SLICE_TYPE_I] = x264_clip3( (int)( qscale2qp( qp2qscale( h->param.rc.i_qp_constant ) / fabs( h->param.rc.f_ip_factor )) + 0.5 ), 0, 51 );
+    rc->qp_constant[SLICE_TYPE_B] = x264_clip3( (int)( qscale2qp( qp2qscale( h->param.rc.i_qp_constant ) * fabs( h->param.rc.f_pb_factor )) + 0.5 ), 0, 51 );
+
     /* Init 1pass CBR algo */
     if( h->param.rc.b_cbr ){
         rc->buffer_size = h->param.rc.i_rc_buffer_size * 1000;
@@ -360,6 +365,8 @@ void x264_ratecontrol_start( x264_t *h, int i_slice_type )
     }
     else if( !h->param.rc.b_cbr )
     {
+        rc->qpm = rc->qpa = rc->qp =
+            rc->qp_constant[ i_slice_type ];
         return;
     }