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

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

Issue 1547833002: Switch from nonstd::unique_ptr to std::unique_ptr. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase 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
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_GrdProc.cpp ('k') | core/src/fxcodec/jbig2/JBig2_GsidProc.cpp » ('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 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_GrrdProc.h" 7 #include "JBig2_GrrdProc.h"
8 8
9 #include <memory>
10
9 #include "JBig2_ArithDecoder.h" 11 #include "JBig2_ArithDecoder.h"
10 #include "JBig2_BitStream.h" 12 #include "JBig2_BitStream.h"
11 #include "JBig2_Image.h" 13 #include "JBig2_Image.h"
12 #include "third_party/base/nonstd_unique_ptr.h"
13 14
14 CJBig2_Image* CJBig2_GRRDProc::decode(CJBig2_ArithDecoder* pArithDecoder, 15 CJBig2_Image* CJBig2_GRRDProc::decode(CJBig2_ArithDecoder* pArithDecoder,
15 JBig2ArithCtx* grContext) { 16 JBig2ArithCtx* grContext) {
16 if (GRW == 0 || GRH == 0) 17 if (GRW == 0 || GRH == 0)
17 return new CJBig2_Image(GRW, GRH); 18 return new CJBig2_Image(GRW, GRH);
18 19
19 if (GRTEMPLATE == 0) { 20 if (GRTEMPLATE == 0) {
20 if ((GRAT[0] == -1) && (GRAT[1] == -1) && (GRAT[2] == -1) && 21 if ((GRAT[0] == -1) && (GRAT[1] == -1) && (GRAT[2] == -1) &&
21 (GRAT[3] == -1) && (GRREFERENCEDX == 0) && 22 (GRAT[3] == -1) && (GRREFERENCEDX == 0) &&
22 (GRW == (FX_DWORD)GRREFERENCE->m_nWidth)) { 23 (GRW == (FX_DWORD)GRREFERENCE->m_nWidth)) {
23 return decode_Template0_opt(pArithDecoder, grContext); 24 return decode_Template0_opt(pArithDecoder, grContext);
24 } 25 }
25 return decode_Template0_unopt(pArithDecoder, grContext); 26 return decode_Template0_unopt(pArithDecoder, grContext);
26 } 27 }
27 28
28 if ((GRREFERENCEDX == 0) && (GRW == (FX_DWORD)GRREFERENCE->m_nWidth)) 29 if ((GRREFERENCEDX == 0) && (GRW == (FX_DWORD)GRREFERENCE->m_nWidth))
29 return decode_Template1_opt(pArithDecoder, grContext); 30 return decode_Template1_opt(pArithDecoder, grContext);
30 return decode_Template1_unopt(pArithDecoder, grContext); 31 return decode_Template1_unopt(pArithDecoder, grContext);
31 } 32 }
32 33
33 CJBig2_Image* CJBig2_GRRDProc::decode_Template0_unopt( 34 CJBig2_Image* CJBig2_GRRDProc::decode_Template0_unopt(
34 CJBig2_ArithDecoder* pArithDecoder, 35 CJBig2_ArithDecoder* pArithDecoder,
35 JBig2ArithCtx* grContext) { 36 JBig2ArithCtx* grContext) {
36 FX_BOOL LTP, SLTP, bVal; 37 FX_BOOL LTP, SLTP, bVal;
37 FX_DWORD CONTEXT; 38 FX_DWORD CONTEXT;
38 FX_DWORD line1, line2, line3, line4, line5; 39 FX_DWORD line1, line2, line3, line4, line5;
39 LTP = 0; 40 LTP = 0;
40 nonstd::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH)); 41 std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH));
41 GRREG->fill(0); 42 GRREG->fill(0);
42 for (FX_DWORD h = 0; h < GRH; h++) { 43 for (FX_DWORD h = 0; h < GRH; h++) {
43 if (TPGRON) { 44 if (TPGRON) {
44 SLTP = pArithDecoder->DECODE(&grContext[0x0010]); 45 SLTP = pArithDecoder->DECODE(&grContext[0x0010]);
45 LTP = LTP ^ SLTP; 46 LTP = LTP ^ SLTP;
46 } 47 }
47 if (LTP == 0) { 48 if (LTP == 0) {
48 line1 = GRREG->getPixel(1, h - 1); 49 line1 = GRREG->getPixel(1, h - 1);
49 line1 |= GRREG->getPixel(0, h - 1) << 1; 50 line1 |= GRREG->getPixel(0, h - 1) << 1;
50 line2 = 0; 51 line2 = 0;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 FX_DWORD CONTEXT; 156 FX_DWORD CONTEXT;
156 FX_DWORD line1, line1_r, line2_r, line3_r; 157 FX_DWORD line1, line1_r, line2_r, line3_r;
157 uint8_t* pLine, *pLineR, cVal; 158 uint8_t* pLine, *pLineR, cVal;
158 intptr_t nStride, nStrideR, nOffset; 159 intptr_t nStride, nStrideR, nOffset;
159 int32_t k, nBits; 160 int32_t k, nBits;
160 int32_t GRWR, GRHR; 161 int32_t GRWR, GRHR;
161 int32_t GRW, GRH; 162 int32_t GRW, GRH;
162 GRW = (int32_t)CJBig2_GRRDProc::GRW; 163 GRW = (int32_t)CJBig2_GRRDProc::GRW;
163 GRH = (int32_t)CJBig2_GRRDProc::GRH; 164 GRH = (int32_t)CJBig2_GRRDProc::GRH;
164 LTP = 0; 165 LTP = 0;
165 nonstd::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH)); 166 std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH));
166 if (!GRREG->m_pData) 167 if (!GRREG->m_pData)
167 return nullptr; 168 return nullptr;
168 169
169 pLine = GRREG->m_pData; 170 pLine = GRREG->m_pData;
170 pLineR = GRREFERENCE->m_pData; 171 pLineR = GRREFERENCE->m_pData;
171 nStride = GRREG->m_nStride; 172 nStride = GRREG->m_nStride;
172 nStrideR = GRREFERENCE->m_nStride; 173 nStrideR = GRREFERENCE->m_nStride;
173 GRWR = (int32_t)GRREFERENCE->m_nWidth; 174 GRWR = (int32_t)GRREFERENCE->m_nWidth;
174 GRHR = (int32_t)GRREFERENCE->m_nHeight; 175 GRHR = (int32_t)GRREFERENCE->m_nHeight;
175 if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1) { 176 if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 return GRREG.release(); 283 return GRREG.release();
283 } 284 }
284 285
285 CJBig2_Image* CJBig2_GRRDProc::decode_Template1_unopt( 286 CJBig2_Image* CJBig2_GRRDProc::decode_Template1_unopt(
286 CJBig2_ArithDecoder* pArithDecoder, 287 CJBig2_ArithDecoder* pArithDecoder,
287 JBig2ArithCtx* grContext) { 288 JBig2ArithCtx* grContext) {
288 FX_BOOL LTP, SLTP, bVal; 289 FX_BOOL LTP, SLTP, bVal;
289 FX_DWORD CONTEXT; 290 FX_DWORD CONTEXT;
290 FX_DWORD line1, line2, line3, line4, line5; 291 FX_DWORD line1, line2, line3, line4, line5;
291 LTP = 0; 292 LTP = 0;
292 nonstd::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH)); 293 std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH));
293 GRREG->fill(0); 294 GRREG->fill(0);
294 for (FX_DWORD h = 0; h < GRH; h++) { 295 for (FX_DWORD h = 0; h < GRH; h++) {
295 if (TPGRON) { 296 if (TPGRON) {
296 SLTP = pArithDecoder->DECODE(&grContext[0x0008]); 297 SLTP = pArithDecoder->DECODE(&grContext[0x0008]);
297 LTP = LTP ^ SLTP; 298 LTP = LTP ^ SLTP;
298 } 299 }
299 if (LTP == 0) { 300 if (LTP == 0) {
300 line1 = GRREG->getPixel(1, h - 1); 301 line1 = GRREG->getPixel(1, h - 1);
301 line1 |= GRREG->getPixel(0, h - 1) << 1; 302 line1 |= GRREG->getPixel(0, h - 1) << 1;
302 line1 |= GRREG->getPixel(-1, h - 1) << 2; 303 line1 |= GRREG->getPixel(-1, h - 1) << 2;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 FX_DWORD CONTEXT; 394 FX_DWORD CONTEXT;
394 FX_DWORD line1, line1_r, line2_r, line3_r; 395 FX_DWORD line1, line1_r, line2_r, line3_r;
395 uint8_t* pLine, *pLineR, cVal; 396 uint8_t* pLine, *pLineR, cVal;
396 intptr_t nStride, nStrideR, nOffset; 397 intptr_t nStride, nStrideR, nOffset;
397 int32_t k, nBits; 398 int32_t k, nBits;
398 int32_t GRWR, GRHR; 399 int32_t GRWR, GRHR;
399 int32_t GRW, GRH; 400 int32_t GRW, GRH;
400 GRW = (int32_t)CJBig2_GRRDProc::GRW; 401 GRW = (int32_t)CJBig2_GRRDProc::GRW;
401 GRH = (int32_t)CJBig2_GRRDProc::GRH; 402 GRH = (int32_t)CJBig2_GRRDProc::GRH;
402 LTP = 0; 403 LTP = 0;
403 nonstd::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH)); 404 std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH));
404 if (!GRREG->m_pData) 405 if (!GRREG->m_pData)
405 return nullptr; 406 return nullptr;
406 407
407 pLine = GRREG->m_pData; 408 pLine = GRREG->m_pData;
408 pLineR = GRREFERENCE->m_pData; 409 pLineR = GRREFERENCE->m_pData;
409 nStride = GRREG->m_nStride; 410 nStride = GRREG->m_nStride;
410 nStrideR = GRREFERENCE->m_nStride; 411 nStrideR = GRREFERENCE->m_nStride;
411 GRWR = (int32_t)GRREFERENCE->m_nWidth; 412 GRWR = (int32_t)GRREFERENCE->m_nWidth;
412 GRHR = (int32_t)GRREFERENCE->m_nHeight; 413 GRHR = (int32_t)GRREFERENCE->m_nHeight;
413 if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1) { 414 if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 pLine[w >> 3] = cVal; 507 pLine[w >> 3] = cVal;
507 } 508 }
508 } 509 }
509 pLine += nStride; 510 pLine += nStride;
510 if (h < GRHR + GRREFERENCEDY) { 511 if (h < GRHR + GRREFERENCEDY) {
511 pLineR += nStrideR; 512 pLineR += nStrideR;
512 } 513 }
513 } 514 }
514 return GRREG.release(); 515 return GRREG.release();
515 } 516 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_GrdProc.cpp ('k') | core/src/fxcodec/jbig2/JBig2_GsidProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698