2 * $Id: box_manager.h 44 2011-02-15 12:32:29Z kaori $
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
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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.
31 #ifndef BOX_MANAGER_H_
32 # define BOX_MANAGER_H_
34 #include "byte_manager.h"
37 typedef struct box_param{
38 int fd; //!< file descriptor
39 Byte8_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
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
57 * @return pointer to the generated box list
59 boxlist_param_t * gene_boxlist();
62 * get box structure of JP2 file
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
69 boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length);
73 * generate box from JP2 file at the given offset
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
79 box_param_t * gene_boxbyOffset( int fd, Byte8_t offset);
83 * generate box from code stream (JPP or JPT stream) at the given offset
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
89 box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset);
92 * generate(search) box from JP2 file
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
100 box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[]);
103 * generate(search) box from code stream
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
111 box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, char TBox[]);
114 * generate child box from JP2 file at the given offset
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
120 box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset);
123 * generate(search) box from JP2 file
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
130 box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, char TBox[]);
135 * @param[in] box box pointer
136 * @return DBox offset (byte position) in the file
138 Byte8_t get_DBoxoff( box_param_t *box);
144 * @param[in] box box pointer
145 * @return DBox length ( content length)
147 Byte8_t get_DBoxlen( box_param_t *box);
151 * fetch header bytes in file stream
153 * @param[in] box box pointer
154 * @return pointer to the fetched bytes
156 Byte_t * fetch_headbytes( box_param_t *box);
160 * fetch DBox (Box Contents) bytes of data in file stream
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
167 Byte_t * fetch_DBoxbytes( box_param_t *box, long offset, int size);
170 * fetch DBox (Box Contents) 1-byte Byte codes in file stream
172 * @param[in] box box pointer
173 * @param[in] offset start Byte position in DBox
174 * @return fetched code
176 Byte_t fetch_DBox1byte( box_param_t *box, long offset);
179 * fetch DBox (Box Contents) 2-byte big endian Byte codes in file stream
181 * @param[in] box box pointer
182 * @param[in] offset start Byte position in DBox
183 * @return fetched code
185 Byte2_t fetch_DBox2bytebigendian( box_param_t *box, long offset);
188 * fetch DBox (Box Contents) 4-byte big endian Byte codes in file stream
190 * @param[in] box box pointer
191 * @param[in] offset start Byte position in DBox
192 * @return fetched code
194 Byte4_t fetch_DBox4bytebigendian( box_param_t *box, long offset);
197 * fetch DBox (Box Contents) 8-byte big endian Byte codes in file stream
199 * @param[in] box box pointer
200 * @param[in] offset start Byte position in DBox
201 * @return fetched code
203 Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset);
207 * search a box by box type
209 * @param[in] type box type
210 * @param[in] boxlist box list pointer
211 * @return found box pointer
213 box_param_t * search_box( char type[], boxlist_param_t *boxlist);
216 * print box parameters
218 * @param[in] box box pointer
220 void print_box( box_param_t *box);
224 * print all box parameters
226 * @param[in] boxlist box list pointer
228 void print_allbox( boxlist_param_t *boxlist);
231 * delete a box in list
233 * @param[in,out] box address of the deleting box pointer
234 * @param[in] boxlist box list pointer
236 void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist);
240 * delete a box in list by Type
242 * @param[in,out] type box type
243 * @param[in] boxlist box list pointer
245 void delete_box_in_list_by_type( char type[], boxlist_param_t *boxlist);
251 * @param[in,out] boxlist address of the box list pointer
253 void delete_boxlist( boxlist_param_t **boxlist);
257 * insert a box into list
259 * @param[in] box box pointer
260 * @param[in] boxlist box list pointer
262 void insert_box_into_list( box_param_t *box, boxlist_param_t *boxlist);
264 #endif /* !BOX_MANAGER_H_ */