Mercurial > mplayer.hg
annotate libmpcodecs/vd_realvid.c @ 26277:644426c3261c
Rename HAVE_XVMC_ACCEL to HAVE_XVMC for consistency and to sync with FFmpeg.
author | diego |
---|---|
date | Mon, 31 Mar 2008 17:19:51 +0000 |
parents | afa125da85cf |
children | 59db094d3494 |
rev | line source |
---|---|
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
1 #include <stdio.h> |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
2 #include <stdlib.h> |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
3 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
4 #include "config.h" |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
5 |
10093 | 6 #ifdef HAVE_LIBDL |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
7 #include <dlfcn.h> |
10093 | 8 #endif |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
9 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
10 #include "mp_msg.h" |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
11 #include "help_mp.h" |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
12 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
13 #include "vd_internal.h" |
22577
a033e5519802
Include loader/ prefix in #include path everywhere.
diego
parents:
21563
diff
changeset
|
14 #include "loader/wine/windef.h" |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
15 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
16 static vd_info_t info = { |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
17 "RealVideo decoder", |
7174 | 18 "realvid", |
12628
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
19 "Alex Beregszaszi", |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
20 "Florian Schneider, Arpad Gereoffy, Alex Beregszaszi, Donnie Smith", |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
21 "binary real video codecs" |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
22 }; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
23 |
7174 | 24 LIBVD_EXTERN(realvid) |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
25 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
26 |
8522 | 27 /* |
28 * Structures for data packets. These used to be tables of unsigned ints, but | |
29 * that does not work on 64 bit platforms (e.g. Alpha). The entries that are | |
30 * pointers get truncated. Pointers on 64 bit platforms are 8 byte longs. | |
31 * So we have to use structures so the compiler will assign the proper space | |
32 * for the pointer. | |
33 */ | |
34 typedef struct cmsg_data_s { | |
35 uint32_t data1; | |
36 uint32_t data2; | |
37 uint32_t* dimensions; | |
38 } cmsg_data_t; | |
39 | |
40 typedef struct transform_in_s { | |
41 uint32_t len; | |
42 uint32_t unknown1; | |
43 uint32_t chunks; | |
44 uint32_t* extra; | |
45 uint32_t unknown2; | |
46 uint32_t timestamp; | |
47 } transform_in_t; | |
48 | |
49 static unsigned long (*rvyuv_custom_message)(cmsg_data_t* ,void*); | |
7728 | 50 static unsigned long (*rvyuv_free)(void*); |
51 static unsigned long (*rvyuv_init)(void*, void*); // initdata,context | |
8522 | 52 static unsigned long (*rvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*); |
8525 | 53 #ifdef USE_WIN32DLL |
54 static unsigned long WINAPI (*wrvyuv_custom_message)(cmsg_data_t* ,void*); | |
55 static unsigned long WINAPI (*wrvyuv_free)(void*); | |
56 static unsigned long WINAPI (*wrvyuv_init)(void*, void*); // initdata,context | |
57 static unsigned long WINAPI (*wrvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*); | |
58 #endif | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
59 |
7728 | 60 static void *rv_handle=NULL; |
25962 | 61 static int initialized=0; |
21559
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
62 static uint8_t *buffer = NULL; |
21563
c08b8066a1c6
Only increase buffer size to avoid crashes when seeking in
reimar
parents:
21559
diff
changeset
|
63 static int bufsz = 0; |
8525 | 64 #ifdef USE_WIN32DLL |
65 static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */ | |
66 #endif | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
67 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
68 void *__builtin_vec_new(unsigned long size) { |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
69 return malloc(size); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
70 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
71 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
72 void __builtin_vec_delete(void *mem) { |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
73 free(mem); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
74 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
75 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
76 void __pure_virtual(void) { |
6361 | 77 printf("FATAL: __pure_virtual() called!\n"); |
78 // exit(1); | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
79 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
80 |
15566 | 81 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) |
6361 | 82 void ___brk_addr(void) {exit(0);} |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
83 char **__environ={NULL}; |
6361 | 84 #undef stderr |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
85 FILE *stderr=NULL; |
6361 | 86 #endif |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
87 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
88 // to set/get/query special features/parameters |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
89 static int control(sh_video_t *sh,int cmd,void* arg,...){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
90 // switch(cmd){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
91 // case VDCTRL_QUERY_MAX_PP_LEVEL: |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
92 // return 9; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
93 // case VDCTRL_SET_PP_LEVEL: |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
94 // vfw_set_postproc(sh,10*(*((int*)arg))); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
95 // return CONTROL_OK; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
96 // } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
97 return CONTROL_UNKNOWN; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
98 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
99 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
100 /* exits program when failure */ |
10093 | 101 #ifdef HAVE_LIBDL |
7728 | 102 static int load_syms_linux(char *path) { |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
103 void *handle; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
104 |
17721
7b336a5585e4
Reduce Real DLL/so loading verbosity, OKed by Roberto.
diego
parents:
17012
diff
changeset
|
105 mp_msg(MSGT_DECVIDEO,MSGL_V, "opening shared obj '%s'\n", path); |
9386 | 106 handle = dlopen (path, RTLD_LAZY); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
107 if (!handle) { |
6361 | 108 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error: %s\n",dlerror()); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
109 return 0; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
110 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
111 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
112 rvyuv_custom_message = dlsym(handle, "RV20toYUV420CustomMessage"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
113 rvyuv_free = dlsym(handle, "RV20toYUV420Free"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
114 rvyuv_init = dlsym(handle, "RV20toYUV420Init"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
115 rvyuv_transform = dlsym(handle, "RV20toYUV420Transform"); |
6361 | 116 |
117 if(rvyuv_custom_message && | |
118 rvyuv_free && | |
119 rvyuv_init && | |
9386 | 120 rvyuv_transform) |
121 { | |
122 rv_handle = handle; | |
123 return 1; | |
124 } | |
13860
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
125 |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
126 rvyuv_custom_message = dlsym(handle, "RV40toYUV420CustomMessage"); |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
127 rvyuv_free = dlsym(handle, "RV40toYUV420Free"); |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
128 rvyuv_init = dlsym(handle, "RV40toYUV420Init"); |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
129 rvyuv_transform = dlsym(handle, "RV40toYUV420Transform"); |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
130 |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
131 if(rvyuv_custom_message && |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
132 rvyuv_free && |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
133 rvyuv_init && |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
134 rvyuv_transform) |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
135 { |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
136 rv_handle = handle; |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
137 return 1; |
d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents:
12628
diff
changeset
|
138 } |
6361 | 139 |
140 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n"); | |
9386 | 141 dlclose(handle); |
6361 | 142 return 0; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
143 } |
10093 | 144 #endif |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
145 |
6543
70a9c9f695a2
first try to load linux dlls, if failed and we're supporting win32 dlls, then try to load the windows ones
alex
parents:
6404
diff
changeset
|
146 #ifdef USE_WIN32DLL |
7127 | 147 |
10093 | 148 #ifdef WIN32_LOADER |
17012 | 149 #include "loader/ldt_keeper.h" |
10093 | 150 #endif |
8525 | 151 void* WINAPI LoadLibraryA(char* name); |
152 void* WINAPI GetProcAddress(void* handle,char* func); | |
153 int WINAPI FreeLibrary(void *handle); | |
7127 | 154 |
24087
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
155 #ifndef WIN32_LOADER |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
156 void * WINAPI GetModuleHandleA(char *); |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
157 static int patch_dll(uint8_t *patchpos, const uint8_t *oldcode, |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
158 const uint8_t *newcode, int codesize) { |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
159 void *handle = GetModuleHandleA("kernel32"); |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
160 int WINAPI (*VirtProt)(void *, unsigned, int, int *); |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
161 int res = 0; |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
162 int prot, tmp; |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
163 VirtProt = GetProcAddress(handle, "VirtualProtect"); |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
164 // change permissions to PAGE_WRITECOPY |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
165 if (!VirtProt || |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
166 !VirtProt(patchpos, codesize, 0x08, &prot)) { |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
167 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "VirtualProtect failed at %p\n", patchpos); |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
168 return 0; |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
169 } |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
170 if (memcmp(patchpos, oldcode, codesize) == 0) { |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
171 memcpy(patchpos, newcode, codesize); |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
172 res = 1; |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
173 } |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
174 VirtProt(patchpos, codesize, prot, &tmp); |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
175 return res; |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
176 } |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
177 #endif |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
178 |
7728 | 179 static int load_syms_windows(char *path) { |
6360 | 180 void *handle; |
8525 | 181 |
17721
7b336a5585e4
Reduce Real DLL/so loading verbosity, OKed by Roberto.
diego
parents:
17012
diff
changeset
|
182 mp_msg(MSGT_DECVIDEO,MSGL_V, "opening win32 dll '%s'\n", path); |
10093 | 183 #ifdef WIN32_LOADER |
6360 | 184 Setup_LDT_Keeper(); |
10093 | 185 #endif |
9386 | 186 handle = LoadLibraryA(path); |
6361 | 187 mp_msg(MSGT_DECVIDEO,MSGL_V,"win32 real codec handle=%p \n",handle); |
8525 | 188 if (!handle) { |
189 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error loading dll\n"); | |
190 return 0; | |
191 } | |
6360 | 192 |
8525 | 193 wrvyuv_custom_message = GetProcAddress(handle, "RV20toYUV420CustomMessage"); |
194 wrvyuv_free = GetProcAddress(handle, "RV20toYUV420Free"); | |
195 wrvyuv_init = GetProcAddress(handle, "RV20toYUV420Init"); | |
196 wrvyuv_transform = GetProcAddress(handle, "RV20toYUV420Transform"); | |
9386 | 197 |
8525 | 198 if(wrvyuv_custom_message && |
199 wrvyuv_free && | |
200 wrvyuv_init && | |
9386 | 201 wrvyuv_transform) |
202 { | |
203 dll_type = 1; | |
204 rv_handle = handle; | |
24087
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
205 #ifndef WIN32_LOADER |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
206 { |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
207 int patched = 0; |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
208 // drv43260.dll |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
209 if (wrvyuv_transform == (void *)0x634114d0) { |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
210 // patch away multithreaded decoding, it causes crashes |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
211 static const uint8_t oldcode[13] = { |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
212 0x83, 0xbb, 0xf8, 0x05, 0x00, 0x00, 0x01, |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
213 0x0f, 0x86, 0xd0, 0x00, 0x00, 0x00 }; |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
214 static const uint8_t newcode[13] = { |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
215 0x31, 0xc0, |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
216 0x89, 0x83, 0xf8, 0x05, 0x00, 0x00, |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
217 0xe9, 0xd0, 0x00, 0x00, 0x00 }; |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
218 patched = patch_dll((void *)0x634132fa, oldcode, newcode, |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
219 sizeof(oldcode)); |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
220 } |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
221 if (!patched) |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
222 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Could not patch Real codec, this might crash on multi-CPU systems\n"); |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
223 } |
5992f8a979e3
Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents:
22577
diff
changeset
|
224 #endif |
9386 | 225 return 1; |
226 } | |
8525 | 227 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n"); |
9386 | 228 FreeLibrary(handle); |
6360 | 229 return 0; // error |
230 } | |
231 #endif | |
232 | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
233 /* we need exact positions */ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
234 struct rv_init_t { |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
235 short unk1; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
236 short w; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
237 short h; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
238 short unk3; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
239 int unk2; |
6345 | 240 int subformat; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
241 int unk5; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
242 int format; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
243 } rv_init_t; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
244 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
245 // init driver |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
246 static int init(sh_video_t *sh){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
247 //unsigned int out_fmt; |
10102 | 248 char *path; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
249 int result; |
6345 | 250 // we export codec id and sub-id from demuxer in bitmapinfohdr: |
20920 | 251 unsigned char* extrahdr=(unsigned char*)(sh->bih+1); |
252 unsigned int extrahdr_size = sh->bih->biSize - sizeof(BITMAPINFOHEADER); | |
253 struct rv_init_t init_data; | |
6345 | 254 |
20920 | 255 if(extrahdr_size < 8) { |
256 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"realvideo: extradata too small (%u)\n", sh->bih->biSize - sizeof(BITMAPINFOHEADER)); | |
257 return 0; | |
258 } | |
259 init_data = (struct rv_init_t){11, sh->disp_w, sh->disp_h, 0, 0, be2me_32(((unsigned int*)extrahdr)[0]), 1, be2me_32(((unsigned int*)extrahdr)[1])}; // rv30 | |
260 | |
261 mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo codec id: 0x%08X sub-id: 0x%08X\n",be2me_32(((unsigned int*)extrahdr)[1]),be2me_32(((unsigned int*)extrahdr)[0])); | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
262 |
10102 | 263 path = malloc(strlen(REALCODEC_PATH)+strlen(sh->codec->dll)+2); |
264 if (!path) return 0; | |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
265 sprintf(path, REALCODEC_PATH "/%s", sh->codec->dll); |
6543
70a9c9f695a2
first try to load linux dlls, if failed and we're supporting win32 dlls, then try to load the windows ones
alex
parents:
6404
diff
changeset
|
266 |
70a9c9f695a2
first try to load linux dlls, if failed and we're supporting win32 dlls, then try to load the windows ones
alex
parents:
6404
diff
changeset
|
267 /* first try to load linux dlls, if failed and we're supporting win32 dlls, |
70a9c9f695a2
first try to load linux dlls, if failed and we're supporting win32 dlls, then try to load the windows ones
alex
parents:
6404
diff
changeset
|
268 then try to load the windows ones */ |
10093 | 269 #ifdef HAVE_LIBDL |
270 if(strstr(sh->codec->dll,".dll") || !load_syms_linux(path)) | |
271 #endif | |
6544
222f6da66fa3
first try to load linux dlls, if failed and we're supporting win32 dlls, then try to load the windows ones
alex
parents:
6543
diff
changeset
|
272 #ifdef USE_WIN32DLL |
10444 | 273 if (!load_syms_windows(sh->codec->dll)) |
6543
70a9c9f695a2
first try to load linux dlls, if failed and we're supporting win32 dlls, then try to load the windows ones
alex
parents:
6404
diff
changeset
|
274 #endif |
70a9c9f695a2
first try to load linux dlls, if failed and we're supporting win32 dlls, then try to load the windows ones
alex
parents:
6404
diff
changeset
|
275 { |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
276 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll); |
9386 | 277 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Read the RealVideo section of the DOCS!\n"); |
10102 | 278 free(path); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
279 return 0; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
280 } |
10102 | 281 free(path); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
282 // only I420 supported |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
283 // if((sh->format!=0x30335652) && !mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
284 // init codec: |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
285 sh->context=NULL; |
8525 | 286 #ifdef USE_WIN32DLL |
287 if (dll_type == 1) | |
288 result=(*wrvyuv_init)(&init_data, &sh->context); | |
289 else | |
290 #endif | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
291 result=(*rvyuv_init)(&init_data, &sh->context); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
292 if (result){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
293 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Couldn't open RealVideo codec, error code: 0x%X \n",result); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
294 return 0; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
295 } |
6345 | 296 // setup rv30 codec (codec sub-type and image dimensions): |
20920 | 297 if((sh->format<=0x30335652) && (be2me_32(((unsigned int*)extrahdr)[1])>=0x20200002)){ |
298 int i, cmsg_cnt; | |
299 uint32_t cmsg24[16]={sh->disp_w,sh->disp_h}; | |
300 cmsg_data_t cmsg_data={0x24,1+(extrahdr[1]&7), &cmsg24[0]}; | |
301 | |
302 mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo: using cmsg24 with %u elements.\n",extrahdr[1]&7); | |
303 cmsg_cnt = (extrahdr[1]&7)*2; | |
304 if (extrahdr_size-8 < cmsg_cnt) { | |
305 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"realvideo: not enough extradata (%u) to make %u cmsg24 elements.\n",extrahdr_size-8,extrahdr[1]&7); | |
306 cmsg_cnt = extrahdr_size-8; | |
307 } | |
308 for (i = 0; i < cmsg_cnt; i++) | |
309 cmsg24[2+i] = extrahdr[8+i]*4; | |
310 if (extrahdr_size-8 > cmsg_cnt) | |
311 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"realvideo: %u bytes of unknown extradata remaining.\n",extrahdr_size-8-cmsg_cnt); | |
8525 | 312 |
313 #ifdef USE_WIN32DLL | |
314 if (dll_type == 1) | |
315 (*wrvyuv_custom_message)(&cmsg_data,sh->context); | |
316 else | |
317 #endif | |
8522 | 318 (*rvyuv_custom_message)(&cmsg_data,sh->context); |
6345 | 319 } |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
320 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: RealVideo codec init OK!\n"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
321 return 1; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
322 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
323 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
324 // uninit driver |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
325 static void uninit(sh_video_t *sh){ |
8525 | 326 #ifdef USE_WIN32DLL |
327 if (dll_type == 1) | |
328 { | |
329 if (wrvyuv_free) wrvyuv_free(sh->context); | |
330 } else | |
331 #endif | |
7728 | 332 if(rvyuv_free) rvyuv_free(sh->context); |
8525 | 333 |
334 #ifdef USE_WIN32DLL | |
335 if (dll_type == 1) | |
336 { | |
337 if (rv_handle) FreeLibrary(rv_handle); | |
338 } else | |
339 #endif | |
10093 | 340 #ifdef HAVE_LIBDL |
6345 | 341 if(rv_handle) dlclose(rv_handle); |
10093 | 342 #endif |
6345 | 343 rv_handle=NULL; |
25962 | 344 initialized = 0; |
21559
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
345 if (buffer) |
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
346 free(buffer); |
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
347 buffer = NULL; |
21563
c08b8066a1c6
Only increase buffer size to avoid crashes when seeking in
reimar
parents:
21559
diff
changeset
|
348 bufsz = 0; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
349 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
350 |
7082 | 351 // copypaste from demux_real.c - it should match to get it working! |
352 typedef struct dp_hdr_s { | |
353 uint32_t chunks; // number of chunks | |
354 uint32_t timestamp; // timestamp from packet header | |
355 uint32_t len; // length of actual data | |
356 uint32_t chunktab; // offset to chunk offset array | |
357 } dp_hdr_t; | |
358 | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
359 // decode a frame |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
360 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
361 mp_image_t* mpi; |
6745
9734bfbb200a
Avoid ulong typedef clash and replace if by unsigned long, patch by Joey Parrish.
atmos4
parents:
6544
diff
changeset
|
362 unsigned long result; |
7082 | 363 dp_hdr_t* dp_hdr=(dp_hdr_t*)data; |
364 unsigned char* dp_data=((unsigned char*)data)+sizeof(dp_hdr_t); | |
365 uint32_t* extra=(uint32_t*)(((char*)data)+dp_hdr->chunktab); | |
366 | |
8522 | 367 unsigned int transform_out[5]; |
368 transform_in_t transform_in={ | |
7082 | 369 dp_hdr->len, // length of the packet (sub-packets appended) |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
370 0, // unknown, seems to be unused |
7082 | 371 dp_hdr->chunks, // number of sub-packets - 1 |
8522 | 372 extra, // table of sub-packet offsets |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
373 0, // unknown, seems to be unused |
25598 | 374 0, // timestamp (should be unneded) |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
375 }; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
376 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
377 if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
378 |
21563
c08b8066a1c6
Only increase buffer size to avoid crashes when seeking in
reimar
parents:
21559
diff
changeset
|
379 if (bufsz < sh->disp_w*sh->disp_h*3/2) { |
21559
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
380 if (buffer) free(buffer); |
21563
c08b8066a1c6
Only increase buffer size to avoid crashes when seeking in
reimar
parents:
21559
diff
changeset
|
381 bufsz = sh->disp_w*sh->disp_h*3/2; |
c08b8066a1c6
Only increase buffer size to avoid crashes when seeking in
reimar
parents:
21559
diff
changeset
|
382 buffer=malloc(bufsz); |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
383 if (!buffer) return 0; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
384 } |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
385 |
8525 | 386 #ifdef USE_WIN32DLL |
387 if (dll_type == 1) | |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
388 result=(*wrvyuv_transform)(dp_data, buffer, &transform_in, |
8525 | 389 transform_out, sh->context); |
390 else | |
391 #endif | |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
392 result=(*rvyuv_transform)(dp_data, buffer, &transform_in, |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
393 transform_out, sh->context); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
394 |
25962 | 395 if(!initialized){ // rv30 width/height now known |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
396 sh->aspect=(float)sh->disp_w/(float)sh->disp_h; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
397 sh->disp_w=transform_out[3]; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
398 sh->disp_h=transform_out[4]; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
399 if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0; |
25962 | 400 initialized=1; |
21559
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
401 } |
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
402 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/, |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
403 sh->disp_w, sh->disp_h); |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
404 if(!mpi) return NULL; |
21559
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
405 mpi->planes[0] = buffer; |
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
406 mpi->stride[0] = sh->disp_w; |
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
407 mpi->planes[1] = buffer + sh->disp_w*sh->disp_h; |
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
408 mpi->stride[1] = sh->disp_w / 2; |
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
409 mpi->planes[2] = buffer + sh->disp_w*sh->disp_h*5/4; |
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
410 mpi->stride[2] = sh->disp_w / 2; |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
411 |
21559
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
412 if(transform_out[0] && |
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
413 (sh->disp_w != transform_out[3] || sh->disp_h != transform_out[4])) |
25962 | 414 initialized = 0; |
21559
de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents:
21466
diff
changeset
|
415 |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
416 return (result?NULL:mpi); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
417 } |