Grok  7.6.0
t1_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2020 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 #pragma once
18 
19 #include "grok.h"
20 #include <cstdint>
21 
22 #ifndef INLINE
23 #if defined(_MSC_VER)
24 #define INLINE __forceinline
25 #elif defined(__GNUC__)
26 #define INLINE __inline__
27 #else
28 #define INLINE
29 #endif /* defined(<Compiler>) */
30 #endif /* INLINE */
31 
33 // buffer padding
34 
35 // decode
38 
39 // encode
42 
43 #include <math.h>
44 #include <assert.h>
45 #include <string.h>
46 #include "MemManager.h"
47 #include "mqc.h"
48 
49 namespace grk {
50 
51 #define T1_NMSEDEC_BITS 7
52 #define T1_NMSEDEC_FRACBITS (T1_NMSEDEC_BITS-1)
53 
54 // We can have a maximum 31 bits in each 32 bit wavelet coefficient
55 // as the most significant bit is reserved for the sign.
56 // Since we need T1_NMSEDEC_FRACBITS fixed point fractional bits,
57 // we can only support a maximum of (31-T1_NMSEDEC_FRACBITS) bit planes
59 
60 struct pass_enc {
61  uint32_t rate;
62  double distortiondec;
63  uint32_t len;
64  bool term;
65 };
66 
67 struct cblk_enc {
68  uint8_t* data;
69  uint32_t data_size;
71  uint32_t x0, y0, x1, y1;
72  uint32_t numbps;
73  uint32_t totalpasses;
74 };
75 
77  uint8_t * data;
78  uint32_t len;
79 };
80 
81 struct seg {
82  uint32_t len;
83  uint32_t real_num_passes;
84 };
85 
86 struct cblk_dec {
89  uint32_t x0, y0, x1, y1;
90  uint32_t numbps;
91  uint32_t real_num_segs;
92 };
93 
94 /* Macros to deal with signed integer with just MSB bit set for
95  * negative values (smr = signed magnitude representation) */
96 #define smr_abs(x) (((uint32_t)(x)) & 0x7FFFFFFFU)
97 #define smr_sign(x) (((uint32_t)(x)) >> 31)
98 #define to_smr(x) ((x) >= 0 ? (uint32_t)(x) : ((uint32_t)(-x) | 0x80000000U))
99 
100 }
101 
102 #include "t1.h"
grk::cblk_enc::data_size
uint32_t data_size
Definition: t1_common.h:69
mqc.h
grk::pass_enc::len
uint32_t len
Definition: t1_common.h:63
grk::cblk_enc::totalpasses
uint32_t totalpasses
Definition: t1_common.h:73
grk::cblk_enc::passes
pass_enc * passes
Definition: t1_common.h:70
grk::cblk_enc
Definition: t1_common.h:67
grk::cblk_dec::y1
uint32_t y1
Definition: t1_common.h:89
grk::seg::real_num_passes
uint32_t real_num_passes
Definition: t1_common.h:83
grk::seg_data_chunk::data
uint8_t * data
Definition: t1_common.h:77
grk::cblk_dec::numbps
uint32_t numbps
Definition: t1_common.h:90
grk::seg
Definition: t1_common.h:81
grk::seg_data_chunk
Definition: t1_common.h:76
grk::cblk_enc::y0
uint32_t y0
Definition: t1_common.h:71
T1_NMSEDEC_FRACBITS
#define T1_NMSEDEC_FRACBITS
Definition: t1_common.h:52
grk::cblk_enc::x0
uint32_t x0
Definition: t1_common.h:71
grk::cblk_dec::chunks
seg_data_chunk * chunks
Definition: t1_common.h:88
grk::pass_enc::rate
uint32_t rate
Definition: t1_common.h:61
grk::pass_enc
Definition: t1_common.h:60
grk::cblk_enc::x1
uint32_t x1
Definition: t1_common.h:71
grk::cblk_dec::x1
uint32_t x1
Definition: t1_common.h:89
grk::cblk_dec::real_num_segs
uint32_t real_num_segs
Definition: t1_common.h:91
grk::cblk_enc::y1
uint32_t y1
Definition: t1_common.h:71
grk_cblk_dec_compressed_data_pad_right
const uint8_t grk_cblk_dec_compressed_data_pad_right
< Space for a fake FFFF marker
Definition: t1_common.h:37
grk
Copyright (C) 2016-2020 Grok Image Compression Inc.
Definition: BitIO.h:27
grk::pass_enc::distortiondec
double distortiondec
Definition: t1_common.h:62
grk::cblk_enc::numbps
uint32_t numbps
Definition: t1_common.h:72
grk::cblk_dec::segs
seg * segs
Definition: t1_common.h:87
grk::cblk_dec::y0
uint32_t y0
Definition: t1_common.h:89
grok.h
grk::cblk_dec
Definition: t1_common.h:86
grk::cblk_enc::data
uint8_t * data
Definition: t1_common.h:68
MemManager.h
t1.h
grk::seg::len
uint32_t len
Definition: t1_common.h:82
grk::seg_data_chunk::len
uint32_t len
Definition: t1_common.h:78
grk_cblk_enc_compressed_data_pad_left
const uint8_t grk_cblk_enc_compressed_data_pad_left
Definition: t1_common.h:40
grk::pass_enc::term
bool term
Definition: t1_common.h:64
grk::k_max_bit_planes
const uint32_t k_max_bit_planes
Definition: t1_common.h:58
grk::cblk_dec::x0
uint32_t x0
Definition: t1_common.h:89