#define avs_close dlclose
#define avs_address dlsym
#else
-#include <windows.h>
#define avs_open() LoadLibraryW( L"avisynth" )
#define avs_close FreeLibrary
#define avs_address GetProcAddress
#ifdef _WIN32
#include <io.h>
-#include <windows.h>
#elif HAVE_MMAP
#include <sys/mman.h>
#include <unistd.h>
SYSTEM_INFO si;
GetSystemInfo( &si );
h->align_mask = si.dwAllocationGranularity - 1;
+ h->prefetch_virtual_memory = (void*)GetProcAddress( GetModuleHandleW( L"kernel32.dll" ), "PrefetchVirtualMemory" );
+ h->process_handle = GetCurrentProcess();
h->map_handle = CreateFileMappingW( osfhandle, NULL, PAGE_READONLY, 0, 0, NULL );
return !h->map_handle;
}
size += align;
#ifdef _WIN32
uint8_t *base = MapViewOfFile( h->map_handle, FILE_MAP_READ, offset >> 32, offset, size );
- /* TODO: Would PrefetchVirtualMemory() (only available on Win8+) be beneficial? */
if( base )
+ {
+ /* PrefetchVirtualMemory() is only available on Windows 8 and newer. */
+ if( h->prefetch_virtual_memory )
+ {
+ struct { void *addr; size_t size; } mem_range = { base, size };
+ h->prefetch_virtual_memory( h->process_handle, 1, &mem_range, 0 );
+ }
return base + align;
+ }
#else
uint8_t *base = mmap( NULL, size, PROT_READ, MAP_PRIVATE, h->fd, offset );
if( base != MAP_FAILED )
#include "x264cli.h"
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
/* options that are used by only some demuxers */
typedef struct
{
{
int align_mask;
#ifdef _WIN32
- void *map_handle;
+ BOOL (WINAPI *prefetch_virtual_memory)( HANDLE, ULONG_PTR, PVOID, ULONG );
+ HANDLE process_handle;
+ HANDLE map_handle;
#elif HAVE_MMAP
int fd;
#endif