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

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

Issue 1876023003: Remove ICodec_* Interfaces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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/fxcodec/codec/fx_codec_progress.h ('k') | core/fxcodec/codec/fx_codec_tiff.cpp » ('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/fxcodec/codec/fx_codec_progress.h" 7 #include "core/fxcodec/codec/include/ccodec_progressivedecoder.h"
8 8
9 #include "core/fxcodec/include/fx_codec.h" 9 #include "core/fxcodec/include/fx_codec.h"
10 #include "core/fxge/include/fx_dib.h" 10 #include "core/fxge/include/fx_dib.h"
11 11
12 void CFXCODEC_WeightTable::Calc(int dest_len, 12 #define FXCODEC_BLOCK_SIZE 4096
13 int dest_min, 13 #define FXCODEC_PNG_GAMMA 2.2
14 int dest_max, 14
15 int src_len, 15 #if _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
16 int src_min, 16 #undef FXCODEC_PNG_GAMMA
17 int src_max, 17 #define FXCODEC_PNG_GAMMA 1.7
18 FX_BOOL bInterpol) { 18 #endif
19
20 void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len,
21 int dest_min,
22 int dest_max,
23 int src_len,
24 int src_min,
25 int src_max,
26 FX_BOOL bInterpol) {
19 if (m_pWeightTables) { 27 if (m_pWeightTables) {
20 FX_Free(m_pWeightTables); 28 FX_Free(m_pWeightTables);
21 } 29 }
22 double scale, base; 30 double scale, base;
23 scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len; 31 scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len;
24 if (dest_len < 0) { 32 if (dest_len < 0) {
25 base = (FX_FLOAT)(src_len); 33 base = (FX_FLOAT)(src_len);
26 } else { 34 } else {
27 base = 0.0f; 35 base = 0.0f;
28 } 36 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 double weight = area_start >= area_end ? 0.0f : area_end - area_start; 114 double weight = area_start >= area_end ? 0.0f : area_end - area_start;
107 if (weight == 0 && j == end_i) { 115 if (weight == 0 && j == end_i) {
108 pixel_weights.m_SrcEnd--; 116 pixel_weights.m_SrcEnd--;
109 break; 117 break;
110 } 118 }
111 pixel_weights.m_Weights[j - start_i] = 119 pixel_weights.m_Weights[j - start_i] =
112 FXSYS_round((FX_FLOAT)(weight * 65536)); 120 FXSYS_round((FX_FLOAT)(weight * 65536));
113 } 121 }
114 } 122 }
115 } 123 }
116 void CFXCODEC_HorzTable::Calc(int dest_len, int src_len, FX_BOOL bInterpol) { 124 void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len,
125 int src_len,
126 FX_BOOL bInterpol) {
117 if (m_pWeightTables) { 127 if (m_pWeightTables) {
118 FX_Free(m_pWeightTables); 128 FX_Free(m_pWeightTables);
119 } 129 }
120 double scale = (double)dest_len / (double)src_len; 130 double scale = (double)dest_len / (double)src_len;
121 m_ItemSize = sizeof(int) * 4; 131 m_ItemSize = sizeof(int) * 4;
122 int size = dest_len * m_ItemSize + 4; 132 int size = dest_len * m_ItemSize + 4;
123 m_pWeightTables = FX_Alloc(uint8_t, size); 133 m_pWeightTables = FX_Alloc(uint8_t, size);
124 if (m_pWeightTables == NULL) { 134 if (m_pWeightTables == NULL) {
125 return; 135 return;
126 } 136 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 for (int des_col = 0; des_col < dest_len; des_col++) { 176 for (int des_col = 0; des_col < dest_len; des_col++) {
167 double src_col_f = des_col / scale; 177 double src_col_f = des_col / scale;
168 int src_col = FXSYS_round((FX_FLOAT)src_col_f); 178 int src_col = FXSYS_round((FX_FLOAT)src_col_f);
169 PixelWeight* pWeight = 179 PixelWeight* pWeight =
170 (PixelWeight*)(m_pWeightTables + des_col * m_ItemSize); 180 (PixelWeight*)(m_pWeightTables + des_col * m_ItemSize);
171 pWeight->m_SrcStart = pWeight->m_SrcEnd = src_col; 181 pWeight->m_SrcStart = pWeight->m_SrcEnd = src_col;
172 pWeight->m_Weights[0] = 65536; 182 pWeight->m_Weights[0] = 65536;
173 pWeight->m_Weights[1] = 0; 183 pWeight->m_Weights[1] = 0;
174 } 184 }
175 } 185 }
176 void CFXCODEC_VertTable::Calc(int dest_len, int src_len) { 186 void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
187 int src_len) {
177 if (m_pWeightTables) { 188 if (m_pWeightTables) {
178 FX_Free(m_pWeightTables); 189 FX_Free(m_pWeightTables);
179 } 190 }
180 double scale = (double)dest_len / (double)src_len; 191 double scale = (double)dest_len / (double)src_len;
181 m_ItemSize = sizeof(int) * 4; 192 m_ItemSize = sizeof(int) * 4;
182 int size = dest_len * m_ItemSize + 4; 193 int size = dest_len * m_ItemSize + 4;
183 m_pWeightTables = FX_Alloc(uint8_t, size); 194 m_pWeightTables = FX_Alloc(uint8_t, size);
184 if (m_pWeightTables == NULL) { 195 if (m_pWeightTables == NULL) {
185 return; 196 return;
186 } 197 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 m_pCodecMgr->GetBmpModule()->Finish(m_pBmpContext); 298 m_pCodecMgr->GetBmpModule()->Finish(m_pBmpContext);
288 } 299 }
289 if (m_pTiffContext) { 300 if (m_pTiffContext) {
290 m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext); 301 m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext);
291 } 302 }
292 FX_Free(m_pSrcBuf); 303 FX_Free(m_pSrcBuf);
293 FX_Free(m_pDecodeBuf); 304 FX_Free(m_pDecodeBuf);
294 FX_Free(m_pSrcPalette); 305 FX_Free(m_pSrcPalette);
295 } 306 }
296 FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData( 307 FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData(
297 ICodec_JpegModule* pJpegModule, 308 CCodec_JpegModule* pJpegModule,
298 FXCODEC_STATUS& err_status) { 309 FXCODEC_STATUS& err_status) {
299 uint32_t dwSize = (uint32_t)m_pFile->GetSize(); 310 uint32_t dwSize = (uint32_t)m_pFile->GetSize();
300 if (dwSize <= m_offSet) { 311 if (dwSize <= m_offSet) {
301 return FALSE; 312 return FALSE;
302 } 313 }
303 dwSize = dwSize - m_offSet; 314 dwSize = dwSize - m_offSet;
304 uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, NULL); 315 uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, NULL);
305 if (dwAvail == m_SrcSize) { 316 if (dwAvail == m_SrcSize) {
306 if (dwSize > FXCODEC_BLOCK_SIZE) { 317 if (dwSize > FXCODEC_BLOCK_SIZE) {
307 dwSize = FXCODEC_BLOCK_SIZE; 318 dwSize = FXCODEC_BLOCK_SIZE;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 pCodec->m_SrcFormat); 556 pCodec->m_SrcFormat);
546 if (pCodec->m_SrcPassNumber == 1 && scale_y > 1.0) { 557 if (pCodec->m_SrcPassNumber == 1 && scale_y > 1.0) {
547 pCodec->ResampleVert(pDIBitmap, scale_y, des_row); 558 pCodec->ResampleVert(pDIBitmap, scale_y, des_row);
548 return; 559 return;
549 } 560 }
550 if (pass == 6 && scale_y > 1.0) { 561 if (pass == 6 && scale_y > 1.0) {
551 pCodec->ResampleVert(pDIBitmap, scale_y, des_row); 562 pCodec->ResampleVert(pDIBitmap, scale_y, des_row);
552 } 563 }
553 } 564 }
554 } 565 }
555 FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(ICodec_GifModule* pGifModule, 566 FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule,
556 FXCODEC_STATUS& err_status) { 567 FXCODEC_STATUS& err_status) {
557 uint32_t dwSize = (uint32_t)m_pFile->GetSize(); 568 uint32_t dwSize = (uint32_t)m_pFile->GetSize();
558 if (dwSize <= m_offSet) { 569 if (dwSize <= m_offSet) {
559 return FALSE; 570 return FALSE;
560 } 571 }
561 dwSize = dwSize - m_offSet; 572 dwSize = dwSize - m_offSet;
562 uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, NULL); 573 uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, NULL);
563 if (dwAvail == m_SrcSize) { 574 if (dwAvail == m_SrcSize) {
564 if (dwSize > FXCODEC_BLOCK_SIZE) { 575 if (dwSize > FXCODEC_BLOCK_SIZE) {
565 dwSize = FXCODEC_BLOCK_SIZE; 576 dwSize = FXCODEC_BLOCK_SIZE;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 return; 838 return;
828 } 839 }
829 } 840 }
830 } 841 }
831 int des_bottom = des_top + m_sizeY - 1; 842 int des_bottom = des_top + m_sizeY - 1;
832 if (des_row + (int)(2 * scale_y) >= des_bottom && 843 if (des_row + (int)(2 * scale_y) >= des_bottom &&
833 des_row + (int)scale_y < des_bottom) { 844 des_row + (int)scale_y < des_bottom) {
834 GifDoubleLineResampleVert(pDeviceBitmap, scale_y, des_row + (int)scale_y); 845 GifDoubleLineResampleVert(pDeviceBitmap, scale_y, des_row + (int)scale_y);
835 } 846 }
836 } 847 }
837 FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(ICodec_BmpModule* pBmpModule, 848 FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule,
838 FXCODEC_STATUS& err_status) { 849 FXCODEC_STATUS& err_status) {
839 uint32_t dwSize = (uint32_t)m_pFile->GetSize(); 850 uint32_t dwSize = (uint32_t)m_pFile->GetSize();
840 if (dwSize <= m_offSet) { 851 if (dwSize <= m_offSet) {
841 return FALSE; 852 return FALSE;
842 } 853 }
843 dwSize = dwSize - m_offSet; 854 dwSize = dwSize - m_offSet;
844 uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, NULL); 855 uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, NULL);
845 if (dwAvail == m_SrcSize) { 856 if (dwAvail == m_SrcSize) {
846 if (dwSize > FXCODEC_BLOCK_SIZE) { 857 if (dwSize > FXCODEC_BLOCK_SIZE) {
847 dwSize = FXCODEC_BLOCK_SIZE; 858 dwSize = FXCODEC_BLOCK_SIZE;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 uint32_t size = (uint32_t)m_pFile->GetSize(); 1012 uint32_t size = (uint32_t)m_pFile->GetSize();
1002 if (size > FXCODEC_BLOCK_SIZE) { 1013 if (size > FXCODEC_BLOCK_SIZE) {
1003 size = FXCODEC_BLOCK_SIZE; 1014 size = FXCODEC_BLOCK_SIZE;
1004 } 1015 }
1005 FX_Free(m_pSrcBuf); 1016 FX_Free(m_pSrcBuf);
1006 m_pSrcBuf = FX_Alloc(uint8_t, size); 1017 m_pSrcBuf = FX_Alloc(uint8_t, size);
1007 FXSYS_memset(m_pSrcBuf, 0, size); 1018 FXSYS_memset(m_pSrcBuf, 0, size);
1008 m_SrcSize = size; 1019 m_SrcSize = size;
1009 switch (imageType) { 1020 switch (imageType) {
1010 case FXCODEC_IMAGE_BMP: { 1021 case FXCODEC_IMAGE_BMP: {
1011 ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); 1022 CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
1012 if (pBmpModule == NULL) { 1023 if (pBmpModule == NULL) {
1013 m_status = FXCODEC_STATUS_ERR_MEMORY; 1024 m_status = FXCODEC_STATUS_ERR_MEMORY;
1014 return FALSE; 1025 return FALSE;
1015 } 1026 }
1016 pBmpModule->InputImagePositionBufCallback = 1027 pBmpModule->InputImagePositionBufCallback =
1017 BmpInputImagePositionBufCallback; 1028 BmpInputImagePositionBufCallback;
1018 pBmpModule->ReadScanlineCallback = BmpReadScanlineCallback; 1029 pBmpModule->ReadScanlineCallback = BmpReadScanlineCallback;
1019 m_pBmpContext = pBmpModule->Start((void*)this); 1030 m_pBmpContext = pBmpModule->Start((void*)this);
1020 if (m_pBmpContext == NULL) { 1031 if (m_pBmpContext == NULL) {
1021 m_status = FXCODEC_STATUS_ERR_MEMORY; 1032 m_status = FXCODEC_STATUS_ERR_MEMORY;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 return TRUE; 1067 return TRUE;
1057 } 1068 }
1058 if (m_pBmpContext) { 1069 if (m_pBmpContext) {
1059 pBmpModule->Finish(m_pBmpContext); 1070 pBmpModule->Finish(m_pBmpContext);
1060 m_pBmpContext = NULL; 1071 m_pBmpContext = NULL;
1061 } 1072 }
1062 m_status = FXCODEC_STATUS_ERR_FORMAT; 1073 m_status = FXCODEC_STATUS_ERR_FORMAT;
1063 return FALSE; 1074 return FALSE;
1064 } break; 1075 } break;
1065 case FXCODEC_IMAGE_JPG: { 1076 case FXCODEC_IMAGE_JPG: {
1066 ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); 1077 CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
1067 if (pJpegModule == NULL) { 1078 if (pJpegModule == NULL) {
1068 m_status = FXCODEC_STATUS_ERR_MEMORY; 1079 m_status = FXCODEC_STATUS_ERR_MEMORY;
1069 return FALSE; 1080 return FALSE;
1070 } 1081 }
1071 m_pJpegContext = pJpegModule->Start(); 1082 m_pJpegContext = pJpegModule->Start();
1072 if (m_pJpegContext == NULL) { 1083 if (m_pJpegContext == NULL) {
1073 m_status = FXCODEC_STATUS_ERR_MEMORY; 1084 m_status = FXCODEC_STATUS_ERR_MEMORY;
1074 return FALSE; 1085 return FALSE;
1075 } 1086 }
1076 FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); 1087 FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size);
(...skipping 22 matching lines...) Expand all
1099 return TRUE; 1110 return TRUE;
1100 } 1111 }
1101 if (m_pJpegContext) { 1112 if (m_pJpegContext) {
1102 pJpegModule->Finish(m_pJpegContext); 1113 pJpegModule->Finish(m_pJpegContext);
1103 m_pJpegContext = NULL; 1114 m_pJpegContext = NULL;
1104 } 1115 }
1105 m_status = FXCODEC_STATUS_ERR_FORMAT; 1116 m_status = FXCODEC_STATUS_ERR_FORMAT;
1106 return FALSE; 1117 return FALSE;
1107 } break; 1118 } break;
1108 case FXCODEC_IMAGE_PNG: { 1119 case FXCODEC_IMAGE_PNG: {
1109 ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); 1120 CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
1110 if (pPngModule == NULL) { 1121 if (pPngModule == NULL) {
1111 m_status = FXCODEC_STATUS_ERR_MEMORY; 1122 m_status = FXCODEC_STATUS_ERR_MEMORY;
1112 return FALSE; 1123 return FALSE;
1113 } 1124 }
1114 pPngModule->ReadHeaderCallback = 1125 pPngModule->ReadHeaderCallback =
1115 CCodec_ProgressiveDecoder::PngReadHeaderFunc; 1126 CCodec_ProgressiveDecoder::PngReadHeaderFunc;
1116 pPngModule->AskScanlineBufCallback = 1127 pPngModule->AskScanlineBufCallback =
1117 CCodec_ProgressiveDecoder::PngAskScanlineBufFunc; 1128 CCodec_ProgressiveDecoder::PngAskScanlineBufFunc;
1118 pPngModule->FillScanlineBufCompletedCallback = 1129 pPngModule->FillScanlineBufCompletedCallback =
1119 CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc; 1130 CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 if (m_pPngContext) { 1171 if (m_pPngContext) {
1161 pPngModule->Finish(m_pPngContext); 1172 pPngModule->Finish(m_pPngContext);
1162 m_pPngContext = NULL; 1173 m_pPngContext = NULL;
1163 } 1174 }
1164 if (m_SrcPassNumber == 0) { 1175 if (m_SrcPassNumber == 0) {
1165 m_status = FXCODEC_STATUS_ERR_FORMAT; 1176 m_status = FXCODEC_STATUS_ERR_FORMAT;
1166 return FALSE; 1177 return FALSE;
1167 } 1178 }
1168 } break; 1179 } break;
1169 case FXCODEC_IMAGE_GIF: { 1180 case FXCODEC_IMAGE_GIF: {
1170 ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); 1181 CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
1171 if (pGifModule == NULL) { 1182 if (pGifModule == NULL) {
1172 m_status = FXCODEC_STATUS_ERR_MEMORY; 1183 m_status = FXCODEC_STATUS_ERR_MEMORY;
1173 return FALSE; 1184 return FALSE;
1174 } 1185 }
1175 pGifModule->RecordCurrentPositionCallback = 1186 pGifModule->RecordCurrentPositionCallback =
1176 CCodec_ProgressiveDecoder::GifRecordCurrentPositionCallback; 1187 CCodec_ProgressiveDecoder::GifRecordCurrentPositionCallback;
1177 pGifModule->AskLocalPaletteBufCallback = 1188 pGifModule->AskLocalPaletteBufCallback =
1178 CCodec_ProgressiveDecoder::GifAskLocalPaletteBufCallback; 1189 CCodec_ProgressiveDecoder::GifAskLocalPaletteBufCallback;
1179 pGifModule->InputRecordPositionBufCallback = 1190 pGifModule->InputRecordPositionBufCallback =
1180 CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback; 1191 CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 return TRUE; 1223 return TRUE;
1213 } 1224 }
1214 if (m_pGifContext) { 1225 if (m_pGifContext) {
1215 pGifModule->Finish(m_pGifContext); 1226 pGifModule->Finish(m_pGifContext);
1216 m_pGifContext = NULL; 1227 m_pGifContext = NULL;
1217 } 1228 }
1218 m_status = FXCODEC_STATUS_ERR_FORMAT; 1229 m_status = FXCODEC_STATUS_ERR_FORMAT;
1219 return FALSE; 1230 return FALSE;
1220 } break; 1231 } break;
1221 case FXCODEC_IMAGE_TIF: { 1232 case FXCODEC_IMAGE_TIF: {
1222 ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); 1233 CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
1223 if (pTiffModule == NULL) { 1234 if (pTiffModule == NULL) {
1224 m_status = FXCODEC_STATUS_ERR_FORMAT; 1235 m_status = FXCODEC_STATUS_ERR_FORMAT;
1225 return FALSE; 1236 return FALSE;
1226 } 1237 }
1227 m_pTiffContext = pTiffModule->CreateDecoder(m_pFile); 1238 m_pTiffContext = pTiffModule->CreateDecoder(m_pFile);
1228 if (m_pTiffContext == NULL) { 1239 if (m_pTiffContext == NULL) {
1229 m_status = FXCODEC_STATUS_ERR_FORMAT; 1240 m_status = FXCODEC_STATUS_ERR_FORMAT;
1230 return FALSE; 1241 return FALSE;
1231 } 1242 }
1232 int32_t frames = 0; 1243 int32_t frames = 0;
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 return FXCODEC_STATUS_ERROR; 1803 return FXCODEC_STATUS_ERROR;
1793 } 1804 }
1794 switch (m_imagType) { 1805 switch (m_imagType) {
1795 case FXCODEC_IMAGE_BMP: 1806 case FXCODEC_IMAGE_BMP:
1796 case FXCODEC_IMAGE_JPG: 1807 case FXCODEC_IMAGE_JPG:
1797 case FXCODEC_IMAGE_PNG: 1808 case FXCODEC_IMAGE_PNG:
1798 case FXCODEC_IMAGE_TIF: 1809 case FXCODEC_IMAGE_TIF:
1799 frames = m_FrameNumber = 1; 1810 frames = m_FrameNumber = 1;
1800 return m_status = FXCODEC_STATUS_DECODE_READY; 1811 return m_status = FXCODEC_STATUS_DECODE_READY;
1801 case FXCODEC_IMAGE_GIF: { 1812 case FXCODEC_IMAGE_GIF: {
1802 ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); 1813 CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
1803 while (TRUE) { 1814 while (TRUE) {
1804 int32_t readResult = 1815 int32_t readResult =
1805 pGifModule->LoadFrameInfo(m_pGifContext, &m_FrameNumber); 1816 pGifModule->LoadFrameInfo(m_pGifContext, &m_FrameNumber);
1806 while (readResult == 2) { 1817 while (readResult == 2) {
1807 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_READ; 1818 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_READ;
1808 if (!GifReadMoreData(pGifModule, error_status)) { 1819 if (!GifReadMoreData(pGifModule, error_status)) {
1809 return error_status; 1820 return error_status;
1810 } 1821 }
1811 if (pPause && pPause->NeedToPauseNow()) { 1822 if (pPause && pPause->NeedToPauseNow()) {
1812 return m_status = FXCODEC_STATUS_FRAME_TOBECONTINUE; 1823 return m_status = FXCODEC_STATUS_FRAME_TOBECONTINUE;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 } 1892 }
1882 if (out_range_y > 0) { 1893 if (out_range_y > 0) {
1883 m_clipBox.bottom -= (int32_t)FXSYS_floor((FX_FLOAT)out_range_y * scaleY); 1894 m_clipBox.bottom -= (int32_t)FXSYS_floor((FX_FLOAT)out_range_y * scaleY);
1884 } 1895 }
1885 } 1896 }
1886 if (m_clipBox.IsEmpty()) { 1897 if (m_clipBox.IsEmpty()) {
1887 return FXCODEC_STATUS_ERR_PARAMS; 1898 return FXCODEC_STATUS_ERR_PARAMS;
1888 } 1899 }
1889 switch (m_imagType) { 1900 switch (m_imagType) {
1890 case FXCODEC_IMAGE_JPG: { 1901 case FXCODEC_IMAGE_JPG: {
1891 ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); 1902 CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
1892 int down_scale = 1; 1903 int down_scale = 1;
1893 GetDownScale(down_scale); 1904 GetDownScale(down_scale);
1894 FX_BOOL bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale); 1905 FX_BOOL bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale);
1895 while (!bStart) { 1906 while (!bStart) {
1896 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR; 1907 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR;
1897 if (!JpegReadMoreData(pJpegModule, error_status)) { 1908 if (!JpegReadMoreData(pJpegModule, error_status)) {
1898 m_pDeviceBitmap = NULL; 1909 m_pDeviceBitmap = NULL;
1899 m_pFile = NULL; 1910 m_pFile = NULL;
1900 return m_status = error_status; 1911 return m_status = error_status;
1901 } 1912 }
(...skipping 15 matching lines...) Expand all
1917 m_SrcFormat = FXCodec_Rgb; 1928 m_SrcFormat = FXCodec_Rgb;
1918 break; 1929 break;
1919 case 4: 1930 case 4:
1920 m_SrcFormat = FXCodec_Cmyk; 1931 m_SrcFormat = FXCodec_Cmyk;
1921 break; 1932 break;
1922 } 1933 }
1923 GetTransMethod(pDIBitmap->GetFormat(), m_SrcFormat); 1934 GetTransMethod(pDIBitmap->GetFormat(), m_SrcFormat);
1924 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 1935 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
1925 } break; 1936 } break;
1926 case FXCODEC_IMAGE_PNG: { 1937 case FXCODEC_IMAGE_PNG: {
1927 ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); 1938 CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
1928 if (pPngModule == NULL) { 1939 if (pPngModule == NULL) {
1929 m_pDeviceBitmap = NULL; 1940 m_pDeviceBitmap = NULL;
1930 m_pFile = NULL; 1941 m_pFile = NULL;
1931 return m_status = FXCODEC_STATUS_ERR_MEMORY; 1942 return m_status = FXCODEC_STATUS_ERR_MEMORY;
1932 } 1943 }
1933 if (m_pPngContext) { 1944 if (m_pPngContext) {
1934 pPngModule->Finish(m_pPngContext); 1945 pPngModule->Finish(m_pPngContext);
1935 m_pPngContext = NULL; 1946 m_pPngContext = NULL;
1936 } 1947 }
1937 m_pPngContext = pPngModule->Start((void*)this); 1948 m_pPngContext = pPngModule->Start((void*)this);
(...skipping 27 matching lines...) Expand all
1965 GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat); 1976 GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
1966 int scanline_size = (m_SrcWidth * m_SrcComponents + 3) / 4 * 4; 1977 int scanline_size = (m_SrcWidth * m_SrcComponents + 3) / 4 * 4;
1967 FX_Free(m_pDecodeBuf); 1978 FX_Free(m_pDecodeBuf);
1968 m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size); 1979 m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size);
1969 FXSYS_memset(m_pDecodeBuf, 0, scanline_size); 1980 FXSYS_memset(m_pDecodeBuf, 0, scanline_size);
1970 m_WeightHorzOO.Calc(m_sizeX, m_clipBox.Width(), m_bInterpol); 1981 m_WeightHorzOO.Calc(m_sizeX, m_clipBox.Width(), m_bInterpol);
1971 m_WeightVert.Calc(m_sizeY, m_clipBox.Height()); 1982 m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
1972 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 1983 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
1973 } break; 1984 } break;
1974 case FXCODEC_IMAGE_GIF: { 1985 case FXCODEC_IMAGE_GIF: {
1975 ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); 1986 CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
1976 if (pGifModule == NULL) { 1987 if (pGifModule == NULL) {
1977 m_pDeviceBitmap = NULL; 1988 m_pDeviceBitmap = NULL;
1978 m_pFile = NULL; 1989 m_pFile = NULL;
1979 return m_status = FXCODEC_STATUS_ERR_MEMORY; 1990 return m_status = FXCODEC_STATUS_ERR_MEMORY;
1980 } 1991 }
1981 m_SrcFormat = FXCodec_8bppRgb; 1992 m_SrcFormat = FXCodec_8bppRgb;
1982 GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat); 1993 GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
1983 int scanline_size = (m_SrcWidth + 3) / 4 * 4; 1994 int scanline_size = (m_SrcWidth + 3) / 4 * 4;
1984 FX_Free(m_pDecodeBuf); 1995 FX_Free(m_pDecodeBuf);
1985 m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size); 1996 m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size);
1986 FXSYS_memset(m_pDecodeBuf, 0, scanline_size); 1997 FXSYS_memset(m_pDecodeBuf, 0, scanline_size);
1987 m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0, 1998 m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0,
1988 m_clipBox.Width(), m_bInterpol); 1999 m_clipBox.Width(), m_bInterpol);
1989 m_WeightVert.Calc(m_sizeY, m_clipBox.Height()); 2000 m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
1990 m_FrameCur = frames; 2001 m_FrameCur = frames;
1991 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 2002 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
1992 } break; 2003 } break;
1993 case FXCODEC_IMAGE_BMP: { 2004 case FXCODEC_IMAGE_BMP: {
1994 ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); 2005 CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
1995 if (pBmpModule == NULL) { 2006 if (pBmpModule == NULL) {
1996 m_pDeviceBitmap = NULL; 2007 m_pDeviceBitmap = NULL;
1997 m_pFile = NULL; 2008 m_pFile = NULL;
1998 return m_status = FXCODEC_STATUS_ERR_MEMORY; 2009 return m_status = FXCODEC_STATUS_ERR_MEMORY;
1999 } 2010 }
2000 switch (m_SrcComponents) { 2011 switch (m_SrcComponents) {
2001 case 1: 2012 case 1:
2002 m_SrcFormat = FXCodec_8bppRgb; 2013 m_SrcFormat = FXCodec_8bppRgb;
2003 break; 2014 break;
2004 case 3: 2015 case 3:
(...skipping 19 matching lines...) Expand all
2024 break; 2035 break;
2025 } 2036 }
2026 return FXCODEC_STATUS_ERROR; 2037 return FXCODEC_STATUS_ERROR;
2027 } 2038 }
2028 FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { 2039 FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
2029 if (m_status != FXCODEC_STATUS_DECODE_TOBECONTINUE) { 2040 if (m_status != FXCODEC_STATUS_DECODE_TOBECONTINUE) {
2030 return FXCODEC_STATUS_ERROR; 2041 return FXCODEC_STATUS_ERROR;
2031 } 2042 }
2032 switch (m_imagType) { 2043 switch (m_imagType) {
2033 case FXCODEC_IMAGE_JPG: { 2044 case FXCODEC_IMAGE_JPG: {
2034 ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); 2045 CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
2035 while (TRUE) { 2046 while (TRUE) {
2036 FX_BOOL readRes = 2047 FX_BOOL readRes =
2037 pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf); 2048 pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf);
2038 while (!readRes) { 2049 while (!readRes) {
2039 FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; 2050 FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
2040 if (!JpegReadMoreData(pJpegModule, error_status)) { 2051 if (!JpegReadMoreData(pJpegModule, error_status)) {
2041 m_pDeviceBitmap = NULL; 2052 m_pDeviceBitmap = NULL;
2042 m_pFile = NULL; 2053 m_pFile = NULL;
2043 return m_status = error_status; 2054 return m_status = error_status;
2044 } 2055 }
2045 readRes = pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf); 2056 readRes = pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf);
2046 } 2057 }
2047 if (m_SrcFormat == FXCodec_Rgb) { 2058 if (m_SrcFormat == FXCodec_Rgb) {
2048 int src_Bpp = (m_SrcFormat & 0xff) >> 3; 2059 int src_Bpp = (m_SrcFormat & 0xff) >> 3;
2049 _RGB2BGR(m_pDecodeBuf + m_clipBox.left * src_Bpp, m_clipBox.Width()); 2060 _RGB2BGR(m_pDecodeBuf + m_clipBox.left * src_Bpp, m_clipBox.Width());
2050 } 2061 }
2051 if (m_SrcRow >= m_clipBox.bottom) { 2062 if (m_SrcRow >= m_clipBox.bottom) {
2052 m_pDeviceBitmap = NULL; 2063 m_pDeviceBitmap = NULL;
2053 m_pFile = NULL; 2064 m_pFile = NULL;
2054 return m_status = FXCODEC_STATUS_DECODE_FINISH; 2065 return m_status = FXCODEC_STATUS_DECODE_FINISH;
2055 } 2066 }
2056 Resample(m_pDeviceBitmap, m_SrcRow, m_pDecodeBuf, m_SrcFormat); 2067 Resample(m_pDeviceBitmap, m_SrcRow, m_pDecodeBuf, m_SrcFormat);
2057 m_SrcRow++; 2068 m_SrcRow++;
2058 if (pPause && pPause->NeedToPauseNow()) { 2069 if (pPause && pPause->NeedToPauseNow()) {
2059 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 2070 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
2060 } 2071 }
2061 } 2072 }
2062 } break; 2073 } break;
2063 case FXCODEC_IMAGE_PNG: { 2074 case FXCODEC_IMAGE_PNG: {
2064 ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); 2075 CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
2065 while (TRUE) { 2076 while (TRUE) {
2066 uint32_t remain_size = (uint32_t)m_pFile->GetSize() - m_offSet; 2077 uint32_t remain_size = (uint32_t)m_pFile->GetSize() - m_offSet;
2067 uint32_t input_size = 2078 uint32_t input_size =
2068 remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size; 2079 remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size;
2069 if (input_size == 0) { 2080 if (input_size == 0) {
2070 if (m_pPngContext) { 2081 if (m_pPngContext) {
2071 pPngModule->Finish(m_pPngContext); 2082 pPngModule->Finish(m_pPngContext);
2072 } 2083 }
2073 m_pPngContext = NULL; 2084 m_pPngContext = NULL;
2074 m_pDeviceBitmap = NULL; 2085 m_pDeviceBitmap = NULL;
(...skipping 19 matching lines...) Expand all
2094 m_pDeviceBitmap = NULL; 2105 m_pDeviceBitmap = NULL;
2095 m_pFile = NULL; 2106 m_pFile = NULL;
2096 return m_status = FXCODEC_STATUS_ERROR; 2107 return m_status = FXCODEC_STATUS_ERROR;
2097 } 2108 }
2098 if (pPause && pPause->NeedToPauseNow()) { 2109 if (pPause && pPause->NeedToPauseNow()) {
2099 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 2110 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
2100 } 2111 }
2101 } 2112 }
2102 } break; 2113 } break;
2103 case FXCODEC_IMAGE_GIF: { 2114 case FXCODEC_IMAGE_GIF: {
2104 ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); 2115 CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
2105 while (TRUE) { 2116 while (TRUE) {
2106 int32_t readRes = 2117 int32_t readRes =
2107 pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr); 2118 pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr);
2108 while (readRes == 2) { 2119 while (readRes == 2) {
2109 FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; 2120 FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
2110 if (!GifReadMoreData(pGifModule, error_status)) { 2121 if (!GifReadMoreData(pGifModule, error_status)) {
2111 m_pDeviceBitmap = NULL; 2122 m_pDeviceBitmap = NULL;
2112 m_pFile = NULL; 2123 m_pFile = NULL;
2113 return m_status = error_status; 2124 return m_status = error_status;
2114 } 2125 }
2115 if (pPause && pPause->NeedToPauseNow()) { 2126 if (pPause && pPause->NeedToPauseNow()) {
2116 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 2127 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
2117 } 2128 }
2118 readRes = pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr); 2129 readRes = pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr);
2119 } 2130 }
2120 if (readRes == 1) { 2131 if (readRes == 1) {
2121 m_pDeviceBitmap = NULL; 2132 m_pDeviceBitmap = NULL;
2122 m_pFile = NULL; 2133 m_pFile = NULL;
2123 return m_status = FXCODEC_STATUS_DECODE_FINISH; 2134 return m_status = FXCODEC_STATUS_DECODE_FINISH;
2124 } 2135 }
2125 m_pDeviceBitmap = NULL; 2136 m_pDeviceBitmap = NULL;
2126 m_pFile = NULL; 2137 m_pFile = NULL;
2127 return m_status = FXCODEC_STATUS_ERROR; 2138 return m_status = FXCODEC_STATUS_ERROR;
2128 } 2139 }
2129 } break; 2140 } break;
2130 case FXCODEC_IMAGE_BMP: { 2141 case FXCODEC_IMAGE_BMP: {
2131 ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); 2142 CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
2132 while (TRUE) { 2143 while (TRUE) {
2133 int32_t readRes = pBmpModule->LoadImage(m_pBmpContext); 2144 int32_t readRes = pBmpModule->LoadImage(m_pBmpContext);
2134 while (readRes == 2) { 2145 while (readRes == 2) {
2135 FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; 2146 FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
2136 if (!BmpReadMoreData(pBmpModule, error_status)) { 2147 if (!BmpReadMoreData(pBmpModule, error_status)) {
2137 m_pDeviceBitmap = NULL; 2148 m_pDeviceBitmap = NULL;
2138 m_pFile = NULL; 2149 m_pFile = NULL;
2139 return m_status = error_status; 2150 return m_status = error_status;
2140 } 2151 }
2141 if (pPause && pPause->NeedToPauseNow()) { 2152 if (pPause && pPause->NeedToPauseNow()) {
2142 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; 2153 return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
2143 } 2154 }
2144 readRes = pBmpModule->LoadImage(m_pBmpContext); 2155 readRes = pBmpModule->LoadImage(m_pBmpContext);
2145 } 2156 }
2146 if (readRes == 1) { 2157 if (readRes == 1) {
2147 m_pDeviceBitmap = NULL; 2158 m_pDeviceBitmap = NULL;
2148 m_pFile = NULL; 2159 m_pFile = NULL;
2149 return m_status = FXCODEC_STATUS_DECODE_FINISH; 2160 return m_status = FXCODEC_STATUS_DECODE_FINISH;
2150 } 2161 }
2151 m_pDeviceBitmap = NULL; 2162 m_pDeviceBitmap = NULL;
2152 m_pFile = NULL; 2163 m_pFile = NULL;
2153 return m_status = FXCODEC_STATUS_ERROR; 2164 return m_status = FXCODEC_STATUS_ERROR;
2154 } 2165 }
2155 } break; 2166 } break;
2156 case FXCODEC_IMAGE_TIF: { 2167 case FXCODEC_IMAGE_TIF: {
2157 ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); 2168 CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
2158 FX_BOOL ret = FALSE; 2169 FX_BOOL ret = FALSE;
2159 if (m_pDeviceBitmap->GetBPP() == 32 && 2170 if (m_pDeviceBitmap->GetBPP() == 32 &&
2160 m_pDeviceBitmap->GetWidth() == m_SrcWidth && m_SrcWidth == m_sizeX && 2171 m_pDeviceBitmap->GetWidth() == m_SrcWidth && m_SrcWidth == m_sizeX &&
2161 m_pDeviceBitmap->GetHeight() == m_SrcHeight && 2172 m_pDeviceBitmap->GetHeight() == m_SrcHeight &&
2162 m_SrcHeight == m_sizeY && m_startX == 0 && m_startY == 0 && 2173 m_SrcHeight == m_sizeY && m_startX == 0 && m_startY == 0 &&
2163 m_clipBox.left == 0 && m_clipBox.top == 0 && 2174 m_clipBox.left == 0 && m_clipBox.top == 0 &&
2164 m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) { 2175 m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) {
2165 ret = pTiffModule->Decode(m_pTiffContext, m_pDeviceBitmap); 2176 ret = pTiffModule->Decode(m_pTiffContext, m_pDeviceBitmap);
2166 m_pDeviceBitmap = NULL; 2177 m_pDeviceBitmap = NULL;
2167 m_pFile = NULL; 2178 m_pFile = NULL;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 m_pDeviceBitmap = NULL; 2300 m_pDeviceBitmap = NULL;
2290 m_pFile = NULL; 2301 m_pFile = NULL;
2291 return m_status = FXCODEC_STATUS_DECODE_FINISH; 2302 return m_status = FXCODEC_STATUS_DECODE_FINISH;
2292 } 2303 }
2293 } break; 2304 } break;
2294 default: 2305 default:
2295 break; 2306 break;
2296 } 2307 }
2297 return FXCODEC_STATUS_ERROR; 2308 return FXCODEC_STATUS_ERROR;
2298 } 2309 }
2299 ICodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() { 2310 CCodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() {
2300 return new CCodec_ProgressiveDecoder(this); 2311 return new CCodec_ProgressiveDecoder(this);
2301 } 2312 }
OLDNEW
« no previous file with comments | « core/fxcodec/codec/fx_codec_progress.h ('k') | core/fxcodec/codec/fx_codec_tiff.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698