Mercurial > mplayer.hg
comparison TOOLS/realcodecs/14_4.c @ 10123:8bf6c57c5bbd
wrappers for 14.4 and 28.8 codecs
author | rtognimp |
---|---|
date | Sat, 17 May 2003 18:19:48 +0000 |
parents | |
children | 3b80b74b6813 |
comparison
equal
deleted
inserted
replaced
10122:5ea24082eaaa | 10123:8bf6c57c5bbd |
---|---|
1 /* | |
2 GPL v2 blah blah | |
3 | |
4 This is a small dll that works as a wrapper for the actual 14_4.so.6.0 | |
5 dll from real player 8.0. | |
6 */ | |
7 | |
8 /* | |
9 Assuming that RACloseCodec is the last call. | |
10 */ | |
11 | |
12 #include <stddef.h> | |
13 #include <stdio.h> | |
14 #include <dlfcn.h> | |
15 #include <sys/time.h> | |
16 | |
17 typedef unsigned long ulong; | |
18 | |
19 ulong (*raCloseCodec)(ulong); | |
20 ulong (*raDecode)(ulong,ulong,ulong,ulong,ulong,ulong); | |
21 ulong (*raFreeDecoder)(ulong); | |
22 ulong (*raGetFlavorProperty)(ulong,ulong,ulong,ulong); | |
23 ulong (*raGetNumberOfFlavors)(void); | |
24 ulong (*raInitDecoder)(ulong,ulong); | |
25 ulong (*raOpenCodec2)(ulong); | |
26 ulong (*raSetFlavor)(ulong); | |
27 | |
28 int b_dlOpened=0; | |
29 void *handle=NULL; | |
30 | |
31 /* exits program when failure */ | |
32 void loadSyms() { | |
33 fputs("loadSyms()\n", stderr); | |
34 if (!b_dlOpened) { | |
35 char *error; | |
36 | |
37 // fputs("opening dll...\n"); | |
38 handle = dlopen ("/home/r/RealPlayer8/Codecs/real14_4.so.6.0", RTLD_LAZY); | |
39 if (!handle) { | |
40 fputs (dlerror(), stderr); | |
41 exit(1); | |
42 } | |
43 | |
44 raCloseCodec = dlsym(handle, "RACloseCodec"); | |
45 if ((error = dlerror()) != NULL) { | |
46 fprintf (stderr, "dlsym(RACloseCodec): %s\n", error); | |
47 exit(1); | |
48 } | |
49 raDecode = dlsym(handle, "RADecode"); | |
50 if ((error = dlerror()) != NULL) { | |
51 fprintf (stderr, "dlsym(RADecode): %s\n", error); | |
52 exit(1); | |
53 } | |
54 raFreeDecoder = dlsym(handle, "RAFreeDecoder"); | |
55 if ((error = dlerror()) != NULL) { | |
56 fprintf (stderr, "dlsym(RAFreeDecoder): %s\n", error); | |
57 exit(1); | |
58 } | |
59 raGetFlavorProperty = dlsym(handle, "RAGetFlavorProperty"); | |
60 if ((error = dlerror()) != NULL) { | |
61 fprintf (stderr, "dlsym(RAGetFlavorProperty): %s\n", error); | |
62 exit(1); | |
63 } | |
64 raGetNumberOfFlavors = dlsym(handle, "RAGetNumberOfFlavors"); | |
65 if ((error = dlerror()) != NULL) { | |
66 fprintf (stderr, "dlsym(RAGetNumberOfFlavors): %s\n", error); | |
67 exit(1); | |
68 } | |
69 raInitDecoder = dlsym(handle, "RAInitDecoder"); | |
70 if ((error = dlerror()) != NULL) { | |
71 fprintf (stderr, "dlsym(RAInitDecoder): %s\n", error); | |
72 exit(1); | |
73 } | |
74 raOpenCodec2 = dlsym(handle, "RAOpenCodec2"); | |
75 if ((error = dlerror()) != NULL) { | |
76 fprintf (stderr, "dlsym(RAOpenCodec2): %s\n", error); | |
77 exit(1); | |
78 } | |
79 raSetFlavor = dlsym(handle, "RASetFlavor"); | |
80 if ((error = dlerror()) != NULL) { | |
81 fprintf (stderr, "dlsym(RASetFlavor): %s\n", error); | |
82 exit(1); | |
83 } | |
84 b_dlOpened=1; | |
85 } | |
86 } | |
87 | |
88 void closeDll() { | |
89 if (handle) { | |
90 b_dlOpened=0; | |
91 dlclose(handle); | |
92 handle=NULL; | |
93 } | |
94 } | |
95 | |
96 void _init(void) { | |
97 loadSyms(); | |
98 } | |
99 | |
100 struct timezone tz; | |
101 struct timeval tv1, tv2; | |
102 | |
103 void tic() { | |
104 gettimeofday(&tv1, &tz); | |
105 } | |
106 | |
107 void toc() { | |
108 long secs, usecs; | |
109 gettimeofday(&tv2, &tz); | |
110 secs=tv2.tv_sec-tv1.tv_sec; | |
111 usecs=tv2.tv_usec-tv1.tv_usec; | |
112 if (usecs<0) { | |
113 usecs+=1000000; | |
114 --secs; | |
115 } | |
116 fprintf(stderr, "Duration: %d.%0.6ds\n", secs, usecs); | |
117 } | |
118 | |
119 | |
120 void hexdump(void *pos, int len) { | |
121 unsigned char *cpos=pos, *cpos1; | |
122 int lines=(len+15)>>4; | |
123 while(lines--) { | |
124 int len1=len, i; | |
125 fprintf(stderr, "%0x ", cpos); | |
126 cpos1=cpos; | |
127 for (i=0;i<16;i++) { | |
128 if (len1>0) { | |
129 fprintf(stderr, "%02x ", *(cpos++)); | |
130 } else { | |
131 fprintf(stderr, " "); | |
132 } | |
133 len1--; | |
134 } | |
135 fputs(" ", stderr); | |
136 cpos=cpos1; | |
137 for (i=0;i<16;i++) { | |
138 if (len>0) { | |
139 unsigned char ch=(*(cpos++)); | |
140 if ((ch<32)||(ch>127)) ch='.'; | |
141 fputc(ch, stderr); | |
142 } | |
143 len--; | |
144 } | |
145 fputs("\n", stderr); | |
146 } | |
147 fputc('\n', stderr); | |
148 } | |
149 | |
150 | |
151 ulong RACloseCodec(ulong p1) { | |
152 ulong result; | |
153 fprintf(stderr, "RACloseCodec(ulong p1=0x%0x(%d))\n", p1, p1); | |
154 result=(*raCloseCodec)(p1); | |
155 // closeDll(); | |
156 fprintf(stderr, "--> 0x%0x(%d)\n\n\n", result, result); | |
157 return result; | |
158 } | |
159 | |
160 static int pkno=0; | |
161 | |
162 ulong RADecode(ulong p1,ulong p2,ulong p3,ulong p4,ulong* p5,ulong p6) { | |
163 ulong result; | |
164 int x,y; | |
165 | |
166 fprintf(stderr, "RADecode(ulong ctx=0x%0x, ", p1); | |
167 fprintf(stderr, "ulong src=0x%0x,\n", p2); | |
168 fprintf(stderr, "ulong len=0x%0x,", p3); | |
169 fprintf(stderr, "ulong dst=0x%0x,\n", p4); | |
170 fprintf(stderr, "ulong dstcnt=0x%0x, ",p5); | |
171 fprintf(stderr, "ulong p6=%d)\n", p6); | |
172 // hexdump((void*)p1, 44); | |
173 hexdump((void*)p2, p3); | |
174 // hexdump((void*)p4, 80); | |
175 // hexdump((void*)p5, 16); | |
176 // tic(); | |
177 | |
178 fprintf(stderr,"\n#CRC[%3d]",pkno++); | |
179 for(y=0;y<10;y++){ | |
180 unsigned short crc=0; | |
181 unsigned char* p=p2; | |
182 p+=60*y; | |
183 for(x=0;x<60;x++){ | |
184 crc+=p[x]<<(x&7); | |
185 } | |
186 fprintf(stderr," %04X",crc); | |
187 } | |
188 fprintf(stderr,"\n"); | |
189 | |
190 result=(*raDecode)(p1,p2,p3,p4,p5,p6); | |
191 // toc(); | |
192 // hexdump((void*)p1, 44); | |
193 // hexdump((void*)p4, 80); | |
194 // hexdump((void*)p5, 16); | |
195 fprintf(stderr, "--> 0x%0x(%d) decoded: %d \n\n\n", result, result, p5[0]); | |
196 return result; | |
197 } | |
198 | |
199 ulong RAFreeDecoder(ulong p1) { | |
200 ulong result; | |
201 fprintf(stderr, "RAFreeDecoder(ulong p1=0x%0x(%d))\n", p1, p1); | |
202 hexdump((void*)p1, 44); | |
203 result=(*raFreeDecoder)(p1); | |
204 fprintf(stderr, "--> 0x%0x(%d)\n\n\n", result, result); | |
205 return result; | |
206 } | |
207 | |
208 ulong RAGetFlavorProperty(ulong p1,ulong p2,ulong p3, ulong p4) { | |
209 ulong result; | |
210 fprintf(stderr, "RAGetFlavorProperty(ulong p1=0x%0x(%d), ", p1, p1); | |
211 fprintf(stderr, "ulong p2=0x%0x(%d),\n", p2, p2); | |
212 fprintf(stderr, "ulong p3=0x%0x(%d), ", p3, p3); | |
213 fprintf(stderr, "ulong p4=0x%0x(%d))\n", p4, p4); | |
214 hexdump((void*)p4/*(void*)(*((void**)p4))*/,p2); | |
215 hexdump((void*)p1, 44); | |
216 tic(); | |
217 result=(*raGetFlavorProperty)(p1,p2,p3,p4); | |
218 toc(); | |
219 fprintf(stderr, "*p4=0x%0x\n", *((ulong*)p4)); | |
220 hexdump((void*)p4/*(void*)(*((void**)p4))*/,p2); | |
221 hexdump((void*)p1, 44); | |
222 fprintf(stderr, "--> 0x%0x(%d)\n\n\n", result, result); | |
223 return result; | |
224 } | |
225 | |
226 ulong RAGetNumberOfFlavors(void) { | |
227 ulong result; | |
228 fprintf(stderr, "RAGetNumberOfFlavors(void)\n"); | |
229 result=(*raGetNumberOfFlavors)(); | |
230 fprintf(stderr, "--> 0x%0x(%d)\n\n\n", result, result); | |
231 return result; | |
232 } | |
233 | |
234 ulong RAInitDecoder(ulong p1,ulong p2) { | |
235 ulong result; | |
236 int temp[256]; | |
237 unsigned char temp2[256]; | |
238 fprintf(stderr, "RAInitDecoder(ulong p1=0x%0x(%d), ", p1, p1); | |
239 fprintf(stderr, "ulong p2=0x%0x(%d))\n", p2, p2); | |
240 hexdump((void*)p2, 4*7); | |
241 // hexdump((void*)p1, 44); | |
242 // memset(temp,0x77,256*4); | |
243 // memcpy(temp,p2,4*7); | |
244 // hexdump((void*)temp[6], 32); | |
245 | |
246 // memset(temp2,0x77,256); | |
247 // memcpy(temp2,temp[6],16); | |
248 // temp[6]=temp2; | |
249 | |
250 result=(*raInitDecoder)(p1,/*temp*/p2); | |
251 // hexdump((void*)temp[6], 32); | |
252 // memcpy(p2,temp,4*11); | |
253 // hexdump((void*)p1, 44); | |
254 fprintf(stderr, "--> 0x%0x(%d)\n\n\n", result, result); | |
255 return result; | |
256 } | |
257 | |
258 ulong RAOpenCodec2(ulong p1) { | |
259 ulong result; | |
260 // loadSyms(); | |
261 fprintf(stderr, "RAOpenCodec2(ulong p1=0x%0x(%d)\n", p1, p1); | |
262 hexdump((void*)p1, 44); | |
263 result=(*raOpenCodec2)(p1); | |
264 hexdump((void*)p1, 44); | |
265 fprintf(stderr, "--> 0x%0x(%d)\n\n\n", result, result); | |
266 return result; | |
267 } | |
268 | |
269 ulong RASetFlavor(ulong p1) { | |
270 ulong result, numprop=0, result1=0; | |
271 ulong numflavors, flavor; | |
272 unsigned short property; | |
273 fprintf(stderr, "RASetFlavor(ulong p1=0x%0x(%d))\n", p1, p1); | |
274 hexdump((void*)p1, 44); | |
275 // hexdump((void*)p1, 44); | |
276 result=(*raSetFlavor)(p1); | |
277 fprintf(stderr, "--> 0x%0x(%d)\n\n\n", result, result); | |
278 | |
279 #if 0 | |
280 fputs("######################## FLAVOR PROPERTIES ###################\n\n", stderr); | |
281 numflavors=raGetNumberOfFlavors2(); | |
282 flavor=0; | |
283 while (flavor<numflavors) { | |
284 fprintf(stderr, "************ Flavor %d *************\n\n", flavor); | |
285 numprop=0; | |
286 while (numprop<32) { | |
287 result1=raGetFlavorProperty(p1, flavor, numprop, (ulong)&property); | |
288 fprintf(stderr, "property %d=%d, result=0x%0x\n\n", | |
289 numprop, property, result1); | |
290 hexdump((void*)result1, property); | |
291 numprop++; | |
292 } | |
293 flavor++; | |
294 } | |
295 | |
296 fputs("######################## FLAVOR PROPERTIES ###################\n\n", stderr); | |
297 #endif | |
298 | |
299 return result; | |
300 } |