OpenJPEG  2.1.0
openjpeg.h
Go to the documentation of this file.
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  * Copyright (c) 2001-2003, David Janssens
10  * Copyright (c) 2002-2003, Yannick Verschueren
11  * Copyright (c) 2003-2007, Francois-Olivier Devaux
12  * Copyright (c) 2003-2014, Antonin Descampe
13  * Copyright (c) 2005, Herve Drolon, FreeImage Team
14  * Copyright (c) 2006-2007, Parvatha Elangovan
15  * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
16  * Copyright (c) 2010-2011, Kaori Hagihara
17  * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
18  * Copyright (c) 2012, CS Systemes d'Information, France
19  * All rights reserved.
20  *
21  * Redistribution and use in source and binary forms, with or without
22  * modification, are permitted provided that the following conditions
23  * are met:
24  * 1. Redistributions of source code must retain the above copyright
25  * notice, this list of conditions and the following disclaimer.
26  * 2. Redistributions in binary form must reproduce the above copyright
27  * notice, this list of conditions and the following disclaimer in the
28  * documentation and/or other materials provided with the distribution.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
31  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40  * POSSIBILITY OF SUCH DAMAGE.
41  */
42 #ifndef OPENJPEG_H
43 #define OPENJPEG_H
44 
45 
46 /*
47 ==========================================================
48  Compiler directives
49 ==========================================================
50 */
51 
52 /*
53 The inline keyword is supported by C99 but not by C90.
54 Most compilers implement their own version of this keyword ...
55 */
56 #ifndef INLINE
57  #if defined(_MSC_VER)
58  #define INLINE __forceinline
59  #elif defined(__GNUC__)
60  #define INLINE __inline__
61  #elif defined(__MWERKS__)
62  #define INLINE inline
63  #else
64  /* add other compilers here ... */
65  #define INLINE
66  #endif /* defined(<Compiler>) */
67 #endif /* INLINE */
68 
69 /* deprecated attribute */
70 #ifdef __GNUC__
71  #define OPJ_DEPRECATED(func) func __attribute__ ((deprecated))
72 #elif defined(_MSC_VER)
73  #define OPJ_DEPRECATED(func) __declspec(deprecated) func
74 #else
75  #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
76  #define OPJ_DEPRECATED(func) func
77 #endif
78 
79 #if defined(OPJ_STATIC) || !defined(_WIN32)
80 /* http://gcc.gnu.org/wiki/Visibility */
81 #if __GNUC__ >= 4
82 #define OPJ_API __attribute__ ((visibility ("default")))
83 #define OPJ_LOCAL __attribute__ ((visibility ("hidden")))
84 #else
85 #define OPJ_API
86 #define OPJ_LOCAL
87 #endif
88 #define OPJ_CALLCONV
89 #else
90 #define OPJ_CALLCONV __stdcall
91 /*
92 The following ifdef block is the standard way of creating macros which make exporting
93 from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
94 symbol defined on the command line. this symbol should not be defined on any project
95 that uses this DLL. This way any other project whose source files include this file see
96 OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
97 defined with this macro as being exported.
98 */
99 #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
100 #define OPJ_API __declspec(dllexport)
101 #else
102 #define OPJ_API __declspec(dllimport)
103 #endif /* OPJ_EXPORTS */
104 #endif /* !OPJ_STATIC || !_WIN32 */
105 
106 typedef int OPJ_BOOL;
107 #define OPJ_TRUE 1
108 #define OPJ_FALSE 0
109 
110 typedef char OPJ_CHAR;
111 typedef float OPJ_FLOAT32;
112 typedef double OPJ_FLOAT64;
113 typedef unsigned char OPJ_BYTE;
114 
115 #include "opj_stdint.h"
116 
117 typedef int8_t OPJ_INT8;
118 typedef uint8_t OPJ_UINT8;
119 typedef int16_t OPJ_INT16;
120 typedef uint16_t OPJ_UINT16;
121 typedef int32_t OPJ_INT32;
122 typedef uint32_t OPJ_UINT32;
123 typedef int64_t OPJ_INT64;
124 typedef uint64_t OPJ_UINT64;
125 
126 typedef int64_t OPJ_OFF_T; /* 64-bit file offset type */
127 
128 #include <stdio.h>
129 typedef size_t OPJ_SIZE_T;
130 
131 /* Avoid compile-time warning because parameter is not used */
132 #define OPJ_ARG_NOT_USED(x) (void)(x)
133 
134 /*
135 ==========================================================
136  Useful constant definitions
137 ==========================================================
138 */
139 
140 #define OPJ_PATH_LEN 4096
142 #define OPJ_J2K_MAXRLVLS 33
143 #define OPJ_J2K_MAXBANDS (3*OPJ_J2K_MAXRLVLS-2)
145 #define OPJ_J2K_DEFAULT_NB_SEGS 10
146 #define OPJ_J2K_STREAM_CHUNK_SIZE 0x100000
147 #define OPJ_J2K_DEFAULT_HEADER_SIZE 1000
148 #define OPJ_J2K_MCC_DEFAULT_NB_RECORDS 10
149 #define OPJ_J2K_MCT_DEFAULT_NB_RECORDS 10
150 
151 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
152 #define JPWL_MAX_NO_TILESPECS 16
153 #define JPWL_MAX_NO_PACKSPECS 16
154 #define JPWL_MAX_NO_MARKERS 512
155 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename"
156 #define JPWL_EXPECTED_COMPONENTS 3
157 #define JPWL_MAXIMUM_TILES 8192
158 #define JPWL_MAXIMUM_HAMMING 2
159 #define JPWL_MAXIMUM_EPB_ROOM 65450
160 /* <<UniPG */
161 
166 #define OPJ_IMG_INFO 1
167 #define OPJ_J2K_MH_INFO 2
168 #define OPJ_J2K_TH_INFO 4
169 #define OPJ_J2K_TCH_INFO 8
170 #define OPJ_J2K_MH_IND 16
171 #define OPJ_J2K_TH_IND 32
172 /*FIXME #define OPJ_J2K_CSTR_IND 48*/
173 #define OPJ_JP2_INFO 128
174 #define OPJ_JP2_IND 256
190 #define OPJ_PROFILE_NONE 0x0000
191 #define OPJ_PROFILE_0 0x0001
192 #define OPJ_PROFILE_1 0x0002
193 #define OPJ_PROFILE_PART2 0x8000
194 #define OPJ_PROFILE_CINEMA_2K 0x0003
195 #define OPJ_PROFILE_CINEMA_4K 0x0004
196 #define OPJ_PROFILE_CINEMA_S2K 0x0005
197 #define OPJ_PROFILE_CINEMA_S4K 0x0006
198 #define OPJ_PROFILE_CINEMA_LTS 0x0007
199 #define OPJ_PROFILE_BC_SINGLE 0x0100
200 #define OPJ_PROFILE_BC_MULTI 0x0200
201 #define OPJ_PROFILE_BC_MULTI_R 0x0300
202 #define OPJ_PROFILE_IMF_2K 0x0400
203 #define OPJ_PROFILE_IMF_4K 0x0401
204 #define OPJ_PROFILE_IMF_8K 0x0402
205 #define OPJ_PROFILE_IMF_2K_R 0x0403
206 #define OPJ_PROFILE_IMF_4K_R 0x0800
207 #define OPJ_PROFILE_IMF_8K_R 0x0801
212 #define OPJ_EXTENSION_NONE 0x0000
213 #define OPJ_EXTENSION_MCT 0x0100
218 #define OPJ_IS_CINEMA(v) (((v) >= OPJ_PROFILE_CINEMA_2K)&&((v) <= OPJ_PROFILE_CINEMA_S4K))
219 #define OPJ_IS_STORAGE(v) ((v) == OPJ_PROFILE_CINEMA_LTS)
220 #define OPJ_IS_BROADCAST(v) (((v) >= OPJ_PROFILE_BC_SINGLE)&&((v) <= ((OPJ_PROFILE_BC_MULTI_R) | (0x000b))))
221 #define OPJ_IS_IMF(v) (((v) >= OPJ_PROFILE_IMF_2K)&&((v) <= ((OPJ_PROFILE_IMF_8K_R) | (0x009b))))
222 #define OPJ_IS_PART2(v) ((v) & OPJ_PROFILE_PART2)
223 
227 #define OPJ_CINEMA_24_CS 1302083
228 #define OPJ_CINEMA_48_CS 651041
229 #define OPJ_CINEMA_24_COMP 1041666
230 #define OPJ_CINEMA_48_COMP 520833
232 /*
233 ==========================================================
234  enum definitions
235 ==========================================================
236 */
237 
242 typedef enum RSIZ_CAPABILITIES {
246  OPJ_MCT = 0x8100
248 
253 typedef enum CINEMA_MODE {
254  OPJ_OFF = 0,
259 
263 typedef enum PROG_ORDER {
265  OPJ_LRCP = 0,
266  OPJ_RLCP = 1,
267  OPJ_RPCL = 2,
268  OPJ_PCRL = 3,
269  OPJ_CPRL = 4
271 
275 typedef enum COLOR_SPACE {
284 
288 typedef enum CODEC_FORMAT {
296 
297 
298 /*
299 ==========================================================
300  event manager typedef definitions
301 ==========================================================
302 */
303 
309 typedef void (*opj_msg_callback) (const char *msg, void *client_data);
310 
311 /*
312 ==========================================================
313  codec typedef definitions
314 ==========================================================
315 */
316 
321 typedef struct opj_poc {
344 } opj_poc_t;
345 
349 typedef struct opj_cparameters {
353  int cp_tx0;
355  int cp_ty0;
357  int cp_tdx;
359  int cp_tdy;
369  char *cp_comment;
371  int csty;
381  float tcp_rates[100];
383  float tcp_distoratio[100];
391  int mode;
398  /* number of precinct size specifications */
399  int res_spec;
404 
412  int index_on;
429 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
459 /* <<UniPG */
460 
477  char tp_on;
479  char tp_flag;
481  char tcp_mct;
486  void * mct_data;
498 
499 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
500 
504 typedef struct opj_dparameters {
520 
531 
542 
547 
550 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
560 /* <<UniPG */
561 
562  unsigned int flags;
563 
565 
566 
570 typedef void * opj_codec_t;
571 
572 /*
573 ==========================================================
574  I/O stream typedef definitions
575 ==========================================================
576 */
577 
582 #define OPJ_STREAM_READ OPJ_TRUE
583 
584 #define OPJ_STREAM_WRITE OPJ_FALSE
585 
586 /*
587  * Callback function prototype for read function
588  */
589 typedef OPJ_SIZE_T (* opj_stream_read_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
590 
591 /*
592  * Callback function prototype for write function
593  */
594 typedef OPJ_SIZE_T (* opj_stream_write_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
595 
596 /*
597  * Callback function prototype for skip function
598  */
599 typedef OPJ_OFF_T (* opj_stream_skip_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
600 
601 /*
602  * Callback function prototype for seek function
603  */
604 typedef OPJ_BOOL (* opj_stream_seek_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
605 
606 /*
607  * Callback function prototype for free user data function
608  */
609 typedef void (* opj_stream_free_user_data_fn) (void * p_user_data) ;
610 
611 /*
612  * JPEG2000 Stream.
613  */
614 typedef void * opj_stream_t;
615 
616 /*
617 ==========================================================
618  image typedef definitions
619 ==========================================================
620 */
621 
625 typedef struct opj_image_comp {
653 
657 typedef struct opj_image {
676 } opj_image_t;
677 
678 
682 typedef struct opj_image_comptparm {
702 
703 
704 /*
705 ==========================================================
706  Information on the JPEG 2000 codestream
707 ==========================================================
708 */
709 /* QUITE EXPERIMENTAL FOR THE MOMENT */
710 
714 typedef struct opj_packet_info {
722  double disto;
724 
725 
726 /* UniPG>> */
730 typedef struct opj_marker_info {
732  unsigned short int type;
736  int len;
738 /* <<UniPG */
739 
743 typedef struct opj_tp_info {
754 } opj_tp_info_t;
755 
759 typedef struct opj_tile_info {
761  double *thresh;
763  int tileno;
769  int end_pos;
771  int pw[33];
773  int ph[33];
775  int pdx[33];
777  int pdy[33];
781  int numpix;
783  double distotile;
785  int marknum;
791  int num_tps;
795 
799 typedef struct opj_codestream_info {
801  double D_max;
803  int packno;
807  int image_w;
809  int image_h;
813  int tile_x;
815  int tile_y;
817  int tile_Ox;
819  int tile_Oy;
821  int tw;
823  int th;
825  int numcomps;
830 /* UniPG>> */
832  int marknum;
837 /* <<UniPG */
847 
848 /* <----------------------------------------------------------- */
849 /* new output managment of the codestream information and index */
850 
854 typedef struct opj_tccp_info
855 {
884 }
886 
890 typedef struct opj_tile_v2_info {
891 
893  int tileno;
902 
905 
907 
911 typedef struct opj_codestream_info_v2 {
912  /* Tile info */
925 
928 
931 
933  opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */
934 
936 
937 
941 typedef struct opj_tp_index {
948 
950 
954 typedef struct opj_tile_index {
957 
966 
967  /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
974  /* <<UniPG */
975 
980 
982 
986 typedef struct opj_codestream_index {
991 
994 
995 /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
1002 /* <<UniPG */
1003 
1007  opj_tile_index_t *tile_index; /* FIXME not used for the moment */
1008 
1010 /* -----------------------------------------------------------> */
1011 
1012 /*
1013 ==========================================================
1014  Metadata from the JP2file
1015 ==========================================================
1016 */
1017 
1022 typedef struct opj_jp2_metadata {
1025 
1027 
1032 typedef struct opj_jp2_index {
1035 
1036 } opj_jp2_index_t;
1037 
1038 
1039 #ifdef __cplusplus
1040 extern "C" {
1041 #endif
1042 
1043 
1044 /*
1045 ==========================================================
1046  openjpeg version
1047 ==========================================================
1048 */
1049 
1050 /* Get the version of the openjpeg library*/
1051 OPJ_API const char * OPJ_CALLCONV opj_version(void);
1052 
1053 /*
1054 ==========================================================
1055  image functions definitions
1056 ==========================================================
1057 */
1058 
1068 
1075 
1086 
1087 /*
1088 ==========================================================
1089  stream functions definitions
1090 ==========================================================
1091 */
1092 
1101 
1111 
1119 
1126 
1133 
1140 
1147 
1154 OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data, opj_stream_free_user_data_fn p_function);
1155 
1163 
1169 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (const char *fname, OPJ_BOOL p_is_read_stream);
1170 
1177  OPJ_SIZE_T p_buffer_size,
1178  OPJ_BOOL p_is_read_stream);
1179 
1180 /*
1181 ==========================================================
1182  event manager functions definitions
1183 ==========================================================
1184 */
1192  opj_msg_callback p_callback,
1193  void * p_user_data);
1201  opj_msg_callback p_callback,
1202  void * p_user_data);
1210  opj_msg_callback p_callback,
1211  void * p_user_data);
1212 
1213 /*
1214 ==========================================================
1215  codec functions definitions
1216 ==========================================================
1217 */
1218 
1226 
1233 
1240  opj_stream_t *p_stream);
1241 
1242 
1248 
1259  opj_dparameters_t *parameters );
1260 
1271  opj_codec_t *p_codec,
1272  opj_image_t **p_image);
1273 
1287  opj_image_t* p_image,
1288  OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
1289  OPJ_INT32 p_end_x, OPJ_INT32 p_end_y );
1290 
1300  opj_stream_t *p_stream,
1301  opj_image_t *p_image);
1302 
1314  opj_stream_t *p_stream,
1315  opj_image_t *p_image,
1316  OPJ_UINT32 tile_index);
1317 
1326 
1340  OPJ_UINT32 p_tile_index,
1341  OPJ_BYTE * p_data,
1342  OPJ_UINT32 p_data_size,
1343  opj_stream_t *p_stream );
1344 
1367  opj_stream_t * p_stream,
1368  OPJ_UINT32 * p_tile_index,
1369  OPJ_UINT32 * p_data_size,
1370  OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
1371  OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
1372  OPJ_UINT32 * p_nb_comps,
1373  OPJ_BOOL * p_should_go_on );
1374 
1388  OPJ_UINT32 p_tile_index,
1389  OPJ_BYTE * p_data,
1390  OPJ_UINT32 p_data_size,
1391  opj_stream_t *p_stream );
1392 
1393 /* COMPRESSION FUNCTIONS*/
1394 
1401 
1424 
1432  opj_cparameters_t *parameters,
1433  opj_image_t *image);
1434 
1442  opj_image_t * p_image,
1443  opj_stream_t *p_stream);
1444 
1451  opj_stream_t *p_stream);
1452 
1461  opj_stream_t *p_stream);
1462 /*
1463 ==========================================================
1464  codec output functions definitions
1465 ==========================================================
1466 */
1467 /* EXPERIMENTAL FUNCTIONS FOR NOW, USED ONLY IN J2K_DUMP*/
1468 
1474 
1475 
1485  OPJ_INT32 info_flag,
1486  FILE* output_stream);
1487 
1497 
1507 
1509 
1510 
1520 
1530 
1531 
1532 /*
1533 ==========================================================
1534  MCT functions
1535 ==========================================================
1536 */
1537 
1549  OPJ_FLOAT32 * pEncodingMatrix,
1550  OPJ_INT32 * p_dc_shift,
1551  OPJ_UINT32 pNbComp);
1552 
1553 
1554 
1555 #ifdef __cplusplus
1556 }
1557 #endif
1558 
1559 #endif /* OPENJPEG_H */