*****************************************************************************/
#include <stdarg.h>
+#include <ctype.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#define OPT2(STR0, STR1) else if( !strcmp( name, STR0 ) || !strcmp( name, STR1 ) )
if(0);
OPT("asm")
- p->cpu = atobool(value) ? x264_cpu_detect() : 0;
+ {
+ p->cpu = isdigit(value[0]) ? atoi(value) :
+ !strcmp(value, "auto") || atobool(value) ? x264_cpu_detect() : 0;
+ if( b_error )
+ {
+ char *buf = strdup(value);
+ char *tok, *saveptr, *init;
+ b_error = 0;
+ p->cpu = 0;
+ for( init=buf; (tok=strtok_r(init, ",", &saveptr)); init=NULL )
+ {
+ for( i=0; x264_cpu_names[i].flags && strcasecmp(tok, x264_cpu_names[i].name); i++ );
+ p->cpu |= x264_cpu_names[i].flags;
+ if( !x264_cpu_names[i].flags )
+ b_error = 1;
+ }
+ free( buf );
+ }
+ }
OPT("threads")
{
if( !strcmp(value, "auto") )
#include "common.h"
+const struct {
+ const char name[8];
+ int flags;
+} x264_cpu_names[] = {
+ {"MMX", X264_CPU_MMX},
+ {"MMX2", X264_CPU_MMX|X264_CPU_MMXEXT},
+ {"MMXEXT", X264_CPU_MMX|X264_CPU_MMXEXT},
+ {"SSE", X264_CPU_MMX|X264_CPU_MMXEXT|X264_CPU_SSE},
+ {"SSE1", X264_CPU_MMX|X264_CPU_MMXEXT|X264_CPU_SSE},
+ {"SSE2", X264_CPU_MMX|X264_CPU_MMXEXT|X264_CPU_SSE|X264_CPU_SSE2},
+ {"SSE3", X264_CPU_MMX|X264_CPU_MMXEXT|X264_CPU_SSE|X264_CPU_SSE2|X264_CPU_SSE3},
+ {"SSSE3", X264_CPU_MMX|X264_CPU_MMXEXT|X264_CPU_SSE|X264_CPU_SSE2|X264_CPU_SSE3|X264_CPU_SSSE3},
+ {"3DNow", X264_CPU_3DNOW},
+ {"Altivec", X264_CPU_ALTIVEC},
+ {"Cache32", X264_CPU_CACHELINE_SPLIT|X264_CPU_CACHELINE_32},
+ {"Cache64", X264_CPU_CACHELINE_SPLIT|X264_CPU_CACHELINE_64},
+ {"", 0},
+};
+
#ifdef HAVE_MMX
extern int x264_cpu_cpuid_test( void );
extern uint32_t x264_cpu_cpuid( uint32_t op, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx );
#define x264_stack_align(func,arg) func(arg)
#endif
+extern const struct {
+ const char name[8];
+ int flags;
+} x264_cpu_names[];
+
#endif
#include <io.h> // _setmode()
#include <fcntl.h> // _O_BINARY
#define inline __inline
+#define strcasecmp stricmp
#define strncasecmp strnicmp
#define snprintf _snprintf
#define fseek _fseeki64
x264_t *x264_encoder_open ( x264_param_t *param )
{
x264_t *h = x264_malloc( sizeof( x264_t ) );
+ char buf[1000], *p;
int i;
memset( h, 0, sizeof( x264_t ) );
mbcmp_init( h );
- x264_log( h, X264_LOG_INFO, "using cpu capabilities: %s%s%s%s%s%s%s%s%s%s\n",
- param->cpu&X264_CPU_MMX ? "MMX " : "",
- param->cpu&X264_CPU_MMXEXT ? "MMXEXT " : "",
- param->cpu&X264_CPU_SSE ? "SSE " : "",
- param->cpu&X264_CPU_SSE2 ? "SSE2 " : "",
- param->cpu&X264_CPU_SSE3 ? "SSE3 " : "",
- param->cpu&X264_CPU_SSSE3 ? "SSSE3 " : "",
- param->cpu&X264_CPU_3DNOW ? "3DNow! " : "",
- param->cpu&X264_CPU_ALTIVEC ? "Altivec " : "",
- param->cpu&X264_CPU_CACHELINE_SPLIT ?
- param->cpu&X264_CPU_CACHELINE_32 ? "Cache32 " :
- param->cpu&X264_CPU_CACHELINE_64 ? "Cache64 " : "Cache? " : "",
- param->cpu ? "" : "none!" );
+ p = buf + sprintf( buf, "using cpu capabilities:" );
+ for( i=0; x264_cpu_names[i].flags; i++ )
+ if( (param->cpu & x264_cpu_names[i].flags) == x264_cpu_names[i].flags
+ && (!i || x264_cpu_names[i].flags != x264_cpu_names[i-1].flags) )
+ p += sprintf( p, " %s", x264_cpu_names[i].name );
+ if( !param->cpu )
+ p += sprintf( p, " none!" );
+ x264_log( h, X264_LOG_INFO, "%s\n", buf );
h->out.i_nal = 0;
h->out.i_bitstream = X264_MAX( 1000000, h->param.i_width * h->param.i_height * 4
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( " --sps-id <integer> Set SPS and PPS id numbers [%d]\n", defaults->i_sps_id );
{ "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 },