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