]> git.sesse.net Git - x264/blobdiff - x264.c
fix SOFLAGS used when building gtk frontend
[x264] / x264.c
diff --git a/x264.c b/x264.c
index efdc5c3a1800556e6127e89ff6751c2276be7d57..1f435f4a06021c58954ec9b324cf627577971e0a 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -1,10 +1,10 @@
 /*****************************************************************************
  * x264: h264 encoder testing program.
  *****************************************************************************
- * Copyright (C) 2003 Laurent Aimar
- * $Id: x264.c,v 1.1 2004/06/03 19:24:12 fenrir Exp $
+ * Copyright (C) 2003-2008 x264 project
  *
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>
+ * Authors: Loren Merritt <lorenm@u.washington.edu>
+ *          Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
  *****************************************************************************/
 
 #include <stdlib.h>
@@ -29,6 +29,7 @@
 #include <getopt.h>
 
 #include "common/common.h"
+#include "common/cpu.h"
 #include "x264.h"
 #include "muxers.h"
 
@@ -89,7 +90,7 @@ int main( int argc, char **argv )
     pthread_win32_thread_attach_np();
 #endif
 
-#ifdef _MSC_VER
+#ifdef _WIN32
     _setmode(_fileno(stdin), _O_BINARY);
     _setmode(_fileno(stdout), _O_BINARY);
 #endif
@@ -201,7 +202,6 @@ static void Help( x264_param_t *defaults, int b_longhelp )
         "                                  - 2: Last pass, does not overwrite stats file\n"
         "                                  - 3: Nth pass, overwrites stats file\n" );
     H0( "      --stats <string>        Filename for 2 pass stats [\"%s\"]\n", defaults->rc.psz_stat_out );
-    H1( "      --rceq <string>         Ratecontrol equation [\"%s\"]\n", defaults->rc.psz_rc_eq );
     H0( "      --qcomp <float>         QP curve compression: 0.0 => CBR, 1.0 => CQP [%.2f]\n", defaults->rc.f_qcompress );
     H1( "      --cplxblur <float>      Reduce fluctuations in QP (before curve compression) [%.1f]\n", defaults->rc.f_complexity_blur );
     H1( "      --qblur <float>         Reduce fluctuations in QP (after curve compression) [%.1f]\n", defaults->rc.f_qblur );
@@ -315,8 +315,10 @@ static void Help( x264_param_t *defaults, int b_longhelp )
     H0( "      --threads <integer>     Parallel encoding\n" );
     H0( "      --thread-input          Run Avisynth in its own thread\n" );
     H1( "      --non-deterministic     Slightly improve quality of SMP, at the cost of repeatability\n" );
+    H1( "      --asm <integer>         Override CPU detection\n" );
     H1( "      --no-asm                Disable all CPU optimizations\n" );
     H1( "      --visualize             Show MB types overlayed on the encoded video\n" );
+    H1( "      --dump-yuv <string>     Save reconstructed frames\n" );
     H1( "      --sps-id <integer>      Set SPS and PPS id numbers [%d]\n", defaults->i_sps_id );
     H1( "      --aud                   Use access unit delimiters\n" );
     H0( "\n" );
