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

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

Issue 1328643002: Remove dead JBig2 code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 3 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/src/fxcodec/jbig2/JBig2_Context.h ('k') | core/src/fxcodec/jbig2/JBig2_GeneralDecoder.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 <map> 7 #include <map>
8 #include <list> 8 #include <list>
9 #include "JBig2_Context.h" 9 #include "JBig2_Context.h"
10 10
11 // Implement a very small least recently used (LRU) cache. It is very 11 // Implement a very small least recently used (LRU) cache. It is very
12 // common for a JBIG2 dictionary to span multiple pages in a PDF file, 12 // common for a JBIG2 dictionary to span multiple pages in a PDF file,
13 // and we do not want to decode the same dictionary over and over 13 // and we do not want to decode the same dictionary over and over
14 // again. We key off of the memory location of the dictionary. The 14 // again. We key off of the memory location of the dictionary. The
15 // list keeps track of the freshness of entries, with freshest ones 15 // list keeps track of the freshness of entries, with freshest ones
16 // at the front. Even a tiny cache size like 2 makes a dramatic 16 // at the front. Even a tiny cache size like 2 makes a dramatic
17 // difference for typical JBIG2 documents. 17 // difference for typical JBIG2 documents.
18 const int kSymbolDictCacheMaxSize = 2; 18 const int kSymbolDictCacheMaxSize = 2;
19 19
20 void OutputBitmap(CJBig2_Image* pImage) {
21 if (!pImage) {
22 return;
23 }
24 }
25 CJBig2_Context* CJBig2_Context::CreateContext( 20 CJBig2_Context* CJBig2_Context::CreateContext(
26 CJBig2_Module* pModule, 21 CJBig2_Module* pModule,
27 uint8_t* pGlobalData, 22 uint8_t* pGlobalData,
28 FX_DWORD dwGlobalLength, 23 FX_DWORD dwGlobalLength,
29 uint8_t* pData, 24 uint8_t* pData,
30 FX_DWORD dwLength, 25 FX_DWORD dwLength,
31 int32_t nStreamType, 26 int32_t nStreamType,
32 std::list<CJBig2_CachePair>* pSymbolDictCache, 27 std::list<CJBig2_CachePair>* pSymbolDictCache,
33 IFX_Pause* pPause) { 28 IFX_Pause* pPause) {
34 return new (pModule) 29 return new (pModule)
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 m_pSegment = NULL; 158 m_pSegment = NULL;
164 return nRet; 159 return nRet;
165 } 160 }
166 m_pSegmentList->addItem(m_pSegment); 161 m_pSegmentList->addItem(m_pSegment);
167 if (m_pSegment->m_dwData_length != 0xffffffff) { 162 if (m_pSegment->m_dwData_length != 0xffffffff) {
168 m_dwOffset = m_dwOffset + m_pSegment->m_dwData_length; 163 m_dwOffset = m_dwOffset + m_pSegment->m_dwData_length;
169 m_pStream->setOffset(m_dwOffset); 164 m_pStream->setOffset(m_dwOffset);
170 } else { 165 } else {
171 m_pStream->offset(4); 166 m_pStream->offset(4);
172 } 167 }
173 OutputBitmap(m_pPage);
174 m_pSegment = NULL; 168 m_pSegment = NULL;
175 if (m_pStream->getByteLeft() > 0 && m_pPage && pPause && 169 if (m_pStream->getByteLeft() > 0 && m_pPage && pPause &&
176 pPause->NeedToPauseNow()) { 170 pPause->NeedToPauseNow()) {
177 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; 171 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE;
178 m_PauseStep = 2; 172 m_PauseStep = 2;
179 return JBIG2_SUCCESS; 173 return JBIG2_SUCCESS;
180 } 174 }
181 } 175 }
182 } else { 176 } else {
183 return JBIG2_END_OF_FILE; 177 return JBIG2_END_OF_FILE;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_FINISH; 290 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_FINISH;
297 return JBIG2_SUCCESS; 291 return JBIG2_SUCCESS;
298 } 292 }
299 if (nRet == JBIG2_SUCCESS) { 293 if (nRet == JBIG2_SUCCESS) {
300 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_FINISH; 294 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_FINISH;
301 } else { 295 } else {
302 m_ProcessiveStatus = FXCODEC_STATUS_ERROR; 296 m_ProcessiveStatus = FXCODEC_STATUS_ERROR;
303 } 297 }
304 return nRet; 298 return nRet;
305 } 299 }
306 int32_t CJBig2_Context::getNextPage(uint8_t* pBuf,
307 int32_t width,
308 int32_t height,
309 int32_t stride,
310 IFX_Pause* pPause) {
311 int32_t nRet = JBIG2_ERROR_STREAM_TYPE;
312 m_bFirstPage = FALSE;
313 m_PauseStep = 0;
314 delete m_pPage;
315 JBIG2_ALLOC(m_pPage, CJBig2_Image(width, height, stride, pBuf));
316 m_bBufSpecified = TRUE;
317 if (m_pPage && pPause && pPause->NeedToPauseNow()) {
318 m_PauseStep = 1;
319 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE;
320 return nRet;
321 }
322 return Continue(pPause);
323 switch (m_nStreamType) {
324 case JBIG2_FILE_STREAM:
325 nRet = decodeFile(pPause);
326 break;
327 case JBIG2_SQUENTIAL_STREAM:
328 nRet = decode_SquentialOrgnazation(pPause);
329 break;
330 case JBIG2_RANDOM_STREAM:
331 nRet = decode_RandomOrgnazation(pPause);
332 break;
333 case JBIG2_EMBED_STREAM:
334 nRet = decode_EmbedOrgnazation(pPause);
335 break;
336 default:
337 return JBIG2_ERROR_STREAM_TYPE;
338 }
339 return nRet;
340 }
341 int32_t CJBig2_Context::getFirstPage(CJBig2_Image** image, IFX_Pause* pPause) { 300 int32_t CJBig2_Context::getFirstPage(CJBig2_Image** image, IFX_Pause* pPause) {
342 int32_t nRet; 301 int32_t nRet;
343 m_bFirstPage = TRUE; 302 m_bFirstPage = TRUE;
344 m_PauseStep = 0; 303 m_PauseStep = 0;
345 if (m_pGlobalContext) { 304 if (m_pGlobalContext) {
346 nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause); 305 nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause);
347 if (nRet != JBIG2_SUCCESS) { 306 if (nRet != JBIG2_SUCCESS) {
348 return nRet; 307 return nRet;
349 } 308 }
350 } 309 }
351 m_bBufSpecified = FALSE; 310 m_bBufSpecified = FALSE;
352 return Continue(pPause); 311 return Continue(pPause);
353 } 312 }
354 int32_t CJBig2_Context::getNextPage(CJBig2_Image** image, IFX_Pause* pPause) {
355 int32_t nRet;
356 m_bBufSpecified = FALSE;
357 m_bFirstPage = FALSE;
358 m_PauseStep = 0;
359 switch (m_nStreamType) {
360 case JBIG2_FILE_STREAM:
361 nRet = decodeFile(pPause);
362 break;
363 case JBIG2_SQUENTIAL_STREAM:
364 nRet = decode_SquentialOrgnazation(pPause);
365 break;
366 case JBIG2_RANDOM_STREAM:
367 nRet = decode_RandomOrgnazation(pPause);
368 break;
369 case JBIG2_EMBED_STREAM:
370 nRet = decode_EmbedOrgnazation(pPause);
371 break;
372 default:
373 return JBIG2_ERROR_STREAM_TYPE;
374 }
375 if (nRet == JBIG2_SUCCESS) {
376 *image = m_pPage;
377 m_pPage = NULL;
378 return JBIG2_SUCCESS;
379 }
380 return nRet;
381 }
382 CJBig2_Segment* CJBig2_Context::findSegmentByNumber(FX_DWORD dwNumber) { 313 CJBig2_Segment* CJBig2_Context::findSegmentByNumber(FX_DWORD dwNumber) {
383 CJBig2_Segment* pSeg; 314 CJBig2_Segment* pSeg;
384 int32_t i; 315 int32_t i;
385 if (m_pGlobalContext) { 316 if (m_pGlobalContext) {
386 pSeg = m_pGlobalContext->findSegmentByNumber(dwNumber); 317 pSeg = m_pGlobalContext->findSegmentByNumber(dwNumber);
387 if (pSeg) { 318 if (pSeg) {
388 return pSeg; 319 return pSeg;
389 } 320 }
390 } 321 }
391 for (i = 0; i < m_pSegmentList->getLength(); i++) { 322 for (i = 0; i < m_pSegmentList->getLength(); i++) {
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 sizeof(JBig2ArithCtx) * dwTemp); 1480 sizeof(JBig2ArithCtx) * dwTemp);
1550 JBIG2_memset(m_gbContext, 0, sizeof(JBig2ArithCtx) * dwTemp); 1481 JBIG2_memset(m_gbContext, 0, sizeof(JBig2ArithCtx) * dwTemp);
1551 } 1482 }
1552 if (m_pArithDecoder == NULL) { 1483 if (m_pArithDecoder == NULL) {
1553 JBIG2_ALLOC(m_pArithDecoder, CJBig2_ArithDecoder(m_pStream)); 1484 JBIG2_ALLOC(m_pArithDecoder, CJBig2_ArithDecoder(m_pStream));
1554 m_ProcessiveStatus = m_pGRD->Start_decode_Arith( 1485 m_ProcessiveStatus = m_pGRD->Start_decode_Arith(
1555 &pSegment->m_Result.im, m_pArithDecoder, m_gbContext, pPause); 1486 &pSegment->m_Result.im, m_pArithDecoder, m_gbContext, pPause);
1556 } else { 1487 } else {
1557 m_ProcessiveStatus = m_pGRD->Continue_decode(pPause); 1488 m_ProcessiveStatus = m_pGRD->Continue_decode(pPause);
1558 } 1489 }
1559 OutputBitmap(pSegment->m_Result.im);
1560 if (m_ProcessiveStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) { 1490 if (m_ProcessiveStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) {
1561 if (pSegment->m_cFlags.s.type != 36) { 1491 if (pSegment->m_cFlags.s.type != 36) {
1562 if (!m_bBufSpecified) { 1492 if (!m_bBufSpecified) {
1563 JBig2PageInfo* pPageInfo = m_pPageInfoList->getLast(); 1493 JBig2PageInfo* pPageInfo = m_pPageInfoList->getLast();
1564 if ((pPageInfo->m_bIsStriped == 1) && 1494 if ((pPageInfo->m_bIsStriped == 1) &&
1565 (m_ri.y + m_ri.height > m_pPage->m_nHeight)) { 1495 (m_ri.y + m_ri.height > m_pPage->m_nHeight)) {
1566 m_pPage->expand(m_ri.y + m_ri.height, 1496 m_pPage->expand(m_ri.y + m_ri.height,
1567 (pPageInfo->m_cFlags & 4) ? 1 : 0); 1497 (pPageInfo->m_cFlags & 4) ? 1 : 0);
1568 } 1498 }
1569 } 1499 }
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 SBSYMCODES[CURTEMP].code = CURCODE; 1817 SBSYMCODES[CURTEMP].code = CURCODE;
1888 CURCODE = CURCODE + 1; 1818 CURCODE = CURCODE + 1;
1889 } 1819 }
1890 CURTEMP = CURTEMP + 1; 1820 CURTEMP = CURTEMP + 1;
1891 } 1821 }
1892 CURLEN = CURLEN + 1; 1822 CURLEN = CURLEN + 1;
1893 } 1823 }
1894 m_pModule->JBig2_Free(LENCOUNT); 1824 m_pModule->JBig2_Free(LENCOUNT);
1895 m_pModule->JBig2_Free(FIRSTCODE); 1825 m_pModule->JBig2_Free(FIRSTCODE);
1896 } 1826 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_Context.h ('k') | core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698