mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Win32 support for av_file_map()
Originally committed as revision 26221 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
db61329607
commit
73f6d31e6c
2
configure
vendored
2
configure
vendored
@ -1040,6 +1040,7 @@ HAVE_LIST="
|
|||||||
machine_ioctl_bt848_h
|
machine_ioctl_bt848_h
|
||||||
machine_ioctl_meteor_h
|
machine_ioctl_meteor_h
|
||||||
malloc_h
|
malloc_h
|
||||||
|
MapViewOfFile
|
||||||
memalign
|
memalign
|
||||||
mkstemp
|
mkstemp
|
||||||
mmap
|
mmap
|
||||||
@ -2687,6 +2688,7 @@ check_func_headers io.h setmode
|
|||||||
check_func_headers lzo/lzo1x.h lzo1x_999_compress
|
check_func_headers lzo/lzo1x.h lzo1x_999_compress
|
||||||
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
|
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
|
||||||
check_func_headers windows.h GetProcessTimes
|
check_func_headers windows.h GetProcessTimes
|
||||||
|
check_func_headers windows.h MapViewOfFile
|
||||||
check_func_headers windows.h VirtualAlloc
|
check_func_headers windows.h VirtualAlloc
|
||||||
|
|
||||||
check_header conio.h
|
check_header conio.h
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#if HAVE_MMAP
|
#if HAVE_MMAP
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#elif HAVE_MAPVIEWOFFILE
|
||||||
|
#include <io.h>
|
||||||
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -81,6 +84,27 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
*bufptr = ptr;
|
*bufptr = ptr;
|
||||||
|
#elif HAVE_MAPVIEWOFFILE
|
||||||
|
{
|
||||||
|
HANDLE mh, fh = (HANDLE)_get_osfhandle(fd);
|
||||||
|
|
||||||
|
mh = CreateFileMapping(fh, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||||
|
if (!mh) {
|
||||||
|
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in CreateFileMapping()\n");
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = MapViewOfFile(mh, FILE_MAP_READ, 0, 0, *size);
|
||||||
|
CloseHandle(mh);
|
||||||
|
if (!ptr) {
|
||||||
|
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in MapViewOfFile()\n");
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*bufptr = ptr;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
*bufptr = av_malloc(*size);
|
*bufptr = av_malloc(*size);
|
||||||
if (!*bufptr) {
|
if (!*bufptr) {
|
||||||
@ -99,6 +123,8 @@ void av_file_unmap(uint8_t *bufptr, size_t size)
|
|||||||
{
|
{
|
||||||
#if HAVE_MMAP
|
#if HAVE_MMAP
|
||||||
munmap(bufptr, size);
|
munmap(bufptr, size);
|
||||||
|
#elif HAVE_MAPVIEWOFFILE
|
||||||
|
UnmapViewOfFile(bufptr);
|
||||||
#else
|
#else
|
||||||
av_free(bufptr);
|
av_free(bufptr);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user