mv config.mak config.mak2
sed -e 's/CFLAGS.*/& -fprofile-generate/; s/LDFLAGS.*/& -fprofile-generate/' config.mak2 > config.mak
$(MAKE) x264$(EXE)
- $(foreach V, $(VIDS), $(foreach I, 0 1 2, ./x264$(EXE) $(OPT$I) $(V) --progress -o $(DEVNULL) ;))
+ $(foreach V, $(VIDS), $(foreach I, 0 1 2, ./x264$(EXE) $(OPT$I) $(V) --progress --threads auto -o $(DEVNULL) ;))
rm -f $(SRC2:%.c=%.o)
sed -e 's/CFLAGS.*/& -fprofile-use/; s/LDFLAGS.*/& -fprofile-use/' config.mak2 > config.mak
$(MAKE)
OPT("asm")
p->cpu = atobool(value) ? x264_cpu_detect() : 0;
OPT("threads")
- p->i_threads = atoi(value);
+ {
+ if( !strcmp(value, "auto") )
+ p->i_threads = 0;
+ else
+ p->i_threads = atoi(value);
+ }
OPT("level")
{
if( atof(value) < 6 )
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#if defined(HAVE_PTHREAD) && defined(SYS_LINUX)
+#define _GNU_SOURCE
+#include <sched.h>
+#endif
+
#include <string.h>
#include "common.h"
}
#endif
+
+#if defined(HAVE_PTHREAD) && ( defined(SYS_LINUX) || defined(WIN32) )
+
+int x264_cpu_num_processors( void )
+{
+ int np;
+#if defined(WIN32)
+ uint32_t p_aff, s_aff;
+ GetProcessAffinityMask( GetCurrentProcess(), &p_aff, &s_aff );
+#else
+ uint64_t p_aff;
+ sched_getaffinity( 0, sizeof(p_aff), (cpu_set_t*)&p_aff );
+#endif
+ for( np = 0; p_aff != 0; p_aff >>= 1 )
+ np += p_aff&1;
+ return np;
+}
+
+#else
+
+int x264_cpu_num_processors( void )
+{
+ return 1;
+}
+
+#endif
#define _CPU_H 1
uint32_t x264_cpu_detect( void );
+int x264_cpu_num_processors( void );
/* probably MMX(EXT) centric but .... */
void x264_cpu_restore( uint32_t cpu );
return -1;
}
+ if( h->param.i_threads == 0 )
+ h->param.i_threads = x264_cpu_num_processors();
h->param.i_threads = x264_clip3( h->param.i_threads, 1, X264_SLICE_MAX );
h->param.i_threads = X264_MIN( h->param.i_threads, (h->param.i_height + 15) / 16 );
#ifndef HAVE_PTHREAD