Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: core/src/fxcodec/codec/fx_codec_progress.cpp

Issue 1720043003: Remove foo != NULL outside of xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_progress.h ('k') | core/src/fxcodec/lbmp/fx_bmp.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/include/fxcodec/fx_codec.h" 7 #include "core/include/fxcodec/fx_codec.h"
8 #include "core/include/fxge/fx_dib.h" 8 #include "core/include/fxge/fx_dib.h"
9 #include "core/src/fxcodec/codec/fx_codec_progress.h" 9 #include "core/src/fxcodec/codec/fx_codec_progress.h"
10 void CFXCODEC_WeightTable::Calc(int dest_len, 10 void CFXCODEC_WeightTable::Calc(int dest_len,
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 m_SrcPaletteNumber = 0; 265 m_SrcPaletteNumber = 0;
266 m_GifPltNumber = 0; 266 m_GifPltNumber = 0;
267 m_GifBgIndex = 0; 267 m_GifBgIndex = 0;
268 m_pGifPalette = NULL; 268 m_pGifPalette = NULL;
269 m_GifTransIndex = -1; 269 m_GifTransIndex = -1;
270 m_GifFrameRect = FX_RECT(0, 0, 0, 0); 270 m_GifFrameRect = FX_RECT(0, 0, 0, 0);
271 m_BmpIsTopBottom = FALSE; 271 m_BmpIsTopBottom = FALSE;
272 } 272 }
273 CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() { 273 CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() {
274 m_pFile = NULL; 274 m_pFile = NULL;
275 if (m_pJpegContext != NULL) { 275 if (m_pJpegContext) {
276 m_pCodecMgr->GetJpegModule()->Finish(m_pJpegContext); 276 m_pCodecMgr->GetJpegModule()->Finish(m_pJpegContext);
277 } 277 }
278 if (m_pPngContext != NULL) { 278 if (m_pPngContext) {
279 m_pCodecMgr->GetPngModule()->Finish(m_pPngContext); 279 m_pCodecMgr->GetPngModule()->Finish(m_pPngContext);
280 } 280 }
281 if (m_pGifContext != NULL) { 281 if (m_pGifContext) {
282 m_pCodecMgr->GetGifModule()->Finish(m_pGifContext); 282 m_pCodecMgr->GetGifModule()->Finish(m_pGifContext);
283 } 283 }
284 if (m_pBmpContext != NULL) { 284 if (m_pBmpContext) {
285 m_pCodecMgr->GetBmpModule()->Finish(m_pBmpContext); 285 m_pCodecMgr->GetBmpModule()->Finish(m_pBmpContext);
286 } 286 }
287 if (m_pTiffContext != NULL) { 287 if (m_pTiffContext) {
288 m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext); 288 m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext);
289 } 289 }
290 if (m_pSrcBuf != NULL) { 290 FX_Free(m_pSrcBuf);
291 FX_Free(m_pSrcBuf); 291 FX_Free(m_pDecodeBuf);
292 } 292 FX_Free(m_pSrcPalette);
293 if (m_pDecodeBuf != NULL) {
294 FX_Free(m_pDecodeBuf);
295 }
296 if (m_pSrcPalette != NULL) {
297 FX_Free(m_pSrcPalette);
298 }
299 } 293 }
300 FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData( 294 FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData(
301 ICodec_JpegModule* pJpegModule, 295 ICodec_JpegModule* pJpegModule,
302 FXCODEC_STATUS& err_status) { 296 FXCODEC_STATUS& err_status) {
303 FX_DWORD dwSize = (FX_DWORD)m_pFile->GetSize(); 297 FX_DWORD dwSize = (FX_DWORD)m_pFile->GetSize();
304 if (dwSize <= m_offSet) { 298 if (dwSize <= m_offSet) {
305 return FALSE; 299 return FALSE;
306 } 300 }
307 dwSize = dwSize - m_offSet; 301 dwSize = dwSize - m_offSet;
308 FX_DWORD dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, NULL); 302 FX_DWORD dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, NULL);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return FALSE; 374 return FALSE;
381 } 375 }
382 *gamma = FXCODEC_PNG_GAMMA; 376 *gamma = FXCODEC_PNG_GAMMA;
383 return TRUE; 377 return TRUE;
384 } 378 }
385 FX_BOOL CCodec_ProgressiveDecoder::PngAskScanlineBufFunc(void* pModule, 379 FX_BOOL CCodec_ProgressiveDecoder::PngAskScanlineBufFunc(void* pModule,
386 int line, 380 int line,
387 uint8_t*& src_buf) { 381 uint8_t*& src_buf) {
388 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; 382 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
389 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap; 383 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap;
390 ASSERT(pDIBitmap != NULL); 384 if (!pDIBitmap) {
391 if (pDIBitmap == NULL) { 385 ASSERT(false);
392 return FALSE; 386 return FALSE;
393 } 387 }
394 if (line >= pCodec->m_clipBox.top && line < pCodec->m_clipBox.bottom) { 388 if (line >= pCodec->m_clipBox.top && line < pCodec->m_clipBox.bottom) {
395 double scale_y = 389 double scale_y =
396 (double)pCodec->m_sizeY / (double)pCodec->m_clipBox.Height(); 390 (double)pCodec->m_sizeY / (double)pCodec->m_clipBox.Height();
397 int32_t row = 391 int32_t row =
398 (int32_t)((line - pCodec->m_clipBox.top) * scale_y) + pCodec->m_startY; 392 (int32_t)((line - pCodec->m_clipBox.top) * scale_y) + pCodec->m_startY;
399 uint8_t* src_scan = (uint8_t*)pDIBitmap->GetScanline(row); 393 uint8_t* src_scan = (uint8_t*)pDIBitmap->GetScanline(row);
400 uint8_t* des_scan = pCodec->m_pDecodeBuf; 394 uint8_t* des_scan = pCodec->m_pDecodeBuf;
401 src_buf = pCodec->m_pDecodeBuf; 395 src_buf = pCodec->m_pDecodeBuf;
402 int32_t src_Bpp = pDIBitmap->GetBPP() >> 3; 396 int32_t src_Bpp = pDIBitmap->GetBPP() >> 3;
403 int32_t des_Bpp = (pCodec->m_SrcFormat & 0xff) >> 3; 397 int32_t des_Bpp = (pCodec->m_SrcFormat & 0xff) >> 3;
404 int32_t src_left = pCodec->m_startX; 398 int32_t src_left = pCodec->m_startX;
405 int32_t des_left = pCodec->m_clipBox.left; 399 int32_t des_left = pCodec->m_clipBox.left;
406 src_scan += src_left * src_Bpp; 400 src_scan += src_left * src_Bpp;
407 des_scan += des_left * des_Bpp; 401 des_scan += des_left * des_Bpp;
408 for (int32_t src_col = 0; src_col < pCodec->m_sizeX; src_col++) { 402 for (int32_t src_col = 0; src_col < pCodec->m_sizeX; src_col++) {
409 PixelWeight* pPixelWeights = 403 PixelWeight* pPixelWeights =
410 pCodec->m_WeightHorzOO.GetPixelWeight(src_col); 404 pCodec->m_WeightHorzOO.GetPixelWeight(src_col);
411 if (pPixelWeights->m_SrcStart != pPixelWeights->m_SrcEnd) { 405 if (pPixelWeights->m_SrcStart != pPixelWeights->m_SrcEnd) {
412 continue; 406 continue;
413 } 407 }
414 switch (pDIBitmap->GetFormat()) { 408 switch (pDIBitmap->GetFormat()) {
415 case FXDIB_1bppMask: 409 case FXDIB_1bppMask:
416 case FXDIB_1bppRgb: 410 case FXDIB_1bppRgb:
417 ASSERT(FALSE); 411 ASSERT(FALSE);
418 return FALSE; 412 return FALSE;
419 case FXDIB_8bppMask: 413 case FXDIB_8bppMask:
420 case FXDIB_8bppRgb: { 414 case FXDIB_8bppRgb: {
421 if (pDIBitmap->GetPalette() != NULL) { 415 if (pDIBitmap->GetPalette()) {
422 return FALSE; 416 return FALSE;
423 } 417 }
424 FX_DWORD des_g = 0; 418 FX_DWORD des_g = 0;
425 des_g += pPixelWeights->m_Weights[0] * src_scan[src_col]; 419 des_g += pPixelWeights->m_Weights[0] * src_scan[src_col];
426 des_scan[pPixelWeights->m_SrcStart] = (uint8_t)(des_g >> 16); 420 des_scan[pPixelWeights->m_SrcStart] = (uint8_t)(des_g >> 16);
427 } break; 421 } break;
428 case FXDIB_Rgb: 422 case FXDIB_Rgb:
429 case FXDIB_Rgb32: { 423 case FXDIB_Rgb32: {
430 FX_DWORD des_b = 0, des_g = 0, des_r = 0; 424 FX_DWORD des_b = 0, des_g = 0, des_r = 0;
431 const uint8_t* p = src_scan + src_col * src_Bpp; 425 const uint8_t* p = src_scan + src_col * src_Bpp;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 des_scan += des_left * des_Bpp; 464 des_scan += des_left * des_Bpp;
471 for (int32_t des_col = 0; des_col < m_sizeX; des_col++) { 465 for (int32_t des_col = 0; des_col < m_sizeX; des_col++) {
472 PixelWeight* pPixelWeights = m_WeightHorzOO.GetPixelWeight(des_col); 466 PixelWeight* pPixelWeights = m_WeightHorzOO.GetPixelWeight(des_col);
473 switch (pDeviceBitmap->GetFormat()) { 467 switch (pDeviceBitmap->GetFormat()) {
474 case FXDIB_1bppMask: 468 case FXDIB_1bppMask:
475 case FXDIB_1bppRgb: 469 case FXDIB_1bppRgb:
476 ASSERT(FALSE); 470 ASSERT(FALSE);
477 return; 471 return;
478 case FXDIB_8bppMask: 472 case FXDIB_8bppMask:
479 case FXDIB_8bppRgb: { 473 case FXDIB_8bppRgb: {
480 if (pDeviceBitmap->GetPalette() != NULL) { 474 if (pDeviceBitmap->GetPalette()) {
481 return; 475 return;
482 } 476 }
483 FX_DWORD des_g = 0; 477 FX_DWORD des_g = 0;
484 des_g += 478 des_g +=
485 pPixelWeights->m_Weights[0] * src_scan[pPixelWeights->m_SrcStart]; 479 pPixelWeights->m_Weights[0] * src_scan[pPixelWeights->m_SrcStart];
486 des_g += 480 des_g +=
487 pPixelWeights->m_Weights[1] * src_scan[pPixelWeights->m_SrcEnd]; 481 pPixelWeights->m_Weights[1] * src_scan[pPixelWeights->m_SrcEnd];
488 *des_scan++ = (uint8_t)(des_g >> 16); 482 *des_scan++ = (uint8_t)(des_g >> 16);
489 } break; 483 } break;
490 case FXDIB_Rgb: 484 case FXDIB_Rgb:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 default: 519 default:
526 return; 520 return;
527 } 521 }
528 } 522 }
529 } 523 }
530 void CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc(void* pModule, 524 void CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc(void* pModule,
531 int pass, 525 int pass,
532 int line) { 526 int line) {
533 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; 527 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
534 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap; 528 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap;
535 ASSERT(pDIBitmap != NULL); 529 ASSERT(pDIBitmap);
536 int src_top = pCodec->m_clipBox.top; 530 int src_top = pCodec->m_clipBox.top;
537 int src_bottom = pCodec->m_clipBox.bottom; 531 int src_bottom = pCodec->m_clipBox.bottom;
538 int des_top = pCodec->m_startY; 532 int des_top = pCodec->m_startY;
539 int src_hei = pCodec->m_clipBox.Height(); 533 int src_hei = pCodec->m_clipBox.Height();
540 int des_hei = pCodec->m_sizeY; 534 int des_hei = pCodec->m_sizeY;
541 if (line >= src_top && line < src_bottom) { 535 if (line >= src_top && line < src_bottom) {
542 double scale_y = (double)des_hei / (double)src_hei; 536 double scale_y = (double)des_hei / (double)src_hei;
543 int src_row = line - src_top; 537 int src_row = line - src_top;
544 int des_row = (int)(src_row * scale_y) + des_top; 538 int des_row = (int)(src_row * scale_y) + des_top;
545 if (des_row >= des_top + des_hei) { 539 if (des_row >= des_top + des_hei) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 } 687 }
694 } 688 }
695 } 689 }
696 return TRUE; 690 return TRUE;
697 } 691 }
698 void CCodec_ProgressiveDecoder::GifReadScanlineCallback(void* pModule, 692 void CCodec_ProgressiveDecoder::GifReadScanlineCallback(void* pModule,
699 int32_t row_num, 693 int32_t row_num,
700 uint8_t* row_buf) { 694 uint8_t* row_buf) {
701 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; 695 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
702 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap; 696 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap;
703 ASSERT(pDIBitmap != NULL); 697 ASSERT(pDIBitmap);
704 int32_t img_width = pCodec->m_GifFrameRect.Width(); 698 int32_t img_width = pCodec->m_GifFrameRect.Width();
705 if (!pDIBitmap->HasAlpha()) { 699 if (!pDIBitmap->HasAlpha()) {
706 uint8_t* byte_ptr = row_buf; 700 uint8_t* byte_ptr = row_buf;
707 for (int i = 0; i < img_width; i++) { 701 for (int i = 0; i < img_width; i++) {
708 if (*byte_ptr == pCodec->m_GifTransIndex) { 702 if (*byte_ptr == pCodec->m_GifTransIndex) {
709 *byte_ptr = pCodec->m_GifBgIndex; 703 *byte_ptr = pCodec->m_GifBgIndex;
710 } 704 }
711 byte_ptr++; 705 byte_ptr++;
712 } 706 }
713 } 707 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 const uint8_t* scan_src2 = 775 const uint8_t* scan_src2 =
782 pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + des_top) + des_ScanOffet; 776 pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + des_top) + des_ScanOffet;
783 for (int des_col = 0; des_col < m_sizeX; des_col++) { 777 for (int des_col = 0; des_col < m_sizeX; des_col++) {
784 switch (pDeviceBitmap->GetFormat()) { 778 switch (pDeviceBitmap->GetFormat()) {
785 case FXDIB_Invalid: 779 case FXDIB_Invalid:
786 case FXDIB_1bppMask: 780 case FXDIB_1bppMask:
787 case FXDIB_1bppRgb: 781 case FXDIB_1bppRgb:
788 return; 782 return;
789 case FXDIB_8bppMask: 783 case FXDIB_8bppMask:
790 case FXDIB_8bppRgb: { 784 case FXDIB_8bppRgb: {
791 if (pDeviceBitmap->GetPalette() != NULL) { 785 if (pDeviceBitmap->GetPalette()) {
792 return; 786 return;
793 } 787 }
794 int des_g = 0; 788 int des_g = 0;
795 des_g += pWeight->m_Weights[0] * (*scan_src1++); 789 des_g += pWeight->m_Weights[0] * (*scan_src1++);
796 des_g += pWeight->m_Weights[1] * (*scan_src2++); 790 des_g += pWeight->m_Weights[1] * (*scan_src2++);
797 *scan_des++ = (uint8_t)(des_g >> 16); 791 *scan_des++ = (uint8_t)(des_g >> 16);
798 } break; 792 } break;
799 case FXDIB_Rgb: 793 case FXDIB_Rgb:
800 case FXDIB_Rgb32: { 794 case FXDIB_Rgb32: {
801 FX_DWORD des_b = 0, des_g = 0, des_r = 0; 795 FX_DWORD des_b = 0, des_g = 0, des_r = 0;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 error_status)) { 878 error_status)) {
885 return FALSE; 879 return FALSE;
886 } 880 }
887 return TRUE; 881 return TRUE;
888 } 882 }
889 void CCodec_ProgressiveDecoder::BmpReadScanlineCallback(void* pModule, 883 void CCodec_ProgressiveDecoder::BmpReadScanlineCallback(void* pModule,
890 int32_t row_num, 884 int32_t row_num,
891 uint8_t* row_buf) { 885 uint8_t* row_buf) {
892 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; 886 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
893 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap; 887 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap;
894 ASSERT(pDIBitmap != NULL); 888 ASSERT(pDIBitmap);
895 FXSYS_memcpy(pCodec->m_pDecodeBuf, row_buf, pCodec->m_ScanlineSize); 889 FXSYS_memcpy(pCodec->m_pDecodeBuf, row_buf, pCodec->m_ScanlineSize);
896 int src_top = pCodec->m_clipBox.top; 890 int src_top = pCodec->m_clipBox.top;
897 int src_bottom = pCodec->m_clipBox.bottom; 891 int src_bottom = pCodec->m_clipBox.bottom;
898 int des_top = pCodec->m_startY; 892 int des_top = pCodec->m_startY;
899 int src_hei = pCodec->m_clipBox.Height(); 893 int src_hei = pCodec->m_clipBox.Height();
900 int des_hei = pCodec->m_sizeY; 894 int des_hei = pCodec->m_sizeY;
901 if (row_num >= src_top && row_num < src_bottom) { 895 if (row_num >= src_top && row_num < src_bottom) {
902 double scale_y = (double)des_hei / (double)src_hei; 896 double scale_y = (double)des_hei / (double)src_hei;
903 int src_row = row_num - src_top; 897 int src_row = row_num - src_top;
904 int des_row = (int)(src_row * scale_y) + des_top; 898 int des_row = (int)(src_row * scale_y) + des_top;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 const uint8_t* scan_src2 = 940 const uint8_t* scan_src2 =
947 pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + des_top) + des_ScanOffet; 941 pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + des_top) + des_ScanOffet;
948 for (int des_col = 0; des_col < m_sizeX; des_col++) { 942 for (int des_col = 0; des_col < m_sizeX; des_col++) {
949 switch (pDeviceBitmap->GetFormat()) { 943 switch (pDeviceBitmap->GetFormat()) {
950 case FXDIB_Invalid: 944 case FXDIB_Invalid:
951 case FXDIB_1bppMask: 945 case FXDIB_1bppMask:
952 case FXDIB_1bppRgb: 946 case FXDIB_1bppRgb:
953 return; 947 return;
954 case FXDIB_8bppMask: 948 case FXDIB_8bppMask:
955 case FXDIB_8bppRgb: { 949 case FXDIB_8bppRgb: {
956 if (pDeviceBitmap->GetPalette() != NULL) { 950 if (pDeviceBitmap->GetPalette()) {
957 return; 951 return;
958 } 952 }
959 int des_g = 0; 953 int des_g = 0;
960 des_g += pWeight->m_Weights[0] * (*scan_src1++); 954 des_g += pWeight->m_Weights[0] * (*scan_src1++);
961 des_g += pWeight->m_Weights[1] * (*scan_src2++); 955 des_g += pWeight->m_Weights[1] * (*scan_src2++);
962 *scan_des++ = (uint8_t)(des_g >> 16); 956 *scan_des++ = (uint8_t)(des_g >> 16);
963 } break; 957 } break;
964 case FXDIB_Rgb: 958 case FXDIB_Rgb:
965 case FXDIB_Rgb32: { 959 case FXDIB_Rgb32: {
966 FX_DWORD des_b = 0, des_g = 0, des_r = 0; 960 FX_DWORD des_b = 0, des_g = 0, des_r = 0;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 } 993 }
1000 } 994 }
1001 FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( 995 FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
1002 FXCODEC_IMAGE_TYPE imageType, 996 FXCODEC_IMAGE_TYPE imageType,
1003 CFX_DIBAttribute* pAttribute) { 997 CFX_DIBAttribute* pAttribute) {
1004 m_offSet = 0; 998 m_offSet = 0;
1005 FX_DWORD size = (FX_DWORD)m_pFile->GetSize(); 999 FX_DWORD size = (FX_DWORD)m_pFile->GetSize();
1006 if (size > FXCODEC_BLOCK_SIZE) { 1000 if (size > FXCODEC_BLOCK_SIZE) {
1007 size = FXCODEC_BLOCK_SIZE; 1001 size = FXCODEC_BLOCK_SIZE;
1008 } 1002 }
1009 if (m_pSrcBuf != NULL) { 1003 FX_Free(m_pSrcBuf);
1010 FX_Free(m_pSrcBuf);
1011 m_pSrcBuf = NULL;
1012 }
1013 m_pSrcBuf = FX_Alloc(uint8_t, size); 1004 m_pSrcBuf = FX_Alloc(uint8_t, size);
1014 if (m_pSrcBuf == NULL) {
1015 m_status = FXCODEC_STATUS_ERR_MEMORY;
1016 return FALSE;
1017 }
1018 FXSYS_memset(m_pSrcBuf, 0, size); 1005 FXSYS_memset(m_pSrcBuf, 0, size);
1019 m_SrcSize = size; 1006 m_SrcSize = size;
1020 switch (imageType) { 1007 switch (imageType) {
1021 case FXCODEC_IMAGE_BMP: { 1008 case FXCODEC_IMAGE_BMP: {
1022 ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); 1009 ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
1023 if (pBmpModule == NULL) { 1010 if (pBmpModule == NULL) {
1024 m_status = FXCODEC_STATUS_ERR_MEMORY; 1011 m_status = FXCODEC_STATUS_ERR_MEMORY;
1025 return FALSE; 1012 return FALSE;
1026 } 1013 }
1027 pBmpModule->InputImagePositionBufCallback = 1014 pBmpModule->InputImagePositionBufCallback =
(...skipping 21 matching lines...) Expand all
1049 m_status = error_status; 1036 m_status = error_status;
1050 return FALSE; 1037 return FALSE;
1051 } 1038 }
1052 readResult = pBmpModule->ReadHeader( 1039 readResult = pBmpModule->ReadHeader(
1053 m_pBmpContext, &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom, 1040 m_pBmpContext, &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom,
1054 &m_SrcComponents, &m_SrcPaletteNumber, &pPalette, pAttribute); 1041 &m_SrcComponents, &m_SrcPaletteNumber, &pPalette, pAttribute);
1055 } 1042 }
1056 if (readResult == 1) { 1043 if (readResult == 1) {
1057 m_SrcBPC = 8; 1044 m_SrcBPC = 8;
1058 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); 1045 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
1059 if (m_pSrcPalette != NULL) { 1046 FX_Free(m_pSrcPalette);
1060 FX_Free(m_pSrcPalette);
1061 m_pSrcPalette = NULL;
1062 }
1063 if (m_SrcPaletteNumber) { 1047 if (m_SrcPaletteNumber) {
1064 m_pSrcPalette = FX_Alloc(FX_ARGB, m_SrcPaletteNumber); 1048 m_pSrcPalette = FX_Alloc(FX_ARGB, m_SrcPaletteNumber);
1065 if (m_pSrcPalette == NULL) {
1066 m_status = FXCODEC_STATUS_ERR_MEMORY;
1067 return FALSE;
1068 }
1069 FXSYS_memcpy(m_pSrcPalette, pPalette, 1049 FXSYS_memcpy(m_pSrcPalette, pPalette,
1070 m_SrcPaletteNumber * sizeof(FX_DWORD)); 1050 m_SrcPaletteNumber * sizeof(FX_DWORD));
1051 } else {
1052 m_pSrcPalette = nullptr;
1071 } 1053 }
1072 return TRUE; 1054 return TRUE;
1073 } 1055 }
1074 if (m_pBmpContext != NULL) { 1056 if (m_pBmpContext) {
1075 pBmpModule->Finish(m_pBmpContext); 1057 pBmpModule->Finish(m_pBmpContext);
1076 m_pBmpContext = NULL; 1058 m_pBmpContext = NULL;
1077 } 1059 }
1078 m_status = FXCODEC_STATUS_ERR_FORMAT; 1060 m_status = FXCODEC_STATUS_ERR_FORMAT;
1079 return FALSE; 1061 return FALSE;
1080 } break; 1062 } break;
1081 case FXCODEC_IMAGE_JPG: { 1063 case FXCODEC_IMAGE_JPG: {
1082 ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); 1064 ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
1083 if (pJpegModule == NULL) { 1065 if (pJpegModule == NULL) {
1084 m_status = FXCODEC_STATUS_ERR_MEMORY; 1066 m_status = FXCODEC_STATUS_ERR_MEMORY;
(...skipping 22 matching lines...) Expand all
1107 } 1089 }
1108 readResult = 1090 readResult =
1109 pJpegModule->ReadHeader(m_pJpegContext, &m_SrcWidth, &m_SrcHeight, 1091 pJpegModule->ReadHeader(m_pJpegContext, &m_SrcWidth, &m_SrcHeight,
1110 &m_SrcComponents, pAttribute); 1092 &m_SrcComponents, pAttribute);
1111 } 1093 }
1112 if (!readResult) { 1094 if (!readResult) {
1113 m_SrcBPC = 8; 1095 m_SrcBPC = 8;
1114 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); 1096 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
1115 return TRUE; 1097 return TRUE;
1116 } 1098 }
1117 if (m_pJpegContext != NULL) { 1099 if (m_pJpegContext) {
1118 pJpegModule->Finish(m_pJpegContext); 1100 pJpegModule->Finish(m_pJpegContext);
1119 m_pJpegContext = NULL; 1101 m_pJpegContext = NULL;
1120 } 1102 }
1121 m_status = FXCODEC_STATUS_ERR_FORMAT; 1103 m_status = FXCODEC_STATUS_ERR_FORMAT;
1122 return FALSE; 1104 return FALSE;
1123 } break; 1105 } break;
1124 case FXCODEC_IMAGE_PNG: { 1106 case FXCODEC_IMAGE_PNG: {
1125 ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); 1107 ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
1126 if (pPngModule == NULL) { 1108 if (pPngModule == NULL) {
1127 m_status = FXCODEC_STATUS_ERR_MEMORY; 1109 m_status = FXCODEC_STATUS_ERR_MEMORY;
(...skipping 15 matching lines...) Expand all
1143 m_status = FXCODEC_STATUS_ERR_READ; 1125 m_status = FXCODEC_STATUS_ERR_READ;
1144 return FALSE; 1126 return FALSE;
1145 } 1127 }
1146 m_offSet += size; 1128 m_offSet += size;
1147 bResult = pPngModule->Input(m_pPngContext, m_pSrcBuf, size, pAttribute); 1129 bResult = pPngModule->Input(m_pPngContext, m_pSrcBuf, size, pAttribute);
1148 while (bResult) { 1130 while (bResult) {
1149 FX_DWORD remain_size = (FX_DWORD)m_pFile->GetSize() - m_offSet; 1131 FX_DWORD remain_size = (FX_DWORD)m_pFile->GetSize() - m_offSet;
1150 FX_DWORD input_size = 1132 FX_DWORD input_size =
1151 remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size; 1133 remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size;
1152 if (input_size == 0) { 1134 if (input_size == 0) {
1153 if (m_pPngContext != NULL) { 1135 if (m_pPngContext) {
1154 pPngModule->Finish(m_pPngContext); 1136 pPngModule->Finish(m_pPngContext);
1155 } 1137 }
1156 m_pPngContext = NULL; 1138 m_pPngContext = NULL;
1157 m_status = FXCODEC_STATUS_ERR_FORMAT; 1139 m_status = FXCODEC_STATUS_ERR_FORMAT;
1158 return FALSE; 1140 return FALSE;
1159 } 1141 }
1160 if (m_pSrcBuf != NULL && input_size > m_SrcSize) { 1142 if (m_pSrcBuf && input_size > m_SrcSize) {
1161 FX_Free(m_pSrcBuf); 1143 FX_Free(m_pSrcBuf);
1162 m_pSrcBuf = FX_Alloc(uint8_t, input_size); 1144 m_pSrcBuf = FX_Alloc(uint8_t, input_size);
1163 if (m_pSrcBuf == NULL) {
1164 m_status = FXCODEC_STATUS_ERR_MEMORY;
1165 return FALSE;
1166 }
1167 FXSYS_memset(m_pSrcBuf, 0, input_size); 1145 FXSYS_memset(m_pSrcBuf, 0, input_size);
1168 m_SrcSize = input_size; 1146 m_SrcSize = input_size;
1169 } 1147 }
1170 bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); 1148 bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size);
1171 if (!bResult) { 1149 if (!bResult) {
1172 m_status = FXCODEC_STATUS_ERR_READ; 1150 m_status = FXCODEC_STATUS_ERR_READ;
1173 return FALSE; 1151 return FALSE;
1174 } 1152 }
1175 m_offSet += input_size; 1153 m_offSet += input_size;
1176 bResult = 1154 bResult =
1177 pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, pAttribute); 1155 pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, pAttribute);
1178 } 1156 }
1179 ASSERT(!bResult); 1157 ASSERT(!bResult);
1180 if (m_pPngContext != NULL) { 1158 if (m_pPngContext) {
1181 pPngModule->Finish(m_pPngContext); 1159 pPngModule->Finish(m_pPngContext);
1182 m_pPngContext = NULL; 1160 m_pPngContext = NULL;
1183 } 1161 }
1184 if (m_SrcPassNumber == 0) { 1162 if (m_SrcPassNumber == 0) {
1185 m_status = FXCODEC_STATUS_ERR_FORMAT; 1163 m_status = FXCODEC_STATUS_ERR_FORMAT;
1186 return FALSE; 1164 return FALSE;
1187 } 1165 }
1188 } break; 1166 } break;
1189 case FXCODEC_IMAGE_GIF: { 1167 case FXCODEC_IMAGE_GIF: {
1190 ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); 1168 ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 } 1202 }
1225 readResult = pGifModule->ReadHeader( 1203 readResult = pGifModule->ReadHeader(
1226 m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber, 1204 m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber,
1227 (void**)&m_pGifPalette, &m_GifBgIndex, nullptr); 1205 (void**)&m_pGifPalette, &m_GifBgIndex, nullptr);
1228 } 1206 }
1229 if (readResult == 1) { 1207 if (readResult == 1) {
1230 m_SrcBPC = 8; 1208 m_SrcBPC = 8;
1231 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); 1209 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
1232 return TRUE; 1210 return TRUE;
1233 } 1211 }
1234 if (m_pGifContext != NULL) { 1212 if (m_pGifContext) {
1235 pGifModule->Finish(m_pGifContext); 1213 pGifModule->Finish(m_pGifContext);
1236 m_pGifContext = NULL; 1214 m_pGifContext = NULL;
1237 } 1215 }
1238 m_status = FXCODEC_STATUS_ERR_FORMAT; 1216 m_status = FXCODEC_STATUS_ERR_FORMAT;
1239 return FALSE; 1217 return FALSE;
1240 } break; 1218 } break;
1241 case FXCODEC_IMAGE_TIF: { 1219 case FXCODEC_IMAGE_TIF: {
1242 ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); 1220 ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
1243 if (pTiffModule == NULL) { 1221 if (pTiffModule == NULL) {
1244 m_status = FXCODEC_STATUS_ERR_FORMAT; 1222 m_status = FXCODEC_STATUS_ERR_FORMAT;
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + des_top) + 1682 pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + des_top) +
1705 des_ScanOffet; 1683 des_ScanOffet;
1706 for (int des_col = 0; des_col < m_sizeX; des_col++) { 1684 for (int des_col = 0; des_col < m_sizeX; des_col++) {
1707 switch (pDeviceBitmap->GetFormat()) { 1685 switch (pDeviceBitmap->GetFormat()) {
1708 case FXDIB_Invalid: 1686 case FXDIB_Invalid:
1709 case FXDIB_1bppMask: 1687 case FXDIB_1bppMask:
1710 case FXDIB_1bppRgb: 1688 case FXDIB_1bppRgb:
1711 return; 1689 return;
1712 case FXDIB_8bppMask: 1690 case FXDIB_8bppMask:
1713 case FXDIB_8bppRgb: { 1691 case FXDIB_8bppRgb: {
1714 if (pDeviceBitmap->GetPalette() != NULL) { 1692 if (pDeviceBitmap->GetPalette()) {
1715 return; 1693 return;
1716 } 1694 }
1717 int des_g = 0; 1695 int des_g = 0;
1718 des_g += pWeight->m_Weights[0] * (*scan_src1++); 1696 des_g += pWeight->m_Weights[0] * (*scan_src1++);
1719 des_g += pWeight->m_Weights[1] * (*scan_src2++); 1697 des_g += pWeight->m_Weights[1] * (*scan_src2++);
1720 *scan_des++ = (uint8_t)(des_g >> 16); 1698 *scan_des++ = (uint8_t)(des_g >> 16);
1721 } break; 1699 } break;
1722 case FXDIB_Rgb: 1700 case FXDIB_Rgb:
1723 case FXDIB_Rgb32: { 1701 case FXDIB_Rgb32: {
1724 FX_DWORD des_b = 0, des_g = 0, des_r = 0; 1702 FX_DWORD des_b = 0, des_g = 0, des_r = 0;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 } 1807 }
1830 if (pPause && pPause->NeedToPauseNow()) { 1808 if (pPause && pPause->NeedToPauseNow()) {
1831 return m_status = FXCODEC_STATUS_FRAME_TOBECONTINUE; 1809 return m_status = FXCODEC_STATUS_FRAME_TOBECONTINUE;
1832 } 1810 }
1833 readResult = pGifModule->LoadFrameInfo(m_pGifContext, &m_FrameNumber); 1811 readResult = pGifModule->LoadFrameInfo(m_pGifContext, &m_FrameNumber);
1834 } 1812 }
1835 if (readResult == 1) { 1813 if (readResult == 1) {
1836 frames = m_FrameNumber; 1814 frames = m_FrameNumber;
1837 return m_status = FXCODEC_STATUS_DECODE_READY; 1815 return m_status = FXCODEC_STATUS_DECODE_READY;
1838 } 1816 }
1839 if (m_pGifContext != NULL) { 1817 if (m_pGifContext) {
1840 pGifModule->Finish(m_pGifContext); 1818 pGifModule->Finish(m_pGifContext);
1841 m_pGifContext = NULL; 1819 m_pGifContext = NULL;
1842 } 1820 }
1843 return m_status = FXCODEC_STATUS_ERROR; 1821 return m_status = FXCODEC_STATUS_ERROR;
1844 } 1822 }
1845 } break; 1823 } break;
1846 default:; 1824 default:;
1847 } 1825 }
1848 return FXCODEC_STATUS_ERROR; 1826 return FXCODEC_STATUS_ERROR;
1849 } 1827 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR; 1892 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR;
1915 if (!JpegReadMoreData(pJpegModule, error_status)) { 1893 if (!JpegReadMoreData(pJpegModule, error_status)) {
1916 m_pDeviceBitmap = NULL; 1894 m_pDeviceBitmap = NULL;
1917 m_pFile = NULL; 1895 m_pFile = NULL;
1918 return m_status = error_status; 1896 return m_status = error_status;
1919 } 1897 }
1920 bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale); 1898 bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale);
1921 } 1899 }
1922 int scanline_size = (m_SrcWidth + down_scale - 1) / down_scale; 1900 int scanline_size = (m_SrcWidth + down_scale - 1) / down_scale;
1923 scanline_size = (scanline_size * m_SrcComponents + 3) / 4 * 4; 1901 scanline_size = (scanline_size * m_SrcComponents + 3) / 4 * 4;
1924 if (m_pDecodeBuf != NULL) { 1902 FX_Free(m_pDecodeBuf);
1925 FX_Free(m_pDecodeBuf);
1926 m_pDecodeBuf = NULL;
1927 }
1928 m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size); 1903 m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size);
1929 if (m_pDecodeBuf == NULL) {
1930 m_pDeviceBitmap = NULL;
1931 m_pFile = NULL;
1932 return m_status = FXCODEC_STATUS_ERR_MEMORY;
1933 }
1934 FXSYS_memset(m_pDecodeBuf, 0, scanline_size); 1904 FXSYS_memset(m_pDecodeBuf, 0, scanline_size);
1935 m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0, 1905 m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0,
1936 m_clipBox.Width(), m_bInterpol); 1906 m_clipBox.Width(), m_bInterpol);
1937 m_WeightVert.Calc(m_sizeY, m_clipBox.Height()); 1907 m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
1938 switch (m_SrcComponents) { 1908 switch (m_SrcComponents) {
1939 case 1: 1909 case 1:
1940 m_SrcFormat = FXCodec_8bppGray; 1910 m_SrcFormat = FXCodec_8bppGray;
1941 break; 1911 break;
1942 case 3: 1912 case 3:
1943 m_SrcFormat = FXCodec_Rgb; 1913 m_SrcFormat = FXCodec_Rgb;
1944 break; 1914 break;
1945 case 4: 1915 case 4:
1946 m_SrcFormat = FXCodec_Cmyk; 1916 m_SrcFormat = FXCodec_Cmyk;
1947 break; 1917 break;
1948 } 1918 }
1949 GetTransMethod(pDIBitmap->GetFormat(), m_SrcFormat); 1919 GetTransMethod(pDIBitmap->GetFormat(), m_SrcFormat);
1950 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 1920 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
1951 } break; 1921 } break;
1952 case FXCODEC_IMAGE_PNG: { 1922 case FXCODEC_IMAGE_PNG: {
1953 ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); 1923 ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
1954 if (pPngModule == NULL) { 1924 if (pPngModule == NULL) {
1955 m_pDeviceBitmap = NULL; 1925 m_pDeviceBitmap = NULL;
1956 m_pFile = NULL; 1926 m_pFile = NULL;
1957 return m_status = FXCODEC_STATUS_ERR_MEMORY; 1927 return m_status = FXCODEC_STATUS_ERR_MEMORY;
1958 } 1928 }
1959 if (m_pPngContext != NULL) { 1929 if (m_pPngContext) {
1960 pPngModule->Finish(m_pPngContext); 1930 pPngModule->Finish(m_pPngContext);
1961 m_pPngContext = NULL; 1931 m_pPngContext = NULL;
1962 } 1932 }
1963 m_pPngContext = pPngModule->Start((void*)this); 1933 m_pPngContext = pPngModule->Start((void*)this);
1964 if (m_pPngContext == NULL) { 1934 if (m_pPngContext == NULL) {
1965 m_pDeviceBitmap = NULL; 1935 m_pDeviceBitmap = NULL;
1966 m_pFile = NULL; 1936 m_pFile = NULL;
1967 return m_status = FXCODEC_STATUS_ERR_MEMORY; 1937 return m_status = FXCODEC_STATUS_ERR_MEMORY;
1968 } 1938 }
1969 m_offSet = 0; 1939 m_offSet = 0;
(...skipping 13 matching lines...) Expand all
1983 m_SrcFormat = FXCodec_Argb; 1953 m_SrcFormat = FXCodec_Argb;
1984 break; 1954 break;
1985 default: { 1955 default: {
1986 m_pDeviceBitmap = NULL; 1956 m_pDeviceBitmap = NULL;
1987 m_pFile = NULL; 1957 m_pFile = NULL;
1988 return m_status = FXCODEC_STATUS_ERR_PARAMS; 1958 return m_status = FXCODEC_STATUS_ERR_PARAMS;
1989 } 1959 }
1990 } 1960 }
1991 GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat); 1961 GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
1992 int scanline_size = (m_SrcWidth * m_SrcComponents + 3) / 4 * 4; 1962 int scanline_size = (m_SrcWidth * m_SrcComponents + 3) / 4 * 4;
1993 if (m_pDecodeBuf != NULL) { 1963 FX_Free(m_pDecodeBuf);
1994 FX_Free(m_pDecodeBuf);
1995 m_pDecodeBuf = NULL;
1996 }
1997 m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size); 1964 m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size);
1998 if (m_pDecodeBuf == NULL) {
1999 m_pDeviceBitmap = NULL;
2000 m_pFile = NULL;
2001 return m_status = FXCODEC_STATUS_ERR_MEMORY;
2002 }
2003 FXSYS_memset(m_pDecodeBuf, 0, scanline_size); 1965 FXSYS_memset(m_pDecodeBuf, 0, scanline_size);
2004 m_WeightHorzOO.Calc(m_sizeX, m_clipBox.Width(), m_bInterpol); 1966 m_WeightHorzOO.Calc(m_sizeX, m_clipBox.Width(), m_bInterpol);
2005 m_WeightVert.Calc(m_sizeY, m_clipBox.Height()); 1967 m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
2006 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 1968 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
2007 } break; 1969 } break;
2008 case FXCODEC_IMAGE_GIF: { 1970 case FXCODEC_IMAGE_GIF: {
2009 ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); 1971 ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
2010 if (pGifModule == NULL) { 1972 if (pGifModule == NULL) {
2011 m_pDeviceBitmap = NULL; 1973 m_pDeviceBitmap = NULL;
2012 m_pFile = NULL; 1974 m_pFile = NULL;
2013 return m_status = FXCODEC_STATUS_ERR_MEMORY; 1975 return m_status = FXCODEC_STATUS_ERR_MEMORY;
2014 } 1976 }
2015 m_SrcFormat = FXCodec_8bppRgb; 1977 m_SrcFormat = FXCodec_8bppRgb;
2016 GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat); 1978 GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
2017 int scanline_size = (m_SrcWidth + 3) / 4 * 4; 1979 int scanline_size = (m_SrcWidth + 3) / 4 * 4;
2018 if (m_pDecodeBuf != NULL) { 1980 FX_Free(m_pDecodeBuf);
2019 FX_Free(m_pDecodeBuf);
2020 m_pDecodeBuf = NULL;
2021 }
2022 m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size); 1981 m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size);
2023 if (m_pDecodeBuf == NULL) {
2024 m_pDeviceBitmap = NULL;
2025 m_pFile = NULL;
2026 return m_status = FXCODEC_STATUS_ERR_MEMORY;
2027 }
2028 FXSYS_memset(m_pDecodeBuf, 0, scanline_size); 1982 FXSYS_memset(m_pDecodeBuf, 0, scanline_size);
2029 m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0, 1983 m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0,
2030 m_clipBox.Width(), m_bInterpol); 1984 m_clipBox.Width(), m_bInterpol);
2031 m_WeightVert.Calc(m_sizeY, m_clipBox.Height()); 1985 m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
2032 m_FrameCur = frames; 1986 m_FrameCur = frames;
2033 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 1987 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
2034 } break; 1988 } break;
2035 case FXCODEC_IMAGE_BMP: { 1989 case FXCODEC_IMAGE_BMP: {
2036 ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); 1990 ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
2037 if (pBmpModule == NULL) { 1991 if (pBmpModule == NULL) {
2038 m_pDeviceBitmap = NULL; 1992 m_pDeviceBitmap = NULL;
2039 m_pFile = NULL; 1993 m_pFile = NULL;
2040 return m_status = FXCODEC_STATUS_ERR_MEMORY; 1994 return m_status = FXCODEC_STATUS_ERR_MEMORY;
2041 } 1995 }
2042 switch (m_SrcComponents) { 1996 switch (m_SrcComponents) {
2043 case 1: 1997 case 1:
2044 m_SrcFormat = FXCodec_8bppRgb; 1998 m_SrcFormat = FXCodec_8bppRgb;
2045 break; 1999 break;
2046 case 3: 2000 case 3:
2047 m_SrcFormat = FXCodec_Rgb; 2001 m_SrcFormat = FXCodec_Rgb;
2048 break; 2002 break;
2049 case 4: 2003 case 4:
2050 m_SrcFormat = FXCodec_Rgb32; 2004 m_SrcFormat = FXCodec_Rgb32;
2051 break; 2005 break;
2052 } 2006 }
2053 GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat); 2007 GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
2054 m_ScanlineSize = (m_SrcWidth * m_SrcComponents + 3) / 4 * 4; 2008 m_ScanlineSize = (m_SrcWidth * m_SrcComponents + 3) / 4 * 4;
2055 if (m_pDecodeBuf != NULL) { 2009 FX_Free(m_pDecodeBuf);
2056 FX_Free(m_pDecodeBuf);
2057 m_pDecodeBuf = NULL;
2058 }
2059 m_pDecodeBuf = FX_Alloc(uint8_t, m_ScanlineSize); 2010 m_pDecodeBuf = FX_Alloc(uint8_t, m_ScanlineSize);
2060 if (m_pDecodeBuf == NULL) {
2061 m_pDeviceBitmap = NULL;
2062 m_pFile = NULL;
2063 return m_status = FXCODEC_STATUS_ERR_MEMORY;
2064 }
2065 FXSYS_memset(m_pDecodeBuf, 0, m_ScanlineSize); 2011 FXSYS_memset(m_pDecodeBuf, 0, m_ScanlineSize);
2066 m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0, 2012 m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0,
2067 m_clipBox.Width(), m_bInterpol); 2013 m_clipBox.Width(), m_bInterpol);
2068 m_WeightVert.Calc(m_sizeY, m_clipBox.Height()); 2014 m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
2069 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 2015 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
2070 } break; 2016 } break;
2071 case FXCODEC_IMAGE_TIF: 2017 case FXCODEC_IMAGE_TIF:
2072 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 2018 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
2073 default: 2019 default:
2074 break; 2020 break;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 } 2056 }
2111 } 2057 }
2112 } break; 2058 } break;
2113 case FXCODEC_IMAGE_PNG: { 2059 case FXCODEC_IMAGE_PNG: {
2114 ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); 2060 ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
2115 while (TRUE) { 2061 while (TRUE) {
2116 FX_DWORD remain_size = (FX_DWORD)m_pFile->GetSize() - m_offSet; 2062 FX_DWORD remain_size = (FX_DWORD)m_pFile->GetSize() - m_offSet;
2117 FX_DWORD input_size = 2063 FX_DWORD input_size =
2118 remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size; 2064 remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size;
2119 if (input_size == 0) { 2065 if (input_size == 0) {
2120 if (m_pPngContext != NULL) { 2066 if (m_pPngContext) {
2121 pPngModule->Finish(m_pPngContext); 2067 pPngModule->Finish(m_pPngContext);
2122 } 2068 }
2123 m_pPngContext = NULL; 2069 m_pPngContext = NULL;
2124 m_pDeviceBitmap = NULL; 2070 m_pDeviceBitmap = NULL;
2125 m_pFile = NULL; 2071 m_pFile = NULL;
2126 return m_status = FXCODEC_STATUS_DECODE_FINISH; 2072 return m_status = FXCODEC_STATUS_DECODE_FINISH;
2127 } 2073 }
2128 if (m_pSrcBuf != NULL && input_size > m_SrcSize) { 2074 if (m_pSrcBuf && input_size > m_SrcSize) {
2129 FX_Free(m_pSrcBuf); 2075 FX_Free(m_pSrcBuf);
2130 m_pSrcBuf = FX_Alloc(uint8_t, input_size); 2076 m_pSrcBuf = FX_Alloc(uint8_t, input_size);
2131 if (m_pSrcBuf == NULL) {
2132 m_pDeviceBitmap = NULL;
2133 m_pFile = NULL;
2134 return m_status = FXCODEC_STATUS_ERR_MEMORY;
2135 }
2136 FXSYS_memset(m_pSrcBuf, 0, input_size); 2077 FXSYS_memset(m_pSrcBuf, 0, input_size);
2137 m_SrcSize = input_size; 2078 m_SrcSize = input_size;
2138 } 2079 }
2139 FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); 2080 FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size);
2140 if (!bResult) { 2081 if (!bResult) {
2141 m_pDeviceBitmap = NULL; 2082 m_pDeviceBitmap = NULL;
2142 m_pFile = NULL; 2083 m_pFile = NULL;
2143 return m_status = FXCODEC_STATUS_ERR_READ; 2084 return m_status = FXCODEC_STATUS_ERR_READ;
2144 } 2085 }
2145 m_offSet += input_size; 2086 m_offSet += input_size;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 } 2286 }
2346 } break; 2287 } break;
2347 default: 2288 default:
2348 break; 2289 break;
2349 } 2290 }
2350 return FXCODEC_STATUS_ERROR; 2291 return FXCODEC_STATUS_ERROR;
2351 } 2292 }
2352 ICodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() { 2293 ICodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() {
2353 return new CCodec_ProgressiveDecoder(this); 2294 return new CCodec_ProgressiveDecoder(this);
2354 } 2295 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_progress.h ('k') | core/src/fxcodec/lbmp/fx_bmp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698