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

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

Issue 1359233002: Split up JBig2_GeneralDecoder.cpp. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase 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_HtrdProc.h ('k') | core/src/fxcodec/jbig2/JBig2_PddProc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "JBig2_HtrdProc.h"
8
9 #include "../../../../third_party/base/nonstd_unique_ptr.h"
10 #include "../../../include/fxcrt/fx_basic.h"
11 #include "JBig2_GsidProc.h"
12
13 CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
14 JBig2ArithCtx* gbContext,
15 IFX_Pause* pPause) {
16 FX_DWORD ng, mg;
17 int32_t x, y;
18 FX_DWORD HBPP;
19 FX_DWORD* GI;
20 nonstd::unique_ptr<CJBig2_Image> HSKIP;
21 nonstd::unique_ptr<CJBig2_Image> HTREG(new CJBig2_Image(HBW, HBH));
22 HTREG->fill(HDEFPIXEL);
23 if (HENABLESKIP == 1) {
24 HSKIP.reset(new CJBig2_Image(HGW, HGH));
25 for (mg = 0; mg < HGH; mg++) {
26 for (ng = 0; ng < HGW; ng++) {
27 x = (HGX + mg * HRY + ng * HRX) >> 8;
28 y = (HGY + mg * HRX - ng * HRY) >> 8;
29 if ((x + HPW <= 0) | (x >= (int32_t)HBW) | (y + HPH <= 0) |
30 (y >= (int32_t)HPH)) {
31 HSKIP->setPixel(ng, mg, 1);
32 } else {
33 HSKIP->setPixel(ng, mg, 0);
34 }
35 }
36 }
37 }
38 HBPP = 1;
39 while ((FX_DWORD)(1 << HBPP) < HNUMPATS) {
40 HBPP++;
41 }
42 nonstd::unique_ptr<CJBig2_GSIDProc> pGID(new CJBig2_GSIDProc());
43 pGID->GSMMR = HMMR;
44 pGID->GSW = HGW;
45 pGID->GSH = HGH;
46 pGID->GSBPP = (uint8_t)HBPP;
47 pGID->GSUSESKIP = HENABLESKIP;
48 pGID->GSKIP = HSKIP.get();
49 pGID->GSTEMPLATE = HTEMPLATE;
50 GI = pGID->decode_Arith(pArithDecoder, gbContext, pPause);
51 if (!GI)
52 return nullptr;
53
54 for (mg = 0; mg < HGH; mg++) {
55 for (ng = 0; ng < HGW; ng++) {
56 x = (HGX + mg * HRY + ng * HRX) >> 8;
57 y = (HGY + mg * HRX - ng * HRY) >> 8;
58 FX_DWORD pat_index = GI[mg * HGW + ng];
59 if (pat_index >= HNUMPATS) {
60 pat_index = HNUMPATS - 1;
61 }
62 HTREG->composeFrom(x, y, HPATS[pat_index], HCOMBOP);
63 }
64 }
65 FX_Free(GI);
66 return HTREG.release();
67 }
68
69 CJBig2_Image* CJBig2_HTRDProc::decode_MMR(CJBig2_BitStream* pStream,
70 IFX_Pause* pPause) {
71 FX_DWORD ng, mg;
72 int32_t x, y;
73 FX_DWORD* GI;
74 nonstd::unique_ptr<CJBig2_Image> HTREG(new CJBig2_Image(HBW, HBH));
75 HTREG->fill(HDEFPIXEL);
76 FX_DWORD HBPP = 1;
77 while ((FX_DWORD)(1 << HBPP) < HNUMPATS) {
78 HBPP++;
79 }
80 nonstd::unique_ptr<CJBig2_GSIDProc> pGID(new CJBig2_GSIDProc());
81 pGID->GSMMR = HMMR;
82 pGID->GSW = HGW;
83 pGID->GSH = HGH;
84 pGID->GSBPP = (uint8_t)HBPP;
85 pGID->GSUSESKIP = 0;
86 GI = pGID->decode_MMR(pStream, pPause);
87 if (!GI)
88 return nullptr;
89
90 for (mg = 0; mg < HGH; mg++) {
91 for (ng = 0; ng < HGW; ng++) {
92 x = (HGX + mg * HRY + ng * HRX) >> 8;
93 y = (HGY + mg * HRX - ng * HRY) >> 8;
94 FX_DWORD pat_index = GI[mg * HGW + ng];
95 if (pat_index >= HNUMPATS) {
96 pat_index = HNUMPATS - 1;
97 }
98 HTREG->composeFrom(x, y, HPATS[pat_index], HCOMBOP);
99 }
100 }
101 FX_Free(GI);
102 return HTREG.release();
103 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_HtrdProc.h ('k') | core/src/fxcodec/jbig2/JBig2_PddProc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698