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

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

Issue 2477443002: Remove FX_BOOL from core (Closed)
Patch Set: Created 4 years, 1 month 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_png.cpp ('k') | core/fxcodec/fx_codec.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/fxcodec/codec/ccodec_progressivedecoder.h" 7 #include "core/fxcodec/codec/ccodec_progressivedecoder.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 29 matching lines...) Expand all
40 CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::CFXCODEC_WeightTable() {} 40 CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::CFXCODEC_WeightTable() {}
41 41
42 CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::~CFXCODEC_WeightTable() {} 42 CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::~CFXCODEC_WeightTable() {}
43 43
44 void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, 44 void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len,
45 int dest_min, 45 int dest_min,
46 int dest_max, 46 int dest_max,
47 int src_len, 47 int src_len,
48 int src_min, 48 int src_min,
49 int src_max, 49 int src_max,
50 FX_BOOL bInterpol) { 50 bool bInterpol) {
51 double scale, base; 51 double scale, base;
52 scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len; 52 scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len;
53 if (dest_len < 0) { 53 if (dest_len < 0) {
54 base = (FX_FLOAT)(src_len); 54 base = (FX_FLOAT)(src_len);
55 } else { 55 } else {
56 base = 0.0f; 56 base = 0.0f;
57 } 57 }
58 m_ItemSize = 58 m_ItemSize =
59 (int)(sizeof(int) * 2 + 59 (int)(sizeof(int) * 2 +
60 sizeof(int) * (FXSYS_ceil(FXSYS_fabs((FX_FLOAT)scale)) + 1)); 60 sizeof(int) * (FXSYS_ceil(FXSYS_fabs((FX_FLOAT)scale)) + 1));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 } 140 }
141 } 141 }
142 142
143 CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::CFXCODEC_HorzTable() {} 143 CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::CFXCODEC_HorzTable() {}
144 144
145 CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::~CFXCODEC_HorzTable() {} 145 CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::~CFXCODEC_HorzTable() {}
146 146
147 void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, 147 void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len,
148 int src_len, 148 int src_len,
149 FX_BOOL bInterpol) { 149 bool bInterpol) {
150 double scale = (double)dest_len / (double)src_len; 150 double scale = (double)dest_len / (double)src_len;
151 m_ItemSize = sizeof(int) * 4; 151 m_ItemSize = sizeof(int) * 4;
152 int size = dest_len * m_ItemSize + 4; 152 int size = dest_len * m_ItemSize + 4;
153 m_pWeightTables.resize(size, 0); 153 m_pWeightTables.resize(size, 0);
154 if (scale > 1) { 154 if (scale > 1) {
155 int pre_des_col = 0; 155 int pre_des_col = 0;
156 for (int src_col = 0; src_col < src_len; src_col++) { 156 for (int src_col = 0; src_col < src_len; src_col++) {
157 double des_col_f = src_col * scale; 157 double des_col_f = src_col * scale;
158 int des_col = FXSYS_round((FX_FLOAT)des_col_f); 158 int des_col = FXSYS_round((FX_FLOAT)des_col_f);
159 PixelWeight* pWeight = GetPixelWeight(des_col); 159 PixelWeight* pWeight = GetPixelWeight(des_col);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 m_SrcHeight = 0; 275 m_SrcHeight = 0;
276 m_SrcComponents = 0; 276 m_SrcComponents = 0;
277 m_SrcBPC = 0; 277 m_SrcBPC = 0;
278 m_SrcPassNumber = 0; 278 m_SrcPassNumber = 0;
279 m_clipBox = FX_RECT(0, 0, 0, 0); 279 m_clipBox = FX_RECT(0, 0, 0, 0);
280 m_imagType = FXCODEC_IMAGE_UNKNOWN; 280 m_imagType = FXCODEC_IMAGE_UNKNOWN;
281 m_status = FXCODEC_STATUS_DECODE_FINISH; 281 m_status = FXCODEC_STATUS_DECODE_FINISH;
282 m_TransMethod = -1; 282 m_TransMethod = -1;
283 m_SrcRow = 0; 283 m_SrcRow = 0;
284 m_SrcFormat = FXCodec_Invalid; 284 m_SrcFormat = FXCodec_Invalid;
285 m_bInterpol = TRUE; 285 m_bInterpol = true;
286 m_FrameNumber = 0; 286 m_FrameNumber = 0;
287 m_FrameCur = 0; 287 m_FrameCur = 0;
288 m_SrcPaletteNumber = 0; 288 m_SrcPaletteNumber = 0;
289 m_GifPltNumber = 0; 289 m_GifPltNumber = 0;
290 m_GifBgIndex = 0; 290 m_GifBgIndex = 0;
291 m_pGifPalette = nullptr; 291 m_pGifPalette = nullptr;
292 m_GifTransIndex = -1; 292 m_GifTransIndex = -1;
293 m_GifFrameRect = FX_RECT(0, 0, 0, 0); 293 m_GifFrameRect = FX_RECT(0, 0, 0, 0);
294 m_BmpIsTopBottom = FALSE; 294 m_BmpIsTopBottom = false;
295 } 295 }
296 296
297 CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() { 297 CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() {
298 m_pFile = nullptr; 298 m_pFile = nullptr;
299 if (m_pJpegContext) 299 if (m_pJpegContext)
300 m_pCodecMgr->GetJpegModule()->Finish(m_pJpegContext); 300 m_pCodecMgr->GetJpegModule()->Finish(m_pJpegContext);
301 if (m_pPngContext) 301 if (m_pPngContext)
302 m_pCodecMgr->GetPngModule()->Finish(m_pPngContext); 302 m_pCodecMgr->GetPngModule()->Finish(m_pPngContext);
303 if (m_pGifContext) 303 if (m_pGifContext)
304 m_pCodecMgr->GetGifModule()->Finish(m_pGifContext); 304 m_pCodecMgr->GetGifModule()->Finish(m_pGifContext);
305 if (m_pBmpContext) 305 if (m_pBmpContext)
306 m_pCodecMgr->GetBmpModule()->Finish(m_pBmpContext); 306 m_pCodecMgr->GetBmpModule()->Finish(m_pBmpContext);
307 if (m_pTiffContext) 307 if (m_pTiffContext)
308 m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext); 308 m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext);
309 FX_Free(m_pSrcBuf); 309 FX_Free(m_pSrcBuf);
310 FX_Free(m_pDecodeBuf); 310 FX_Free(m_pDecodeBuf);
311 FX_Free(m_pSrcPalette); 311 FX_Free(m_pSrcPalette);
312 } 312 }
313 313
314 FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData( 314 bool CCodec_ProgressiveDecoder::JpegReadMoreData(CCodec_JpegModule* pJpegModule,
315 CCodec_JpegModule* pJpegModule, 315 FXCODEC_STATUS& err_status) {
316 FXCODEC_STATUS& err_status) {
317 uint32_t dwSize = (uint32_t)m_pFile->GetSize(); 316 uint32_t dwSize = (uint32_t)m_pFile->GetSize();
318 if (dwSize <= m_offSet) { 317 if (dwSize <= m_offSet) {
319 return FALSE; 318 return false;
320 } 319 }
321 dwSize = dwSize - m_offSet; 320 dwSize = dwSize - m_offSet;
322 uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, nullptr); 321 uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, nullptr);
323 if (dwAvail == m_SrcSize) { 322 if (dwAvail == m_SrcSize) {
324 if (dwSize > FXCODEC_BLOCK_SIZE) { 323 if (dwSize > FXCODEC_BLOCK_SIZE) {
325 dwSize = FXCODEC_BLOCK_SIZE; 324 dwSize = FXCODEC_BLOCK_SIZE;
326 } 325 }
327 m_SrcSize = (dwSize + dwAvail + FXCODEC_BLOCK_SIZE - 1) / 326 m_SrcSize = (dwSize + dwAvail + FXCODEC_BLOCK_SIZE - 1) /
328 FXCODEC_BLOCK_SIZE * FXCODEC_BLOCK_SIZE; 327 FXCODEC_BLOCK_SIZE * FXCODEC_BLOCK_SIZE;
329 m_pSrcBuf = FX_Realloc(uint8_t, m_pSrcBuf, m_SrcSize); 328 m_pSrcBuf = FX_Realloc(uint8_t, m_pSrcBuf, m_SrcSize);
330 if (!m_pSrcBuf) { 329 if (!m_pSrcBuf) {
331 err_status = FXCODEC_STATUS_ERR_MEMORY; 330 err_status = FXCODEC_STATUS_ERR_MEMORY;
332 return FALSE; 331 return false;
333 } 332 }
334 } else { 333 } else {
335 uint32_t dwConsume = m_SrcSize - dwAvail; 334 uint32_t dwConsume = m_SrcSize - dwAvail;
336 if (dwAvail) { 335 if (dwAvail) {
337 FXSYS_memmove(m_pSrcBuf, m_pSrcBuf + dwConsume, dwAvail); 336 FXSYS_memmove(m_pSrcBuf, m_pSrcBuf + dwConsume, dwAvail);
338 } 337 }
339 if (dwSize > dwConsume) { 338 if (dwSize > dwConsume) {
340 dwSize = dwConsume; 339 dwSize = dwConsume;
341 } 340 }
342 } 341 }
343 if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) { 342 if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) {
344 err_status = FXCODEC_STATUS_ERR_READ; 343 err_status = FXCODEC_STATUS_ERR_READ;
345 return FALSE; 344 return false;
346 } 345 }
347 m_offSet += dwSize; 346 m_offSet += dwSize;
348 pJpegModule->Input(m_pJpegContext, m_pSrcBuf, dwSize + dwAvail); 347 pJpegModule->Input(m_pJpegContext, m_pSrcBuf, dwSize + dwAvail);
349 return TRUE; 348 return true;
350 } 349 }
351 350
352 FX_BOOL CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule, 351 bool CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule,
353 int width, 352 int width,
354 int height, 353 int height,
355 int bpc, 354 int bpc,
356 int pass, 355 int pass,
357 int* color_type, 356 int* color_type,
358 double* gamma) { 357 double* gamma) {
359 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; 358 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
360 if (!pCodec->m_pDeviceBitmap) { 359 if (!pCodec->m_pDeviceBitmap) {
361 pCodec->m_SrcWidth = width; 360 pCodec->m_SrcWidth = width;
362 pCodec->m_SrcHeight = height; 361 pCodec->m_SrcHeight = height;
363 pCodec->m_SrcBPC = bpc; 362 pCodec->m_SrcBPC = bpc;
364 pCodec->m_SrcPassNumber = pass; 363 pCodec->m_SrcPassNumber = pass;
365 switch (*color_type) { 364 switch (*color_type) {
366 case 0: 365 case 0:
367 pCodec->m_SrcComponents = 1; 366 pCodec->m_SrcComponents = 1;
368 break; 367 break;
369 case 4: 368 case 4:
370 pCodec->m_SrcComponents = 2; 369 pCodec->m_SrcComponents = 2;
371 break; 370 break;
372 case 2: 371 case 2:
373 pCodec->m_SrcComponents = 3; 372 pCodec->m_SrcComponents = 3;
374 break; 373 break;
375 case 3: 374 case 3:
376 case 6: 375 case 6:
377 pCodec->m_SrcComponents = 4; 376 pCodec->m_SrcComponents = 4;
378 break; 377 break;
379 default: 378 default:
380 pCodec->m_SrcComponents = 0; 379 pCodec->m_SrcComponents = 0;
381 break; 380 break;
382 } 381 }
383 pCodec->m_clipBox = FX_RECT(0, 0, width, height); 382 pCodec->m_clipBox = FX_RECT(0, 0, width, height);
384 return FALSE; 383 return false;
385 } 384 }
386 FXDIB_Format format = pCodec->m_pDeviceBitmap->GetFormat(); 385 FXDIB_Format format = pCodec->m_pDeviceBitmap->GetFormat();
387 switch (format) { 386 switch (format) {
388 case FXDIB_1bppMask: 387 case FXDIB_1bppMask:
389 case FXDIB_1bppRgb: 388 case FXDIB_1bppRgb:
390 ASSERT(FALSE); 389 ASSERT(false);
391 return FALSE; 390 return false;
392 case FXDIB_8bppMask: 391 case FXDIB_8bppMask:
393 case FXDIB_8bppRgb: 392 case FXDIB_8bppRgb:
394 *color_type = 0; 393 *color_type = 0;
395 break; 394 break;
396 case FXDIB_Rgb: 395 case FXDIB_Rgb:
397 *color_type = 2; 396 *color_type = 2;
398 break; 397 break;
399 case FXDIB_Rgb32: 398 case FXDIB_Rgb32:
400 case FXDIB_Argb: 399 case FXDIB_Argb:
401 *color_type = 6; 400 *color_type = 6;
402 break; 401 break;
403 default: 402 default:
404 ASSERT(FALSE); 403 ASSERT(false);
405 return FALSE; 404 return false;
406 } 405 }
407 *gamma = kPngGamma; 406 *gamma = kPngGamma;
408 return TRUE; 407 return true;
409 } 408 }
410 409
411 FX_BOOL CCodec_ProgressiveDecoder::PngAskScanlineBufFunc(void* pModule, 410 bool CCodec_ProgressiveDecoder::PngAskScanlineBufFunc(void* pModule,
412 int line, 411 int line,
413 uint8_t*& src_buf) { 412 uint8_t*& src_buf) {
414 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; 413 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
415 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap; 414 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap;
416 if (!pDIBitmap) { 415 if (!pDIBitmap) {
417 ASSERT(false); 416 ASSERT(false);
418 return FALSE; 417 return false;
419 } 418 }
420 if (line >= pCodec->m_clipBox.top && line < pCodec->m_clipBox.bottom) { 419 if (line >= pCodec->m_clipBox.top && line < pCodec->m_clipBox.bottom) {
421 double scale_y = 420 double scale_y =
422 (double)pCodec->m_sizeY / (double)pCodec->m_clipBox.Height(); 421 (double)pCodec->m_sizeY / (double)pCodec->m_clipBox.Height();
423 int32_t row = 422 int32_t row =
424 (int32_t)((line - pCodec->m_clipBox.top) * scale_y) + pCodec->m_startY; 423 (int32_t)((line - pCodec->m_clipBox.top) * scale_y) + pCodec->m_startY;
425 uint8_t* src_scan = (uint8_t*)pDIBitmap->GetScanline(row); 424 uint8_t* src_scan = (uint8_t*)pDIBitmap->GetScanline(row);
426 uint8_t* des_scan = pCodec->m_pDecodeBuf; 425 uint8_t* des_scan = pCodec->m_pDecodeBuf;
427 src_buf = pCodec->m_pDecodeBuf; 426 src_buf = pCodec->m_pDecodeBuf;
428 int32_t src_Bpp = pDIBitmap->GetBPP() >> 3; 427 int32_t src_Bpp = pDIBitmap->GetBPP() >> 3;
429 int32_t des_Bpp = (pCodec->m_SrcFormat & 0xff) >> 3; 428 int32_t des_Bpp = (pCodec->m_SrcFormat & 0xff) >> 3;
430 int32_t src_left = pCodec->m_startX; 429 int32_t src_left = pCodec->m_startX;
431 int32_t des_left = pCodec->m_clipBox.left; 430 int32_t des_left = pCodec->m_clipBox.left;
432 src_scan += src_left * src_Bpp; 431 src_scan += src_left * src_Bpp;
433 des_scan += des_left * des_Bpp; 432 des_scan += des_left * des_Bpp;
434 for (int32_t src_col = 0; src_col < pCodec->m_sizeX; src_col++) { 433 for (int32_t src_col = 0; src_col < pCodec->m_sizeX; src_col++) {
435 PixelWeight* pPixelWeights = 434 PixelWeight* pPixelWeights =
436 pCodec->m_WeightHorzOO.GetPixelWeight(src_col); 435 pCodec->m_WeightHorzOO.GetPixelWeight(src_col);
437 if (pPixelWeights->m_SrcStart != pPixelWeights->m_SrcEnd) { 436 if (pPixelWeights->m_SrcStart != pPixelWeights->m_SrcEnd) {
438 continue; 437 continue;
439 } 438 }
440 switch (pDIBitmap->GetFormat()) { 439 switch (pDIBitmap->GetFormat()) {
441 case FXDIB_1bppMask: 440 case FXDIB_1bppMask:
442 case FXDIB_1bppRgb: 441 case FXDIB_1bppRgb:
443 ASSERT(FALSE); 442 ASSERT(false);
444 return FALSE; 443 return false;
445 case FXDIB_8bppMask: 444 case FXDIB_8bppMask:
446 case FXDIB_8bppRgb: { 445 case FXDIB_8bppRgb: {
447 if (pDIBitmap->GetPalette()) { 446 if (pDIBitmap->GetPalette()) {
448 return FALSE; 447 return false;
449 } 448 }
450 uint32_t des_g = 0; 449 uint32_t des_g = 0;
451 des_g += pPixelWeights->m_Weights[0] * src_scan[src_col]; 450 des_g += pPixelWeights->m_Weights[0] * src_scan[src_col];
452 des_scan[pPixelWeights->m_SrcStart] = (uint8_t)(des_g >> 16); 451 des_scan[pPixelWeights->m_SrcStart] = (uint8_t)(des_g >> 16);
453 } break; 452 } break;
454 case FXDIB_Rgb: 453 case FXDIB_Rgb:
455 case FXDIB_Rgb32: { 454 case FXDIB_Rgb32: {
456 uint32_t des_b = 0, des_g = 0, des_r = 0; 455 uint32_t des_b = 0, des_g = 0, des_r = 0;
457 const uint8_t* p = src_scan + src_col * src_Bpp; 456 const uint8_t* p = src_scan + src_col * src_Bpp;
458 des_b += pPixelWeights->m_Weights[0] * (*p++); 457 des_b += pPixelWeights->m_Weights[0] * (*p++);
(...skipping 10 matching lines...) Expand all
469 des_b += pPixelWeights->m_Weights[0] * (*p++); 468 des_b += pPixelWeights->m_Weights[0] * (*p++);
470 des_g += pPixelWeights->m_Weights[0] * (*p++); 469 des_g += pPixelWeights->m_Weights[0] * (*p++);
471 des_r += pPixelWeights->m_Weights[0] * (*p++); 470 des_r += pPixelWeights->m_Weights[0] * (*p++);
472 uint8_t* pDes = &des_scan[pPixelWeights->m_SrcStart * des_Bpp]; 471 uint8_t* pDes = &des_scan[pPixelWeights->m_SrcStart * des_Bpp];
473 *pDes++ = (uint8_t)((des_b) >> 16); 472 *pDes++ = (uint8_t)((des_b) >> 16);
474 *pDes++ = (uint8_t)((des_g) >> 16); 473 *pDes++ = (uint8_t)((des_g) >> 16);
475 *pDes++ = (uint8_t)((des_r) >> 16); 474 *pDes++ = (uint8_t)((des_r) >> 16);
476 *pDes = *p; 475 *pDes = *p;
477 } break; 476 } break;
478 default: 477 default:
479 return FALSE; 478 return false;
480 } 479 }
481 } 480 }
482 } 481 }
483 return TRUE; 482 return true;
484 } 483 }
485 484
486 void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz( 485 void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz(
487 CFX_DIBitmap* pDeviceBitmap, 486 CFX_DIBitmap* pDeviceBitmap,
488 int32_t des_line, 487 int32_t des_line,
489 uint8_t* src_scan, 488 uint8_t* src_scan,
490 FXCodec_Format src_format) { 489 FXCodec_Format src_format) {
491 uint8_t* des_scan = (uint8_t*)pDeviceBitmap->GetScanline(des_line); 490 uint8_t* des_scan = (uint8_t*)pDeviceBitmap->GetScanline(des_line);
492 int32_t src_Bpp = (m_SrcFormat & 0xff) >> 3; 491 int32_t src_Bpp = (m_SrcFormat & 0xff) >> 3;
493 int32_t des_Bpp = pDeviceBitmap->GetBPP() >> 3; 492 int32_t des_Bpp = pDeviceBitmap->GetBPP() >> 3;
494 int32_t src_left = m_clipBox.left; 493 int32_t src_left = m_clipBox.left;
495 int32_t des_left = m_startX; 494 int32_t des_left = m_startX;
496 src_scan += src_left * src_Bpp; 495 src_scan += src_left * src_Bpp;
497 des_scan += des_left * des_Bpp; 496 des_scan += des_left * des_Bpp;
498 for (int32_t des_col = 0; des_col < m_sizeX; des_col++) { 497 for (int32_t des_col = 0; des_col < m_sizeX; des_col++) {
499 PixelWeight* pPixelWeights = m_WeightHorzOO.GetPixelWeight(des_col); 498 PixelWeight* pPixelWeights = m_WeightHorzOO.GetPixelWeight(des_col);
500 switch (pDeviceBitmap->GetFormat()) { 499 switch (pDeviceBitmap->GetFormat()) {
501 case FXDIB_1bppMask: 500 case FXDIB_1bppMask:
502 case FXDIB_1bppRgb: 501 case FXDIB_1bppRgb:
503 ASSERT(FALSE); 502 ASSERT(false);
504 return; 503 return;
505 case FXDIB_8bppMask: 504 case FXDIB_8bppMask:
506 case FXDIB_8bppRgb: { 505 case FXDIB_8bppRgb: {
507 if (pDeviceBitmap->GetPalette()) { 506 if (pDeviceBitmap->GetPalette()) {
508 return; 507 return;
509 } 508 }
510 uint32_t des_g = 0; 509 uint32_t des_g = 0;
511 des_g += 510 des_g +=
512 pPixelWeights->m_Weights[0] * src_scan[pPixelWeights->m_SrcStart]; 511 pPixelWeights->m_Weights[0] * src_scan[pPixelWeights->m_SrcStart];
513 des_g += 512 des_g +=
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 if (pCodec->m_SrcPassNumber == 1 && scale_y > 1.0) { 577 if (pCodec->m_SrcPassNumber == 1 && scale_y > 1.0) {
579 pCodec->ResampleVert(pDIBitmap, scale_y, des_row); 578 pCodec->ResampleVert(pDIBitmap, scale_y, des_row);
580 return; 579 return;
581 } 580 }
582 if (pass == 6 && scale_y > 1.0) { 581 if (pass == 6 && scale_y > 1.0) {
583 pCodec->ResampleVert(pDIBitmap, scale_y, des_row); 582 pCodec->ResampleVert(pDIBitmap, scale_y, des_row);
584 } 583 }
585 } 584 }
586 } 585 }
587 586
588 FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, 587 bool CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule,
589 FXCODEC_STATUS& err_status) { 588 FXCODEC_STATUS& err_status) {
590 uint32_t dwSize = (uint32_t)m_pFile->GetSize(); 589 uint32_t dwSize = (uint32_t)m_pFile->GetSize();
591 if (dwSize <= m_offSet) { 590 if (dwSize <= m_offSet) {
592 return FALSE; 591 return false;
593 } 592 }
594 dwSize = dwSize - m_offSet; 593 dwSize = dwSize - m_offSet;
595 uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, nullptr); 594 uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, nullptr);
596 if (dwAvail == m_SrcSize) { 595 if (dwAvail == m_SrcSize) {
597 if (dwSize > FXCODEC_BLOCK_SIZE) { 596 if (dwSize > FXCODEC_BLOCK_SIZE) {
598 dwSize = FXCODEC_BLOCK_SIZE; 597 dwSize = FXCODEC_BLOCK_SIZE;
599 } 598 }
600 m_SrcSize = (dwSize + dwAvail + FXCODEC_BLOCK_SIZE - 1) / 599 m_SrcSize = (dwSize + dwAvail + FXCODEC_BLOCK_SIZE - 1) /
601 FXCODEC_BLOCK_SIZE * FXCODEC_BLOCK_SIZE; 600 FXCODEC_BLOCK_SIZE * FXCODEC_BLOCK_SIZE;
602 m_pSrcBuf = FX_Realloc(uint8_t, m_pSrcBuf, m_SrcSize); 601 m_pSrcBuf = FX_Realloc(uint8_t, m_pSrcBuf, m_SrcSize);
603 if (!m_pSrcBuf) { 602 if (!m_pSrcBuf) {
604 err_status = FXCODEC_STATUS_ERR_MEMORY; 603 err_status = FXCODEC_STATUS_ERR_MEMORY;
605 return FALSE; 604 return false;
606 } 605 }
607 } else { 606 } else {
608 uint32_t dwConsume = m_SrcSize - dwAvail; 607 uint32_t dwConsume = m_SrcSize - dwAvail;
609 if (dwAvail) { 608 if (dwAvail) {
610 FXSYS_memmove(m_pSrcBuf, m_pSrcBuf + dwConsume, dwAvail); 609 FXSYS_memmove(m_pSrcBuf, m_pSrcBuf + dwConsume, dwAvail);
611 } 610 }
612 if (dwSize > dwConsume) { 611 if (dwSize > dwConsume) {
613 dwSize = dwConsume; 612 dwSize = dwConsume;
614 } 613 }
615 } 614 }
616 if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) { 615 if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) {
617 err_status = FXCODEC_STATUS_ERR_READ; 616 err_status = FXCODEC_STATUS_ERR_READ;
618 return FALSE; 617 return false;
619 } 618 }
620 m_offSet += dwSize; 619 m_offSet += dwSize;
621 pGifModule->Input(m_pGifContext, m_pSrcBuf, dwSize + dwAvail); 620 pGifModule->Input(m_pGifContext, m_pSrcBuf, dwSize + dwAvail);
622 return TRUE; 621 return true;
623 } 622 }
624 623
625 void CCodec_ProgressiveDecoder::GifRecordCurrentPositionCallback( 624 void CCodec_ProgressiveDecoder::GifRecordCurrentPositionCallback(
626 void* pModule, 625 void* pModule,
627 uint32_t& cur_pos) { 626 uint32_t& cur_pos) {
628 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; 627 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
629 uint32_t remain_size = 628 uint32_t remain_size =
630 pCodec->m_pCodecMgr->GetGifModule()->GetAvailInput(pCodec->m_pGifContext); 629 pCodec->m_pCodecMgr->GetGifModule()->GetAvailInput(pCodec->m_pGifContext);
631 cur_pos = pCodec->m_offSet - remain_size; 630 cur_pos = pCodec->m_offSet - remain_size;
632 } 631 }
633 632
634 uint8_t* CCodec_ProgressiveDecoder::GifAskLocalPaletteBufCallback( 633 uint8_t* CCodec_ProgressiveDecoder::GifAskLocalPaletteBufCallback(
635 void* pModule, 634 void* pModule,
636 int32_t frame_num, 635 int32_t frame_num,
637 int32_t pal_size) { 636 int32_t pal_size) {
638 return FX_Alloc(uint8_t, pal_size); 637 return FX_Alloc(uint8_t, pal_size);
639 } 638 }
640 639
641 FX_BOOL CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback( 640 bool CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback(
642 void* pModule, 641 void* pModule,
643 uint32_t rcd_pos, 642 uint32_t rcd_pos,
644 const FX_RECT& img_rc, 643 const FX_RECT& img_rc,
645 int32_t pal_num, 644 int32_t pal_num,
646 void* pal_ptr, 645 void* pal_ptr,
647 int32_t delay_time, 646 int32_t delay_time,
648 FX_BOOL user_input, 647 bool user_input,
649 int32_t trans_index, 648 int32_t trans_index,
650 int32_t disposal_method, 649 int32_t disposal_method,
651 FX_BOOL interlace) { 650 bool interlace) {
652 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; 651 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
653 pCodec->m_offSet = rcd_pos; 652 pCodec->m_offSet = rcd_pos;
654 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR; 653 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR;
655 if (!pCodec->GifReadMoreData(pCodec->m_pCodecMgr->GetGifModule(), 654 if (!pCodec->GifReadMoreData(pCodec->m_pCodecMgr->GetGifModule(),
656 error_status)) { 655 error_status)) {
657 return FALSE; 656 return false;
658 } 657 }
659 uint8_t* pPalette = nullptr; 658 uint8_t* pPalette = nullptr;
660 if (pal_num != 0 && pal_ptr) { 659 if (pal_num != 0 && pal_ptr) {
661 pPalette = (uint8_t*)pal_ptr; 660 pPalette = (uint8_t*)pal_ptr;
662 } else { 661 } else {
663 pal_num = pCodec->m_GifPltNumber; 662 pal_num = pCodec->m_GifPltNumber;
664 pPalette = pCodec->m_pGifPalette; 663 pPalette = pCodec->m_pGifPalette;
665 } 664 }
666 if (!pCodec->m_pSrcPalette) { 665 if (!pCodec->m_pSrcPalette) {
667 pCodec->m_pSrcPalette = FX_Alloc(FX_ARGB, pal_num); 666 pCodec->m_pSrcPalette = FX_Alloc(FX_ARGB, pal_num);
668 } else if (pal_num > pCodec->m_SrcPaletteNumber) { 667 } else if (pal_num > pCodec->m_SrcPaletteNumber) {
669 pCodec->m_pSrcPalette = FX_Realloc(FX_ARGB, pCodec->m_pSrcPalette, pal_num); 668 pCodec->m_pSrcPalette = FX_Realloc(FX_ARGB, pCodec->m_pSrcPalette, pal_num);
670 } 669 }
671 if (!pCodec->m_pSrcPalette) 670 if (!pCodec->m_pSrcPalette)
672 return FALSE; 671 return false;
673 672
674 pCodec->m_SrcPaletteNumber = pal_num; 673 pCodec->m_SrcPaletteNumber = pal_num;
675 for (int i = 0; i < pal_num; i++) { 674 for (int i = 0; i < pal_num; i++) {
676 uint32_t j = i * 3; 675 uint32_t j = i * 3;
677 pCodec->m_pSrcPalette[i] = 676 pCodec->m_pSrcPalette[i] =
678 ArgbEncode(0xff, pPalette[j], pPalette[j + 1], pPalette[j + 2]); 677 ArgbEncode(0xff, pPalette[j], pPalette[j + 1], pPalette[j + 2]);
679 } 678 }
680 pCodec->m_GifTransIndex = trans_index; 679 pCodec->m_GifTransIndex = trans_index;
681 pCodec->m_GifFrameRect = img_rc; 680 pCodec->m_GifFrameRect = img_rc;
682 pCodec->m_SrcPassNumber = interlace ? 4 : 1; 681 pCodec->m_SrcPassNumber = interlace ? 4 : 1;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 717 }
719 case 12: { 718 case 12: {
720 for (int col = 0; col < sizeX; col++) { 719 for (int col = 0; col < sizeX; col++) {
721 FXARGB_SETDIB(pScanline, argb); 720 FXARGB_SETDIB(pScanline, argb);
722 pScanline += 4; 721 pScanline += 4;
723 } 722 }
724 break; 723 break;
725 } 724 }
726 } 725 }
727 } 726 }
728 return TRUE; 727 return true;
729 } 728 }
730 729
731 void CCodec_ProgressiveDecoder::GifReadScanlineCallback(void* pModule, 730 void CCodec_ProgressiveDecoder::GifReadScanlineCallback(void* pModule,
732 int32_t row_num, 731 int32_t row_num,
733 uint8_t* row_buf) { 732 uint8_t* row_buf) {
734 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; 733 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
735 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap; 734 CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap;
736 ASSERT(pDIBitmap); 735 ASSERT(pDIBitmap);
737 int32_t img_width = pCodec->m_GifFrameRect.Width(); 736 int32_t img_width = pCodec->m_GifFrameRect.Width();
738 if (!pDIBitmap->HasAlpha()) { 737 if (!pDIBitmap->HasAlpha()) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 } 867 }
869 } 868 }
870 } 869 }
871 int des_bottom = des_top + m_sizeY - 1; 870 int des_bottom = des_top + m_sizeY - 1;
872 if (des_row + (int)(2 * scale_y) >= des_bottom && 871 if (des_row + (int)(2 * scale_y) >= des_bottom &&
873 des_row + (int)scale_y < des_bottom) { 872 des_row + (int)scale_y < des_bottom) {
874 GifDoubleLineResampleVert(pDeviceBitmap, scale_y, des_row + (int)scale_y); 873 GifDoubleLineResampleVert(pDeviceBitmap, scale_y, des_row + (int)scale_y);
875 } 874 }
876 } 875 }
877 876
878 FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule, 877 bool CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule,
879 FXCODEC_STATUS& err_status) { 878 FXCODEC_STATUS& err_status) {
880 uint32_t dwSize = (uint32_t)m_pFile->GetSize(); 879 uint32_t dwSize = (uint32_t)m_pFile->GetSize();
881 if (dwSize <= m_offSet) 880 if (dwSize <= m_offSet)
882 return FALSE; 881 return false;
883 882
884 dwSize = dwSize - m_offSet; 883 dwSize = dwSize - m_offSet;
885 uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, nullptr); 884 uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, nullptr);
886 if (dwAvail == m_SrcSize) { 885 if (dwAvail == m_SrcSize) {
887 if (dwSize > FXCODEC_BLOCK_SIZE) { 886 if (dwSize > FXCODEC_BLOCK_SIZE) {
888 dwSize = FXCODEC_BLOCK_SIZE; 887 dwSize = FXCODEC_BLOCK_SIZE;
889 } 888 }
890 m_SrcSize = (dwSize + dwAvail + FXCODEC_BLOCK_SIZE - 1) / 889 m_SrcSize = (dwSize + dwAvail + FXCODEC_BLOCK_SIZE - 1) /
891 FXCODEC_BLOCK_SIZE * FXCODEC_BLOCK_SIZE; 890 FXCODEC_BLOCK_SIZE * FXCODEC_BLOCK_SIZE;
892 m_pSrcBuf = FX_Realloc(uint8_t, m_pSrcBuf, m_SrcSize); 891 m_pSrcBuf = FX_Realloc(uint8_t, m_pSrcBuf, m_SrcSize);
893 if (!m_pSrcBuf) { 892 if (!m_pSrcBuf) {
894 err_status = FXCODEC_STATUS_ERR_MEMORY; 893 err_status = FXCODEC_STATUS_ERR_MEMORY;
895 return FALSE; 894 return false;
896 } 895 }
897 } else { 896 } else {
898 uint32_t dwConsume = m_SrcSize - dwAvail; 897 uint32_t dwConsume = m_SrcSize - dwAvail;
899 if (dwAvail) { 898 if (dwAvail) {
900 FXSYS_memmove(m_pSrcBuf, m_pSrcBuf + dwConsume, dwAvail); 899 FXSYS_memmove(m_pSrcBuf, m_pSrcBuf + dwConsume, dwAvail);
901 } 900 }
902 if (dwSize > dwConsume) { 901 if (dwSize > dwConsume) {
903 dwSize = dwConsume; 902 dwSize = dwConsume;
904 } 903 }
905 } 904 }
906 if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) { 905 if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) {
907 err_status = FXCODEC_STATUS_ERR_READ; 906 err_status = FXCODEC_STATUS_ERR_READ;
908 return FALSE; 907 return false;
909 } 908 }
910 m_offSet += dwSize; 909 m_offSet += dwSize;
911 pBmpModule->Input(m_pBmpContext, m_pSrcBuf, dwSize + dwAvail); 910 pBmpModule->Input(m_pBmpContext, m_pSrcBuf, dwSize + dwAvail);
912 return TRUE; 911 return true;
913 } 912 }
914 913
915 FX_BOOL CCodec_ProgressiveDecoder::BmpInputImagePositionBufCallback( 914 bool CCodec_ProgressiveDecoder::BmpInputImagePositionBufCallback(
916 void* pModule, 915 void* pModule,
917 uint32_t rcd_pos) { 916 uint32_t rcd_pos) {
918 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; 917 CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
919 pCodec->m_offSet = rcd_pos; 918 pCodec->m_offSet = rcd_pos;
920 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR; 919 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR;
921 return pCodec->BmpReadMoreData(pCodec->m_pCodecMgr->GetBmpModule(), 920 return pCodec->BmpReadMoreData(pCodec->m_pCodecMgr->GetBmpModule(),
922 error_status); 921 error_status);
923 } 922 }
924 923
925 void CCodec_ProgressiveDecoder::BmpReadScanlineCallback(void* pModule, 924 void CCodec_ProgressiveDecoder::BmpReadScanlineCallback(void* pModule,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 *scan_des++ = (uint8_t)((des_r) >> 16); 1031 *scan_des++ = (uint8_t)((des_r) >> 16);
1033 *scan_des++ = (uint8_t)((des_a) >> 16); 1032 *scan_des++ = (uint8_t)((des_a) >> 16);
1034 } break; 1033 } break;
1035 default: 1034 default:
1036 return; 1035 return;
1037 } 1036 }
1038 } 1037 }
1039 } 1038 }
1040 } 1039 }
1041 1040
1042 FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( 1041 bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
1043 FXCODEC_IMAGE_TYPE imageType, 1042 CFX_DIBAttribute* pAttribute) {
1044 CFX_DIBAttribute* pAttribute) {
1045 m_offSet = 0; 1043 m_offSet = 0;
1046 uint32_t size = (uint32_t)m_pFile->GetSize(); 1044 uint32_t size = (uint32_t)m_pFile->GetSize();
1047 if (size > FXCODEC_BLOCK_SIZE) { 1045 if (size > FXCODEC_BLOCK_SIZE) {
1048 size = FXCODEC_BLOCK_SIZE; 1046 size = FXCODEC_BLOCK_SIZE;
1049 } 1047 }
1050 FX_Free(m_pSrcBuf); 1048 FX_Free(m_pSrcBuf);
1051 m_pSrcBuf = FX_Alloc(uint8_t, size); 1049 m_pSrcBuf = FX_Alloc(uint8_t, size);
1052 FXSYS_memset(m_pSrcBuf, 0, size); 1050 FXSYS_memset(m_pSrcBuf, 0, size);
1053 m_SrcSize = size; 1051 m_SrcSize = size;
1054 switch (imageType) { 1052 switch (imageType) {
1055 case FXCODEC_IMAGE_BMP: { 1053 case FXCODEC_IMAGE_BMP: {
1056 CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); 1054 CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
1057 if (!pBmpModule) { 1055 if (!pBmpModule) {
1058 m_status = FXCODEC_STATUS_ERR_MEMORY; 1056 m_status = FXCODEC_STATUS_ERR_MEMORY;
1059 return FALSE; 1057 return false;
1060 } 1058 }
1061 pBmpModule->InputImagePositionBufCallback = 1059 pBmpModule->InputImagePositionBufCallback =
1062 BmpInputImagePositionBufCallback; 1060 BmpInputImagePositionBufCallback;
1063 pBmpModule->ReadScanlineCallback = BmpReadScanlineCallback; 1061 pBmpModule->ReadScanlineCallback = BmpReadScanlineCallback;
1064 m_pBmpContext = pBmpModule->Start((void*)this); 1062 m_pBmpContext = pBmpModule->Start((void*)this);
1065 if (!m_pBmpContext) { 1063 if (!m_pBmpContext) {
1066 m_status = FXCODEC_STATUS_ERR_MEMORY; 1064 m_status = FXCODEC_STATUS_ERR_MEMORY;
1067 return FALSE; 1065 return false;
1068 } 1066 }
1069 FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); 1067 bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size);
1070 if (!bResult) { 1068 if (!bResult) {
1071 m_status = FXCODEC_STATUS_ERR_READ; 1069 m_status = FXCODEC_STATUS_ERR_READ;
1072 return FALSE; 1070 return false;
1073 } 1071 }
1074 m_offSet += size; 1072 m_offSet += size;
1075 pBmpModule->Input(m_pBmpContext, m_pSrcBuf, size); 1073 pBmpModule->Input(m_pBmpContext, m_pSrcBuf, size);
1076 uint32_t* pPalette = nullptr; 1074 uint32_t* pPalette = nullptr;
1077 int32_t readResult = pBmpModule->ReadHeader( 1075 int32_t readResult = pBmpModule->ReadHeader(
1078 m_pBmpContext, &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom, 1076 m_pBmpContext, &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom,
1079 &m_SrcComponents, &m_SrcPaletteNumber, &pPalette, pAttribute); 1077 &m_SrcComponents, &m_SrcPaletteNumber, &pPalette, pAttribute);
1080 while (readResult == 2) { 1078 while (readResult == 2) {
1081 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT; 1079 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT;
1082 if (!BmpReadMoreData(pBmpModule, error_status)) { 1080 if (!BmpReadMoreData(pBmpModule, error_status)) {
1083 m_status = error_status; 1081 m_status = error_status;
1084 return FALSE; 1082 return false;
1085 } 1083 }
1086 readResult = pBmpModule->ReadHeader( 1084 readResult = pBmpModule->ReadHeader(
1087 m_pBmpContext, &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom, 1085 m_pBmpContext, &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom,
1088 &m_SrcComponents, &m_SrcPaletteNumber, &pPalette, pAttribute); 1086 &m_SrcComponents, &m_SrcPaletteNumber, &pPalette, pAttribute);
1089 } 1087 }
1090 if (readResult == 1) { 1088 if (readResult == 1) {
1091 m_SrcBPC = 8; 1089 m_SrcBPC = 8;
1092 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); 1090 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
1093 FX_Free(m_pSrcPalette); 1091 FX_Free(m_pSrcPalette);
1094 if (m_SrcPaletteNumber) { 1092 if (m_SrcPaletteNumber) {
1095 m_pSrcPalette = FX_Alloc(FX_ARGB, m_SrcPaletteNumber); 1093 m_pSrcPalette = FX_Alloc(FX_ARGB, m_SrcPaletteNumber);
1096 FXSYS_memcpy(m_pSrcPalette, pPalette, 1094 FXSYS_memcpy(m_pSrcPalette, pPalette,
1097 m_SrcPaletteNumber * sizeof(uint32_t)); 1095 m_SrcPaletteNumber * sizeof(uint32_t));
1098 } else { 1096 } else {
1099 m_pSrcPalette = nullptr; 1097 m_pSrcPalette = nullptr;
1100 } 1098 }
1101 return TRUE; 1099 return true;
1102 } 1100 }
1103 if (m_pBmpContext) { 1101 if (m_pBmpContext) {
1104 pBmpModule->Finish(m_pBmpContext); 1102 pBmpModule->Finish(m_pBmpContext);
1105 m_pBmpContext = nullptr; 1103 m_pBmpContext = nullptr;
1106 } 1104 }
1107 m_status = FXCODEC_STATUS_ERR_FORMAT; 1105 m_status = FXCODEC_STATUS_ERR_FORMAT;
1108 return FALSE; 1106 return false;
1109 } 1107 }
1110 case FXCODEC_IMAGE_JPG: { 1108 case FXCODEC_IMAGE_JPG: {
1111 CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); 1109 CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
1112 if (!pJpegModule) { 1110 if (!pJpegModule) {
1113 m_status = FXCODEC_STATUS_ERR_MEMORY; 1111 m_status = FXCODEC_STATUS_ERR_MEMORY;
1114 return FALSE; 1112 return false;
1115 } 1113 }
1116 m_pJpegContext = pJpegModule->Start(); 1114 m_pJpegContext = pJpegModule->Start();
1117 if (!m_pJpegContext) { 1115 if (!m_pJpegContext) {
1118 m_status = FXCODEC_STATUS_ERR_MEMORY; 1116 m_status = FXCODEC_STATUS_ERR_MEMORY;
1119 return FALSE; 1117 return false;
1120 } 1118 }
1121 FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); 1119 bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size);
1122 if (!bResult) { 1120 if (!bResult) {
1123 m_status = FXCODEC_STATUS_ERR_READ; 1121 m_status = FXCODEC_STATUS_ERR_READ;
1124 return FALSE; 1122 return false;
1125 } 1123 }
1126 m_offSet += size; 1124 m_offSet += size;
1127 pJpegModule->Input(m_pJpegContext, m_pSrcBuf, size); 1125 pJpegModule->Input(m_pJpegContext, m_pSrcBuf, size);
1128 int32_t readResult = 1126 int32_t readResult =
1129 pJpegModule->ReadHeader(m_pJpegContext, &m_SrcWidth, &m_SrcHeight, 1127 pJpegModule->ReadHeader(m_pJpegContext, &m_SrcWidth, &m_SrcHeight,
1130 &m_SrcComponents, pAttribute); 1128 &m_SrcComponents, pAttribute);
1131 while (readResult == 2) { 1129 while (readResult == 2) {
1132 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT; 1130 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT;
1133 if (!JpegReadMoreData(pJpegModule, error_status)) { 1131 if (!JpegReadMoreData(pJpegModule, error_status)) {
1134 m_status = error_status; 1132 m_status = error_status;
1135 return FALSE; 1133 return false;
1136 } 1134 }
1137 readResult = 1135 readResult =
1138 pJpegModule->ReadHeader(m_pJpegContext, &m_SrcWidth, &m_SrcHeight, 1136 pJpegModule->ReadHeader(m_pJpegContext, &m_SrcWidth, &m_SrcHeight,
1139 &m_SrcComponents, pAttribute); 1137 &m_SrcComponents, pAttribute);
1140 } 1138 }
1141 if (!readResult) { 1139 if (!readResult) {
1142 m_SrcBPC = 8; 1140 m_SrcBPC = 8;
1143 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); 1141 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
1144 return TRUE; 1142 return true;
1145 } 1143 }
1146 if (m_pJpegContext) { 1144 if (m_pJpegContext) {
1147 pJpegModule->Finish(m_pJpegContext); 1145 pJpegModule->Finish(m_pJpegContext);
1148 m_pJpegContext = nullptr; 1146 m_pJpegContext = nullptr;
1149 } 1147 }
1150 m_status = FXCODEC_STATUS_ERR_FORMAT; 1148 m_status = FXCODEC_STATUS_ERR_FORMAT;
1151 return FALSE; 1149 return false;
1152 } 1150 }
1153 case FXCODEC_IMAGE_PNG: { 1151 case FXCODEC_IMAGE_PNG: {
1154 CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); 1152 CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
1155 if (!pPngModule) { 1153 if (!pPngModule) {
1156 m_status = FXCODEC_STATUS_ERR_MEMORY; 1154 m_status = FXCODEC_STATUS_ERR_MEMORY;
1157 return FALSE; 1155 return false;
1158 } 1156 }
1159 pPngModule->ReadHeaderCallback = 1157 pPngModule->ReadHeaderCallback =
1160 CCodec_ProgressiveDecoder::PngReadHeaderFunc; 1158 CCodec_ProgressiveDecoder::PngReadHeaderFunc;
1161 pPngModule->AskScanlineBufCallback = 1159 pPngModule->AskScanlineBufCallback =
1162 CCodec_ProgressiveDecoder::PngAskScanlineBufFunc; 1160 CCodec_ProgressiveDecoder::PngAskScanlineBufFunc;
1163 pPngModule->FillScanlineBufCompletedCallback = 1161 pPngModule->FillScanlineBufCompletedCallback =
1164 CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc; 1162 CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc;
1165 m_pPngContext = pPngModule->Start((void*)this); 1163 m_pPngContext = pPngModule->Start((void*)this);
1166 if (!m_pPngContext) { 1164 if (!m_pPngContext) {
1167 m_status = FXCODEC_STATUS_ERR_MEMORY; 1165 m_status = FXCODEC_STATUS_ERR_MEMORY;
1168 return FALSE; 1166 return false;
1169 } 1167 }
1170 FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); 1168 bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size);
1171 if (!bResult) { 1169 if (!bResult) {
1172 m_status = FXCODEC_STATUS_ERR_READ; 1170 m_status = FXCODEC_STATUS_ERR_READ;
1173 return FALSE; 1171 return false;
1174 } 1172 }
1175 m_offSet += size; 1173 m_offSet += size;
1176 bResult = pPngModule->Input(m_pPngContext, m_pSrcBuf, size, pAttribute); 1174 bResult = pPngModule->Input(m_pPngContext, m_pSrcBuf, size, pAttribute);
1177 while (bResult) { 1175 while (bResult) {
1178 uint32_t remain_size = (uint32_t)m_pFile->GetSize() - m_offSet; 1176 uint32_t remain_size = (uint32_t)m_pFile->GetSize() - m_offSet;
1179 uint32_t input_size = 1177 uint32_t input_size =
1180 remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size; 1178 remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size;
1181 if (input_size == 0) { 1179 if (input_size == 0) {
1182 if (m_pPngContext) { 1180 if (m_pPngContext) {
1183 pPngModule->Finish(m_pPngContext); 1181 pPngModule->Finish(m_pPngContext);
1184 } 1182 }
1185 m_pPngContext = nullptr; 1183 m_pPngContext = nullptr;
1186 m_status = FXCODEC_STATUS_ERR_FORMAT; 1184 m_status = FXCODEC_STATUS_ERR_FORMAT;
1187 return FALSE; 1185 return false;
1188 } 1186 }
1189 if (m_pSrcBuf && input_size > m_SrcSize) { 1187 if (m_pSrcBuf && input_size > m_SrcSize) {
1190 FX_Free(m_pSrcBuf); 1188 FX_Free(m_pSrcBuf);
1191 m_pSrcBuf = FX_Alloc(uint8_t, input_size); 1189 m_pSrcBuf = FX_Alloc(uint8_t, input_size);
1192 FXSYS_memset(m_pSrcBuf, 0, input_size); 1190 FXSYS_memset(m_pSrcBuf, 0, input_size);
1193 m_SrcSize = input_size; 1191 m_SrcSize = input_size;
1194 } 1192 }
1195 bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); 1193 bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size);
1196 if (!bResult) { 1194 if (!bResult) {
1197 m_status = FXCODEC_STATUS_ERR_READ; 1195 m_status = FXCODEC_STATUS_ERR_READ;
1198 return FALSE; 1196 return false;
1199 } 1197 }
1200 m_offSet += input_size; 1198 m_offSet += input_size;
1201 bResult = 1199 bResult =
1202 pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, pAttribute); 1200 pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, pAttribute);
1203 } 1201 }
1204 ASSERT(!bResult); 1202 ASSERT(!bResult);
1205 if (m_pPngContext) { 1203 if (m_pPngContext) {
1206 pPngModule->Finish(m_pPngContext); 1204 pPngModule->Finish(m_pPngContext);
1207 m_pPngContext = nullptr; 1205 m_pPngContext = nullptr;
1208 } 1206 }
1209 if (m_SrcPassNumber == 0) { 1207 if (m_SrcPassNumber == 0) {
1210 m_status = FXCODEC_STATUS_ERR_FORMAT; 1208 m_status = FXCODEC_STATUS_ERR_FORMAT;
1211 return FALSE; 1209 return false;
1212 } 1210 }
1213 return TRUE; 1211 return true;
1214 } 1212 }
1215 case FXCODEC_IMAGE_GIF: { 1213 case FXCODEC_IMAGE_GIF: {
1216 CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); 1214 CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
1217 if (!pGifModule) { 1215 if (!pGifModule) {
1218 m_status = FXCODEC_STATUS_ERR_MEMORY; 1216 m_status = FXCODEC_STATUS_ERR_MEMORY;
1219 return FALSE; 1217 return false;
1220 } 1218 }
1221 pGifModule->RecordCurrentPositionCallback = 1219 pGifModule->RecordCurrentPositionCallback =
1222 CCodec_ProgressiveDecoder::GifRecordCurrentPositionCallback; 1220 CCodec_ProgressiveDecoder::GifRecordCurrentPositionCallback;
1223 pGifModule->AskLocalPaletteBufCallback = 1221 pGifModule->AskLocalPaletteBufCallback =
1224 CCodec_ProgressiveDecoder::GifAskLocalPaletteBufCallback; 1222 CCodec_ProgressiveDecoder::GifAskLocalPaletteBufCallback;
1225 pGifModule->InputRecordPositionBufCallback = 1223 pGifModule->InputRecordPositionBufCallback =
1226 CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback; 1224 CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback;
1227 pGifModule->ReadScanlineCallback = 1225 pGifModule->ReadScanlineCallback =
1228 CCodec_ProgressiveDecoder::GifReadScanlineCallback; 1226 CCodec_ProgressiveDecoder::GifReadScanlineCallback;
1229 m_pGifContext = pGifModule->Start((void*)this); 1227 m_pGifContext = pGifModule->Start((void*)this);
1230 if (!m_pGifContext) { 1228 if (!m_pGifContext) {
1231 m_status = FXCODEC_STATUS_ERR_MEMORY; 1229 m_status = FXCODEC_STATUS_ERR_MEMORY;
1232 return FALSE; 1230 return false;
1233 } 1231 }
1234 FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); 1232 bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size);
1235 if (!bResult) { 1233 if (!bResult) {
1236 m_status = FXCODEC_STATUS_ERR_READ; 1234 m_status = FXCODEC_STATUS_ERR_READ;
1237 return FALSE; 1235 return false;
1238 } 1236 }
1239 m_offSet += size; 1237 m_offSet += size;
1240 pGifModule->Input(m_pGifContext, m_pSrcBuf, size); 1238 pGifModule->Input(m_pGifContext, m_pSrcBuf, size);
1241 m_SrcComponents = 1; 1239 m_SrcComponents = 1;
1242 int32_t readResult = pGifModule->ReadHeader( 1240 int32_t readResult = pGifModule->ReadHeader(
1243 m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber, 1241 m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber,
1244 (void**)&m_pGifPalette, &m_GifBgIndex, nullptr); 1242 (void**)&m_pGifPalette, &m_GifBgIndex, nullptr);
1245 while (readResult == 2) { 1243 while (readResult == 2) {
1246 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT; 1244 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT;
1247 if (!GifReadMoreData(pGifModule, error_status)) { 1245 if (!GifReadMoreData(pGifModule, error_status)) {
1248 m_status = error_status; 1246 m_status = error_status;
1249 return FALSE; 1247 return false;
1250 } 1248 }
1251 readResult = pGifModule->ReadHeader( 1249 readResult = pGifModule->ReadHeader(
1252 m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber, 1250 m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber,
1253 (void**)&m_pGifPalette, &m_GifBgIndex, nullptr); 1251 (void**)&m_pGifPalette, &m_GifBgIndex, nullptr);
1254 } 1252 }
1255 if (readResult == 1) { 1253 if (readResult == 1) {
1256 m_SrcBPC = 8; 1254 m_SrcBPC = 8;
1257 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); 1255 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
1258 return TRUE; 1256 return true;
1259 } 1257 }
1260 if (m_pGifContext) { 1258 if (m_pGifContext) {
1261 pGifModule->Finish(m_pGifContext); 1259 pGifModule->Finish(m_pGifContext);
1262 m_pGifContext = nullptr; 1260 m_pGifContext = nullptr;
1263 } 1261 }
1264 m_status = FXCODEC_STATUS_ERR_FORMAT; 1262 m_status = FXCODEC_STATUS_ERR_FORMAT;
1265 return FALSE; 1263 return false;
1266 } 1264 }
1267 case FXCODEC_IMAGE_TIF: { 1265 case FXCODEC_IMAGE_TIF: {
1268 CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); 1266 CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
1269 if (!pTiffModule) { 1267 if (!pTiffModule) {
1270 m_status = FXCODEC_STATUS_ERR_FORMAT; 1268 m_status = FXCODEC_STATUS_ERR_FORMAT;
1271 return FALSE; 1269 return false;
1272 } 1270 }
1273 m_pTiffContext = pTiffModule->CreateDecoder(m_pFile); 1271 m_pTiffContext = pTiffModule->CreateDecoder(m_pFile);
1274 if (!m_pTiffContext) { 1272 if (!m_pTiffContext) {
1275 m_status = FXCODEC_STATUS_ERR_FORMAT; 1273 m_status = FXCODEC_STATUS_ERR_FORMAT;
1276 return FALSE; 1274 return false;
1277 } 1275 }
1278 int32_t dummy_bpc; 1276 int32_t dummy_bpc;
1279 FX_BOOL ret = pTiffModule->LoadFrameInfo(m_pTiffContext, 0, &m_SrcWidth, 1277 bool ret = pTiffModule->LoadFrameInfo(m_pTiffContext, 0, &m_SrcWidth,
1280 &m_SrcHeight, &m_SrcComponents, 1278 &m_SrcHeight, &m_SrcComponents,
1281 &dummy_bpc, pAttribute); 1279 &dummy_bpc, pAttribute);
1282 m_SrcComponents = 4; 1280 m_SrcComponents = 4;
1283 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); 1281 m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
1284 if (!ret) { 1282 if (!ret) {
1285 pTiffModule->DestroyDecoder(m_pTiffContext); 1283 pTiffModule->DestroyDecoder(m_pTiffContext);
1286 m_pTiffContext = nullptr; 1284 m_pTiffContext = nullptr;
1287 m_status = FXCODEC_STATUS_ERR_FORMAT; 1285 m_status = FXCODEC_STATUS_ERR_FORMAT;
1288 return FALSE; 1286 return false;
1289 } 1287 }
1290 return TRUE; 1288 return true;
1291 } 1289 }
1292 default: 1290 default:
1293 m_status = FXCODEC_STATUS_ERR_FORMAT; 1291 m_status = FXCODEC_STATUS_ERR_FORMAT;
1294 return FALSE; 1292 return false;
1295 } 1293 }
1296 } 1294 }
1297 1295
1298 FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( 1296 FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo(
1299 IFX_SeekableReadStream* pFile, 1297 IFX_SeekableReadStream* pFile,
1300 FXCODEC_IMAGE_TYPE imageType, 1298 FXCODEC_IMAGE_TYPE imageType,
1301 CFX_DIBAttribute* pAttribute, 1299 CFX_DIBAttribute* pAttribute,
1302 bool bSkipImageTypeCheck) { 1300 bool bSkipImageTypeCheck) {
1303 switch (m_status) { 1301 switch (m_status) {
1304 case FXCODEC_STATUS_FRAME_READY: 1302 case FXCODEC_STATUS_FRAME_READY:
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 return FXCODEC_STATUS_ERROR; 1871 return FXCODEC_STATUS_ERROR;
1874 } 1872 }
1875 } 1873 }
1876 1874
1877 FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, 1875 FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
1878 int start_x, 1876 int start_x,
1879 int start_y, 1877 int start_y,
1880 int size_x, 1878 int size_x,
1881 int size_y, 1879 int size_y,
1882 int32_t frames, 1880 int32_t frames,
1883 FX_BOOL bInterpol) { 1881 bool bInterpol) {
1884 if (m_status != FXCODEC_STATUS_DECODE_READY) 1882 if (m_status != FXCODEC_STATUS_DECODE_READY)
1885 return FXCODEC_STATUS_ERROR; 1883 return FXCODEC_STATUS_ERROR;
1886 1884
1887 if (!pDIBitmap || pDIBitmap->GetBPP() < 8 || frames < 0 || 1885 if (!pDIBitmap || pDIBitmap->GetBPP() < 8 || frames < 0 ||
1888 frames >= m_FrameNumber) { 1886 frames >= m_FrameNumber) {
1889 return FXCODEC_STATUS_ERR_PARAMS; 1887 return FXCODEC_STATUS_ERR_PARAMS;
1890 } 1888 }
1891 m_pDeviceBitmap = pDIBitmap; 1889 m_pDeviceBitmap = pDIBitmap;
1892 if (m_clipBox.IsEmpty()) 1890 if (m_clipBox.IsEmpty())
1893 return FXCODEC_STATUS_ERR_PARAMS; 1891 return FXCODEC_STATUS_ERR_PARAMS;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 } 1926 }
1929 } 1927 }
1930 if (m_clipBox.IsEmpty()) { 1928 if (m_clipBox.IsEmpty()) {
1931 return FXCODEC_STATUS_ERR_PARAMS; 1929 return FXCODEC_STATUS_ERR_PARAMS;
1932 } 1930 }
1933 switch (m_imagType) { 1931 switch (m_imagType) {
1934 case FXCODEC_IMAGE_JPG: { 1932 case FXCODEC_IMAGE_JPG: {
1935 CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); 1933 CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
1936 int down_scale = 1; 1934 int down_scale = 1;
1937 GetDownScale(down_scale); 1935 GetDownScale(down_scale);
1938 FX_BOOL bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale); 1936 bool bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale);
1939 while (!bStart) { 1937 while (!bStart) {
1940 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR; 1938 FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR;
1941 if (!JpegReadMoreData(pJpegModule, error_status)) { 1939 if (!JpegReadMoreData(pJpegModule, error_status)) {
1942 m_pDeviceBitmap = nullptr; 1940 m_pDeviceBitmap = nullptr;
1943 m_pFile = nullptr; 1941 m_pFile = nullptr;
1944 m_status = error_status; 1942 m_status = error_status;
1945 return m_status; 1943 return m_status;
1946 } 1944 }
1947 bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale); 1945 bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale);
1948 } 1946 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 } 2079 }
2082 2080
2083 FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { 2081 FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
2084 if (m_status != FXCODEC_STATUS_DECODE_TOBECONTINUE) 2082 if (m_status != FXCODEC_STATUS_DECODE_TOBECONTINUE)
2085 return FXCODEC_STATUS_ERROR; 2083 return FXCODEC_STATUS_ERROR;
2086 2084
2087 switch (m_imagType) { 2085 switch (m_imagType) {
2088 case FXCODEC_IMAGE_JPG: { 2086 case FXCODEC_IMAGE_JPG: {
2089 CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); 2087 CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
2090 while (true) { 2088 while (true) {
2091 FX_BOOL readRes = 2089 bool readRes = pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf);
2092 pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf);
2093 while (!readRes) { 2090 while (!readRes) {
2094 FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; 2091 FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
2095 if (!JpegReadMoreData(pJpegModule, error_status)) { 2092 if (!JpegReadMoreData(pJpegModule, error_status)) {
2096 m_pDeviceBitmap = nullptr; 2093 m_pDeviceBitmap = nullptr;
2097 m_pFile = nullptr; 2094 m_pFile = nullptr;
2098 m_status = error_status; 2095 m_status = error_status;
2099 return m_status; 2096 return m_status;
2100 } 2097 }
2101 readRes = pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf); 2098 readRes = pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf);
2102 } 2099 }
(...skipping 30 matching lines...) Expand all
2133 m_pFile = nullptr; 2130 m_pFile = nullptr;
2134 m_status = FXCODEC_STATUS_DECODE_FINISH; 2131 m_status = FXCODEC_STATUS_DECODE_FINISH;
2135 return m_status; 2132 return m_status;
2136 } 2133 }
2137 if (m_pSrcBuf && input_size > m_SrcSize) { 2134 if (m_pSrcBuf && input_size > m_SrcSize) {
2138 FX_Free(m_pSrcBuf); 2135 FX_Free(m_pSrcBuf);
2139 m_pSrcBuf = FX_Alloc(uint8_t, input_size); 2136 m_pSrcBuf = FX_Alloc(uint8_t, input_size);
2140 FXSYS_memset(m_pSrcBuf, 0, input_size); 2137 FXSYS_memset(m_pSrcBuf, 0, input_size);
2141 m_SrcSize = input_size; 2138 m_SrcSize = input_size;
2142 } 2139 }
2143 FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); 2140 bool bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size);
2144 if (!bResult) { 2141 if (!bResult) {
2145 m_pDeviceBitmap = nullptr; 2142 m_pDeviceBitmap = nullptr;
2146 m_pFile = nullptr; 2143 m_pFile = nullptr;
2147 m_status = FXCODEC_STATUS_ERR_READ; 2144 m_status = FXCODEC_STATUS_ERR_READ;
2148 return m_status; 2145 return m_status;
2149 } 2146 }
2150 m_offSet += input_size; 2147 m_offSet += input_size;
2151 bResult = 2148 bResult =
2152 pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, nullptr); 2149 pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, nullptr);
2153 if (!bResult) { 2150 if (!bResult) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 return m_status; 2215 return m_status;
2219 } 2216 }
2220 m_pDeviceBitmap = nullptr; 2217 m_pDeviceBitmap = nullptr;
2221 m_pFile = nullptr; 2218 m_pFile = nullptr;
2222 m_status = FXCODEC_STATUS_ERROR; 2219 m_status = FXCODEC_STATUS_ERROR;
2223 return m_status; 2220 return m_status;
2224 } 2221 }
2225 }; 2222 };
2226 case FXCODEC_IMAGE_TIF: { 2223 case FXCODEC_IMAGE_TIF: {
2227 CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); 2224 CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
2228 FX_BOOL ret = FALSE; 2225 bool ret = false;
2229 if (m_pDeviceBitmap->GetBPP() == 32 && 2226 if (m_pDeviceBitmap->GetBPP() == 32 &&
2230 m_pDeviceBitmap->GetWidth() == m_SrcWidth && m_SrcWidth == m_sizeX && 2227 m_pDeviceBitmap->GetWidth() == m_SrcWidth && m_SrcWidth == m_sizeX &&
2231 m_pDeviceBitmap->GetHeight() == m_SrcHeight && 2228 m_pDeviceBitmap->GetHeight() == m_SrcHeight &&
2232 m_SrcHeight == m_sizeY && m_startX == 0 && m_startY == 0 && 2229 m_SrcHeight == m_sizeY && m_startX == 0 && m_startY == 0 &&
2233 m_clipBox.left == 0 && m_clipBox.top == 0 && 2230 m_clipBox.left == 0 && m_clipBox.top == 0 &&
2234 m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) { 2231 m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) {
2235 ret = pTiffModule->Decode(m_pTiffContext, m_pDeviceBitmap); 2232 ret = pTiffModule->Decode(m_pTiffContext, m_pDeviceBitmap);
2236 m_pDeviceBitmap = nullptr; 2233 m_pDeviceBitmap = nullptr;
2237 m_pFile = nullptr; 2234 m_pFile = nullptr;
2238 if (!ret) { 2235 if (!ret) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 return m_status; 2366 return m_status;
2370 } 2367 }
2371 default: 2368 default:
2372 return FXCODEC_STATUS_ERROR; 2369 return FXCODEC_STATUS_ERROR;
2373 } 2370 }
2374 } 2371 }
2375 2372
2376 CCodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() { 2373 CCodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() {
2377 return new CCodec_ProgressiveDecoder(this); 2374 return new CCodec_ProgressiveDecoder(this);
2378 } 2375 }
OLDNEW
« no previous file with comments | « core/fxcodec/codec/fx_codec_png.cpp ('k') | core/fxcodec/fx_codec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698