Merge pull request #1390 from stweil/typos
[openjpeg.git] / src / lib / openjpip / index_manager.h
1 /*
2  * $Id$
3  *
4  * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
5  * Copyright (c) 2002-2014, 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     INDEX_MANAGER_H_
32 # define    INDEX_MANAGER_H_
33
34 #include "opj_config.h"
35 #include "opj_includes.h"
36
37 #include "byte_manager.h"
38 #include "faixbox_manager.h"
39 #include "metadata_manager.h"
40 #include "mhixbox_manager.h"
41
42 /** progression order */
43 #if 0
44 typedef enum porder {
45     PROG_UNKNOWN = -1,      /**< place-holder */
46     LRCP = 0,               /**< layer-resolution-component-precinct order */
47     RLCP = 1,               /**< resolution-layer-component-precinct order */
48     RPCL = 2,               /**< resolution-precinct-component-layer order */
49     PCRL = 3,               /**< precinct-component-resolution-layer order */
50     CPRL = 4                /**< component-precinct-resolution-layer order */
51 } porder_t;
52 #endif
53
54 /** A.5.1 Image and tile size (SIZ)*/
55 typedef struct SIZmarker_param {
56     Byte2_t Lsiz;              /**< length of marker segment excluding the marker*/
57     Byte2_t Rsiz;              /**< capabilities that a decoder needs*/
58     Byte4_t Xsiz;              /**< width of the reference grid*/
59     Byte4_t Ysiz;              /**< height of the reference grid*/
60     Byte4_t XOsiz;             /**< horizontal offset from the origin of the reference grid to the left side of the image area*/
61     Byte4_t YOsiz;             /**< vertical offset from the origin of the reference grid to the top side of the image area*/
62     Byte4_t XTsiz;             /**< width of one reference tile with respect to the reference grid*/
63     Byte4_t YTsiz;             /**< height of one reference tile with respect to the reference grid*/
64     Byte4_t XTOsiz;            /**< horizontal offset from the origin of the reference grid to the left side of the first tile*/
65     Byte4_t YTOsiz;            /**< vertical offset from the origin of the reference grid to the top side of the first tile*/
66     Byte4_t XTnum;             /**< number of tiles in horizontal direction*/
67     Byte4_t YTnum;             /**< number of tiles in vertical direction*/
68     Byte2_t Csiz;              /**< number of the components in the image*/
69     Byte_t  Ssiz[3];           /**< precision (depth) in bits and sign of the component samples*/
70     Byte_t  XRsiz[3];          /**< horizontal separation of a sample of component with respect to the reference grid*/
71     Byte_t  YRsiz[3];          /**< vertical separation of a sample of component with respect to the reference grid*/
72 } SIZmarker_param_t;
73
74 /** A.6.1 Coding style default (COD)*/
75 typedef struct CODmarker_param {
76     Byte2_t  Lcod;             /**< length of marker segment excluding the marker*/
77     Byte_t   Scod;             /**< Coding style for all components*/
78     OPJ_PROG_ORDER prog_order;       /**< progression order*/
79     Byte2_t  numOflayers;      /**< number of layers*/
80     Byte_t   numOfdecomp;      /**< number of decompositions levels*/
81     Byte4_t  *XPsiz;           /**< dynamic array of precinct width  at successive resolution level in order*/
82     Byte4_t  *YPsiz;           /**< dynamic array of precinct height at successive resolution level in order*/
83 } CODmarker_param_t;
84
85 /** index parameters*/
86 typedef struct index_param {
87     metadatalist_param_t *metadatalist; /**< metadata-bin list*/
88     OPJ_OFF_T offset;                     /**< codestream offset*/
89     Byte8_t length;                     /**< codestream length */
90     Byte8_t mhead_length;               /**< main header length  */
91     SIZmarker_param_t SIZ;              /**< SIZ marker information*/
92     CODmarker_param_t COD;              /**< COD marker information*/
93     faixbox_param_t *tilepart;          /**< tile part information from tpix box*/
94     mhixbox_param_t
95     **tileheader;       /**< dynamic array of tile header information from thix box*/
96     faixbox_param_t
97     **precpacket;       /**< dynamic array of precint packet information from ppix box*/
98 } index_param_t;
99
100
101 /**
102  * parse JP2 file
103  * AnnexI: Indexing JPEG2000 files for JPIP
104  *
105  * @param[in] fd file descriptor of the JP2 file
106  * @return       pointer to the generated structure of index parameters
107  */
108 index_param_t * parse_jp2file(int fd);
109
110 /**
111  * print index parameters
112  *
113  * @param[in] index index parameters
114  */
115 void print_index(index_param_t index);
116
117 /**
118  * print Image and Tile SIZ parameters
119  *
120  * @param[in] SIZ SIZ marker information
121  */
122 void print_SIZ(SIZmarker_param_t SIZ);
123
124 /**
125  * print Coding style default COD parameters
126  *
127  * @param[in] COD COD marker information
128  */
129 void print_COD(CODmarker_param_t COD);
130
131 /**
132  * delete index
133  *
134  * @param[in,out] index addressof the index pointer
135  */
136 void delete_index(index_param_t **index);
137
138 /**
139  * delete dynamic arrays in COD marker
140  *
141  * @param[in] COD COD marker information
142  */
143 void delete_COD(CODmarker_param_t COD);
144
145
146 /** 1-dimensional range parameters*/
147 typedef struct range_param {
148     Byte4_t minvalue; /**< minimal value*/
149     Byte4_t maxvalue; /**< maximal value*/
150 } range_param_t;
151
152 /**
153  * get horizontal range of the tile in reference grid
154  *
155  * @param[in] SIZ      SIZ marker information
156  * @param[in] tile_id  tile id
157  * @param[in] level    decomposition level
158  * @return             structured range parameter
159  */
160 range_param_t get_tile_Xrange(SIZmarker_param_t SIZ, Byte4_t tile_id,
161                               int level);
162
163 /**
164  * get vertical range of the tile in reference grid
165  *
166  * @param[in] SIZ      SIZ marker information
167  * @param[in] tile_id  tile id
168  * @param[in] level    decomposition level
169  * @return             structured range parameter
170  */
171 range_param_t get_tile_Yrange(SIZmarker_param_t SIZ, Byte4_t tile_id,
172                               int level);
173
174
175 /**
176  * get tile wdith at the decomposition level
177  *
178  * @param[in] SIZ      SIZ marker information
179  * @param[in] tile_id  tile id
180  * @param[in] level    decomposition level
181  * @return             tile width
182  */
183 Byte4_t get_tile_XSiz(SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
184 Byte4_t get_tile_YSiz(SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
185
186
187 /**
188  * answers if the target is feasible to JPT-stream
189  *
190  * @param[in] index index parameters
191  * @return    true if JPT-stream is feasible
192  */
193 OPJ_BOOL isJPTfeasible(index_param_t index);
194
195 #endif      /* !INDEX_MANAGER_H_ */