vd_realvid.c
来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· C语言 代码 · 共 550 行 · 第 1/2 页
C
550 行
#include <uclib.h>#include <uclib.h>#include "config.h"#define HAVE_LIBDL#ifdef HAVE_LIBDL//#include <dlfcn.h>#endif#include "mp_msg.h"#include "help_mp.h"#include "vd_internal.h"#include "loader/wine/windef.h"#undef memcpy#define memcpy uc_memcpystatic vd_info_t info = { "RealVideo decoder", "realvid", "Alex Beregszaszi", "Florian Schneider, Arpad Gereoffy, Alex Beregszaszi, Donnie Smith", "binary real video codecs"};#ifndef HX_RESULTtypedef int HX_RESULT;#endif /* #ifndef HX_RESULT */extern HX_RESULT _RV40toYUV420CustomMessage(unsigned int *msg_id, void *global);extern HX_RESULT _RV40toYUV420HiveMessage(unsigned int *msg_id, void *global);extern HX_RESULT _RV40toYUV420Transform ( unsigned char *pRV20Packets, unsigned char *pDecodedFrameBuffer, void *pInputParams, void *pOutputParams, void *global );extern HX_RESULT _RV40toYUV420Free(void *global);extern HX_RESULT _RV40toYUV420Init(void *prv10Init, void **decoderState);LIBVD_EXTERN(realvid)#ifdef USE_16M_SDRAMvd_functions_t *func_table (void){ return &mpcodecs_vd_realvid;}#endif/* * Structures for data packets. These used to be tables of unsigned ints, but * that does not work on 64 bit platforms (e.g. Alpha). The entries that are * pointers get truncated. Pointers on 64 bit platforms are 8 byte longs. * So we have to use structures so the compiler will assign the proper space * for the pointer. */typedef struct cmsg_data_s { uint32_t data1; uint32_t data2; uint32_t* dimensions;} cmsg_data_t;typedef struct transform_in_s { uint32_t len; uint32_t unknown1; uint32_t chunks; uint32_t* extra; uint32_t unknown2; uint32_t timestamp;} transform_in_t;static unsigned long (*rvyuv_custom_message)(cmsg_data_t* ,void*);static unsigned long (*rvyuv_free)(void*);static unsigned long (*rvyuv_init)(void*, void*); // initdata,contextstatic unsigned long (*rvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*);#ifdef USE_WIN32DLLstatic unsigned long WINAPI (*wrvyuv_custom_message)(cmsg_data_t* ,void*);static unsigned long WINAPI (*wrvyuv_free)(void*);static unsigned long WINAPI (*wrvyuv_init)(void*, void*); // initdata,contextstatic unsigned long WINAPI (*wrvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*);#endifstatic void *rv_handle=NULL;static int inited=0;static uint32_t *buffer = NULL;//static int bufsz = 0;#ifdef USE_WIN32DLLstatic int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */#endifvoid *__builtin_vec_new(unsigned long size) { return malloc(size);}void __builtin_vec_delete(void *mem) { free(mem);}void __pure_virtual(void) { printf("FATAL: __pure_virtual() called!\n");// exit(1);}#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)void ___brk_addr(void) {exit(0);}char **__environ={NULL};#undef stderrFILE *stderr=NULL;#endif// to set/get/query special features/parametersstatic int control(sh_video_t *sh,int cmd,void* arg,...){// switch(cmd){// case VDCTRL_QUERY_MAX_PP_LEVEL:// return 9;// case VDCTRL_SET_PP_LEVEL:// vfw_set_postproc(sh,10*(*((int*)arg)));// return CONTROL_OK;// } return CONTROL_UNKNOWN;}/* exits program when failure */#ifdef HAVE_LIBDLstatic int load_syms_linux(char *path) {#if 0 void *handle; mp_msg(MSGT_DECVIDEO,MSGL_V, "opening shared obj '%s'\n", path); handle = dlopen (path, RTLD_LAZY); if (!handle) { mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error: %s\n",dlerror()); return 0; } rvyuv_custom_message = dlsym(handle, "RV20toYUV420CustomMessage"); rvyuv_free = dlsym(handle, "RV20toYUV420Free"); rvyuv_init = dlsym(handle, "RV20toYUV420Init"); rvyuv_transform = dlsym(handle, "RV20toYUV420Transform"); if(rvyuv_custom_message && rvyuv_free && rvyuv_init && rvyuv_transform) { rv_handle = handle; return 1; } rvyuv_custom_message = dlsym(handle, "RV40toYUV420CustomMessage"); rvyuv_free = dlsym(handle, "RV40toYUV420Free"); rvyuv_init = dlsym(handle, "RV40toYUV420Init"); rvyuv_transform = dlsym(handle, "RV40toYUV420Transform");#endif //rvyuv_custom_message = dlsym(handle, "RV40toYUV420CustomMessage"); //rvyuv_free = dlsym(handle, "RV40toYUV420Free"); //rvyuv_init = dlsym(handle, "RV40toYUV420Init"); //rvyuv_transform = dlsym(handle, "RV40toYUV420Transform"); rvyuv_custom_message = _RV40toYUV420CustomMessage; rvyuv_free = _RV40toYUV420Free; rvyuv_init = _RV40toYUV420Init; rvyuv_transform = _RV40toYUV420Transform; if(rvyuv_custom_message && rvyuv_free && rvyuv_init && rvyuv_transform) { rv_handle = 0; return 1; } mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n"); //dlclose(handle); return 0;}#endif#ifdef USE_WIN32DLL#ifdef WIN32_LOADER#include "loader/ldt_keeper.h"#endifvoid* WINAPI LoadLibraryA(char* name);void* WINAPI GetProcAddress(void* handle,char* func);int WINAPI FreeLibrary(void *handle);#ifndef WIN32_LOADERvoid * WINAPI GetModuleHandleA(char *);static int patch_dll(uint8_t *patchpos, const uint8_t *oldcode, const uint8_t *newcode, int codesize) { void *handle = GetModuleHandleA("kernel32"); int WINAPI (*VirtProt)(void *, unsigned, int, int *); int res = 0; int prot, tmp; VirtProt = GetProcAddress(handle, "VirtualProtect"); // change permissions to PAGE_WRITECOPY if (!VirtProt || !VirtProt(patchpos, codesize, 0x08, &prot)) { mp_msg(MSGT_DECVIDEO, MSGL_WARN, "VirtualProtect failed at %p\n", patchpos); return 0; } if (memcmp(patchpos, oldcode, codesize) == 0) { memcpy(patchpos, newcode, codesize); res = 1; } VirtProt(patchpos, codesize, prot, &tmp); return res;}#endifstatic int load_syms_windows(char *path) { void *handle; mp_msg(MSGT_DECVIDEO,MSGL_V, "opening win32 dll '%s'\n", path);#ifdef WIN32_LOADER Setup_LDT_Keeper();#endif handle = LoadLibraryA(path); mp_msg(MSGT_DECVIDEO,MSGL_V,"win32 real codec handle=%p \n",handle); if (!handle) { mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error loading dll\n"); return 0; } wrvyuv_custom_message = GetProcAddress(handle, "RV20toYUV420CustomMessage"); wrvyuv_free = GetProcAddress(handle, "RV20toYUV420Free"); wrvyuv_init = GetProcAddress(handle, "RV20toYUV420Init"); wrvyuv_transform = GetProcAddress(handle, "RV20toYUV420Transform"); if(wrvyuv_custom_message && wrvyuv_free && wrvyuv_init && wrvyuv_transform) { dll_type = 1; rv_handle = handle;#ifndef WIN32_LOADER { int patched = 0; // drv43260.dll if (wrvyuv_transform == (void *)0x634114d0) { // patch away multithreaded decoding, it causes crashes static const uint8_t oldcode[13] = { 0x83, 0xbb, 0xf8, 0x05, 0x00, 0x00, 0x01, 0x0f, 0x86, 0xd0, 0x00, 0x00, 0x00 }; static const uint8_t newcode[13] = { 0x31, 0xc0, 0x89, 0x83, 0xf8, 0x05, 0x00, 0x00, 0xe9, 0xd0, 0x00, 0x00, 0x00 }; patched = patch_dll((void *)0x634132fa, oldcode, newcode, sizeof(oldcode)); } if (!patched) mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Could not patch Real codec, this might crash on multi-CPU systems\n"); }#endif return 1; } mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n"); FreeLibrary(handle); return 0; // error}#endif/* we need exact positions */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?