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