Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
106
Src/libvp6/corelibs/sal/win32/duck_io.c
Normal file
106
Src/libvp6/corelibs/sal/win32/duck_io.c
Normal file
|
@ -0,0 +1,106 @@
|
|||
/***********************************************\
|
||||
??? duck_io.c
|
||||
\***********************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include "duck_io.h"
|
||||
#include "duck_hfb.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
int read_count;
|
||||
|
||||
|
||||
int duck_readFinished(int han, int flag)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int duck_open(const char *name, unsigned long userData)
|
||||
{
|
||||
int f;
|
||||
FILE *fp;
|
||||
unsigned long x;
|
||||
|
||||
read_count = 0;
|
||||
|
||||
fp = fopen(name, "rb");
|
||||
|
||||
if (!fp)
|
||||
assert(0);
|
||||
|
||||
x = (unsigned long ) fp;
|
||||
|
||||
/* high bit is set, the cast is a bad idea ! */
|
||||
if (x & 0x90000000)
|
||||
assert(0);
|
||||
|
||||
f = (int ) x;
|
||||
|
||||
return f;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void duck_close(int handle)
|
||||
{
|
||||
fclose((FILE *) handle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long totalRead = 0;
|
||||
static long tellNo = 0;
|
||||
long duck_read(int handle,unsigned char *buffer,long bytes)
|
||||
{
|
||||
int x;
|
||||
|
||||
|
||||
if (buffer == NULL){
|
||||
duck_seek(handle,bytes,SEEK_CUR);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
tellNo = ftell((FILE *) handle);
|
||||
|
||||
if (bytes == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
x = fread(buffer,sizeof(char) ,bytes, (FILE *) handle);
|
||||
|
||||
|
||||
if (feof((FILE *) handle) && (x != (int ) bytes))
|
||||
return -1;
|
||||
|
||||
|
||||
totalRead += x;
|
||||
|
||||
if (x == -1L)
|
||||
assert(0);
|
||||
|
||||
return x ;
|
||||
}
|
||||
|
||||
|
||||
long duck_seek(int handle,long offset,int origin)
|
||||
{
|
||||
long x = fseek((FILE *) handle,offset,origin);
|
||||
|
||||
tellNo = ftell((FILE *) handle);
|
||||
|
||||
return tellNo ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
70
Src/libvp6/corelibs/sal/win32/duck_io32.c
Normal file
70
Src/libvp6/corelibs/sal/win32/duck_io32.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
/***********************************************\
|
||||
??? duck_io.c
|
||||
\***********************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "duck_io.h"
|
||||
|
||||
int duck_open(const char *name, unsigned long userData)
|
||||
{
|
||||
char filename[255];
|
||||
(void) userData;
|
||||
|
||||
if(name[strlen(name)-4] != '.') { /*no extension, try .AVI */
|
||||
sprintf(filename,"%s.AVI",name);
|
||||
//f = open(filename,O_BINARY|O_RDONLY);
|
||||
//return(f);
|
||||
}else
|
||||
strcpy(filename,name);
|
||||
//return(open(filename,O_BINARY|O_RDONLY));
|
||||
return (int)CreateFile(filename,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_FLAG_NO_BUFFERING,NULL);
|
||||
}
|
||||
|
||||
void duck_close(int handle)
|
||||
{
|
||||
//close(handle);
|
||||
CloseHandle((void *)handle);
|
||||
}
|
||||
|
||||
long duck_read(int handle,unsigned char *buffer,long bytes)
|
||||
{
|
||||
DWORD bytesRead;
|
||||
|
||||
if (buffer == NULL){
|
||||
duck_seek(handle,bytes,SEEK_CUR);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
ReadFile((void *)handle,buffer,bytes,&bytesRead,NULL);
|
||||
//return(read(handle,buffer,bytes));
|
||||
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
int64_t duck_seek(int handle,int64_t offset,int origin)
|
||||
{
|
||||
//return(lseek(handle,offset,origin));
|
||||
return(SetFilePointer((HANDLE) handle,(LONG)offset,NULL,origin));
|
||||
}
|
||||
|
||||
int duck_readFinished(int han, int flag)
|
||||
{
|
||||
(void)han; // not used;
|
||||
(void)flag; // not used;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void set_iofuncs()
|
||||
{
|
||||
|
||||
// HFB_Setopen(duck_open);
|
||||
// HFB_Setclose(duck_close);
|
||||
// HFB_Setread(duck_read);
|
||||
// HFB_Setseek(duck_seek);
|
||||
}
|
132
Src/libvp6/corelibs/sal/win32/duck_mem.c
Normal file
132
Src/libvp6/corelibs/sal/win32/duck_mem.c
Normal file
|
@ -0,0 +1,132 @@
|
|||
/***********************************************\
|
||||
??? duck_mem.c
|
||||
\***********************************************/
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <dos.h>
|
||||
#include <time.h>
|
||||
#include <malloc.h>
|
||||
#include "duck_mem.h"
|
||||
#include "duck_io.h"
|
||||
//#include "duck_hfb.h"
|
||||
#include "duck_dxl.h"
|
||||
|
||||
//#define CHECK_MEM
|
||||
|
||||
#ifdef CHECK_MEM
|
||||
#include <map>
|
||||
#include "debug.h"
|
||||
#endif
|
||||
|
||||
#ifdef CHECK_MEM
|
||||
struct comp
|
||||
{
|
||||
bool operator()(void* v1, void* v2) const
|
||||
{
|
||||
return v1 < v2;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CHECK_MEM
|
||||
std::map<void*, size_t, struct comp> pointers;
|
||||
int g_allocs = 0;
|
||||
int g_frees = 0;
|
||||
#endif
|
||||
|
||||
void *duck_memmove( void *dst, const void *src, size_t length )
|
||||
{
|
||||
return memmove(dst, src, length);
|
||||
}
|
||||
|
||||
void *duck_malloc(size_t size, dmemType foo)
|
||||
{
|
||||
void *temp = malloc(size);
|
||||
|
||||
#ifdef CHECK_MEM
|
||||
g_allocs++;
|
||||
TRACE("a=%d\t%d\n", g_allocs, (int)temp);
|
||||
pointers[temp] = size;
|
||||
#endif
|
||||
return temp;
|
||||
}
|
||||
|
||||
void *duck_memset( void *dest, int c, size_t count )
|
||||
{
|
||||
return((void *) memset(dest, c, count));
|
||||
}
|
||||
|
||||
void *duck_calloc(size_t n,size_t size, dmemType foo)
|
||||
{
|
||||
void *temp = calloc(n, size);
|
||||
|
||||
#ifdef CHECK_MEM
|
||||
g_allocs++;
|
||||
TRACE("a=%d\t%d\n", g_allocs, (int)temp);
|
||||
pointers[temp] = size;
|
||||
#endif
|
||||
return temp;
|
||||
}
|
||||
|
||||
void duck_free(void *old_blk)
|
||||
{
|
||||
#ifdef CHECK_MEM
|
||||
g_frees++;
|
||||
TRACE("f=%d\t%d\n", g_frees, (int)old_blk);
|
||||
if(!pointers.erase(old_blk))
|
||||
assert(0);
|
||||
#endif
|
||||
free(old_blk);
|
||||
}
|
||||
|
||||
void* duck_realloc(void *src, size_t newSize, size_t oldSize)
|
||||
{
|
||||
void *temp;
|
||||
if(newSize <= oldSize)
|
||||
return src;
|
||||
|
||||
#ifdef CHECK_MEM
|
||||
temp = duck_malloc(newSize, DMEM_GENERAL);
|
||||
duck_memcpy(temp, src, oldSize);
|
||||
duck_free(src);
|
||||
#else
|
||||
temp = realloc(src, newSize);
|
||||
#endif
|
||||
return temp;
|
||||
}
|
||||
|
||||
void *duck_memcpy(void *dest, const void *source, size_t length)
|
||||
{
|
||||
return memcpy(dest,source,length);
|
||||
}
|
||||
|
||||
void *duck_memcpy64(void *dest, const void *source, int64_t length)
|
||||
{
|
||||
/* Not fully 64 bit compliant */
|
||||
return memcpy(dest,source,(size_t)length);
|
||||
}
|
||||
|
||||
|
||||
int duck_strcmp(const char *one, const char *two)
|
||||
{
|
||||
return strcmp(one, two);
|
||||
}
|
||||
|
||||
void set_memfuncs()
|
||||
{
|
||||
#if defined(DXV_DLL)
|
||||
DXV_Setmalloc(malloc);
|
||||
DXV_Setcalloc(calloc);
|
||||
DXV_Setfree(free);
|
||||
#endif
|
||||
|
||||
#if defined(HFB_DLL)
|
||||
HFB_Setmalloc(malloc);
|
||||
HFB_Setcalloc(calloc);
|
||||
HFB_Setfree(free);
|
||||
#endif
|
||||
}
|
19
Src/libvp6/corelibs/sal/win32/duck_str.c
Normal file
19
Src/libvp6/corelibs/sal/win32/duck_str.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/***********************************************\
|
||||
??? duck_io.c
|
||||
\***********************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "duck_io.h"
|
||||
#include "duck_hfb.h"
|
||||
|
||||
int duck_strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
return strcmp(s1, s2);
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue