1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*! @file vlc.h
*
* @brief This file defines the data structures for the wavelet tree
*
* @version 1.0.0
*
* (C) Copyright 2018 GoPro Inc (http://gopro.com/).
*
* Licensed under either:
* - Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0
* - MIT license, http://opensource.org/licenses/MIT
* at your option.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef WAVELET_H
#define WAVELET_H
#include "common.h"
/*!
@brief Data structure used for wavelets
This data structure is used for wavelets and can be used for images since
an image with multiple planar channels and a wavelet with multiple bands
are similar data structures.
The pitch is the distance between rows in bytes and must always be
an integer multiple of the pixel size in bytes.
The wavelet data structure contains an array of the scale factor for
each band that is the cummulative result of the application of the
wavelet transforms that created the wavelet.
*/
typedef struct _wavelet
{
DIMENSION width; //!< Width of the image in pixels
DIMENSION height; //!< Height of the image in lines
DIMENSION pitch; //!< Distance between rows (in bytes)
uint16_t band_count; //!< Number of bands in a wavelet
uint32_t valid_band_mask; //!< Mask indicating which bands have been decoded
uint16_t scale[MAX_BAND_COUNT]; //!< Cumulative scaling by the wavelet transforms
QUANT quant[MAX_BAND_COUNT]; //!< Quantization value for each band
PIXEL *data[MAX_BAND_COUNT]; //!< Data buffer for each band
} WAVELET;
//! Indices for the wavelet bands in the image data structure
typedef enum
{
LL_BAND = 0, //!< Lowpass transform of lowpass intermediate result
LH_BAND, //!< Lowpass transform of highpass intermediate result
HL_BAND, //!< Highpass transform of lowpass intermediate result
HH_BAND //!< Highpass transform of highpass intermediate result
} WAVELET_BAND;
//! Types of wavelet tranforms
enum
{
WAVELET_TYPE_HORIZONTAL = 1,
WAVELET_TYPE_VERTICAL = 2,
WAVELET_TYPE_TEMPORAL = 4,
//! The baseline profile only supports spatial wavelets
WAVELET_TYPE_SPATIAL = (WAVELET_TYPE_HORIZONTAL | WAVELET_TYPE_VERTICAL),
};
//! Data structure for the wavelet tree (one channel)
typedef struct _transform
{
//! Prescale the input by the specified shift before the transform
PRESCALE prescale[MAX_WAVELET_COUNT];
//! List of the wavelets in the transform for one channel
WAVELET *wavelet[MAX_WAVELET_COUNT];
} TRANSFORM;
#ifdef __cplusplus
extern "C" {
#endif
CODEC_ERROR AllocWavelet(gpr_allocator *allocator, WAVELET *wavelet, DIMENSION width, DIMENSION height);
CODEC_ERROR ReleaseWavelet(gpr_allocator *allocator, WAVELET *wavelet);
WAVELET *CreateWavelet(gpr_allocator *allocator, DIMENSION width, DIMENSION height);
CODEC_ERROR DeleteWavelet(gpr_allocator *allocator, WAVELET *wavelet);
CODEC_ERROR SetTransformScale(TRANSFORM *transform);
CODEC_ERROR SetTransformPrescale(TRANSFORM *transform, int precision);
bool BandValidMask(int band);
bool BandsAllValid(WAVELET *wavelet);
#define AllBandsValid BandsAllValid
CODEC_ERROR UpdateWaveletValidBandMask(WAVELET *wavelet, int band);
int SubbandWaveletIndex(int subband);
int SubbandBandIndex(int subband);
CODEC_ERROR ResetTransformFlags(TRANSFORM transform[], int transform_count);
CODEC_ERROR ReleaseTransform(gpr_allocator *allocator, TRANSFORM *transform);
bool IsTransformPrescaleDefault(TRANSFORM *transform, int precision);
PIXEL *WaveletRowAddress(WAVELET *wavelet, int band, int row);
void WaveletToRGB( gpr_allocator allocator, PIXEL* GS_src, PIXEL* RG_src, PIXEL* BG_src, DIMENSION src_width, DIMENSION src_height, DIMENSION src_pitch, RGB_IMAGE *dst_image,
int input_precision_bits, int output_precision_bits, gpr_rgb_gain* rgb_gain );
#ifdef __cplusplus
}
#endif
#endif // WAVELET_H
|