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 INDEX_MANAGER_H_
32 # define INDEX_MANAGER_H_
34 #include "byte_manager.h"
35 #include "faixbox_manager.h"
36 #include "metadata_manager.h"
37 #include "mhixbox_manager.h"
40 /** progression order */
42 PROG_UNKNOWN = -1, /**< place-holder */
43 LRCP = 0, /**< layer-resolution-component-precinct order */
44 RLCP = 1, /**< resolution-layer-component-precinct order */
45 RPCL = 2, /**< resolution-precinct-component-layer order */
46 PCRL = 3, /**< precinct-component-resolution-layer order */
47 CPRL = 4 /**< component-precinct-resolution-layer order */
50 /** A.5.1 Image and tile size (SIZ)*/
51 typedef struct SIZmarker_param{
52 Byte2_t Lsiz; /**< length of marker segment excluding the marker*/
53 Byte2_t Rsiz; /**< capabilities that a decoder needs*/
54 Byte4_t Xsiz; /**< width of the reference grid*/
55 Byte4_t Ysiz; /**< height of the reference grid*/
56 Byte4_t XOsiz; /**< horizontal offset from the origin of the reference grid to the left side of the image area*/
57 Byte4_t YOsiz; /**< vertical offset from the origin of the reference grid to the top side of the image area*/
58 Byte4_t XTsiz; /**< width of one reference tile with respect to the reference grid*/
59 Byte4_t YTsiz; /**< height of one reference tile with respect to the reference grid*/
60 Byte4_t XTOsiz; /**< horizontal offset from the origin of the reference grid to the left side of the first tile*/
61 Byte4_t YTOsiz; /**< vertical offset from the origin of the reference grid to the top side of the first tile*/
62 Byte4_t XTnum; /**< number of tiles in horizontal direction*/
63 Byte4_t YTnum; /**< number of tiles in vertical direction*/
64 Byte2_t Csiz; /**< number of the components in the image*/
65 Byte_t Ssiz[3]; /**< precision (depth) in bits and sign of the component samples*/
66 Byte_t XRsiz[3]; /**< horizontal separation of a sample of component with respect to the reference grid*/
67 Byte_t YRsiz[3]; /**< vertical separation of a sample of component with respect to the reference grid*/
70 /** A.6.1 Coding style default (COD)*/
71 typedef struct CODmarker_param{
72 Byte2_t Lcod; /**< length of marker segment excluding the marker*/
73 Byte_t Scod; /**< Coding style for all components*/
74 porder_t prog_order; /**< progression order*/
75 Byte2_t numOflayers; /**< number of layers*/
76 Byte_t numOfdecomp; /**< number of decompositions levels*/
77 Byte4_t *XPsiz; /**< dynamic array of precinct width at successive resolution level in order*/
78 Byte4_t *YPsiz; /**< dynamic array of precinct height at successive resolution level in order*/
81 /** index parameters*/
82 typedef struct index_param{
83 metadatalist_param_t *metadatalist; /**< metadata-bin list*/
84 OPJ_OFF_T offset; /**< codestream offset*/
85 Byte8_t length; /**< codestream length */
86 Byte8_t mhead_length; /**< main header length */
87 SIZmarker_param_t SIZ; /**< SIZ marker information*/
88 CODmarker_param_t COD; /**< COD marker information*/
89 faixbox_param_t *tilepart; /**< tile part information from tpix box*/
90 mhixbox_param_t **tileheader; /**< dynamic array of tile header information from thix box*/
91 faixbox_param_t **precpacket; /**< dynamic array of precint packet information from ppix box*/
97 * AnnexI: Indexing JPEG2000 files for JPIP
99 * @param[in] fd file descriptor of the JP2 file
100 * @return pointer to the generated structure of index parameters
102 index_param_t * parse_jp2file( int fd);
105 * print index parameters
107 * @param[in] index index parameters
109 void print_index( index_param_t index);
112 * print Image and Tile SIZ parameters
114 * @param[in] SIZ SIZ marker information
116 void print_SIZ( SIZmarker_param_t SIZ);
119 * print Coding style default COD parameters
121 * @param[in] COD COD marker information
123 void print_COD( CODmarker_param_t COD);
128 * @param[in,out] index addressof the index pointer
130 void delete_index( index_param_t **index);
133 * delete dynamic arrays in COD marker
135 * @param[in] COD COD marker information
137 void delete_COD( CODmarker_param_t COD);
140 /** 1-dimensional range parameters*/
141 typedef struct range_param{
142 Byte4_t minvalue; /**< minimal value*/
143 Byte4_t maxvalue; /**< maximal value*/
147 * get horizontal range of the tile in reference grid
149 * @param[in] SIZ SIZ marker information
150 * @param[in] tile_id tile id
151 * @param[in] level decomposition level
152 * @return structured range parameter
154 range_param_t get_tile_Xrange( SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
157 * get vertical range of the tile in reference grid
159 * @param[in] SIZ SIZ marker information
160 * @param[in] tile_id tile id
161 * @param[in] level decomposition level
162 * @return structured range parameter
164 range_param_t get_tile_Yrange( SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
168 * get tile wdith at the decomposition level
170 * @param[in] SIZ SIZ marker information
171 * @param[in] tile_id tile id
172 * @param[in] level decomposition level
175 Byte4_t get_tile_XSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
176 Byte4_t get_tile_YSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
180 * answers if the target is feasible to JPT-stream
182 * @param[in] index index parameters
183 * @return true if JPT-stream is feasible
185 bool isJPTfeasible( index_param_t index);
187 #endif /* !INDEX_MANAGER_H_ */