00ce9ab91bdeda96d0d8a2de8a66a5cf6d784d15
[openjpeg.git] / src / lib / openjp2 / opj_codec.h
1 /*
2  * The copyright in this software is being made available under the 2-clauses
3  * BSD License, included below. This software may be subject to other third
4  * party and contributor rights, including patent rights, and no such rights
5  * are granted under this license.
6  *
7  * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
8  * Copyright (c) 2002-2014, Professor Benoit Macq
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 #ifndef __OPJ_CODEC_H
33 #define __OPJ_CODEC_H
34 /**
35 @file opj_codec.h
36 */
37
38
39 /**
40  * Main codec handler used for compression or decompression.
41  */
42 typedef struct opj_codec_private {
43     /** FIXME DOC */
44     union {
45         /**
46          * Decompression handler.
47          */
48         struct opj_decompression {
49             /** Main header reading function handler */
50             OPJ_BOOL(*opj_read_header)(struct opj_stream_private * cio,
51                                        void * p_codec,
52                                        opj_image_t **p_image,
53                                        struct opj_event_mgr * p_manager);
54
55             /** Decoding function */
56             OPJ_BOOL(*opj_decode)(void * p_codec,
57                                   struct opj_stream_private * p_cio,
58                                   opj_image_t * p_image,
59                                   struct opj_event_mgr * p_manager);
60
61             /** FIXME DOC */
62             OPJ_BOOL(*opj_read_tile_header)(void * p_codec,
63                                             OPJ_UINT32 * p_tile_index,
64                                             OPJ_UINT32 * p_data_size,
65                                             OPJ_INT32 * p_tile_x0,
66                                             OPJ_INT32 * p_tile_y0,
67                                             OPJ_INT32 * p_tile_x1,
68                                             OPJ_INT32 * p_tile_y1,
69                                             OPJ_UINT32 * p_nb_comps,
70                                             OPJ_BOOL * p_should_go_on,
71                                             struct opj_stream_private * p_cio,
72                                             struct opj_event_mgr * p_manager);
73
74             /** FIXME DOC */
75             OPJ_BOOL(*opj_decode_tile_data)(void * p_codec,
76                                             OPJ_UINT32 p_tile_index,
77                                             OPJ_BYTE * p_data,
78                                             OPJ_UINT32 p_data_size,
79                                             struct opj_stream_private * p_cio,
80                                             struct opj_event_mgr * p_manager);
81
82             /** Reading function used after codestream if necessary */
83             OPJ_BOOL(* opj_end_decompress)(void *p_codec,
84                                            struct opj_stream_private * cio,
85                                            struct opj_event_mgr * p_manager);
86
87             /** Codec destroy function handler */
88             void (*opj_destroy)(void * p_codec);
89
90             /** Setup decoder function handler */
91             void (*opj_setup_decoder)(void * p_codec, opj_dparameters_t * p_param);
92
93             /** Set decode area function handler */
94             OPJ_BOOL(*opj_set_decode_area)(void * p_codec,
95                                            opj_image_t * p_image,
96                                            OPJ_INT32 p_start_x,
97                                            OPJ_INT32 p_end_x,
98                                            OPJ_INT32 p_start_y,
99                                            OPJ_INT32 p_end_y,
100                                            struct opj_event_mgr * p_manager);
101
102             /** Get tile function */
103             OPJ_BOOL(*opj_get_decoded_tile)(void *p_codec,
104                                             opj_stream_private_t * p_cio,
105                                             opj_image_t *p_image,
106                                             struct opj_event_mgr * p_manager,
107                                             OPJ_UINT32 tile_index);
108
109             /** Set the decoded resolution factor */
110             OPJ_BOOL(*opj_set_decoded_resolution_factor)(void * p_codec,
111                     OPJ_UINT32 res_factor,
112                     opj_event_mgr_t * p_manager);
113
114         } m_decompression;
115
116         /**
117          * Compression handler. FIXME DOC
118          */
119         struct opj_compression {
120             OPJ_BOOL(* opj_start_compress)(void *p_codec,
121                                            struct opj_stream_private * cio,
122                                            struct opj_image * p_image,
123                                            struct opj_event_mgr * p_manager);
124
125             OPJ_BOOL(* opj_encode)(void * p_codec,
126                                    struct opj_stream_private *p_cio,
127                                    struct opj_event_mgr * p_manager);
128
129             OPJ_BOOL(* opj_write_tile)(void * p_codec,
130                                        OPJ_UINT32 p_tile_index,
131                                        OPJ_BYTE * p_data,
132                                        OPJ_UINT32 p_data_size,
133                                        struct opj_stream_private * p_cio,
134                                        struct opj_event_mgr * p_manager);
135
136             OPJ_BOOL(* opj_end_compress)(void * p_codec,
137                                          struct opj_stream_private * p_cio,
138                                          struct opj_event_mgr * p_manager);
139
140             void (* opj_destroy)(void * p_codec);
141
142             OPJ_BOOL(* opj_setup_encoder)(void * p_codec,
143                                           opj_cparameters_t * p_param,
144                                           struct opj_image * p_image,
145                                           struct opj_event_mgr * p_manager);
146         } m_compression;
147     } m_codec_data;
148     /** FIXME DOC*/
149     void * m_codec;
150     /** Event handler */
151     opj_event_mgr_t m_event_mgr;
152     /** Flag to indicate if the codec is used to decode or encode*/
153     OPJ_BOOL is_decompressor;
154     void (*opj_dump_codec)(void * p_codec, OPJ_INT32 info_flag,
155                            FILE* output_stream);
156     opj_codestream_info_v2_t* (*opj_get_codec_info)(void* p_codec);
157     opj_codestream_index_t* (*opj_get_codec_index)(void* p_codec);
158
159     /** Set number of threads */
160     OPJ_BOOL(*opj_set_threads)(void * p_codec, OPJ_UINT32 num_threads);
161 }
162 opj_codec_private_t;
163
164
165 #endif /* __OPJ_CODEC_H */
166