OpenJPEG: t1.h Source File

OpenJPEG 2.5.0

t1.h
Go to the documentation of this file.
1/*
2 * The copyright in this software is being made available under the 2-clauses
3 * BSD License, included below. This software may be subject to other third
4 * party and contributor rights, including patent rights, and no such rights
5 * are granted under this license.
6 *
7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
8 * Copyright (c) 2002-2014, Professor Benoit Macq
9 * Copyright (c) 2001-2003, David Janssens
10 * Copyright (c) 2002-2003, Yannick Verschueren
11 * Copyright (c) 2003-2007, Francois-Olivier Devaux
12 * Copyright (c) 2003-2014, Antonin Descampe
13 * Copyright (c) 2005, Herve Drolon, FreeImage Team
14 * Copyright (c) 2012, Carl Hetherington
15 * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39#ifndef OPJ_T1_H
40#define OPJ_T1_H
51
52/* ----------------------------------------------------------------------- */
53#define T1_NMSEDEC_BITS 7
54
55#define T1_NUMCTXS_ZC 9
56#define T1_NUMCTXS_SC 5
57#define T1_NUMCTXS_MAG 3
58#define T1_NUMCTXS_AGG 1
59#define T1_NUMCTXS_UNI 1
60
61#define T1_CTXNO_ZC 0
62#define T1_CTXNO_SC (T1_CTXNO_ZC+T1_NUMCTXS_ZC)
63#define T1_CTXNO_MAG (T1_CTXNO_SC+T1_NUMCTXS_SC)
64#define T1_CTXNO_AGG (T1_CTXNO_MAG+T1_NUMCTXS_MAG)
65#define T1_CTXNO_UNI (T1_CTXNO_AGG+T1_NUMCTXS_AGG)
66#define T1_NUMCTXS (T1_CTXNO_UNI+T1_NUMCTXS_UNI)
67
68#define T1_NMSEDEC_FRACBITS (T1_NMSEDEC_BITS-1)
69
70#define T1_TYPE_MQ 0
71#define T1_TYPE_RAW 1
73/* BEGINNING of flags that apply to opj_flag_t */
85/* SIGMA: significance state (3 cols x 6 rows)
86 * CHI: state for negative sample value (1 col x 6 rows)
87 * MU: state for visited in refinement pass (1 col x 4 rows)
88 * PI: state for visited in significance pass (1 col * 4 rows)
89 */
90
91#define T1_SIGMA_0 (1U << 0)
92#define T1_SIGMA_1 (1U << 1)
93#define T1_SIGMA_2 (1U << 2)
94#define T1_SIGMA_3 (1U << 3)
95#define T1_SIGMA_4 (1U << 4)
96#define T1_SIGMA_5 (1U << 5)
97#define T1_SIGMA_6 (1U << 6)
98#define T1_SIGMA_7 (1U << 7)
99#define T1_SIGMA_8 (1U << 8)
100#define T1_SIGMA_9 (1U << 9)
101#define T1_SIGMA_10 (1U << 10)
102#define T1_SIGMA_11 (1U << 11)
103#define T1_SIGMA_12 (1U << 12)
104#define T1_SIGMA_13 (1U << 13)
105#define T1_SIGMA_14 (1U << 14)
106#define T1_SIGMA_15 (1U << 15)
107#define T1_SIGMA_16 (1U << 16)
108#define T1_SIGMA_17 (1U << 17)
109
110#define T1_CHI_0 (1U << 18)
111#define T1_CHI_0_I 18
112#define T1_CHI_1 (1U << 19)
113#define T1_CHI_1_I 19
114#define T1_MU_0 (1U << 20)
115#define T1_PI_0 (1U << 21)
116#define T1_CHI_2 (1U << 22)
117#define T1_CHI_2_I 22
118#define T1_MU_1 (1U << 23)
119#define T1_PI_1 (1U << 24)
120#define T1_CHI_3 (1U << 25)
121#define T1_MU_2 (1U << 26)
122#define T1_PI_2 (1U << 27)
123#define T1_CHI_4 (1U << 28)
124#define T1_MU_3 (1U << 29)
125#define T1_PI_3 (1U << 30)
126#define T1_CHI_5 (1U << 31)
127#define T1_CHI_5_I 31
128
149#define T1_SIGMA_NW T1_SIGMA_0
150#define T1_SIGMA_N T1_SIGMA_1
151#define T1_SIGMA_NE T1_SIGMA_2
152#define T1_SIGMA_W T1_SIGMA_3
153#define T1_SIGMA_THIS T1_SIGMA_4
154#define T1_SIGMA_E T1_SIGMA_5
155#define T1_SIGMA_SW T1_SIGMA_6
156#define T1_SIGMA_S T1_SIGMA_7
157#define T1_SIGMA_SE T1_SIGMA_8
158#define T1_SIGMA_NEIGHBOURS (T1_SIGMA_NW | T1_SIGMA_N | T1_SIGMA_NE | T1_SIGMA_W | T1_SIGMA_E | T1_SIGMA_SW | T1_SIGMA_S | T1_SIGMA_SE)
159
160#define T1_CHI_THIS T1_CHI_1
161#define T1_CHI_THIS_I T1_CHI_1_I
162#define T1_MU_THIS T1_MU_0
163#define T1_PI_THIS T1_PI_0
164#define T1_CHI_S T1_CHI_2
165
166#define T1_LUT_SGN_W (1U << 0)
167#define T1_LUT_SIG_N (1U << 1)
168#define T1_LUT_SGN_E (1U << 2)
169#define T1_LUT_SIG_W (1U << 3)
170#define T1_LUT_SGN_N (1U << 4)
171#define T1_LUT_SIG_E (1U << 5)
172#define T1_LUT_SGN_S (1U << 6)
173#define T1_LUT_SIG_S (1U << 7)
174/* END of flags that apply to opj_flag_t */
175
176/* ----------------------------------------------------------------------- */
177
179 typedef OPJ_UINT32 opj_flag_t;
180
184 typedef struct opj_t1 {
185
187 opj_mqc_t mqc;
188
189 OPJ_INT32 *data;
195 opj_flag_t *flags;
196
197 OPJ_UINT32 w;
198 OPJ_UINT32 h;
199 OPJ_UINT32 datasize;
200 OPJ_UINT32 flagssize;
201 OPJ_BOOL encoder;
202
203 /* The 3 variables below are only used by the decoder */
204 /* set to TRUE in multithreaded context */
205 OPJ_BOOL mustuse_cblkdatabuffer;
206 /* Temporary buffer to concatenate all chunks of a codebock */
207 OPJ_BYTE *cblkdatabuffer;
208 /* Maximum size available in cblkdatabuffer */
209 OPJ_UINT32 cblkdatabuffersize;
210} opj_t1_t;
211
214/* ----------------------------------------------------------------------- */
215
224 OPJ_BOOL opj_t1_encode_cblks(opj_tcd_t* tcd,
225 opj_tcd_tile_t *tile,
226 opj_tcp_t *tcp,
227 const OPJ_FLOAT64 * mct_norms,
228 OPJ_UINT32 mct_numcomps);
229
240void opj_t1_decode_cblks(opj_tcd_t* tcd,
241 volatile OPJ_BOOL* pret,
242 opj_tcd_tilecomp_t* tilec,
243 opj_tccp_t* tccp,
244 opj_event_mgr_t *p_manager,
245 opj_mutex_t* p_manager_mutex,
246 OPJ_BOOL check_pterm);
247
248
249
255 opj_t1_t* opj_t1_create(OPJ_BOOL isEncoder);
256
262void opj_t1_destroy(opj_t1_t *p_t1);
263/* ----------------------------------------------------------------------- */
267
268#endif /* OPJ_T1_H */
OPJ_BYTE
unsigned char OPJ_BYTE
Definition openjpeg.h:123
OPJ_FLOAT64
double OPJ_FLOAT64
Definition openjpeg.h:122
OPJ_INT32
int32_t OPJ_INT32
Definition openjpeg.h:131
OPJ_UINT32
uint32_t OPJ_UINT32
Definition openjpeg.h:132
OPJ_BOOL
int OPJ_BOOL
Definition openjpeg.h:116
tcp
@ tcp
Definition query_parser.h:41
opj_event_mgr
Message handler object used for.
Definition event.h:50
opj_mqc
MQ coder.
Definition mqc.h:74
opj_t1
Tier-1 coding (coding of code-block coefficients)
Definition t1.h:184
opj_t1::w
OPJ_UINT32 w
Definition t1.h:197
opj_t1::encoder
OPJ_BOOL encoder
Definition t1.h:201
opj_t1::cblkdatabuffer
OPJ_BYTE * cblkdatabuffer
Definition t1.h:207
opj_t1::h
OPJ_UINT32 h
Definition t1.h:198
opj_t1::flagssize
OPJ_UINT32 flagssize
Definition t1.h:200
opj_t1::mqc
opj_mqc_t mqc
MQC component.
Definition t1.h:187
opj_t1::datasize
OPJ_UINT32 datasize
Definition t1.h:199
opj_t1::data
OPJ_INT32 * data
Definition t1.h:189
opj_t1::cblkdatabuffersize
OPJ_UINT32 cblkdatabuffersize
Definition t1.h:209
opj_t1::mustuse_cblkdatabuffer
OPJ_BOOL mustuse_cblkdatabuffer
Definition t1.h:205
opj_t1::flags
opj_flag_t * flags
Flags used by decoder and encoder.
Definition t1.h:195
opj_tccp
Tile-component coding parameters.
Definition j2k.h:179
opj_tcd_tile
FIXME DOC.
Definition tcd.h:233
opj_tcd_tilecomp
Tile-component structure.
Definition tcd.h:194
opj_tcd
Tile coder/decoder.
Definition tcd.h:256
opj_tcp
Tile coding parameters : this structure is used to store coding/decoding parameters common to all til...
Definition j2k.h:245
opj_t1_t
struct opj_t1 opj_t1_t
Tier-1 coding (coding of code-block coefficients)
opj_t1_decode_cblks
void opj_t1_decode_cblks(opj_tcd_t *tcd, volatile OPJ_BOOL *pret, opj_tcd_tilecomp_t *tilec, opj_tccp_t *tccp, opj_event_mgr_t *p_manager, opj_mutex_t *p_manager_mutex, OPJ_BOOL check_pterm)
Decode the code-blocks of a tile.
Definition t1.c:1836
opj_t1_encode_cblks
OPJ_BOOL opj_t1_encode_cblks(opj_tcd_t *tcd, opj_tcd_tile_t *tile, opj_tcp_t *tcp, const OPJ_FLOAT64 *mct_norms, OPJ_UINT32 mct_numcomps)
Encode the code-blocks of a tile.
Definition t1.c:2304
opj_flag_t
OPJ_UINT32 opj_flag_t
Flags for 4 consecutive rows of a column.
Definition t1.h:179
opj_t1_destroy
void opj_t1_destroy(opj_t1_t *p_t1)
Destroys a previously created T1 handle.
Definition t1.c:1568
opj_t1_create
opj_t1_t * opj_t1_create(OPJ_BOOL isEncoder)
Creates a new Tier 1 handle and initializes the look-up tables of the Tier-1 coder/decoder.
Definition t1.c:1548
opj_mutex_t
struct opj_mutex_t opj_mutex_t
Opaque type for a mutex.
Definition thread.h:52