Grok  7.6.6
t1_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2021 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 // decompress
38 
39 // compress
42 
43 #include <math.h>
44 #include <cassert>
45 #include <cstring>
46 #include "mqc.h"
47 
48 namespace grk {
49 
50 #define T1_NMSEDEC_BITS 7
51 #define T1_NMSEDEC_FRACBITS (T1_NMSEDEC_BITS-1)
52 
53 #define T1_NUMCTXS_ZC 9
54 #define T1_NUMCTXS_SC 5
55 #define T1_NUMCTXS_MAG 3
56 #define T1_NUMCTXS_AGG 1
57 #define T1_NUMCTXS_UNI 1
58 
59 #define T1_CTXNO_ZC 0
60 #define T1_CTXNO_SC (T1_CTXNO_ZC+T1_NUMCTXS_ZC)
61 #define T1_CTXNO_MAG (T1_CTXNO_SC+T1_NUMCTXS_SC)
62 #define T1_CTXNO_AGG (T1_CTXNO_MAG+T1_NUMCTXS_MAG)
63 #define T1_CTXNO_UNI (T1_CTXNO_AGG+T1_NUMCTXS_AGG)
64 #define T1_NUMCTXS (T1_CTXNO_UNI+T1_NUMCTXS_UNI)
65 
66 // We can have a maximum 31 bits in each 32 bit wavelet coefficient
67 // as the most significant bit is reserved for the sign.
68 // Since we need T1_NMSEDEC_FRACBITS fixed point fractional bits,
69 // we can only support a maximum of (31-T1_NMSEDEC_FRACBITS) bit planes
71 
72 struct pass_enc {
73  uint32_t rate;
74  double distortiondec;
75  uint32_t len;
76  bool term;
77 };
78 
79 struct cblk_enc {
80  uint8_t* data;
82  uint32_t x0, y0, x1, y1;
83  uint32_t numbps;
84  uint32_t numPassesTotal;
85 };
86 
88  uint8_t * buf;
89  uint32_t len;
90 };
91 
92 struct seg {
93  uint32_t len;
94  uint32_t numpasses;
95 };
96 
97 struct cblk_dec {
100  uint32_t x0, y0, x1, y1;
101  uint32_t numbps;
102  uint32_t numSegments;
103 };
104 
105 /* Macros to deal with signed integer with just MSB bit set for
106  * negative values (smr = signed magnitude representation) */
107 #define smr_abs(x) (((uint32_t)(x)) & 0x7FFFFFFFU)
108 #define smr_sign(x) (((uint32_t)(x)) >> 31)
109 #define to_smr(x) ((x) >= 0 ? (uint32_t)(x) : ((uint32_t)(-x) | 0x80000000U))
110 
111 }
112 
113 #include "T1.h"
Copyright (C) 2016-2021 Grok Image Compression Inc.
Definition: BitIO.cpp:23
const uint32_t k_max_bit_planes
Definition: t1_common.h:70
Definition: t1_common.h:97
uint32_t numSegments
Definition: t1_common.h:102
uint32_t x0
Definition: t1_common.h:100
uint32_t numbps
Definition: t1_common.h:101
seg_data_chunk * seg_buffers
Definition: t1_common.h:99
uint32_t y1
Definition: t1_common.h:100
seg * segs
Definition: t1_common.h:98
uint32_t x1
Definition: t1_common.h:100
uint32_t y0
Definition: t1_common.h:100
Definition: t1_common.h:79
uint32_t x1
Definition: t1_common.h:82
uint32_t numPassesTotal
Definition: t1_common.h:84
pass_enc * passes
Definition: t1_common.h:81
uint32_t numbps
Definition: t1_common.h:83
uint32_t y1
Definition: t1_common.h:82
uint32_t y0
Definition: t1_common.h:82
uint32_t x0
Definition: t1_common.h:82
uint8_t * data
Definition: t1_common.h:80
Definition: t1_common.h:72
double distortiondec
Definition: t1_common.h:74
uint32_t len
Definition: t1_common.h:75
bool term
Definition: t1_common.h:76
uint32_t rate
Definition: t1_common.h:73
Definition: t1_common.h:87
uint32_t len
Definition: t1_common.h:89
uint8_t * buf
Definition: t1_common.h:88
Definition: t1_common.h:92
uint32_t numpasses
Definition: t1_common.h:94
uint32_t len
Definition: t1_common.h:93
const uint8_t grk_cblk_enc_compressed_data_pad_left
Definition: t1_common.h:40
#define T1_NMSEDEC_FRACBITS
Definition: t1_common.h:51
const uint8_t grk_cblk_dec_compressed_data_pad_right
< Space for a fake FFFF marker
Definition: t1_common.h:37