OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_SRC_FXCODEC_LGIF_FX_GIF_H_ | 7 #ifndef CORE_SRC_FXCODEC_LGIF_FX_GIF_H_ |
8 #define CORE_SRC_FXCODEC_LGIF_FX_GIF_H_ | 8 #define CORE_SRC_FXCODEC_LGIF_FX_GIF_H_ |
9 | 9 |
10 #include <setjmp.h> | 10 #include <setjmp.h> |
11 | 11 |
12 #include "core/include/fxcrt/fx_basic.h" | 12 #include "core/include/fxcrt/fx_basic.h" |
13 | 13 |
14 extern FX_WORD _GetWord_LSBFirst(uint8_t* p); | |
15 extern void _SetWord_LSBFirst(uint8_t* p, FX_WORD v); | |
16 extern void _BpcConvert(const uint8_t* src_buf, | |
17 FX_DWORD src_len, | |
18 int32_t src_bpc, | |
19 int32_t dst_bpc, | |
20 uint8_t*& dst_buf, | |
21 FX_DWORD& dst_len); | |
22 #define GIF_SUPPORT_COMMENT_EXTENSION | 14 #define GIF_SUPPORT_COMMENT_EXTENSION |
23 #define GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 15 #define GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION |
24 #define GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 16 #define GIF_SUPPORT_PLAIN_TEXT_EXTENSION |
25 #define GIF_SIGNATURE "GIF" | 17 #define GIF_SIGNATURE "GIF" |
26 #define GIF_SIG_EXTENSION 0x21 | 18 #define GIF_SIG_EXTENSION 0x21 |
27 #define GIF_SIG_IMAGE 0x2C | 19 #define GIF_SIG_IMAGE 0x2C |
28 #define GIF_SIG_TRAILER 0x3B | 20 #define GIF_SIG_TRAILER 0x3B |
29 #define GIF_BLOCK_GCE 0xF9 | 21 #define GIF_BLOCK_GCE 0xF9 |
30 #define GIF_BLOCK_PTE 0x01 | 22 #define GIF_BLOCK_PTE 0x01 |
31 #define GIF_BLOCK_CE 0xFE | 23 #define GIF_BLOCK_CE 0xFE |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 uint8_t bit_offset; | 193 uint8_t bit_offset; |
202 uint8_t index_bit_cur; | 194 uint8_t index_bit_cur; |
203 uint8_t index_buf[GIF_DATA_BLOCK]; | 195 uint8_t index_buf[GIF_DATA_BLOCK]; |
204 uint8_t index_buf_len; | 196 uint8_t index_buf_len; |
205 tag_Table code_table[GIF_MAX_LZW_CODE]; | 197 tag_Table code_table[GIF_MAX_LZW_CODE]; |
206 FX_WORD table_cur; | 198 FX_WORD table_cur; |
207 }; | 199 }; |
208 typedef struct tag_gif_decompress_struct gif_decompress_struct; | 200 typedef struct tag_gif_decompress_struct gif_decompress_struct; |
209 typedef gif_decompress_struct* gif_decompress_struct_p; | 201 typedef gif_decompress_struct* gif_decompress_struct_p; |
210 typedef gif_decompress_struct_p* gif_decompress_struct_pp; | 202 typedef gif_decompress_struct_p* gif_decompress_struct_pp; |
211 static int32_t s_gif_interlace_step[4] = {8, 8, 4, 2}; | 203 static const int32_t s_gif_interlace_step[4] = {8, 8, 4, 2}; |
212 struct tag_gif_decompress_struct { | 204 struct tag_gif_decompress_struct { |
213 jmp_buf jmpbuf; | 205 jmp_buf jmpbuf; |
214 FX_CHAR* err_ptr; | 206 FX_CHAR* err_ptr; |
215 void (*_gif_error_fn)(gif_decompress_struct_p gif_ptr, | 207 void (*_gif_error_fn)(gif_decompress_struct_p gif_ptr, |
Tom Sepez
2016/02/25 19:00:39
no leading _ ?
Lei Zhang
2016/02/25 20:38:37
Done.
| |
216 const FX_CHAR* err_msg); | 208 const FX_CHAR* err_msg); |
217 void* context_ptr; | 209 void* context_ptr; |
218 int width; | 210 int width; |
219 int height; | 211 int height; |
220 GifPalette* global_pal_ptr; | 212 GifPalette* global_pal_ptr; |
221 int32_t global_pal_num; | 213 int32_t global_pal_num; |
222 uint8_t global_sort_flag; | 214 uint8_t global_sort_flag; |
223 uint8_t global_color_resolution; | 215 uint8_t global_color_resolution; |
224 | 216 |
225 uint8_t bc_index; | 217 uint8_t bc_index; |
226 uint8_t pixel_aspect; | 218 uint8_t pixel_aspect; |
227 CGifLZWDecoder* img_decoder_ptr; | 219 CGifLZWDecoder* img_decoder_ptr; |
228 FX_DWORD img_row_offset; | 220 FX_DWORD img_row_offset; |
229 FX_DWORD img_row_avail_size; | 221 FX_DWORD img_row_avail_size; |
230 uint8_t img_pass_num; | 222 uint8_t img_pass_num; |
231 CFX_ArrayTemplate<GifImage*>* img_ptr_arr_ptr; | 223 CFX_ArrayTemplate<GifImage*>* img_ptr_arr_ptr; |
232 uint8_t* (*_gif_ask_buf_for_pal_fn)(gif_decompress_struct_p gif_ptr, | 224 uint8_t* (*_gif_ask_buf_for_pal_fn)(gif_decompress_struct_p gif_ptr, |
Tom Sepez
2016/02/25 19:00:39
here, too, and below?
Lei Zhang
2016/02/25 20:38:37
Done.
| |
233 int32_t pal_size); | 225 int32_t pal_size); |
234 uint8_t* next_in; | 226 uint8_t* next_in; |
235 FX_DWORD avail_in; | 227 FX_DWORD avail_in; |
236 int32_t decode_status; | 228 int32_t decode_status; |
237 FX_DWORD skip_size; | 229 FX_DWORD skip_size; |
238 void (*_gif_record_current_position_fn)(gif_decompress_struct_p gif_ptr, | 230 void (*_gif_record_current_position_fn)(gif_decompress_struct_p gif_ptr, |
239 FX_DWORD* cur_pos_ptr); | 231 FX_DWORD* cur_pos_ptr); |
240 void (*_gif_get_row_fn)(gif_decompress_struct_p gif_ptr, | 232 void (*_gif_get_row_fn)(gif_decompress_struct_p gif_ptr, |
241 int32_t row_num, | 233 int32_t row_num, |
242 uint8_t* row_buf); | 234 uint8_t* row_buf); |
243 FX_BOOL (*_gif_get_record_position_fn)(gif_decompress_struct_p gif_ptr, | 235 FX_BOOL (*_gif_get_record_position_fn)(gif_decompress_struct_p gif_ptr, |
244 FX_DWORD cur_pos, | 236 FX_DWORD cur_pos, |
245 int32_t left, int32_t top, int32_t width, int32_t height, | 237 int32_t left, int32_t top, int32_t width, int32_t height, |
246 int32_t pal_num, void* pal_ptr, | 238 int32_t pal_num, void* pal_ptr, |
247 int32_t delay_time, FX_BOOL user_input, | 239 int32_t delay_time, FX_BOOL user_input, |
248 int32_t trans_index, int32_t disposal_method, FX_BOOL interlace); | 240 int32_t trans_index, int32_t disposal_method, FX_BOOL interlace); |
249 #ifdef GIF_SUPPORT_APPLICATION_EXTENSION | 241 #ifdef GIF_SUPPORT_APPLICATION_EXTENSION |
Tom Sepez
2016/02/25 19:00:39
never true?
Lei Zhang
2016/02/25 20:38:37
Done.
| |
250 uint8_t app_identify[8]; | 242 uint8_t app_identify[8]; |
251 uint8_t app_authentication[3]; | 243 uint8_t app_authentication[3]; |
252 FX_DWORD app_data_size; | 244 FX_DWORD app_data_size; |
253 uint8_t* app_data; | 245 uint8_t* app_data; |
254 #endif | 246 #endif |
255 #ifdef GIF_SUPPORT_COMMENT_EXTENSION | 247 #ifdef GIF_SUPPORT_COMMENT_EXTENSION |
Tom Sepez
2016/02/25 19:00:39
always true?
Lei Zhang
2016/02/25 20:38:37
Done.
| |
256 CFX_ByteString* cmt_data_ptr; | 248 CFX_ByteString* cmt_data_ptr; |
257 #endif | 249 #endif |
258 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 250 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION |
Tom Sepez
2016/02/25 19:00:39
always true
Lei Zhang
2016/02/25 20:38:37
Done.
| |
259 GifGCE* gce_ptr; | 251 GifGCE* gce_ptr; |
260 #endif | 252 #endif |
261 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 253 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION |
Tom Sepez
2016/02/25 19:00:39
always true
Lei Zhang
2016/02/25 20:38:37
Done.
| |
262 CFX_ArrayTemplate<GifPlainText*>* pt_ptr_arr_ptr; | 254 CFX_ArrayTemplate<GifPlainText*>* pt_ptr_arr_ptr; |
263 #endif | 255 #endif |
264 }; | 256 }; |
265 typedef struct tag_gif_compress_struct gif_compress_struct; | 257 typedef struct tag_gif_compress_struct gif_compress_struct; |
266 typedef gif_compress_struct* gif_compress_struct_p; | 258 typedef gif_compress_struct* gif_compress_struct_p; |
267 typedef gif_compress_struct_p* gif_compress_struct_pp; | 259 typedef gif_compress_struct_p* gif_compress_struct_pp; |
268 struct tag_gif_compress_struct { | 260 struct tag_gif_compress_struct { |
269 const uint8_t* src_buf; | 261 const uint8_t* src_buf; |
270 FX_DWORD src_pitch; | 262 FX_DWORD src_pitch; |
271 FX_DWORD src_width; | 263 FX_DWORD src_width; |
272 FX_DWORD src_row; | 264 FX_DWORD src_row; |
273 FX_DWORD cur_offset; | 265 FX_DWORD cur_offset; |
274 FX_DWORD frames; | 266 FX_DWORD frames; |
275 GifHeader* header_ptr; | 267 GifHeader* header_ptr; |
276 GifLSD* lsd_ptr; | 268 GifLSD* lsd_ptr; |
277 GifPalette* global_pal; | 269 GifPalette* global_pal; |
278 FX_WORD gpal_num; | 270 FX_WORD gpal_num; |
279 GifPalette* local_pal; | 271 GifPalette* local_pal; |
280 FX_WORD lpal_num; | 272 FX_WORD lpal_num; |
281 GifImageInfo* image_info_ptr; | 273 GifImageInfo* image_info_ptr; |
282 CGifLZWEncoder* img_encoder_ptr; | 274 CGifLZWEncoder* img_encoder_ptr; |
283 #ifdef GIF_SUPPORT_APPLICATION_EXTENSION | 275 #ifdef GIF_SUPPORT_APPLICATION_EXTENSION |
Tom Sepez
2016/02/25 19:00:39
same here.
Lei Zhang
2016/02/25 20:38:37
Done.
| |
284 uint8_t app_identify[8]; | 276 uint8_t app_identify[8]; |
285 uint8_t app_authentication[3]; | 277 uint8_t app_authentication[3]; |
286 FX_DWORD app_data_size; | 278 FX_DWORD app_data_size; |
287 uint8_t* app_data; | 279 uint8_t* app_data; |
288 #endif | 280 #endif |
289 | 281 |
290 #ifdef GIF_SUPPORT_COMMENT_EXTENSION | 282 #ifdef GIF_SUPPORT_COMMENT_EXTENSION |
291 uint8_t* cmt_data_ptr; | 283 uint8_t* cmt_data_ptr; |
292 FX_DWORD cmt_data_len; | 284 FX_DWORD cmt_data_len; |
293 #endif | 285 #endif |
294 | 286 |
295 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 287 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION |
296 GifGCE* gce_ptr; | 288 GifGCE* gce_ptr; |
297 #endif | 289 #endif |
298 | 290 |
299 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 291 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION |
300 GifPTE* pte_ptr; | 292 GifPTE* pte_ptr; |
301 const uint8_t* pte_data_ptr; | 293 const uint8_t* pte_data_ptr; |
302 FX_DWORD pte_data_len; | 294 FX_DWORD pte_data_len; |
303 #endif | 295 #endif |
304 }; | 296 }; |
305 | 297 |
306 void _gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg); | 298 void gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg); |
307 void _gif_warn(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg); | 299 void gif_warn(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg); |
308 gif_decompress_struct_p _gif_create_decompress(); | 300 gif_decompress_struct_p gif_create_decompress(); |
309 void _gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr); | 301 void gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr); |
310 gif_compress_struct_p _gif_create_compress(); | 302 gif_compress_struct_p gif_create_compress(); |
311 void _gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr); | 303 void gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr); |
312 int32_t _gif_read_header(gif_decompress_struct_p gif_ptr); | 304 int32_t gif_read_header(gif_decompress_struct_p gif_ptr); |
313 int32_t _gif_get_frame(gif_decompress_struct_p gif_ptr); | 305 int32_t gif_get_frame(gif_decompress_struct_p gif_ptr); |
314 int32_t _gif_get_frame_num(gif_decompress_struct_p gif_ptr); | 306 int32_t gif_get_frame_num(gif_decompress_struct_p gif_ptr); |
315 int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr); | 307 int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr); |
316 int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr); | 308 int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr); |
317 void _gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr, | 309 void gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr, |
318 GifGCE** gce_ptr_ptr); | 310 GifGCE** gce_ptr_ptr); |
319 int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num); | 311 int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num); |
320 uint8_t* _gif_read_data(gif_decompress_struct_p gif_ptr, | 312 uint8_t* gif_read_data(gif_decompress_struct_p gif_ptr, |
321 uint8_t** des_buf_pp, | 313 uint8_t** des_buf_pp, |
322 FX_DWORD data_size); | 314 FX_DWORD data_size); |
323 void _gif_save_decoding_status(gif_decompress_struct_p gif_ptr, int32_t status); | 315 void gif_save_decoding_status(gif_decompress_struct_p gif_ptr, int32_t status); |
324 void _gif_input_buffer(gif_decompress_struct_p gif_ptr, | 316 void gif_input_buffer(gif_decompress_struct_p gif_ptr, |
325 uint8_t* src_buf, | 317 uint8_t* src_buf, |
326 FX_DWORD src_size); | 318 FX_DWORD src_size); |
327 FX_DWORD _gif_get_avail_input(gif_decompress_struct_p gif_ptr, | 319 FX_DWORD gif_get_avail_input(gif_decompress_struct_p gif_ptr, |
328 uint8_t** avial_buf_ptr); | 320 uint8_t** avial_buf_ptr); |
329 void interlace_buf(const uint8_t* buf, FX_DWORD width, FX_DWORD height); | 321 void interlace_buf(const uint8_t* buf, FX_DWORD width, FX_DWORD height); |
330 FX_BOOL _gif_encode(gif_compress_struct_p gif_ptr, | 322 FX_BOOL gif_encode(gif_compress_struct_p gif_ptr, |
331 uint8_t*& dst_buf, | 323 uint8_t*& dst_buf, |
332 FX_DWORD& dst_len); | 324 FX_DWORD& dst_len); |
333 | 325 |
334 #endif // CORE_SRC_FXCODEC_LGIF_FX_GIF_H_ | 326 #endif // CORE_SRC_FXCODEC_LGIF_FX_GIF_H_ |
OLD | NEW |