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