Grok  9.7.5
t1_common.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 #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_NUMCTXS_ZC 9
51 #define T1_NUMCTXS_SC 5
52 #define T1_NUMCTXS_MAG 3
53 #define T1_NUMCTXS_AGG 1
54 #define T1_NUMCTXS_UNI 1
55 
56 #define T1_CTXNO_ZC 0
57 #define T1_CTXNO_SC (T1_CTXNO_ZC + T1_NUMCTXS_ZC)
58 #define T1_CTXNO_MAG (T1_CTXNO_SC + T1_NUMCTXS_SC)
59 #define T1_CTXNO_AGG (T1_CTXNO_MAG + T1_NUMCTXS_MAG)
60 #define T1_CTXNO_UNI (T1_CTXNO_AGG + T1_NUMCTXS_AGG)
61 #define T1_NUMCTXS (T1_CTXNO_UNI + T1_NUMCTXS_UNI)
62 
63 struct pass_enc
64 {
65  uint32_t rate;
66  double distortiondec;
67  uint32_t len;
68  bool term;
69 };
70 
71 struct cblk_enc
72 {
73  uint8_t* data;
75  uint32_t x0, y0, x1, y1;
76  uint8_t numbps;
77  uint32_t numPassesTotal;
78 };
79 
80 /* Macros to deal with signed integer with just MSB bit set for
81  * negative values (smr = signed magnitude representation) */
82 #define smr_abs(x) (((uint32_t)(x)) & 0x7FFFFFFFU)
83 #define smr_sign(x) (((uint32_t)(x)) >> 31)
84 #define to_smr(x) ((x) >= 0 ? (uint32_t)(x) : ((uint32_t)(-x) | 0x80000000U))
85 
86 } // namespace grk
87 
88 #include "T1.h"
Copyright (C) 2016-2022 Grok Image Compression Inc.
Definition: ICacheable.h:20
Definition: t1_common.h:72
uint32_t x1
Definition: t1_common.h:75
uint32_t numPassesTotal
Definition: t1_common.h:77
pass_enc * passes
Definition: t1_common.h:74
uint32_t y1
Definition: t1_common.h:75
uint32_t y0
Definition: t1_common.h:75
uint32_t x0
Definition: t1_common.h:75
uint8_t * data
Definition: t1_common.h:73
uint8_t numbps
Definition: t1_common.h:76
Definition: t1_common.h:64
double distortiondec
Definition: t1_common.h:66
uint32_t len
Definition: t1_common.h:67
bool term
Definition: t1_common.h:68
uint32_t rate
Definition: t1_common.h:65
const uint8_t grk_cblk_enc_compressed_data_pad_left
Definition: t1_common.h:40
const uint8_t grk_cblk_dec_compressed_data_pad_right
< Space for a fake FFFF marker
Definition: t1_common.h:37