2 * This is a small DLL that works as a wrapper for the actual realdrv4.so.6.0
3 * DLL from RealPlayer 8.0.
5 * This file is part of MPlayer.
7 * MPlayer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * MPlayer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 Assuming that RACloseCodec is the last call.
33 typedef unsigned long ulong
;
35 //000000000000a410 g DF .text 0000000000000043 G2 RV20toYUV420Free
36 //000000000000a6c0 g DF .text 0000000000000060 G2 RV20toYUV420CustomMessage
37 //000000000000a200 g DF .text 000000000000020c G2 RV20toYUV420Init
38 //000000000000a724 g DF .text 0000000000000132 G2 RV20toYUV420HiveMessage
39 //000000000000a458 g DF .text 0000000000000262 G2 RV20toYUV420Transform
41 ulong (*rvyuvCustomMessage
)(ulong
,ulong
);
42 ulong (*rvyuvFree
)(ulong
);
43 ulong (*rvyuvHiveMessage
)(ulong
,ulong
);
44 ulong (*rvyuvInit
)(ulong
,ulong
);
45 ulong (*rvyuvTransform
)(ulong
,ulong
,ulong
,ulong
,ulong
);
47 //void (*setDLLAccessPath)(ulong);
52 /* exits program when failure */
54 fputs("loadSyms()\n", stderr
);
58 fputs("opening dll...\n",stderr
);
59 handle
= dlopen ("/usr/local/RealPlayer8/Codecs/realdrv4.so.6.0", RTLD_LAZY
);
61 fputs (dlerror(), stderr
);
65 rvyuvCustomMessage
= dlsym(handle
, "RV20toYUV420CustomMessage");
66 if ((error
= dlerror()) != NULL
) {
67 fprintf (stderr
, "dlsym(rvyuvCustomMessage): %s\n", error
);
70 fprintf(stderr
, "RV20toYUV420CustomMessage()=0x%0x\n", rvyuvCustomMessage
);
71 rvyuvFree
= dlsym(handle
, "RV20toYUV420Free");
72 if ((error
= dlerror()) != NULL
) {
73 fprintf (stderr
, "dlsym(rvyuvFree): %s\n", error
);
76 fprintf(stderr
, "RV20toYUV420Free()=0x%0x\n", rvyuvFree
);
77 rvyuvHiveMessage
= dlsym(handle
, "RV20toYUV420HiveMessage");
78 if ((error
= dlerror()) != NULL
) {
79 fprintf (stderr
, "dlsym(rvyuvHiveMessage): %s\n", error
);
82 fprintf(stderr
, "RV20toYUV420HiveMessage()=0x%0x\n", rvyuvHiveMessage
);
83 rvyuvInit
= dlsym(handle
, "RV20toYUV420Init");
84 if ((error
= dlerror()) != NULL
) {
85 fprintf (stderr
, "dlsym(rvyuvInit): %s\n", error
);
88 fprintf(stderr
, "RV20toYUV420Init()=0x%0x\n", rvyuvInit
);
89 rvyuvTransform
= dlsym(handle
, "RV20toYUV420Transform");
90 if ((error
= dlerror()) != NULL
) {
91 fprintf (stderr
, "dlsym(rvyuvTransform): %s\n", error
);
94 fprintf(stderr
, "RV20toYUV420Transform()=0x%0x\n", rvyuvTransform
);
112 struct timeval tv1
, tv2
;
115 gettimeofday(&tv1
, &tz
);
120 gettimeofday(&tv2
, &tz
);
121 secs
=tv2
.tv_sec
-tv1
.tv_sec
;
122 usecs
=tv2
.tv_usec
-tv1
.tv_usec
;
127 // fprintf(stderr, "Duration: %ld.%.6lds\n", secs, usecs);
131 static void hexdump(void *pos
, int len
) {
132 unsigned char *cpos
=pos
, *cpos1
;
133 int lines
=(len
+15)>>4;
136 fprintf(stderr
, "#R# %0x ", (int)cpos
-(int)pos
);
140 fprintf(stderr
, "%02x ", *(cpos
++));
142 fprintf(stderr
, " ");
150 unsigned char ch
=(*(cpos
++));
151 if ((ch
<32)||(ch
>127)) ch
='.';
162 ulong
RV20toYUV420CustomMessage(ulong
* p1
,ulong p2
) {
166 fprintf(stderr
, "#R# => RV20toYUV420CustomMessage(%p,%p) [%ld,%ld,%ld] \n", p1
, p2
, p1
[0],p1
[1],p1
[2]);
170 memset(temp
,0x77,16*4);
171 memcpy(temp
,p1
[2],16);
178 // fprintf(stderr, "ulong p2=0x%0lx(%ld))\n", p2, p2);
179 // hexdump((void*)p1, 12);
180 // if (pp1[0]==0x24) {
181 // hexdump((void*)(pp1[2]),128);
184 result
=(*rvyuvCustomMessage
)(p1
,p2
);
186 fprintf(stderr
, "#R# <= RV20toYUV420CustomMessage --> 0x%0lx(%ld)\n", result
, result
);
190 ulong
RV20toYUV420Free(ulong p1
) {
192 fprintf(stderr
, "RV20toYUV420Free(ulong p1=0x%0lx(%ld))\n", p1
, p1
);
193 // hexdump((void*)p1, 44);
195 result
=(*rvyuvFree
)(p1
);
197 // hexdump((void*)p1, 44);
198 fprintf(stderr
, "RV20toYUV420Free --> 0x%0lx(%ld)\n\n\n", result
, result
);
204 ulong
RV20toYUV420HiveMessage(ulong
*p1
,ulong p2
) {
206 fprintf(stderr
, "#R# RV20toYUV420HiveMessage(%p,%p)\n", p1
, p2
);
207 // p1->constant,p1->width,p1->height,p1->format1,p1->format2);
208 // fprintf(stderr, "ulong p2=0x%0lx(%ld))\n", p2, p2);
209 // hexdump((void*)p1, sizeof(struct init_data));
211 fprintf(stderr
,">HIVE %ld %p\n",p1
[0],p1
[1]);
213 fprintf(stderr
,"COPY INIT DATA!\n");
214 memset(h_temp
,0x77,1000);
216 fprintf(stderr
,"COPY OK!\n");
219 // result=(*rvyuvHiveMessage)(p1,p2);
220 result
=(*rvyuvHiveMessage
)(h_temp
,p2
);
223 fprintf(stderr
,"COPY INIT DATA!\n");
225 fprintf(stderr
,"COPY OK!\n");
227 memset(h_temp
,0x77,1000);
232 fprintf(stderr
,"<HIVE %ld %p\n",p1
[0],p1
[1]);
234 // hexdump((void*)p1, sizeof(struct init_data));
235 // hexdump((void*)p1, 8);
236 fprintf(stderr
, "#R# RV20toYUV420HiveMessage --> 0x%0lx(%ld)\n\n", result
, result
);
241 short constant
; //=0xb;
251 static char i_temp
[32768];
253 ulong
RV20toYUV420Init(ulong p1
,ulong p2
) {
255 fprintf(stderr
, "#R# RV20toYUV420Init(ulong p1=0x%0lx(%ld), ", p1
, p1
);
256 fprintf(stderr
, "ulong p2=0x%0lx(%ld))\n", p2
, p2
);
258 fprintf(stderr
,"COPY INIT DATA!\n");
259 memcpy(i_temp
,p1
,24);
261 fprintf(stderr
,"COPY OK!\n");
263 hexdump((void*)p1
, 24);
265 result
=(*rvyuvInit
)(p1
,p2
);
267 hexdump((void*)p1
, 24);
269 memset(i_temp
,0x77,1000);
271 // hexdump(*((void**)p2), 512);
272 fprintf(stderr
, "#R# RV20toYUV420Init --> 0x%0lx(%ld)\n\n\n", result
, result
);
276 unsigned long build_crc(unsigned char *pch
, unsigned long len
) {
277 unsigned long crc
=0, a
;
279 // it's not the real crc function, but so what...
285 // crc=((crc<<3)+b)^a;
291 #define MIN(a,b) ((a)<(b)?(a):(b))
293 // p1=input data (stream)
298 ulong
RV20toYUV420Transform(ulong p1
,ulong p2
,ulong p3
,ulong p4
,ulong p5
) {
300 //result=RV20toYUV420Transform(char *input_stream, char *output_data,
301 // struct transin *, struct transout *, struct rvyuvMain *);
310 unsigned long crc_src
, crc0
;
311 // unsigned long len, crc1, crc2;
312 unsigned char *pch
=(char *)p1
;
313 fprintf(stderr
, "#R# RV20toYUV420Transform(in=%p,out=%p,tin=%p,tout=%p,yuv=%p)\n",p1
,p2
,p3
,p4
,p5
);
314 // input data, length=*p3
315 // hexdump((void*)p1, /*MIN(64,*/ *((ulong*)p3) /*)*/ );
320 // len=pp3[3]*pp3[4]*3/2;
322 // while(--len) *(pch++)=0;
323 // hexdump((char*)p2, 64);
324 // hexdump((void*)p3, 32);
325 // hexdump((void*)p5, 64);
327 // if (pp3[3]>1024) {
328 // hexdump((void*)(pp3[3]),32);
333 // it's not the real crc function, but so what...
335 crc_src
=build_crc(pch
, pp3
[0]);
338 fprintf(stderr
,"transin1[%p]: {%ld/%ld} ",pp4
,pp3
[2],pp3
[0]);
339 // pp4[0],pp4[1],pp4[2],pp4[3],
340 // pp4[4],pp4[5],pp4[6],pp4[7]);
342 memset(temp
,0x77,128*4);
344 memcpy(temp
,pp4
,8*(pp3
[2]+1));
345 for(i
=0;i
<=pp3
[2];i
++){
346 fprintf(stderr
," %p(%ld)",temp
[i
*2],temp
[i
*2+1]);
348 fprintf(stderr
,"\n");
360 /* fprintf(stderr, "rvyuvMain=0x%0x\n", v);
363 fprintf(stderr, "[$+3ch]=0x%0x\n", v);
367 fprintf(stderr, "[$+60h]=0x%0x\n", v);
371 fprintf(stderr, "[$+28h]=0x%0x\n", v);
378 fprintf(stderr, "[$+178h]=0x%0x\n", v);
383 result
=(*rvyuvTransform
)(p1
,p2
,p3
,p4
,p5
);
386 crc0
=build_crc(p2
, 176*144);
387 // crc1=build_crc(p2+pp4[3]*pp4[4]/2, pp4[3]*pp4[4]/2);
388 // crc2=build_crc(p2+pp4[3]*pp4[4], pp4[3]*pp4[4]/2);
391 // TRANSFORM: <timestamp> <numblocks> <len> <crc_src> <crc_dest> <p4[4]>
392 // fprintf(stderr, "TRAFO:\t%ld\t%ld\t%ld\t%.8lX\t%.8lX\t%ld\n",
393 // pp3[5], pp3[2], pp3[0], crc_src, crc0, pp3[4]);
394 fprintf(stderr
, "#R# Decode: %ld(%ld) [%08lX] pts=%ld -> %ld [%08lX]\n",
395 pp3
[0],pp3
[2],crc_src
,pp3
[5],
399 // hexdump((char*)p2, /*64*/ pp4[3]*pp4[4]/2);
400 // hexdump((void*)p4, 20);
401 // hexdump((void*)p5, 512);
402 // fprintf(stderr, "RV20toYUV420Transform --> 0x%0lx(%ld)\n\n\n", result, result);