Grok 10.0.5
coding_local.hpp
Go to the documentation of this file.
1// Copyright (c) 2019 - 2021, Osamu Watanabe
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are met:
6//
7// 1. Redistributions of source code must retain the above copyright notice, this
8// list of conditions and the following disclaimer.
9//
10// 2. Redistributions in binary form must reproduce the above copyright notice,
11// this list of conditions and the following disclaimer in the documentation
12// and/or other materials provided with the distribution.
13//
14// 3. Neither the name of the copyright holder nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29#pragma once
30
31#define SHIFT_SIGMA 0 // J2K and HTJ2K
32#define SHIFT_SIGMA_ 1 // J2K only
33#define SHIFT_PI_ 2 // J2K and HTJ2K; used as refinement indicator for HTJ2K
34#define SHIFT_REF 3 // HTJ2K only
35#define SHIFT_SCAN 4 // HTJ2K only
36
37// getters
38inline uint8_t Sigma(uint8_t &data) { return (data >> SHIFT_SIGMA) & 1; }
39inline uint8_t Sigma_(uint8_t &data) { return (data >> SHIFT_SIGMA_) & 1; }
40inline uint8_t Pi_(uint8_t &data) { return (data >> SHIFT_PI_) & 1; }
41inline uint8_t Scan(uint8_t &data) { return (data >> SHIFT_SCAN) & 1; }
42inline uint8_t Refinement_value(uint8_t &data) { return (data >> SHIFT_REF) & 1; }
43inline uint8_t Refinement_indicator(uint8_t &data) { return (data >> SHIFT_PI_) & 1; }
44
45// setters
46inline void sigma(uint8_t &data, const uint8_t &val) { data |= val; }
47inline void scan(uint8_t &data, const uint8_t &val) { data |= val << SHIFT_SCAN; }
48inline void refinement_value(uint8_t &data, const uint8_t &val) { data |= val << SHIFT_REF; }
49inline void refinement_indicator(uint8_t &data, const uint8_t &val) {
50 if (val) {
51 data |= 1 << SHIFT_PI_;
52 } else {
53 data &= ~(1 << SHIFT_PI_);
54 }
55}
uint8_t Sigma(uint8_t &data)
Definition: coding_local.hpp:38
#define SHIFT_PI_
Definition: coding_local.hpp:33
#define SHIFT_REF
Definition: coding_local.hpp:34
uint8_t Scan(uint8_t &data)
Definition: coding_local.hpp:41
void refinement_indicator(uint8_t &data, const uint8_t &val)
Definition: coding_local.hpp:49
#define SHIFT_SIGMA
Definition: coding_local.hpp:31
#define SHIFT_SIGMA_
Definition: coding_local.hpp:32
uint8_t Refinement_indicator(uint8_t &data)
Definition: coding_local.hpp:43
void scan(uint8_t &data, const uint8_t &val)
Definition: coding_local.hpp:47
void refinement_value(uint8_t &data, const uint8_t &val)
Definition: coding_local.hpp:48
#define SHIFT_SCAN
Definition: coding_local.hpp:35
uint8_t Pi_(uint8_t &data)
Definition: coding_local.hpp:40
void sigma(uint8_t &data, const uint8_t &val)
Definition: coding_local.hpp:46
uint8_t Sigma_(uint8_t &data)
Definition: coding_local.hpp:39
uint8_t Refinement_value(uint8_t &data)
Definition: coding_local.hpp:42