Grok  10.0.3
Quantizer.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  * 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 namespace grk
25 {
30 {
31  grk_stepsize() : expn(0), mant(0) {}
33  uint8_t expn;
35  uint16_t mant;
36 };
37 
38 struct Quantizer
39 {
40  public:
41  Quantizer(bool reversible, uint8_t guard_bits);
42  virtual ~Quantizer() = default;
43  // for compress
44  void pull(grk_stepsize* stepptr);
45  // for decompress
46  void push(grk_stepsize* stepptr);
47  virtual void generate(uint32_t decomps, uint32_t max_bit_depth, bool color_transform,
48  bool is_signed);
49  virtual bool write(IBufferedStream* stream);
50 
51  protected:
52  uint32_t get_num_guard_bits() const;
53  uint8_t Sqcd;
54  union
55  {
56  uint8_t u8_SPqcd[97];
57  uint16_t u16_SPqcd[97];
58  };
59  uint32_t num_decomps;
61 };
62 
63 } // namespace grk
Copyright (C) 2016-2022 Grok Image Compression Inc.
Definition: ICacheable.h:20
Definition: IBufferedStream.h:20
Definition: Quantizer.h:39
uint32_t num_decomps
Definition: Quantizer.h:59
Quantizer(bool reversible, uint8_t guard_bits)
Definition: Quantizer.cpp:26
virtual void generate(uint32_t decomps, uint32_t max_bit_depth, bool color_transform, bool is_signed)
Definition: Quantizer.cpp:80
virtual ~Quantizer()=default
uint8_t Sqcd
Definition: Quantizer.h:53
virtual bool write(IBufferedStream *stream)
Definition: Quantizer.cpp:113
void pull(grk_stepsize *stepptr)
Note:
Definition: Quantizer.cpp:50
uint32_t get_num_guard_bits() const
Definition: Quantizer.cpp:33
uint8_t u8_SPqcd[97]
Definition: Quantizer.h:56
void push(grk_stepsize *stepptr)
Definition: Quantizer.cpp:68
uint16_t u16_SPqcd[97]
Definition: Quantizer.h:57
bool isReversible
Definition: Quantizer.h:60
Quantization stepsize.
Definition: Quantizer.h:30
uint16_t mant
mantissa -11 bits
Definition: Quantizer.h:35
uint8_t expn
exponent - 5 bits
Definition: Quantizer.h:33
grk_stepsize()
Definition: Quantizer.h:31