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