@@ -391,6 +393,7 @@ static int  Parse( int argc, char **argv,
             { "qpstep",  required_argument, NULL, 0 },
             { "crf",     required_argument, NULL, 0 },
             { "ref",     required_argument, NULL, 'r' },
+            { "asm",     required_argument, NULL, 0 },
             { "no-asm",  no_argument,       NULL, 0 },
             { "sar",     required_argument, NULL, 0 },
             { "fps",     required_argument, NULL, 0 },
@@ -429,7 +432,6 @@ static int  Parse( int argc, char **argv,
             { "chroma-qp-offset", required_argument, NULL, 0 },
             { "pass",    required_argument, NULL, 'p' },
             { "stats",   required_argument, NULL, 0 },
-            { "rceq",    required_argument, NULL, 0 },
             { "qcomp",   required_argument, NULL, 0 },
             { "qblur",   required_argument, NULL, 0 },
             { "cplxblur",required_argument, NULL, 0 },
@@ -444,6 +446,7 @@ static int  Parse( int argc, char **argv,
             { "verbose", no_argument,       NULL, 'v' },
             { "progress",no_argument,       NULL, OPT_PROGRESS },
             { "visualize",no_argument,      NULL, OPT_VISUALIZE },
+            { "dump-yuv",required_argument, NULL, 0 },
             { "sps-id",  required_argument, NULL, 0 },
             { "aud",     no_argument,       NULL, 0 },
             { "nr",      required_argument, NULL, 0 },
@@ -627,7 +630,7 @@ static int  Parse( int argc, char **argv,
             sscanf( argv[optind++], "%ux%u", &param->i_width, &param->i_height );
         }
     }
-        
+
     if( !(b_avis || b_y4m) && ( !param->i_width || !param->i_height ) )
     {
         fprintf( stderr, "x264 [error]: Rawyuv input requires a resolution.\n" );
@@ -664,7 +667,8 @@ static int  Parse( int argc, char **argv,
     }
 
 #ifdef HAVE_PTHREAD
-    if( b_thread_input || param->i_threads > 1 )
+    if( b_thread_input || param->i_threads > 1
+        || (param->i_threads == 0 && x264_cpu_num_processors() > 1) )
     {
         if( open_file_thread( NULL, &opt->hin, param ) )
         {
@@ -685,11 +689,20 @@ static int  Parse( int argc, char **argv,
 
 static void parse_qpfile( cli_opt_t *opt, x264_picture_t *pic, int i_frame )
 {
-    int num = -1, qp;
+    int num = -1, qp, ret;
     char type;
+    uint64_t file_pos;
     while( num < i_frame )
     {
-        int ret = fscanf( opt->qpfile, "%d %c %d\n", &num, &type, &qp );
+        file_pos = ftell( opt->qpfile );
+        ret = fscanf( opt->qpfile, "%d %c %d\n", &num, &type, &qp );
+               if( num > i_frame || ret == EOF )
+               {
+                       pic->i_type = X264_TYPE_AUTO;
+                       pic->i_qpplus1 = 0;
+                       fseek( opt->qpfile , file_pos , SEEK_SET );
+                       break;
+               }
         if( num < i_frame )
             continue;
         pic->i_qpplus1 = qp+1;
@@ -699,7 +712,7 @@ static void parse_qpfile( cli_opt_t *opt, x264_picture_t *pic, int i_frame )
         else if( type == 'B' ) pic->i_type = X264_TYPE_BREF;
         else if( type == 'b' ) pic->i_type = X264_TYPE_B;
         else ret = 0;
-        if( ret != 3 || qp < 0 || qp > 51 || num > i_frame )
+        if( ret != 3 || qp < -1 || qp > 51 )
         {
             fprintf( stderr, "x264 [error]: can't parse qpfile for frame %d\n", i_frame );
             fclose( opt->qpfile );
@@ -809,7 +822,7 @@ static int  Encode( x264_param_t *param, cli_opt_t *opt )
         i_frame++;
 
         /* update status line (up to 1000 times per input file) */
-        if( opt->b_progress && param->i_log_level < X264_LOG_DEBUG && 
+        if( opt->b_progress && param->i_log_level < X264_LOG_DEBUG &&
             ( i_frame_total ? i_frame * 1000 / i_frame_total > i_progress
                             : i_frame % 10 == 0 ) )
         {
@@ -837,6 +850,7 @@ static int  Encode( x264_param_t *param, cli_opt_t *opt )
     i_end = x264_mdate();
     x264_picture_clean( &pic );
     x264_encoder_close( h );
+    x264_free( mux_buffer );
     fprintf( stderr, "\n" );
 
     if( b_ctrl_c )