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

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

Issue 1536923002: Cleanup CJBig2_HuffmanTable and friends. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years 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 | « no previous file | core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "JBig2_Context.h" 7 #include "core/src/fxcodec/jbig2/JBig2_Context.h"
8 8
9 #include <algorithm>
9 #include <list> 10 #include <list>
11 #include <vector>
10 12
11 #include "JBig2_ArithDecoder.h" 13 #include "core/src/fxcodec/jbig2/JBig2_ArithDecoder.h"
12 #include "JBig2_GrdProc.h" 14 #include "core/src/fxcodec/jbig2/JBig2_BitStream.h"
13 #include "JBig2_GrrdProc.h" 15 #include "core/src/fxcodec/jbig2/JBig2_GrdProc.h"
14 #include "JBig2_HtrdProc.h" 16 #include "core/src/fxcodec/jbig2/JBig2_GrrdProc.h"
15 #include "JBig2_PddProc.h" 17 #include "core/src/fxcodec/jbig2/JBig2_HtrdProc.h"
16 #include "JBig2_SddProc.h" 18 #include "core/src/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h"
17 #include "JBig2_TrdProc.h" 19 #include "core/src/fxcodec/jbig2/JBig2_PddProc.h"
20 #include "core/src/fxcodec/jbig2/JBig2_SddProc.h"
21 #include "core/src/fxcodec/jbig2/JBig2_TrdProc.h"
18 22
19 namespace { 23 namespace {
20 24
21 size_t GetHuffContextSize(uint8_t val) { 25 size_t GetHuffContextSize(uint8_t val) {
22 return val == 0 ? 65536 : val == 1 ? 8192 : 1024; 26 return val == 0 ? 65536 : val == 1 ? 8192 : 1024;
23 } 27 }
24 28
25 size_t GetRefAggContextSize(FX_BOOL val) { 29 size_t GetRefAggContextSize(FX_BOOL val) {
26 return val ? 1024 : 8192; 30 return val ? 1024 : 8192;
27 } 31 }
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im, 1259 m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im,
1256 (JBig2ComposeOp)(ri.flags & 0x03)); 1260 (JBig2ComposeOp)(ri.flags & 0x03));
1257 delete pSegment->m_Result.im; 1261 delete pSegment->m_Result.im;
1258 pSegment->m_Result.im = NULL; 1262 pSegment->m_Result.im = NULL;
1259 } 1263 }
1260 return JBIG2_SUCCESS; 1264 return JBIG2_SUCCESS;
1261 } 1265 }
1262 1266
1263 int32_t CJBig2_Context::parseTable(CJBig2_Segment* pSegment) { 1267 int32_t CJBig2_Context::parseTable(CJBig2_Segment* pSegment) {
1264 pSegment->m_nResultType = JBIG2_HUFFMAN_TABLE_POINTER; 1268 pSegment->m_nResultType = JBIG2_HUFFMAN_TABLE_POINTER;
1265 pSegment->m_Result.ht = new CJBig2_HuffmanTable(m_pStream.get()); 1269 pSegment->m_Result.ht = nullptr;
1266 if (!pSegment->m_Result.ht->isOK()) { 1270 nonstd::unique_ptr<CJBig2_HuffmanTable> pHuff(
1267 delete pSegment->m_Result.ht; 1271 new CJBig2_HuffmanTable(m_pStream.get()));
1268 pSegment->m_Result.ht = NULL; 1272 if (!pHuff->IsOK())
1269 return JBIG2_ERROR_FATAL; 1273 return JBIG2_ERROR_FATAL;
1270 } 1274
1275 pSegment->m_Result.ht = pHuff.release();
1271 m_pStream->alignByte(); 1276 m_pStream->alignByte();
1272 return JBIG2_SUCCESS; 1277 return JBIG2_SUCCESS;
1273 } 1278 }
1274 1279
1275 int32_t CJBig2_Context::parseRegionInfo(JBig2RegionInfo* pRI) { 1280 int32_t CJBig2_Context::parseRegionInfo(JBig2RegionInfo* pRI) {
1276 if (m_pStream->readInteger((FX_DWORD*)&pRI->width) != 0 || 1281 if (m_pStream->readInteger((FX_DWORD*)&pRI->width) != 0 ||
1277 m_pStream->readInteger((FX_DWORD*)&pRI->height) != 0 || 1282 m_pStream->readInteger((FX_DWORD*)&pRI->height) != 0 ||
1278 m_pStream->readInteger((FX_DWORD*)&pRI->x) != 0 || 1283 m_pStream->readInteger((FX_DWORD*)&pRI->x) != 0 ||
1279 m_pStream->readInteger((FX_DWORD*)&pRI->y) != 0 || 1284 m_pStream->readInteger((FX_DWORD*)&pRI->y) != 0 ||
1280 m_pStream->read1Byte(&pRI->flags) != 0) { 1285 m_pStream->read1Byte(&pRI->flags) != 0) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 SBSYMCODES[CURTEMP].code = CURCODE; 1425 SBSYMCODES[CURTEMP].code = CURCODE;
1421 CURCODE = CURCODE + 1; 1426 CURCODE = CURCODE + 1;
1422 } 1427 }
1423 CURTEMP = CURTEMP + 1; 1428 CURTEMP = CURTEMP + 1;
1424 } 1429 }
1425 CURLEN = CURLEN + 1; 1430 CURLEN = CURLEN + 1;
1426 } 1431 }
1427 FX_Free(LENCOUNT); 1432 FX_Free(LENCOUNT);
1428 FX_Free(FIRSTCODE); 1433 FX_Free(FIRSTCODE);
1429 } 1434 }
OLDNEW
« no previous file with comments | « no previous file | core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698