Mercurial > mplayer.hg
annotate fli.c @ 4691:9c23a7497a6d
Scratch for volunteers
author | nick |
---|---|
date | Wed, 13 Feb 2002 08:59:23 +0000 |
parents | 68582b4ce881 |
children | f78d2b53aa48 |
rev | line source |
---|---|
3155 | 1 /* |
2 FLI Decoder for MPlayer | |
3 | |
4 (C) 2001 Mike Melanson | |
3185 | 5 |
6 32bpp support (c) alex | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
7 |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
8 Additional code and bug fixes by Roberto Togni |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
9 |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
10 For information on the FLI format, as well as various traps to |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
11 avoid while programming one, visit: |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
12 http://www.pcisys.net/~melanson/codecs/ |
3155 | 13 */ |
14 | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
15 #include <stdio.h> |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
16 #include <stdlib.h> |
3509
21c7b77b3e83
fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in
melanson
parents:
3185
diff
changeset
|
17 #include "config.h" |
21c7b77b3e83
fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in
melanson
parents:
3185
diff
changeset
|
18 #include "bswap.h" |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
19 #include "mp_msg.h" |
3509
21c7b77b3e83
fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in
melanson
parents:
3185
diff
changeset
|
20 |
21c7b77b3e83
fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in
melanson
parents:
3185
diff
changeset
|
21 #define LE_16(x) (le2me_16(*(unsigned short *)(x))) |
21c7b77b3e83
fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in
melanson
parents:
3185
diff
changeset
|
22 #define LE_32(x) (le2me_32(*(unsigned int *)(x))) |
3155 | 23 |
24 #define FLI_256_COLOR 4 | |
25 #define FLI_DELTA 7 | |
26 #define FLI_COLOR 11 | |
27 #define FLI_LC 12 | |
28 #define FLI_BLACK 13 | |
29 #define FLI_BRUN 15 | |
30 #define FLI_COPY 16 | |
31 #define FLI_MINI 18 | |
32 | |
33 // 256 RGB entries; 25% of these bytes will be unused, but it's faster | |
34 // to index 4-byte entries | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
35 #define PALETTE_SIZE 1024 |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
36 static unsigned char palette[PALETTE_SIZE]; |
3155 | 37 |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
38 void *init_fli_decoder(int width, int height) |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
39 { |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
40 memset(palette, 0, PALETTE_SIZE); |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
41 |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
42 return malloc(width * height * sizeof (unsigned int)); |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
43 } |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
44 |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
45 void decode_fli_frame( |
3155 | 46 unsigned char *encoded, |
47 int encoded_size, | |
48 unsigned char *decoded, | |
49 int width, | |
50 int height, | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
51 int bytes_per_pixel, |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
52 void *context) |
3155 | 53 { |
54 int stream_ptr = 0; | |
55 int pixel_ptr; | |
56 int palette_ptr1; | |
57 int palette_ptr2; | |
58 | |
59 unsigned int frame_size; | |
60 int num_chunks; | |
61 | |
62 unsigned int chunk_size; | |
63 int chunk_type; | |
64 | |
65 int i, j; | |
66 | |
67 int color_packets; | |
68 int color_changes; | |
69 int color_scale; | |
70 | |
71 int lines; | |
72 int compressed_lines; | |
73 int starting_line; | |
74 signed short line_packets; | |
75 int y_ptr; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
76 int line_inc = width * bytes_per_pixel; |
3155 | 77 signed char byte_run; |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
78 int pixel_skip; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
79 int update_whole_frame = 0; // Palette change flag |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
80 unsigned int *fli_ghost_image = (unsigned int *)context; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
81 int ghost_pixel_ptr; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
82 int ghost_y_ptr; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
83 |
3155 | 84 frame_size = LE_32(&encoded[stream_ptr]); |
85 stream_ptr += 6; // skip the magic number | |
86 num_chunks = LE_16(&encoded[stream_ptr]); | |
87 stream_ptr += 10; // skip padding | |
88 | |
89 // iterate through the chunks | |
90 frame_size -= 16; | |
91 while ((frame_size > 0) && (num_chunks > 0)) | |
92 { | |
93 chunk_size = LE_32(&encoded[stream_ptr]); | |
94 stream_ptr += 4; | |
95 chunk_type = LE_16(&encoded[stream_ptr]); | |
96 stream_ptr += 2; | |
97 | |
98 switch (chunk_type) | |
99 { | |
100 case FLI_256_COLOR: | |
101 case FLI_COLOR: | |
102 if (chunk_type == FLI_COLOR) | |
103 color_scale = 4; | |
104 else | |
105 color_scale = 1; | |
106 // set up the palette | |
107 color_packets = LE_16(&encoded[stream_ptr]); | |
108 stream_ptr += 2; | |
109 palette_ptr1 = 0; | |
110 for (i = 0; i < color_packets; i++) | |
111 { | |
112 // first byte is how many colors to skip | |
113 palette_ptr1 += (encoded[stream_ptr++] * 4); | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
114 // wrap around, for good measure |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
115 if (palette_ptr1 >= PALETTE_SIZE) |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
116 palette_ptr1 = 0; |
3155 | 117 // next byte indicates how many entries to change |
118 color_changes = encoded[stream_ptr++]; | |
119 // if there are 0 color changes, there are actually 256 | |
120 if (color_changes == 0) | |
121 color_changes = 256; | |
122 for (j = 0; j < color_changes; j++) | |
123 { | |
124 palette[palette_ptr1++] = encoded[stream_ptr + 2] * color_scale; | |
125 palette[palette_ptr1++] = encoded[stream_ptr + 1] * color_scale; | |
126 palette[palette_ptr1++] = encoded[stream_ptr + 0] * color_scale; | |
127 palette_ptr1++; | |
128 stream_ptr += 3; | |
129 } | |
130 } | |
3509
21c7b77b3e83
fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in
melanson
parents:
3185
diff
changeset
|
131 // it seems that a color packet has to be an even number of bytes |
21c7b77b3e83
fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in
melanson
parents:
3185
diff
changeset
|
132 // so account for a pad byte |
21c7b77b3e83
fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in
melanson
parents:
3185
diff
changeset
|
133 if (stream_ptr & 0x01) |
21c7b77b3e83
fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in
melanson
parents:
3185
diff
changeset
|
134 stream_ptr++; |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
135 /* Palette has changed, must update frame */ |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
136 update_whole_frame = 1; |
3155 | 137 break; |
138 | |
139 case FLI_DELTA: | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
140 y_ptr = ghost_y_ptr = 0; |
3155 | 141 compressed_lines = LE_16(&encoded[stream_ptr]); |
142 stream_ptr += 2; | |
143 while (compressed_lines > 0) | |
144 { | |
145 line_packets = LE_16(&encoded[stream_ptr]); | |
146 stream_ptr += 2; | |
147 if (line_packets < 0) | |
148 { | |
149 line_packets = -line_packets; | |
150 y_ptr += (line_packets * line_inc); | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
151 ghost_y_ptr += (line_packets * width); |
3155 | 152 } |
153 else | |
154 { | |
155 pixel_ptr = y_ptr; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
156 ghost_pixel_ptr = ghost_y_ptr; |
3155 | 157 for (i = 0; i < line_packets; i++) |
158 { | |
159 // account for the skip bytes | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
160 pixel_skip = encoded[stream_ptr++]; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
161 pixel_ptr += pixel_skip * bytes_per_pixel; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
162 ghost_pixel_ptr += pixel_skip; |
3155 | 163 byte_run = encoded[stream_ptr++]; |
164 if (byte_run < 0) | |
165 { | |
166 byte_run = -byte_run; | |
167 palette_ptr1 = encoded[stream_ptr++] * 4; | |
168 palette_ptr2 = encoded[stream_ptr++] * 4; | |
169 for (j = 0; j < byte_run; j++) | |
170 { | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
171 fli_ghost_image[ghost_pixel_ptr++] = palette_ptr1; |
3155 | 172 decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; |
173 decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; | |
174 decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; | |
3185 | 175 if (bytes_per_pixel == 4) /* 32bpp */ |
176 pixel_ptr++; | |
3155 | 177 |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
178 fli_ghost_image[ghost_pixel_ptr++] = palette_ptr2; |
3155 | 179 decoded[pixel_ptr++] = palette[palette_ptr2 + 0]; |
180 decoded[pixel_ptr++] = palette[palette_ptr2 + 1]; | |
181 decoded[pixel_ptr++] = palette[palette_ptr2 + 2]; | |
3185 | 182 if (bytes_per_pixel == 4) /* 32bpp */ |
183 pixel_ptr++; | |
3155 | 184 } |
185 } | |
186 else | |
187 { | |
188 for (j = 0; j < byte_run * 2; j++) | |
189 { | |
190 palette_ptr1 = encoded[stream_ptr++] * 4; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
191 fli_ghost_image[ghost_pixel_ptr++] = palette_ptr1; |
3155 | 192 decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; |
193 decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; | |
194 decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; | |
3185 | 195 if (bytes_per_pixel == 4) /* 32bpp */ |
196 pixel_ptr++; | |
3155 | 197 } |
198 } | |
199 } | |
200 y_ptr += line_inc; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
201 ghost_y_ptr += width; |
3155 | 202 compressed_lines--; |
203 } | |
204 } | |
205 break; | |
206 | |
207 case FLI_LC: | |
208 // line compressed | |
209 starting_line = LE_16(&encoded[stream_ptr]); | |
210 stream_ptr += 2; | |
211 y_ptr = starting_line * line_inc; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
212 ghost_y_ptr = starting_line * width; |
3155 | 213 |
214 compressed_lines = LE_16(&encoded[stream_ptr]); | |
215 stream_ptr += 2; | |
216 while (compressed_lines > 0) | |
217 { | |
218 pixel_ptr = y_ptr; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
219 ghost_pixel_ptr = ghost_y_ptr; |
3155 | 220 line_packets = encoded[stream_ptr++]; |
221 if (line_packets > 0) | |
222 { | |
223 for (i = 0; i < line_packets; i++) | |
224 { | |
225 // account for the skip bytes | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
226 pixel_skip = encoded[stream_ptr++]; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
227 pixel_ptr += pixel_skip * bytes_per_pixel; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
228 ghost_pixel_ptr += pixel_skip; |
3155 | 229 byte_run = encoded[stream_ptr++]; |
230 if (byte_run > 0) | |
231 { | |
232 for (j = 0; j < byte_run; j++) | |
233 { | |
234 palette_ptr1 = encoded[stream_ptr++] * 4; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
235 fli_ghost_image[ghost_pixel_ptr++] = palette_ptr1; |
3155 | 236 decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; |
237 decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; | |
238 decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; | |
3185 | 239 if (bytes_per_pixel == 4) /* 32bpp */ |
240 pixel_ptr++; | |
3155 | 241 } |
242 } | |
243 else | |
244 { | |
245 byte_run = -byte_run; | |
246 palette_ptr1 = encoded[stream_ptr++] * 4; | |
247 for (j = 0; j < byte_run; j++) | |
248 { | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
249 fli_ghost_image[ghost_pixel_ptr++] = palette_ptr1; |
3155 | 250 decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; |
251 decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; | |
252 decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; | |
3185 | 253 if (bytes_per_pixel == 4) /* 32bpp */ |
254 pixel_ptr++; | |
3155 | 255 } |
256 } | |
257 } | |
258 } | |
259 | |
260 y_ptr += line_inc; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
261 ghost_y_ptr += width; |
3155 | 262 compressed_lines--; |
263 } | |
264 break; | |
265 | |
266 case FLI_BLACK: | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
267 // set the whole frame to color 0 (which is usually black) by |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
268 // clearing the ghost image and trigger a full frame update |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
269 memset(fli_ghost_image, 0, width * height * sizeof(unsigned int)); |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
270 update_whole_frame = 1; |
3155 | 271 break; |
272 | |
273 case FLI_BRUN: | |
274 // byte run compression | |
275 y_ptr = 0; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
276 ghost_y_ptr = 0; |
3155 | 277 for (lines = 0; lines < height; lines++) |
278 { | |
279 pixel_ptr = y_ptr; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
280 ghost_pixel_ptr = ghost_y_ptr; |
3155 | 281 line_packets = encoded[stream_ptr++]; |
282 for (i = 0; i < line_packets; i++) | |
283 { | |
284 byte_run = encoded[stream_ptr++]; | |
285 if (byte_run > 0) | |
286 { | |
287 palette_ptr1 = encoded[stream_ptr++] * 4; | |
288 for (j = 0; j < byte_run; j++) | |
289 { | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
290 fli_ghost_image[ghost_pixel_ptr++] = palette_ptr1; |
3155 | 291 decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; |
292 decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; | |
293 decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; | |
3185 | 294 if (bytes_per_pixel == 4) /* 32bpp */ |
295 pixel_ptr++; | |
3155 | 296 } |
297 } | |
298 else // copy bytes if byte_run < 0 | |
299 { | |
300 byte_run = -byte_run; | |
301 for (j = 0; j < byte_run; j++) | |
302 { | |
303 palette_ptr1 = encoded[stream_ptr++] * 4; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
304 fli_ghost_image[ghost_pixel_ptr++] = palette_ptr1; |
3155 | 305 decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; |
306 decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; | |
307 decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; | |
3185 | 308 if (bytes_per_pixel == 4) /* 32bpp */ |
309 pixel_ptr++; | |
3155 | 310 } |
311 } | |
312 } | |
313 | |
314 y_ptr += line_inc; | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
315 ghost_y_ptr += width; |
3155 | 316 } |
317 break; | |
318 | |
319 case FLI_COPY: | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
320 // copy the chunk (uncompressed frame) to the ghost image and |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
321 // schedule the whole frame to be updated |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
322 memcpy(fli_ghost_image, &encoded[stream_ptr], chunk_size - 6); |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
323 stream_ptr += chunk_size - 6; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
324 update_whole_frame = 1; |
3155 | 325 break; |
326 | |
327 case FLI_MINI: | |
328 // sort of a thumbnail? disregard this chunk... | |
329 stream_ptr += chunk_size - 6; | |
330 break; | |
331 | |
332 default: | |
333 printf ("FLI: Unrecognized chunk type: %d\n", chunk_type); | |
334 break; | |
335 } | |
336 | |
337 frame_size -= chunk_size; | |
338 num_chunks--; | |
339 } | |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
340 |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
341 if (update_whole_frame) |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
342 { |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
343 pixel_ptr = 0; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
344 while (pixel_ptr < (width * height * bytes_per_pixel)) |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
345 { |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
346 palette_ptr1 = fli_ghost_image[pixel_ptr/bytes_per_pixel]; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
347 decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
348 decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
349 decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
350 if (bytes_per_pixel == 4) /* 32bpp */ |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
351 pixel_ptr++; |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
352 } |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
353 } |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
354 |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
355 // by the end of the chunk, the stream ptr should equal the frame |
4688 | 356 // size (minus 1, possibly); if it doesn't, issue a warning |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
357 if ((stream_ptr != encoded_size) && (stream_ptr != encoded_size - 1)) |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
358 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
359 " warning: processed FLI chunk where encoded size = %d\n" \ |
4688 | 360 " and final chunk ptr = %d\n", |
4687
2973e997c4a5
some obscure bug fixes to the FLI decoder, with many thanks to Roberto
melanson
parents:
3737
diff
changeset
|
361 encoded_size, stream_ptr); |
3155 | 362 } |