OpenJPEG version 1.1
[openjpeg.git] / libopenjpeg / pi.h
1 /*
2  * Copyright (c) 2001-2003, David Janssens
3  * Copyright (c) 2002-2003, Yannick Verschueren
4  * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
5  * Copyright (c) 2005, Herv� Drolon, FreeImage Team
6  * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
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
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #ifndef __PI_H
32 #define __PI_H
33 /**
34 @file pi.h
35 @brief Implementation of a packet iterator (PI)
36
37 The functions in PI.C have for goal to realize a packet iterator that permits to get the next
38 packet following the progression order and change of it. The functions in PI.C are used
39 by some function in T2.C.
40 */
41
42 /** @defgroup PI PI - Implementation of a packet iterator */
43 /*@{*/
44
45 /**
46 FIXME: documentation
47 */
48 typedef struct opj_pi_resolution {
49   int pdx, pdy;
50   int pw, ph;
51 } opj_pi_resolution_t;
52
53 /**
54 FIXME: documentation
55 */
56 typedef struct opj_pi_comp {
57   int dx, dy;
58   /** number of resolution levels */
59   int numresolutions;
60   opj_pi_resolution_t *resolutions;
61 } opj_pi_comp_t;
62
63 /** 
64 Packet iterator 
65 */
66 typedef struct opj_pi_iterator {
67         /** precise if the packet has been already used (usefull for progression order change) */
68         short int *include;
69         /** layer step used to localize the packet in the include vector */
70         int step_l;
71         /** resolution step used to localize the packet in the include vector */
72         int step_r;     
73         /** component step used to localize the packet in the include vector */
74         int step_c;     
75         /** precinct step used to localize the packet in the include vector */
76         int step_p;     
77         /** component that identify the packet */
78         int compno;
79         /** resolution that identify the packet */
80         int resno;
81         /** precinct that identify the packet */
82         int precno;
83         /** layer that identify the packet */
84         int layno;   
85         /** 0 if the first packet */
86         int first;
87         /** progression order change information */
88         opj_poc_t poc;
89         /** */
90         int numcomps;
91         /** */
92         opj_pi_comp_t *comps;
93         int tx0, ty0, tx1, ty1;
94         int x, y, dx, dy;
95 } opj_pi_iterator_t;
96
97 /** @name Exported functions */
98 /*@{*/
99 /* ----------------------------------------------------------------------- */
100 /**
101 Create a packet iterator
102 @param image Raw image for which the packets will be listed
103 @param cp Coding parameters
104 @param tileno Number that identifies the tile for which to list the packets
105 @return Returns a packet iterator that points to the first packet of the tile
106 @see pi_destroy
107 */
108 opj_pi_iterator_t *pi_create(opj_image_t * image, opj_cp_t * cp, int tileno);
109
110 /**
111 Destroy a packet iterator
112 @param pi Previously created packet iterator
113 @param cp Coding parameters
114 @param tileno Number that identifies the tile for which the packets were listed
115 @see pi_create
116 */
117 void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno);
118
119 /**
120 Modify the packet iterator to point to the next packet
121 @param pi Packet iterator to modify
122 @return Returns false if pi pointed to the last packet or else returns true 
123 */
124 bool pi_next(opj_pi_iterator_t * pi);
125 /* ----------------------------------------------------------------------- */
126 /*@}*/
127
128 /*@}*/
129
130 #endif /* __PI_H */