annotate xacodec.c @ 2486:d4f398ef37aa

rewritten matrox tvout section
author gabucino
date Fri, 26 Oct 2001 17:19:13 +0000
parents aa96a104e8e0
children 39b8b9069f41
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
1 /*
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
2 xacodec.c -- XAnim Video Codec DLL support
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
3
0959af64c098 needs to be hacked
alex
parents:
diff changeset
4 (C) 2001 Alex Beregszaszi <alex@naxine.org>
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
5 and Arpad Gereoffy <arpi@thot.banki.hu>
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
6 */
0959af64c098 needs to be hacked
alex
parents:
diff changeset
7
0959af64c098 needs to be hacked
alex
parents:
diff changeset
8 #include <stdio.h>
2376
4edd4d7f4511 mplayerization
arpi
parents: 2373
diff changeset
9 #include <stdlib.h>
4edd4d7f4511 mplayerization
arpi
parents: 2373
diff changeset
10
2409
25f6a4335abb FreeBSD patch
nexus
parents: 2406
diff changeset
11 #ifdef __FreeBSD__
25f6a4335abb FreeBSD patch
nexus
parents: 2406
diff changeset
12 #include <unistd.h>
25f6a4335abb FreeBSD patch
nexus
parents: 2406
diff changeset
13 #endif
25f6a4335abb FreeBSD patch
nexus
parents: 2406
diff changeset
14
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
15 #include <dlfcn.h> /* dlsym, dlopen, dlclose */
0959af64c098 needs to be hacked
alex
parents:
diff changeset
16 #include <stdarg.h> /* va_alist, va_start, va_end */
0959af64c098 needs to be hacked
alex
parents:
diff changeset
17 #include <errno.h> /* strerror, errno */
0959af64c098 needs to be hacked
alex
parents:
diff changeset
18
2376
4edd4d7f4511 mplayerization
arpi
parents: 2373
diff changeset
19 #include "config.h"
2382
alex
parents: 2381
diff changeset
20 #define XACODEC_PATH "/usr/lib/xanim/mods"
2376
4edd4d7f4511 mplayerization
arpi
parents: 2373
diff changeset
21
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
22 #include "mp_msg.h"
2376
4edd4d7f4511 mplayerization
arpi
parents: 2373
diff changeset
23 #include "bswap.h"
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
24
0959af64c098 needs to be hacked
alex
parents:
diff changeset
25 #include "stream.h"
0959af64c098 needs to be hacked
alex
parents:
diff changeset
26 #include "demuxer.h"
0959af64c098 needs to be hacked
alex
parents:
diff changeset
27 #include "codec-cfg.h"
0959af64c098 needs to be hacked
alex
parents:
diff changeset
28 #include "stheader.h"
2376
4edd4d7f4511 mplayerization
arpi
parents: 2373
diff changeset
29
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
30 #include "libvo/img_format.h"
0959af64c098 needs to be hacked
alex
parents:
diff changeset
31 #include "xacodec.h"
0959af64c098 needs to be hacked
alex
parents:
diff changeset
32
2484
aa96a104e8e0 FreeBSD libdl fix
nexus
parents: 2481
diff changeset
33 #if defined(HAVE_LIBDL) || defined(__FreeBSD__)
2481
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
34
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
35 #if 0
2381
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
36 typedef char xaBYTE;
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
37 typedef short xaSHORT;
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
38 typedef int xaLONG;
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
39
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
40 typedef unsigned char xaUBYTE;
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
41 typedef unsigned short xaUSHORT;
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
42 typedef unsigned int xaULONG;
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
43 #endif
2381
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
44
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
45 #define xaFALSE 0
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
46 #define xaTRUE 1
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
47
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
48 #ifndef RTLD_NOW
0959af64c098 needs to be hacked
alex
parents:
diff changeset
49 #define RLTD_NOW 2
0959af64c098 needs to be hacked
alex
parents:
diff changeset
50 #endif
0959af64c098 needs to be hacked
alex
parents:
diff changeset
51 #ifndef RTLD_LAZY
0959af64c098 needs to be hacked
alex
parents:
diff changeset
52 #define RLTD_LAZY 1
0959af64c098 needs to be hacked
alex
parents:
diff changeset
53 #endif
0959af64c098 needs to be hacked
alex
parents:
diff changeset
54 #ifndef RTLD_GLOBAL
0959af64c098 needs to be hacked
alex
parents:
diff changeset
55 #define RLTD_GLOBAL 256
0959af64c098 needs to be hacked
alex
parents:
diff changeset
56 #endif
0959af64c098 needs to be hacked
alex
parents:
diff changeset
57
2382
alex
parents: 2381
diff changeset
58 #define XA_CLOSE_FUNCS 5
alex
parents: 2381
diff changeset
59 int xa_close_func = 0;
alex
parents: 2381
diff changeset
60
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
61 typedef struct xacodec_driver
0959af64c098 needs to be hacked
alex
parents:
diff changeset
62 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
63 XA_DEC_INFO *decinfo;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
64 void *file_handler;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
65 long (*iq_func)(XA_CODEC_HDR *codec_hdr);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
66 unsigned int (*dec_func)(unsigned char *image, unsigned char *delta,
0959af64c098 needs to be hacked
alex
parents:
diff changeset
67 unsigned int dsize, XA_DEC_INFO *dec_info);
2382
alex
parents: 2381
diff changeset
68 void *close_func[XA_CLOSE_FUNCS];
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
69 xacodec_image_t image;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
70 } xacodec_driver_t;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
71
0959af64c098 needs to be hacked
alex
parents:
diff changeset
72 xacodec_driver_t *xacodec_driver = NULL;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
73
0959af64c098 needs to be hacked
alex
parents:
diff changeset
74 /* Needed by XAnim DLLs */
0959af64c098 needs to be hacked
alex
parents:
diff changeset
75 int XA_Print(char *fmt, ...)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
76 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
77 va_list vallist;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
78 char buf[1024];
0959af64c098 needs to be hacked
alex
parents:
diff changeset
79
0959af64c098 needs to be hacked
alex
parents:
diff changeset
80 va_start(vallist, fmt);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
81 vsnprintf(buf, 1024, fmt, vallist);
2377
3ad626921328 fixing...
arpi
parents: 2376
diff changeset
82 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "[xacodec] %s\n", buf);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
83 va_end(vallist);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
84 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
85
2382
alex
parents: 2381
diff changeset
86 /* 0 is no debug (needed by 3ivX) */
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
87 long xa_debug = 0;
2382
alex
parents: 2381
diff changeset
88
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
89 int TheEnd1(char *err_mess)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
90 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
91 XA_Print("error: %s - exiting\n", err_mess);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
92 xacodec_exit();
0959af64c098 needs to be hacked
alex
parents:
diff changeset
93 }
2382
alex
parents: 2381
diff changeset
94
alex
parents: 2381
diff changeset
95 int XA_Add_Func_To_Free_Chain(XA_ANIM_HDR *anim_hdr, void (*function)())
alex
parents: 2381
diff changeset
96 {
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
97 // XA_Print("XA_Add_Func_To_Free_Chain('anim_hdr: %08x', 'function: %08x')",
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
98 // anim_hdr, function);
2382
alex
parents: 2381
diff changeset
99 xacodec_driver->close_func[xa_close_func] = function;
alex
parents: 2381
diff changeset
100 if (xa_close_func+1 < XA_CLOSE_FUNCS)
alex
parents: 2381
diff changeset
101 xa_close_func++;
alex
parents: 2381
diff changeset
102 }
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
103 /* end of crap */
0959af64c098 needs to be hacked
alex
parents:
diff changeset
104
0959af64c098 needs to be hacked
alex
parents:
diff changeset
105 /* load, init and query */
0959af64c098 needs to be hacked
alex
parents:
diff changeset
106 int xacodec_init(char *filename, xacodec_driver_t *codec_driver)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
107 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
108 void *(*what_the)();
0959af64c098 needs to be hacked
alex
parents:
diff changeset
109 char *error;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
110 XAVID_MOD_HDR *mod_hdr;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
111 XAVID_FUNC_HDR *func;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
112 int i;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
113
0959af64c098 needs to be hacked
alex
parents:
diff changeset
114 codec_driver->file_handler = dlopen(filename, RTLD_NOW|RTLD_GLOBAL);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
115 if (!codec_driver->file_handler)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
116 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
117 error = dlerror();
0959af64c098 needs to be hacked
alex
parents:
diff changeset
118 if (error)
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
119 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: failed to init %s while %s\n", filename, error);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
120 else
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
121 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: failed ot init (dlopen) %s\n", filename);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
122 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
123 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
124
0959af64c098 needs to be hacked
alex
parents:
diff changeset
125 what_the = dlsym(codec_driver->file_handler, "What_The");
0959af64c098 needs to be hacked
alex
parents:
diff changeset
126 if ((error = dlerror()) != NULL)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
127 {
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
128 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: failed to init %s while %s\n", filename, error);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
129 dlclose(codec_driver->file_handler);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
130 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
131 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
132
0959af64c098 needs to be hacked
alex
parents:
diff changeset
133 mod_hdr = what_the();
0959af64c098 needs to be hacked
alex
parents:
diff changeset
134 if (!mod_hdr)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
135 {
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
136 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: 'What_The' function failed in %s\n", filename);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
137 dlclose(codec_driver->file_handler);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
138 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
139 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
140
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
141 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "=== XAnim Codec ===\n");
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
142 mp_msg(MSGT_DECVIDEO, MSGL_INFO, " Filename: %s (API revision: %x)\n", filename, mod_hdr->api_rev);
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
143 mp_msg(MSGT_DECVIDEO, MSGL_INFO, " Codec: %s. Rev: %s\n", mod_hdr->desc, mod_hdr->rev);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
144 if (mod_hdr->copyright)
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
145 mp_msg(MSGT_DECVIDEO, MSGL_INFO, " %s\n", mod_hdr->copyright);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
146 if (mod_hdr->mod_author)
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
147 mp_msg(MSGT_DECVIDEO, MSGL_INFO, " Module Author(s): %s\n", mod_hdr->mod_author);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
148 if (mod_hdr->authors)
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
149 mp_msg(MSGT_DECVIDEO, MSGL_INFO, " Codec Author(s): %s\n", mod_hdr->authors);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
150
0959af64c098 needs to be hacked
alex
parents:
diff changeset
151 if (mod_hdr->api_rev > XAVID_API_REV)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
152 {
2414
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
153 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: not supported api revision (%d) in %s\n",
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
154 mod_hdr->api_rev, filename);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
155 dlclose(codec_driver->file_handler);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
156 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
157 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
158
0959af64c098 needs to be hacked
alex
parents:
diff changeset
159 func = mod_hdr->funcs;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
160 if (!func)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
161 {
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
162 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: function table error in %s\n", filename);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
163 dlclose(codec_driver->file_handler);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
164 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
165 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
166
2382
alex
parents: 2381
diff changeset
167 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "dump: funcs: 0x%08x (num %d)\n", mod_hdr->funcs, mod_hdr->num_funcs);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
168 for (i = 0; i < mod_hdr->num_funcs; i++)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
169 {
2382
alex
parents: 2381
diff changeset
170 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "dump(%d): %d %d [iq:0x%08x d:0x%08x]\n", i,
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
171 func[i].what, func[i].id, func[i].iq_func, func[i].dec_func);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
172 if (func[i].what & XAVID_AVI_QUERY)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
173 {
2382
alex
parents: 2381
diff changeset
174 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "0x%08x: avi init/query func (id: %d)\n",
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
175 func[i].iq_func, func[i].id);
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
176 codec_driver->iq_func = (void *)(func[i].iq_func);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
177 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
178 if (func[i].what & XAVID_QT_QUERY)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
179 {
2382
alex
parents: 2381
diff changeset
180 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "0x%08x: qt init/query func (id: %d)\n",
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
181 func[i].iq_func, func[i].id);
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
182 codec_driver->iq_func = (void *)func[i].iq_func;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
183 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
184 if (func[i].what & XAVID_DEC_FUNC)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
185 {
2382
alex
parents: 2381
diff changeset
186 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "0x%08x: decoder func (init/query: 0x%08x) (id: %d)\n",
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
187 func[i].dec_func, func[i].iq_func, func[i].id);
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
188 codec_driver->dec_func = (void *)func[i].dec_func;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
189 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
190 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
191 return(1);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
192 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
193
0959af64c098 needs to be hacked
alex
parents:
diff changeset
194 int xacodec_query(xacodec_driver_t *codec_driver, XA_CODEC_HDR *codec_hdr)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
195 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
196 long codec_ret;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
197
0959af64c098 needs to be hacked
alex
parents:
diff changeset
198 codec_ret = codec_driver->iq_func(codec_hdr);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
199 switch(codec_ret)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
200 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
201 case CODEC_SUPPORTED:
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
202 codec_driver->dec_func = (void *)codec_hdr->decoder;
2382
alex
parents: 2381
diff changeset
203 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Codec is supported: found decoder for %s at 0x%08x\n",
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
204 codec_hdr->description, codec_hdr->decoder);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
205 return(1);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
206 case CODEC_UNSUPPORTED:
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
207 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "Codec (%s) is unsupported by driver\n",
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
208 codec_hdr->description);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
209 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
210 case CODEC_UNKNOWN:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
211 default:
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
212 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "Codec (%s) is unknown by driver\n",
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
213 codec_hdr->description);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
214 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
215 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
216 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
217
0959af64c098 needs to be hacked
alex
parents:
diff changeset
218 char *xacodec_def_path = XACODEC_PATH;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
219
0959af64c098 needs to be hacked
alex
parents:
diff changeset
220 int xacodec_init_video(sh_video_t *vidinfo, int out_format)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
221 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
222 char dll[1024];
0959af64c098 needs to be hacked
alex
parents:
diff changeset
223 XA_CODEC_HDR codec_hdr;
2382
alex
parents: 2381
diff changeset
224 int i;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
225
0959af64c098 needs to be hacked
alex
parents:
diff changeset
226 xacodec_driver = realloc(xacodec_driver, sizeof(struct xacodec_driver));
0959af64c098 needs to be hacked
alex
parents:
diff changeset
227 if (xacodec_driver == NULL)
2414
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
228 {
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
229 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: memory allocation error: %s\n",
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
230 strerror(errno));
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
231 return(0);
2414
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
232 }
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
233
0959af64c098 needs to be hacked
alex
parents:
diff changeset
234 xacodec_driver->iq_func = NULL;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
235 xacodec_driver->dec_func = NULL;
2382
alex
parents: 2381
diff changeset
236
alex
parents: 2381
diff changeset
237 for (i=0; i < XA_CLOSE_FUNCS; i++)
alex
parents: 2381
diff changeset
238 xacodec_driver->close_func[i] = NULL;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
239
0959af64c098 needs to be hacked
alex
parents:
diff changeset
240 snprintf(dll, 1024, "%s/%s", xacodec_def_path, vidinfo->codec->dll);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
241 if (xacodec_init(dll, xacodec_driver) == 0)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
242 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
243
0959af64c098 needs to be hacked
alex
parents:
diff changeset
244 codec_hdr.anim_hdr = malloc(4096);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
245 codec_hdr.description = vidinfo->codec->info;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
246 codec_hdr.compression = bswap_32(vidinfo->format);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
247 codec_hdr.decoder = NULL;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
248 codec_hdr.avi_ctab_flag = 0;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
249 codec_hdr.avi_read_ext = NULL;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
250 codec_hdr.xapi_rev = 0x0001;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
251 codec_hdr.extra = NULL;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
252 codec_hdr.x = vidinfo->disp_w;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
253 codec_hdr.y = vidinfo->disp_h;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
254
0959af64c098 needs to be hacked
alex
parents:
diff changeset
255 switch(out_format)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
256 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
257 case IMGFMT_RGB8:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
258 codec_hdr.depth = 8;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
259 break;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
260 case IMGFMT_RGB15:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
261 codec_hdr.depth = 15;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
262 break;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
263 case IMGFMT_RGB16:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
264 codec_hdr.depth = 16;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
265 break;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
266 case IMGFMT_RGB24:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
267 codec_hdr.depth = 24;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
268 break;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
269 case IMGFMT_RGB32:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
270 codec_hdr.depth = 32;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
271 break;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
272 case IMGFMT_BGR8:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
273 codec_hdr.depth = 8;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
274 break;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
275 case IMGFMT_BGR15:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
276 codec_hdr.depth = 15;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
277 break;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
278 case IMGFMT_BGR16:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
279 codec_hdr.depth = 16;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
280 break;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
281 case IMGFMT_BGR24:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
282 codec_hdr.depth = 24;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
283 break;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
284 case IMGFMT_BGR32:
0959af64c098 needs to be hacked
alex
parents:
diff changeset
285 codec_hdr.depth = 32;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
286 break;
2383
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
287 case IMGFMT_IYUV:
2382
alex
parents: 2381
diff changeset
288 case IMGFMT_I420:
2383
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
289 case IMGFMT_YV12:
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
290 codec_hdr.depth = 12;
2382
alex
parents: 2381
diff changeset
291 break;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
292 default:
2382
alex
parents: 2381
diff changeset
293 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: not supported image format (%s)\n",
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
294 vo_format_name(out_format));
0959af64c098 needs to be hacked
alex
parents:
diff changeset
295 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
296 }
2382
alex
parents: 2381
diff changeset
297 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "xacodec: querying for %dx%d %dbit [fourcc: %4x] (%s)...\n",
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
298 codec_hdr.x, codec_hdr.y, codec_hdr.depth, codec_hdr.compression,
0959af64c098 needs to be hacked
alex
parents:
diff changeset
299 codec_hdr.description);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
300
0959af64c098 needs to be hacked
alex
parents:
diff changeset
301 if (xacodec_query(xacodec_driver, &codec_hdr) == 0)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
302 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
303
0959af64c098 needs to be hacked
alex
parents:
diff changeset
304 // free(codec_hdr.anim_hdr);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
305
0959af64c098 needs to be hacked
alex
parents:
diff changeset
306 xacodec_driver->decinfo = malloc(sizeof(XA_DEC_INFO));
2414
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
307 if (xacodec_driver->decinfo == NULL)
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
308 {
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
309 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: memory allocation error: %s\n",
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
310 strerror(errno));
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
311 return(0);
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
312 }
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
313 xacodec_driver->decinfo->cmd = 0;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
314 xacodec_driver->decinfo->skip_flag = 0;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
315 xacodec_driver->decinfo->imagex = xacodec_driver->decinfo->xe = codec_hdr.x;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
316 xacodec_driver->decinfo->imagey = xacodec_driver->decinfo->ye = codec_hdr.y;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
317 xacodec_driver->decinfo->imaged = codec_hdr.depth;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
318 xacodec_driver->decinfo->chdr = NULL;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
319 xacodec_driver->decinfo->map_flag = 0; /* xaFALSE */
0959af64c098 needs to be hacked
alex
parents:
diff changeset
320 xacodec_driver->decinfo->map = NULL;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
321 xacodec_driver->decinfo->xs = xacodec_driver->decinfo->ys = 0;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
322 xacodec_driver->decinfo->special = 0;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
323 xacodec_driver->decinfo->extra = codec_hdr.extra;
2414
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
324 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "decinfo->extra, filled by codec: 0x%08x [%s]\n",
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
325 &xacodec_driver->decinfo->extra, xacodec_driver->decinfo->extra);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
326
2377
3ad626921328 fixing...
arpi
parents: 2376
diff changeset
327 // vidinfo->our_out_buffer = malloc(codec_hdr.y * codec_hdr.x * ((codec_hdr.depth+7)/8));
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
328 // vidinfo->our_out_buffer = malloc(codec_hdr.y * codec_hdr.x * codec_hdr.depth);
2414
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
329 xacodec_driver->image.out_fmt = out_format;
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
330 xacodec_driver->image.bpp = codec_hdr.depth;
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
331 xacodec_driver->image.width = codec_hdr.x;
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
332 xacodec_driver->image.height = codec_hdr.y;
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
333 xacodec_driver->image.mem = malloc(codec_hdr.y * codec_hdr.x * ((codec_hdr.depth+7)/8));
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
334
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
335 if (xacodec_driver->image.mem == NULL)
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
336 {
2414
557a31eed636 some cosmetic and debugging changes
alex
parents: 2409
diff changeset
337 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: memory allocation error: %s\n",
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
338 strerror(errno));
0959af64c098 needs to be hacked
alex
parents:
diff changeset
339 return(0);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
340 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
341
0959af64c098 needs to be hacked
alex
parents:
diff changeset
342 return(1);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
343 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
344
0959af64c098 needs to be hacked
alex
parents:
diff changeset
345 #define ACT_DLT_NORM 0x00000000
0959af64c098 needs to be hacked
alex
parents:
diff changeset
346 #define ACT_DLT_BODY 0x00000001
0959af64c098 needs to be hacked
alex
parents:
diff changeset
347 #define ACT_DLT_XOR 0x00000002
0959af64c098 needs to be hacked
alex
parents:
diff changeset
348 #define ACT_DLT_NOP 0x00000004
0959af64c098 needs to be hacked
alex
parents:
diff changeset
349 #define ACT_DLT_MAPD 0x00000008
0959af64c098 needs to be hacked
alex
parents:
diff changeset
350 #define ACT_DLT_DROP 0x00000010
0959af64c098 needs to be hacked
alex
parents:
diff changeset
351 #define ACT_DLT_BAD 0x80000000
0959af64c098 needs to be hacked
alex
parents:
diff changeset
352
0959af64c098 needs to be hacked
alex
parents:
diff changeset
353 // unsigned int (*dec_func)(unsigned char *image, unsigned char *delta,
0959af64c098 needs to be hacked
alex
parents:
diff changeset
354 // unsigned int dsize, XA_DEC_INFO *dec_info);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
355
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
356 xacodec_image_t* xacodec_decode_frame(uint8_t *frame, int frame_size, int skip_flag)
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
357 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
358 unsigned int ret;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
359 int i;
2387
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
360 xacodec_image_t *image=&xacodec_driver->image;
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
361
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
362 // ugyis kiirja a vegen h dropped vagy nem..
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
363 // if (skip_flag > 0)
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
364 // mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "frame will be dropped..\n");
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
365
0959af64c098 needs to be hacked
alex
parents:
diff changeset
366 xacodec_driver->decinfo->skip_flag = skip_flag;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
367
2387
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
368 image->planes[0]=image->mem;
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
369 image->stride[0]=image->width;
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
370 image->stride[1]=image->stride[2]=image->width/2;
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
371 switch(image->out_fmt){
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
372 case IMGFMT_YV12:
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
373 image->planes[2]=image->planes[0]+image->width*image->height;
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
374 image->planes[1]=image->planes[2]+image->width*image->height/4;
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
375 break;
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
376 case IMGFMT_I420:
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
377 case IMGFMT_IYUV:
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
378 image->planes[1]=image->planes[0]+image->width*image->height;
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
379 image->planes[2]=image->planes[1]+image->width*image->height/4;
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
380 break;
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
381 }
d13780700b40 cvid yuv "fixed"
arpi
parents: 2384
diff changeset
382
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
383 // printf("frame: %08x (size: %d) - dest: %08x\n", frame, frame_size, dest);
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
385 ret = xacodec_driver->dec_func((uint8_t*)&xacodec_driver->image, frame, frame_size, xacodec_driver->decinfo);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
386
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
387 // printf("ret: %lu : ", ret);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
388
0959af64c098 needs to be hacked
alex
parents:
diff changeset
389
0959af64c098 needs to be hacked
alex
parents:
diff changeset
390 if (ret == ACT_DLT_NORM)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
391 {
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
392 // mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "norm\n");
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
393 return &xacodec_driver->image;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
394 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
395
0959af64c098 needs to be hacked
alex
parents:
diff changeset
396 /*
0959af64c098 needs to be hacked
alex
parents:
diff changeset
397 if (!(ret & ACT_DLT_MAPD))
0959af64c098 needs to be hacked
alex
parents:
diff changeset
398 xacodec_driver->decinfo->map_flag = 0;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
399 else
0959af64c098 needs to be hacked
alex
parents:
diff changeset
400 {
0959af64c098 needs to be hacked
alex
parents:
diff changeset
401 xacodec_driver->decinfo->map_flag = 1;
0959af64c098 needs to be hacked
alex
parents:
diff changeset
402 xacodec_driver->decinfo->map = ...
0959af64c098 needs to be hacked
alex
parents:
diff changeset
403 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
404 */
0959af64c098 needs to be hacked
alex
parents:
diff changeset
405
0959af64c098 needs to be hacked
alex
parents:
diff changeset
406 if (ret & ACT_DLT_NOP)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
407 {
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
408 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "nop\n");
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
409 return NULL; /* dst = 0 */
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
410 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
411
0959af64c098 needs to be hacked
alex
parents:
diff changeset
412 if (ret & ACT_DLT_DROP) /* by skip frames and errors */
0959af64c098 needs to be hacked
alex
parents:
diff changeset
413 {
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
414 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "drop\n");
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
415 return NULL;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
416 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
417
0959af64c098 needs to be hacked
alex
parents:
diff changeset
418 if (ret & ACT_DLT_BAD)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
419 {
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
420 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "bad\n");
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
421 return NULL;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
422 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
423
0959af64c098 needs to be hacked
alex
parents:
diff changeset
424 if (ret & ACT_DLT_BODY)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
425 {
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
426 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "body\n");
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
427 return NULL;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
428 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
429
0959af64c098 needs to be hacked
alex
parents:
diff changeset
430 if (ret & ACT_DLT_XOR)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
431 {
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
432 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "xor\n");
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
433 return &xacodec_driver->image;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
434 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
435
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
436 return NULL;
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
437 }
0959af64c098 needs to be hacked
alex
parents:
diff changeset
438
0959af64c098 needs to be hacked
alex
parents:
diff changeset
439 int xacodec_exit()
0959af64c098 needs to be hacked
alex
parents:
diff changeset
440 {
2382
alex
parents: 2381
diff changeset
441 int i;
alex
parents: 2381
diff changeset
442 void (*close_func)();
alex
parents: 2381
diff changeset
443
alex
parents: 2381
diff changeset
444 for (i=0; i < XA_CLOSE_FUNCS; i++)
alex
parents: 2381
diff changeset
445 if (xacodec_driver->close_func[i])
alex
parents: 2381
diff changeset
446 {
alex
parents: 2381
diff changeset
447 close_func = xacodec_driver->close_func[i];
alex
parents: 2381
diff changeset
448 close_func();
alex
parents: 2381
diff changeset
449 }
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
450 dlclose(xacodec_driver->file_handler);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
451 if (xacodec_driver->decinfo != NULL)
0959af64c098 needs to be hacked
alex
parents:
diff changeset
452 free(xacodec_driver->decinfo);
2388
9c14dc7a848c little cleanup
alex
parents: 2387
diff changeset
453 free(xacodec_driver);
2372
0959af64c098 needs to be hacked
alex
parents:
diff changeset
454 return(TRUE);
0959af64c098 needs to be hacked
alex
parents:
diff changeset
455 }
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
456
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
457
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
458 /* *** XANIM Conversions *** */
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
459 /* like loader/win32.c - mini XANIM library */
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
460
2382
alex
parents: 2381
diff changeset
461 unsigned long XA_Time_Read()
alex
parents: 2381
diff changeset
462 {
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
463 return GetTimer(); //(GetRelativeTime());
2382
alex
parents: 2381
diff changeset
464 }
alex
parents: 2381
diff changeset
465
alex
parents: 2381
diff changeset
466 void XA_dummy()
alex
parents: 2381
diff changeset
467 {
alex
parents: 2381
diff changeset
468 XA_Print("dummy() called");
alex
parents: 2381
diff changeset
469 }
alex
parents: 2381
diff changeset
470
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
471 void XA_Gen_YUV_Tabs(XA_ANIM_HDR *anim_hdr)
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
472 {
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
473 XA_Print("XA_Gen_YUV_Tabs('anim_hdr: %08x')", anim_hdr);
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
474
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
475 // XA_Print("anim type: %d - img[x: %d, y: %d, c: %d, d: %d]",
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
476 // anim_hdr->anim_type, anim_hdr->imagex, anim_hdr->imagey,
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
477 // anim_hdr->imagec, anim_hdr->imaged);
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
478 return;
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
479 }
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
480
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
481 void JPG_Setup_Samp_Limit_Table(XA_ANIM_HDR *anim_hdr)
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
482 {
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
483 XA_Print("JPG_Setup_Samp_Limit_Table('anim_hdr: %08x')", anim_hdr);
2381
448559791c0e cvid works but buggy
arpi
parents: 2377
diff changeset
484 // xa_byte_limit = jpg_samp_limit + (MAXJSAMPLE + 1);
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
485 return;
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
486 }
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
487
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
488 void JPG_Alloc_MCU_Bufs(XA_ANIM_HDR *anim_hdr, unsigned int width,
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
489 unsigned int height, unsigned int full_flag)
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
490 {
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
491 XA_Print("JPG_Alloc_MCU_Bufs('anim_hdr: %08x', 'width: %d', 'height: %d', 'full_flag: %d')",
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
492 anim_hdr, width, height, full_flag);
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
493 return;
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
494 }
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
495
2406
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
496 /* --------------- 4x4 pixel YUV block fillers [CVID] ----------------- */
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
497
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
498 typedef struct
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
499 {
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
500 unsigned char r0, g0, b0;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
501 unsigned char r1, g1, b1;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
502 unsigned char r2, g2, b2;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
503 unsigned char r3, g3, b3;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
504 unsigned int clr0_0, clr0_1, clr0_2, clr0_3;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
505 unsigned int clr1_0, clr1_1, clr1_2, clr1_3;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
506 unsigned int clr2_0, clr2_1, clr2_2, clr2_3;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
507 unsigned int clr3_0, clr3_1, clr3_2, clr3_3;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
508 } XA_2x2_Color;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
509
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
510 #define SET_4_YUV_PIXELS(image,x,y,cmap2x2) \
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
511 image->planes[0][((x)+0)+((y)+0)*image->stride[0]]=cmap2x2->clr0_0;\
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
512 image->planes[0][((x)+1)+((y)+0)*image->stride[0]]=cmap2x2->clr0_1;\
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
513 image->planes[0][((x)+0)+((y)+1)*image->stride[0]]=cmap2x2->clr0_2;\
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
514 image->planes[0][((x)+1)+((y)+1)*image->stride[0]]=cmap2x2->clr0_3;\
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
515 image->planes[1][((x)>>1)+((y)>>1)*image->stride[1]]=cmap2x2->clr1_0;\
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
516 image->planes[2][((x)>>1)+((y)>>1)*image->stride[2]]=cmap2x2->clr1_1;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
517
2406
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
518 void XA_2x2_OUT_1BLK_Convert(unsigned char *image_p, unsigned int x, unsigned int y,
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
519 unsigned int imagex, XA_2x2_Color *cmap2x2)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
520 {
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
521 xacodec_image_t *image=(xacodec_image_t*)image_p;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
522
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
523 #if 0
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
524 SET_4_YUV_PIXELS(image,x,y,cmap2x2)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
525 #else
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
526 SET_4_YUV_PIXELS(image,x,y,cmap2x2)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
527 SET_4_YUV_PIXELS(image,x+2,y,cmap2x2)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
528 SET_4_YUV_PIXELS(image,x,y+2,cmap2x2)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
529 SET_4_YUV_PIXELS(image,x+2,y+2,cmap2x2)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
530 #endif
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
531 return;
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
532 }
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
533
2406
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
534 void XA_2x2_OUT_4BLKS_Convert(unsigned char *image_p, unsigned int x, unsigned int y,
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
535 unsigned int imagex, XA_2x2_Color *cm0, XA_2x2_Color *cm1, XA_2x2_Color *cm2,
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
536 XA_2x2_Color *cm3)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
537 {
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
538 xacodec_image_t *image=(xacodec_image_t*)image_p;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
539
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
540 SET_4_YUV_PIXELS(image,x,y,cm0)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
541 SET_4_YUV_PIXELS(image,x+2,y,cm1)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
542 SET_4_YUV_PIXELS(image,x,y+2,cm2)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
543 SET_4_YUV_PIXELS(image,x+2,y+2,cm3)
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
544 return;
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
545 }
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
546
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
547 void *YUV2x2_Blk_Func(unsigned int image_type, int blks, unsigned int dith_flag)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
548 {
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
549 void (*color_func)();
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
550
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
551 switch(blks){
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
552 case 1:
2406
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
553 return (void*) XA_2x2_OUT_1BLK_Convert;
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
554 case 4:
2406
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
555 return (void*) XA_2x2_OUT_4BLKS_Convert;
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
556 }
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
557
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
558 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Unimplemented: YUV2x2_Blk_Func(image_type=%d blks=%d dith=%d)\n",image_type,blks,dith_flag);
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
559 return (void*) XA_dummy;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
560 }
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
561
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
562 // Take Four Y's and UV and put them into a 2x2 Color structure.
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
563
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
564 void XA_YUV_2x2_clr(XA_2x2_Color *cmap2x2, unsigned int Y0, unsigned int Y1,
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
565 unsigned int Y2, unsigned int Y3, unsigned int U, unsigned int V,
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
566 unsigned int map_flag, unsigned int *map, XA_CHDR *chdr)
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
567 {
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
568
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
569 // printf("XA_YUV_2x2_clr(%p [%d,%d,%d,%d][%d][%d] %d %p %p)\n",
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
570 // cmap2x2,Y0,Y1,Y2,Y3,U,V,map_flag,map,chdr);
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
571
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
572 cmap2x2->clr0_0=Y0;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
573 cmap2x2->clr0_1=Y1;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
574 cmap2x2->clr0_2=Y2;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
575 cmap2x2->clr0_3=Y3;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
576 cmap2x2->clr1_0=U;
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
577 cmap2x2->clr1_1=V;
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
578 return;
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
579 }
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
580
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
581 void *YUV2x2_Map_Func(unsigned int image_type, unsigned int dith_type)
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
582 {
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
583 // XA_Print("YUV2x2_Map_Func('image_type: %d', 'dith_type: %d')",
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
584 // image_type, dith_type);
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
585 return((void*)XA_YUV_2x2_clr);
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
586 }
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
587
2406
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
588 /* -------------------- whole YUV frame converters ------------------------- */
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
589
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
590 typedef struct
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
591 {
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
592 unsigned char *Ybuf;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
593 unsigned char *Ubuf;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
594 unsigned char *Vbuf;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
595 unsigned char *the_buf;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
596 unsigned int the_buf_size;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
597 unsigned short y_w, y_h;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
598 unsigned short uv_w, uv_h;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
599 } YUVBufs;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
600
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
601 typedef struct
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
602 {
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
603 unsigned long Uskip_mask;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
604 long *YUV_Y_tab;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
605 long *YUV_UB_tab;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
606 long *YUV_VR_tab;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
607 long *YUV_UG_tab;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
608 long *YUV_VG_tab;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
609 } YUVTabs;
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
610
2406
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
611 YUVBufs jpg_YUVBufs;
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
612 YUVTabs def_yuv_tabs;
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
613
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
614 /* -------------- YUV 4x4 1x1 1x1 [Indeo 3,4,5] ------------------ */
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
615
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
616 void XA_YUV1611_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
617 unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs,
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
618 unsigned int map_flag, unsigned int *map, XA_CHDR *chdr)
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
619 {
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
620 xacodec_image_t *image=(xacodec_image_t*)image_p;
2395
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
621 int y;
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
622 int uvstride;
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
623
2395
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
624 #if 0
2397
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
625 printf("YUVTabs: %d %p %p %p %p %p\n",yuv_tabs->Uskip_mask,
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
626 yuv_tabs->YUV_Y_tab,
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
627 yuv_tabs->YUV_UB_tab,
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
628 yuv_tabs->YUV_VR_tab,
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
629 yuv_tabs->YUV_UG_tab,
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
630 yuv_tabs->YUV_VG_tab );
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
631
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
632 XA_Print("XA_YUV1611_Convert('image: %08x', 'imagex: %d', 'imagey: %d', 'i_x: %d', 'i_y: %d', 'yuv_bufs: %08x', 'yuv_tabs: %08x', 'map_flag: %d', 'map: %08x', 'chdr: %08x')",
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
633 image, imagex, imagey, i_x, i_y, yuv, yuv_tabs, map_flag, map, chdr);
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
634
2395
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
635 printf("YUV: %p %p %p %X (%d) %dx%d %dx%d\n",
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
636 yuv->Ybuf,yuv->Ubuf,yuv->Vbuf,yuv->the_buf,yuv->the_buf_size,
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
637 yuv->y_w,yuv->y_h,yuv->uv_w,yuv->uv_h);
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
638 #endif
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
639
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
640 // copy Y plane:
2397
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
641 if(yuv_tabs->YUV_Y_tab){ // dirty hack to detect iv32:
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
642 for(y=0;y<imagey*imagex;y++)
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
643 image->planes[0][y]=yuv->Ybuf[y]<<1;
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
644 } else
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
645 memcpy(image->planes[0],yuv->Ybuf,imagex*imagey);
2395
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
646
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
647 // scale U,V planes by 2:
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
648 imagex>>=2;
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
649 imagey>>=2;
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
650
2395
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
651 uvstride=(yuv->uv_w)?yuv->uv_w:imagex;
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
652
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
653 for(y=0;y<imagey;y++){
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
654 unsigned char *su=yuv->Ubuf+uvstride*y;
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
655 unsigned char *sv=yuv->Vbuf+uvstride*y;
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
656 unsigned int strideu=image->stride[1];
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
657 unsigned int stridev=image->stride[2];
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
658 unsigned char *du=image->planes[1]+2*y*strideu;
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
659 unsigned char *dv=image->planes[2]+2*y*stridev;
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
660 int x;
2397
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
661 if(yuv_tabs->YUV_Y_tab){ // dirty hack to detect iv32:
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
662 for(x=0;x<imagex;x++){
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
663 du[2*x]=du[2*x+1]=du[2*x+strideu]=du[2*x+strideu+1]=su[x]*2;
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
664 dv[2*x]=dv[2*x+1]=dv[2*x+stridev]=dv[2*x+stridev+1]=sv[x]*2;
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
665 }
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
666 } else {
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
667 for(x=0;x<imagex;x++){
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
668 du[2*x]=du[2*x+1]=du[2*x+strideu]=du[2*x+strideu+1]=su[x];
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
669 dv[2*x]=dv[2*x+1]=dv[2*x+stridev]=dv[2*x+stridev+1]=sv[x];
af87f279dbd4 iv32 color scaling fix
arpi
parents: 2395
diff changeset
670 }
2395
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
671 }
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
672 }
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
673 return;
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
674 }
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
675
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
676 void *XA_YUV1611_Func(unsigned int image_type)
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
677 {
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
678 // XA_Print("XA_YUV1611_Func('image_type: %d')", image_type);
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
679 return((void *)XA_YUV1611_Convert);
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
680 }
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
681
2406
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
682 /* -------------- YUV 4x1 1x1 1x1 (4:1:1 ?) [???] ------------------ */
2395
6c176e31873d YUV 16:1:1 fixed (indeo5)
arpi
parents: 2391
diff changeset
683
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
684 void XA_YUV411111_Convert(unsigned char *image, unsigned int imagex, unsigned int imagey,
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
685 unsigned int i_x, unsigned int i_y, YUVBufs *yuv_bufs, YUVTabs *yuv_tabs,
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
686 unsigned int map_flag, unsigned int *map, XA_CHDR *chdr)
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
687 {
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
688 XA_Print("XA_YUV411111_Convert('image: %d', 'imagex: %d', 'imagey: %d', 'i_x: %d', 'i_y: %d', 'yuv_bufs: %08x', 'yuv_tabs: %08x', 'map_flag: %d', 'map: %08x', 'chdr: %08x')",
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
689 image, imagex, imagey, i_x, i_y, yuv_bufs, yuv_tabs, map_flag, map, chdr);
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
690 return;
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
691 }
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
692
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
693 void *XA_YUV411111_Func(unsigned int image_type)
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
694 {
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
695 // XA_Print("XA_YUV411111_Func('image_type: %d')", image_type);
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
696 return((void*)XA_YUV411111_Convert);
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
697 }
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
698
2406
2547932c6ef0 comments...
arpi
parents: 2404
diff changeset
699 /* --------------- YUV 2x2 1x1 1x1 (4:2:0 aka YV12) [3ivX,H263] ------------ */
2391
335b9b6302fa cvid/3ivx yuv renderers cleanup
arpi
parents: 2388
diff changeset
700
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
701 void XA_YUV221111_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
702 unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs, unsigned int map_flag,
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
703 unsigned int *map, XA_CHDR *chdr)
2383
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
704 {
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
705 xacodec_image_t *image=(xacodec_image_t*)image_p;
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
706
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
707 #if 0
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
708 printf("XA_YUV221111_Convert(%p %dx%d %d;%d [%dx%d] %p %p %d %p %p)\n",
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
709 image,imagex,imagey,i_x,i_y, image->width,image->height,
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
710 yuv,yuv_tabs,map_flag,map,chdr);
2383
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
711
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
712 printf("YUV: %p %p %p %X (%X) %Xx%X %Xx%X\n",
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
713 yuv->Ybuf,yuv->Ubuf,yuv->Vbuf,yuv->the_buf,yuv->the_buf_size,
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
714 yuv->y_w,yuv->y_h,yuv->uv_w,yuv->uv_h);
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
715 #endif
2383
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
716
2403
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
717 if(i_x==image->width && i_y==image->height){
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
718 // printf("Direct render!!!\n");
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
719 image->planes[0]=yuv->Ybuf;
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
720 if(image->out_fmt==IMGFMT_YV12){
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
721 image->planes[1]=yuv->Ubuf;
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
722 image->planes[2]=yuv->Vbuf;
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
723 } else {
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
724 image->planes[1]=yuv->Vbuf;
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
725 image->planes[2]=yuv->Ubuf;
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
726 }
2403
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
727 image->stride[0]=i_x; // yuv->y_w
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
728 image->stride[1]=image->stride[2]=i_x/2; // yuv->uv_w
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
729 } else {
2403
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
730 int y;
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
731 for(y=0;y<i_y;y++)
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
732 memcpy(image->planes[0]+y*image->stride[0],yuv->Ybuf+y*i_x,i_x);
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
733 i_x>>=1; i_y>>=1;
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
734 for(y=0;y<i_y;y++){
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
735 memcpy(image->planes[1]+y*image->stride[1],yuv->Ubuf+y*i_x,i_x);
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
736 memcpy(image->planes[2]+y*image->stride[2],yuv->Vbuf+y*i_x,i_x);
af90fac426a6 h263 fixed
arpi
parents: 2402
diff changeset
737 }
2384
814166bee8fd 3ivx YV12 direct rendering (one lss memcpy)
arpi
parents: 2383
diff changeset
738 }
2402
f628c76bbc11 little cleanup to eleminate xanim typedefs and be more mplayer like
alex
parents: 2397
diff changeset
739 return;
2383
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
740 }
e13c63bc4151 hmm. 3ivx works
arpi
parents: 2382
diff changeset
741
2382
alex
parents: 2381
diff changeset
742 void *XA_YUV221111_Func(unsigned int image_type)
alex
parents: 2381
diff changeset
743 {
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
744 // XA_Print("XA_YUV221111_Func('image_type: %d')", image_type);
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
745 return((void *)XA_YUV221111_Convert);
2382
alex
parents: 2381
diff changeset
746 }
2373
463da8544d23 reworked for mplayer
alex
parents: 2372
diff changeset
747
2404
da766ceb7bdd cleaned up, also removed some useless printf's to be more faster ;)
alex
parents: 2403
diff changeset
748 /* *** EOF XANIM *** */
2481
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
749
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
750 #else /* HAVE_LIBDL */
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
751
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
752 int xacodec_init_video(void)
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
753 {
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
754 mp_msg(MSGT_DEMUX, MSGL_FATAL, "xacodec needs libdl to work!\n");
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
755 return 0;
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
756 }
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
757
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
758 void xacodec_decode_frame(void)
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
759 {
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
760 mp_msg(MSGT_DEMUX, MSGL_FATAL, "xacodec needs libdl to work!\n");
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
761 return NULL;
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
762 }
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
763
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
764 void xacodec_exit(void)
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
765 {
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
766 mp_msg(MSGT_DEMUX, MSGL_FATAL, "xacodec needs libdl to work!\n");
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
767 return;
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
768 }
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
769
0e9a5504a246 libdl checking added
alex
parents: 2414
diff changeset
770 #endif /* HAVE_LIBDL */