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

Side by Side Diff: core/fxcodec/jbig2/JBig2_Context.cpp

Issue 1821043003: Remove FX_WORD in favor of uint16_t. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use stdint.h directly, bitfield minefield. Created 4 years, 9 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/jbig2/JBig2_BitStream.cpp ('k') | core/fxcodec/jbig2/JBig2_GrdProc.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/jbig2/JBig2_Context.h" 7 #include "core/fxcodec/jbig2/JBig2_Context.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 FX_Alloc(FX_DWORD, pSegment->m_nReferred_to_segment_count); 295 FX_Alloc(FX_DWORD, pSegment->m_nReferred_to_segment_count);
296 for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) { 296 for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
297 switch (cSSize) { 297 switch (cSSize) {
298 case 1: 298 case 1:
299 if (m_pStream->read1Byte(&cTemp) != 0) 299 if (m_pStream->read1Byte(&cTemp) != 0)
300 return JBIG2_ERROR_TOO_SHORT; 300 return JBIG2_ERROR_TOO_SHORT;
301 301
302 pSegment->m_pReferred_to_segment_numbers[i] = cTemp; 302 pSegment->m_pReferred_to_segment_numbers[i] = cTemp;
303 break; 303 break;
304 case 2: 304 case 2:
305 FX_WORD wTemp; 305 uint16_t wTemp;
306 if (m_pStream->readShortInteger(&wTemp) != 0) 306 if (m_pStream->readShortInteger(&wTemp) != 0)
307 return JBIG2_ERROR_TOO_SHORT; 307 return JBIG2_ERROR_TOO_SHORT;
308 308
309 pSegment->m_pReferred_to_segment_numbers[i] = wTemp; 309 pSegment->m_pReferred_to_segment_numbers[i] = wTemp;
310 break; 310 break;
311 case 4: 311 case 4:
312 if (m_pStream->readInteger(&dwTemp) != 0) 312 if (m_pStream->readInteger(&dwTemp) != 0)
313 return JBIG2_ERROR_TOO_SHORT; 313 return JBIG2_ERROR_TOO_SHORT;
314 314
315 pSegment->m_pReferred_to_segment_numbers[i] = dwTemp; 315 pSegment->m_pReferred_to_segment_numbers[i] = dwTemp;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 if (!m_bInPage) 372 if (!m_bInPage)
373 return JBIG2_ERROR_FATAL; 373 return JBIG2_ERROR_FATAL;
374 return parseGenericRegion(pSegment, pPause); 374 return parseGenericRegion(pSegment, pPause);
375 case 40: 375 case 40:
376 case 42: 376 case 42:
377 case 43: 377 case 43:
378 if (!m_bInPage) 378 if (!m_bInPage)
379 return JBIG2_ERROR_FATAL; 379 return JBIG2_ERROR_FATAL;
380 return parseGenericRefinementRegion(pSegment); 380 return parseGenericRefinementRegion(pSegment);
381 case 48: { 381 case 48: {
382 FX_WORD wTemp; 382 uint16_t wTemp;
383 std::unique_ptr<JBig2PageInfo> pPageInfo(new JBig2PageInfo); 383 std::unique_ptr<JBig2PageInfo> pPageInfo(new JBig2PageInfo);
384 if (m_pStream->readInteger(&pPageInfo->m_dwWidth) != 0 || 384 if (m_pStream->readInteger(&pPageInfo->m_dwWidth) != 0 ||
385 m_pStream->readInteger(&pPageInfo->m_dwHeight) != 0 || 385 m_pStream->readInteger(&pPageInfo->m_dwHeight) != 0 ||
386 m_pStream->readInteger(&pPageInfo->m_dwResolutionX) != 0 || 386 m_pStream->readInteger(&pPageInfo->m_dwResolutionX) != 0 ||
387 m_pStream->readInteger(&pPageInfo->m_dwResolutionY) != 0 || 387 m_pStream->readInteger(&pPageInfo->m_dwResolutionY) != 0 ||
388 m_pStream->read1Byte(&pPageInfo->m_cFlags) != 0 || 388 m_pStream->read1Byte(&pPageInfo->m_cFlags) != 0 ||
389 m_pStream->readShortInteger(&wTemp) != 0) { 389 m_pStream->readShortInteger(&wTemp) != 0) {
390 return JBIG2_ERROR_TOO_SHORT; 390 return JBIG2_ERROR_TOO_SHORT;
391 } 391 }
392 pPageInfo->m_bIsStriped = !!(wTemp & 0x8000); 392 pPageInfo->m_bIsStriped = !!(wTemp & 0x8000);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 m_pStream->offset(pSegment->m_dwData_length); 428 m_pStream->offset(pSegment->m_dwData_length);
429 break; 429 break;
430 default: 430 default:
431 break; 431 break;
432 } 432 }
433 return JBIG2_SUCCESS; 433 return JBIG2_SUCCESS;
434 } 434 }
435 435
436 int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment, 436 int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
437 IFX_Pause* pPause) { 437 IFX_Pause* pPause) {
438 FX_WORD wFlags; 438 uint16_t wFlags;
439 if (m_pStream->readShortInteger(&wFlags) != 0) 439 if (m_pStream->readShortInteger(&wFlags) != 0)
440 return JBIG2_ERROR_TOO_SHORT; 440 return JBIG2_ERROR_TOO_SHORT;
441 441
442 std::unique_ptr<CJBig2_SDDProc> pSymbolDictDecoder(new CJBig2_SDDProc); 442 std::unique_ptr<CJBig2_SDDProc> pSymbolDictDecoder(new CJBig2_SDDProc);
443 pSymbolDictDecoder->SDHUFF = wFlags & 0x0001; 443 pSymbolDictDecoder->SDHUFF = wFlags & 0x0001;
444 pSymbolDictDecoder->SDREFAGG = (wFlags >> 1) & 0x0001; 444 pSymbolDictDecoder->SDREFAGG = (wFlags >> 1) & 0x0001;
445 pSymbolDictDecoder->SDTEMPLATE = (wFlags >> 10) & 0x0003; 445 pSymbolDictDecoder->SDTEMPLATE = (wFlags >> 10) & 0x0003;
446 pSymbolDictDecoder->SDRTEMPLATE = (wFlags >> 12) & 0x0003; 446 pSymbolDictDecoder->SDRTEMPLATE = (wFlags >> 12) & 0x0003;
447 uint8_t cSDHUFFDH = (wFlags >> 2) & 0x0003; 447 uint8_t cSDHUFFDH = (wFlags >> 2) & 0x0003;
448 uint8_t cSDHUFFDW = (wFlags >> 4) & 0x0003; 448 uint8_t cSDHUFFDW = (wFlags >> 4) & 0x0003;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 if (wFlags & 0x0200) { 646 if (wFlags & 0x0200) {
647 if (bUseGbContext) 647 if (bUseGbContext)
648 pSegment->m_Result.sd->SetGbContext(gbContext); 648 pSegment->m_Result.sd->SetGbContext(gbContext);
649 if (bUseGrContext) 649 if (bUseGrContext)
650 pSegment->m_Result.sd->SetGrContext(grContext); 650 pSegment->m_Result.sd->SetGrContext(grContext);
651 } 651 }
652 return JBIG2_SUCCESS; 652 return JBIG2_SUCCESS;
653 } 653 }
654 654
655 int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) { 655 int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
656 FX_WORD wFlags; 656 uint16_t wFlags;
657 JBig2RegionInfo ri; 657 JBig2RegionInfo ri;
658 if (parseRegionInfo(&ri) != JBIG2_SUCCESS || 658 if (parseRegionInfo(&ri) != JBIG2_SUCCESS ||
659 m_pStream->readShortInteger(&wFlags) != 0) { 659 m_pStream->readShortInteger(&wFlags) != 0) {
660 return JBIG2_ERROR_TOO_SHORT; 660 return JBIG2_ERROR_TOO_SHORT;
661 } 661 }
662 662
663 std::unique_ptr<CJBig2_TRDProc> pTRD(new CJBig2_TRDProc); 663 std::unique_ptr<CJBig2_TRDProc> pTRD(new CJBig2_TRDProc);
664 pTRD->SBW = ri.width; 664 pTRD->SBW = ri.width;
665 pTRD->SBH = ri.height; 665 pTRD->SBH = ri.height;
666 pTRD->SBHUFF = wFlags & 0x0001; 666 pTRD->SBHUFF = wFlags & 0x0001;
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 SBSYMCODES[CURTEMP].code = CURCODE; 1408 SBSYMCODES[CURTEMP].code = CURCODE;
1409 CURCODE = CURCODE + 1; 1409 CURCODE = CURCODE + 1;
1410 } 1410 }
1411 CURTEMP = CURTEMP + 1; 1411 CURTEMP = CURTEMP + 1;
1412 } 1412 }
1413 CURLEN = CURLEN + 1; 1413 CURLEN = CURLEN + 1;
1414 } 1414 }
1415 FX_Free(LENCOUNT); 1415 FX_Free(LENCOUNT);
1416 FX_Free(FIRSTCODE); 1416 FX_Free(FIRSTCODE);
1417 } 1417 }
OLDNEW
« no previous file with comments | « core/fxcodec/jbig2/JBig2_BitStream.cpp ('k') | core/fxcodec/jbig2/JBig2_GrdProc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698