Grok 20.3.2
t1_common.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2026 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
18#pragma once
19
20#include <cstdint>
21#include <cmath>
22#include <cassert>
23
24namespace grk::t1
25{
26
35// LL band index when resolution == 0
36const uint32_t BAND_RES_ZERO_INDEX_LL = 0;
37
38// band indices when resolution > 0
46
47const uint32_t T1_NUMCTXS_ZC = 9;
48const uint32_t T1_NUMCTXS_SC = 5;
49const uint32_t T1_NUMCTXS_MAG = 3;
50const uint32_t T1_NUMCTXS_AGG = 1;
51const uint32_t T1_NUMCTXS_UNI = 1;
52
53const uint32_t T1_CTXNO_ZC = 0;
59
61{
62 uint16_t rate;
64 uint16_t len;
65 bool term;
66};
67
69{
70 uint8_t* data;
72 uint32_t x0, y0, x1, y1;
73 uint8_t numbps;
75#ifdef PLUGIN_DEBUG_ENCODE
76 uint32_t* context_stream;
77#endif
78 pass_enc* getPass(uint8_t passno)
79 {
80 return passes + passno;
81 }
82};
83
84/* Macros to deal with signed integer with just MSB bit set for
85 * negative values (smr = signed magnitude representation) */
86#define smr_abs(x) (((uint32_t)(x)) & 0x7FFFFFFFU)
87#define smr_sign(x) (uint8_t)(((uint32_t)(x)) >> 31)
88#define to_smr(x) ((x) >= 0 ? (uint32_t)(x) : ((uint32_t)(-x) | 0x80000000U))
89
90} // namespace grk::t1
Definition SchedulerFreebyrd.h:36
const uint32_t T1_NUMCTXS_UNI
Definition t1_common.h:51
eBandOrientation
Definition t1_common.h:28
@ BAND_ORIENT_HH
Definition t1_common.h:32
@ BAND_ORIENT_LL
Definition t1_common.h:29
@ BAND_ORIENT_LH
Definition t1_common.h:31
@ BAND_NUM_ORIENTATIONS
Definition t1_common.h:33
@ BAND_ORIENT_HL
Definition t1_common.h:30
const uint32_t T1_NUMCTXS_MAG
Definition t1_common.h:49
const uint32_t T1_CTXNO_ZC
Definition t1_common.h:53
const uint32_t T1_NUMCTXS_ZC
Definition t1_common.h:47
const uint32_t T1_CTXNO_SC
Definition t1_common.h:54
const uint32_t T1_CTXNO_MAG
Definition t1_common.h:55
const uint32_t T1_NUMCTXS_SC
Definition t1_common.h:48
const uint32_t BAND_RES_ZERO_INDEX_LL
Definition t1_common.h:36
const uint32_t T1_CTXNO_AGG
Definition t1_common.h:56
eBandIndex
Definition t1_common.h:40
@ BAND_INDEX_HL
Definition t1_common.h:41
@ BAND_NUM_INDICES
Definition t1_common.h:44
@ BAND_INDEX_HH
Definition t1_common.h:43
@ BAND_INDEX_LH
Definition t1_common.h:42
const uint32_t T1_NUMCTXS
Definition t1_common.h:58
const uint32_t T1_NUMCTXS_AGG
Definition t1_common.h:50
const uint32_t T1_CTXNO_UNI
Definition t1_common.h:57
Definition t1_common.h:69
pass_enc * getPass(uint8_t passno)
Definition t1_common.h:78
uint32_t x1
Definition t1_common.h:72
uint8_t * data
Definition t1_common.h:70
uint8_t numPassesTotal
Definition t1_common.h:74
uint32_t y0
Definition t1_common.h:72
uint32_t y1
Definition t1_common.h:72
uint32_t x0
Definition t1_common.h:72
pass_enc * passes
Definition t1_common.h:71
uint8_t numbps
Definition t1_common.h:73
Definition t1_common.h:61
double distortiondec
Definition t1_common.h:63
uint16_t len
Definition t1_common.h:64
bool term
Definition t1_common.h:65
uint16_t rate
Definition t1_common.h:62