Grok  7.6.2
HTParams.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2020 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 following license:
18  */
19 // This software is released under the 2-Clause BSD license, included
20 // below.
21 //
22 // Copyright (c) 2019, Aous Naman
23 // Copyright (c) 2019, Kakadu Software Pty Ltd, Australia
24 // Copyright (c) 2019, The University of New South Wales, Australia
25 //
26 // Redistribution and use in source and binary forms, with or without
27 // modification, are permitted provided that the following conditions are
28 // met:
29 //
30 // 1. Redistributions of source code must retain the above copyright
31 // notice, this list of conditions and the following disclaimer.
32 //
33 // 2. Redistributions in binary form must reproduce the above copyright
34 // notice, this list of conditions and the following disclaimer in the
35 // documentation and/or other materials provided with the distribution.
36 //
37 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
38 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
39 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
40 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
41 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
43 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
44 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
46 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 //***************************************************************************/
49 // This file is part of the OpenJPH software implementation.
50 // File: ojph_expand.cpp
51 // Author: Aous Naman
52 // Date: 28 August 2019
53 //***************************************************************************/
54 
55 
56 #pragma once
57 
58 #include <algorithm>
59 #include <cstdint>
60 #include <cstring>
61 using namespace std;
62 
63 namespace grk {
64 
66 {
67 public:
68  static float get_gain_l(uint32_t num_decomp, bool reversible);
69  static float get_gain_h(uint32_t num_decomp, bool reversible);
70 private:
71  static const float gain_9x7_l[34];
72  static const float gain_9x7_h[34];
73  static const float gain_5x3_l[34];
74  static const float gain_5x3_h[34];
75 };
76 
77 struct param_qcd
78 {
79 public:
80  param_qcd() : Sqcd(0),
81  num_decomps(0),
82  base_delta(-1.0f)
83  {
84  memset(u8_SPqcd, 0, 97);
85  memset(u16_SPqcd, 0, 97*sizeof(short));
86  }
87 
88  void set_delta(float delta) { base_delta = delta; }
89  void set_rev_quant(uint32_t bit_depth, bool is_employing_color_transform);
90  void set_irrev_quant();
91 
92  void generate(uint8_t guard_bits,
93  uint32_t decomps,bool is_reversible,
94  uint32_t max_bit_depth, bool color_transform, bool is_signed );
95 
96  uint32_t get_num_guard_bits() const;
97  uint32_t get_MAGBp() const;
98 
99  void pull(grk_stepsize* stepptr, bool reversible);
100  void push(grk_stepsize* stepptr, bool reversible);
101 
102 private:
103  uint8_t Sqcd;
104  union
105  {
106  uint8_t u8_SPqcd[97];
107  uint16_t u16_SPqcd[97];
108  };
109  uint32_t num_decomps;
110  float base_delta;
111 };
112 
113 }
114 
115 
116 
grk::param_qcd::param_qcd
param_qcd()
Definition: HTParams.h:80
grk::bibo_gains
Definition: HTParams.cpp:108
grk::sqrt_energy_gains
Definition: HTParams.h:66
grk::grk_stepsize
Quantization stepsize.
Definition: Quantizer.h:35
HTParams.h
grk::log
void log(grk_msg_callback msg_handler, void *l_data, char const *const format, Args &... args) noexcept
Definition: logger.cpp:30
grk::param_qcd
Definition: HTParams.h:78
grk::bibo_gains::get_bibo_gain_h
static float get_bibo_gain_h(uint32_t num_decomp, bool reversible)
Definition: HTParams.cpp:112
grk
Copyright (C) 2016-2020 Grok Image Compression Inc.
Definition: BitIO.cpp:23
grk_includes.h
grk::param_qcd::Sqcd
uint8_t Sqcd
Definition: HTParams.h:103
grk::param_qcd::base_delta
float base_delta
Definition: HTParams.h:110
grk::bibo_gains::get_bibo_gain_l
static float get_bibo_gain_l(uint32_t num_decomp, bool reversible)
Definition: HTParams.cpp:110
grk::grk_stepsize::expn
uint8_t expn
exponent - 5 bits
Definition: Quantizer.h:39
grk::param_qcd::num_decomps
uint32_t num_decomps
Definition: HTParams.h:109
grk::param_qcd::set_delta
void set_delta(float delta)
Definition: HTParams.h:88