]> git.sesse.net Git - x264/blobdiff - x264.c
* all: Patch by Loren Merritt.
[x264] / x264.c
diff --git a/x264.c b/x264.c
index 75c347b67d959507052d3a836c083fddcb9a90fd..e34b27ce52dd30d88ab771c10ed2f1fdb3f8117f 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -24,7 +24,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <stdint.h>
 
 #include <math.h>
 
@@ -37,8 +36,8 @@
 #include <fcntl.h>  /* _O_BINARY */
 #endif
 
-#include "x264.h"
 #include "core/common.h"
+#include "x264.h"
 
 #define DATA_MAX 3000000
 uint8_t data[DATA_MAX];
@@ -74,7 +73,6 @@ int main( int argc, char **argv )
 #endif
 
     x264_param_default( &param );
-    param.f_fps = 25.0;
 
     /* Parse command line */
     if( Parse( argc, argv, &param, &fin, &fout, &b_decompress ) < 0 )
@@ -105,25 +103,44 @@ static void Help( void )
              "  -h, --help                  Print this help\n"
              "\n"
              "  -I, --idrframe <integer>    Each 'number' I frames are IDR frames\n"
-             "  -i, --iframe <integer>      Frequency of I frames\n"
+             "  -i, --iframe <integer>      Max interval between I frames\n"
+             "      --scenecut <integer>    How aggresively to insert extra I frames\n"
              "  -b, --bframe <integer>      Number of B-frames between I and P\n"
              "\n"
              "  -c, --cabac                 Enable CABAC\n"
              "  -r, --ref <integer>         Number of references\n"
              "  -n, --nf                    Disable loop filter\n"
              "  -f, --filter <alpha:beta>   Loop filter AplhaCO and Beta parameters\n"
+             "\n"
              "  -q, --qp <integer>          Set QP\n"
-             "  -B, --bitrate <integer>     Set bitrate [broken]\n"
+             "  -B, --bitrate <integer>     Set bitrate\n"
+             "      --qpmin <integer>       Set min QP\n"
+             "      --qpmax <integer>       Set max QP\n"
+             "      --qpstep <integer>      Set max QP step\n"
+             "      --rcsens <integer>      RC sensitivity\n"
+             "      --rcbuf <integer>       Size of VBV buffer\n"
+             "      --rcinitbuf <integer>   Initial VBV buffer occupancy\n"
+             "      --ipratio <float>       QP factor between I and P\n"
+             "      --pbratio <float>       QP factor between P and B\n"
              "\n"
+             "  -p, --pass <1|2>            Enable 2 pass ratecontrol\n"
+             "      --stats <string>        Filename for 2 pass stats\n"
+             "      --rceq <string>         Ratecontrol equation\n"
+             "      --qcomp <float>         0.0 => CBR, 1.0 => CQP, 0.6 => default\n"
+             "\n"
+
              "  -A, --analyse <string>      Analyse options:\n"
              "                                  - i4x4\n"
              "                                  - psub16x16,psub8x8\n"
              "                                  - none, all\n"
+             "      --subme <integer>       Subpixel motion estimation quality\n"
              "\n"
              "  -s, --sar width:height      Specify Sample Aspect Ratio\n"
              "  -o, --output                Specify output file\n"
              "\n"
              "      --no-asm                Disable any CPU optims\n"
+             "      --no-psnr               Disable PSNR computaion\n"
+             "      --quiet                 Quiet Mode\n"
              "\n",
             X264_BUILD
            );
