2 * This is a small DLL that works as a wrapper for the actual realdrv2.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 ulong (*rvyuvCustomMessage
)(ulong
,ulong
);
36 ulong (*rvyuvFree
)(ulong
);
37 ulong (*rvyuvHiveMessage
)(ulong
,ulong
);
38 ulong (*rvyuvInit
)(ulong
,ulong
);
39 ulong (*rvyuvTransform
)(ulong
,ulong
,ulong
,ulong
,ulong
);
40 ulong (*rvyuvRNFRUFree
)(ulong
);
41 ulong (*rvyuvRNFRUGetFrame
)(ulong
,ulong
,ulong
);
42 ulong (*rvyuvRNFRUInit
)(ulong
,ulong
,ulong
);
43 ulong (*rvyuvRNFRUSetup
)(ulong
,ulong
,ulong
,ulong
,ulong
,ulong
,ulong
,ulong
);
45 //void (*setDLLAccessPath)(ulong);
50 /* exits program when failure */
52 fputs("loadSyms()\n", stderr
);
56 fputs("opening dll...\n",stderr
);
57 handle
= dlopen ("/usr/local/RealPlayer8/Codecs/realdrv2.so.6.0", RTLD_LAZY
);
59 fputs (dlerror(), stderr
);
63 rvyuvCustomMessage
= dlsym(handle
, "RV20toYUV420CustomMessage");
64 if ((error
= dlerror()) != NULL
) {
65 fprintf (stderr
, "dlsym(rvyuvCustomMessage): %s\n", error
);
68 fprintf(stderr
, "RV20toYUV420CustomMessage()=0x%0x\n", rvyuvCustomMessage
);
69 rvyuvFree
= dlsym(handle
, "RV20toYUV420Free");
70 if ((error
= dlerror()) != NULL
) {
71 fprintf (stderr
, "dlsym(rvyuvFree): %s\n", error
);
74 fprintf(stderr
, "RV20toYUV420Free()=0x%0x\n", rvyuvFree
);
75 rvyuvHiveMessage
= dlsym(handle
, "RV20toYUV420HiveMessage");
76 if ((error
= dlerror()) != NULL
) {
77 fprintf (stderr
, "dlsym(rvyuvHiveMessage): %s\n", error
);
80 fprintf(stderr
, "RV20toYUV420HiveMessage()=0x%0x\n", rvyuvHiveMessage
);
81 rvyuvInit
= dlsym(handle
, "RV20toYUV420Init");
82 if ((error
= dlerror()) != NULL
) {
83 fprintf (stderr
, "dlsym(rvyuvInit): %s\n", error
);
86 fprintf(stderr
, "RV20toYUV420Init()=0x%0x\n", rvyuvInit
);
87 rvyuvTransform
= dlsym(handle
, "RV20toYUV420Transform");
88 if ((error
= dlerror()) != NULL
) {
89 fprintf (stderr
, "dlsym(rvyuvTransform): %s\n", error
);
92 fprintf(stderr
, "RV20toYUV420Transform()=0x%0x\n", rvyuvTransform
);
93 rvyuvRNFRUFree
= dlsym(handle
, "RV20toYUV420_RN_FRU_Free");
94 if ((error
= dlerror()) != NULL
) {
95 fprintf (stderr
, "dlsym(rvyuvRNFRUFree): %s\n", error
);
98 fprintf(stderr
, "RV20toYUV420_RN_FRU_Free()=0x%0x\n", rvyuvRNFRUFree
);
99 rvyuvRNFRUGetFrame
= dlsym(handle
, "RV20toYUV420_RN_FRU_GetFrame");
100 if ((error
= dlerror()) != NULL
) {
101 fprintf (stderr
, "dlsym(rvyuvRNFRUGetFrame): %s\n", error
);
104 fprintf(stderr
, "RV20toYUV420_RN_FRU_GetFrame()=0x%0x\n", rvyuvRNFRUGetFrame
);
105 rvyuvRNFRUInit
= dlsym(handle
, "RV20toYUV420_RN_FRU_Init");
106 if ((error
= dlerror()) != NULL
) {
107 fprintf (stderr
, "dlsym(rvyuvRNFRUInit): %s\n", error
);
110 fprintf(stderr
, "RV20toYUV420_RN_FRU_Init()=0x%0x\n", rvyuvRNFRUInit
);
111 rvyuvRNFRUSetup
= dlsym(handle
, "RV20toYUV420_RN_FRU_Setup");
112 if ((error
= dlerror()) != NULL
) {
113 fprintf (stderr
, "dlsym(rvyuvRNFRUSetup): %s\n", error
);
116 fprintf(stderr
, "RV20toYUV420_RN_FRU_Setup()=0x%0x\n", rvyuvRNFRUSetup
);
118 /* setDLLAccessPath = dlsym(handle, "SetDLLAccessPath");
119 if ((error = dlerror()) != NULL) {
120 fprintf (stderr, "dlsym(SetDLLAccessPath): %s\n", error);
127 void closeDll(void) {
140 struct timeval tv1
, tv2
;
143 gettimeofday(&tv1
, &tz
);
148 gettimeofday(&tv2
, &tz
);
149 secs
=tv2
.tv_sec
-tv1
.tv_sec
;
150 usecs
=tv2
.tv_usec
-tv1
.tv_usec
;
155 // fprintf(stderr, "Duration: %ld.%.6lds\n", secs, usecs);
159 static void hexdump(void *pos
, int len
) {
160 unsigned char *cpos
=pos
, *cpos1
;
161 int lines
=(len
+15)>>4;
164 fprintf(stderr
, "#R# %0x ", (int)cpos
-(int)pos
);
168 fprintf(stderr
, "%02x ", *(cpos
++));
170 fprintf(stderr
, " ");
178 unsigned char ch
=(*(cpos
++));
179 if ((ch
<32)||(ch
>127)) ch
='.';
190 ulong
RV20toYUV420CustomMessage(ulong
* p1
,ulong p2
) {
194 fprintf(stderr
, "#R# => RV20toYUV420CustomMessage(%p,%p) [%ld,%ld,%ld] \n", p1
, p2
, p1
[0],p1
[1],p1
[2]);
197 if(p1[0]!=17) return 0;
199 if(p1[1]!=1) return 0;
201 if(p1[0]==105) return 0;
202 if(p1[0]==3) return 0;
203 if(p1[0]==18) return 0;
204 if(p1[0]==30) return 0;
209 memset(temp
,0x77,16*4);
210 memcpy(temp
,p1
[2],16);
224 // fprintf(stderr, "ulong p2=0x%0lx(%ld))\n", p2, p2);
225 // hexdump((void*)p1, 12);
226 // if (pp1[0]==0x24) {
227 // hexdump((void*)(pp1[2]),128);
230 result
=(*rvyuvCustomMessage
)(p1
,p2
);
232 fprintf(stderr
, "#R# <= RV20toYUV420CustomMessage --> 0x%0lx(%ld)\n", result
, result
);
236 ulong
RV20toYUV420Free(ulong p1
) {
238 fprintf(stderr
, "RV20toYUV420Free(ulong p1=0x%0lx(%ld))\n", p1
, p1
);
239 // hexdump((void*)p1, 44);
241 result
=(*rvyuvFree
)(p1
);
243 // hexdump((void*)p1, 44);
244 fprintf(stderr
, "RV20toYUV420Free --> 0x%0lx(%ld)\n\n\n", result
, result
);
250 ulong
RV20toYUV420HiveMessage(ulong
*p1
,ulong p2
) {
252 fprintf(stderr
, "#R# RV20toYUV420HiveMessage(%p,%p)\n", p1
, p2
);
253 // p1->constant,p1->width,p1->height,p1->format1,p1->format2);
254 // fprintf(stderr, "ulong p2=0x%0lx(%ld))\n", p2, p2);
255 // hexdump((void*)p1, sizeof(struct init_data));
257 fprintf(stderr
,">HIVE %ld %p\n",p1
[0],p1
[1]);
259 if(p1
[0]!=0) return 0;
264 // fprintf(stderr,"COPY INIT DATA!\n");
265 memset(h_temp
,0x77,1000);
267 // fprintf(stderr,"COPY OK!\n");
270 // result=(*rvyuvHiveMessage)(p1,p2);
271 result
=(*rvyuvHiveMessage
)(h_temp
,p2
);
274 fprintf(stderr
,"COPY INIT DATA!\n");
276 fprintf(stderr
,"COPY OK!\n");
278 memset(h_temp
,0x77,1000);
283 fprintf(stderr
,"<HIVE %ld %p\n",p1
[0],p1
[1]);
285 // hexdump((void*)p1, sizeof(struct init_data));
286 // hexdump((void*)p1, 8);
287 fprintf(stderr
, "#R# RV20toYUV420HiveMessage --> 0x%0lx(%ld)\n\n", result
, result
);
292 short constant
; //=0xb;
302 static char i_temp
[32768];
304 ulong
RV20toYUV420Init(ulong p1
,ulong p2
) {
306 fprintf(stderr
, "#R# RV20toYUV420Init(ulong p1=0x%0lx(%ld), ", p1
, p1
);
307 fprintf(stderr
, "ulong p2=0x%0lx(%ld))\n", p2
, p2
);
309 fprintf(stderr
,"COPY INIT DATA!\n");
310 memcpy(i_temp
,p1
,24);
312 fprintf(stderr
,"COPY OK!\n");
314 hexdump((void*)p1
, 24);
316 result
=(*rvyuvInit
)(p1
,p2
);
318 hexdump((void*)p1
, 24);
320 memset(i_temp
,0x77,1000);
322 // hexdump(*((void**)p2), 512);
323 fprintf(stderr
, "#R# RV20toYUV420Init --> 0x%0lx(%ld)\n\n\n", result
, result
);
327 unsigned long build_crc(unsigned char *pch
, unsigned long len
) {
328 unsigned long crc
=0, a
;
330 // it's not the real crc function, but so what...
336 // crc=((crc<<3)+b)^a;
342 #define MIN(a,b) ((a)<(b)?(a):(b))
344 // p1=input data (stream)
349 ulong
RV20toYUV420Transform(ulong p1
,ulong p2
,ulong p3
,ulong p4
,ulong p5
) {
351 //result=RV20toYUV420Transform(char *input_stream, char *output_data,
352 // struct transin *, struct transout *, struct rvyuvMain *);
361 unsigned long crc_src
, crc0
;
362 // unsigned long len, crc1, crc2;
363 unsigned char *pch
=(char *)p1
;
364 fprintf(stderr
, "#R# RV20toYUV420Transform(in=%p,out=%p,tin=%p,tout=%p,yuv=%p)\n",p1
,p2
,p3
,p4
,p5
);
365 // input data, length=*p3
366 // hexdump((void*)p1, /*MIN(64,*/ *((ulong*)p3) /*)*/ );
371 // len=pp3[3]*pp3[4]*3/2;
373 // while(--len) *(pch++)=0;
374 // hexdump((char*)p2, 64);
375 // hexdump((void*)p3, 32);
376 // hexdump((void*)p5, 64);
378 // if (pp3[3]>1024) {
379 // hexdump((void*)(pp3[3]),32);
384 // it's not the real crc function, but so what...
386 crc_src
=build_crc(pch
, pp3
[0]);
389 fprintf(stderr
,"transin1[%p]: {%ld/%ld} ",pp4
,pp3
[2],pp3
[0]);
390 // pp4[0],pp4[1],pp4[2],pp4[3],
391 // pp4[4],pp4[5],pp4[6],pp4[7]);
393 memset(temp
,0x77,128*4);
395 memcpy(temp
,pp4
,8*(pp3
[2]+1));
396 for(i
=0;i
<=pp3
[2];i
++){
397 fprintf(stderr
," %p(%ld)",temp
[i
*2],temp
[i
*2+1]);
399 fprintf(stderr
,"\n");
411 /* fprintf(stderr, "rvyuvMain=0x%0x\n", v);
414 fprintf(stderr, "[$+3ch]=0x%0x\n", v);
418 fprintf(stderr, "[$+60h]=0x%0x\n", v);
422 fprintf(stderr, "[$+28h]=0x%0x\n", v);
429 fprintf(stderr, "[$+178h]=0x%0x\n", v);
434 result
=(*rvyuvTransform
)(p1
,p2
,p3
,p4
,p5
);
437 crc0
=build_crc(p2
, 176*144);
438 // crc1=build_crc(p2+pp4[3]*pp4[4]/2, pp4[3]*pp4[4]/2);
439 // crc2=build_crc(p2+pp4[3]*pp4[4], pp4[3]*pp4[4]/2);
442 // TRANSFORM: <timestamp> <numblocks> <len> <crc_src> <crc_dest> <p4[4]>
443 // fprintf(stderr, "TRAFO:\t%ld\t%ld\t%ld\t%.8lX\t%.8lX\t%ld\n",
444 // pp3[5], pp3[2], pp3[0], crc_src, crc0, pp3[4]);
445 fprintf(stderr
, "#R# Decode: %ld(%ld) [%08lX] pts=%ld -> %ld [%08lX]\n",
446 pp3
[0],pp3
[2],crc_src
,pp3
[5],
450 // hexdump((char*)p2, /*64*/ pp4[3]*pp4[4]/2);
451 // hexdump((void*)p4, 20);
452 // hexdump((void*)p5, 512);
453 // fprintf(stderr, "RV20toYUV420Transform --> 0x%0lx(%ld)\n\n\n", result, result);
457 ulong
RV20toYUV420_RN_FRU_Free(ulong p1
) {
459 fprintf(stderr
, "RV20toYUV420_RN_FRU_Free(ulong p1=0x%0lx(%ld))\n", p1
, p1
);
461 result
=(*rvyuvRNFRUFree
)(p1
);
463 fprintf(stderr
, "RV20toYUV420_RN_FRU_Free --> 0x%0lx(%ld)\n\n\n", result
, result
);
467 ulong
RV20toYUV420_RN_FRU_GetFrame(ulong p1
,ulong p2
,ulong p3
) {
469 // fprintf(stderr, "RV20toYUV420_RN_FRU_GetFrame(ulong p1=0x%0lx(%ld), ", p1, p1);
470 // fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
471 // fprintf(stderr, "ulong p3=0x%0lx(%ld))\n", p3, p3);
472 // hexdump((void*)p1, 44);
474 result
=(*rvyuvRNFRUGetFrame
)(p1
,p2
,p3
);
476 // hexdump((void*)p1, 44);
477 // fprintf(stderr, "RV20toYUV420_RN_FRU_GetFrame --> 0x%0lx(%ld)\n\n\n", result, result);
481 ulong
RV20toYUV420_RN_FRU_Init(ulong p1
,ulong p2
,ulong p3
) {
483 // fprintf(stderr, "RV20toYUV420_RN_FRU_Init(ulong p1=0x%0lx(%ld), ", p1, p1);
484 // fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
485 // fprintf(stderr, "ulong p3=0x%0lx(%ld))\n", p3, p3);
486 // hexdump((void*)p1, 44);
488 result
=(*rvyuvRNFRUInit
)(p1
,p2
,p3
);
490 // hexdump((void*)p1, 44);
491 // fprintf(stderr, "RV20toYUV420_RN_FRU_Init --> 0x%0lx(%ld)\n\n\n", result, result);
495 ulong
RV20toYUV420_RN_FRU_Setup(ulong p1
,ulong p2
,ulong p3
,ulong p4
,
496 ulong p5
,ulong p6
,ulong p7
,ulong p8
) {
498 // fprintf(stderr, "RV20toYUV420_RN_FRU_Setup(ulong p1=0x%0lx(%ld), ", p1, p1);
499 // fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
500 // fprintf(stderr, "ulong p3=0x%0lx(%ld), ", p3, p3);
501 // fprintf(stderr, "ulong p4=0x%0lx(%ld),\n\t", p4, p4);
502 // fprintf(stderr, "ulong p5=0x%0lx(%ld), ", p5, p5);
503 // fprintf(stderr, "ulong p6=0x%0lx(%ld),\n\t", p6, p6);
504 // fprintf(stderr, "ulong p7=0x%0lx(%ld), ", p7, p7);
505 // fprintf(stderr, "ulong p8=0x%0lx(%ld))\n", p8, p8);
506 // hexdump((void*)p1, 44);
508 result
=(*rvyuvRNFRUSetup
)(p1
,p2
,p3
,p4
,p5
,p6
,p7
,p8
);
510 // hexdump((void*)p1, 44);
511 // fprintf(stderr, "RV20toYUV420_RN_FRU_Setup --> 0x%0lx(%ld)\n\n\n", result, result);
515 /*void SetDLLAccessPath(ulong p1) {
516 fprintf(stderr, "SetDLLAccessPath(ulong p1=0x%0lx(%ld))\n", p1, p1);
517 hexdump((void*)p1, 44);
518 (*setDLLAccessPath)(p1);
519 hexdump((void*)p1, 44);
520 fprintf(stderr, "--> void\n\n\n");