[x264-devel] More validation of input parameters

Anton Mitrofanov git at videolan.org
Thu May 12 08:38:56 CEST 2011


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Wed May  4 11:45:58 2011 +0400| [5ac5779349dfa811039086f3df580808c739fecc] | committer: Jason Garrett-Glaser

More validation of input parameters
This fixes a crash with --me umh and insane values of --me-range.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=5ac5779349dfa811039086f3df580808c739fecc
---

 encoder/encoder.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index c80fac4..81ac7f6 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -532,10 +532,10 @@ static int x264_validate_parameters( x264_t *h, int b_open )
     h->param.rc.i_qp_max = x264_clip3( h->param.rc.i_qp_max, 0, QP_MAX );
     h->param.rc.i_qp_min = x264_clip3( h->param.rc.i_qp_min, 0, h->param.rc.i_qp_max );
     h->param.rc.i_qp_step = x264_clip3( h->param.rc.i_qp_step, 0, QP_MAX );
-    h->param.rc.i_bitrate = X264_MAX( h->param.rc.i_bitrate, 0 );
-    h->param.rc.i_vbv_buffer_size = X264_MAX( h->param.rc.i_vbv_buffer_size, 0 );
-    h->param.rc.i_vbv_max_bitrate = X264_MAX( h->param.rc.i_vbv_max_bitrate, 0 );
-    h->param.rc.f_vbv_buffer_init = X264_MAX( h->param.rc.f_vbv_buffer_init, 0 );
+    h->param.rc.i_bitrate = x264_clip3( h->param.rc.i_bitrate, 0, 2000000 );
+    h->param.rc.i_vbv_buffer_size = x264_clip3( h->param.rc.i_vbv_buffer_size, 0, 2000000 );
+    h->param.rc.i_vbv_max_bitrate = x264_clip3( h->param.rc.i_vbv_max_bitrate, 0, 2000000 );
+    h->param.rc.f_vbv_buffer_init = x264_clip3f( h->param.rc.f_vbv_buffer_init, 0, 2000000 );
     if( h->param.rc.i_vbv_buffer_size )
     {
         if( h->param.rc.i_rc_method == X264_RC_CQP )
@@ -701,8 +701,7 @@ static int x264_validate_parameters( x264_t *h, int b_open )
     if( h->param.analyse.i_me_method < X264_ME_DIA ||
         h->param.analyse.i_me_method > X264_ME_TESA )
         h->param.analyse.i_me_method = X264_ME_HEX;
-    if( h->param.analyse.i_me_range < 4 )
-        h->param.analyse.i_me_range = 4;
+    h->param.analyse.i_me_range = x264_clip3( h->param.analyse.i_me_range, 4, 1024 );
     if( h->param.analyse.i_me_range > 16 && h->param.analyse.i_me_method <= X264_ME_HEX )
         h->param.analyse.i_me_range = 16;
     if( h->param.analyse.i_me_method == X264_ME_TESA &&



More information about the x264-devel mailing list