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