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