annotate libmpcodecs/vd_realvid.c @ 30559:10b0a635293b

Remove unused XPM-loading function pixbuf_load_xpm() from spuenc.c. Remove unused function pixbuf_delete() from spuenc.[ch].
author reimar
date Tue, 16 Feb 2010 19:34:41 +0000
parents ad6740b58b0d
children 2b9abdf8f6bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
19 #include <stdio.h>
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
20 #include <stdlib.h>
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
21
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
22 #include "config.h"
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
23
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
24 #ifdef HAVE_LIBDL
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
25 #include <dlfcn.h>
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
26 #endif
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
27
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
28 #include "mp_msg.h"
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
29 #include "help_mp.h"
28468
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
30 #include "mpbswap.h"
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
31
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
32 #include "vd_internal.h"
22577
a033e5519802 Include loader/ prefix in #include path everywhere.
diego
parents: 21563
diff changeset
33 #include "loader/wine/windef.h"
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
34
30504
cc27da5d7286 Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents: 30421
diff changeset
35 static const vd_info_t info = {
6404
83b3315c679b Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents: 6361
diff changeset
36 "RealVideo decoder",
7174
7672615cc811 sync driver names with codec-cfg
arpi
parents: 7172
diff changeset
37 "realvid",
12628
985e1813e298 support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents: 12356
diff changeset
38 "Alex Beregszaszi",
985e1813e298 support for realvideo codecs under macosx, original patch by Donnie Smith
alex
parents: 12356
diff changeset
39 "Florian Schneider, Arpad Gereoffy, Alex Beregszaszi, Donnie Smith",
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
40 "binary real video codecs"
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
41 };
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
42
7174
7672615cc811 sync driver names with codec-cfg
arpi
parents: 7172
diff changeset
43 LIBVD_EXTERN(realvid)
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
44
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
45
8522
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
46 /*
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
47 * Structures for data packets. These used to be tables of unsigned ints, but
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
48 * that does not work on 64 bit platforms (e.g. Alpha). The entries that are
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
49 * pointers get truncated. Pointers on 64 bit platforms are 8 byte longs.
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
50 * So we have to use structures so the compiler will assign the proper space
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
51 * for the pointer.
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
52 */
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
53 typedef struct cmsg_data_s {
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
54 uint32_t data1;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
55 uint32_t data2;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
56 uint32_t* dimensions;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
57 } cmsg_data_t;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
58
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
59 typedef struct transform_in_s {
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
60 uint32_t len;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
61 uint32_t unknown1;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
62 uint32_t chunks;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
63 uint32_t* extra;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
64 uint32_t unknown2;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
65 uint32_t timestamp;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
66 } transform_in_t;
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
67
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
68 static unsigned long (*rvyuv_custom_message)(cmsg_data_t* ,void*);
7728
64b5604195c5 make local stuff 'static', complete uninit
arpi
parents: 7557
diff changeset
69 static unsigned long (*rvyuv_free)(void*);
64b5604195c5 make local stuff 'static', complete uninit
arpi
parents: 7557
diff changeset
70 static unsigned long (*rvyuv_init)(void*, void*); // initdata,context
8522
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
71 static unsigned long (*rvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*);
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
72 #ifdef CONFIG_WIN32DLL
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
73 static unsigned long WINAPI (*wrvyuv_custom_message)(cmsg_data_t* ,void*);
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
74 static unsigned long WINAPI (*wrvyuv_free)(void*);
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
75 static unsigned long WINAPI (*wrvyuv_init)(void*, void*); // initdata,context
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
76 static unsigned long WINAPI (*wrvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*);
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
77 #endif
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
78
7728
64b5604195c5 make local stuff 'static', complete uninit
arpi
parents: 7557
diff changeset
79 static void *rv_handle=NULL;
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25598
diff changeset
80 static int initialized=0;
21559
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
81 static uint8_t *buffer = NULL;
21563
c08b8066a1c6 Only increase buffer size to avoid crashes when seeking in
reimar
parents: 21559
diff changeset
82 static int bufsz = 0;
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
83 #ifdef CONFIG_WIN32DLL
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
84 static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
85 #endif
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
86
30555
ad6740b58b0d libmpcodecs: Mark functions not used outside of their files as static.
diego
parents: 30504
diff changeset
87 static void *__builtin_vec_new(unsigned long size)
ad6740b58b0d libmpcodecs: Mark functions not used outside of their files as static.
diego
parents: 30504
diff changeset
88 {
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
89 return malloc(size);
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
90 }
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
91
30555
ad6740b58b0d libmpcodecs: Mark functions not used outside of their files as static.
diego
parents: 30504
diff changeset
92 static void __builtin_vec_delete(void *mem)
ad6740b58b0d libmpcodecs: Mark functions not used outside of their files as static.
diego
parents: 30504
diff changeset
93 {
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
94 free(mem);
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
95 }
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
96
30555
ad6740b58b0d libmpcodecs: Mark functions not used outside of their files as static.
diego
parents: 30504
diff changeset
97 static void __pure_virtual(void)
ad6740b58b0d libmpcodecs: Mark functions not used outside of their files as static.
diego
parents: 30504
diff changeset
98 {
6361
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
99 printf("FATAL: __pure_virtual() called!\n");
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
100 // exit(1);
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
101 }
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
102
15566
3758536dcef3 DragonFly BSD support
diego
parents: 14568
diff changeset
103 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
6361
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
104 void ___brk_addr(void) {exit(0);}
6404
83b3315c679b Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents: 6361
diff changeset
105 char **__environ={NULL};
6361
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
106 #undef stderr
6404
83b3315c679b Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents: 6361
diff changeset
107 FILE *stderr=NULL;
6361
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
108 #endif
6341
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 // to set/get/query special features/parameters
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
111 static int control(sh_video_t *sh,int cmd,void* arg,...){
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
112 // switch(cmd){
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
113 // case VDCTRL_QUERY_MAX_PP_LEVEL:
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
114 // return 9;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
115 // case VDCTRL_SET_PP_LEVEL:
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
116 // vfw_set_postproc(sh,10*(*((int*)arg)));
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
117 // return CONTROL_OK;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
118 // }
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
119 return CONTROL_UNKNOWN;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
120 }
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
121
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
122 /* exits program when failure */
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
123 #ifdef HAVE_LIBDL
7728
64b5604195c5 make local stuff 'static', complete uninit
arpi
parents: 7557
diff changeset
124 static int load_syms_linux(char *path) {
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
125 void *handle;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
126
17721
7b336a5585e4 Reduce Real DLL/so loading verbosity, OKed by Roberto.
diego
parents: 17012
diff changeset
127 mp_msg(MSGT_DECVIDEO,MSGL_V, "opening shared obj '%s'\n", path);
9386
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
128 handle = dlopen (path, RTLD_LAZY);
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
129 if (!handle) {
6361
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
130 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error: %s\n",dlerror());
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
131 return 0;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
132 }
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
133
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
134 rvyuv_custom_message = dlsym(handle, "RV20toYUV420CustomMessage");
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
135 rvyuv_free = dlsym(handle, "RV20toYUV420Free");
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
136 rvyuv_init = dlsym(handle, "RV20toYUV420Init");
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
137 rvyuv_transform = dlsym(handle, "RV20toYUV420Transform");
6361
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
138
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
139 if(rvyuv_custom_message &&
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
140 rvyuv_free &&
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
141 rvyuv_init &&
9386
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
142 rvyuv_transform)
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
143 {
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
144 rv_handle = handle;
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
145 return 1;
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
146 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28468
diff changeset
147
13860
d6f716fdd734 remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents: 12628
diff changeset
148 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
149 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
150 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
151 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
152
d6f716fdd734 remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents: 12628
diff changeset
153 if(rvyuv_custom_message &&
d6f716fdd734 remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents: 12628
diff changeset
154 rvyuv_free &&
d6f716fdd734 remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents: 12628
diff changeset
155 rvyuv_init &&
d6f716fdd734 remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents: 12628
diff changeset
156 rvyuv_transform)
d6f716fdd734 remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents: 12628
diff changeset
157 {
d6f716fdd734 remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents: 12628
diff changeset
158 rv_handle = handle;
d6f716fdd734 remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents: 12628
diff changeset
159 return 1;
d6f716fdd734 remove mac shlb support to use new helix codec for realvideo support on osx
nplourde
parents: 12628
diff changeset
160 }
6361
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
161
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
162 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n");
9386
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
163 dlclose(handle);
6361
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
164 return 0;
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
165 }
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
166 #endif
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
167
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
168 #ifdef CONFIG_WIN32DLL
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 7083
diff changeset
169
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
170 #ifdef WIN32_LOADER
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15566
diff changeset
171 #include "loader/ldt_keeper.h"
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
172 #endif
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
173 void* WINAPI LoadLibraryA(char* name);
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
174 void* WINAPI GetProcAddress(void* handle,char* func);
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
175 int WINAPI FreeLibrary(void *handle);
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 7083
diff changeset
176
24087
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
177 #ifndef WIN32_LOADER
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
178 void * WINAPI GetModuleHandleA(char *);
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
179 static int patch_dll(uint8_t *patchpos, const uint8_t *oldcode,
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
180 const uint8_t *newcode, int codesize) {
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
181 void *handle = GetModuleHandleA("kernel32");
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
182 int WINAPI (*VirtProt)(void *, unsigned, int, int *);
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
183 int res = 0;
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
184 int prot, tmp;
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
185 VirtProt = GetProcAddress(handle, "VirtualProtect");
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
186 // change permissions to PAGE_WRITECOPY
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
187 if (!VirtProt ||
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
188 !VirtProt(patchpos, codesize, 0x08, &prot)) {
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
189 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "VirtualProtect failed at %p\n", patchpos);
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
190 return 0;
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
191 }
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
192 if (memcmp(patchpos, oldcode, codesize) == 0) {
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
193 memcpy(patchpos, newcode, codesize);
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
194 res = 1;
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
195 }
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
196 VirtProt(patchpos, codesize, prot, &tmp);
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
197 return res;
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
198 }
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
199 #endif
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
200
7728
64b5604195c5 make local stuff 'static', complete uninit
arpi
parents: 7557
diff changeset
201 static int load_syms_windows(char *path) {
6360
1acda8182b14 win32 dll support (non-working)
arpi
parents: 6354
diff changeset
202 void *handle;
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
203
17721
7b336a5585e4 Reduce Real DLL/so loading verbosity, OKed by Roberto.
diego
parents: 17012
diff changeset
204 mp_msg(MSGT_DECVIDEO,MSGL_V, "opening win32 dll '%s'\n", path);
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
205 #ifdef WIN32_LOADER
6360
1acda8182b14 win32 dll support (non-working)
arpi
parents: 6354
diff changeset
206 Setup_LDT_Keeper();
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
207 #endif
9386
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
208 handle = LoadLibraryA(path);
6361
433bc1becbb6 freebsd support (hack) by Nexus
arpi
parents: 6360
diff changeset
209 mp_msg(MSGT_DECVIDEO,MSGL_V,"win32 real codec handle=%p \n",handle);
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
210 if (!handle) {
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
211 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error loading dll\n");
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
212 return 0;
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
213 }
6360
1acda8182b14 win32 dll support (non-working)
arpi
parents: 6354
diff changeset
214
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
215 wrvyuv_custom_message = GetProcAddress(handle, "RV20toYUV420CustomMessage");
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
216 wrvyuv_free = GetProcAddress(handle, "RV20toYUV420Free");
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
217 wrvyuv_init = GetProcAddress(handle, "RV20toYUV420Init");
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
218 wrvyuv_transform = GetProcAddress(handle, "RV20toYUV420Transform");
9386
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
219
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
220 if(wrvyuv_custom_message &&
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
221 wrvyuv_free &&
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
222 wrvyuv_init &&
9386
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
223 wrvyuv_transform)
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
224 {
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
225 dll_type = 1;
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
226 rv_handle = handle;
24087
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
227 #ifndef WIN32_LOADER
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
228 {
26389
b65cf3a35900 Oops...should be "drv43260.dll" instead of "drv34260.dll"
zuxy
parents: 26388
diff changeset
229 if (strstr(path, "drv43260.dll")) {
26385
3d02fa79ae6c Don't print "Could not patch" messages when we haven't actually tried to patch.
zuxy
parents: 26384
diff changeset
230 int patched;
24087
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
231 // patch away multithreaded decoding, it causes crashes
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
232 static const uint8_t oldcode[13] = {
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
233 0x83, 0xbb, 0xf8, 0x05, 0x00, 0x00, 0x01,
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
234 0x0f, 0x86, 0xd0, 0x00, 0x00, 0x00 };
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
235 static const uint8_t newcode[13] = {
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
236 0x31, 0xc0,
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
237 0x89, 0x83, 0xf8, 0x05, 0x00, 0x00,
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
238 0xe9, 0xd0, 0x00, 0x00, 0x00 };
26388
a630c8945001 Cosmetic fix for r26419
zuxy
parents: 26387
diff changeset
239 patched = patch_dll(
a630c8945001 Cosmetic fix for r26419
zuxy
parents: 26387
diff changeset
240 (char*)wrvyuv_transform + 0x634132fa - 0x634114d0,
a630c8945001 Cosmetic fix for r26419
zuxy
parents: 26387
diff changeset
241 oldcode, newcode, sizeof(oldcode));
26386
cf87699fba0b Indentation fix for r26417
zuxy
parents: 26385
diff changeset
242 if (!patched)
cf87699fba0b Indentation fix for r26417
zuxy
parents: 26385
diff changeset
243 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Could not patch Real codec, this might crash on multi-CPU systems\n");
26385
3d02fa79ae6c Don't print "Could not patch" messages when we haven't actually tried to patch.
zuxy
parents: 26384
diff changeset
244 }
24087
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
245 }
5992f8a979e3 Runtime-patching for windows to fix crash with drv43260.dll
reimar
parents: 22577
diff changeset
246 #endif
9386
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
247 return 1;
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
248 }
26384
59db094d3494 Check for drvc.dll entries for mingw32
zuxy
parents: 25962
diff changeset
249
59db094d3494 Check for drvc.dll entries for mingw32
zuxy
parents: 25962
diff changeset
250 wrvyuv_custom_message = GetProcAddress(handle, "RV40toYUV420CustomMessage");
59db094d3494 Check for drvc.dll entries for mingw32
zuxy
parents: 25962
diff changeset
251 wrvyuv_free = GetProcAddress(handle, "RV40toYUV420Free");
59db094d3494 Check for drvc.dll entries for mingw32
zuxy
parents: 25962
diff changeset
252 wrvyuv_init = GetProcAddress(handle, "RV40toYUV420Init");
59db094d3494 Check for drvc.dll entries for mingw32
zuxy
parents: 25962
diff changeset
253 wrvyuv_transform = GetProcAddress(handle, "RV40toYUV420Transform");
59db094d3494 Check for drvc.dll entries for mingw32
zuxy
parents: 25962
diff changeset
254 if(wrvyuv_custom_message &&
59db094d3494 Check for drvc.dll entries for mingw32
zuxy
parents: 25962
diff changeset
255 wrvyuv_free &&
59db094d3494 Check for drvc.dll entries for mingw32
zuxy
parents: 25962
diff changeset
256 wrvyuv_init &&
26398
f79cdff78e10 Set dll_type and rv_handle for drvc.dll
zuxy
parents: 26389
diff changeset
257 wrvyuv_transform) {
f79cdff78e10 Set dll_type and rv_handle for drvc.dll
zuxy
parents: 26389
diff changeset
258 dll_type = 1;
f79cdff78e10 Set dll_type and rv_handle for drvc.dll
zuxy
parents: 26389
diff changeset
259 rv_handle = handle;
26384
59db094d3494 Check for drvc.dll entries for mingw32
zuxy
parents: 25962
diff changeset
260 return 1;
26398
f79cdff78e10 Set dll_type and rv_handle for drvc.dll
zuxy
parents: 26389
diff changeset
261 }
26384
59db094d3494 Check for drvc.dll entries for mingw32
zuxy
parents: 25962
diff changeset
262
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
263 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n");
9386
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
264 FreeLibrary(handle);
6360
1acda8182b14 win32 dll support (non-working)
arpi
parents: 6354
diff changeset
265 return 0; // error
1acda8182b14 win32 dll support (non-working)
arpi
parents: 6354
diff changeset
266 }
1acda8182b14 win32 dll support (non-working)
arpi
parents: 6354
diff changeset
267 #endif
1acda8182b14 win32 dll support (non-working)
arpi
parents: 6354
diff changeset
268
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
269 /* we need exact positions */
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
270 struct rv_init_t {
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
271 short unk1;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
272 short w;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
273 short h;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
274 short unk3;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
275 int unk2;
6345
2b6ff13acf5b - removed unused function pointers
arpi
parents: 6341
diff changeset
276 int subformat;
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
277 int unk5;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
278 int format;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
279 } rv_init_t;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
280
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
281 // init driver
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
282 static int init(sh_video_t *sh){
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
283 //unsigned int out_fmt;
10102
0f59b1e9ad97 dynamic path[] allocation
alex
parents: 10093
diff changeset
284 char *path;
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
285 int result;
6345
2b6ff13acf5b - removed unused function pointers
arpi
parents: 6341
diff changeset
286 // we export codec id and sub-id from demuxer in bitmapinfohdr:
20920
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
287 unsigned char* extrahdr=(unsigned char*)(sh->bih+1);
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
288 unsigned int extrahdr_size = sh->bih->biSize - sizeof(BITMAPINFOHEADER);
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
289 struct rv_init_t init_data;
6345
2b6ff13acf5b - removed unused function pointers
arpi
parents: 6341
diff changeset
290
20920
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
291 if(extrahdr_size < 8) {
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
292 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"realvideo: extradata too small (%u)\n", sh->bih->biSize - sizeof(BITMAPINFOHEADER));
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
293 return 0;
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
294 }
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
295 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
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
296
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
297 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
298
10102
0f59b1e9ad97 dynamic path[] allocation
alex
parents: 10093
diff changeset
299 path = malloc(strlen(REALCODEC_PATH)+strlen(sh->codec->dll)+2);
0f59b1e9ad97 dynamic path[] allocation
alex
parents: 10093
diff changeset
300 if (!path) return 0;
6404
83b3315c679b Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents: 6361
diff changeset
301 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
302
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
303 /* 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
304 then try to load the windows ones */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28468
diff changeset
305 #ifdef HAVE_LIBDL
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
306 if(strstr(sh->codec->dll,".dll") || !load_syms_linux(path))
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
307 #endif
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
308 #ifdef CONFIG_WIN32DLL
10444
2e46e51269c1 Win32 codec paths in vd_realvid.c
diego
parents: 10142
diff changeset
309 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
310 #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
311 {
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
312 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
9386
8537d9a5fed5 possible 10l
alex
parents: 8525
diff changeset
313 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Read the RealVideo section of the DOCS!\n");
10102
0f59b1e9ad97 dynamic path[] allocation
alex
parents: 10093
diff changeset
314 free(path);
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
315 return 0;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
316 }
10102
0f59b1e9ad97 dynamic path[] allocation
alex
parents: 10093
diff changeset
317 free(path);
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
318 // only I420 supported
9552
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
319 // 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
320 // init codec:
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
321 sh->context=NULL;
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
322 #ifdef CONFIG_WIN32DLL
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
323 if (dll_type == 1)
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
324 result=(*wrvyuv_init)(&init_data, &sh->context);
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
325 else
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
326 #endif
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
327 result=(*rvyuv_init)(&init_data, &sh->context);
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
328 if (result){
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
329 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
330 return 0;
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
331 }
6345
2b6ff13acf5b - removed unused function pointers
arpi
parents: 6341
diff changeset
332 // setup rv30 codec (codec sub-type and image dimensions):
20920
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
333 if((sh->format<=0x30335652) && (be2me_32(((unsigned int*)extrahdr)[1])>=0x20200002)){
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
334 int i, cmsg_cnt;
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
335 uint32_t cmsg24[16]={sh->disp_w,sh->disp_h};
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
336 cmsg_data_t cmsg_data={0x24,1+(extrahdr[1]&7), &cmsg24[0]};
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
337
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
338 mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo: using cmsg24 with %u elements.\n",extrahdr[1]&7);
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
339 cmsg_cnt = (extrahdr[1]&7)*2;
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
340 if (extrahdr_size-8 < cmsg_cnt) {
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
341 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"realvideo: not enough extradata (%u) to make %u cmsg24 elements.\n",extrahdr_size-8,extrahdr[1]&7);
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
342 cmsg_cnt = extrahdr_size-8;
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
343 }
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
344 for (i = 0; i < cmsg_cnt; i++)
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
345 cmsg24[2+i] = extrahdr[8+i]*4;
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
346 if (extrahdr_size-8 > cmsg_cnt)
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20144
diff changeset
347 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"realvideo: %u bytes of unknown extradata remaining.\n",extrahdr_size-8-cmsg_cnt);
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
348
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
349 #ifdef CONFIG_WIN32DLL
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
350 if (dll_type == 1)
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
351 (*wrvyuv_custom_message)(&cmsg_data,sh->context);
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
352 else
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
353 #endif
8522
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
354 (*rvyuv_custom_message)(&cmsg_data,sh->context);
6345
2b6ff13acf5b - removed unused function pointers
arpi
parents: 6341
diff changeset
355 }
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
356 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
357 return 1;
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 // uninit driver
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
361 static void uninit(sh_video_t *sh){
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
362 #ifdef CONFIG_WIN32DLL
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
363 if (dll_type == 1)
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
364 {
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
365 if (wrvyuv_free) wrvyuv_free(sh->context);
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
366 } else
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
367 #endif
7728
64b5604195c5 make local stuff 'static', complete uninit
arpi
parents: 7557
diff changeset
368 if(rvyuv_free) rvyuv_free(sh->context);
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
369
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
370 #ifdef CONFIG_WIN32DLL
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
371 if (dll_type == 1)
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
372 {
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
373 if (rv_handle) FreeLibrary(rv_handle);
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
374 } else
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
375 #endif
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
376 #ifdef HAVE_LIBDL
6345
2b6ff13acf5b - removed unused function pointers
arpi
parents: 6341
diff changeset
377 if(rv_handle) dlclose(rv_handle);
10093
ad83de1c0038 cygwin/mingw32 support by Sascha Sommer
alex
parents: 9552
diff changeset
378 #endif
6345
2b6ff13acf5b - removed unused function pointers
arpi
parents: 6341
diff changeset
379 rv_handle=NULL;
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25598
diff changeset
380 initialized = 0;
21559
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
381 if (buffer)
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
382 free(buffer);
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
383 buffer = NULL;
21563
c08b8066a1c6 Only increase buffer size to avoid crashes when seeking in
reimar
parents: 21559
diff changeset
384 bufsz = 0;
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
385 }
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
386
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
387 // decode a frame
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
388 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
389 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
390 unsigned long result;
28468
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
391 uint8_t *buf = data;
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
392 int chunks = *buf++;
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
393 int extra_size = 8*(chunks+1);
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
394 uint32_t data_size = len-1-extra_size;
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
395 unsigned char* dp_data=buf+extra_size;
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
396 uint32_t* extra=(uint32_t*)buf;
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
397 int i;
7082
678e77165b8e uses new dp_hdr_t packet structure
arpi
parents: 6745
diff changeset
398
8522
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
399 unsigned int transform_out[5];
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
400 transform_in_t transform_in={
28468
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
401 data_size, // length of the packet (sub-packets appended)
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
402 0, // unknown, seems to be unused
28468
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
403 chunks, // number of sub-packets - 1
8522
4b29a7646dac alpha support by Alan Young <ayoung@teleport.com>
alex
parents: 7728
diff changeset
404 extra, // table of sub-packet offsets
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
405 0, // unknown, seems to be unused
25598
0cf6c33e4400 Do not pass timestamp to realvideo binary decoder
rtogni
parents: 24087
diff changeset
406 0, // timestamp (should be unneded)
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
407 };
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
408
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
409 if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
410
21563
c08b8066a1c6 Only increase buffer size to avoid crashes when seeking in
reimar
parents: 21559
diff changeset
411 if (bufsz < sh->disp_w*sh->disp_h*3/2) {
21559
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
412 if (buffer) free(buffer);
21563
c08b8066a1c6 Only increase buffer size to avoid crashes when seeking in
reimar
parents: 21559
diff changeset
413 bufsz = sh->disp_w*sh->disp_h*3/2;
c08b8066a1c6 Only increase buffer size to avoid crashes when seeking in
reimar
parents: 21559
diff changeset
414 buffer=malloc(bufsz);
9552
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
415 if (!buffer) return 0;
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
416 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28468
diff changeset
417
28468
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
418 for (i=0; i<2*(chunks+1); i++)
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
419 extra[i] = le2me_32(extra[i]);
b9da026ee222 change internal real video packetizing format to the more straight forward one
aurel
parents: 27341
diff changeset
420
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
421 #ifdef CONFIG_WIN32DLL
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
422 if (dll_type == 1)
9552
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
423 result=(*wrvyuv_transform)(dp_data, buffer, &transform_in,
8525
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
424 transform_out, sh->context);
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
425 else
8d0bfe72e709 win32 dlls support
alex
parents: 8522
diff changeset
426 #endif
9552
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
427 result=(*rvyuv_transform)(dp_data, buffer, &transform_in,
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
428 transform_out, sh->context);
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
429
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25598
diff changeset
430 if(!initialized){ // rv30 width/height now known
9552
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
431 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
432 sh->disp_w=transform_out[3];
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
433 sh->disp_h=transform_out[4];
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
434 if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0;
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25598
diff changeset
435 initialized=1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28468
diff changeset
436 }
21559
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
437 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
9552
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
438 sh->disp_w, sh->disp_h);
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
439 if(!mpi) return NULL;
21559
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
440 mpi->planes[0] = buffer;
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
441 mpi->stride[0] = sh->disp_w;
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
442 mpi->planes[1] = buffer + sh->disp_w*sh->disp_h;
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
443 mpi->stride[1] = sh->disp_w / 2;
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
444 mpi->planes[2] = buffer + sh->disp_w*sh->disp_h*5/4;
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
445 mpi->stride[2] = sh->disp_w / 2;
9552
86b5ea6396ab Ugly hack to handle bad width/height values from stream header
arpi
parents: 9386
diff changeset
446
21559
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
447 if(transform_out[0] &&
de2a96f41195 Fix realvideo size changes by using our own malloced buffer and export type mpi.
reimar
parents: 21466
diff changeset
448 (sh->disp_w != transform_out[3] || sh->disp_h != transform_out[4]))
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25598
diff changeset
449 initialized = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28468
diff changeset
450
26754
63630c09e237 cosmetics: Remove pointless parentheses from return calls.
diego
parents: 26398
diff changeset
451 return result ? NULL : mpi;
6341
d79c52610702 RealVideo rv30 decoder, using binary driver from realplayer8
arpi
parents:
diff changeset
452 }