Mercurial > mplayer.hg
annotate libmpcodecs/vd_realvid.c @ 9954:2615897d001d
also tdfxfb supports geometry
author | attila |
---|---|
date | Mon, 21 Apr 2003 07:53:55 +0000 |
parents | 86b5ea6396ab |
children | ad83de1c0038 |
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 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
7 #include <dlfcn.h> |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
8 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
9 #include "mp_msg.h" |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
10 #include "help_mp.h" |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
11 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
12 #include "vd_internal.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 static vd_info_t info = { |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
15 "RealVideo decoder", |
7174 | 16 "realvid", |
8525 | 17 "Florian Schneider & A'rpi", // win32 dlls support by alex |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
18 "using original closed source codecs for Linux", |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
19 "binary real video codecs" |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
20 }; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
21 |
7174 | 22 LIBVD_EXTERN(realvid) |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
23 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
24 |
8522 | 25 /* |
26 * Structures for data packets. These used to be tables of unsigned ints, but | |
27 * that does not work on 64 bit platforms (e.g. Alpha). The entries that are | |
28 * pointers get truncated. Pointers on 64 bit platforms are 8 byte longs. | |
29 * So we have to use structures so the compiler will assign the proper space | |
30 * for the pointer. | |
31 */ | |
32 typedef struct cmsg_data_s { | |
33 uint32_t data1; | |
34 uint32_t data2; | |
35 uint32_t* dimensions; | |
36 } cmsg_data_t; | |
37 | |
38 typedef struct transform_in_s { | |
39 uint32_t len; | |
40 uint32_t unknown1; | |
41 uint32_t chunks; | |
42 uint32_t* extra; | |
43 uint32_t unknown2; | |
44 uint32_t timestamp; | |
45 } transform_in_t; | |
46 | |
47 static unsigned long (*rvyuv_custom_message)(cmsg_data_t* ,void*); | |
7728 | 48 static unsigned long (*rvyuv_free)(void*); |
49 static unsigned long (*rvyuv_hive_message)(unsigned long,unsigned long); | |
50 static unsigned long (*rvyuv_init)(void*, void*); // initdata,context | |
8522 | 51 static unsigned long (*rvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*); |
8525 | 52 #ifdef USE_WIN32DLL |
53 static unsigned long WINAPI (*wrvyuv_custom_message)(cmsg_data_t* ,void*); | |
54 static unsigned long WINAPI (*wrvyuv_free)(void*); | |
55 static unsigned long WINAPI (*wrvyuv_hive_message)(unsigned long,unsigned long); | |
56 static unsigned long WINAPI (*wrvyuv_init)(void*, void*); // initdata,context | |
57 static unsigned long WINAPI (*wrvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*); | |
58 #endif | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
59 |
7728 | 60 static void *rv_handle=NULL; |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
61 static int inited; |
8525 | 62 #ifdef USE_WIN32DLL |
63 static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */ | |
64 #endif | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
65 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
66 void *__builtin_vec_new(unsigned long size) { |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
67 return malloc(size); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
68 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
69 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
70 void __builtin_vec_delete(void *mem) { |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
71 free(mem); |
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 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
74 void __pure_virtual(void) { |
6361 | 75 printf("FATAL: __pure_virtual() called!\n"); |
76 // exit(1); | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
77 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
78 |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
79 #if defined(__FreeBSD__) || defined(__NetBSD__) |
6361 | 80 void ___brk_addr(void) {exit(0);} |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
81 char **__environ={NULL}; |
6361 | 82 #undef stderr |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
83 FILE *stderr=NULL; |
6361 | 84 #endif |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
85 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
86 // to set/get/query special features/parameters |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
87 static int control(sh_video_t *sh,int cmd,void* arg,...){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
88 // switch(cmd){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
89 // case VDCTRL_QUERY_MAX_PP_LEVEL: |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
90 // return 9; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
91 // case VDCTRL_SET_PP_LEVEL: |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
92 // vfw_set_postproc(sh,10*(*((int*)arg))); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
93 // return CONTROL_OK; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
94 // } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
95 return CONTROL_UNKNOWN; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
96 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
97 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
98 /* exits program when failure */ |
7728 | 99 static int load_syms_linux(char *path) { |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
100 void *handle; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
101 |
6361 | 102 mp_msg(MSGT_DECVIDEO,MSGL_INFO, "opening shared obj '%s'\n", path); |
9386 | 103 handle = dlopen (path, RTLD_LAZY); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
104 if (!handle) { |
6361 | 105 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error: %s\n",dlerror()); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
106 return 0; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
107 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
108 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
109 rvyuv_custom_message = dlsym(handle, "RV20toYUV420CustomMessage"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
110 rvyuv_free = dlsym(handle, "RV20toYUV420Free"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
111 rvyuv_hive_message = dlsym(handle, "RV20toYUV420HiveMessage"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
112 rvyuv_init = dlsym(handle, "RV20toYUV420Init"); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
113 rvyuv_transform = dlsym(handle, "RV20toYUV420Transform"); |
6361 | 114 |
115 if(rvyuv_custom_message && | |
116 rvyuv_free && | |
117 rvyuv_hive_message && | |
118 rvyuv_init && | |
9386 | 119 rvyuv_transform) |
120 { | |
121 rv_handle = handle; | |
122 return 1; | |
123 } | |
6361 | 124 |
125 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n"); | |
9386 | 126 dlclose(handle); |
6361 | 127 return 0; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
128 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
129 |
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
|
130 #ifdef USE_WIN32DLL |
7127 | 131 |
132 #include "../loader/ldt_keeper.h" | |
8525 | 133 void* WINAPI LoadLibraryA(char* name); |
134 void* WINAPI GetProcAddress(void* handle,char* func); | |
135 int WINAPI FreeLibrary(void *handle); | |
7127 | 136 |
7728 | 137 static int load_syms_windows(char *path) { |
6360 | 138 void *handle; |
8525 | 139 |
140 mp_msg(MSGT_DECVIDEO,MSGL_INFO, "opening win32 dll '%s'\n", path); | |
6360 | 141 Setup_LDT_Keeper(); |
9386 | 142 handle = LoadLibraryA(path); |
6361 | 143 mp_msg(MSGT_DECVIDEO,MSGL_V,"win32 real codec handle=%p \n",handle); |
8525 | 144 if (!handle) { |
145 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error loading dll\n"); | |
146 return 0; | |
147 } | |
6360 | 148 |
8525 | 149 wrvyuv_custom_message = GetProcAddress(handle, "RV20toYUV420CustomMessage"); |
150 wrvyuv_free = GetProcAddress(handle, "RV20toYUV420Free"); | |
151 wrvyuv_hive_message = GetProcAddress(handle, "RV20toYUV420HiveMessage"); | |
152 wrvyuv_init = GetProcAddress(handle, "RV20toYUV420Init"); | |
153 wrvyuv_transform = GetProcAddress(handle, "RV20toYUV420Transform"); | |
9386 | 154 |
8525 | 155 if(wrvyuv_custom_message && |
156 wrvyuv_free && | |
157 wrvyuv_hive_message && | |
158 wrvyuv_init && | |
9386 | 159 wrvyuv_transform) |
160 { | |
161 dll_type = 1; | |
162 rv_handle = handle; | |
163 return 1; | |
164 } | |
8525 | 165 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n"); |
9386 | 166 FreeLibrary(handle); |
6360 | 167 return 0; // error |
168 } | |
169 #endif | |
170 | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
171 /* we need exact positions */ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
172 struct rv_init_t { |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
173 short unk1; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
174 short w; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
175 short h; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
176 short unk3; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
177 int unk2; |
6345 | 178 int subformat; |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
179 int unk5; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
180 int format; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
181 } rv_init_t; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
182 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
183 // init driver |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
184 static int init(sh_video_t *sh){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
185 //unsigned int out_fmt; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
186 char path[4096]; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
187 int result; |
6345 | 188 // we export codec id and sub-id from demuxer in bitmapinfohdr: |
189 unsigned int* extrahdr=(unsigned int*)(sh->bih+1); | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
190 struct rv_init_t init_data={ |
6345 | 191 11, sh->disp_w, sh->disp_h,0,0,extrahdr[0], |
192 1,extrahdr[1]}; // rv30 | |
193 | |
194 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
|
195 |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6361
diff
changeset
|
196 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
|
197 |
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
|
198 /* 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
|
199 then try to load the windows ones */ |
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
|
200 if(!load_syms_linux(path)) |
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
|
201 #ifdef USE_WIN32DLL |
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
|
202 if (!load_syms_windows(path)) |
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
|
203 #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
|
204 { |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
205 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll); |
9386 | 206 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Read the RealVideo section of the DOCS!\n"); |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
207 return 0; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
208 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
209 // only I420 supported |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
210 // 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
|
211 // init codec: |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
212 sh->context=NULL; |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
213 inited=0; |
8525 | 214 #ifdef USE_WIN32DLL |
215 if (dll_type == 1) | |
216 result=(*wrvyuv_init)(&init_data, &sh->context); | |
217 else | |
218 #endif | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
219 result=(*rvyuv_init)(&init_data, &sh->context); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
220 if (result){ |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
221 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
|
222 return 0; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
223 } |
6345 | 224 // 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
|
225 if((sh->format<=0x30335652) && (extrahdr[1]>=0x20200002)){ |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
226 uint32_t cmsg24[4]={sh->disp_w,sh->disp_h,((unsigned short *)extrahdr)[4],((unsigned short *)extrahdr)[5]}; |
8522 | 227 cmsg_data_t cmsg_data={0x24,1+((extrahdr[0]>>16)&7), &cmsg24[0]}; |
8525 | 228 |
229 #ifdef USE_WIN32DLL | |
230 if (dll_type == 1) | |
231 (*wrvyuv_custom_message)(&cmsg_data,sh->context); | |
232 else | |
233 #endif | |
8522 | 234 (*rvyuv_custom_message)(&cmsg_data,sh->context); |
6345 | 235 } |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
236 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
|
237 return 1; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
238 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
239 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
240 // uninit driver |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
241 static void uninit(sh_video_t *sh){ |
8525 | 242 #ifdef USE_WIN32DLL |
243 if (dll_type == 1) | |
244 { | |
245 if (wrvyuv_free) wrvyuv_free(sh->context); | |
246 } else | |
247 #endif | |
7728 | 248 if(rvyuv_free) rvyuv_free(sh->context); |
8525 | 249 |
250 #ifdef USE_WIN32DLL | |
251 if (dll_type == 1) | |
252 { | |
253 if (rv_handle) FreeLibrary(rv_handle); | |
254 } else | |
255 #endif | |
6345 | 256 if(rv_handle) dlclose(rv_handle); |
257 rv_handle=NULL; | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
258 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
259 |
7082 | 260 // copypaste from demux_real.c - it should match to get it working! |
261 typedef struct dp_hdr_s { | |
262 uint32_t chunks; // number of chunks | |
263 uint32_t timestamp; // timestamp from packet header | |
264 uint32_t len; // length of actual data | |
265 uint32_t chunktab; // offset to chunk offset array | |
266 } dp_hdr_t; | |
267 | |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
268 // decode a frame |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
269 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
|
270 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
|
271 unsigned long result; |
7082 | 272 dp_hdr_t* dp_hdr=(dp_hdr_t*)data; |
273 unsigned char* dp_data=((unsigned char*)data)+sizeof(dp_hdr_t); | |
274 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
|
275 unsigned char* buffer; |
7082 | 276 |
8522 | 277 unsigned int transform_out[5]; |
278 transform_in_t transform_in={ | |
7082 | 279 dp_hdr->len, // length of the packet (sub-packets appended) |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
280 0, // unknown, seems to be unused |
7082 | 281 dp_hdr->chunks, // number of sub-packets - 1 |
8522 | 282 extra, // table of sub-packet offsets |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
283 0, // unknown, seems to be unused |
7082 | 284 dp_hdr->timestamp,// timestamp (the integer value from the stream) |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
285 }; |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
286 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
287 if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
288 |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
289 if(inited){ // rv30 width/height not yet known |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
290 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
|
291 sh->disp_w, sh->disp_h); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
292 if(!mpi) return NULL; |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
293 buffer=mpi->planes[0]; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
294 } else { |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
295 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
|
296 if (!buffer) return 0; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
297 } |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
298 |
8525 | 299 #ifdef USE_WIN32DLL |
300 if (dll_type == 1) | |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
301 result=(*wrvyuv_transform)(dp_data, buffer, &transform_in, |
8525 | 302 transform_out, sh->context); |
303 else | |
304 #endif | |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
305 result=(*rvyuv_transform)(dp_data, buffer, &transform_in, |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
306 transform_out, sh->context); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
307 |
9552
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
308 if(!inited){ // rv30 width/height now known |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
309 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
|
310 sh->disp_w=transform_out[3]; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
311 sh->disp_h=transform_out[4]; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
312 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
|
313 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
|
314 sh->disp_w, sh->disp_h); |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
315 if(!mpi) return NULL; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
316 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
|
317 free(buffer); |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
318 inited=1; |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
319 } |
86b5ea6396ab
Ugly hack to handle bad width/height values from stream header
arpi
parents:
9386
diff
changeset
|
320 |
6341
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
321 return (result?NULL:mpi); |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
322 } |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
323 |
d79c52610702
RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff
changeset
|
324 #endif |