mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-28 03:34:06 +00:00
Add --cpuid parameter to disable runtime optimizations.
This commit is contained in:
parent
b32867be2a
commit
75a137c1e9
|
@ -95,6 +95,7 @@ int config_init(config *cfg)
|
||||||
cfg->slice_addresses_in_ts[0] = 0;
|
cfg->slice_addresses_in_ts[0] = 0;
|
||||||
|
|
||||||
cfg->threads = 0;
|
cfg->threads = 0;
|
||||||
|
cfg->cpuid = 1;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -438,6 +439,8 @@ static int config_parse(config *cfg, const char *name, const char *value)
|
||||||
error = !parse_slice_specification(value, &cfg->slice_count, &cfg->slice_addresses_in_ts);
|
error = !parse_slice_specification(value, &cfg->slice_count, &cfg->slice_addresses_in_ts);
|
||||||
else if OPT("threads")
|
else if OPT("threads")
|
||||||
cfg->threads = atoi(value);
|
cfg->threads = atoi(value);
|
||||||
|
else if OPT("cpuid")
|
||||||
|
cfg->cpuid = atoi(value);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
#undef OPT
|
#undef OPT
|
||||||
|
@ -492,6 +495,7 @@ int config_read(config *cfg,int argc, char *argv[])
|
||||||
{ "owf", required_argument, NULL, 0 },
|
{ "owf", required_argument, NULL, 0 },
|
||||||
{ "slice-addresses", required_argument, NULL, 0 },
|
{ "slice-addresses", required_argument, NULL, 0 },
|
||||||
{ "threads", required_argument, NULL, 0 },
|
{ "threads", required_argument, NULL, 0 },
|
||||||
|
{ "cpuid", required_argument, NULL, 0 },
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ typedef struct
|
||||||
int32_t* slice_addresses_in_ts;
|
int32_t* slice_addresses_in_ts;
|
||||||
|
|
||||||
int32_t threads;
|
int32_t threads;
|
||||||
|
int32_t cpuid;
|
||||||
} config;
|
} config;
|
||||||
|
|
||||||
/* Function definitions */
|
/* Function definitions */
|
||||||
|
|
|
@ -79,13 +79,6 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
CHECKPOINTS_INIT();
|
CHECKPOINTS_INIT();
|
||||||
|
|
||||||
//Initialize strategies
|
|
||||||
if (!strategyselector_init()) {
|
|
||||||
fprintf(stderr, "Failed to initialize strategies.\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Handle configuration
|
// Handle configuration
|
||||||
cfg = config_alloc();
|
cfg = config_alloc();
|
||||||
|
|
||||||
|
@ -125,6 +118,7 @@ int main(int argc, char *argv[])
|
||||||
" --aud : Use access unit delimiters\n"
|
" --aud : Use access unit delimiters\n"
|
||||||
" --cqmfile <string> : Custom Quantization Matrices from a file\n"
|
" --cqmfile <string> : Custom Quantization Matrices from a file\n"
|
||||||
" --debug <string> : Output encoders reconstruction.\n"
|
" --debug <string> : Output encoders reconstruction.\n"
|
||||||
|
" --cpuid <integer> : Disable runtime cpu optimizations with value 0.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Video Usability Information:\n"
|
" Video Usability Information:\n"
|
||||||
" --sar <width:height> : Specify Sample Aspect Ratio\n"
|
" --sar <width:height> : Specify Sample Aspect Ratio\n"
|
||||||
|
@ -202,6 +196,12 @@ int main(int argc, char *argv[])
|
||||||
goto exit_failure;
|
goto exit_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Initialize strategies
|
||||||
|
if (!strategyselector_init(cfg->cpuid)) {
|
||||||
|
fprintf(stderr, "Failed to initialize strategies.\n");
|
||||||
|
goto exit_failure;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the input file name is a dash, this means stdin
|
// Check if the input file name is a dash, this means stdin
|
||||||
if (!strcmp(cfg->input, "-")) {
|
if (!strcmp(cfg->input, "-")) {
|
||||||
input = stdin;
|
input = stdin;
|
||||||
|
|
|
@ -32,13 +32,13 @@
|
||||||
|
|
||||||
hardware_flags g_hardware_flags;
|
hardware_flags g_hardware_flags;
|
||||||
|
|
||||||
static void set_hardware_flags();
|
static void set_hardware_flags(int32_t cpuid);
|
||||||
static void* strategyselector_choose_for(const strategy_list * const strategies, const char * const strategy_type);
|
static void* strategyselector_choose_for(const strategy_list * const strategies, const char * const strategy_type);
|
||||||
|
|
||||||
//Strategies to include (add new file here)
|
//Strategies to include (add new file here)
|
||||||
|
|
||||||
//Returns 1 if successful
|
//Returns 1 if successful
|
||||||
int strategyselector_init() {
|
int strategyselector_init(int32_t cpuid) {
|
||||||
const strategy_to_select *cur_strategy_to_select = strategies_to_select;
|
const strategy_to_select *cur_strategy_to_select = strategies_to_select;
|
||||||
strategy_list strategies;
|
strategy_list strategies;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ int strategyselector_init() {
|
||||||
strategies.count = 0;
|
strategies.count = 0;
|
||||||
strategies.strategies = NULL;
|
strategies.strategies = NULL;
|
||||||
|
|
||||||
set_hardware_flags();
|
set_hardware_flags(cpuid);
|
||||||
|
|
||||||
//Add new register function here
|
//Add new register function here
|
||||||
if (!strategy_register_picture(&strategies)) {
|
if (!strategy_register_picture(&strategies)) {
|
||||||
|
@ -232,7 +232,7 @@ out_close:
|
||||||
}
|
}
|
||||||
#endif //COMPILE_POWERPC
|
#endif //COMPILE_POWERPC
|
||||||
|
|
||||||
static void set_hardware_flags() {
|
static void set_hardware_flags(int32_t cpuid) {
|
||||||
memset(&g_hardware_flags, 0, sizeof(g_hardware_flags));
|
memset(&g_hardware_flags, 0, sizeof(g_hardware_flags));
|
||||||
|
|
||||||
g_hardware_flags.arm = COMPILE_ARM;
|
g_hardware_flags.arm = COMPILE_ARM;
|
||||||
|
@ -240,7 +240,7 @@ static void set_hardware_flags() {
|
||||||
g_hardware_flags.powerpc = COMPILE_POWERPC;
|
g_hardware_flags.powerpc = COMPILE_POWERPC;
|
||||||
|
|
||||||
#if COMPILE_INTEL
|
#if COMPILE_INTEL
|
||||||
{
|
if (cpuid) {
|
||||||
unsigned int eax = 0, ebx = 0, ecx = 0, edx =0;
|
unsigned int eax = 0, ebx = 0, ecx = 0, edx =0;
|
||||||
/* CPU feature bits */
|
/* CPU feature bits */
|
||||||
enum { BIT_SSE3 = 0, BIT_SSSE3 = 9, BIT_SSE41 = 19, BIT_SSE42 = 20,
|
enum { BIT_SSE3 = 0, BIT_SSSE3 = 9, BIT_SSE41 = 19, BIT_SSE42 = 20,
|
||||||
|
@ -290,7 +290,7 @@ static void set_hardware_flags() {
|
||||||
get_cpuid(7, &eax, &ebx, &ecx, &edx);
|
get_cpuid(7, &eax, &ebx, &ecx, &edx);
|
||||||
if (ebx & (1 << 5)) g_hardware_flags.intel_flags.avx2 = 1;
|
if (ebx & (1 << 5)) g_hardware_flags.intel_flags.avx2 = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Compiled: INTEL, flags:");
|
fprintf(stderr, "Compiled: INTEL, flags:");
|
||||||
#if COMPILE_INTEL_MMX
|
#if COMPILE_INTEL_MMX
|
||||||
|
@ -320,7 +320,7 @@ static void set_hardware_flags() {
|
||||||
#if COMPILE_INTEL_AVX2
|
#if COMPILE_INTEL_AVX2
|
||||||
fprintf(stderr, " AVX2");
|
fprintf(stderr, " AVX2");
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "\nRun on : INTEL, flags:");
|
fprintf(stderr, "\nDetected: INTEL, flags:");
|
||||||
if (g_hardware_flags.intel_flags.mmx) fprintf(stderr, " MMX");
|
if (g_hardware_flags.intel_flags.mmx) fprintf(stderr, " MMX");
|
||||||
if (g_hardware_flags.intel_flags.sse) fprintf(stderr, " SSE");
|
if (g_hardware_flags.intel_flags.sse) fprintf(stderr, " SSE");
|
||||||
if (g_hardware_flags.intel_flags.sse2) fprintf(stderr, " SSE2");
|
if (g_hardware_flags.intel_flags.sse2) fprintf(stderr, " SSE2");
|
||||||
|
@ -331,17 +331,19 @@ static void set_hardware_flags() {
|
||||||
if (g_hardware_flags.intel_flags.avx) fprintf(stderr, " AVX");
|
if (g_hardware_flags.intel_flags.avx) fprintf(stderr, " AVX");
|
||||||
if (g_hardware_flags.intel_flags.avx2) fprintf(stderr, " AVX2");
|
if (g_hardware_flags.intel_flags.avx2) fprintf(stderr, " AVX2");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
|
||||||
#endif //COMPILE_INTEL
|
#endif //COMPILE_INTEL
|
||||||
|
|
||||||
#if COMPILE_POWERPC
|
#if COMPILE_POWERPC
|
||||||
|
if (cpuid) {
|
||||||
g_hardware_flags.powerpc_flags.altivec = altivec_available();
|
g_hardware_flags.powerpc_flags.altivec = altivec_available();
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Compiled: PowerPC, flags:");
|
fprintf(stderr, "Compiled: PowerPC, flags:");
|
||||||
#if COMPILE_POWERPC_ALTIVEC
|
#if COMPILE_POWERPC_ALTIVEC
|
||||||
fprintf(stderr, " AltiVec");
|
fprintf(stderr, " AltiVec");
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "\nRun on : PowerPC, flags:");
|
fprintf(stderr, "\nDetected: PowerPC, flags:");
|
||||||
if (g_hardware_flags.powerpc_flags.altivec) fprintf(stderr, " AltiVec");
|
if (g_hardware_flags.powerpc_flags.altivec) fprintf(stderr, " AltiVec");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
* along with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
|
* along with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
#if defined(_DEBUG) && !defined(DEBUG_STRATEGYSELECTOR)
|
#if defined(_DEBUG) && !defined(DEBUG_STRATEGYSELECTOR)
|
||||||
# define DEBUG_STRATEGYSELECTOR
|
# define DEBUG_STRATEGYSELECTOR
|
||||||
#endif
|
#endif
|
||||||
|
@ -136,7 +138,7 @@ typedef struct {
|
||||||
extern hardware_flags g_hardware_flags;
|
extern hardware_flags g_hardware_flags;
|
||||||
|
|
||||||
|
|
||||||
int strategyselector_init();
|
int strategyselector_init(int32_t cpuid);
|
||||||
void strategyselector_free();
|
void strategyselector_free();
|
||||||
int strategyselector_register(void *opaque, const char *type, const char *strategy_name, int priority, void *fptr);
|
int strategyselector_register(void *opaque, const char *type, const char *strategy_name, int priority, void *fptr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue