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