]> git.sesse.net Git - x264/commitdiff
Various high-bit-depth ratecontrol fixes
authorAnton Mitrofanov <BugMaster@narod.ru>
Tue, 16 Nov 2010 23:46:30 +0000 (02:46 +0300)
committerFiona Glaser <fiona@x264.com>
Wed, 17 Nov 2010 06:01:44 +0000 (22:01 -0800)
common/common.c
encoder/ratecontrol.c

index bdab98dedecb47bc28d2067e1e1f0f3c49bf92d1..4e3f9342e4fa30478e1e2283f8c944ac9726b33d 100644 (file)
@@ -468,8 +468,8 @@ int x264_param_apply_profile( x264_param_t *param, const char *profile )
         x264_log( NULL, X264_LOG_ERROR, "invalid profile: %s\n", profile );
         return -1;
     }
-    if( (param->rc.i_rc_method == X264_RC_CQP && param->rc.i_qp_constant == 0) ||
-        (param->rc.i_rc_method == X264_RC_CRF && param->rc.f_rf_constant == 0) )
+    if( (param->rc.i_rc_method == X264_RC_CQP && param->rc.i_qp_constant <= 0) ||
+        (param->rc.i_rc_method == X264_RC_CRF && (int)(param->rc.f_rf_constant + QP_BD_OFFSET) <= 0) )
     {
         x264_log( NULL, X264_LOG_ERROR, "%s profile doesn't support lossless\n", profile );
         return -1;
index 8e2191fe4b36554f5a33a79b09584e9986be9c0c..f1d6260dadf15a5af4d2a1b827192dec1802cf0e 100644 (file)
@@ -1095,7 +1095,7 @@ void x264_ratecontrol_summary( x264_t *h )
         double mbtree_offset = h->param.rc.b_mb_tree ? (1.0-h->param.rc.f_qcompress)*13.5 : 0;
         x264_log( h, X264_LOG_INFO, "final ratefactor: %.2f\n",
                   qscale2qp( pow( base_cplx, 1 - rc->qcompress )
-                             * rc->cplxr_sum / rc->wanted_bits_window ) - mbtree_offset );
+                             * rc->cplxr_sum / rc->wanted_bits_window ) - mbtree_offset - QP_BD_OFFSET );
     }
 }
 
@@ -1449,7 +1449,7 @@ int x264_ratecontrol_slice_type( x264_t *h, int frame_num )
             /* We could try to initialize everything required for ABR and
              * adaptive B-frames, but that would be complicated.
              * So just calculate the average QP used so far. */
-            h->param.rc.i_qp_constant = (h->stat.i_frame_count[SLICE_TYPE_P] == 0) ? 24
+            h->param.rc.i_qp_constant = (h->stat.i_frame_count[SLICE_TYPE_P] == 0) ? 24 + QP_BD_OFFSET
                                       : 1 + h->stat.f_frame_qp[SLICE_TYPE_P] / h->stat.i_frame_count[SLICE_TYPE_P];
             rc->qp_constant[SLICE_TYPE_P] = x264_clip3( h->param.rc.i_qp_constant, 0, QP_MAX );
             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, QP_MAX );