28 |
#include <string.h> |
#include <string.h> |
29 |
#include <time.h> |
#include <time.h> |
30 |
|
|
31 |
|
#if !defined(_WIN32) |
32 |
|
#include <unistd.h> |
33 |
|
#endif |
34 |
|
|
35 |
|
#if defined(__APPLE__) && defined(__MACH__) && !defined(_SC_NPROCESSORS_CONF) |
36 |
|
#include <sys/types.h> |
37 |
|
#include <sys/sysctl.h> |
38 |
|
#ifdef MAX |
39 |
|
#undef MAX |
40 |
|
#endif |
41 |
|
#ifdef MIN |
42 |
|
#undef MIN |
43 |
|
#endif |
44 |
|
#endif |
45 |
|
|
46 |
#include "xvid.h" |
#include "xvid.h" |
47 |
#include "decoder.h" |
#include "decoder.h" |
48 |
#include "encoder.h" |
#include "encoder.h" |
676 |
return XVID_ERR_VERSION; |
return XVID_ERR_VERSION; |
677 |
|
|
678 |
info->actual_version = XVID_VERSION; |
info->actual_version = XVID_VERSION; |
679 |
info->build = "xvid-1.2.0-dev"; |
info->build = "xvid-1.3.0-dev"; |
680 |
info->cpu_flags = detect_cpu_flags(); |
info->cpu_flags = detect_cpu_flags(); |
681 |
info->num_threads = 0; |
info->num_threads = 0; /* single-thread */ |
682 |
|
|
683 |
#if defined(_WIN32) |
#if defined(_WIN32) |
684 |
|
|
685 |
{ |
{ |
686 |
DWORD dwProcessAffinityMask, dwSystemAffinityMask; |
SYSTEM_INFO siSysInfo; |
687 |
if (GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR) &dwProcessAffinityMask, (PDWORD_PTR) &dwSystemAffinityMask)) { |
GetSystemInfo(&siSysInfo); |
688 |
int i; |
info->num_threads = siSysInfo.dwNumberOfProcessors; /* number of _logical_ cores */ |
|
for(i=0; i<32; i++) { |
|
|
if ((dwProcessAffinityMask & (1<<i))) |
|
|
info->num_threads++; |
|
|
} |
|
689 |
} |
} |
|
} |
|
|
#else |
|
690 |
|
|
691 |
#include <unistd.h> |
#elif defined(_SC_NPROCESSORS_CONF) /* should be available on Apple too actually */ |
692 |
|
|
693 |
info->num_threads = sysconf(_SC_NPROCESSORS_CONF); |
info->num_threads = sysconf(_SC_NPROCESSORS_CONF); |
694 |
|
|
695 |
|
#elif defined(__APPLE__) && defined(__MACH__) |
696 |
|
|
697 |
|
{ |
698 |
|
size_t len; |
699 |
|
int mib[2], ncpu; |
700 |
|
|
701 |
|
mib[0] = CTL_HW; |
702 |
|
mib[1] = HW_NCPU; |
703 |
|
len = sizeof(ncpu); |
704 |
|
if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == 0) |
705 |
|
info -> num_threads = ncpu; |
706 |
|
else |
707 |
|
info -> num_threads = 1; |
708 |
|
} |
709 |
|
|
710 |
#endif |
#endif |
711 |
|
|
712 |
return 0; |
return 0; |