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