Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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 <string.h>
10
11#include "core/fxcodec/jbig2/JBig2_Context.h"
12#include "core/fxcodec/jbig2/JBig2_DocumentContext.h"
13#include "core/fxcrt/fx_2d_size.h"
14#include "core/fxcrt/span_util.h"
15
16namespace fxcodec {
17
18namespace {
19
20FXCODEC_STATUS Decode(Jbig2Context* pJbig2Context, bool decode_success) {
21 FXCODEC_STATUS status = pJbig2Context->m_pContext->GetProcessingStatus();
23 return status;
24
25 pJbig2Context->m_pContext.reset();
26 if (!decode_success)
28
29 int dword_size = pJbig2Context->m_height * pJbig2Context->m_dest_pitch / 4;
30 uint32_t* dword_buf = reinterpret_cast<uint32_t*>(pJbig2Context->m_dest_buf);
31 for (int i = 0; i < dword_size; i++)
32 dword_buf[i] = ~dword_buf[i];
34}
35
36} // namespace
37
38Jbig2Context::Jbig2Context() = default;
39
40Jbig2Context::~Jbig2Context() = default;
41
42// static
44 Jbig2Context* pJbig2Context,
45 JBig2_DocumentContext* pJBig2DocumentContext,
46 uint32_t width,
47 uint32_t height,
48 pdfium::span<const uint8_t> src_span,
49 uint64_t src_key,
50 pdfium::span<const uint8_t> global_span,
51 uint64_t global_key,
52 pdfium::span<uint8_t> dest_buf,
53 uint32_t dest_pitch,
54 PauseIndicatorIface* pPause) {
55 pJbig2Context->m_width = width;
56 pJbig2Context->m_height = height;
57 pJbig2Context->m_pSrcSpan = src_span;
58 pJbig2Context->m_nSrcKey = src_key;
59 pJbig2Context->m_pGlobalSpan = global_span;
60 pJbig2Context->m_nGlobalKey = global_key;
61 pJbig2Context->m_dest_buf = dest_buf.data();
62 pJbig2Context->m_dest_pitch = dest_pitch;
63 fxcrt::spanset(dest_buf.first(Fx2DSizeOrDie(height, dest_pitch)), 0);
64 pJbig2Context->m_pContext =
65 CJBig2_Context::Create(global_span, global_key, src_span, src_key,
66 pJBig2DocumentContext->GetSymbolDictCache());
67 bool succeeded = pJbig2Context->m_pContext->GetFirstPage(
68 dest_buf, width, height, dest_pitch, pPause);
69 return Decode(pJbig2Context, succeeded);
70}
71
72// static
74 PauseIndicatorIface* pPause) {
75 bool succeeded = pJbig2Context->m_pContext->Continue(pPause);
76 return Decode(pJbig2Context, succeeded);
77}
78
79} // namespace fxcodec
UNOWNED_PTR_EXCLUSION uint8_t * m_dest_buf
static FXCODEC_STATUS StartDecode(Jbig2Context *pJbig2Context, JBig2_DocumentContext *pJbig2DocumentContext, uint32_t width, uint32_t height, pdfium::span< const uint8_t > src_span, uint64_t src_key, pdfium::span< const uint8_t > global_span, uint64_t global_key, pdfium::span< uint8_t > dest_buf, uint32_t dest_pitch, PauseIndicatorIface *pPause)
static FXCODEC_STATUS ContinueDecode(Jbig2Context *pJbig2Context, PauseIndicatorIface *pPause)
FXCODEC_STATUS