8df79e9d42
Avoid a pthreads dependency via pthread_once() when compiled with --disable-multithread. In addition, this synchronization is disabled for Win32 as well, even though we can be sure that the required primatives exist, so that the requirements on the application when built with --disable-multithread are consistent across platforms. Users using libvpx built with --disable-multithread in a multithreaded context should provide their own synchronization. Updated the documentation to vpx_codec_enc_init_ver() and vpx_codec_dec_init_ver() to note this requirement. Moved the RTCD initialization call to match this description, as previously it didn't happen until the first frame. Change-Id: Id576f6bce2758362188278d3085051c218a56d4a
98 lines
2.2 KiB
C
98 lines
2.2 KiB
C
/*
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
|
|
#include "vpx_config.h"
|
|
#include "vpx_rtcd.h"
|
|
#if ARCH_ARM
|
|
#include "vpx_ports/arm.h"
|
|
#elif ARCH_X86 || ARCH_X86_64
|
|
#include "vpx_ports/x86.h"
|
|
#endif
|
|
#include "vp8/common/onyxc_int.h"
|
|
|
|
#if CONFIG_MULTITHREAD
|
|
#if HAVE_UNISTD_H && !defined(__OS2__)
|
|
#include <unistd.h>
|
|
#elif defined(_WIN32)
|
|
#include <windows.h>
|
|
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
|
|
#elif defined(__OS2__)
|
|
#define INCL_DOS
|
|
#define INCL_DOSSPINLOCK
|
|
#include <os2.h>
|
|
#endif
|
|
#endif
|
|
|
|
#if CONFIG_MULTITHREAD
|
|
static int get_cpu_count()
|
|
{
|
|
int core_count = 16;
|
|
|
|
#if HAVE_UNISTD_H && !defined(__OS2__)
|
|
#if defined(_SC_NPROCESSORS_ONLN)
|
|
core_count = sysconf(_SC_NPROCESSORS_ONLN);
|
|
#elif defined(_SC_NPROC_ONLN)
|
|
core_count = sysconf(_SC_NPROC_ONLN);
|
|
#endif
|
|
#elif defined(_WIN32)
|
|
{
|
|
PGNSI pGNSI;
|
|
SYSTEM_INFO sysinfo;
|
|
|
|
/* Call GetNativeSystemInfo if supported or
|
|
* GetSystemInfo otherwise. */
|
|
|
|
pGNSI = (PGNSI) GetProcAddress(
|
|
GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
|
|
if (pGNSI != NULL)
|
|
pGNSI(&sysinfo);
|
|
else
|
|
GetSystemInfo(&sysinfo);
|
|
|
|
core_count = sysinfo.dwNumberOfProcessors;
|
|
}
|
|
#elif defined(__OS2__)
|
|
{
|
|
ULONG proc_id;
|
|
ULONG status;
|
|
|
|
core_count = 0;
|
|
for (proc_id = 1; ; proc_id++)
|
|
{
|
|
if (DosGetProcessorStatus(proc_id, &status))
|
|
break;
|
|
|
|
if (status == PROC_ONLINE)
|
|
core_count++;
|
|
}
|
|
}
|
|
#else
|
|
/* other platforms */
|
|
#endif
|
|
|
|
return core_count > 0 ? core_count : 1;
|
|
}
|
|
#endif
|
|
|
|
|
|
void vp8_machine_specific_config(VP8_COMMON *ctx)
|
|
{
|
|
#if CONFIG_MULTITHREAD
|
|
ctx->processor_core_count = get_cpu_count();
|
|
#endif /* CONFIG_MULTITHREAD */
|
|
|
|
#if ARCH_ARM
|
|
ctx->cpu_caps = arm_cpu_caps();
|
|
#elif ARCH_X86 || ARCH_X86_64
|
|
ctx->cpu_caps = x86_simd_caps();
|
|
#endif
|
|
}
|