Grok  7.6.6
HTParams.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2021 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  isHT(false)
84  {
85  memset(u8_SPqcd, 0, GRK_J2K_MAXBANDS);
86  memset(u16_SPqcd, 0, GRK_J2K_MAXBANDS *sizeof(short));
87  }
88 
89  void setIsHT(bool ht){ isHT = ht; }
90  void set_delta(float delta) { base_delta = delta; }
91  void set_rev_quant(uint32_t bit_depth, bool is_employing_color_transform);
92  void set_irrev_quant();
93 
94  void generate(uint8_t guard_bits,
95  uint32_t decomps,
96  bool is_reversible,
97  uint32_t max_bit_depth,
98  bool color_transform,
99  bool is_signed );
100 
101  uint32_t get_num_guard_bits() const;
102  uint32_t get_MAGBp() const;
103 
104  void pull(grk_stepsize* stepptr, bool reversible);
105  void push(grk_stepsize* stepptr, bool reversible);
106 
107 private:
108  uint8_t Sqcd;
109  union
110  {
111  uint8_t u8_SPqcd[97];
112  uint16_t u16_SPqcd[97];
113  };
114  uint32_t num_decomps;
115  float base_delta;
116  bool isHT;
117 };
118 
119 }
120 
121 
122 
Definition: HTParams.h:66
#define GRK_J2K_MAXBANDS
Maximum number of sub-bands.
Definition: grok.h:83
Copyright (C) 2016-2021 Grok Image Compression Inc.
Definition: BitIO.cpp:23
Quantization stepsize.
Definition: Quantizer.h:35
Definition: HTParams.h:78
bool isHT
Definition: HTParams.h:116
void set_delta(float delta)
Definition: HTParams.h:90
uint32_t num_decomps
Definition: HTParams.h:114
uint8_t Sqcd
Definition: HTParams.h:108
void setIsHT(bool ht)
Definition: HTParams.h:89
param_qcd()
Definition: HTParams.h:80
float base_delta
Definition: HTParams.h:115