OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 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_GrrdProc.h" | 7 #include "core/fxcodec/jbig2/JBig2_GrrdProc.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "core/src/fxcodec/jbig2/JBig2_ArithDecoder.h" | 11 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" |
12 #include "core/src/fxcodec/jbig2/JBig2_BitStream.h" | 12 #include "core/fxcodec/jbig2/JBig2_BitStream.h" |
13 #include "core/src/fxcodec/jbig2/JBig2_Image.h" | 13 #include "core/fxcodec/jbig2/JBig2_Image.h" |
14 | 14 |
15 CJBig2_Image* CJBig2_GRRDProc::decode(CJBig2_ArithDecoder* pArithDecoder, | 15 CJBig2_Image* CJBig2_GRRDProc::decode(CJBig2_ArithDecoder* pArithDecoder, |
16 JBig2ArithCtx* grContext) { | 16 JBig2ArithCtx* grContext) { |
17 if (GRW == 0 || GRH == 0) | 17 if (GRW == 0 || GRH == 0) |
18 return new CJBig2_Image(GRW, GRH); | 18 return new CJBig2_Image(GRW, GRH); |
19 | 19 |
20 if (GRTEMPLATE == 0) { | 20 if (GRTEMPLATE == 0) { |
21 if ((GRAT[0] == -1) && (GRAT[1] == -1) && (GRAT[2] == -1) && | 21 if ((GRAT[0] == -1) && (GRAT[1] == -1) && (GRAT[2] == -1) && |
22 (GRAT[3] == -1) && (GRREFERENCEDX == 0) && | 22 (GRAT[3] == -1) && (GRREFERENCEDX == 0) && |
23 (GRW == (FX_DWORD)GRREFERENCE->m_nWidth)) { | 23 (GRW == (FX_DWORD)GRREFERENCE->m_nWidth)) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 CJBig2_Image* CJBig2_GRRDProc::decode_Template0_opt( | 149 CJBig2_Image* CJBig2_GRRDProc::decode_Template0_opt( |
150 CJBig2_ArithDecoder* pArithDecoder, | 150 CJBig2_ArithDecoder* pArithDecoder, |
151 JBig2ArithCtx* grContext) { | 151 JBig2ArithCtx* grContext) { |
152 if (!GRREFERENCE->m_pData) | 152 if (!GRREFERENCE->m_pData) |
153 return nullptr; | 153 return nullptr; |
154 | 154 |
155 FX_BOOL LTP, SLTP, bVal; | 155 FX_BOOL LTP, SLTP, bVal; |
156 FX_DWORD CONTEXT; | 156 FX_DWORD CONTEXT; |
157 FX_DWORD line1, line1_r, line2_r, line3_r; | 157 FX_DWORD line1, line1_r, line2_r, line3_r; |
158 uint8_t* pLine, *pLineR, cVal; | 158 uint8_t *pLine, *pLineR, cVal; |
159 intptr_t nStride, nStrideR, nOffset; | 159 intptr_t nStride, nStrideR, nOffset; |
160 int32_t k, nBits; | 160 int32_t k, nBits; |
161 int32_t GRWR, GRHR; | 161 int32_t GRWR, GRHR; |
162 int32_t GRW, GRH; | 162 int32_t GRW, GRH; |
163 GRW = (int32_t)CJBig2_GRRDProc::GRW; | 163 GRW = (int32_t)CJBig2_GRRDProc::GRW; |
164 GRH = (int32_t)CJBig2_GRRDProc::GRH; | 164 GRH = (int32_t)CJBig2_GRRDProc::GRH; |
165 LTP = 0; | 165 LTP = 0; |
166 std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH)); | 166 std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH)); |
167 if (!GRREG->m_pData) | 167 if (!GRREG->m_pData) |
168 return nullptr; | 168 return nullptr; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 | 386 |
387 CJBig2_Image* CJBig2_GRRDProc::decode_Template1_opt( | 387 CJBig2_Image* CJBig2_GRRDProc::decode_Template1_opt( |
388 CJBig2_ArithDecoder* pArithDecoder, | 388 CJBig2_ArithDecoder* pArithDecoder, |
389 JBig2ArithCtx* grContext) { | 389 JBig2ArithCtx* grContext) { |
390 if (!GRREFERENCE->m_pData) | 390 if (!GRREFERENCE->m_pData) |
391 return nullptr; | 391 return nullptr; |
392 | 392 |
393 FX_BOOL LTP, SLTP, bVal; | 393 FX_BOOL LTP, SLTP, bVal; |
394 FX_DWORD CONTEXT; | 394 FX_DWORD CONTEXT; |
395 FX_DWORD line1, line1_r, line2_r, line3_r; | 395 FX_DWORD line1, line1_r, line2_r, line3_r; |
396 uint8_t* pLine, *pLineR, cVal; | 396 uint8_t *pLine, *pLineR, cVal; |
397 intptr_t nStride, nStrideR, nOffset; | 397 intptr_t nStride, nStrideR, nOffset; |
398 int32_t k, nBits; | 398 int32_t k, nBits; |
399 int32_t GRWR, GRHR; | 399 int32_t GRWR, GRHR; |
400 int32_t GRW, GRH; | 400 int32_t GRW, GRH; |
401 GRW = (int32_t)CJBig2_GRRDProc::GRW; | 401 GRW = (int32_t)CJBig2_GRRDProc::GRW; |
402 GRH = (int32_t)CJBig2_GRRDProc::GRH; | 402 GRH = (int32_t)CJBig2_GRRDProc::GRH; |
403 LTP = 0; | 403 LTP = 0; |
404 std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH)); | 404 std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH)); |
405 if (!GRREG->m_pData) | 405 if (!GRREG->m_pData) |
406 return nullptr; | 406 return nullptr; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 pLine[w >> 3] = cVal; | 507 pLine[w >> 3] = cVal; |
508 } | 508 } |
509 } | 509 } |
510 pLine += nStride; | 510 pLine += nStride; |
511 if (h < GRHR + GRREFERENCEDY) { | 511 if (h < GRHR + GRREFERENCEDY) { |
512 pLineR += nStrideR; | 512 pLineR += nStrideR; |
513 } | 513 } |
514 } | 514 } |
515 return GRREG.release(); | 515 return GRREG.release(); |
516 } | 516 } |
OLD | NEW |