[trunk] Rework r2077
[openjpeg.git] / src / lib / openjp2 / indexbox_manager.h
1 /*
2  * $Id: indexbox_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
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) 2003-2004, Yannick Verschueren
7  * Copyright (c) 2010-2011, Kaori Hagihara
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 /*! \file
33  *  \brief Modification of jpip.c from 2KAN indexer
34  */
35
36 #ifndef  INDEXBOX_MANAGER_H_
37 # define INDEXBOX_MANAGER_H_
38
39 #include "openjpeg.h"
40 #include "j2k.h" /* needed to use jp2.h */
41 #include "jp2.h"
42
43 #define JPIP_CIDX 0x63696478   /* Codestream index                */
44 #define JPIP_CPTR 0x63707472   /* Codestream Finder Box           */
45 #define JPIP_MANF 0x6d616e66   /* Manifest Box                    */
46 #define JPIP_FAIX 0x66616978   /* Fragment array Index box        */
47 #define JPIP_MHIX 0x6d686978   /* Main Header Index Table         */
48 #define JPIP_TPIX 0x74706978   /* Tile-part Index Table box       */
49 #define JPIP_THIX 0x74686978   /* Tile header Index Table box     */
50 #define JPIP_PPIX 0x70706978   /* Precinct Packet Index Table box */
51 #define JPIP_PHIX 0x70686978   /* Packet Header index Table       */
52 #define JPIP_FIDX 0x66696478   /* File Index                      */
53 #define JPIP_FPTR 0x66707472   /* File Finder                     */
54 #define JPIP_PRXY 0x70727879   /* Proxy boxes                     */
55 #define JPIP_IPTR 0x69707472   /* Index finder box                */
56 #define JPIP_PHLD 0x70686c64   /* Place holder                    */
57
58
59 /* 
60  * Write tile-part Index table box (superbox)
61  *
62  * @param[in] coff      offset of j2k codestream
63  * @param[in] cstr_info codestream information
64  * @param[in] j2klen    length of j2k codestream
65  * @param[in] cio       file output handle
66  * @return              length of tpix box
67  */
68 int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio);
69 int write_tpix_v2( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_stream_private_t *cio,
70               opj_event_mgr_t * p_manager );
71
72
73 /* 
74  * Write tile header index table box (superbox)
75  *
76  * @param[in] coff      offset of j2k codestream
77  * @param[in] cstr_info codestream information pointer
78  * @param[in] cio       file output handle
79  * @return              length of thix box
80  */
81 int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio);
82 int write_thix_v2( int coff, opj_codestream_info_t cstr_info, opj_stream_private_t *cio, opj_event_mgr_t * p_manager );
83
84
85 /* 
86  * Write precinct packet index table box (superbox)
87  *
88  * @param[in] coff      offset of j2k codestream
89  * @param[in] cstr_info codestream information
90  * @param[in] EPHused   true if EPH option used
91  * @param[in] j2klen    length of j2k codestream
92  * @param[in] cio       file output handle
93  * @return              length of ppix box
94  */
95 int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
96 int write_ppix_v2( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_stream_private_t *cio,
97               opj_event_mgr_t * p_manager );
98
99
100 /* 
101  * Write packet header index table box (superbox)
102  *
103  * @param[in] coff      offset of j2k codestream
104  * @param[in] cstr_info codestream information
105  * @param[in] EPHused   true if EPH option used
106  * @param[in] j2klen    length of j2k codestream
107  * @param[in] cio       file output handle
108  * @return              length of ppix box
109  */
110 int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
111 int write_phix_v2( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_stream_private_t *cio,
112               opj_event_mgr_t * p_manager );
113
114 /* 
115  * Wriet manifest box (box)
116  *
117  * @param[in] second number to be visited
118  * @param[in] v      number of boxes
119  * @param[in] box    box to be manifested
120  * @param[in] cio    file output handle
121  */
122 void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio);
123
124 int write_mainmhix_v2( int coff, opj_codestream_info_t cstr_info, opj_stream_private_t *cio,
125               opj_event_mgr_t * p_manager );
126
127 int write_phixfaix_v2( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_stream_private_t *cio,
128               opj_event_mgr_t * p_manager );
129
130 int write_ppixfaix_v2( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_stream_private_t *cio,
131               opj_event_mgr_t * p_manager );
132
133 int write_tilemhix_v2( int coff, opj_codestream_info_t cstr_info, int tileno, opj_stream_private_t *cio,
134               opj_event_mgr_t * p_manager );
135
136 int write_tpixfaix_v2( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_stream_private_t *cio,
137               opj_event_mgr_t * p_manager );
138
139 #endif      /* !INDEXBOX_MANAGER_H_ */