@@ -148,6 +165,22 @@ static int  Parse( int argc, char **argv,
     for( ;; )
     {
         int long_options_index;
+#define OPT_QPMIN 256
+#define OPT_QPMAX 257
+#define OPT_QPSTEP 258
+#define OPT_RCSENS 259
+#define OPT_IPRATIO 260
+#define OPT_PBRATIO 261
+#define OPT_RCBUF 262
+#define OPT_RCIBUF 263
+#define OPT_RCSTATS 264
+#define OPT_RCEQ 265
+#define OPT_QCOMP 266
+#define OPT_NOPSNR 267
+#define OPT_QUIET 268
+#define OPT_SUBME 269
+#define OPT_SCENECUT 270
+
         static struct option long_options[] =
         {
             { "help",    no_argument,       NULL, 'h' },
@@ -155,21 +188,37 @@ static int  Parse( int argc, char **argv,
             { "bframe",  required_argument, NULL, 'b' },
             { "iframe",  required_argument, NULL, 'i' },
             { "idrframe",required_argument, NULL, 'I' },
+            { "scenecut",required_argument, NULL, OPT_SCENECUT },
             { "nf",      no_argument,       NULL, 'n' },
             { "filter",  required_argument, NULL, 'f' },
             { "cabac",   no_argument,       NULL, 'c' },
             { "qp",      required_argument, NULL, 'q' },
+            { "qpmin",   required_argument, NULL, OPT_QPMIN },
+            { "qpmax",   required_argument, NULL, OPT_QPMAX },
+            { "qpstep",  required_argument, NULL, OPT_QPSTEP },
             { "ref",     required_argument, NULL, 'r' },
             { "no-asm",  no_argument,       NULL, 'C' },
             { "sar",     required_argument, NULL, 's' },
             { "output",  required_argument, NULL, 'o' },
             { "analyse", required_argument, NULL, 'A' },
+            { "subme",   required_argument, NULL, OPT_SUBME },
+            { "rcsens",  required_argument, NULL, OPT_RCSENS },
+            { "rcbuf",   required_argument, NULL, OPT_RCBUF },
+            { "rcinitbuf",required_argument, NULL, OPT_RCIBUF },
+            { "ipratio", required_argument, NULL, OPT_IPRATIO },
+            { "pbratio", required_argument, NULL, OPT_PBRATIO },
+            { "pass",    required_argument, NULL, 'p' },
+            { "stats",   required_argument, NULL, OPT_RCSTATS },
+            { "rceq",    required_argument, NULL, OPT_RCEQ },
+            { "qcomp",   required_argument, NULL, OPT_QCOMP },
+            { "no-psnr", no_argument,       NULL, OPT_NOPSNR },
+            { "quiet",   no_argument,       NULL, OPT_QUIET },
             {0, 0, 0, 0}
         };
 
         int c;
 
-        c = getopt_long( argc, argv, "hi:I:b:r:cxB:q:no:s:A:",
+        c = getopt_long( argc, argv, "hi:I:b:r:cxB:q:no:s:A:p:",
                          long_options, &long_options_index);
 
         if( c == -1 )
@@ -186,7 +235,8 @@ static int  Parse( int argc, char **argv,
             case 0:
                 break;
             case 'B':
-                param->i_bitrate = atol( optarg );
+                param->rc.i_bitrate = atol( optarg );
+                param->rc.b_cbr = 1;
                 break;
             case 'b':
                 param->i_bframe = atol( optarg );
@@ -197,6 +247,9 @@ static int  Parse( int argc, char **argv,
             case 'I':
                 param->i_idrframe = atol( optarg );
                 break;
+            case OPT_SCENECUT:
+                param->i_scenecut_threshold = atol( optarg );
+                break;
             case 'n':
                 param->b_deblocking_filter = 0;
                 break;
@@ -211,7 +264,16 @@ static int  Parse( int argc, char **argv,
                 break;
             }
             case 'q':
-                param->i_qp_constant = atoi( optarg );
+                param->rc.i_qp_constant = atoi( optarg );
+                break;
+            case OPT_QPMIN:
+                param->rc.i_qp_min = atoi( optarg );
+                break;
+            case OPT_QPMAX:
+                param->rc.i_qp_max = atoi( optarg );
+                break;
+            case OPT_QPSTEP:
+                param->rc.i_qp_step = atoi( optarg );
                 break;
             case 'r':
                 param->i_frame_reference = atoi( optarg );
@@ -251,7 +313,53 @@ static int  Parse( int argc, char **argv,
                 if( strstr( optarg, "psub16x16" ) ) param->analyse.inter |= X264_ANALYSE_PSUB16x16;
                 if( strstr( optarg, "psub8x8" ) )   param->analyse.inter |= X264_ANALYSE_PSUB8x8;
                 break;
+            case OPT_SUBME:
+                param->analyse.i_subpel_refine = atoi(optarg);
+                break;
+            case OPT_RCBUF:
+                param->rc.i_rc_buffer_size = atoi(optarg);
+                break;
+            case OPT_RCIBUF:
+                param->rc.i_rc_init_buffer = atoi(optarg);
+                break;
+            case OPT_RCSENS:
+                param->rc.i_rc_sens = atoi(optarg);
+                break;
+            case OPT_IPRATIO:
+                param->rc.f_ip_factor = atof(optarg);
+                break;
+            case OPT_PBRATIO:
+                param->rc.f_pb_factor = atof(optarg);
+                break;
+            case 'p':
+            {
+                int i_pass = atoi(optarg);
+                if( i_pass == 1 )
+                    param->rc.b_stat_write = 1;
+                else if( i_pass == 2 )
+                    param->rc.b_stat_read = 1;
+                else if( i_pass > 2 )   /* XXX untested */
+                    param->rc.b_stat_read =
+                    param->rc.b_stat_write = 1;
+                break;
+            }
+            case OPT_RCSTATS:
+                param->rc.psz_stat_in = optarg;
+                param->rc.psz_stat_out = optarg;
+                break;
+            case OPT_RCEQ:
+                param->rc.psz_rc_eq = optarg;
+               break;
+            case OPT_QCOMP:
+                param->rc.f_qcompress = atof(optarg);
+                break;
 
+            case OPT_NOPSNR:
+                param->analyse.b_psnr = 0;
+                break;
+            case OPT_QUIET:
+                param->i_log_level = X264_LOG_NONE;
+                break;
             default:
                 fprintf( stderr, "unknown option (%c)\n", optopt );
                 return -1;