/[public]/psiconv/trunk/lib/psiconv/generate_image.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/generate_image.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 176 Revision 184
22#include "compat.h" 22#include "compat.h"
23 23
24#include "generate_routines.h" 24#include "generate_routines.h"
25#include "error.h" 25#include "error.h"
26#include "list.h" 26#include "list.h"
27#include "image.h"
27 28
28#ifdef DMALLOC 29#ifdef DMALLOC
29#include <dmalloc.h> 30#include <dmalloc.h>
30#endif 31#endif
31 32
32typedef psiconv_list psiconv_pixel_bytes; /* psiconv_u8 */
33
34typedef psiconv_list psiconv_pixel_ints; /* of psiconv_u32 */
35
36typedef struct psiconv_pixel_float_s
37{
38 psiconv_u32 length;
39 float *red;
40 float *green;
41 float *blue;
42} psiconv_pixel_floats_t;
43 33
44static int psiconv_collect_pixel_data(psiconv_pixel_ints *pixels, 34static int psiconv_collect_pixel_data(psiconv_pixel_ints *pixels,
45 int xsize,int ysize, 35 int xsize,int ysize,
46 const psiconv_pixel_floats_t data, 36 const psiconv_pixel_floats_t data,
47 int colordepth,int color, 37 int colordepth,int color,
62 psiconv_pixel_bytes *encoded_bytes); 52 psiconv_pixel_bytes *encoded_bytes);
63static int psiconv_encode_rle24(const psiconv_config config, 53static int psiconv_encode_rle24(const psiconv_config config,
64 const psiconv_pixel_bytes plain_bytes, 54 const psiconv_pixel_bytes plain_bytes,
65 psiconv_pixel_bytes *encoded_bytes); 55 psiconv_pixel_bytes *encoded_bytes);
66 56
67#define PALET_NONE_LEN 0
68
69psiconv_pixel_floats_t palet_none =
70 {
71 PALET_NONE_LEN,
72 NULL,
73 NULL,
74 NULL
75 };
76
77#define PALET_COLOR_4_LEN 16
78float palet_color_4_red[PALET_COLOR_4_LEN] =
79 { 0x00/256.0, 0x55/256.0, 0x80/256.0, 0x80/256.0, /* 0x00 */
80 0x00/256.0, 0xff/256.0, 0x00/256.0, 0xff/256.0, /* 0x04 */
81 0xff/256.0, 0x00/256.0, 0x00/256.0, 0x80/256.0, /* 0x08 */
82 0x00/256.0, 0x00/256.0, 0xaa/256.0, 0xff/256.0 /* 0x0c */
83 };
84
85float palet_color_4_green[PALET_COLOR_4_LEN] =
86 { 0x00/256.0, 0x55/256.0, 0x00/256.0, 0x80/256.0, /* 0x00 */
87 0x80/256.0, 0x00/256.0, 0xff/256.0, 0xff/256.0, /* 0x04 */
88 0x00/256.0, 0xff/256.0, 0xff/256.0, 0x00/256.0, /* 0x08 */
89 0x00/256.0, 0x80/256.0, 0xaa/256.0, 0xff/256.0 /* 0x0c */
90 };
91
92float palet_color_4_blue[PALET_COLOR_4_LEN] =
93 { 0x00/256.0, 0x55/256.0, 0x00/256.0, 0x00/256.0, /* 0x00 */
94 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x04 */
95 0xff/256.0, 0x00/256.0, 0xff/256.0, 0x80/256.0, /* 0x08 */
96 0x80/256.0, 0x80/256.0, 0xaa/256.0, 0xff/256.0 /* 0x0c */
97 };
98
99psiconv_pixel_floats_t palet_color_4 =
100 {
101 PALET_COLOR_4_LEN,
102 palet_color_4_red,
103 palet_color_4_green,
104 palet_color_4_blue,
105 };
106
107#define PALET_COLOR_8_LEN 256
108float palet_color_8_red[PALET_COLOR_8_LEN] =
109 { 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x00 */
110 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x04 */
111 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x08 */
112 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x0c */
113 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x10 */
114 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x14 */
115 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x18 */
116 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x1c */
117 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x20 */
118 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x24 */
119 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x28 */
120 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x2c */
121 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x30 */
122 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x34 */
123 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x38 */
124 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x3c */
125 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x40 */
126 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x44 */
127 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x48 */
128 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x4c */
129 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x50 */
130 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x54 */
131 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x58 */
132 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x5c */
133 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x60 */
134 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x64 */
135 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x68 */
136 0x11/256.0, 0x22/256.0, 0x44/256.0, 0x55/256.0, /* 0x6c */
137 0x77/256.0, 0x11/256.0, 0x22/256.0, 0x44/256.0, /* 0x70 */
138 0x55/256.0, 0x77/256.0, 0x00/256.0, 0x00/256.0, /* 0x74 */
139 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x78 */
140 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x7c */
141 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x80 */
142 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x84 */
143 0x00/256.0, 0x00/256.0, 0x88/256.0, 0xaa/256.0, /* 0x88 */
144 0xbb/256.0, 0xdd/256.0, 0xee/256.0, 0x88/256.0, /* 0x8c */
145 0xaa/256.0, 0xbb/256.0, 0xdd/256.0, 0xee/256.0, /* 0x90 */
146 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x94 */
147 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x98 */
148 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x9c */
149 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xa0 */
150 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xa4 */
151 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xa8 */
152 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xac */
153 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xb0 */
154 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xb4 */
155 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xb8 */
156 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xbc */
157 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xc0 */
158 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xc4 */
159 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xc8 */
160 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xcc */
161 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xd0 */
162 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xd4 */
163 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xd8 */
164 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xdc */
165 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xe0 */
166 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xe4 */
167 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xe8 */
168 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xec */
169 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xf0 */
170 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xf4 */
171 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xf8 */
172 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0 /* 0xfc */
173 };
174
175float palet_color_8_green[PALET_COLOR_8_LEN] =
176 { 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x00 */
177 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0x04 */
178 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x08 */
179 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x0c */
180 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0x10 */
181 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x14 */
182 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0x18 */
183 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0x1c */
184 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0x20 */
185 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x24 */
186 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0x28 */
187 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x2c */
188 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x30 */
189 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0x34 */
190 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x38 */
191 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0x3c */
192 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0x40 */
193 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0x44 */
194 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x48 */
195 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0x4c */
196 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x50 */
197 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x54 */
198 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0x58 */
199 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x5c */
200 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0x60 */
201 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0x64 */
202 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0x68 */
203 0x11/256.0, 0x22/256.0, 0x44/256.0, 0x55/256.0, /* 0x6c */
204 0x77/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x70 */
205 0x00/256.0, 0x00/256.0, 0x11/256.0, 0x22/256.0, /* 0x74 */
206 0x44/256.0, 0x55/256.0, 0x77/256.0, 0x00/256.0, /* 0x78 */
207 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x7c */
208 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x80 */
209 0x00/256.0, 0x88/256.0, 0xaa/256.0, 0xbb/256.0, /* 0x84 */
210 0xdd/256.0, 0xee/256.0, 0x00/256.0, 0x00/256.0, /* 0x88 */
211 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x88/256.0, /* 0x8c */
212 0xaa/256.0, 0xbb/256.0, 0xdd/256.0, 0xee/256.0, /* 0x90 */
213 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x94 */
214 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0x98 */
215 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x9c */
216 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0xa0 */
217 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0xa4 */
218 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xa8 */
219 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xac */
220 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0xb0 */
221 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xb4 */
222 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0xb8 */
223 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0xbc */
224 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0xc0 */
225 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0xc4 */
226 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0xc8 */
227 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xcc */
228 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xd0 */
229 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0xd4 */
230 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xd8 */
231 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0xdc */
232 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0xe0 */
233 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0xe4 */
234 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0xe8 */
235 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0xec */
236 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xf0 */
237 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xf4 */
238 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0xf8 */
239 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xfc */
240 };
241
242float palet_color_8_blue[PALET_COLOR_8_LEN] =
243 { 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x00 */
244 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x04 */
245 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x08 */
246 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x0c */
247 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x10 */
248 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x14 */
249 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x18 */
250 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x1c */
251 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x20 */
252 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x24 */
253 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x28 */
254 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x2c */
255 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x30 */
256 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x34 */
257 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x38 */
258 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x3c */
259 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x40 */
260 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x44 */
261 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x48 */
262 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x4c */
263 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x50 */
264 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x54 */
265 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x58 */
266 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x5c */
267 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x60 */
268 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x64 */
269 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x68 */
270 0x11/256.0, 0x22/256.0, 0x44/256.0, 0x55/256.0, /* 0x6c */
271 0x77/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x70 */
272 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x74 */
273 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x11/256.0, /* 0x78 */
274 0x22/256.0, 0x44/256.0, 0x55/256.0, 0x77/256.0, /* 0x7c */
275 0x88/256.0, 0xaa/256.0, 0xbb/256.0, 0xdd/256.0, /* 0x80 */
276 0xee/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x84 */
277 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x88 */
278 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x88/256.0, /* 0x8c */
279 0xaa/256.0, 0xbb/256.0, 0xdd/256.0, 0xee/256.0, /* 0x90 */
280 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x94 */
281 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x98 */
282 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x9c */
283 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xa0 */
284 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xa4 */
285 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xa8 */
286 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xac */
287 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xb0 */
288 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xb4 */
289 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xb8 */
290 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xbc */
291 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xc0 */
292 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xc4 */
293 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xc8 */
294 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xcc */
295 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xd0 */
296 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xd4 */
297 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xd8 */
298 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xdc */
299 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xe0 */
300 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xe4 */
301 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xe8 */
302 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xec */
303 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xf0 */
304 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xf4 */
305 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xf8 */
306 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xfc */
307 };
308
309psiconv_pixel_floats_t palet_color_8 =
310 {
311 PALET_COLOR_8_LEN,
312 palet_color_8_red,
313 palet_color_8_green,
314 palet_color_8_blue,
315 };
316
317int psiconv_write_paint_data_section(const psiconv_config config, 57int psiconv_write_paint_data_section(const psiconv_config config,
318 psiconv_buffer buf, 58 psiconv_buffer buf, int lev,
319 const psiconv_paint_data_section value, 59 const psiconv_paint_data_section value,
320 int is_clipart) 60 int is_clipart)
321{ 61{
322 int res,colordepth,i; 62 int res,colordepth,i;
323 psiconv_pixel_ints ints; 63 psiconv_pixel_ints ints;
324 psiconv_pixel_floats_t floats,palet; 64 psiconv_pixel_floats_t floats,palet;
325 psiconv_list bytes,bytes_rle; 65 psiconv_list bytes,bytes_rle;
326 psiconv_u8 *byteptr,encoding; 66 psiconv_u8 *byteptr,encoding;
327 67
68 psiconv_progress(config,lev,0,"Writing paint data section");
69
328 /* First, we check whether we can cope with the current configuration. 70 /* First, we check whether we can cope with the current configuration.
329 If not, we stop at once */ 71 If not, we stop at once */
330 if ((config->colordepth != 2) && (config->colordepth != 4) && 72 if ((config->colordepth != 2) && (config->colordepth != 4) &&
331 (config->colordepth != 8) && (config->colordepth != 12) && 73 (config->colordepth != 8) && (config->colordepth != 12) &&
332 (config->colordepth != 16) && (config->colordepth != 24)) { 74 (config->colordepth != 16) && (config->colordepth != 24)) {
333 psiconv_warn(config,0,psiconv_buffer_length(buf), 75 psiconv_error(config,0,psiconv_buffer_length(buf),
334 "Unsupported color depth (%d); try 2, 4, 8, 16 or 24", 76 "Unsupported color depth (%d); try 2, 4, 8, 16 or 24",
335 config->colordepth); 77 config->colordepth);
336 res = -PSICONV_E_GENERATE; 78 res = -PSICONV_E_GENERATE;
337 goto ERROR1; 79 goto ERROR1;
338 } 80 }
339 81
340 if ((config->color) && 82 if ((config->color) &&
341 (config->bluebits || config->redbits || config->greenbits) && 83 (config->bluebits || config->redbits || config->greenbits) &&
342 (config->bluebits+config->redbits+config->greenbits!=config->colordepth)) { 84 (config->bluebits+config->redbits+config->greenbits!=config->colordepth)) {
343 psiconv_warn(config,0,psiconv_buffer_length(buf), 85 psiconv_error(config,0,psiconv_buffer_length(buf),
344 "Sum of red (%d), green (%d) and blue (%d) bits should be " 86 "Sum of red (%d), green (%d) and blue (%d) bits should be "
345 "equal to the color depth (%d)", 87 "equal to the color depth (%d)",
346 config->redbits,config->greenbits,config->bluebits, 88 config->redbits,config->greenbits,config->bluebits,
347 config->colordepth); 89 config->colordepth);
348 res = -PSICONV_E_GENERATE; 90 res = -PSICONV_E_GENERATE;
350 } 92 }
351 93
352 if (config->color && 94 if (config->color &&
353 !(config->redbits || config->greenbits || config->bluebits) && 95 !(config->redbits || config->greenbits || config->bluebits) &&
354 (config->colordepth != 4) && (config->colordepth != 8)) { 96 (config->colordepth != 4) && (config->colordepth != 8)) {
355 psiconv_warn(config,0,psiconv_buffer_length(buf), 97 psiconv_error(config,0,psiconv_buffer_length(buf),
356 "Current color depth (%d) has no palet associated with it", 98 "Current color depth (%d) has no palet associated with it",
357 config->colordepth); 99 config->colordepth);
358 res = -PSICONV_E_GENERATE; 100 res = -PSICONV_E_GENERATE;
359 goto ERROR1; 101 goto ERROR1;
360 } 102 }
363 psiconv_warn(config,0,psiconv_buffer_length(buf), 105 psiconv_warn(config,0,psiconv_buffer_length(buf),
364 "All image types except 2-bit greyscale are experimental!"); 106 "All image types except 2-bit greyscale are experimental!");
365 107
366 108
367 if (!value) { 109 if (!value) {
368 psiconv_warn(config,0,psiconv_buffer_length(buf),"Null paint data section"); 110 psiconv_error(config,0,psiconv_buffer_length(buf),"Null paint data section");
369 res = -PSICONV_E_GENERATE; 111 res = -PSICONV_E_GENERATE;
370 goto ERROR1; 112 goto ERROR1;
371 } 113 }
372 114
373 floats.red = value->red; 115 floats.red = value->red;
374 floats.green = value->green; 116 floats.green = value->green;
375 floats.blue = value->blue; 117 floats.blue = value->blue;
376 floats.length = value->xsize * value->ysize; 118 floats.length = value->xsize * value->ysize;
377 119
378 palet = palet_none; 120 palet = psiconv_palet_none;
379 if ((config->color) && (config->redbits == 0) && (config->greenbits == 0) &&\ 121 if ((config->color) && (config->redbits == 0) && (config->greenbits == 0) &&
380 (config->bluebits == 0)) 122 (config->bluebits == 0))
381 switch (config->colordepth) { 123 switch (config->colordepth) {
382 case 4: palet = palet_color_4; break; 124 case 4: palet = psiconv_palet_color_4; break;
383 case 8: palet = palet_color_8; break; 125 case 8: palet = psiconv_palet_color_8; break;
384 default: palet = palet_none; break; 126 default: palet = psiconv_palet_none; break;
385 } 127 }
386 128
387 if ((res = psiconv_collect_pixel_data(&ints,value->xsize, 129 if ((res = psiconv_collect_pixel_data(&ints,value->xsize,
388 value->ysize,floats, 130 value->ysize,floats,
389 config->colordepth,config->color, 131 config->colordepth,config->color,
390 config->redbits,config->greenbits, 132 config->redbits,config->greenbits,
391 config->bluebits,palet))) 133 config->bluebits,palet))) {
134 psiconv_error(config,lev,0,"Error collecting pixel data");
392 goto ERROR1; 135 goto ERROR1;
136 }
393 137
394 if ((res = psiconv_pixel_data_to_bytes(config,&bytes,value->xsize,value->ysize, 138 if ((res = psiconv_pixel_data_to_bytes(config,&bytes,value->xsize,value->ysize,
395 ints,config->colordepth))) 139 ints,config->colordepth))) {
140 psiconv_error(config,lev,0,"Error translating pixel data to bytes");
396 goto ERROR2; 141 goto ERROR2;
142 }
397 143
398 144
399 switch (config->colordepth) { 145 switch (config->colordepth) {
400 case 2: 146 case 2:
401 case 4: 147 case 4:
402 case 8: 148 case 8:
403 encoding = 0x01; 149 encoding = 0x01;
404 if ((res = psiconv_encode_rle8(config,bytes,&bytes_rle))) 150 if ((res = psiconv_encode_rle8(config,bytes,&bytes_rle))) {
151 psiconv_error(config,lev,0,"Error encoding RLE8");
405 goto ERROR3; 152 goto ERROR3;
153 }
406 break; 154 break;
407 case 12: 155 case 12:
408 encoding = 0x02; 156 encoding = 0x02;
409 if ((res = psiconv_encode_rle12(config,bytes,&bytes_rle))) 157 if ((res = psiconv_encode_rle12(config,bytes,&bytes_rle))) {
158 psiconv_error(config,lev,0,"Error encoding RLE12");
410 goto ERROR3; 159 goto ERROR3;
160 }
411 break; 161 break;
412 case 16: 162 case 16:
413 encoding = 0x03; 163 encoding = 0x03;
414 if ((res = psiconv_encode_rle16(config,bytes,&bytes_rle))) 164 if ((res = psiconv_encode_rle16(config,bytes,&bytes_rle))) {
165 psiconv_error(config,lev,0,"Error encoding RLE16");
415 goto ERROR3; 166 goto ERROR3;
167 }
416 break; 168 break;
417 case 24: 169 case 24:
418 encoding = 0x04; 170 encoding = 0x04;
419 if ((res = psiconv_encode_rle24(config,bytes,&bytes_rle))) 171 if ((res = psiconv_encode_rle24(config,bytes,&bytes_rle))) {
172 psiconv_error(config,lev,0,"Error encoding RLE24");
420 goto ERROR3; 173 goto ERROR3;
174 }
421 break; 175 break;
422 default: 176 default:
423 encoding = 0x00; 177 encoding = 0x00;
424 } 178 }
425 if (encoding) { 179 if (encoding) {
430 psiconv_list_free(bytes_rle); 184 psiconv_list_free(bytes_rle);
431 encoding = 0x00; 185 encoding = 0x00;
432 } 186 }
433 } 187 }
434 188
435 if ((res = psiconv_write_u32(config,buf, 189 if ((res = psiconv_write_u32(config,buf,lev+1,
436 0x28+psiconv_list_length(bytes)))) 190 0x28+psiconv_list_length(bytes))))
437 goto ERROR3; 191 goto ERROR3;
438 if ((res = psiconv_write_u32(config,buf,0x28))) 192 if ((res = psiconv_write_u32(config,buf,lev+1,0x28)))
439 goto ERROR3; 193 goto ERROR3;
440 if ((res = psiconv_write_u32(config,buf,value->xsize))) 194 if ((res = psiconv_write_u32(config,buf,lev+1,value->xsize)))
441 goto ERROR3; 195 goto ERROR3;
442 if ((res = psiconv_write_u32(config,buf,value->ysize))) 196 if ((res = psiconv_write_u32(config,buf,lev+1,value->ysize)))
443 goto ERROR3; 197 goto ERROR3;
444 if ((res = psiconv_write_length(config,buf,value->pic_xsize))) 198 if ((res = psiconv_write_length(config,buf,lev+1,value->pic_xsize)))
445 goto ERROR3; 199 goto ERROR3;
446 if ((res = psiconv_write_length(config,buf,value->pic_ysize))) 200 if ((res = psiconv_write_length(config,buf,lev+1,value->pic_ysize)))
447 goto ERROR3; 201 goto ERROR3;
448 colordepth = config->colordepth; 202 colordepth = config->colordepth;
449 if ((res = psiconv_write_u32(config,buf,colordepth))) 203 if ((res = psiconv_write_u32(config,buf,lev+1,colordepth)))
450 goto ERROR3; 204 goto ERROR3;
451 if ((res = psiconv_write_u32(config,buf,(config->color?1:0)))) 205 if ((res = psiconv_write_u32(config,buf,lev+1,(config->color?1:0))))
452 goto ERROR3; 206 goto ERROR3;
453 if ((res = psiconv_write_u32(config,buf,0))) 207 if ((res = psiconv_write_u32(config,buf,lev+1,0)))
454 goto ERROR3; 208 goto ERROR3;
455 if ((res = psiconv_write_u32(config,buf,encoding))) 209 if ((res = psiconv_write_u32(config,buf,lev+1,encoding)))
456 goto ERROR3; 210 goto ERROR3;
457 if (is_clipart) { 211 if (is_clipart) {
458 if ((res = psiconv_write_u32(config,buf,0xffffffff))) 212 if ((res = psiconv_write_u32(config,buf,lev+1,0xffffffff)))
459 goto ERROR3; 213 goto ERROR3;
460 if ((res = psiconv_write_u32(config,buf,0x00000044))) 214 if ((res = psiconv_write_u32(config,buf,lev+1,0x00000044)))
461 goto ERROR3; 215 goto ERROR3;
462 } 216 }
463 for (i = 0; i < psiconv_list_length(bytes); i++) { 217 for (i = 0; i < psiconv_list_length(bytes); i++) {
464 if (!(byteptr = psiconv_list_get(bytes,i))) 218 if (!(byteptr = psiconv_list_get(bytes,i)))
465 goto ERROR3; 219 goto ERROR3;
466 if ((res = psiconv_write_u8(config,buf,*byteptr))) 220 if ((res = psiconv_write_u8(config,buf,lev+1,*byteptr)))
467 goto ERROR3; 221 goto ERROR3;
468 } 222 }
469 223
470ERROR3: 224ERROR3:
471 psiconv_list_free(bytes); 225 psiconv_list_free(bytes);
547 psiconv_u32 *pixelptr; 301 psiconv_u32 *pixelptr;
548 int inputbitsleft,outputbitnr,bitsfit,outputbytenr; 302 int inputbitsleft,outputbitnr,bitsfit,outputbytenr;
549 303
550 304
551 if (!bytes) { 305 if (!bytes) {
552 psiconv_warn(config,0,0,"NULL pixel data"); 306 psiconv_error(config,0,0,"NULL pixel data");
553 res = -PSICONV_E_GENERATE; 307 res = -PSICONV_E_GENERATE;
554 goto ERROR1; 308 goto ERROR1;
555 } 309 }
556 if (!pixels) { 310 if (!pixels) {
557 psiconv_warn(config,0,0,"NULL pixel data"); 311 psiconv_error(config,0,0,"NULL pixel data");
558 res = -PSICONV_E_GENERATE; 312 res = -PSICONV_E_GENERATE;
559 goto ERROR1; 313 goto ERROR1;
560 } 314 }
561 if (psiconv_list_length(pixels) != xsize * ysize) { 315 if (psiconv_list_length(pixels) != xsize * ysize) {
562 psiconv_warn(config,0,0,"Pixel number is not correct"); 316 psiconv_error(config,0,0,"Pixel number is not correct");
563 res = -PSICONV_E_GENERATE; 317 res = -PSICONV_E_GENERATE;
564 goto ERROR1; 318 goto ERROR1;
565 } 319 }
566 320
567 if (!(*bytes = psiconv_list_new(sizeof(psiconv_u8)))) { 321 if (!(*bytes = psiconv_list_new(sizeof(psiconv_u8)))) {
574 outputbyte = 0; 328 outputbyte = 0;
575 for (y = 0; y < ysize; y++) { 329 for (y = 0; y < ysize; y++) {
576 outputbytenr = 0; 330 outputbytenr = 0;
577 for (x = 0; x < xsize; x++) { 331 for (x = 0; x < xsize; x++) {
578 if (!(pixelptr = psiconv_list_get(pixels,y*xsize+x))) { 332 if (!(pixelptr = psiconv_list_get(pixels,y*xsize+x))) {
579 psiconv_warn(config,0,0,"Massive internal corruption"); 333 psiconv_error(config,0,0,"Massive internal corruption");
580 res = -PSICONV_E_NOMEM; 334 res = -PSICONV_E_NOMEM;
581 goto ERROR2; 335 goto ERROR2;
582 } 336 }
583 inputbitsleft = colordepth; 337 inputbitsleft = colordepth;
584 inputdata = *pixelptr; 338 inputdata = *pixelptr;
655 goto ERROR2; 409 goto ERROR2;
656 if ((res = psiconv_list_add(*encoded_bytes,next))) 410 if ((res = psiconv_list_add(*encoded_bytes,next)))
657 goto ERROR2; 411 goto ERROR2;
658 i +=2; 412 i +=2;
659 } else if (*next == *entry) { 413 } else if (*next == *entry) {
660 len = 0; 414 len = 1;
661 while ((*next == *entry) && 415 while ((*next == *entry) &&
662 (i+len + 1 < psiconv_list_length(plain_bytes)) && 416 (i+len + 2 < psiconv_list_length(plain_bytes)) &&
663 len < 0x80) { 417 len < 0x80) {
664 len ++; 418 len ++;
665 if (!(next = psiconv_list_get(plain_bytes,i+len))) { 419 if (!(next = psiconv_list_get(plain_bytes,i+len))) {
666 res = -PSICONV_E_NOMEM; 420 res = -PSICONV_E_NOMEM;
667 goto ERROR2; 421 goto ERROR2;
1077 return res; 831 return res;
1078} 832}
1079 833
1080 834
1081int psiconv_write_sketch_section(const psiconv_config config, 835int psiconv_write_sketch_section(const psiconv_config config,
1082 psiconv_buffer buf, 836 psiconv_buffer buf, int lev,
1083 const psiconv_sketch_section value) 837 const psiconv_sketch_section value)
1084{ 838{
1085 int res; 839 int res;
1086 840
841 psiconv_progress(config,lev,0,"Writing sketch section");
1087 if (!value) { 842 if (!value) {
1088 psiconv_warn(config,0,0,"NULL sketch section"); 843 psiconv_error(config,0,0,"NULL sketch section");
1089 res = -PSICONV_E_GENERATE; 844 res = -PSICONV_E_GENERATE;
1090 goto ERROR1; 845 goto ERROR1;
1091 } 846 }
1092 847
1093 if ((res = psiconv_write_u16(config,buf,value->displayed_xsize))) 848 if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_xsize)))
1094 goto ERROR1; 849 goto ERROR1;
1095 if ((res = psiconv_write_u16(config,buf,value->displayed_ysize))) 850 if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_ysize)))
1096 goto ERROR1; 851 goto ERROR1;
1097 if ((res = psiconv_write_u16(config,buf,value->picture_data_x_offset))) 852 if ((res = psiconv_write_u16(config,buf,lev+1,value->picture_data_x_offset)))
1098 goto ERROR1; 853 goto ERROR1;
1099 if ((res = psiconv_write_u16(config,buf,value->picture_data_y_offset))) 854 if ((res = psiconv_write_u16(config,buf,lev+1,value->picture_data_y_offset)))
1100 goto ERROR1; 855 goto ERROR1;
1101 if ((res = psiconv_write_u16(config,buf,value->displayed_size_x_offset))) 856 if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_size_x_offset)))
1102 goto ERROR1; 857 goto ERROR1;
1103 if ((res = psiconv_write_u16(config,buf,value->displayed_size_y_offset))) 858 if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_size_y_offset)))
1104 goto ERROR1; 859 goto ERROR1;
1105 if ((res = psiconv_write_u16(config,buf,value->form_xsize))) 860 if ((res = psiconv_write_u16(config,buf,lev+1,value->form_xsize)))
1106 goto ERROR1; 861 goto ERROR1;
1107 if ((res = psiconv_write_u16(config,buf,value->form_ysize))) 862 if ((res = psiconv_write_u16(config,buf,lev+1,value->form_ysize)))
1108 goto ERROR1; 863 goto ERROR1;
1109 if ((res = psiconv_write_u16(config,buf,0x0000))) 864 if ((res = psiconv_write_u16(config,buf,lev+1,0x0000)))
1110 goto ERROR1; 865 goto ERROR1;
1111 if ((res = psiconv_write_paint_data_section(config,buf,value->picture,0))) 866 if ((res = psiconv_write_paint_data_section(config,buf,lev+1,value->picture,0)))
1112 goto ERROR1; 867 goto ERROR1;
1113 if ((res = psiconv_write_u16(config,buf,value->magnification_x * 0x03e8))) 868 if ((res = psiconv_write_u16(config,buf,lev+1,value->magnification_x * 0x03e8)))
1114 goto ERROR1; 869 goto ERROR1;
1115 if ((res = psiconv_write_u16(config,buf,value->magnification_y * 0x03e8))) 870 if ((res = psiconv_write_u16(config,buf,lev+1,value->magnification_y * 0x03e8)))
1116 goto ERROR1; 871 goto ERROR1;
1117 if ((res = psiconv_write_u32(config,buf,value->cut_left * 0x0c * 872 if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_left * 0x0c *
1118 value->displayed_xsize))) 873 value->displayed_xsize)))
1119 goto ERROR1; 874 goto ERROR1;
1120 if ((res = psiconv_write_u32(config,buf,value->cut_right * 0x0c * 875 if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_right * 0x0c *
1121 value->displayed_xsize))) 876 value->displayed_xsize)))
1122 goto ERROR1; 877 goto ERROR1;
1123 if ((res = psiconv_write_u32(config,buf,value->cut_top * 0x0c * 878 if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_top * 0x0c *
1124 value->displayed_ysize))) 879 value->displayed_ysize)))
1125 goto ERROR1; 880 goto ERROR1;
1126 if ((res = psiconv_write_u32(config,buf,value->cut_bottom * 0x0c * 881 if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_bottom * 0x0c *
1127 value->displayed_ysize))) 882 value->displayed_ysize)))
1128 goto ERROR1; 883 goto ERROR1;
1129 884
1130ERROR1: 885ERROR1:
1131 return res; 886 return res;
1132} 887}
1133 888
1134int psiconv_write_clipart_section(const psiconv_config config, 889int psiconv_write_clipart_section(const psiconv_config config,
1135 psiconv_buffer buf, 890 psiconv_buffer buf, int lev,
1136 const psiconv_clipart_section value) 891 const psiconv_clipart_section value)
1137{ 892{
1138 int res; 893 int res;
1139 894
1140 895 psiconv_progress(config,lev,0,"Writing clipart section");
1141 if (!value) { 896 if (!value) {
1142 psiconv_warn(config,0,psiconv_buffer_length(buf), 897 psiconv_error(config,0,psiconv_buffer_length(buf),
1143 "NULL Clipart Section"); 898 "NULL Clipart Section");
1144 res = -PSICONV_E_GENERATE; 899 res = -PSICONV_E_GENERATE;
1145 goto ERROR; 900 goto ERROR;
1146 } 901 }
1147 if ((res = psiconv_write_u32(config,buf,PSICONV_ID_CLIPART_ITEM))) 902 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_CLIPART_ITEM)))
1148 goto ERROR; 903 goto ERROR;
1149 if ((res = psiconv_write_u32(config,buf,0x00000002))) 904 if ((res = psiconv_write_u32(config,buf,lev+1,0x00000002)))
1150 goto ERROR; 905 goto ERROR;
1151 if ((res = psiconv_write_u32(config,buf,0x00000000))) 906 if ((res = psiconv_write_u32(config,buf,lev+1,0x00000000)))
1152 goto ERROR; 907 goto ERROR;
1153 if ((res = psiconv_write_u32(config,buf,0x00000000))) 908 if ((res = psiconv_write_u32(config,buf,lev+1,0x00000000)))
1154 goto ERROR; 909 goto ERROR;
1155 if ((res = psiconv_write_u32(config,buf,0x0000000C))) 910 if ((res = psiconv_write_u32(config,buf,lev+1,0x0000000C)))
1156 goto ERROR; 911 goto ERROR;
1157 if ((res = psiconv_write_paint_data_section(config,buf,value->picture,1))) 912 if ((res = psiconv_write_paint_data_section(config,buf,lev+1,value->picture,1)))
1158 goto ERROR; 913 goto ERROR;
1159 914
1160ERROR: 915ERROR:
1161 return res; 916 return res;
1162} 917}
1163 918
1164int psiconv_write_jumptable_section(const psiconv_config config, 919int psiconv_write_jumptable_section(const psiconv_config config,
1165 psiconv_buffer buf, 920 psiconv_buffer buf, int lev,
1166 const psiconv_jumptable_section value) 921 const psiconv_jumptable_section value)
1167{ 922{
1168 int res,i; 923 int res,i;
1169 psiconv_u32 *offset_ptr; 924 psiconv_u32 *offset_ptr;
1170 925
926 psiconv_progress(config,lev,0,"Writing jumptable section");
1171 927
1172 if (!value) { 928 if (!value) {
1173 psiconv_warn(config,0,psiconv_buffer_length(buf), 929 psiconv_error(config,0,psiconv_buffer_length(buf),
1174 "NULL Jumptable Section"); 930 "NULL Jumptable Section");
1175 res = -PSICONV_E_GENERATE; 931 res = -PSICONV_E_GENERATE;
1176 goto ERROR; 932 goto ERROR;
1177 } 933 }
1178 if ((res = psiconv_write_u32(config,buf,psiconv_list_length(value)))) 934 if ((res = psiconv_write_u32(config,buf,lev+1,psiconv_list_length(value))))
1179 goto ERROR; 935 goto ERROR;
1180 for (i = 0; i < psiconv_list_length(value); i++) { 936 for (i = 0; i < psiconv_list_length(value); i++) {
1181 if (!(offset_ptr = psiconv_list_get(value,i))) { 937 if (!(offset_ptr = psiconv_list_get(value,i))) {
1182 psiconv_warn(config,0,psiconv_buffer_length(buf), 938 psiconv_error(config,0,psiconv_buffer_length(buf),
1183 "Massive memory corruption"); 939 "Massive memory corruption");
1184 res = -PSICONV_E_NOMEM; 940 res = -PSICONV_E_NOMEM;
1185 goto ERROR; 941 goto ERROR;
1186 } 942 }
1187 if ((res = psiconv_write_offset(config,buf,*offset_ptr))) 943 if ((res = psiconv_write_offset(config,buf,lev+1,*offset_ptr)))
1188 goto ERROR; 944 goto ERROR;
1189 } 945 }
1190 946
1191ERROR: 947ERROR:
1192 return res; 948 return res;

Legend:
Removed from v.176  
changed lines
  Added in v.184

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26