| 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/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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Implement a very small least recently used (LRU) cache. It is very | 39 // Implement a very small least recently used (LRU) cache. It is very |
| 40 // common for a JBIG2 dictionary to span multiple pages in a PDF file, | 40 // common for a JBIG2 dictionary to span multiple pages in a PDF file, |
| 41 // and we do not want to decode the same dictionary over and over | 41 // and we do not want to decode the same dictionary over and over |
| 42 // again. We key off of the memory location of the dictionary. The | 42 // again. We key off of the memory location of the dictionary. The |
| 43 // list keeps track of the freshness of entries, with freshest ones | 43 // list keeps track of the freshness of entries, with freshest ones |
| 44 // at the front. Even a tiny cache size like 2 makes a dramatic | 44 // at the front. Even a tiny cache size like 2 makes a dramatic |
| 45 // difference for typical JBIG2 documents. | 45 // difference for typical JBIG2 documents. |
| 46 static const int kSymbolDictCacheMaxSize = 2; | 46 static const int kSymbolDictCacheMaxSize = 2; |
| 47 | 47 |
| 48 CJBig2_Context* CJBig2_Context::CreateContext( | |
| 49 CPDF_StreamAcc* pGlobalStream, | |
| 50 CPDF_StreamAcc* pSrcStream, | |
| 51 std::list<CJBig2_CachePair>* pSymbolDictCache, | |
| 52 IFX_Pause* pPause) { | |
| 53 return new CJBig2_Context(pGlobalStream, pSrcStream, pSymbolDictCache, pPause, | |
| 54 false); | |
| 55 } | |
| 56 | |
| 57 void CJBig2_Context::DestroyContext(CJBig2_Context* pContext) { | |
| 58 delete pContext; | |
| 59 } | |
| 60 | |
| 61 CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream, | 48 CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream, |
| 62 CPDF_StreamAcc* pSrcStream, | 49 CPDF_StreamAcc* pSrcStream, |
| 63 std::list<CJBig2_CachePair>* pSymbolDictCache, | 50 std::list<CJBig2_CachePair>* pSymbolDictCache, |
| 64 IFX_Pause* pPause, | 51 IFX_Pause* pPause, |
| 65 bool bIsGlobal) | 52 bool bIsGlobal) |
| 66 : m_nSegmentDecoded(0), | 53 : m_nSegmentDecoded(0), |
| 67 m_bInPage(false), | 54 m_bInPage(false), |
| 68 m_bBufSpecified(false), | 55 m_bBufSpecified(false), |
| 69 m_PauseStep(10), | 56 m_PauseStep(10), |
| 70 m_pPause(pPause), | 57 m_pPause(pPause), |
| 71 m_ProcessingStatus(FXCODEC_STATUS_FRAME_READY), | 58 m_ProcessingStatus(FXCODEC_STATUS_FRAME_READY), |
| 72 m_gbContext(nullptr), | |
| 73 m_dwOffset(0), | 59 m_dwOffset(0), |
| 74 m_pSymbolDictCache(pSymbolDictCache), | 60 m_pSymbolDictCache(pSymbolDictCache), |
| 75 m_bIsGlobal(bIsGlobal) { | 61 m_bIsGlobal(bIsGlobal) { |
| 76 if (pGlobalStream && (pGlobalStream->GetSize() > 0)) { | 62 if (pGlobalStream && (pGlobalStream->GetSize() > 0)) { |
| 77 m_pGlobalContext = new CJBig2_Context(nullptr, pGlobalStream, | 63 m_pGlobalContext.reset(new CJBig2_Context(nullptr, pGlobalStream, |
| 78 pSymbolDictCache, pPause, true); | 64 pSymbolDictCache, pPause, true)); |
| 79 } else { | |
| 80 m_pGlobalContext = nullptr; | |
| 81 } | 65 } |
| 82 | |
| 83 m_pStream.reset(new CJBig2_BitStream(pSrcStream)); | 66 m_pStream.reset(new CJBig2_BitStream(pSrcStream)); |
| 84 } | 67 } |
| 85 | 68 |
| 86 CJBig2_Context::~CJBig2_Context() { | 69 CJBig2_Context::~CJBig2_Context() {} |
| 87 FX_Free(m_gbContext); | |
| 88 m_gbContext = nullptr; | |
| 89 delete m_pGlobalContext; | |
| 90 m_pGlobalContext = nullptr; | |
| 91 } | |
| 92 | 70 |
| 93 int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) { | 71 int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) { |
| 94 int32_t nRet; | 72 int32_t nRet; |
| 95 if (m_pStream->getByteLeft() <= 0) | 73 if (m_pStream->getByteLeft() <= 0) |
| 96 return JBIG2_END_OF_FILE; | 74 return JBIG2_END_OF_FILE; |
| 97 | 75 |
| 98 while (m_pStream->getByteLeft() >= JBIG2_MIN_SEGMENT_SIZE) { | 76 while (m_pStream->getByteLeft() >= JBIG2_MIN_SEGMENT_SIZE) { |
| 99 if (!m_pSegment) { | 77 if (!m_pSegment) { |
| 100 m_pSegment.reset(new CJBig2_Segment); | 78 m_pSegment.reset(new CJBig2_Segment); |
| 101 nRet = parseSegmentHeader(m_pSegment.get()); | 79 nRet = parseSegmentHeader(m_pSegment.get()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 128 m_SegmentList.push_back(m_pSegment.release()); | 106 m_SegmentList.push_back(m_pSegment.release()); |
| 129 if (m_pStream->getByteLeft() > 0 && m_pPage && pPause && | 107 if (m_pStream->getByteLeft() > 0 && m_pPage && pPause && |
| 130 pPause->NeedToPauseNow()) { | 108 pPause->NeedToPauseNow()) { |
| 131 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; | 109 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; |
| 132 m_PauseStep = 2; | 110 m_PauseStep = 2; |
| 133 return JBIG2_SUCCESS; | 111 return JBIG2_SUCCESS; |
| 134 } | 112 } |
| 135 } | 113 } |
| 136 return JBIG2_SUCCESS; | 114 return JBIG2_SUCCESS; |
| 137 } | 115 } |
| 116 |
| 138 int32_t CJBig2_Context::decode_EmbedOrgnazation(IFX_Pause* pPause) { | 117 int32_t CJBig2_Context::decode_EmbedOrgnazation(IFX_Pause* pPause) { |
| 139 return decode_SquentialOrgnazation(pPause); | 118 return decode_SquentialOrgnazation(pPause); |
| 140 } | 119 } |
| 120 |
| 141 int32_t CJBig2_Context::decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause) { | 121 int32_t CJBig2_Context::decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause) { |
| 142 int32_t nRet; | 122 int32_t nRet; |
| 143 while (m_pStream->getByteLeft() > JBIG2_MIN_SEGMENT_SIZE) { | 123 while (m_pStream->getByteLeft() > JBIG2_MIN_SEGMENT_SIZE) { |
| 144 std::unique_ptr<CJBig2_Segment> pSegment(new CJBig2_Segment); | 124 std::unique_ptr<CJBig2_Segment> pSegment(new CJBig2_Segment); |
| 145 nRet = parseSegmentHeader(pSegment.get()); | 125 nRet = parseSegmentHeader(pSegment.get()); |
| 146 if (nRet != JBIG2_SUCCESS) { | 126 if (nRet != JBIG2_SUCCESS) { |
| 147 return nRet; | 127 return nRet; |
| 148 } else if (pSegment->m_cFlags.s.type == 51) { | 128 } else if (pSegment->m_cFlags.s.type == 51) { |
| 149 break; | 129 break; |
| 150 } | 130 } |
| 151 m_SegmentList.push_back(pSegment.release()); | 131 m_SegmentList.push_back(pSegment.release()); |
| 152 if (pPause && m_pPause && pPause->NeedToPauseNow()) { | 132 if (pPause && m_pPause && pPause->NeedToPauseNow()) { |
| 153 m_PauseStep = 3; | 133 m_PauseStep = 3; |
| 154 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; | 134 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; |
| 155 return JBIG2_SUCCESS; | 135 return JBIG2_SUCCESS; |
| 156 } | 136 } |
| 157 } | 137 } |
| 158 m_nSegmentDecoded = 0; | 138 m_nSegmentDecoded = 0; |
| 159 return decode_RandomOrgnazation(pPause); | 139 return decode_RandomOrgnazation(pPause); |
| 160 } | 140 } |
| 141 |
| 161 int32_t CJBig2_Context::decode_RandomOrgnazation(IFX_Pause* pPause) { | 142 int32_t CJBig2_Context::decode_RandomOrgnazation(IFX_Pause* pPause) { |
| 162 for (; m_nSegmentDecoded < m_SegmentList.size(); ++m_nSegmentDecoded) { | 143 for (; m_nSegmentDecoded < m_SegmentList.size(); ++m_nSegmentDecoded) { |
| 163 int32_t nRet = | 144 int32_t nRet = |
| 164 parseSegmentData(m_SegmentList.get(m_nSegmentDecoded), pPause); | 145 parseSegmentData(m_SegmentList.get(m_nSegmentDecoded), pPause); |
| 165 if (nRet == JBIG2_END_OF_PAGE || nRet == JBIG2_END_OF_FILE) | 146 if (nRet == JBIG2_END_OF_PAGE || nRet == JBIG2_END_OF_FILE) |
| 166 return JBIG2_SUCCESS; | 147 return JBIG2_SUCCESS; |
| 167 | 148 |
| 168 if (nRet != JBIG2_SUCCESS) | 149 if (nRet != JBIG2_SUCCESS) |
| 169 return nRet; | 150 return nRet; |
| 170 | 151 |
| 171 if (m_pPage && pPause && pPause->NeedToPauseNow()) { | 152 if (m_pPage && pPause && pPause->NeedToPauseNow()) { |
| 172 m_PauseStep = 4; | 153 m_PauseStep = 4; |
| 173 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; | 154 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; |
| 174 return JBIG2_SUCCESS; | 155 return JBIG2_SUCCESS; |
| 175 } | 156 } |
| 176 } | 157 } |
| 177 return JBIG2_SUCCESS; | 158 return JBIG2_SUCCESS; |
| 178 } | 159 } |
| 160 |
| 179 int32_t CJBig2_Context::getFirstPage(uint8_t* pBuf, | 161 int32_t CJBig2_Context::getFirstPage(uint8_t* pBuf, |
| 180 int32_t width, | 162 int32_t width, |
| 181 int32_t height, | 163 int32_t height, |
| 182 int32_t stride, | 164 int32_t stride, |
| 183 IFX_Pause* pPause) { | 165 IFX_Pause* pPause) { |
| 184 int32_t nRet = 0; | 166 int32_t nRet = 0; |
| 185 if (m_pGlobalContext) { | 167 if (m_pGlobalContext) { |
| 186 nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause); | 168 nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause); |
| 187 if (nRet != JBIG2_SUCCESS) { | 169 if (nRet != JBIG2_SUCCESS) { |
| 188 m_ProcessingStatus = FXCODEC_STATUS_ERROR; | 170 m_ProcessingStatus = FXCODEC_STATUS_ERROR; |
| 189 return nRet; | 171 return nRet; |
| 190 } | 172 } |
| 191 } | 173 } |
| 192 m_PauseStep = 0; | 174 m_PauseStep = 0; |
| 193 m_pPage.reset(new CJBig2_Image(width, height, stride, pBuf)); | 175 m_pPage.reset(new CJBig2_Image(width, height, stride, pBuf)); |
| 194 m_bBufSpecified = true; | 176 m_bBufSpecified = true; |
| 195 if (pPause && pPause->NeedToPauseNow()) { | 177 if (pPause && pPause->NeedToPauseNow()) { |
| 196 m_PauseStep = 1; | 178 m_PauseStep = 1; |
| 197 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; | 179 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; |
| 198 return nRet; | 180 return nRet; |
| 199 } | 181 } |
| 200 return Continue(pPause); | 182 return Continue(pPause); |
| 201 } | 183 } |
| 184 |
| 202 int32_t CJBig2_Context::Continue(IFX_Pause* pPause) { | 185 int32_t CJBig2_Context::Continue(IFX_Pause* pPause) { |
| 203 m_ProcessingStatus = FXCODEC_STATUS_DECODE_READY; | 186 m_ProcessingStatus = FXCODEC_STATUS_DECODE_READY; |
| 204 int32_t nRet = 0; | 187 int32_t nRet = 0; |
| 205 if (m_PauseStep <= 1) { | 188 if (m_PauseStep <= 1) { |
| 206 nRet = decode_EmbedOrgnazation(pPause); | 189 nRet = decode_EmbedOrgnazation(pPause); |
| 207 } else if (m_PauseStep == 2) { | 190 } else if (m_PauseStep == 2) { |
| 208 nRet = decode_SquentialOrgnazation(pPause); | 191 nRet = decode_SquentialOrgnazation(pPause); |
| 209 } else if (m_PauseStep == 3) { | 192 } else if (m_PauseStep == 3) { |
| 210 nRet = decode_RandomOrgnazation_FirstPage(pPause); | 193 nRet = decode_RandomOrgnazation_FirstPage(pPause); |
| 211 } else if (m_PauseStep == 4) { | 194 } else if (m_PauseStep == 4) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 238 } | 221 } |
| 239 } | 222 } |
| 240 for (size_t i = 0; i < m_SegmentList.size(); ++i) { | 223 for (size_t i = 0; i < m_SegmentList.size(); ++i) { |
| 241 CJBig2_Segment* pSeg = m_SegmentList.get(i); | 224 CJBig2_Segment* pSeg = m_SegmentList.get(i); |
| 242 if (pSeg->m_dwNumber == dwNumber) { | 225 if (pSeg->m_dwNumber == dwNumber) { |
| 243 return pSeg; | 226 return pSeg; |
| 244 } | 227 } |
| 245 } | 228 } |
| 246 return nullptr; | 229 return nullptr; |
| 247 } | 230 } |
| 231 |
| 248 CJBig2_Segment* CJBig2_Context::findReferredSegmentByTypeAndIndex( | 232 CJBig2_Segment* CJBig2_Context::findReferredSegmentByTypeAndIndex( |
| 249 CJBig2_Segment* pSegment, | 233 CJBig2_Segment* pSegment, |
| 250 uint8_t cType, | 234 uint8_t cType, |
| 251 int32_t nIndex) { | 235 int32_t nIndex) { |
| 252 int32_t count = 0; | 236 int32_t count = 0; |
| 253 for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) { | 237 for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) { |
| 254 CJBig2_Segment* pSeg = | 238 CJBig2_Segment* pSeg = |
| 255 findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]); | 239 findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]); |
| 256 if (pSeg && pSeg->m_cFlags.s.type == cType) { | 240 if (pSeg && pSeg->m_cFlags.s.type == cType) { |
| 257 if (count == nIndex) | 241 if (count == nIndex) |
| 258 return pSeg; | 242 return pSeg; |
| 259 ++count; | 243 ++count; |
| 260 } | 244 } |
| 261 } | 245 } |
| 262 return nullptr; | 246 return nullptr; |
| 263 } | 247 } |
| 248 |
| 264 int32_t CJBig2_Context::parseSegmentHeader(CJBig2_Segment* pSegment) { | 249 int32_t CJBig2_Context::parseSegmentHeader(CJBig2_Segment* pSegment) { |
| 265 if (m_pStream->readInteger(&pSegment->m_dwNumber) != 0 || | 250 if (m_pStream->readInteger(&pSegment->m_dwNumber) != 0 || |
| 266 m_pStream->read1Byte(&pSegment->m_cFlags.c) != 0) { | 251 m_pStream->read1Byte(&pSegment->m_cFlags.c) != 0) { |
| 267 return JBIG2_ERROR_TOO_SHORT; | 252 return JBIG2_ERROR_TOO_SHORT; |
| 268 } | 253 } |
| 269 | 254 |
| 270 uint32_t dwTemp; | 255 uint32_t dwTemp; |
| 271 uint8_t cTemp = m_pStream->getCurByte(); | 256 uint8_t cTemp = m_pStream->getCurByte(); |
| 272 if ((cTemp >> 5) == 7) { | 257 if ((cTemp >> 5) == 7) { |
| 273 if (m_pStream->readInteger( | 258 if (m_pStream->readInteger( |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 return JBIG2_ERROR_TOO_SHORT; | 1084 return JBIG2_ERROR_TOO_SHORT; |
| 1100 } | 1085 } |
| 1101 } | 1086 } |
| 1102 } | 1087 } |
| 1103 } | 1088 } |
| 1104 pGRD->USESKIP = 0; | 1089 pGRD->USESKIP = 0; |
| 1105 m_pGRD = std::move(pGRD); | 1090 m_pGRD = std::move(pGRD); |
| 1106 } | 1091 } |
| 1107 pSegment->m_nResultType = JBIG2_IMAGE_POINTER; | 1092 pSegment->m_nResultType = JBIG2_IMAGE_POINTER; |
| 1108 if (m_pGRD->MMR == 0) { | 1093 if (m_pGRD->MMR == 0) { |
| 1109 if (!m_gbContext) { | 1094 if (m_gbContext.empty()) { |
| 1110 const size_t size = GetHuffContextSize(m_pGRD->GBTEMPLATE); | 1095 const size_t size = GetHuffContextSize(m_pGRD->GBTEMPLATE); |
| 1111 m_gbContext = FX_Alloc(JBig2ArithCtx, size); | 1096 m_gbContext.resize(size); |
| 1112 JBIG2_memset(m_gbContext, 0, sizeof(JBig2ArithCtx) * size); | |
| 1113 } | 1097 } |
| 1114 if (!m_pArithDecoder) { | 1098 if (!m_pArithDecoder) { |
| 1115 m_pArithDecoder.reset(new CJBig2_ArithDecoder(m_pStream.get())); | 1099 m_pArithDecoder.reset(new CJBig2_ArithDecoder(m_pStream.get())); |
| 1116 m_ProcessingStatus = m_pGRD->Start_decode_Arith( | 1100 m_ProcessingStatus = m_pGRD->Start_decode_Arith(&pSegment->m_Result.im, |
| 1117 &pSegment->m_Result.im, m_pArithDecoder.get(), m_gbContext, pPause); | 1101 m_pArithDecoder.get(), |
| 1102 &m_gbContext[0], pPause); |
| 1118 } else { | 1103 } else { |
| 1119 m_ProcessingStatus = m_pGRD->Continue_decode(pPause); | 1104 m_ProcessingStatus = m_pGRD->Continue_decode(pPause); |
| 1120 } | 1105 } |
| 1121 if (m_ProcessingStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) { | 1106 if (m_ProcessingStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) { |
| 1122 if (pSegment->m_cFlags.s.type != 36) { | 1107 if (pSegment->m_cFlags.s.type != 36) { |
| 1123 if (!m_bBufSpecified) { | 1108 if (!m_bBufSpecified) { |
| 1124 JBig2PageInfo* pPageInfo = m_PageInfoList.back(); | 1109 JBig2PageInfo* pPageInfo = m_PageInfoList.back(); |
| 1125 if ((pPageInfo->m_bIsStriped == 1) && | 1110 if ((pPageInfo->m_bIsStriped == 1) && |
| 1126 (m_ri.y + m_ri.height > m_pPage->m_nHeight)) { | 1111 (m_ri.y + m_ri.height > m_pPage->m_nHeight)) { |
| 1127 m_pPage->expand(m_ri.y + m_ri.height, | 1112 m_pPage->expand(m_ri.y + m_ri.height, |
| 1128 (pPageInfo->m_cFlags & 4) ? 1 : 0); | 1113 (pPageInfo->m_cFlags & 4) ? 1 : 0); |
| 1129 } | 1114 } |
| 1130 } | 1115 } |
| 1131 FX_RECT Rect = m_pGRD->GetReplaceRect(); | 1116 FX_RECT Rect = m_pGRD->GetReplaceRect(); |
| 1132 m_pPage->composeFrom(m_ri.x + Rect.left, m_ri.y + Rect.top, | 1117 m_pPage->composeFrom(m_ri.x + Rect.left, m_ri.y + Rect.top, |
| 1133 pSegment->m_Result.im, | 1118 pSegment->m_Result.im, |
| 1134 (JBig2ComposeOp)(m_ri.flags & 0x03), &Rect); | 1119 (JBig2ComposeOp)(m_ri.flags & 0x03), &Rect); |
| 1135 } | 1120 } |
| 1136 return JBIG2_SUCCESS; | 1121 return JBIG2_SUCCESS; |
| 1137 } else { | 1122 } else { |
| 1138 m_pArithDecoder.reset(); | 1123 m_pArithDecoder.reset(); |
| 1139 FX_Free(m_gbContext); | 1124 m_gbContext.clear(); |
| 1140 m_gbContext = nullptr; | |
| 1141 if (!pSegment->m_Result.im) { | 1125 if (!pSegment->m_Result.im) { |
| 1142 m_ProcessingStatus = FXCODEC_STATUS_ERROR; | 1126 m_ProcessingStatus = FXCODEC_STATUS_ERROR; |
| 1143 m_pGRD.reset(); | 1127 m_pGRD.reset(); |
| 1144 return JBIG2_ERROR_FATAL; | 1128 return JBIG2_ERROR_FATAL; |
| 1145 } | 1129 } |
| 1146 m_pStream->alignByte(); | 1130 m_pStream->alignByte(); |
| 1147 m_pStream->offset(2); | 1131 m_pStream->offset(2); |
| 1148 } | 1132 } |
| 1149 } else { | 1133 } else { |
| 1150 m_pGRD->Start_decode_MMR(&pSegment->m_Result.im, m_pStream.get(), pPause); | 1134 m_pGRD->Start_decode_MMR(&pSegment->m_Result.im, m_pStream.get(), pPause); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 CODES[CURTEMP] = CURCODE; | 1350 CODES[CURTEMP] = CURCODE; |
| 1367 CURCODE = CURCODE + 1; | 1351 CURCODE = CURCODE + 1; |
| 1368 } | 1352 } |
| 1369 CURTEMP = CURTEMP + 1; | 1353 CURTEMP = CURTEMP + 1; |
| 1370 } | 1354 } |
| 1371 CURLEN = CURLEN + 1; | 1355 CURLEN = CURLEN + 1; |
| 1372 } | 1356 } |
| 1373 FX_Free(LENCOUNT); | 1357 FX_Free(LENCOUNT); |
| 1374 FX_Free(FIRSTCODE); | 1358 FX_Free(FIRSTCODE); |
| 1375 } | 1359 } |
| 1360 |
| 1376 void CJBig2_Context::huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, | 1361 void CJBig2_Context::huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, |
| 1377 int NTEMP) { | 1362 int NTEMP) { |
| 1378 int CURLEN, LENMAX, CURCODE, CURTEMP, i; | 1363 int CURLEN, LENMAX, CURCODE, CURTEMP, i; |
| 1379 int* LENCOUNT; | 1364 int* LENCOUNT; |
| 1380 int* FIRSTCODE; | 1365 int* FIRSTCODE; |
| 1381 LENMAX = 0; | 1366 LENMAX = 0; |
| 1382 for (i = 0; i < NTEMP; ++i) { | 1367 for (i = 0; i < NTEMP; ++i) { |
| 1383 if (SBSYMCODES[i].codelen > LENMAX) { | 1368 if (SBSYMCODES[i].codelen > LENMAX) { |
| 1384 LENMAX = SBSYMCODES[i].codelen; | 1369 LENMAX = SBSYMCODES[i].codelen; |
| 1385 } | 1370 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1402 SBSYMCODES[CURTEMP].code = CURCODE; | 1387 SBSYMCODES[CURTEMP].code = CURCODE; |
| 1403 CURCODE = CURCODE + 1; | 1388 CURCODE = CURCODE + 1; |
| 1404 } | 1389 } |
| 1405 CURTEMP = CURTEMP + 1; | 1390 CURTEMP = CURTEMP + 1; |
| 1406 } | 1391 } |
| 1407 CURLEN = CURLEN + 1; | 1392 CURLEN = CURLEN + 1; |
| 1408 } | 1393 } |
| 1409 FX_Free(LENCOUNT); | 1394 FX_Free(LENCOUNT); |
| 1410 FX_Free(FIRSTCODE); | 1395 FX_Free(FIRSTCODE); |
| 1411 } | 1396 } |
| OLD | NEW |