JasPer 4.2.8
 
Loading...
Searching...
No Matches
jpc_t2cod.h
1/*
2 * Copyright (c) 1999-2000 Image Power, Inc. and the University of
3 * British Columbia.
4 * Copyright (c) 2001-2002 Michael David Adams.
5 * All rights reserved.
6 */
7
8/* __START_OF_JASPER_LICENSE__
9 *
10 * JasPer License Version 2.0
11 *
12 * Copyright (c) 2001-2006 Michael David Adams
13 * Copyright (c) 1999-2000 Image Power, Inc.
14 * Copyright (c) 1999-2000 The University of British Columbia
15 *
16 * All rights reserved.
17 *
18 * Permission is hereby granted, free of charge, to any person (the
19 * "User") obtaining a copy of this software and associated documentation
20 * files (the "Software"), to deal in the Software without restriction,
21 * including without limitation the rights to use, copy, modify, merge,
22 * publish, distribute, and/or sell copies of the Software, and to permit
23 * persons to whom the Software is furnished to do so, subject to the
24 * following conditions:
25 *
26 * 1. The above copyright notices and this permission notice (which
27 * includes the disclaimer below) shall be included in all copies or
28 * substantial portions of the Software.
29 *
30 * 2. The name of a copyright holder shall not be used to endorse or
31 * promote products derived from the Software without specific prior
32 * written permission.
33 *
34 * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
35 * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
36 * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
37 * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
39 * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
40 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
41 * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
42 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
43 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
44 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
45 * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
46 * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
47 * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
48 * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
49 * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
50 * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
51 * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
52 * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
53 * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
54 * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
55 * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
56 * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
57 * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
58 * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
59 * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
60 *
61 * __END_OF_JASPER_LICENSE__
62 */
63
64/*
65 * Tier-2 Coding Library
66 *
67 * $Id$
68 */
69
70#ifndef JPC_T2COD_H
71#define JPC_T2COD_H
72
73/******************************************************************************\
74* Includes.
75\******************************************************************************/
76
77#include "jpc_cs.h"
78
79/******************************************************************************\
80* Types.
81\******************************************************************************/
82
83/* Progression change list. */
84
85typedef struct {
86
87 /* The number of progression changes. */
88 unsigned numpchgs;
89
90 /* The maximum number of progression changes that can be accomodated
91 without growing the progression change array. */
92 unsigned maxpchgs;
93
94 /* The progression changes. */
95 jpc_pchg_t **pchgs;
96
97} jpc_pchglist_t;
98
99/* Packet iterator per-resolution-level information. */
100
101typedef struct {
102
103 /* The number of precincts. */
104 unsigned numprcs;
105
106 /* The last layer processed for each precinct. */
107 unsigned *prclyrnos;
108
109 /* The precinct width exponent. */
110 unsigned prcwidthexpn;
111
112 /* The precinct height exponent. */
113 unsigned prcheightexpn;
114
115 /* The number of precincts spanning the resolution level in the horizontal
116 direction. */
117 unsigned numhprcs;
118
119} jpc_pirlvl_t;
120
121/* Packet iterator per-component information. */
122
123typedef struct {
124
125 /* The number of resolution levels. */
126 unsigned numrlvls;
127
128 /* The per-resolution-level information. */
129 jpc_pirlvl_t *pirlvls;
130
131 /* The horizontal sampling period. */
132 uint_fast32_t hsamp;
133
134 /* The vertical sampling period. */
135 uint_fast32_t vsamp;
136
137} jpc_picomp_t;
138
139/* Packet iterator class. */
140
141typedef struct {
142
143 /* The number of layers. */
144 unsigned numlyrs;
145
146 /* The number of resolution levels. */
147 unsigned maxrlvls;
148
149 /* The number of components. */
150 unsigned numcomps;
151
152 /* The per-component information. */
153 jpc_picomp_t *picomps;
154
155 /* The current component. */
156 jpc_picomp_t *picomp;
157
158 /* The current resolution level. */
159 jpc_pirlvl_t *pirlvl;
160
161 /* The number of the current component. */
162 unsigned compno;
163
164 /* The number of the current resolution level. */
165 unsigned rlvlno;
166
167 /* The number of the current precinct. */
168 unsigned prcno;
169
170 /* The number of the current layer. */
171 unsigned lyrno;
172
173 /* The x-coordinate of the current position. */
174 uint_fast32_t x;
175
176 /* The y-coordinate of the current position. */
177 uint_fast32_t y;
178
179 /* The horizontal step size. */
180 uint_fast32_t xstep;
181
182 /* The vertical step size. */
183 uint_fast32_t ystep;
184
185 /* The x-coordinate of the top-left corner of the tile on the reference
186 grid. */
187 uint_fast32_t xstart;
188
189 /* The y-coordinate of the top-left corner of the tile on the reference
190 grid. */
191 uint_fast32_t ystart;
192
193 /* The x-coordinate of the bottom-right corner of the tile on the
194 reference grid (plus one). */
195 uint_fast32_t xend;
196
197 /* The y-coordinate of the bottom-right corner of the tile on the
198 reference grid (plus one). */
199 uint_fast32_t yend;
200
201 /* The current progression change. */
202 const jpc_pchg_t *pchg;
203
204 /* The progression change list. */
205 jpc_pchglist_t *pchglist;
206
207 /* The progression to use in the absense of explicit specification. */
208 jpc_pchg_t defaultpchg;
209
210 /* The current progression change number. */
211 int pchgno;
212
213 /* Is this the first time in the current progression volume? */
214 bool prgvolfirst;
215
216 /* Is the current iterator value valid? */
217 bool valid;
218
219 /* The current packet number. */
220 int pktno;
221
222} jpc_pi_t;
223
224/******************************************************************************\
225* Functions/macros for packet iterators.
226\******************************************************************************/
227
228/* Create a packet iterator. */
229jpc_pi_t *jpc_pi_create0(void);
230
231/* Destroy a packet iterator. */
232void jpc_pi_destroy(jpc_pi_t *pi);
233
234/* Add a progression change to a packet iterator. */
235int jpc_pi_addpchg(jpc_pi_t *pi, jpc_pocpchg_t *pchg);
236
237/* Prepare a packet iterator for iteration. */
238int jpc_pi_init(jpc_pi_t *pi);
239
240/* Set the iterator to the first packet. */
241int jpc_pi_begin(jpc_pi_t *pi);
242
243/* Proceed to the next packet in sequence. */
244int jpc_pi_next(jpc_pi_t *pi);
245
246/* Get the index of the current packet. */
247#define jpc_pi_getind(pi) ((pi)->pktno)
248
249/* Get the component number of the current packet. */
250#define jpc_pi_cmptno(pi) (assert(pi->valid), (pi)->compno)
251
252/* Get the resolution level of the current packet. */
253#define jpc_pi_rlvlno(pi) (assert(pi->valid), (pi)->rlvlno)
254
255/* Get the layer number of the current packet. */
256#define jpc_pi_lyrno(pi) (assert(pi->valid), (pi)->lyrno)
257
258/* Get the precinct number of the current packet. */
259#define jpc_pi_prcno(pi) (assert(pi->valid), (pi)->prcno)
260
261/* Get the progression order for the current packet. */
262#define jpc_pi_prg(pi) (assert(pi->valid), (pi)->pchg->prgord)
263
264/******************************************************************************\
265* Functions/macros for progression change lists.
266\******************************************************************************/
267
268/* Create a progression change list. */
269jpc_pchglist_t *jpc_pchglist_create(void);
270
271/* Destroy a progression change list. */
272void jpc_pchglist_destroy(jpc_pchglist_t *pchglist);
273
274/* Insert a new element into a progression change list. */
275int jpc_pchglist_insert(jpc_pchglist_t *pchglist, int pchgno, jpc_pchg_t *pchg);
276
277/* Remove an element from a progression change list. */
278jpc_pchg_t *jpc_pchglist_remove(jpc_pchglist_t *pchglist, unsigned pchgno);
279
280/* Get an element from a progression change list. */
281JAS_ATTRIBUTE_PURE
282const jpc_pchg_t *jpc_pchglist_get(const jpc_pchglist_t *pchglist, unsigned pchgno);
283
284/* Copy a progression change list. */
285jpc_pchglist_t *jpc_pchglist_copy(const jpc_pchglist_t *pchglist);
286
287/* Get the number of elements in a progression change list. */
288JAS_ATTRIBUTE_PURE
289unsigned jpc_pchglist_numpchgs(const jpc_pchglist_t *pchglist);
290
291/******************************************************************************\
292* Functions/macros for progression changes.
293\******************************************************************************/
294
295/* Destroy a progression change. */
296void jpc_pchg_destroy(jpc_pchg_t *pchg);
297
298/* Copy a progression change. */
299jpc_pchg_t *jpc_pchg_copy(const jpc_pchg_t *pchg);
300
301/******************************************************************************\
302* Functions/macros for debugging.
303\******************************************************************************/
304
305void jpc_pi_dump(const jpc_pi_t *pi);
306
307#endif