annotate xacodec.c @ 2372:0959af64c098

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