Commit 93b54ce1 authored by Loren Merritt's avatar Loren Merritt

allow fractional values of crf


git-svn-id: svn://svn.videolan.org/x264/trunk@591 df754926-b1dd-0310-bc7b-ec298dee348c
parent 8d1ebe2e
......@@ -87,7 +87,7 @@ void x264_param_default( x264_param_t *param )
param->rc.i_vbv_buffer_size = 0;
param->rc.f_vbv_buffer_init = 0.9;
param->rc.i_qp_constant = 26;
param->rc.i_rf_constant = 0;
param->rc.f_rf_constant = 0;
param->rc.i_qp_min = 10;
param->rc.i_qp_max = 51;
param->rc.i_qp_step = 4;
......@@ -465,7 +465,7 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
}
OPT("crf")
{
p->rc.i_rf_constant = atoi(value);
p->rc.f_rf_constant = atof(value);
p->rc.i_rc_method = X264_RC_CRF;
}
OPT2("qpmin", "qp-min")
......@@ -900,7 +900,7 @@ char *x264_param2string( x264_param_t *p, int b_res )
if( p->rc.i_rc_method == X264_RC_ABR || p->rc.i_rc_method == X264_RC_CRF )
{
if( p->rc.i_rc_method == X264_RC_CRF )
s += sprintf( s, " crf=%d", p->rc.i_rf_constant );
s += sprintf( s, " crf=%.1f", p->rc.f_rf_constant );
else
s += sprintf( s, " bitrate=%d ratetol=%.1f",
p->rc.i_bitrate, p->rc.f_rate_tolerance );
......
......@@ -377,10 +377,10 @@ static int x264_validate_parameters( x264_t *h )
x264_log( h, X264_LOG_ERROR, "invalid RC method\n" );
return -1;
}
h->param.rc.i_rf_constant = x264_clip3( h->param.rc.i_rf_constant, 0, 51 );
h->param.rc.f_rf_constant = x264_clip3f( h->param.rc.f_rf_constant, 0, 51 );
h->param.rc.i_qp_constant = x264_clip3( h->param.rc.i_qp_constant, 0, 51 );
if( h->param.rc.i_rc_method == X264_RC_CRF )
h->param.rc.i_qp_constant = h->param.rc.i_rf_constant;
h->param.rc.i_qp_constant = h->param.rc.f_rf_constant;
if( (h->param.rc.i_rc_method == X264_RC_CQP || h->param.rc.i_rc_method == X264_RC_CRF)
&& h->param.rc.i_qp_constant == 0 )
{
......
......@@ -252,7 +252,7 @@ int x264_ratecontrol_new( x264_t *h )
if( rc->b_abr )
{
/* FIXME ABR_INIT_QP is actually used only in CRF */
#define ABR_INIT_QP ( h->param.rc.i_rc_method == X264_RC_CRF ? h->param.rc.i_rf_constant : 24 )
#define ABR_INIT_QP ( h->param.rc.i_rc_method == X264_RC_CRF ? h->param.rc.f_rf_constant : 24 )
rc->accum_p_norm = .01;
rc->accum_p_qp = ABR_INIT_QP * rc->accum_p_norm;
/* estimated ratio that produces a reasonable QP for the first I-frame */
......@@ -266,7 +266,7 @@ int x264_ratecontrol_new( x264_t *h )
/* arbitrary rescaling to make CRF somewhat similar to QP */
double base_cplx = h->mb.i_mb_count * (h->param.i_bframe ? 120 : 80);
rc->rate_factor_constant = pow( base_cplx, 1 - h->param.rc.f_qcompress )
/ qp2qscale( h->param.rc.i_rf_constant );
/ qp2qscale( h->param.rc.f_rf_constant );
}
rc->ip_offset = 6.0 * log(h->param.rc.f_ip_factor) / log(2.0);
......
......@@ -362,7 +362,7 @@ static int Parse( int argc, char **argv,
{ "keyint", required_argument, NULL, 'I' },
{ "scenecut",required_argument, NULL, 0 },
{ "nf", no_argument, NULL, 0 },
{ "nodeblock", no_argument, NULL, 0 },
{ "no-deblock", no_argument, NULL, 0 },
{ "filter", required_argument, NULL, 0 },
{ "deblock", required_argument, NULL, 'f' },
{ "interlaced", no_argument, NULL, 0 },
......
......@@ -35,7 +35,7 @@
#include <stdarg.h>
#define X264_BUILD 53
#define X264_BUILD 54
/* x264_t:
* opaque handler for encoder */
......@@ -238,7 +238,7 @@ typedef struct
int i_qp_step; /* max QP step between frames */
int i_bitrate;
int i_rf_constant; /* 1pass VBR, nominal QP */
float f_rf_constant; /* 1pass VBR, nominal QP */
float f_rate_tolerance;
int i_vbv_max_bitrate;
int i_vbv_buffer_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment