| OLD | NEW |
| 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/src/fxcodec/jbig2/JBig2_HuffmanTable.h" | 7 #include "core/fxcodec/jbig2/JBig2_HuffmanTable.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "core/fxcodec/jbig2/JBig2_BitStream.h" |
| 13 #include "core/fxcodec/jbig2/JBig2_Define.h" |
| 14 #include "core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h" |
| 12 #include "core/include/fxcrt/fx_memory.h" | 15 #include "core/include/fxcrt/fx_memory.h" |
| 13 #include "core/src/fxcodec/jbig2/JBig2_BitStream.h" | |
| 14 #include "core/src/fxcodec/jbig2/JBig2_Define.h" | |
| 15 #include "core/src/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h" | |
| 16 | 16 |
| 17 CJBig2_HuffmanTable::CJBig2_HuffmanTable(const JBig2TableLine* pTable, | 17 CJBig2_HuffmanTable::CJBig2_HuffmanTable(const JBig2TableLine* pTable, |
| 18 FX_DWORD nLines, | 18 FX_DWORD nLines, |
| 19 bool bHTOOB) | 19 bool bHTOOB) |
| 20 : m_bOK(true), HTOOB(bHTOOB), NTEMP(nLines) { | 20 : m_bOK(true), HTOOB(bHTOOB), NTEMP(nLines) { |
| 21 ParseFromStandardTable(pTable); | 21 ParseFromStandardTable(pTable); |
| 22 } | 22 } |
| 23 | 23 |
| 24 CJBig2_HuffmanTable::CJBig2_HuffmanTable(CJBig2_BitStream* pStream) | 24 CJBig2_HuffmanTable::CJBig2_HuffmanTable(CJBig2_BitStream* pStream) |
| 25 : HTOOB(false), NTEMP(0) { | 25 : HTOOB(false), NTEMP(0) { |
| 26 m_bOK = ParseFromCodedBuffer(pStream); | 26 m_bOK = ParseFromCodedBuffer(pStream); |
| 27 } | 27 } |
| 28 | 28 |
| 29 CJBig2_HuffmanTable::~CJBig2_HuffmanTable() { | 29 CJBig2_HuffmanTable::~CJBig2_HuffmanTable() {} |
| 30 } | |
| 31 | 30 |
| 32 void CJBig2_HuffmanTable::ParseFromStandardTable(const JBig2TableLine* pTable) { | 31 void CJBig2_HuffmanTable::ParseFromStandardTable(const JBig2TableLine* pTable) { |
| 33 PREFLEN.resize(NTEMP); | 32 PREFLEN.resize(NTEMP); |
| 34 RANGELEN.resize(NTEMP); | 33 RANGELEN.resize(NTEMP); |
| 35 RANGELOW.resize(NTEMP); | 34 RANGELOW.resize(NTEMP); |
| 36 for (FX_DWORD i = 0; i < NTEMP; ++i) { | 35 for (FX_DWORD i = 0; i < NTEMP; ++i) { |
| 37 PREFLEN[i] = pTable[i].PREFLEN; | 36 PREFLEN[i] = pTable[i].PREFLEN; |
| 38 RANGELEN[i] = pTable[i].RANDELEN; | 37 RANGELEN[i] = pTable[i].RANDELEN; |
| 39 RANGELOW[i] = pTable[i].RANGELOW; | 38 RANGELOW[i] = pTable[i].RANGELOW; |
| 40 } | 39 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 size_t size = PREFLEN.size(); | 127 size_t size = PREFLEN.size(); |
| 129 if (NTEMP < size) | 128 if (NTEMP < size) |
| 130 return; | 129 return; |
| 131 | 130 |
| 132 size += 16; | 131 size += 16; |
| 133 ASSERT(NTEMP < size); | 132 ASSERT(NTEMP < size); |
| 134 PREFLEN.resize(size); | 133 PREFLEN.resize(size); |
| 135 RANGELEN.resize(size); | 134 RANGELEN.resize(size); |
| 136 RANGELOW.resize(size); | 135 RANGELOW.resize(size); |
| 137 } | 136 } |
| OLD | NEW |