Quantizer.h
Go to the documentation of this file.
/*
* Copyright (C) 2016-2023 Grok Image Compression Inc.
*
* This source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* This source code incorporates work covered by the BSD 2-clause license.
* Please see the LICENSE file in the root directory for details.
*
*/
#pragma once
namespace grk
{
struct grk_stepsize
{
grk_stepsize() : expn(0), mant(0) {}
uint8_t expn;
uint16_t mant;
};
struct Quantizer
{
public:
Quantizer(bool reversible, uint8_t guard_bits);
virtual ~Quantizer() = default;
// for compress
void pull(grk_stepsize* stepptr);
// for decompress
void push(grk_stepsize* stepptr);
virtual void generate(uint32_t decomps, uint32_t max_bit_depth, bool color_transform,
bool is_signed);
virtual bool write(BufferedStream* stream);
protected:
uint32_t get_num_guard_bits() const;
uint8_t Sqcd;
union
{
uint8_t u8_SPqcd[97];
uint16_t u16_SPqcd[97];
};
uint32_t num_decomps;
bool isReversible;
};
} // namespace grk
grk
Copyright (C) 2016-2023 Grok Image Compression Inc.
Definition ICacheable.h:20
grk::grk_read
void grk_read(const uint8_t *buffer, TYPE *value, uint32_t numBytes)
Definition BufferedStream.h:239
grk::BufferedStream
Definition BufferedStream.h:35
grk::Quantizer
Definition Quantizer.h:39
grk::Quantizer::num_decomps
uint32_t num_decomps
Definition Quantizer.h:59
grk::Quantizer::generate
virtual void generate(uint32_t decomps, uint32_t max_bit_depth, bool color_transform, bool is_signed)
Definition Quantizer.cpp:80
grk::Quantizer::~Quantizer
virtual ~Quantizer()=default
grk::Quantizer::Sqcd
uint8_t Sqcd
Definition Quantizer.h:53
grk::Quantizer::write
virtual bool write(BufferedStream *stream)
Definition Quantizer.cpp:113
grk::Quantizer::pull
void pull(grk_stepsize *stepptr)
Note:
Definition Quantizer.cpp:50
grk::Quantizer::get_num_guard_bits
uint32_t get_num_guard_bits() const
Definition Quantizer.cpp:33
grk::Quantizer::u8_SPqcd
uint8_t u8_SPqcd[97]
Definition Quantizer.h:56
grk::Quantizer::push
void push(grk_stepsize *stepptr)
Definition Quantizer.cpp:68
grk::Quantizer::u16_SPqcd
uint16_t u16_SPqcd[97]
Definition Quantizer.h:57
grk::Quantizer::isReversible
bool isReversible
Definition Quantizer.h:60
grk::grk_stepsize
Quantization stepsize.
Definition Quantizer.h:30
grk::grk_stepsize::mant
uint16_t mant
mantissa -11 bits
Definition Quantizer.h:35
grk::grk_stepsize::expn
uint8_t expn
exponent - 5 bits
Definition Quantizer.h:33
grk::grk_stepsize::grk_stepsize
grk_stepsize()
Definition Quantizer.h:31