Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
JBig2_PddProc.cpp
Go to the documentation of this file.
1
// Copyright 2015 The PDFium Authors
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
"core/fxcodec/jbig2/JBig2_PddProc.h"
8
9
#
include
<
memory
>
10
11
#
include
"core/fxcodec/jbig2/JBig2_GrdProc.h"
12
#
include
"core/fxcodec/jbig2/JBig2_Image.h"
13
#
include
"core/fxcodec/jbig2/JBig2_PatternDict.h"
14
15
std
::
unique_ptr
<
CJBig2_PatternDict
>
CJBig2_PDDProc
::
DecodeArith
(
16
CJBig2_ArithDecoder
* pArithDecoder,
17
pdfium::span<JBig2ArithCtx> gbContexts,
18
PauseIndicatorIface
* pPause) {
19
std::unique_ptr<CJBig2_GRDProc> pGRD = CreateGRDProc();
20
if
(!pGRD)
21
return
nullptr
;
22
23
pGRD->GBTEMPLATE =
HDTEMPLATE
;
24
pGRD->TPGDON =
false
;
25
pGRD->USESKIP =
false
;
26
pGRD->GBAT[0] = -1 *
static_cast
<int32_t>(
HDPW
);
27
pGRD->GBAT[1] = 0;
28
if
(pGRD->GBTEMPLATE == 0) {
29
pGRD->GBAT[2] = -3;
30
pGRD->GBAT[3] = -1;
31
pGRD->GBAT[4] = 2;
32
pGRD->GBAT[5] = -2;
33
pGRD->GBAT[6] = -2;
34
pGRD->GBAT[7] = -2;
35
}
36
37
std::unique_ptr<CJBig2_Image> BHDC;
38
CJBig2_GRDProc
::
ProgressiveArithDecodeState
state;
39
state.pImage = &BHDC;
40
state.pArithDecoder = pArithDecoder;
41
state.gbContexts = gbContexts;
42
state.pPause =
nullptr
;
43
44
FXCODEC_STATUS
status = pGRD->StartDecodeArith(&state);
45
state.pPause = pPause;
46
while
(status ==
FXCODEC_STATUS
::
kDecodeToBeContinued
)
47
status = pGRD->ContinueDecode(&state);
48
if
(!BHDC)
49
return
nullptr
;
50
51
auto
pDict =
std
::make_unique<
CJBig2_PatternDict
>(
GRAYMAX
+ 1);
52
for
(uint32_t GRAY = 0; GRAY <=
GRAYMAX
; ++GRAY)
53
pDict->HDPATS[GRAY] = BHDC->SubImage(
HDPW
* GRAY, 0,
HDPW
,
HDPH
);
54
return
pDict;
55
}
56
57
std
::
unique_ptr
<
CJBig2_PatternDict
>
CJBig2_PDDProc
::
DecodeMMR
(
58
CJBig2_BitStream
* pStream) {
59
std::unique_ptr<CJBig2_GRDProc> pGRD = CreateGRDProc();
60
if
(!pGRD)
61
return
nullptr
;
62
63
std::unique_ptr<CJBig2_Image> BHDC;
64
pGRD->StartDecodeMMR(&BHDC, pStream);
65
if
(!BHDC)
66
return
nullptr
;
67
68
auto
pDict =
std
::make_unique<
CJBig2_PatternDict
>(
GRAYMAX
+ 1);
69
for
(uint32_t GRAY = 0; GRAY <=
GRAYMAX
; ++GRAY)
70
pDict->HDPATS[GRAY] = BHDC->SubImage(
HDPW
* GRAY, 0,
HDPW
,
HDPH
);
71
return
pDict;
72
}
73
74
std::unique_ptr<CJBig2_GRDProc>
CJBig2_PDDProc
::CreateGRDProc() {
75
uint32_t width = (
GRAYMAX
+ 1) *
HDPW
;
76
uint32_t height =
HDPH
;
77
if
(width >
kJBig2MaxImageSize
|| height >
kJBig2MaxImageSize
)
78
return
nullptr
;
79
80
auto
pGRD =
std
::make_unique<
CJBig2_GRDProc
>();
81
pGRD->MMR =
HDMMR
;
82
pGRD->GBW = width;
83
pGRD->GBH = height;
84
return
pGRD;
85
}
kJBig2MaxImageSize
constexpr int32_t kJBig2MaxImageSize
Definition
JBig2_Define.h:31
CJBig2_ArithDecoder
Definition
JBig2_ArithDecoder.h:41
CJBig2_BitStream
Definition
JBig2_BitStream.h:14
CJBig2_GRDProc::ProgressiveArithDecodeState
Definition
JBig2_GrdProc.h:29
CJBig2_GRDProc
Definition
JBig2_GrdProc.h:27
CJBig2_PDDProc
Definition
JBig2_PddProc.h:23
CJBig2_PDDProc::HDTEMPLATE
uint8_t HDTEMPLATE
Definition
JBig2_PddProc.h:36
CJBig2_PDDProc::HDMMR
bool HDMMR
Definition
JBig2_PddProc.h:32
CJBig2_PDDProc::GRAYMAX
uint32_t GRAYMAX
Definition
JBig2_PddProc.h:35
CJBig2_PDDProc::HDPW
uint8_t HDPW
Definition
JBig2_PddProc.h:33
CJBig2_PDDProc::DecodeArith
std::unique_ptr< CJBig2_PatternDict > DecodeArith(CJBig2_ArithDecoder *pArithDecoder, pdfium::span< JBig2ArithCtx > gbContexts, PauseIndicatorIface *pPause)
Definition
JBig2_PddProc.cpp:15
CJBig2_PDDProc::DecodeMMR
std::unique_ptr< CJBig2_PatternDict > DecodeMMR(CJBig2_BitStream *pStream)
Definition
JBig2_PddProc.cpp:57
CJBig2_PDDProc::HDPH
uint8_t HDPH
Definition
JBig2_PddProc.h:34
CJBig2_PatternDict
Definition
JBig2_PatternDict.h:16
PauseIndicatorIface
Definition
pauseindicator_iface.h:10
FXCODEC_STATUS
FXCODEC_STATUS
Definition
fx_codec_def.h:10
FXCODEC_STATUS::kDecodeToBeContinued
@ kDecodeToBeContinued
Definition
fx_codec_def.h:15
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fxcodec
jbig2
JBig2_PddProc.cpp
Generated on
for Qt by
1.18.0