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_Image.h
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#ifndef CORE_FXCODEC_JBIG2_JBIG2_IMAGE_H_
8#define CORE_FXCODEC_JBIG2_JBIG2_IMAGE_H_
9
10#include <stdint.h>
11
12#include <memory>
13
14#include "core/fxcodec/jbig2/JBig2_Define.h"
15#include "core/fxcrt/compiler_specific.h"
16#include "core/fxcrt/fx_memory_wrappers.h"
17#include "core/fxcrt/maybe_owned.h"
18#include "core/fxcrt/span.h"
19
20struct FX_RECT;
21
29
31 public:
32 CJBig2_Image(int32_t w, int32_t h);
33 CJBig2_Image(int32_t w,
34 int32_t h,
35 int32_t stride,
36 pdfium::span<uint8_t> pBuf);
37 CJBig2_Image(const CJBig2_Image& other);
39
40 static bool IsValidImageSize(int32_t w, int32_t h);
41
42 int32_t width() const { return m_nWidth; }
43 int32_t height() const { return m_nHeight; }
44 int32_t stride() const { return m_nStride; }
45
46 uint8_t* data() const { return m_pData.Get(); }
47
48 int GetPixel(int32_t x, int32_t y) const;
49 void SetPixel(int32_t x, int32_t y, int v);
50
51 // SAFETY: propogated to caller via UNSAFE_BUFFER_USAGE.
52 UNSAFE_BUFFER_USAGE uint8_t* GetLineUnsafe(int32_t y) const {
53 return UNSAFE_BUFFERS(data() + y * m_nStride);
54 }
55
56 uint8_t* GetLine(int32_t y) const {
57 // SAFETY: m_nHeight valid lines in image.
58 return (y >= 0 && y < m_nHeight) ? UNSAFE_BUFFERS(GetLineUnsafe(y))
59 : nullptr;
60 }
61
62 void CopyLine(int32_t hTo, int32_t hFrom);
63 void Fill(bool v);
64
65 bool ComposeFrom(int32_t x, int32_t y, CJBig2_Image* pSrc, JBig2ComposeOp op);
66 bool ComposeFromWithRect(int32_t x,
67 int32_t y,
68 CJBig2_Image* pSrc,
69 const FX_RECT& rtSrc,
71
73 int32_t y,
74 int32_t w,
75 int32_t h);
76 void Expand(int32_t h, bool v);
77
78 bool ComposeTo(CJBig2_Image* pDst, int32_t x, int32_t y, JBig2ComposeOp op);
80 int32_t x,
81 int32_t y,
82 const FX_RECT& rtSrc,
84
85 private:
86 void SubImageFast(int32_t x,
87 int32_t y,
88 int32_t w,
89 int32_t h,
90 CJBig2_Image* pImage);
91 void SubImageSlow(int32_t x,
92 int32_t y,
93 int32_t w,
94 int32_t h,
95 CJBig2_Image* pImage);
96 bool ComposeToInternal(CJBig2_Image* pDst,
97 int32_t x,
98 int32_t y,
100 const FX_RECT& rtSrc);
101
102 MaybeOwned<uint8_t, FxFreeDeleter> m_pData;
103 int32_t m_nWidth = 0; // 1-bit pixels
104 int32_t m_nHeight = 0; // lines
105 int32_t m_nStride = 0; // bytes, must be multiple of 4.
106};
107
108#endif // CORE_FXCODEC_JBIG2_JBIG2_IMAGE_H_
static const size_t kSymbolDictCacheMaxSize
JBig2_Result
#define JBIG2_MIN_SEGMENT_SIZE
constexpr uint32_t kJBig2MaxNewSymbols
constexpr int32_t kJBig2MaxReferredSegmentCount
constexpr uint32_t kJBig2MaxExportSymbols
constexpr int32_t kJBig2OOB
constexpr int32_t kJBig2MaxImageSize
constexpr uint32_t kJBig2MaxPatternIndex
std::pair< uint64_t, uint32_t > CJBig2_CompoundKey
JBig2ComposeOp
Definition JBig2_Image.h:22
@ JBIG2_COMPOSE_REPLACE
Definition JBig2_Image.h:27
@ JBIG2_COMPOSE_AND
Definition JBig2_Image.h:24
@ JBIG2_COMPOSE_XOR
Definition JBig2_Image.h:25
@ JBIG2_COMPOSE_OR
Definition JBig2_Image.h:23
@ JBIG2_COMPOSE_XNOR
Definition JBig2_Image.h:26
JBig2_ResultType
@ JBIG2_IMAGE_POINTER
@ JBIG2_VOID_POINTER
@ JBIG2_HUFFMAN_TABLE_POINTER
@ JBIG2_SYMBOL_DICT_POINTER
@ JBIG2_PATTERN_DICT_POINTER
JBig2_SegmentState
@ JBIG2_SEGMENT_DATA_UNPARSED
@ JBIG2_SEGMENT_PARSE_COMPLETE
@ JBIG2_SEGMENT_ERROR
@ JBIG2_SEGMENT_HEADER_UNPARSED
@ JBIG2_SEGMENT_PAUSED
JBig2Corner
#define DCHECK
Definition check.h:33
static std::unique_ptr< CJBig2_Context > Create(pdfium::span< const uint8_t > pGlobalSpan, uint64_t global_key, pdfium::span< const uint8_t > pSrcSpan, uint64_t src_key, std::list< CJBig2_CachePair > *pSymbolDictCache)
static bool HuffmanAssignCode(pdfium::span< JBig2HuffmanCode > symcodes)
bool GetFirstPage(pdfium::span< uint8_t > pBuf, int32_t width, int32_t height, int32_t stride, PauseIndicatorIface *pPause)
bool Continue(PauseIndicatorIface *pPause)
FXCODEC_STATUS GetProcessingStatus() const
static constexpr size_t kNumHuffmanTables
const std::vector< int > & GetRANGELEN() const
const std::vector< JBig2HuffmanCode > & GetCODES() const
CJBig2_HuffmanTable(CJBig2_BitStream *pStream)
uint32_t Size() const
const std::vector< int > & GetRANGELOW() const
CJBig2_Image(int32_t w, int32_t h, int32_t stride, pdfium::span< uint8_t > pBuf)
bool ComposeFrom(int32_t x, int32_t y, CJBig2_Image *pSrc, JBig2ComposeOp op)
void SetPixel(int32_t x, int32_t y, int v)
std::unique_ptr< CJBig2_Image > SubImage(int32_t x, int32_t y, int32_t w, int32_t h)
int32_t height() const
Definition JBig2_Image.h:43
CJBig2_Image(int32_t w, int32_t h)
uint8_t * GetLine(int32_t y) const
Definition JBig2_Image.h:56
void CopyLine(int32_t hTo, int32_t hFrom)
CJBig2_Image(const CJBig2_Image &other)
bool ComposeToWithRect(CJBig2_Image *pDst, int32_t x, int32_t y, const FX_RECT &rtSrc, JBig2ComposeOp op)
uint8_t * data() const
Definition JBig2_Image.h:46
static bool IsValidImageSize(int32_t w, int32_t h)
int GetPixel(int32_t x, int32_t y) const
int32_t stride() const
Definition JBig2_Image.h:44
bool ComposeTo(CJBig2_Image *pDst, int32_t x, int32_t y, JBig2ComposeOp op)
UNSAFE_BUFFER_USAGE uint8_t * GetLineUnsafe(int32_t y) const
Definition JBig2_Image.h:52
int32_t width() const
Definition JBig2_Image.h:42
void Fill(bool v)
void Expand(int32_t h, bool v)
bool ComposeFromWithRect(int32_t x, int32_t y, CJBig2_Image *pSrc, const FX_RECT &rtSrc, JBig2ComposeOp op)
CJBig2_PatternDict(uint32_t dict_size)
std::vector< std::unique_ptr< CJBig2_Image > > HDPATS
std::vector< uint32_t > m_Referred_to_segment_numbers
std::unique_ptr< CJBig2_SymbolDict > m_SymbolDict
std::unique_ptr< CJBig2_HuffmanTable > m_HuffmanTable
JBig2_SegmentState m_State
std::unique_ptr< CJBig2_PatternDict > m_PatternDict
JBig2_ResultType m_nResultType
uint8_t deferred_non_retain
uint8_t page_association_size
uint32_t m_dwData_length
uint32_t m_dwHeader_Length
uint32_t m_dwDataOffset
int32_t m_nReferred_to_segment_count
uint32_t m_dwPage_association
std::unique_ptr< CJBig2_Image > m_Image
uint32_t m_dwNumber
virtual bool NeedToPauseNow()=0
#define UNSAFE_BUFFERS(...)
#define UNSAFE_BUFFER_USAGE
FXCODEC_STATUS
pdfium::CheckedNumeric< uint32_t > FX_SAFE_UINT32
pdfium::CheckedNumeric< int32_t > FX_SAFE_INT32
bool m_bIsStriped
Definition JBig2_Page.h:19
uint16_t m_wMaxStripeSize
Definition JBig2_Page.h:20
uint32_t m_dwHeight
Definition JBig2_Page.h:14
bool m_bDefaultPixelValue
Definition JBig2_Page.h:18
uint32_t m_dwResolutionY
Definition JBig2_Page.h:16
uint32_t m_dwWidth
Definition JBig2_Page.h:13
uint32_t m_dwResolutionX
Definition JBig2_Page.h:15