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

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

Powered by Google App Engine
This is Rietveld 408576698