Commit 28c0f241 authored by Loren Merritt's avatar Loren Merritt

more error checking of input parameters



git-svn-id: svn://svn.videolan.org/x264/trunk@394 df754926-b1dd-0310-bc7b-ec298dee348c
parent bf1e4d1f
......@@ -352,6 +352,8 @@ static int x264_validate_parameters( x264_t *h )
}
#endif
if( h->param.rc.b_cbr )
h->param.rc.i_rf_constant = 0;
if( h->param.rc.i_rf_constant > 0 )
h->param.rc.i_qp_constant = h->param.rc.i_rf_constant;
h->param.rc.i_rf_constant = x264_clip3( h->param.rc.i_rf_constant, 0, 51 );
......@@ -418,6 +420,7 @@ static int x264_validate_parameters( x264_t *h )
h->param.analyse.i_chroma_qp_offset = x264_clip3(h->param.analyse.i_chroma_qp_offset, -12, 12);
if( !h->param.b_cabac )
h->param.analyse.i_trellis = 0;
h->param.analyse.i_trellis = x264_clip3( h->param.analyse.i_trellis, 0, 2 );
{
const x264_level_t *l = x264_levels;
......@@ -439,6 +442,20 @@ static int x264_validate_parameters( x264_t *h )
if( h->param.rc.f_complexity_blur < 0 )
h->param.rc.f_complexity_blur = 0;
/* ensure the booleans are 0 or 1 so they can be used in math */
#define BOOLIFY(x) h->param.x = !!h->param.x
BOOLIFY( b_cabac );
BOOLIFY( b_deblocking_filter );
BOOLIFY( analyse.b_transform_8x8 );
BOOLIFY( analyse.b_weighted_bipred );
BOOLIFY( analyse.b_bidir_me );
BOOLIFY( analyse.b_chroma_me );
BOOLIFY( analyse.b_fast_pskip );
BOOLIFY( rc.b_cbr );
BOOLIFY( rc.b_stat_write );
BOOLIFY( rc.b_stat_read );
#undef BOOLIFY
return 0;
}
......
......@@ -192,8 +192,14 @@ int x264_ratecontrol_new( x264_t *h )
if( rc->b_2pass && h->param.rc.i_rf_constant )
x264_log(h, X264_LOG_ERROR, "constant rate-factor is incompatible with 2pass.\n");
if( h->param.rc.i_vbv_max_bitrate && !h->param.rc.b_cbr && !h->param.rc.i_rf_constant )
if( h->param.rc.i_vbv_buffer_size && !h->param.rc.b_cbr && !h->param.rc.i_rf_constant )
x264_log(h, X264_LOG_ERROR, "VBV is incompatible with constant QP.\n");
if( h->param.rc.i_vbv_buffer_size && h->param.rc.b_cbr
&& h->param.rc.i_vbv_max_bitrate == 0 )
{
x264_log( h, X264_LOG_DEBUG, "VBV maxrate unspecified, assuming CBR\n" );
h->param.rc.i_vbv_max_bitrate = h->param.rc.i_bitrate;
}
if( h->param.rc.i_vbv_max_bitrate < h->param.rc.i_bitrate &&
h->param.rc.i_vbv_max_bitrate > 0)
x264_log(h, X264_LOG_ERROR, "max bitrate less than average bitrate, ignored.\n");
......
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