annotate xacodec.c @ 2383:e13c63bc4151

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