Grok 12.0.1
mqc.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2024 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
24#include <t1_common.h>
25#include "plugin_interface.h"
26namespace grk
27{
28
29// the next line must be uncommented in order to support debugging
30// for plugin encode
31// #define PLUGIN_DEBUG_ENCODE
32
33struct mqc_state;
34struct mqcoder;
35
47
48#define MQC_NUMCTXS 19
49struct mqcoder
50{
57 /* only used by decoder, to count the number of times a terminating 0xFF >0x8F marker is read */
69 /* lut_ctxno_zc shifted by (1 << 9) * bandIndex */
73#ifdef PLUGIN_DEBUG_ENCODE
75#endif
76};
77
78const uint32_t A_MIN = 0x8000;
79
80#include "mqc_inl.h"
81#include "mqc_dec_inl.h"
82#include "mqc_enc_inl.h"
83
86
87/* ENCODE */
88
99
100/* DECODE */
101
117void mqc_init_dec(mqcoder* mqc, uint8_t* bp, uint32_t len);
118
135
145
146} // namespace grk
#define MQC_NUMCTXS
Definition mqc.h:48
Copyright (C) 2016-2024 Grok Image Compression Inc.
Definition ICacheable.h:20
void mqc_flush_enc(mqcoder *mqc)
Definition mqc_enc.cpp:213
void grk_read(const uint8_t *buffer, TYPE *value, uint32_t numBytes)
Definition BufferedStream.h:239
uint32_t mqc_numbytes_enc(mqcoder *mqc)
Definition mqc_enc.cpp:177
void mqc_segmark_enc(mqcoder *mqc)
Definition mqc_enc.cpp:327
void mqc_raw_init_dec(mqcoder *mqc, uint8_t *bp, uint32_t len)
Initialize the decoder for RAW decoding.
Definition mqc_dec.cpp:107
void mqc_bypass_flush_enc(mqcoder *mqc, bool erterm)
Definition mqc_enc.cpp:252
const uint32_t A_MIN
Definition mqc.h:78
void mqc_erterm_enc(mqcoder *mqc)
Definition mqc_enc.cpp:312
void mqc_bypass_enc(mqcoder *mqc, uint32_t d)
void mqc_finish_dec(mqcoder *mqc)
Terminate RAW/MQC decoding.
Definition mqc_dec.cpp:114
void mqc_restart_init_enc(mqcoder *mqc)
Definition mqc_enc.cpp:294
void mqc_bypass_init_enc(mqcoder *mqc)
Definition mqc_enc.cpp:229
void mqc_encode(mqcoder *mqc, uint32_t d)
Definition mqc_enc.cpp:205
void mqc_init_enc(mqcoder *mqc, uint8_t *bp)
Definition mqc_enc.cpp:182
uint32_t mqc_bypass_get_extra_bytes_enc(mqcoder *mqc, bool erterm)
Definition mqc_enc.cpp:247
void mqc_init_dec(mqcoder *mqc, uint8_t *bp, uint32_t len)
Initialize the decoder for MQ decoding.
Definition mqc_dec.cpp:91
void mqc_resetstates(mqcoder *mqc)
Definition mqc_dec.cpp:120
Definition plugin_interface.h:35
Definition mqc.h:37
const mqc_state * nmps
next state if the next encoded symbol is the MPS
Definition mqc.h:43
const mqc_state * nlps
next state if the next encoded symbol is the LPS
Definition mqc.h:45
uint32_t mps
the Most Probable Symbol (0 or 1)
Definition mqc.h:41
uint32_t qeval
the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff)
Definition mqc.h:39
Definition mqc.h:50
uint32_t end_of_byte_stream_counter
Definition mqc.h:58
uint8_t * end
pointer to the end of the buffer
Definition mqc.h:64
const mqc_state * ctxs[MQC_NUMCTXS]
Array of contexts.
Definition mqc.h:66
uint32_t a
only used by MQ decoder
Definition mqc.h:54
uint8_t * start
pointer to the start of the buffer
Definition mqc.h:62
const uint8_t * lut_ctxno_zc_orient
Definition mqc.h:70
const mqc_state ** curctx
Active context.
Definition mqc.h:68
uint8_t * bp
pointer to the current position in the buffer
Definition mqc.h:60
uint8_t backup[grk_cblk_dec_compressed_data_pad_right]
Original value of the 2 bytes at end[0] and end[1].
Definition mqc.h:72
uint32_t ct
number of bits already read or free to write
Definition mqc.h:56
uint32_t c
temporary buffer where bits are coded or decoded
Definition mqc.h:52
const uint8_t grk_cblk_dec_compressed_data_pad_right
< Space for a fake FFFF marker
Definition t1_common.h:37