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_decoder.cpp
Go to the documentation of this file.
1
// Copyright 2014 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_decoder.h"
8
9
#
include
"core/fxcodec/jbig2/JBig2_Context.h"
10
#
include
"core/fxcodec/jbig2/JBig2_DocumentContext.h"
11
#
include
"core/fxcrt/fx_2d_size.h"
12
#
include
"core/fxcrt/span_util.h"
13
#
include
"core/fxcrt/stl_util.h"
14
15
namespace
fxcodec
{
16
17
namespace
{
18
19
FXCODEC_STATUS
Decode(
Jbig2Context
* pJbig2Context,
bool
decode_success) {
20
FXCODEC_STATUS
status = pJbig2Context->m_pContext->GetProcessingStatus();
21
if
(status !=
FXCODEC_STATUS
::
kDecodeFinished
) {
22
return
status;
23
}
24
pJbig2Context->m_pContext.reset();
25
if
(!decode_success) {
26
return
FXCODEC_STATUS
::
kError
;
27
}
28
uint32_t byte_size = pJbig2Context
->
m_height
* pJbig2Context
->
m_dest_pitch
;
29
pdfium::span<uint8_t> nonraw_span(pJbig2Context->m_dest_buf.first(byte_size));
30
auto
dword_span =
fxcrt
::reinterpret_span<uint32_t>(nonraw_span);
31
for
(
auto
& pix : dword_span) {
32
pix = ~pix;
33
}
34
return
FXCODEC_STATUS
::
kDecodeFinished
;
35
}
36
37
}
// namespace
38
39
Jbig2Context
::
Jbig2Context
() =
default
;
40
41
Jbig2Context
::~
Jbig2Context
() =
default
;
42
43
// static
44
FXCODEC_STATUS
Jbig2Decoder
::StartDecode(
45
Jbig2Context
* pJbig2Context,
46
JBig2_DocumentContext
* pJBig2DocumentContext,
47
uint32_t width,
48
uint32_t height,
49
pdfium::span<
const
uint8_t> src_span,
50
uint64_t src_key,
51
pdfium::span<
const
uint8_t> global_span,
52
uint64_t global_key,
53
pdfium::span<uint8_t> dest_buf,
54
uint32_t dest_pitch,
55
PauseIndicatorIface
* pPause) {
56
pJbig2Context
->
m_width
= width;
57
pJbig2Context
->
m_height
= height;
58
pJbig2Context->m_pSrcSpan = src_span;
59
pJbig2Context
->
m_nSrcKey
= src_key;
60
pJbig2Context->m_pGlobalSpan = global_span;
61
pJbig2Context
->
m_nGlobalKey
= global_key;
62
pJbig2Context->m_dest_buf = dest_buf;
63
pJbig2Context
->
m_dest_pitch
= dest_pitch;
64
fxcrt
::Fill(dest_buf.first(Fx2DSizeOrDie(height, dest_pitch)), 0);
65
pJbig2Context->m_pContext =
66
CJBig2_Context::Create(global_span, global_key, src_span, src_key,
67
pJBig2DocumentContext->GetSymbolDictCache());
68
bool
succeeded = pJbig2Context->m_pContext->GetFirstPage(
69
dest_buf, width, height, dest_pitch, pPause);
70
return
Decode(pJbig2Context, succeeded);
71
}
72
73
// static
74
FXCODEC_STATUS
Jbig2Decoder
::
ContinueDecode
(
Jbig2Context
* pJbig2Context,
75
PauseIndicatorIface
* pPause) {
76
bool
succeeded = pJbig2Context->m_pContext->Continue(pPause);
77
return
Decode(pJbig2Context, succeeded);
78
}
79
80
}
// namespace fxcodec
JBig2_DocumentContext
Definition
JBig2_DocumentContext.h:22
PauseIndicatorIface
Definition
pauseindicator_iface.h:10
fxcodec::Jbig2Context
Definition
jbig2_decoder.h:24
fxcodec::Jbig2Context::m_width
uint32_t m_width
Definition
jbig2_decoder.h:29
fxcodec::Jbig2Context::m_height
uint32_t m_height
Definition
jbig2_decoder.h:30
fxcodec::Jbig2Context::m_nGlobalKey
uint64_t m_nGlobalKey
Definition
jbig2_decoder.h:31
fxcodec::Jbig2Context::Jbig2Context
Jbig2Context()
fxcodec::Jbig2Context::~Jbig2Context
~Jbig2Context()
fxcodec::Jbig2Context::m_dest_pitch
uint32_t m_dest_pitch
Definition
jbig2_decoder.h:36
fxcodec::Jbig2Context::m_nSrcKey
uint64_t m_nSrcKey
Definition
jbig2_decoder.h:32
fxcodec::Jbig2Decoder
Definition
jbig2_decoder.h:40
fxcodec::Jbig2Decoder::ContinueDecode
static FXCODEC_STATUS ContinueDecode(Jbig2Context *pJbig2Context, PauseIndicatorIface *pPause)
Definition
jbig2_decoder.cpp:74
FXCODEC_STATUS
FXCODEC_STATUS
Definition
fx_codec_def.h:10
FXCODEC_STATUS::kDecodeFinished
@ kDecodeFinished
Definition
fx_codec_def.h:16
FXCODEC_STATUS::kError
@ kError
Definition
fx_codec_def.h:11
fxcodec
Definition
fpdf_parser_decode.h:28
fxcrt
Definition
stl_util.h:17
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fxcodec
jbig2
jbig2_decoder.cpp
Generated on
for Qt by
1.18.0