| 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 #include "core/src/fxcodec/lgif/fx_gif.h" | 7 #include "core/src/fxcodec/lgif/fx_gif.h" | 
| 8 void CGifLZWDecoder::Input(uint8_t* src_buf, FX_DWORD src_size) { | 8 void CGifLZWDecoder::Input(uint8_t* src_buf, FX_DWORD src_size) { | 
| 9   next_in = src_buf; | 9   next_in = src_buf; | 
| 10   avail_in = src_size; | 10   avail_in = src_size; | 
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 369   gif_ptr->pt_ptr_arr_ptr = new CFX_ArrayTemplate<GifPlainText*>; | 369   gif_ptr->pt_ptr_arr_ptr = new CFX_ArrayTemplate<GifPlainText*>; | 
| 370 #endif | 370 #endif | 
| 371   return gif_ptr; | 371   return gif_ptr; | 
| 372 } | 372 } | 
| 373 void _gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) { | 373 void _gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) { | 
| 374   if (gif_ptr_ptr == NULL || *gif_ptr_ptr == NULL) { | 374   if (gif_ptr_ptr == NULL || *gif_ptr_ptr == NULL) { | 
| 375     return; | 375     return; | 
| 376   } | 376   } | 
| 377   gif_decompress_struct_p gif_ptr = *gif_ptr_ptr; | 377   gif_decompress_struct_p gif_ptr = *gif_ptr_ptr; | 
| 378   *gif_ptr_ptr = NULL; | 378   *gif_ptr_ptr = NULL; | 
| 379   if (gif_ptr->global_pal_ptr != NULL) { | 379   FX_Free(gif_ptr->global_pal_ptr); | 
| 380     FX_Free(gif_ptr->global_pal_ptr); | 380   delete gif_ptr->img_decoder_ptr; | 
| 381   } | 381   if (gif_ptr->img_ptr_arr_ptr) { | 
| 382   if (gif_ptr->img_decoder_ptr != NULL) { |  | 
| 383     delete gif_ptr->img_decoder_ptr; |  | 
| 384   } |  | 
| 385   if (gif_ptr->img_ptr_arr_ptr != NULL) { |  | 
| 386     int32_t size_img_arr = gif_ptr->img_ptr_arr_ptr->GetSize(); | 382     int32_t size_img_arr = gif_ptr->img_ptr_arr_ptr->GetSize(); | 
| 387     for (int32_t i = 0; i < size_img_arr; i++) { | 383     for (int32_t i = 0; i < size_img_arr; i++) { | 
| 388       GifImage* p = gif_ptr->img_ptr_arr_ptr->GetAt(i); | 384       GifImage* p = gif_ptr->img_ptr_arr_ptr->GetAt(i); | 
| 389       if (p->image_info_ptr != NULL) { | 385       FX_Free(p->image_info_ptr); | 
| 390         FX_Free(p->image_info_ptr); | 386       FX_Free(p->image_gce_ptr); | 
| 391       } | 387       FX_Free(p->image_row_buf); | 
| 392       if (p->image_gce_ptr != NULL) { | 388       if (p->local_pal_ptr && p->local_pal_ptr != gif_ptr->global_pal_ptr) { | 
| 393         FX_Free(p->image_gce_ptr); |  | 
| 394       } |  | 
| 395       if (p->image_row_buf != NULL) { |  | 
| 396         FX_Free(p->image_row_buf); |  | 
| 397       } |  | 
| 398       if (p->local_pal_ptr != NULL && |  | 
| 399           p->local_pal_ptr != gif_ptr->global_pal_ptr) { |  | 
| 400         FX_Free(p->local_pal_ptr); | 389         FX_Free(p->local_pal_ptr); | 
| 401       } | 390       } | 
| 402       FX_Free(p); | 391       FX_Free(p); | 
| 403     } | 392     } | 
| 404     gif_ptr->img_ptr_arr_ptr->RemoveAll(); | 393     gif_ptr->img_ptr_arr_ptr->RemoveAll(); | 
| 405     delete gif_ptr->img_ptr_arr_ptr; | 394     delete gif_ptr->img_ptr_arr_ptr; | 
| 406   } | 395   } | 
| 407 #ifdef GIF_SUPPORT_APPLICATION_EXTENSION | 396 #ifdef GIF_SUPPORT_APPLICATION_EXTENSION | 
| 408   if (gif_ptr->app_data != NULL) { | 397   FX_Free(gif_ptr->app_data); | 
| 409     FX_Free(gif_ptr->app_data); |  | 
| 410   } |  | 
| 411 #endif | 398 #endif | 
| 412 #ifdef GIF_SUPPORT_COMMENT_EXTENSION | 399 #ifdef GIF_SUPPORT_COMMENT_EXTENSION | 
| 413   if (gif_ptr->cmt_data_ptr != NULL) { | 400   delete gif_ptr->cmt_data_ptr; | 
| 414     delete gif_ptr->cmt_data_ptr; |  | 
| 415   } |  | 
| 416 #endif | 401 #endif | 
| 417 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 402 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 
| 418   if (gif_ptr->gce_ptr != NULL) { | 403   FX_Free(gif_ptr->gce_ptr); | 
| 419     FX_Free(gif_ptr->gce_ptr); |  | 
| 420   } |  | 
| 421 #endif | 404 #endif | 
| 422 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 405 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 
| 423   if (gif_ptr->pt_ptr_arr_ptr != NULL) { | 406   if (gif_ptr->pt_ptr_arr_ptr) { | 
| 424     int32_t size_pt_arr = gif_ptr->pt_ptr_arr_ptr->GetSize(); | 407     int32_t size_pt_arr = gif_ptr->pt_ptr_arr_ptr->GetSize(); | 
| 425     for (int32_t i = 0; i < size_pt_arr; i++) { | 408     for (int32_t i = 0; i < size_pt_arr; i++) { | 
| 426       GifPlainText* p = gif_ptr->pt_ptr_arr_ptr->GetAt(i); | 409       GifPlainText* p = gif_ptr->pt_ptr_arr_ptr->GetAt(i); | 
| 427       if (p->gce_ptr != NULL) { | 410       FX_Free(p->gce_ptr); | 
| 428         FX_Free(p->gce_ptr); | 411       FX_Free(p->pte_ptr); | 
| 429       } | 412       delete p->string_ptr; | 
| 430       if (p->pte_ptr != NULL) { |  | 
| 431         FX_Free(p->pte_ptr); |  | 
| 432       } |  | 
| 433       if (p->string_ptr != NULL) { |  | 
| 434         delete p->string_ptr; |  | 
| 435       } |  | 
| 436     } | 413     } | 
| 437     gif_ptr->pt_ptr_arr_ptr->RemoveAll(); | 414     gif_ptr->pt_ptr_arr_ptr->RemoveAll(); | 
| 438     delete gif_ptr->pt_ptr_arr_ptr; | 415     delete gif_ptr->pt_ptr_arr_ptr; | 
| 439   } | 416   } | 
| 440 #endif | 417 #endif | 
| 441   FX_Free(gif_ptr); | 418   FX_Free(gif_ptr); | 
| 442 } | 419 } | 
| 443 gif_compress_struct_p _gif_create_compress() { | 420 gif_compress_struct_p _gif_create_compress() { | 
| 444   gif_compress_struct_p gif_ptr = | 421   gif_compress_struct_p gif_ptr = | 
| 445       (gif_compress_struct*)FX_Alloc(uint8_t, sizeof(gif_compress_struct)); | 422       (gif_compress_struct*)FX_Alloc(uint8_t, sizeof(gif_compress_struct)); | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 504   gif_ptr->pte_ptr->block_size = 12; | 481   gif_ptr->pte_ptr->block_size = 12; | 
| 505 #endif | 482 #endif | 
| 506   return gif_ptr; | 483   return gif_ptr; | 
| 507 } | 484 } | 
| 508 void _gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr) { | 485 void _gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr) { | 
| 509   if (gif_ptr_ptr == NULL || *gif_ptr_ptr == NULL) { | 486   if (gif_ptr_ptr == NULL || *gif_ptr_ptr == NULL) { | 
| 510     return; | 487     return; | 
| 511   } | 488   } | 
| 512   gif_compress_struct_p gif_ptr = *gif_ptr_ptr; | 489   gif_compress_struct_p gif_ptr = *gif_ptr_ptr; | 
| 513   *gif_ptr_ptr = NULL; | 490   *gif_ptr_ptr = NULL; | 
| 514   if (gif_ptr->header_ptr != NULL) { | 491   FX_Free(gif_ptr->header_ptr); | 
| 515     FX_Free(gif_ptr->header_ptr); | 492   FX_Free(gif_ptr->lsd_ptr); | 
| 516   } | 493   FX_Free(gif_ptr->global_pal); | 
| 517   if (gif_ptr->lsd_ptr != NULL) { | 494   FX_Free(gif_ptr->image_info_ptr); | 
| 518     FX_Free(gif_ptr->lsd_ptr); | 495   FX_Free(gif_ptr->local_pal); | 
| 519   } | 496   delete gif_ptr->img_encoder_ptr; | 
| 520   if (gif_ptr->global_pal != NULL) { |  | 
| 521     FX_Free(gif_ptr->global_pal); |  | 
| 522   } |  | 
| 523   if (gif_ptr->image_info_ptr != NULL) { |  | 
| 524     FX_Free(gif_ptr->image_info_ptr); |  | 
| 525   } |  | 
| 526   if (gif_ptr->local_pal != NULL) { |  | 
| 527     FX_Free(gif_ptr->local_pal); |  | 
| 528   } |  | 
| 529   if (gif_ptr->img_encoder_ptr != NULL) { |  | 
| 530     delete gif_ptr->img_encoder_ptr; |  | 
| 531   } |  | 
| 532 #ifdef GIF_SUPPORT_APPLICATION_EXTENSION | 497 #ifdef GIF_SUPPORT_APPLICATION_EXTENSION | 
| 533   if (gif_ptr->app_data != NULL) { | 498   FX_Free(gif_ptr->app_data); | 
| 534     FX_Free(gif_ptr->app_data); |  | 
| 535   } |  | 
| 536 #endif | 499 #endif | 
| 537 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 500 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 
| 538   if (gif_ptr->gce_ptr != NULL) { | 501   FX_Free(gif_ptr->gce_ptr); | 
| 539     FX_Free(gif_ptr->gce_ptr); |  | 
| 540   } |  | 
| 541 #endif | 502 #endif | 
| 542 #ifdef GIF_SUPPORT_COMMENT_EXTENSION | 503 #ifdef GIF_SUPPORT_COMMENT_EXTENSION | 
| 543   if (gif_ptr->cmt_data_ptr != NULL) { | 504   FX_Free(gif_ptr->cmt_data_ptr); | 
| 544     FX_Free(gif_ptr->cmt_data_ptr); |  | 
| 545   } |  | 
| 546 #endif | 505 #endif | 
| 547 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 506 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 
| 548   if (gif_ptr->pte_ptr != NULL) { | 507   FX_Free(gif_ptr->pte_ptr); | 
| 549     FX_Free(gif_ptr->pte_ptr); |  | 
| 550   } |  | 
| 551 #endif | 508 #endif | 
| 552   FX_Free(gif_ptr); | 509   FX_Free(gif_ptr); | 
| 553 } | 510 } | 
| 554 void _gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) { | 511 void _gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) { | 
| 555   if (gif_ptr != NULL && gif_ptr->_gif_error_fn != NULL) { | 512   if (gif_ptr && gif_ptr->_gif_error_fn) { | 
| 556     gif_ptr->_gif_error_fn(gif_ptr, err_msg); | 513     gif_ptr->_gif_error_fn(gif_ptr, err_msg); | 
| 557   } | 514   } | 
| 558 } | 515 } | 
| 559 void _gif_warn(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) {} | 516 void _gif_warn(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) {} | 
| 560 int32_t _gif_read_header(gif_decompress_struct_p gif_ptr) { | 517 int32_t _gif_read_header(gif_decompress_struct_p gif_ptr) { | 
| 561   if (gif_ptr == NULL) { | 518   if (gif_ptr == NULL) { | 
| 562     return 0; | 519     return 0; | 
| 563   } | 520   } | 
| 564   FX_DWORD skip_size_org = gif_ptr->skip_size; | 521   FX_DWORD skip_size_org = gif_ptr->skip_size; | 
| 565   ASSERT(sizeof(GifHeader) == 6); | 522   ASSERT(sizeof(GifHeader) == 6); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 584     ASSERT(sizeof(GifPalette) == 3); | 541     ASSERT(sizeof(GifPalette) == 3); | 
| 585     int32_t global_pal_size = gif_ptr->global_pal_num * 3; | 542     int32_t global_pal_size = gif_ptr->global_pal_num * 3; | 
| 586     uint8_t* global_pal_ptr = NULL; | 543     uint8_t* global_pal_ptr = NULL; | 
| 587     if (_gif_read_data(gif_ptr, &global_pal_ptr, global_pal_size) == NULL) { | 544     if (_gif_read_data(gif_ptr, &global_pal_ptr, global_pal_size) == NULL) { | 
| 588       gif_ptr->skip_size = skip_size_org; | 545       gif_ptr->skip_size = skip_size_org; | 
| 589       return 2; | 546       return 2; | 
| 590     } | 547     } | 
| 591     gif_ptr->global_sort_flag = ((GifGF*)&gif_lsd_ptr->global_flag)->sort_flag; | 548     gif_ptr->global_sort_flag = ((GifGF*)&gif_lsd_ptr->global_flag)->sort_flag; | 
| 592     gif_ptr->global_color_resolution = | 549     gif_ptr->global_color_resolution = | 
| 593         ((GifGF*)&gif_lsd_ptr->global_flag)->color_resolution; | 550         ((GifGF*)&gif_lsd_ptr->global_flag)->color_resolution; | 
| 594     if (gif_ptr->global_pal_ptr != NULL) { | 551     FX_Free(gif_ptr->global_pal_ptr); | 
| 595       FX_Free(gif_ptr->global_pal_ptr); |  | 
| 596     } |  | 
| 597     gif_ptr->global_pal_ptr = NULL; |  | 
| 598     gif_ptr->global_pal_ptr = (GifPalette*)FX_Alloc(uint8_t, global_pal_size); | 552     gif_ptr->global_pal_ptr = (GifPalette*)FX_Alloc(uint8_t, global_pal_size); | 
| 599     GIF_PTR_NOT_NULL(gif_ptr->global_pal_ptr, gif_ptr); |  | 
| 600     FXSYS_memcpy(gif_ptr->global_pal_ptr, global_pal_ptr, global_pal_size); | 553     FXSYS_memcpy(gif_ptr->global_pal_ptr, global_pal_ptr, global_pal_size); | 
| 601   } | 554   } | 
| 602   gif_ptr->width = (int)_GetWord_LSBFirst((uint8_t*)&gif_lsd_ptr->width); | 555   gif_ptr->width = (int)_GetWord_LSBFirst((uint8_t*)&gif_lsd_ptr->width); | 
| 603   gif_ptr->height = (int)_GetWord_LSBFirst((uint8_t*)&gif_lsd_ptr->height); | 556   gif_ptr->height = (int)_GetWord_LSBFirst((uint8_t*)&gif_lsd_ptr->height); | 
| 604   gif_ptr->bc_index = gif_lsd_ptr->bc_index; | 557   gif_ptr->bc_index = gif_lsd_ptr->bc_index; | 
| 605   gif_ptr->pixel_aspect = gif_lsd_ptr->pixel_aspect; | 558   gif_ptr->pixel_aspect = gif_lsd_ptr->pixel_aspect; | 
| 606   return 1; | 559   return 1; | 
| 607 } | 560 } | 
| 608 int32_t _gif_get_frame(gif_decompress_struct_p gif_ptr) { | 561 int32_t _gif_get_frame(gif_decompress_struct_p gif_ptr) { | 
| 609   if (gif_ptr == NULL) { | 562   if (gif_ptr == NULL) { | 
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 713         continue; | 666         continue; | 
| 714       } | 667       } | 
| 715     } | 668     } | 
| 716   } | 669   } | 
| 717   return 1; | 670   return 1; | 
| 718 } | 671 } | 
| 719 void _gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr, | 672 void _gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr, | 
| 720                            GifGCE** gce_ptr_ptr) { | 673                            GifGCE** gce_ptr_ptr) { | 
| 721   *gce_ptr_ptr = NULL; | 674   *gce_ptr_ptr = NULL; | 
| 722 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 675 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 
| 723   if (gif_ptr->gce_ptr != NULL && gce_ptr_ptr != NULL) { | 676   if (gif_ptr->gce_ptr && gce_ptr_ptr) { | 
| 724     *gce_ptr_ptr = gif_ptr->gce_ptr; | 677     *gce_ptr_ptr = gif_ptr->gce_ptr; | 
| 725     gif_ptr->gce_ptr = NULL; | 678     gif_ptr->gce_ptr = NULL; | 
| 726   } | 679   } | 
| 727 #endif | 680 #endif | 
| 728 } | 681 } | 
| 729 int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) { | 682 int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) { | 
| 730   uint8_t* data_size_ptr = NULL; | 683   uint8_t* data_size_ptr = NULL; | 
| 731   uint8_t* data_ptr = NULL; | 684   uint8_t* data_ptr = NULL; | 
| 732   FX_DWORD skip_size_org = gif_ptr->skip_size; | 685   FX_DWORD skip_size_org = gif_ptr->skip_size; | 
| 733   switch (gif_ptr->decode_status) { | 686   switch (gif_ptr->decode_status) { | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 749             _gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 702             _gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 
| 750           gif_ptr->skip_size = skip_size_org; | 703           gif_ptr->skip_size = skip_size_org; | 
| 751           return 2; | 704           return 2; | 
| 752         } | 705         } | 
| 753         gif_ae_data_str += CFX_ByteString((const uint8_t*)data_ptr, data_size); | 706         gif_ae_data_str += CFX_ByteString((const uint8_t*)data_ptr, data_size); | 
| 754       } | 707       } | 
| 755       FXSYS_memcpy(gif_ptr->app_identify, gif_ae_ptr->app_identify, 8); | 708       FXSYS_memcpy(gif_ptr->app_identify, gif_ae_ptr->app_identify, 8); | 
| 756       FXSYS_memcpy(gif_ptr->app_authentication, gif_ae_ptr->app_authentication, | 709       FXSYS_memcpy(gif_ptr->app_authentication, gif_ae_ptr->app_authentication, | 
| 757                    3); | 710                    3); | 
| 758       gif_ptr->app_data_size = gif_ae_data_str.GetLength(); | 711       gif_ptr->app_data_size = gif_ae_data_str.GetLength(); | 
| 759       if (gif_ptr->app_data != NULL) { | 712       FX_Free(gif_ptr->app_data); | 
| 760         FX_Free(gif_ptr->app_data); |  | 
| 761         gif_ptr->app_data = NULL; |  | 
| 762       } |  | 
| 763       gif_ptr->app_data = FX_Alloc(uint8_t, gif_ptr->app_data_size); | 713       gif_ptr->app_data = FX_Alloc(uint8_t, gif_ptr->app_data_size); | 
| 764       GIF_PTR_NOT_NULL(gif_ptr->app_data, gif_ptr); |  | 
| 765       FXSYS_memcpy(gif_ptr->app_data, const uint8_t*(gif_ae_data_str), | 714       FXSYS_memcpy(gif_ptr->app_data, const uint8_t*(gif_ae_data_str), | 
| 766                    gif_ptr->app_data_size); | 715                    gif_ptr->app_data_size); | 
| 767     } break; | 716     } break; | 
| 768 #endif | 717 #endif | 
| 769 #ifdef GIF_SUPPORT_COMMENT_EXTENSION | 718 #ifdef GIF_SUPPORT_COMMENT_EXTENSION | 
| 770     case GIF_D_STATUS_EXT_CE: { | 719     case GIF_D_STATUS_EXT_CE: { | 
| 771       if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 720       if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 
| 772         gif_ptr->skip_size = skip_size_org; | 721         gif_ptr->skip_size = skip_size_org; | 
| 773         return 2; | 722         return 2; | 
| 774       } | 723       } | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 786     } break; | 735     } break; | 
| 787 #endif | 736 #endif | 
| 788 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 737 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 
| 789     case GIF_D_STATUS_EXT_PTE: { | 738     case GIF_D_STATUS_EXT_PTE: { | 
| 790       ASSERT(sizeof(GifPTE) == 13); | 739       ASSERT(sizeof(GifPTE) == 13); | 
| 791       GifPTE* gif_pte_ptr = NULL; | 740       GifPTE* gif_pte_ptr = NULL; | 
| 792       if (_gif_read_data(gif_ptr, (uint8_t**)&gif_pte_ptr, 13) == NULL) { | 741       if (_gif_read_data(gif_ptr, (uint8_t**)&gif_pte_ptr, 13) == NULL) { | 
| 793         return 2; | 742         return 2; | 
| 794       } | 743       } | 
| 795       GifPlainText* gif_pt_ptr = FX_Alloc(GifPlainText, 1); | 744       GifPlainText* gif_pt_ptr = FX_Alloc(GifPlainText, 1); | 
| 796       GIF_PTR_NOT_NULL(gif_pt_ptr, gif_ptr); |  | 
| 797       FXSYS_memset(gif_pt_ptr, 0, sizeof(GifPlainText)); | 745       FXSYS_memset(gif_pt_ptr, 0, sizeof(GifPlainText)); | 
| 798       _gif_takeover_gce_ptr(gif_ptr, &gif_pt_ptr->gce_ptr); | 746       _gif_takeover_gce_ptr(gif_ptr, &gif_pt_ptr->gce_ptr); | 
| 799       gif_pt_ptr->pte_ptr = (GifPTE*)FX_Alloc(uint8_t, sizeof(GifPTE)); | 747       gif_pt_ptr->pte_ptr = (GifPTE*)FX_Alloc(uint8_t, sizeof(GifPTE)); | 
| 800       GIF_PTR_NOT_NULL(gif_pt_ptr->pte_ptr, gif_ptr); |  | 
| 801       gif_pt_ptr->string_ptr = new CFX_ByteString; | 748       gif_pt_ptr->string_ptr = new CFX_ByteString; | 
| 802       GIF_PTR_NOT_NULL(gif_pt_ptr->string_ptr, gif_ptr); |  | 
| 803       gif_pt_ptr->pte_ptr->block_size = gif_pte_ptr->block_size; | 749       gif_pt_ptr->pte_ptr->block_size = gif_pte_ptr->block_size; | 
| 804       gif_pt_ptr->pte_ptr->grid_left = | 750       gif_pt_ptr->pte_ptr->grid_left = | 
| 805           _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_left); | 751           _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_left); | 
| 806       gif_pt_ptr->pte_ptr->grid_top = | 752       gif_pt_ptr->pte_ptr->grid_top = | 
| 807           _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_top); | 753           _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_top); | 
| 808       gif_pt_ptr->pte_ptr->grid_width = | 754       gif_pt_ptr->pte_ptr->grid_width = | 
| 809           _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_width); | 755           _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_width); | 
| 810       gif_pt_ptr->pte_ptr->grid_height = | 756       gif_pt_ptr->pte_ptr->grid_height = | 
| 811           _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_height); | 757           _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_height); | 
| 812       gif_pt_ptr->pte_ptr->char_width = gif_pte_ptr->char_width; | 758       gif_pt_ptr->pte_ptr->char_width = gif_pte_ptr->char_width; | 
| 813       gif_pt_ptr->pte_ptr->char_height = gif_pte_ptr->char_height; | 759       gif_pt_ptr->pte_ptr->char_height = gif_pte_ptr->char_height; | 
| 814       gif_pt_ptr->pte_ptr->fc_index = gif_pte_ptr->fc_index; | 760       gif_pt_ptr->pte_ptr->fc_index = gif_pte_ptr->fc_index; | 
| 815       gif_pt_ptr->pte_ptr->bc_index = gif_pte_ptr->bc_index; | 761       gif_pt_ptr->pte_ptr->bc_index = gif_pte_ptr->bc_index; | 
| 816       if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 762       if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 
| 817         gif_ptr->skip_size = skip_size_org; | 763         gif_ptr->skip_size = skip_size_org; | 
| 818         if (gif_pt_ptr != NULL) { | 764         if (gif_pt_ptr) { | 
| 819           if (gif_pt_ptr->gce_ptr != NULL) { | 765           FX_Free(gif_pt_ptr->gce_ptr); | 
| 820             FX_Free(gif_pt_ptr->gce_ptr); | 766           FX_Free(gif_pt_ptr->pte_ptr); | 
| 821           } | 767           delete gif_pt_ptr->string_ptr; | 
| 822           if (gif_pt_ptr->pte_ptr != NULL) { |  | 
| 823             FX_Free(gif_pt_ptr->pte_ptr); |  | 
| 824           } |  | 
| 825           if (gif_pt_ptr->string_ptr != NULL) { |  | 
| 826             delete gif_pt_ptr->string_ptr; |  | 
| 827           } |  | 
| 828           FX_Free(gif_pt_ptr); | 768           FX_Free(gif_pt_ptr); | 
| 829         } | 769         } | 
| 830         return 2; | 770         return 2; | 
| 831       } | 771       } | 
| 832       while (*data_size_ptr != GIF_BLOCK_TERMINAL) { | 772       while (*data_size_ptr != GIF_BLOCK_TERMINAL) { | 
| 833         uint8_t data_size = *data_size_ptr; | 773         uint8_t data_size = *data_size_ptr; | 
| 834         if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL || | 774         if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL || | 
| 835             _gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 775             _gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 
| 836           gif_ptr->skip_size = skip_size_org; | 776           gif_ptr->skip_size = skip_size_org; | 
| 837           if (gif_pt_ptr != NULL) { | 777           if (gif_pt_ptr) { | 
| 838             if (gif_pt_ptr->gce_ptr != NULL) { | 778             FX_Free(gif_pt_ptr->gce_ptr); | 
| 839               FX_Free(gif_pt_ptr->gce_ptr); | 779             FX_Free(gif_pt_ptr->pte_ptr); | 
| 840             } | 780             delete gif_pt_ptr->string_ptr; | 
| 841             if (gif_pt_ptr->pte_ptr != NULL) { |  | 
| 842               FX_Free(gif_pt_ptr->pte_ptr); |  | 
| 843             } |  | 
| 844             if (gif_pt_ptr->string_ptr != NULL) { |  | 
| 845               delete gif_pt_ptr->string_ptr; |  | 
| 846             } |  | 
| 847             FX_Free(gif_pt_ptr); | 781             FX_Free(gif_pt_ptr); | 
| 848           } | 782           } | 
| 849           return 2; | 783           return 2; | 
| 850         } | 784         } | 
| 851         *(gif_pt_ptr->string_ptr) += | 785         *(gif_pt_ptr->string_ptr) += | 
| 852             CFX_ByteString((const FX_CHAR*)data_ptr, data_size); | 786             CFX_ByteString((const FX_CHAR*)data_ptr, data_size); | 
| 853       } | 787       } | 
| 854       gif_ptr->pt_ptr_arr_ptr->Add(gif_pt_ptr); | 788       gif_ptr->pt_ptr_arr_ptr->Add(gif_pt_ptr); | 
| 855     } break; | 789     } break; | 
| 856 #endif | 790 #endif | 
| 857 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 791 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 
| 858     case GIF_D_STATUS_EXT_GCE: { | 792     case GIF_D_STATUS_EXT_GCE: { | 
| 859       ASSERT(sizeof(GifGCE) == 5); | 793       ASSERT(sizeof(GifGCE) == 5); | 
| 860       GifGCE* gif_gce_ptr = NULL; | 794       GifGCE* gif_gce_ptr = NULL; | 
| 861       if (_gif_read_data(gif_ptr, (uint8_t**)&gif_gce_ptr, 6) == NULL) { | 795       if (_gif_read_data(gif_ptr, (uint8_t**)&gif_gce_ptr, 6) == NULL) { | 
| 862         return 2; | 796         return 2; | 
| 863       } | 797       } | 
| 864       if (gif_ptr->gce_ptr == NULL) { | 798       if (gif_ptr->gce_ptr == NULL) { | 
| 865         gif_ptr->gce_ptr = (GifGCE*)FX_Alloc(uint8_t, sizeof(GifGCE)); | 799         gif_ptr->gce_ptr = (GifGCE*)FX_Alloc(uint8_t, sizeof(GifGCE)); | 
| 866         GIF_PTR_NOT_NULL(gif_ptr->gce_ptr, gif_ptr); |  | 
| 867       } | 800       } | 
| 868       gif_ptr->gce_ptr->block_size = gif_gce_ptr->block_size; | 801       gif_ptr->gce_ptr->block_size = gif_gce_ptr->block_size; | 
| 869       gif_ptr->gce_ptr->gce_flag = gif_gce_ptr->gce_flag; | 802       gif_ptr->gce_ptr->gce_flag = gif_gce_ptr->gce_flag; | 
| 870       gif_ptr->gce_ptr->delay_time = | 803       gif_ptr->gce_ptr->delay_time = | 
| 871           _GetWord_LSBFirst((uint8_t*)&gif_gce_ptr->delay_time); | 804           _GetWord_LSBFirst((uint8_t*)&gif_gce_ptr->delay_time); | 
| 872       gif_ptr->gce_ptr->trans_index = gif_gce_ptr->trans_index; | 805       gif_ptr->gce_ptr->trans_index = gif_gce_ptr->trans_index; | 
| 873     } break; | 806     } break; | 
| 874 #endif | 807 #endif | 
| 875     default: { | 808     default: { | 
| 876 #ifndef GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 809 #ifndef GIF_SUPPORT_PLAIN_TEXT_EXTENSION | 
|  | 810 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 
| 877       if (gif_ptr->decode_status == GIF_D_STATUS_EXT_PTE) { | 811       if (gif_ptr->decode_status == GIF_D_STATUS_EXT_PTE) { | 
| 878 #ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION | 812         FX_Free(gif_ptr->gce_ptr); | 
| 879         if (gif_ptr->gce_ptr != NULL) { | 813         gif_ptr->gce_ptr = NULL; | 
| 880           FX_Free(gif_ptr->gce_ptr); | 814       } | 
| 881           gif_ptr->gce_ptr = NULL; |  | 
| 882         } |  | 
| 883 #endif | 815 #endif | 
| 884       } |  | 
| 885 #endif | 816 #endif | 
| 886       if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 817       if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 
| 887         return 2; | 818         return 2; | 
| 888       } | 819       } | 
| 889       while (*data_size_ptr != GIF_BLOCK_TERMINAL) { | 820       while (*data_size_ptr != GIF_BLOCK_TERMINAL) { | 
| 890         if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL || | 821         if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL || | 
| 891             _gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 822             _gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { | 
| 892           gif_ptr->skip_size = skip_size_org; | 823           gif_ptr->skip_size = skip_size_org; | 
| 893           return 2; | 824           return 2; | 
| 894         } | 825         } | 
| 895       } | 826       } | 
| 896     } | 827     } | 
| 897   } | 828   } | 
| 898   _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_SIG); | 829   _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_SIG); | 
| 899   return 1; | 830   return 1; | 
| 900 } | 831 } | 
| 901 int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) { | 832 int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) { | 
| 902   if (gif_ptr->width == 0 || gif_ptr->height == 0) { | 833   if (gif_ptr->width == 0 || gif_ptr->height == 0) { | 
| 903     _gif_error(gif_ptr, "No Image Header Info"); | 834     _gif_error(gif_ptr, "No Image Header Info"); | 
| 904     return 0; | 835     return 0; | 
| 905   } | 836   } | 
| 906   FX_DWORD skip_size_org = gif_ptr->skip_size; | 837   FX_DWORD skip_size_org = gif_ptr->skip_size; | 
| 907   ASSERT(sizeof(GifImageInfo) == 9); | 838   ASSERT(sizeof(GifImageInfo) == 9); | 
| 908   GifImageInfo* gif_img_info_ptr = NULL; | 839   GifImageInfo* gif_img_info_ptr = NULL; | 
| 909   if (_gif_read_data(gif_ptr, (uint8_t**)&gif_img_info_ptr, 9) == NULL) { | 840   if (_gif_read_data(gif_ptr, (uint8_t**)&gif_img_info_ptr, 9) == NULL) { | 
| 910     return 2; | 841     return 2; | 
| 911   } | 842   } | 
| 912   GifImage* gif_image_ptr = (GifImage*)FX_Alloc(uint8_t, sizeof(GifImage)); | 843   GifImage* gif_image_ptr = (GifImage*)FX_Alloc(uint8_t, sizeof(GifImage)); | 
| 913   GIF_PTR_NOT_NULL(gif_image_ptr, gif_ptr); |  | 
| 914   FXSYS_memset(gif_image_ptr, 0, sizeof(GifImage)); | 844   FXSYS_memset(gif_image_ptr, 0, sizeof(GifImage)); | 
| 915   gif_image_ptr->image_info_ptr = | 845   gif_image_ptr->image_info_ptr = | 
| 916       (GifImageInfo*)FX_Alloc(uint8_t, sizeof(GifImageInfo)); | 846       (GifImageInfo*)FX_Alloc(uint8_t, sizeof(GifImageInfo)); | 
| 917   GIF_PTR_NOT_NULL(gif_image_ptr->image_info_ptr, gif_ptr); |  | 
| 918   gif_image_ptr->image_info_ptr->left = | 847   gif_image_ptr->image_info_ptr->left = | 
| 919       _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->left); | 848       _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->left); | 
| 920   gif_image_ptr->image_info_ptr->top = | 849   gif_image_ptr->image_info_ptr->top = | 
| 921       _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->top); | 850       _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->top); | 
| 922   gif_image_ptr->image_info_ptr->width = | 851   gif_image_ptr->image_info_ptr->width = | 
| 923       _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->width); | 852       _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->width); | 
| 924   gif_image_ptr->image_info_ptr->height = | 853   gif_image_ptr->image_info_ptr->height = | 
| 925       _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->height); | 854       _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->height); | 
| 926   gif_image_ptr->image_info_ptr->local_flag = gif_img_info_ptr->local_flag; | 855   gif_image_ptr->image_info_ptr->local_flag = gif_img_info_ptr->local_flag; | 
| 927   if (gif_image_ptr->image_info_ptr->left + | 856   if (gif_image_ptr->image_info_ptr->left + | 
| 928               gif_image_ptr->image_info_ptr->width > | 857               gif_image_ptr->image_info_ptr->width > | 
| 929           gif_ptr->width || | 858           gif_ptr->width || | 
| 930       gif_image_ptr->image_info_ptr->top + | 859       gif_image_ptr->image_info_ptr->top + | 
| 931               gif_image_ptr->image_info_ptr->height > | 860               gif_image_ptr->image_info_ptr->height > | 
| 932           gif_ptr->height) { | 861           gif_ptr->height) { | 
| 933     if (gif_image_ptr->image_info_ptr != NULL) { | 862     FX_Free(gif_image_ptr->image_info_ptr); | 
| 934       FX_Free(gif_image_ptr->image_info_ptr); | 863     FX_Free(gif_image_ptr->image_row_buf); | 
| 935     } |  | 
| 936     if (gif_image_ptr->image_row_buf != NULL) { |  | 
| 937       FX_Free(gif_image_ptr->image_row_buf); |  | 
| 938     } |  | 
| 939     FX_Free(gif_image_ptr); | 864     FX_Free(gif_image_ptr); | 
| 940     _gif_error(gif_ptr, "Image Data Out Of LSD, The File May Be Corrupt"); | 865     _gif_error(gif_ptr, "Image Data Out Of LSD, The File May Be Corrupt"); | 
| 941     return 0; | 866     return 0; | 
| 942   } | 867   } | 
| 943   GifLF* gif_img_info_lf_ptr = (GifLF*)&gif_img_info_ptr->local_flag; | 868   GifLF* gif_img_info_lf_ptr = (GifLF*)&gif_img_info_ptr->local_flag; | 
| 944   if (gif_img_info_lf_ptr->local_pal) { | 869   if (gif_img_info_lf_ptr->local_pal) { | 
| 945     ASSERT(sizeof(GifPalette) == 3); | 870     ASSERT(sizeof(GifPalette) == 3); | 
| 946     int32_t loc_pal_size = (2 << gif_img_info_lf_ptr->pal_bits) * 3; | 871     int32_t loc_pal_size = (2 << gif_img_info_lf_ptr->pal_bits) * 3; | 
| 947     uint8_t* loc_pal_ptr = NULL; | 872     uint8_t* loc_pal_ptr = NULL; | 
| 948     if (_gif_read_data(gif_ptr, &loc_pal_ptr, loc_pal_size) == NULL) { | 873     if (_gif_read_data(gif_ptr, &loc_pal_ptr, loc_pal_size) == NULL) { | 
| 949       gif_ptr->skip_size = skip_size_org; | 874       gif_ptr->skip_size = skip_size_org; | 
| 950       if (gif_image_ptr->image_info_ptr != NULL) { | 875       FX_Free(gif_image_ptr->image_info_ptr); | 
| 951         FX_Free(gif_image_ptr->image_info_ptr); | 876       FX_Free(gif_image_ptr->image_row_buf); | 
| 952       } |  | 
| 953       if (gif_image_ptr->image_row_buf != NULL) { |  | 
| 954         FX_Free(gif_image_ptr->image_row_buf); |  | 
| 955       } |  | 
| 956       FX_Free(gif_image_ptr); | 877       FX_Free(gif_image_ptr); | 
| 957       return 2; | 878       return 2; | 
| 958     } | 879     } | 
| 959     gif_image_ptr->local_pal_ptr = | 880     gif_image_ptr->local_pal_ptr = | 
| 960         (GifPalette*)gif_ptr->_gif_ask_buf_for_pal_fn(gif_ptr, loc_pal_size); | 881         (GifPalette*)gif_ptr->_gif_ask_buf_for_pal_fn(gif_ptr, loc_pal_size); | 
| 961     if (gif_image_ptr->local_pal_ptr != NULL) { | 882     if (gif_image_ptr->local_pal_ptr) { | 
| 962       FXSYS_memcpy((uint8_t*)gif_image_ptr->local_pal_ptr, loc_pal_ptr, | 883       FXSYS_memcpy((uint8_t*)gif_image_ptr->local_pal_ptr, loc_pal_ptr, | 
| 963                    loc_pal_size); | 884                    loc_pal_size); | 
| 964     } | 885     } | 
| 965   } | 886   } | 
| 966   uint8_t* code_size_ptr = NULL; | 887   uint8_t* code_size_ptr = NULL; | 
| 967   if (_gif_read_data(gif_ptr, &code_size_ptr, 1) == NULL) { | 888   if (_gif_read_data(gif_ptr, &code_size_ptr, 1) == NULL) { | 
| 968     gif_ptr->skip_size = skip_size_org; | 889     gif_ptr->skip_size = skip_size_org; | 
| 969     if (gif_image_ptr->image_info_ptr != NULL) { | 890     FX_Free(gif_image_ptr->image_info_ptr); | 
| 970       FX_Free(gif_image_ptr->image_info_ptr); | 891     FX_Free(gif_image_ptr->local_pal_ptr); | 
| 971     } | 892     FX_Free(gif_image_ptr->image_row_buf); | 
| 972     if (gif_image_ptr->local_pal_ptr != NULL) { |  | 
| 973       FX_Free(gif_image_ptr->local_pal_ptr); |  | 
| 974     } |  | 
| 975     if (gif_image_ptr->image_row_buf != NULL) { |  | 
| 976       FX_Free(gif_image_ptr->image_row_buf); |  | 
| 977     } |  | 
| 978     FX_Free(gif_image_ptr); | 893     FX_Free(gif_image_ptr); | 
| 979     return 2; | 894     return 2; | 
| 980   } | 895   } | 
| 981   gif_image_ptr->image_code_size = *code_size_ptr; | 896   gif_image_ptr->image_code_size = *code_size_ptr; | 
| 982   gif_ptr->_gif_record_current_position_fn(gif_ptr, | 897   gif_ptr->_gif_record_current_position_fn(gif_ptr, | 
| 983                                            &gif_image_ptr->image_data_pos); | 898                                            &gif_image_ptr->image_data_pos); | 
| 984   gif_image_ptr->image_data_pos += gif_ptr->skip_size; | 899   gif_image_ptr->image_data_pos += gif_ptr->skip_size; | 
| 985   _gif_takeover_gce_ptr(gif_ptr, &gif_image_ptr->image_gce_ptr); | 900   _gif_takeover_gce_ptr(gif_ptr, &gif_image_ptr->image_gce_ptr); | 
| 986   gif_ptr->img_ptr_arr_ptr->Add(gif_image_ptr); | 901   gif_ptr->img_ptr_arr_ptr->Add(gif_image_ptr); | 
| 987   _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA); | 902   _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA); | 
| 988   return 1; | 903   return 1; | 
| 989 } | 904 } | 
| 990 int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { | 905 int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { | 
| 991   if (gif_ptr == NULL || frame_num < 0 || | 906   if (gif_ptr == NULL || frame_num < 0 || | 
| 992       frame_num >= gif_ptr->img_ptr_arr_ptr->GetSize()) { | 907       frame_num >= gif_ptr->img_ptr_arr_ptr->GetSize()) { | 
| 993     return 0; | 908     return 0; | 
| 994   } | 909   } | 
| 995   uint8_t* data_size_ptr = NULL; | 910   uint8_t* data_size_ptr = NULL; | 
| 996   uint8_t* data_ptr = NULL; | 911   uint8_t* data_ptr = NULL; | 
| 997   FX_DWORD skip_size_org = gif_ptr->skip_size; | 912   FX_DWORD skip_size_org = gif_ptr->skip_size; | 
| 998   GifImage* gif_image_ptr = gif_ptr->img_ptr_arr_ptr->GetAt(frame_num); | 913   GifImage* gif_image_ptr = gif_ptr->img_ptr_arr_ptr->GetAt(frame_num); | 
| 999   FX_DWORD gif_img_row_bytes = gif_image_ptr->image_info_ptr->width; | 914   FX_DWORD gif_img_row_bytes = gif_image_ptr->image_info_ptr->width; | 
| 1000   if (gif_ptr->decode_status == GIF_D_STATUS_TAIL) { | 915   if (gif_ptr->decode_status == GIF_D_STATUS_TAIL) { | 
| 1001     if (gif_image_ptr->image_row_buf) { | 916     if (gif_image_ptr->image_row_buf) { | 
| 1002       FX_Free(gif_image_ptr->image_row_buf); | 917       FX_Free(gif_image_ptr->image_row_buf); | 
| 1003       gif_image_ptr->image_row_buf = NULL; | 918       gif_image_ptr->image_row_buf = NULL; | 
| 1004     } | 919     } | 
| 1005     gif_image_ptr->image_row_buf = FX_Alloc(uint8_t, gif_img_row_bytes); | 920     gif_image_ptr->image_row_buf = FX_Alloc(uint8_t, gif_img_row_bytes); | 
| 1006     GIF_PTR_NOT_NULL(gif_image_ptr->image_row_buf, gif_ptr); |  | 
| 1007     GifGCE* gif_img_gce_ptr = gif_image_ptr->image_gce_ptr; | 921     GifGCE* gif_img_gce_ptr = gif_image_ptr->image_gce_ptr; | 
| 1008     int32_t loc_pal_num = | 922     int32_t loc_pal_num = | 
| 1009         ((GifLF*)&gif_image_ptr->image_info_ptr->local_flag)->local_pal | 923         ((GifLF*)&gif_image_ptr->image_info_ptr->local_flag)->local_pal | 
| 1010             ? (2 << ((GifLF*)&gif_image_ptr->image_info_ptr->local_flag) | 924             ? (2 << ((GifLF*)&gif_image_ptr->image_info_ptr->local_flag) | 
| 1011                         ->pal_bits) | 925                         ->pal_bits) | 
| 1012             : 0; | 926             : 0; | 
| 1013     gif_ptr->avail_in = 0; | 927     gif_ptr->avail_in = 0; | 
| 1014     if (gif_img_gce_ptr == NULL) { | 928     if (gif_img_gce_ptr == NULL) { | 
| 1015       FX_BOOL bRes = gif_ptr->_gif_get_record_position_fn( | 929       FX_BOOL bRes = gif_ptr->_gif_get_record_position_fn( | 
| 1016           gif_ptr, gif_image_ptr->image_data_pos, | 930           gif_ptr, gif_image_ptr->image_data_pos, | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 1047               ->interlace); | 961               ->interlace); | 
| 1048       if (!bRes) { | 962       if (!bRes) { | 
| 1049         FX_Free(gif_image_ptr->image_row_buf); | 963         FX_Free(gif_image_ptr->image_row_buf); | 
| 1050         gif_image_ptr->image_row_buf = NULL; | 964         gif_image_ptr->image_row_buf = NULL; | 
| 1051         _gif_error(gif_ptr, "Error Read Record Position Data"); | 965         _gif_error(gif_ptr, "Error Read Record Position Data"); | 
| 1052         return 0; | 966         return 0; | 
| 1053       } | 967       } | 
| 1054     } | 968     } | 
| 1055     if (gif_ptr->img_decoder_ptr == NULL) { | 969     if (gif_ptr->img_decoder_ptr == NULL) { | 
| 1056       gif_ptr->img_decoder_ptr = new CGifLZWDecoder(gif_ptr->err_ptr); | 970       gif_ptr->img_decoder_ptr = new CGifLZWDecoder(gif_ptr->err_ptr); | 
| 1057       GIF_PTR_NOT_NULL(gif_ptr->img_decoder_ptr, gif_ptr); |  | 
| 1058     } | 971     } | 
| 1059     gif_ptr->img_decoder_ptr->InitTable(gif_image_ptr->image_code_size); | 972     gif_ptr->img_decoder_ptr->InitTable(gif_image_ptr->image_code_size); | 
| 1060     gif_ptr->img_row_offset = 0; | 973     gif_ptr->img_row_offset = 0; | 
| 1061     gif_ptr->img_row_avail_size = 0; | 974     gif_ptr->img_row_avail_size = 0; | 
| 1062     gif_ptr->img_pass_num = 0; | 975     gif_ptr->img_pass_num = 0; | 
| 1063     gif_image_ptr->image_row_num = 0; | 976     gif_image_ptr->image_row_num = 0; | 
| 1064     _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA); | 977     _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA); | 
| 1065   } | 978   } | 
| 1066   CGifLZWDecoder* img_decoder_ptr = gif_ptr->img_decoder_ptr; | 979   CGifLZWDecoder* img_decoder_ptr = gif_ptr->img_decoder_ptr; | 
| 1067   if (gif_ptr->decode_status == GIF_D_STATUS_IMG_DATA) { | 980   if (gif_ptr->decode_status == GIF_D_STATUS_IMG_DATA) { | 
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1172 } | 1085 } | 
| 1173 void _gif_input_buffer(gif_decompress_struct_p gif_ptr, | 1086 void _gif_input_buffer(gif_decompress_struct_p gif_ptr, | 
| 1174                        uint8_t* src_buf, | 1087                        uint8_t* src_buf, | 
| 1175                        FX_DWORD src_size) { | 1088                        FX_DWORD src_size) { | 
| 1176   gif_ptr->next_in = src_buf; | 1089   gif_ptr->next_in = src_buf; | 
| 1177   gif_ptr->avail_in = src_size; | 1090   gif_ptr->avail_in = src_size; | 
| 1178   gif_ptr->skip_size = 0; | 1091   gif_ptr->skip_size = 0; | 
| 1179 } | 1092 } | 
| 1180 FX_DWORD _gif_get_avail_input(gif_decompress_struct_p gif_ptr, | 1093 FX_DWORD _gif_get_avail_input(gif_decompress_struct_p gif_ptr, | 
| 1181                               uint8_t** avial_buf_ptr) { | 1094                               uint8_t** avial_buf_ptr) { | 
| 1182   if (avial_buf_ptr != NULL) { | 1095   if (avial_buf_ptr) { | 
| 1183     *avial_buf_ptr = NULL; | 1096     *avial_buf_ptr = NULL; | 
| 1184     if (gif_ptr->avail_in > 0) { | 1097     if (gif_ptr->avail_in > 0) { | 
| 1185       *avial_buf_ptr = gif_ptr->next_in; | 1098       *avial_buf_ptr = gif_ptr->next_in; | 
| 1186     } | 1099     } | 
| 1187   } | 1100   } | 
| 1188   return gif_ptr->avail_in; | 1101   return gif_ptr->avail_in; | 
| 1189 } | 1102 } | 
| 1190 int32_t _gif_get_frame_num(gif_decompress_struct_p gif_ptr) { | 1103 int32_t _gif_get_frame_num(gif_decompress_struct_p gif_ptr) { | 
| 1191   return gif_ptr->img_ptr_arr_ptr->GetSize(); | 1104   return gif_ptr->img_ptr_arr_ptr->GetSize(); | 
| 1192 } | 1105 } | 
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1417     gif_ptr->cur_offset = cur_offset; | 1330     gif_ptr->cur_offset = cur_offset; | 
| 1418     res = FALSE; | 1331     res = FALSE; | 
| 1419   } | 1332   } | 
| 1420   dst_len = gif_ptr->cur_offset; | 1333   dst_len = gif_ptr->cur_offset; | 
| 1421   dst_buf[dst_len - 1] = GIF_SIG_TRAILER; | 1334   dst_buf[dst_len - 1] = GIF_SIG_TRAILER; | 
| 1422   if (res) { | 1335   if (res) { | 
| 1423     gif_ptr->frames++; | 1336     gif_ptr->frames++; | 
| 1424   } | 1337   } | 
| 1425   return res; | 1338   return res; | 
| 1426 } | 1339 } | 
| OLD | NEW | 
|---|