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

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

Issue 1545183002: Merge to XFA: Switch from nonstd::unique_ptr to std::unique_ptr. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: xfa Created 4 years, 12 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
OLDNEW
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 "JBig2_HtrdProc.h" 7 #include "JBig2_HtrdProc.h"
8 8
9 #include <memory>
10
9 #include "JBig2_GsidProc.h" 11 #include "JBig2_GsidProc.h"
10 #include "core/include/fxcrt/fx_basic.h" 12 #include "core/include/fxcrt/fx_basic.h"
11 #include "third_party/base/nonstd_unique_ptr.h"
12 13
13 CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, 14 CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
14 JBig2ArithCtx* gbContext, 15 JBig2ArithCtx* gbContext,
15 IFX_Pause* pPause) { 16 IFX_Pause* pPause) {
16 FX_DWORD ng, mg; 17 FX_DWORD ng, mg;
17 int32_t x, y; 18 int32_t x, y;
18 FX_DWORD HBPP; 19 FX_DWORD HBPP;
19 FX_DWORD* GI; 20 FX_DWORD* GI;
20 nonstd::unique_ptr<CJBig2_Image> HSKIP; 21 std::unique_ptr<CJBig2_Image> HSKIP;
21 nonstd::unique_ptr<CJBig2_Image> HTREG(new CJBig2_Image(HBW, HBH)); 22 std::unique_ptr<CJBig2_Image> HTREG(new CJBig2_Image(HBW, HBH));
22 HTREG->fill(HDEFPIXEL); 23 HTREG->fill(HDEFPIXEL);
23 if (HENABLESKIP == 1) { 24 if (HENABLESKIP == 1) {
24 HSKIP.reset(new CJBig2_Image(HGW, HGH)); 25 HSKIP.reset(new CJBig2_Image(HGW, HGH));
25 for (mg = 0; mg < HGH; mg++) { 26 for (mg = 0; mg < HGH; mg++) {
26 for (ng = 0; ng < HGW; ng++) { 27 for (ng = 0; ng < HGW; ng++) {
27 x = (HGX + mg * HRY + ng * HRX) >> 8; 28 x = (HGX + mg * HRY + ng * HRX) >> 8;
28 y = (HGY + mg * HRX - ng * HRY) >> 8; 29 y = (HGY + mg * HRX - ng * HRY) >> 8;
29 if ((x + HPW <= 0) | (x >= (int32_t)HBW) | (y + HPH <= 0) | 30 if ((x + HPW <= 0) | (x >= (int32_t)HBW) | (y + HPH <= 0) |
30 (y >= (int32_t)HPH)) { 31 (y >= (int32_t)HPH)) {
31 HSKIP->setPixel(ng, mg, 1); 32 HSKIP->setPixel(ng, mg, 1);
32 } else { 33 } else {
33 HSKIP->setPixel(ng, mg, 0); 34 HSKIP->setPixel(ng, mg, 0);
34 } 35 }
35 } 36 }
36 } 37 }
37 } 38 }
38 HBPP = 1; 39 HBPP = 1;
39 while ((FX_DWORD)(1 << HBPP) < HNUMPATS) { 40 while ((FX_DWORD)(1 << HBPP) < HNUMPATS) {
40 HBPP++; 41 HBPP++;
41 } 42 }
42 nonstd::unique_ptr<CJBig2_GSIDProc> pGID(new CJBig2_GSIDProc()); 43 std::unique_ptr<CJBig2_GSIDProc> pGID(new CJBig2_GSIDProc());
43 pGID->GSMMR = HMMR; 44 pGID->GSMMR = HMMR;
44 pGID->GSW = HGW; 45 pGID->GSW = HGW;
45 pGID->GSH = HGH; 46 pGID->GSH = HGH;
46 pGID->GSBPP = (uint8_t)HBPP; 47 pGID->GSBPP = (uint8_t)HBPP;
47 pGID->GSUSESKIP = HENABLESKIP; 48 pGID->GSUSESKIP = HENABLESKIP;
48 pGID->GSKIP = HSKIP.get(); 49 pGID->GSKIP = HSKIP.get();
49 pGID->GSTEMPLATE = HTEMPLATE; 50 pGID->GSTEMPLATE = HTEMPLATE;
50 GI = pGID->decode_Arith(pArithDecoder, gbContext, pPause); 51 GI = pGID->decode_Arith(pArithDecoder, gbContext, pPause);
51 if (!GI) 52 if (!GI)
52 return nullptr; 53 return nullptr;
(...skipping 11 matching lines...) Expand all
64 } 65 }
65 FX_Free(GI); 66 FX_Free(GI);
66 return HTREG.release(); 67 return HTREG.release();
67 } 68 }
68 69
69 CJBig2_Image* CJBig2_HTRDProc::decode_MMR(CJBig2_BitStream* pStream, 70 CJBig2_Image* CJBig2_HTRDProc::decode_MMR(CJBig2_BitStream* pStream,
70 IFX_Pause* pPause) { 71 IFX_Pause* pPause) {
71 FX_DWORD ng, mg; 72 FX_DWORD ng, mg;
72 int32_t x, y; 73 int32_t x, y;
73 FX_DWORD* GI; 74 FX_DWORD* GI;
74 nonstd::unique_ptr<CJBig2_Image> HTREG(new CJBig2_Image(HBW, HBH)); 75 std::unique_ptr<CJBig2_Image> HTREG(new CJBig2_Image(HBW, HBH));
75 HTREG->fill(HDEFPIXEL); 76 HTREG->fill(HDEFPIXEL);
76 FX_DWORD HBPP = 1; 77 FX_DWORD HBPP = 1;
77 while ((FX_DWORD)(1 << HBPP) < HNUMPATS) { 78 while ((FX_DWORD)(1 << HBPP) < HNUMPATS) {
78 HBPP++; 79 HBPP++;
79 } 80 }
80 nonstd::unique_ptr<CJBig2_GSIDProc> pGID(new CJBig2_GSIDProc()); 81 std::unique_ptr<CJBig2_GSIDProc> pGID(new CJBig2_GSIDProc());
81 pGID->GSMMR = HMMR; 82 pGID->GSMMR = HMMR;
82 pGID->GSW = HGW; 83 pGID->GSW = HGW;
83 pGID->GSH = HGH; 84 pGID->GSH = HGH;
84 pGID->GSBPP = (uint8_t)HBPP; 85 pGID->GSBPP = (uint8_t)HBPP;
85 pGID->GSUSESKIP = 0; 86 pGID->GSUSESKIP = 0;
86 GI = pGID->decode_MMR(pStream, pPause); 87 GI = pGID->decode_MMR(pStream, pPause);
87 if (!GI) 88 if (!GI)
88 return nullptr; 89 return nullptr;
89 90
90 for (mg = 0; mg < HGH; mg++) { 91 for (mg = 0; mg < HGH; mg++) {
91 for (ng = 0; ng < HGW; ng++) { 92 for (ng = 0; ng < HGW; ng++) {
92 x = (HGX + mg * HRY + ng * HRX) >> 8; 93 x = (HGX + mg * HRY + ng * HRX) >> 8;
93 y = (HGY + mg * HRX - ng * HRY) >> 8; 94 y = (HGY + mg * HRX - ng * HRY) >> 8;
94 FX_DWORD pat_index = GI[mg * HGW + ng]; 95 FX_DWORD pat_index = GI[mg * HGW + ng];
95 if (pat_index >= HNUMPATS) { 96 if (pat_index >= HNUMPATS) {
96 pat_index = HNUMPATS - 1; 97 pat_index = HNUMPATS - 1;
97 } 98 }
98 HTREG->composeFrom(x, y, HPATS[pat_index], HCOMBOP); 99 HTREG->composeFrom(x, y, HPATS[pat_index], HCOMBOP);
99 } 100 }
100 } 101 }
101 FX_Free(GI); 102 FX_Free(GI);
102 return HTREG.release(); 103 return HTREG.release();
103 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698