From: Anton Mitrofanov Date: Tue, 16 Nov 2010 23:46:30 +0000 (+0300) Subject: Various high-bit-depth ratecontrol fixes X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=2824c3a064d88f8b1a4af726249c0b51a449c0b2;p=x264.git Various high-bit-depth ratecontrol fixes --- diff --git a/common/common.c b/common/common.c index bdab98de..4e3f9342 100644 --- a/common/common.c +++ b/common/common.c @@ -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; diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c index 34879b7b..d1fa48ee 100644 --- a/encoder/ratecontrol.c +++ b/encoder/ratecontrol.c @@ -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 );