[trunk] FolderReorgProposal task: fix jpip doxygen
[openjpeg.git] / src / lib / openjpip / box_manager.h
1 /*
2  * $Id$
3  *
4  * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
5  * Copyright (c) 2002-2011, Professor Benoit Macq
6  * Copyright (c) 2010-2011, Kaori Hagihara
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         BOX_MANAGER_H_
32 # define        BOX_MANAGER_H_
33
34 #include "byte_manager.h"
35
36 /** box parameters*/
37 typedef struct box_param{
38   int fd;                 /**< file descriptor*/
39   OPJ_OFF_T offset;         /**< byte position of the whole Box (LBox) in the file*/
40   Byte_t  headlen;        /**< header length  8 or 16*/
41   Byte8_t length;         /**< length of the whole Box*/
42   char    type[4];        /**< type of information in the DBox*/
43   struct box_param *next; /**< pointer to the next box*/
44 } box_param_t;
45
46
47 /** Box list parameters*/
48 typedef struct boxlist_param{
49   box_param_t *first; /**< first box pointer of the list*/
50   box_param_t *last;  /**< last  box pointer of the list*/
51 } boxlist_param_t;
52
53
54 /**
55  * generate a box list
56  *
57  * @return pointer to the generated box list
58  */
59 boxlist_param_t * gene_boxlist(void);
60
61 /**
62  * get box structure of JP2 file
63  *
64  * @param[in]  fd     file descriptor
65  * @param[in]  offset offset of the decomposing region
66  * @param[in]  length length of the decomposing region
67  * @return            pointer to the generated boxlist
68  */
69 boxlist_param_t * get_boxstructure( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length);
70
71
72 /**
73  * generate box from JP2 file at the given offset
74  *
75  * @param[in] fd     file discriptor of the JP2 file
76  * @param[in] offset Box offset
77  * @return           pointer to the structure of generate box parameters
78  */
79 box_param_t * gene_boxbyOffset( int fd, OPJ_OFF_T offset);
80
81
82 /**
83  * generate box from code stream (JPP or JPT stream) at the given offset
84  *
85  * @param[in] stream code stream of a box
86  * @param[in] offset Box offset of the whole stream
87  * @return           pointer to the structure of generate box parameters
88  */
89 box_param_t * gene_boxbyOffinStream( Byte_t *stream, OPJ_OFF_T offset);
90
91 /**
92  * generate(search) box from JP2 file
93  *
94  * @param[in] fd     file discriptor of the JP2 file
95  * @param[in] offset start Byte position of the search
96  * @param[in] length Byte length of the search, if 0, size to the end of file 
97  * @param[in] TBox   Box Type
98  * @return           pointer to the structure of generate/found box parameters
99  */
100 box_param_t * gene_boxbyType( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length, const char TBox[]);
101
102 /**
103  * generate(search) box from code stream
104  *
105  * @param[in] stream code stream ( from the first byte)
106  * @param[in] offset start Byte position of the search
107  * @param[in] length Byte length of the search, if 0, size to the end of file 
108  * @param[in] TBox   Box Type
109  * @return           pointer to the structure of generate/found box parameters
110  */
111 box_param_t * gene_boxbyTypeinStream( Byte_t *stream, OPJ_OFF_T offset, OPJ_SIZE_T length, const char TBox[]);
112
113 /**
114  * generate child box from JP2 file at the given offset
115  *
116  * @param[in] superbox super box pointer
117  * @param[in] offset   offset from DBox first byte of superbox
118  * @return             pointer to the structure of generate box parameters
119  */
120 box_param_t * gene_childboxbyOffset( box_param_t *superbox, OPJ_OFF_T offset);
121
122 /**
123  * generate(search) box from JP2 file
124  *
125  * @param[in] superbox super box pointer
126  * @param[in] offset   offset from DBox first byte of superbox
127  * @param[in] TBox     Box Type
128  * @return             pointer to the structure of generate/found box parameters
129  */
130 box_param_t * gene_childboxbyType( box_param_t *superbox, OPJ_OFF_T offset, const char TBox[]);
131
132 /**
133  * get DBox offset
134  *
135  * @param[in] box box pointer
136  * @return        DBox offset (byte position) in the file
137  */
138 OPJ_OFF_T get_DBoxoff( box_param_t *box);
139
140
141 /**
142  * get DBox length
143  *
144  * @param[in] box box pointer
145  * @return        DBox length ( content length)
146  */
147 OPJ_SIZE_T get_DBoxlen( box_param_t *box);
148
149
150 /**
151  * fetch header bytes in file stream
152  *
153  * @param[in] box    box pointer
154  * @return           pointer to the fetched bytes
155  */
156 Byte_t * fetch_headbytes( box_param_t *box);
157
158
159 /**
160  * fetch DBox (Box Contents) bytes of data in file stream
161  *
162  * @param[in] box    box pointer
163  * @param[in] offset start Byte position in DBox
164  * @param[in] size   Byte length
165  * @return           pointer to the fetched data
166  */
167 Byte_t * fetch_DBoxbytes( box_param_t *box, OPJ_OFF_T offset, OPJ_SIZE_T size);
168
169 /**
170  * fetch DBox (Box Contents) 1-byte Byte codes in file stream
171  *
172  * @param[in] box    box pointer
173  * @param[in] offset start Byte position in DBox
174  * @return           fetched code
175  */
176 Byte_t fetch_DBox1byte( box_param_t *box, OPJ_OFF_T offset);
177
178 /**
179  * fetch DBox (Box Contents) 2-byte big endian Byte codes in file stream
180  *
181  * @param[in] box    box pointer
182  * @param[in] offset start Byte position in DBox
183  * @return           fetched code
184  */
185 Byte2_t fetch_DBox2bytebigendian( box_param_t *box, OPJ_OFF_T offset);
186
187 /**
188  * fetch DBox (Box Contents) 4-byte big endian Byte codes in file stream
189  *
190  * @param[in] box    box pointer
191  * @param[in] offset start Byte position in DBox
192  * @return           fetched code
193  */
194 Byte4_t fetch_DBox4bytebigendian( box_param_t *box, OPJ_OFF_T offset);
195
196 /**
197  * fetch DBox (Box Contents) 8-byte big endian Byte codes in file stream
198  *
199  * @param[in] box    box pointer
200  * @param[in] offset start Byte position in DBox
201  * @return           fetched code
202  */
203 Byte8_t fetch_DBox8bytebigendian( box_param_t *box, OPJ_OFF_T offset);
204
205
206 /**
207  * search a box by box type
208  *
209  * @param[in] type    box type
210  * @param[in] boxlist box list pointer
211  * @return            found box pointer
212  */
213 box_param_t * search_box( const char type[], boxlist_param_t *boxlist);
214
215 /**
216  * print box parameters
217  *
218  * @param[in] box box pointer
219  */
220 void print_box( box_param_t *box);
221
222
223 /**
224  * print all box parameters
225  *
226  * @param[in] boxlist box list pointer
227  */
228 void print_allbox( boxlist_param_t *boxlist);
229
230 /**
231  * delete a box in list
232  *
233  * @param[in,out] box     address of the deleting box pointer
234  * @param[in]     boxlist box list pointer
235  */
236 void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist);
237
238
239 /**
240  * delete a box in list by Type
241  *
242  * @param[in,out] type    box type
243  * @param[in]     boxlist box list pointer
244  */
245 void delete_box_in_list_by_type( const char type[], boxlist_param_t *boxlist);
246
247
248 /**
249  * delete box list
250  *
251  * @param[in,out] boxlist address of the box list pointer
252  */
253 void delete_boxlist( boxlist_param_t **boxlist);
254
255
256 /**
257  * insert a box into list
258  *
259  * @param[in] box     box pointer
260  * @param[in] boxlist box list pointer
261  */
262 void insert_box_into_list( box_param_t *box, boxlist_param_t *boxlist);
263
264 #endif      /* !BOX_MANAGER_H_ */