]> granicus.if.org Git - libx264/commitdiff
adjust coded buffer size based on input resolution and QP (old default wasn't enough...
authorLoren Merritt <pengvado@videolan.org>
Tue, 21 Jun 2005 04:45:49 +0000 (04:45 +0000)
committerLoren Merritt <pengvado@videolan.org>
Tue, 21 Jun 2005 04:45:49 +0000 (04:45 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@268 df754926-b1dd-0310-bc7b-ec298dee348c

encoder/encoder.c
x264.c

index 32c5072c74847db6564c5d262cf98b060a1cdb64..b562b2f48fa83898a4ddca01a4c16233d682c069 100644 (file)
@@ -515,7 +515,9 @@ x264_t *x264_encoder_open   ( x264_param_t *param )
 
     /* Init x264_t */
     h->out.i_nal = 0;
-    h->out.i_bitstream = 1000000; /* FIXME estimate max size (idth/height) */
+    h->out.i_bitstream = X264_MAX( 1000000, h->param.i_width * h->param.i_height * 1.7
+        * ( h->param.rc.b_cbr ? pow( 0.5, h->param.rc.i_qp_min )
+          : pow( 0.5, h->param.rc.i_qp_constant ) * X264_MAX( 1, h->param.rc.f_ip_factor )));
     h->out.p_bitstream = x264_malloc( h->out.i_bitstream );
 
     h->i_frame = 0;
diff --git a/x264.c b/x264.c
index f81eb188f07c5440321d77340e73128acf63e45f..0901ab781f675525721cf479ab73db06b6965e1f 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -501,9 +501,13 @@ static int  Parse( int argc, char **argv,
                 break;
             case 'i':
                 param->i_keyint_min = atol( optarg );
+                if( param->i_keyint_max < param->i_keyint_min )
+                    param->i_keyint_max = param->i_keyint_min;
                 break;
             case 'I':
                 param->i_keyint_max = atol( optarg );
+                if( param->i_keyint_min > param->i_keyint_max )
+                    param->i_keyint_min = param->i_keyint_max;
                 break;
             case OPT_SCENECUT:
                 param->i_scenecut_threshold = atol( optarg );