Grok  10.0.3
T1.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2022 Grok Image Compression Inc.
3  *
4  * This source code is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License, version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This source code is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  *
17  * This source code incorporates work covered by the BSD 2-clause license.
18  * Please see the LICENSE file in the root directory for details.
19  *
20  */
21 
22 #pragma once
23 #include "grk_includes.h"
24 
25 namespace grk
26 {
28 typedef uint32_t grk_flag;
29 struct DecompressCodeblock;
30 
31 struct T1
32 {
33  T1(bool isCompressor, uint32_t maxCblkW, uint32_t maxCblkH);
34  ~T1();
35 
36  bool decompress_cblk(DecompressCodeblock* cblk, uint8_t* compressedData, uint8_t orientation,
37  uint32_t cblksty);
38  void code_block_enc_deallocate(cblk_enc* p_code_block);
39  bool alloc(uint32_t w, uint32_t h);
40  double compress_cblk(cblk_enc* cblk, uint32_t max, uint8_t orientation, uint16_t compno,
41  uint8_t level, uint8_t qmfbid, double stepsize, uint32_t cblksty,
42  const double* mct_norms, uint16_t mct_numcomps, bool doRateControl);
44 
45  int32_t* getUncompressedData(void);
46  void attachUncompressedData(int32_t* data, uint32_t w, uint32_t h);
47  void allocCompressedData(size_t len);
48  uint8_t* getCompressedDataBuffer(void);
49  static double getnorm(uint32_t level, uint8_t orientation, bool reversible);
50 
51  private:
52  bool allocUncompressedData(size_t len);
53  void deallocUncompressedData(void);
54  int32_t* uncompressedData;
57  uint32_t w;
58  uint32_t h;
60 
62  // decompress only
63  uint8_t* compressedData; /* Temporary buffer to concatenate all chunks of a codebock */
64  size_t compressedDataLen; /* Maximum size available in compressedData */
66 
73  uint32_t flagssize;
74  bool compressor;
75 
76  template<uint32_t w, uint32_t h, bool vsc>
77  void dec_clnpass(int32_t bpno);
78  void dec_clnpass(int32_t bpno, int32_t cblksty);
79  void dec_clnpass_check_segsym(int32_t cblksty);
80  void dec_sigpass_raw(int32_t bpno, int32_t cblksty);
81  void dec_refpass_raw(int32_t bpno);
82  void dec_sigpass_mqc(int32_t bpno, int32_t cblksty);
83  void dec_refpass_mqc(int32_t bpno);
84  inline void dec_refpass_step_raw(grk_flag* flagsp, int32_t* datap, int32_t poshalf,
85  uint32_t ci);
86  inline void dec_sigpass_step_raw(grk_flag* flagsp, int32_t* datap, int32_t oneplushalf,
87  uint32_t vsc, uint32_t ci);
88  void enc_clnpass(int32_t bpno, int32_t* nmsedec, uint32_t cblksty);
89  void enc_sigpass(int32_t bpno, int32_t* nmsedec, uint8_t type, uint32_t cblksty);
90  void enc_refpass(int32_t bpno, int32_t* nmsedec, uint8_t type);
91  int enc_is_term_pass(cblk_enc* cblk, uint32_t cblksty, int32_t bpno, uint32_t passtype);
92  bool code_block_enc_allocate(cblk_enc* p_code_block);
100  double getnorm_53(uint32_t level, uint8_t orientation);
108  double getnorm_97(uint32_t level, uint8_t orientation);
109 
110  double getwmsedec(int32_t nmsedec, uint16_t compno, uint32_t level, uint8_t orientation,
111  int32_t bpno, uint32_t qmfbid, double stepsize, const double* mct_norms,
112  uint32_t mct_numcomps);
113 };
114 
115 } // namespace grk
Copyright (C) 2016-2022 Grok Image Compression Inc.
Definition: ICacheable.h:20
uint32_t grk_flag
Flags for 4 consecutive rows of a column.
Definition: T1.h:28
Definition: Codeblock.h:201
Definition: T1.h:32
bool alloc(uint32_t w, uint32_t h)
Definition: T1.cpp:332
bool allocUncompressedData(size_t len)
Definition: T1.cpp:298
void dec_clnpass(int32_t bpno)
Definition: T1.cpp:1028
uint8_t * getCompressedDataBuffer(void)
Definition: T1.cpp:282
void dec_sigpass_mqc(int32_t bpno, int32_t cblksty)
Definition: T1.cpp:1158
T1(bool isCompressor, uint32_t maxCblkW, uint32_t maxCblkH)
Definition: T1.cpp:243
int32_t * uncompressedData
Definition: T1.h:54
bool decompress_cblk(DecompressCodeblock *cblk, uint8_t *compressedData, uint8_t orientation, uint32_t cblksty)
Definition: T1.cpp:1255
void attachUncompressedData(int32_t *data, uint32_t w, uint32_t h)
Definition: T1.cpp:326
void enc_clnpass(int32_t bpno, int32_t *nmsedec, uint32_t cblksty)
Definition: T1.cpp:601
bool code_block_enc_allocate(cblk_enc *p_code_block)
Definition: T1.cpp:403
void dec_refpass_mqc(int32_t bpno)
Definition: T1.cpp:1250
size_t uncompressedDataLen
Definition: T1.h:55
~T1()
Definition: T1.cpp:252
void allocCompressedData(size_t len)
Definition: T1.cpp:286
void enc_refpass(int32_t bpno, int32_t *nmsedec, uint8_t type)
Definition: T1.cpp:550
void dec_sigpass_step_raw(grk_flag *flagsp, int32_t *datap, int32_t oneplushalf, uint32_t vsc, uint32_t ci)
Definition: T1.cpp:1047
uint8_t * compressedData
Definition: T1.h:63
mqcoder coder
Definition: T1.h:43
int enc_is_term_pass(cblk_enc *cblk, uint32_t cblksty, int32_t bpno, uint32_t passtype)
Definition: T1.cpp:432
int32_t * getUncompressedData(void)
Definition: T1.cpp:294
void deallocUncompressedData(void)
Definition: T1.cpp:319
double compress_cblk(cblk_enc *cblk, uint32_t max, uint8_t orientation, uint16_t compno, uint8_t level, uint8_t qmfbid, double stepsize, uint32_t cblksty, const double *mct_norms, uint16_t mct_numcomps, bool doRateControl)
Definition: T1.cpp:755
uint32_t h
Definition: T1.h:58
double getnorm_53(uint32_t level, uint8_t orientation)
Get the norm of a wavelet function of a subband at a specified level for the reversible 5-3 DWT.
Definition: T1.cpp:271
uint32_t uncompressedDataStride
Definition: T1.h:59
void dec_clnpass_check_segsym(int32_t cblksty)
Definition: T1.cpp:1009
grk_flag * flags
Flags used by decompressor and compressor.
Definition: T1.h:72
void code_block_enc_deallocate(cblk_enc *p_code_block)
ENCODE ////////////////////////////////////////////////////.
Definition: T1.cpp:398
void enc_sigpass(int32_t bpno, int32_t *nmsedec, uint8_t type, uint32_t cblksty)
Definition: T1.cpp:482
size_t compressedDataLen
Definition: T1.h:64
uint32_t w
Definition: T1.h:57
uint32_t flagssize
Definition: T1.h:73
void dec_sigpass_raw(int32_t bpno, int32_t cblksty)
Definition: T1.cpp:1089
bool ownsUncompressedData
Definition: T1.h:56
void dec_refpass_step_raw(grk_flag *flagsp, int32_t *datap, int32_t poshalf, uint32_t ci)
Definition: T1.cpp:1165
static double getnorm(uint32_t level, uint8_t orientation, bool reversible)
Definition: T1.cpp:258
void dec_refpass_raw(int32_t bpno)
Definition: T1.cpp:1189
double getnorm_97(uint32_t level, uint8_t orientation)
Get the norm of a wavelet function of a subband at a specified level for the irreversible 9-7 DWT.
Definition: T1.cpp:278
double getwmsedec(int32_t nmsedec, uint16_t compno, uint32_t level, uint8_t orientation, int32_t bpno, uint32_t qmfbid, double stepsize, const double *mct_norms, uint32_t mct_numcomps)
Definition: T1.cpp:413
bool compressor
Definition: T1.h:74
Definition: t1_common.h:72
Definition: mqc.h:44