Added the default lossless parameter to opj_set_default_encoder_parameters in openjpeg.c
[openjpeg.git] / v2 / libopenjpeg / pi.h
1 /*\r
2  * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium\r
3  * Copyright (c) 2002-2007, Professor Benoit Macq\r
4  * Copyright (c) 2001-2003, David Janssens\r
5  * Copyright (c) 2002-2003, Yannick Verschueren\r
6  * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe\r
7  * Copyright (c) 2005, Herve Drolon, FreeImage Team\r
8  * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>\r
9  * All rights reserved.\r
10  *\r
11  * Redistribution and use in source and binary forms, with or without\r
12  * modification, are permitted provided that the following conditions\r
13  * are met:\r
14  * 1. Redistributions of source code must retain the above copyright\r
15  *    notice, this list of conditions and the following disclaimer.\r
16  * 2. Redistributions in binary form must reproduce the above copyright\r
17  *    notice, this list of conditions and the following disclaimer in the\r
18  *    documentation and/or other materials provided with the distribution.\r
19  *\r
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'\r
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\r
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
30  * POSSIBILITY OF SUCH DAMAGE.\r
31  */\r
32 \r
33 #ifndef __PI_H\r
34 #define __PI_H\r
35 /**\r
36 @file pi.h\r
37 @brief Implementation of a packet iterator (PI)\r
38 \r
39 The functions in PI.C have for goal to realize a packet iterator that permits to get the next\r
40 packet following the progression order and change of it. The functions in PI.C are used\r
41 by some function in T2.C.\r
42 */\r
43 #include "openjpeg.h"\r
44 #include "t2.h"\r
45 /** @defgroup PI PI - Implementation of a packet iterator */\r
46 /*@{*/\r
47 struct opj_poc;\r
48 struct opj_image;\r
49 struct opj_cp;\r
50 \r
51 /**\r
52 FIXME: documentation\r
53 */\r
54 typedef struct opj_pi_resolution {\r
55   OPJ_UINT32 pdx, pdy;\r
56   OPJ_UINT32 pw, ph;\r
57 } opj_pi_resolution_t;\r
58 \r
59 /**\r
60 FIXME: documentation\r
61 */\r
62 typedef struct opj_pi_comp {\r
63   OPJ_UINT32 dx, dy;\r
64   /** number of resolution levels */\r
65   OPJ_UINT32 numresolutions;\r
66   opj_pi_resolution_t *resolutions;\r
67 } opj_pi_comp_t;\r
68 \r
69 /** \r
70 Packet iterator \r
71 */\r
72 typedef struct opj_pi_iterator {\r
73         /** Enabling Tile part generation*/\r
74         OPJ_BYTE tp_on;\r
75         /** precise if the packet has been already used (usefull for progression order change) */\r
76         OPJ_INT16 *include;\r
77         /** layer step used to localize the packet in the include vector */\r
78         OPJ_UINT32 step_l;\r
79         /** resolution step used to localize the packet in the include vector */\r
80         OPJ_UINT32 step_r;      \r
81         /** component step used to localize the packet in the include vector */\r
82         OPJ_UINT32 step_c;      \r
83         /** precinct step used to localize the packet in the include vector */\r
84         OPJ_UINT32 step_p;      \r
85         /** component that identify the packet */\r
86         OPJ_UINT32 compno;\r
87         /** resolution that identify the packet */\r
88         OPJ_UINT32 resno;\r
89         /** precinct that identify the packet */\r
90         OPJ_UINT32 precno;\r
91         /** layer that identify the packet */\r
92         OPJ_UINT32 layno;   \r
93         /** progression order change information */\r
94         struct opj_poc poc;\r
95         /** number of components in the image */\r
96         OPJ_UINT32 numcomps;\r
97         /** Components*/\r
98         opj_pi_comp_t *comps;\r
99         OPJ_INT32 tx0, ty0, tx1, ty1;\r
100         OPJ_INT32 x, y;\r
101         OPJ_UINT32 dx, dy;\r
102         /** 0 if the first packet */\r
103         OPJ_UINT32 first : 1;\r
104 } opj_pi_iterator_t;\r
105 \r
106 /** @name Exported functions */\r
107 /*@{*/\r
108 /* ----------------------------------------------------------------------- */\r
109 /**\r
110  * Creates a packet iterator for encoding.\r
111  * \r
112  * @param       p_image         the image being encoded.\r
113  * @param       p_cp            the coding parameters.\r
114  * @param       p_tile_no       index of the tile being encoded.\r
115  * @param       p_t2_mode       the type of pass for generating the packet iterator\r
116  * @return      a list of packet iterator that points to the first packet of the tile (not true).\r
117 */\r
118 opj_pi_iterator_t *pi_initialise_encode(const struct opj_image *image,struct opj_cp *cp, OPJ_UINT32 tileno,J2K_T2_MODE t2_mode);\r
119 \r
120 /**\r
121  * Updates the encoding parameters of the codec.\r
122  * \r
123  * @param       p_image         the image being encoded.\r
124  * @param       p_cp            the coding parameters.\r
125  * @param       p_tile_no       index of the tile being encoded.\r
126 */\r
127 void pi_update_encoding_parameters(\r
128                                                                                 const struct opj_image *p_image,\r
129                                                                                 struct opj_cp *p_cp, \r
130                                                                                 OPJ_UINT32 p_tile_no\r
131                                                                                 );\r
132 \r
133 \r
134 \r
135 /**\r
136 Modify the packet iterator for enabling tile part generation\r
137 @param pi Handle to the packet iterator generated in pi_initialise_encode  \r
138 @param cp Coding parameters\r
139 @param tileno Number that identifies the tile for which to list the packets\r
140 @param tpnum Tile part number of the current tile\r
141 @param tppos The position of the tile part flag in the progression order\r
142 */\r
143 void pi_create_encode( opj_pi_iterator_t *pi, struct opj_cp *cp,OPJ_UINT32 tileno, OPJ_UINT32 pino,OPJ_UINT32 tpnum, OPJ_INT32 tppos, J2K_T2_MODE t2_mode);\r
144 \r
145 \r
146 /**\r
147 Create a packet iterator for Decoder\r
148 @param image Raw image for which the packets will be listed\r
149 @param cp Coding parameters\r
150 @param tileno Number that identifies the tile for which to list the packets\r
151 @return Returns a packet iterator that points to the first packet of the tile\r
152 @see pi_destroy\r
153 */\r
154 opj_pi_iterator_t *pi_create_decode(struct opj_image * image, struct opj_cp * cp, OPJ_UINT32 tileno);\r
155 \r
156 \r
157 \r
158 /**\r
159  * Destroys a packet iterator array.\r
160  * \r
161  * @param       p_pi                    the packet iterator array to destroy.\r
162  * @param       p_nb_elements   the number of elements in the array.\r
163  */\r
164 void pi_destroy(\r
165                                 opj_pi_iterator_t *p_pi,\r
166                                 OPJ_UINT32 p_nb_elements);\r
167 \r
168 /**\r
169 Modify the packet iterator to point to the next packet\r
170 @param pi Packet iterator to modify\r
171 @return Returns false if pi pointed to the last packet or else returns true \r
172 */\r
173 bool pi_next(opj_pi_iterator_t * pi);\r
174 \r
175 \r
176 /* ----------------------------------------------------------------------- */\r
177 /*@}*/\r
178 \r
179 /*@}*/\r
180 \r
181 #endif /* __PI_H */\r