Mercurial > mplayer.hg
annotate libmpcodecs/vd_realvid.c @ 12885:010a28a43c9f
fix for people experimenting with GUI under windows
author | reimar |
---|---|
date | Thu, 22 Jul 2004 19:07:13 +0000 |
parents | 985e1813e298 |
children | d6f716fdd734 |
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 #ifdef USE_REALCODECS |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
6 |
10093 | 7 #ifdef HAVE_LIBDL |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
8 #include <dlfcn.h> |
10093 | 9 #endif |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
10 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
11 #include "mp_msg.h" |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
12 #include "help_mp.h" |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
13 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
14 #include "vd_internal.h" |
12356
6a61d694f7d3
minimal fix for alex's 1000000000000l compile errors. imo the fix in
rfelker
parents:
10444
diff
changeset
|
15 #include "wine/windef.h" |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
16 |
12628
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
17 #ifdef USE_MACSHLB |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
18 #include <CoreServices/CoreServices.h> |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
19 #endif |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
20 |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
21 static vd_info_t info = { |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
22 "RealVideo decoder", |
7174 | 23 "realvid", |
12628
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
24 "Alex Beregszaszi", |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
25 "Florian Schneider, Arpad Gereoffy, Alex Beregszaszi, Donnie Smith", |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
26 "binary real video codecs" |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
27 }; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
28 |
7174 | 29 LIBVD_EXTERN(realvid) |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
30 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
31 |
8522 | 32 /* |
33 * Structures for data packets. These used to be tables of unsigned ints, but | |
34 * that does not work on 64 bit platforms (e.g. Alpha). The entries that are | |
35 * pointers get truncated. Pointers on 64 bit platforms are 8 byte longs. | |
36 * So we have to use structures so the compiler will assign the proper space | |
37 * for the pointer. | |
38 */ | |
39 typedef struct cmsg_data_s { | |
40 uint32_t data1; | |
41 uint32_t data2; | |
42 uint32_t* dimensions; | |
43 } cmsg_data_t; | |
44 | |
45 typedef struct transform_in_s { | |
46 uint32_t len; | |
47 uint32_t unknown1; | |
48 uint32_t chunks; | |
49 uint32_t* extra; | |
50 uint32_t unknown2; | |
51 uint32_t timestamp; | |
52 } transform_in_t; | |
53 | |
54 static unsigned long (*rvyuv_custom_message)(cmsg_data_t* ,void*); | |
7728 | 55 static unsigned long (*rvyuv_free)(void*); |
56 static unsigned long (*rvyuv_hive_message)(unsigned long,unsigned long); | |
57 static unsigned long (*rvyuv_init)(void*, void*); // initdata,context | |
8522 | 58 static unsigned long (*rvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*); |
8525 | 59 #ifdef USE_WIN32DLL |
60 static unsigned long WINAPI (*wrvyuv_custom_message)(cmsg_data_t* ,void*); | |
61 static unsigned long WINAPI (*wrvyuv_free)(void*); | |
62 static unsigned long WINAPI (*wrvyuv_hive_message)(unsigned long,unsigned long); | |
63 static unsigned long WINAPI (*wrvyuv_init)(void*, void*); // initdata,context | |
64 static unsigned long WINAPI (*wrvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*); | |
65 #endif | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
66 |
7728 | 67 static void *rv_handle=NULL; |
12628
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
68 static int inited=0; |
8525 | 69 #ifdef USE_WIN32DLL |
70 static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */ | |
71 #endif | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
72 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
73 void *__builtin_vec_new(unsigned long size) { |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
74 return malloc(size); |
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 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
77 void __builtin_vec_delete(void *mem) { |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
78 free(mem); |
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 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
81 void __pure_virtual(void) { |
6361 | 82 printf("FATAL: __pure_virtual() called!\n"); |
83 // exit(1); | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
84 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
85 |
10142
1031f03eec7e
OpenBSD support by Bjorn Sandell <biorn@dce.chalmers.se>
alex
parents:
10102
diff
changeset
|
86 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) |
6361 | 87 void ___brk_addr(void) {exit(0);} |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
88 char **__environ={NULL}; |
6361 | 89 #undef stderr |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
90 FILE *stderr=NULL; |
6361 | 91 #endif |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
92 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
93 // to set/get/query special features/parameters |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
94 static int control(sh_video_t *sh,int cmd,void* arg,...){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
95 // switch(cmd){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
96 // case VDCTRL_QUERY_MAX_PP_LEVEL: |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
97 // return 9; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
98 // case VDCTRL_SET_PP_LEVEL: |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
99 // vfw_set_postproc(sh,10*(*((int*)arg))); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
100 // return CONTROL_OK; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
101 // } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
102 return CONTROL_UNKNOWN; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
103 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
104 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
105 /* exits program when failure */ |
10093 | 106 #ifdef HAVE_LIBDL |
7728 | 107 static int load_syms_linux(char *path) { |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
108 void *handle; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
109 |
6361 | 110 mp_msg(MSGT_DECVIDEO,MSGL_INFO, "opening shared obj '%s'\n", path); |
9386 | 111 handle = dlopen (path, RTLD_LAZY); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
112 if (!handle) { |
6361 | 113 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error: %s\n",dlerror()); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
114 return 0; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
115 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
116 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
117 rvyuv_custom_message = dlsym(handle, "RV20toYUV420CustomMessage"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
118 rvyuv_free = dlsym(handle, "RV20toYUV420Free"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
119 rvyuv_hive_message = dlsym(handle, "RV20toYUV420HiveMessage"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
120 rvyuv_init = dlsym(handle, "RV20toYUV420Init"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
121 rvyuv_transform = dlsym(handle, "RV20toYUV420Transform"); |
6361 | 122 |
123 if(rvyuv_custom_message && | |
124 rvyuv_free && | |
125 rvyuv_hive_message && | |
126 rvyuv_init && | |
9386 | 127 rvyuv_transform) |
128 { | |
129 rv_handle = handle; | |
130 return 1; | |
131 } | |
6361 | 132 |
133 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n"); | |
9386 | 134 dlclose(handle); |
6361 | 135 return 0; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
136 } |
10093 | 137 #endif |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
138 |
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
|
139 #ifdef USE_WIN32DLL |
7127 | 140 |
10093 | 141 #ifdef WIN32_LOADER |
7127 | 142 #include "../loader/ldt_keeper.h" |
10093 | 143 #endif |
8525 | 144 void* WINAPI LoadLibraryA(char* name); |
145 void* WINAPI GetProcAddress(void* handle,char* func); | |
146 int WINAPI FreeLibrary(void *handle); | |
7127 | 147 |
7728 | 148 static int load_syms_windows(char *path) { |
6360 | 149 void *handle; |
8525 | 150 |
151 mp_msg(MSGT_DECVIDEO,MSGL_INFO, "opening win32 dll '%s'\n", path); | |
10093 | 152 #ifdef WIN32_LOADER |
6360 | 153 Setup_LDT_Keeper(); |
10093 | 154 #endif |
9386 | 155 handle = LoadLibraryA(path); |
6361 | 156 mp_msg(MSGT_DECVIDEO,MSGL_V,"win32 real codec handle=%p \n",handle); |
8525 | 157 if (!handle) { |
158 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error loading dll\n"); | |
159 return 0; | |
160 } | |
6360 | 161 |
8525 | 162 wrvyuv_custom_message = GetProcAddress(handle, "RV20toYUV420CustomMessage"); |
163 wrvyuv_free = GetProcAddress(handle, "RV20toYUV420Free"); | |
164 wrvyuv_hive_message = GetProcAddress(handle, "RV20toYUV420HiveMessage"); | |
165 wrvyuv_init = GetProcAddress(handle, "RV20toYUV420Init"); | |
166 wrvyuv_transform = GetProcAddress(handle, "RV20toYUV420Transform"); | |
9386 | 167 |
8525 | 168 if(wrvyuv_custom_message && |
169 wrvyuv_free && | |
170 wrvyuv_hive_message && | |
171 wrvyuv_init && | |
9386 | 172 wrvyuv_transform) |
173 { | |
174 dll_type = 1; | |
175 rv_handle = handle; | |
176 return 1; | |
177 } | |
8525 | 178 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n"); |
9386 | 179 FreeLibrary(handle); |
6360 | 180 return 0; // error |
181 } | |
182 #endif | |
183 | |
12628
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
184 #ifdef USE_MACSHLB |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
185 void *load_one_sym_mac(char *symbolName, CFragConnectionID *connID); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
186 |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
187 static int load_syms_mac(char *path) { |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
188 Ptr mainAddr; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
189 OSStatus status; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
190 FSRef fsref; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
191 FSSpec fsspec; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
192 OSErr err; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
193 Str255 errMessage; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
194 CFragConnectionID *connID; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
195 |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
196 mp_msg(MSGT_DECVIDEO,MSGL_INFO, "opening mac shlb '%s'\n", path); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
197 |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
198 if ( (connID = (CFragConnectionID *)NewPtr( sizeof( CFragConnectionID ))) == nil ) { |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
199 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"NewPtr() failed.\n" ); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
200 return 0; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
201 } |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
202 |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
203 if ( (status = FSPathMakeRef( path, &fsref, NULL )) != noErr ) { |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
204 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"FSPathMakeRef() failed with error %d.\n", status ); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
205 return 0; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
206 } |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
207 |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
208 if ( (status = FSGetCatalogInfo( &fsref, kFSCatInfoNone, NULL, NULL, &fsspec, NULL )) != noErr ) { |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
209 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"FSGetCatalogInfo() failed with error %d.\n", status ); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
210 return 0; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
211 } |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
212 |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
213 if ( (err = GetDiskFragment( &fsspec, 0, kCFragGoesToEOF, NULL, kPrivateCFragCopy, connID, &mainAddr, errMessage )) != noErr ) { |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
214 p2cstrcpy( errMessage, errMessage ); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
215 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"GetDiskFragment() failed with error %d: %s\n", err, errMessage ); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
216 return 0; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
217 } |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
218 |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
219 rvyuv_custom_message = load_one_sym_mac("RV20toYUV420CustomMessage", connID); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
220 rvyuv_free = load_one_sym_mac("RV20toYUV420Free", connID); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
221 rvyuv_hive_message = load_one_sym_mac("RV20toYUV420HiveMessage", connID); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
222 rvyuv_init = load_one_sym_mac("RV20toYUV420Init", connID); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
223 rvyuv_transform = load_one_sym_mac("RV20toYUV420Transform", connID); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
224 |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
225 if(rvyuv_custom_message && |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
226 rvyuv_free && |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
227 rvyuv_hive_message && |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
228 rvyuv_init && |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
229 rvyuv_transform) |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
230 { |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
231 rv_handle = connID; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
232 return 1; |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
233 } |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
234 |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
235 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n"); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
236 (void)CloseConnection(connID); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
237 return 0; // error |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
238 } |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
239 #endif |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
240 |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
241 |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
242 /* we need exact positions */ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
243 struct rv_init_t { |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
244 short unk1; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
245 short w; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
246 short h; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
247 short unk3; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
248 int unk2; |
6345 | 249 int subformat; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
250 int unk5; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
251 int format; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
252 } rv_init_t; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
253 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
254 // init driver |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
255 static int init(sh_video_t *sh){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
256 //unsigned int out_fmt; |
10102 | 257 char *path; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
258 int result; |
6345 | 259 // we export codec id and sub-id from demuxer in bitmapinfohdr: |
260 unsigned int* extrahdr=(unsigned int*)(sh->bih+1); | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
261 struct rv_init_t init_data={ |
6345 | 262 11, sh->disp_w, sh->disp_h,0,0,extrahdr[0], |
263 1,extrahdr[1]}; // rv30 | |
264 | |
265 mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo codec id: 0x%08X sub-id: 0x%08X\n",extrahdr[1],extrahdr[0]); | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
266 |
10102 | 267 path = malloc(strlen(REALCODEC_PATH)+strlen(sh->codec->dll)+2); |
268 if (!path) return 0; | |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
269 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
|
270 |
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
|
271 /* 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
|
272 then try to load the windows ones */ |
12628
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
273 #ifdef USE_MACSHLB |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
274 if (strstr(sh->codec->dll, ".shlb") && !load_syms_mac(path)) |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
275 #endif |
10093 | 276 #ifdef HAVE_LIBDL |
277 if(strstr(sh->codec->dll,".dll") || !load_syms_linux(path)) | |
278 #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
|
279 #ifdef USE_WIN32DLL |
10444 | 280 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
|
281 #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
|
282 { |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
283 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll); |
9386 | 284 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Read the RealVideo section of the DOCS!\n"); |
10102 | 285 free(path); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
286 return 0; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
287 } |
10102 | 288 free(path); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
289 // only I420 supported |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
290 // 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
|
291 // init codec: |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
292 sh->context=NULL; |
8525 | 293 #ifdef USE_WIN32DLL |
294 if (dll_type == 1) | |
295 result=(*wrvyuv_init)(&init_data, &sh->context); | |
296 else | |
297 #endif | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
298 result=(*rvyuv_init)(&init_data, &sh->context); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
299 if (result){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
300 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
|
301 return 0; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
302 } |
6345 | 303 // setup rv30 codec (codec sub-type and image dimensions): |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
304 if((sh->format<=0x30335652) && (extrahdr[1]>=0x20200002)){ |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
305 uint32_t cmsg24[4]={sh->disp_w,sh->disp_h,((unsigned short *)extrahdr)[4],((unsigned short *)extrahdr)[5]}; |
8522 | 306 cmsg_data_t cmsg_data={0x24,1+((extrahdr[0]>>16)&7), &cmsg24[0]}; |
8525 | 307 |
308 #ifdef USE_WIN32DLL | |
309 if (dll_type == 1) | |
310 (*wrvyuv_custom_message)(&cmsg_data,sh->context); | |
311 else | |
312 #endif | |
8522 | 313 (*rvyuv_custom_message)(&cmsg_data,sh->context); |
6345 | 314 } |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
315 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
|
316 return 1; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
317 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
318 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
319 // uninit driver |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
320 static void uninit(sh_video_t *sh){ |
8525 | 321 #ifdef USE_WIN32DLL |
322 if (dll_type == 1) | |
323 { | |
324 if (wrvyuv_free) wrvyuv_free(sh->context); | |
325 } else | |
326 #endif | |
7728 | 327 if(rvyuv_free) rvyuv_free(sh->context); |
8525 | 328 |
329 #ifdef USE_WIN32DLL | |
330 if (dll_type == 1) | |
331 { | |
332 if (rv_handle) FreeLibrary(rv_handle); | |
333 } else | |
334 #endif | |
10093 | 335 #ifdef HAVE_LIBDL |
6345 | 336 if(rv_handle) dlclose(rv_handle); |
10093 | 337 #endif |
12628
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
338 #ifdef USE_MACSHLB |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
339 if (rv_handle){ |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
340 (void)CloseConnection(rv_handle); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
341 DisposePtr((Ptr)rv_handle); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
342 } |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
343 if (rvyuv_custom_message) DisposePtr((Ptr)rvyuv_custom_message); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
344 if (rvyuv_free) DisposePtr((Ptr)rvyuv_free); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
345 if (rvyuv_hive_message) DisposePtr((Ptr)rvyuv_hive_message); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
346 if (rvyuv_init) DisposePtr((Ptr)rvyuv_init); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
347 if (rvyuv_transform) DisposePtr((Ptr)rvyuv_transform); |
985e1813e298
support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents:
12356
diff
changeset
|
348 #endif |
6345 | 349 rv_handle=NULL; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
350 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
351 |
7082 | 352 // copypaste from demux_real.c - it should match to get it working! |
353 typedef struct dp_hdr_s { | |
354 uint32_t chunks; // number of chunks | |
355 uint32_t timestamp; // timestamp from packet header | |
356 uint32_t len; // length of actual data | |
357 uint32_t chunktab; // offset to chunk offset array | |
358 } dp_hdr_t; | |
359 | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
360 // decode a frame |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
361 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
|
362 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
|
363 unsigned long result; |
7082 | 364 dp_hdr_t* dp_hdr=(dp_hdr_t*)data; |
365 unsigned char* dp_data=((unsigned char*)data)+sizeof(dp_hdr_t); | |
366 uint32_t* extra=(uint32_t*)(((char*)data)+dp_hdr->chunktab); | |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
367 unsigned char* buffer; |
7082 | 368 |
8522 | 369 unsigned int transform_out[5]; |
370 transform_in_t transform_in={ | |
7082 | 371 dp_hdr->len, // length of the packet (sub-packets appended) |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
372 0, // unknown, seems to be unused |
7082 | 373 dp_hdr->chunks, // number of sub-packets - 1 |
8522 | 374 extra, // table of sub-packet offsets |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
375 0, // unknown, seems to be unused |
7082 | 376 dp_hdr->timestamp,// timestamp (the integer value from the stream) |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
377 }; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
378 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
379 if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
380 |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
381 if(inited){ // rv30 width/height not yet known |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
382 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/, |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
383 sh->disp_w, sh->disp_h); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
384 if(!mpi) return NULL; |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
385 buffer=mpi->planes[0]; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
386 } else { |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
387 buffer=malloc(sh->disp_w*sh->disp_h*3/2); |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
388 if (!buffer) return 0; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
389 } |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
390 |
8525 | 391 #ifdef USE_WIN32DLL |
392 if (dll_type == 1) | |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
393 result=(*wrvyuv_transform)(dp_data, buffer, &transform_in, |
8525 | 394 transform_out, sh->context); |
395 else | |
396 #endif | |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
397 result=(*rvyuv_transform)(dp_data, buffer, &transform_in, |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
398 transform_out, sh->context); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
399 |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
400 if(!inited){ // rv30 width/height now known |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
401 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
|
402 sh->disp_w=transform_out[3]; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
403 sh->disp_h=transform_out[4]; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
404 if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
405 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/, |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
406 sh->disp_w, sh->disp_h); |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
407 if(!mpi) return NULL; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
408 memcpy(mpi->planes[0],buffer,sh->disp_w*sh->disp_h*3/2); |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
409 free(buffer); |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
410 inited=1; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
411 } |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
412 |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
413 return (result?NULL:mpi); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
414 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
415 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
416 #endif |