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