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/fxcodec/jbig2/JBig2_HtrdProc.h" | 7 #include "core/fxcodec/jbig2/JBig2_HtrdProc.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "core/fxcodec/jbig2/JBig2_GsidProc.h" | 11 #include "core/fxcodec/jbig2/JBig2_GsidProc.h" |
12 #include "core/fxcrt/fx_basic.h" | 12 #include "core/fxcrt/fx_basic.h" |
| 13 #include "third_party/base/ptr_util.h" |
13 | 14 |
14 CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, | 15 CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, |
15 JBig2ArithCtx* gbContext, | 16 JBig2ArithCtx* gbContext, |
16 IFX_Pause* pPause) { | 17 IFX_Pause* pPause) { |
17 uint32_t ng, mg; | 18 uint32_t ng, mg; |
18 int32_t x, y; | 19 int32_t x, y; |
19 uint32_t HBPP; | 20 uint32_t HBPP; |
20 uint32_t* GI; | 21 uint32_t* GI; |
21 std::unique_ptr<CJBig2_Image> HSKIP; | 22 std::unique_ptr<CJBig2_Image> HSKIP; |
22 std::unique_ptr<CJBig2_Image> HTREG(new CJBig2_Image(HBW, HBH)); | 23 std::unique_ptr<CJBig2_Image> HTREG(new CJBig2_Image(HBW, HBH)); |
23 HTREG->fill(HDEFPIXEL); | 24 HTREG->fill(HDEFPIXEL); |
24 if (HENABLESKIP == 1) { | 25 if (HENABLESKIP == 1) { |
25 HSKIP.reset(new CJBig2_Image(HGW, HGH)); | 26 HSKIP = pdfium::MakeUnique<CJBig2_Image>(HGW, HGH); |
26 for (mg = 0; mg < HGH; mg++) { | 27 for (mg = 0; mg < HGH; mg++) { |
27 for (ng = 0; ng < HGW; ng++) { | 28 for (ng = 0; ng < HGW; ng++) { |
28 x = (HGX + mg * HRY + ng * HRX) >> 8; | 29 x = (HGX + mg * HRY + ng * HRX) >> 8; |
29 y = (HGY + mg * HRX - ng * HRY) >> 8; | 30 y = (HGY + mg * HRX - ng * HRY) >> 8; |
30 if ((x + HPW <= 0) | (x >= (int32_t)HBW) | (y + HPH <= 0) | | 31 if ((x + HPW <= 0) | (x >= (int32_t)HBW) | (y + HPH <= 0) | |
31 (y >= (int32_t)HPH)) { | 32 (y >= (int32_t)HPH)) { |
32 HSKIP->setPixel(ng, mg, 1); | 33 HSKIP->setPixel(ng, mg, 1); |
33 } else { | 34 } else { |
34 HSKIP->setPixel(ng, mg, 0); | 35 HSKIP->setPixel(ng, mg, 0); |
35 } | 36 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 uint32_t pat_index = GI[mg * HGW + ng]; | 96 uint32_t pat_index = GI[mg * HGW + ng]; |
96 if (pat_index >= HNUMPATS) { | 97 if (pat_index >= HNUMPATS) { |
97 pat_index = HNUMPATS - 1; | 98 pat_index = HNUMPATS - 1; |
98 } | 99 } |
99 HTREG->composeFrom(x, y, HPATS[pat_index], HCOMBOP); | 100 HTREG->composeFrom(x, y, HPATS[pat_index], HCOMBOP); |
100 } | 101 } |
101 } | 102 } |
102 FX_Free(GI); | 103 FX_Free(GI); |
103 return HTREG.release(); | 104 return HTREG.release(); |
104 } | 105 } |
OLD | NEW |