OpenJPEG  2.3.1
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 # if defined(OPJ_STATIC) /* static library uses "hidden" */
83 # define OPJ_API __attribute__ ((visibility ("hidden")))
84 # else
85 # define OPJ_API __attribute__ ((visibility ("default")))
86 # endif
87 # define OPJ_LOCAL __attribute__ ((visibility ("hidden")))
88 # else
89 # define OPJ_API
90 # define OPJ_LOCAL
91 # endif
92 # define OPJ_CALLCONV
93 #else
94 # define OPJ_CALLCONV __stdcall
95 /*
96 The following ifdef block is the standard way of creating macros which make exporting
97 from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
98 symbol defined on the command line. this symbol should not be defined on any project
99 that uses this DLL. This way any other project whose source files include this file see
100 OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols
101 defined with this macro as being exported.
102 */
103 # if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
104 # define OPJ_API __declspec(dllexport)
105 # else
106 # define OPJ_API __declspec(dllimport)
107 # endif /* OPJ_EXPORTS */
108 #endif /* !OPJ_STATIC || !_WIN32 */
109 
110 typedef int OPJ_BOOL;
111 #define OPJ_TRUE 1
112 #define OPJ_FALSE 0
113 
114 typedef char OPJ_CHAR;
115 typedef float OPJ_FLOAT32;
116 typedef double OPJ_FLOAT64;
117 typedef unsigned char OPJ_BYTE;
118 
119 #include "opj_stdint.h"
120 
121 typedef int8_t OPJ_INT8;
122 typedef uint8_t OPJ_UINT8;
123 typedef int16_t OPJ_INT16;
124 typedef uint16_t OPJ_UINT16;
125 typedef int32_t OPJ_INT32;
126 typedef uint32_t OPJ_UINT32;
127 typedef int64_t OPJ_INT64;
128 typedef uint64_t OPJ_UINT64;
129 
130 typedef int64_t OPJ_OFF_T; /* 64-bit file offset type */
131 
132 #include <stdio.h>
133 typedef size_t OPJ_SIZE_T;
134 
135 /* Avoid compile-time warning because parameter is not used */
136 #define OPJ_ARG_NOT_USED(x) (void)(x)
137 
138 /*
139 ==========================================================
140  Useful constant definitions
141 ==========================================================
142 */
143 
144 #define OPJ_PATH_LEN 4096
146 #define OPJ_J2K_MAXRLVLS 33
147 #define OPJ_J2K_MAXBANDS (3*OPJ_J2K_MAXRLVLS-2)
149 #define OPJ_J2K_DEFAULT_NB_SEGS 10
150 #define OPJ_J2K_STREAM_CHUNK_SIZE 0x100000
151 #define OPJ_J2K_DEFAULT_HEADER_SIZE 1000
152 #define OPJ_J2K_MCC_DEFAULT_NB_RECORDS 10
153 #define OPJ_J2K_MCT_DEFAULT_NB_RECORDS 10
154 
155 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
156 #define JPWL_MAX_NO_TILESPECS 16
157 #define JPWL_MAX_NO_PACKSPECS 16
158 #define JPWL_MAX_NO_MARKERS 512
159 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename"
160 #define JPWL_EXPECTED_COMPONENTS 3
161 #define JPWL_MAXIMUM_TILES 8192
162 #define JPWL_MAXIMUM_HAMMING 2
163 #define JPWL_MAXIMUM_EPB_ROOM 65450
164 /* <<UniPG */
165 
170 #define OPJ_IMG_INFO 1
171 #define OPJ_J2K_MH_INFO 2
172 #define OPJ_J2K_TH_INFO 4
173 #define OPJ_J2K_TCH_INFO 8
174 #define OPJ_J2K_MH_IND 16
175 #define OPJ_J2K_TH_IND 32
176 /*FIXME #define OPJ_J2K_CSTR_IND 48*/
177 #define OPJ_JP2_INFO 128
178 #define OPJ_JP2_IND 256
194 #define OPJ_PROFILE_NONE 0x0000
195 #define OPJ_PROFILE_0 0x0001
196 #define OPJ_PROFILE_1 0x0002
197 #define OPJ_PROFILE_PART2 0x8000
198 #define OPJ_PROFILE_CINEMA_2K 0x0003
199 #define OPJ_PROFILE_CINEMA_4K 0x0004
200 #define OPJ_PROFILE_CINEMA_S2K 0x0005
201 #define OPJ_PROFILE_CINEMA_S4K 0x0006
202 #define OPJ_PROFILE_CINEMA_LTS 0x0007
203 #define OPJ_PROFILE_BC_SINGLE 0x0100
204 #define OPJ_PROFILE_BC_MULTI 0x0200
205 #define OPJ_PROFILE_BC_MULTI_R 0x0300
206 #define OPJ_PROFILE_IMF_2K 0x0400
207 #define OPJ_PROFILE_IMF_4K 0x0401
208 #define OPJ_PROFILE_IMF_8K 0x0402
209 #define OPJ_PROFILE_IMF_2K_R 0x0403
210 #define OPJ_PROFILE_IMF_4K_R 0x0800
211 #define OPJ_PROFILE_IMF_8K_R 0x0801
216 #define OPJ_EXTENSION_NONE 0x0000
217 #define OPJ_EXTENSION_MCT 0x0100
222 #define OPJ_IS_CINEMA(v) (((v) >= OPJ_PROFILE_CINEMA_2K)&&((v) <= OPJ_PROFILE_CINEMA_S4K))
223 #define OPJ_IS_STORAGE(v) ((v) == OPJ_PROFILE_CINEMA_LTS)
224 #define OPJ_IS_BROADCAST(v) (((v) >= OPJ_PROFILE_BC_SINGLE)&&((v) <= ((OPJ_PROFILE_BC_MULTI_R) | (0x000b))))
225 #define OPJ_IS_IMF(v) (((v) >= OPJ_PROFILE_IMF_2K)&&((v) <= ((OPJ_PROFILE_IMF_8K_R) | (0x009b))))
226 #define OPJ_IS_PART2(v) ((v) & OPJ_PROFILE_PART2)
227 
231 #define OPJ_CINEMA_24_CS 1302083
232 #define OPJ_CINEMA_48_CS 651041
233 #define OPJ_CINEMA_24_COMP 1041666
234 #define OPJ_CINEMA_48_COMP 520833
236 /*
237 ==========================================================
238  enum definitions
239 ==========================================================
240 */
241 
246 typedef enum RSIZ_CAPABILITIES {
250  OPJ_MCT = 0x8100
252 
257 typedef enum CINEMA_MODE {
258  OPJ_OFF = 0,
263 
267 typedef enum PROG_ORDER {
269  OPJ_LRCP = 0,
270  OPJ_RLCP = 1,
271  OPJ_RPCL = 2,
272  OPJ_PCRL = 3,
273  OPJ_CPRL = 4
275 
279 typedef enum COLOR_SPACE {
288 
292 typedef enum CODEC_FORMAT {
300 
301 
302 /*
303 ==========================================================
304  event manager typedef definitions
305 ==========================================================
306 */
307 
313 typedef void (*opj_msg_callback)(const char *msg, void *client_data);
314 
315 /*
316 ==========================================================
317  codec typedef definitions
318 ==========================================================
319 */
320 
325 typedef struct opj_poc {
348 } opj_poc_t;
349 
353 typedef struct opj_cparameters {
357  int cp_tx0;
359  int cp_ty0;
361  int cp_tdx;
363  int cp_tdy;
373  char *cp_comment;
375  int csty;
387  float tcp_rates[100];
390  float tcp_distoratio[100];
398  int mode;
405  /* number of precinct size specifications */
406  int res_spec;
411 
419  int index_on;
436  /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
466  /* <<UniPG */
467 
484  char tp_on;
486  char tp_flag;
488  char tcp_mct;
493  void * mct_data;
505 
506 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
507 #define OPJ_DPARAMETERS_DUMP_FLAG 0x0002
508 
512 typedef struct opj_dparameters {
528 
539 
550 
555 
558  /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
568  /* <<UniPG */
569 
570  unsigned int flags;
571 
573 
574 
578 typedef void * opj_codec_t;
579 
580 /*
581 ==========================================================
582  I/O stream typedef definitions
583 ==========================================================
584 */
585 
590 #define OPJ_STREAM_READ OPJ_TRUE
591 
592 #define OPJ_STREAM_WRITE OPJ_FALSE
593 
594 /*
595  * Callback function prototype for read function
596  */
597 typedef OPJ_SIZE_T(* opj_stream_read_fn)(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
598  void * p_user_data) ;
599 
600 /*
601  * Callback function prototype for write function
602  */
603 typedef OPJ_SIZE_T(* opj_stream_write_fn)(void * p_buffer,
604  OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
605 
606 /*
607  * Callback function prototype for skip function
608  */
609 typedef OPJ_OFF_T(* opj_stream_skip_fn)(OPJ_OFF_T p_nb_bytes,
610  void * p_user_data) ;
611 
612 /*
613  * Callback function prototype for seek function
614  */
615 typedef OPJ_BOOL(* opj_stream_seek_fn)(OPJ_OFF_T p_nb_bytes,
616  void * p_user_data) ;
617 
618 /*
619  * Callback function prototype for free user data function
620  */
621 typedef void (* opj_stream_free_user_data_fn)(void * p_user_data) ;
622 
623 /*
624  * JPEG2000 Stream.
625  */
626 typedef void * opj_stream_t;
627 
628 /*
629 ==========================================================
630  image typedef definitions
631 ==========================================================
632 */
633 
637 typedef struct opj_image_comp {
665 
669 typedef struct opj_image {
688 } opj_image_t;
689 
690 
694 typedef struct opj_image_comptparm {
714 
715 
716 /*
717 ==========================================================
718  Information on the JPEG 2000 codestream
719 ==========================================================
720 */
721 /* QUITE EXPERIMENTAL FOR THE MOMENT */
722 
726 typedef struct opj_packet_info {
734  double disto;
736 
737 
738 /* UniPG>> */
742 typedef struct opj_marker_info {
744  unsigned short int type;
748  int len;
750 /* <<UniPG */
751 
755 typedef struct opj_tp_info {
766 } opj_tp_info_t;
767 
771 typedef struct opj_tile_info {
773  double *thresh;
775  int tileno;
781  int end_pos;
783  int pw[33];
785  int ph[33];
787  int pdx[33];
789  int pdy[33];
793  int numpix;
795  double distotile;
797  int marknum;
803  int num_tps;
807 
811 typedef struct opj_codestream_info {
813  double D_max;
815  int packno;
819  int image_w;
821  int image_h;
825  int tile_x;
827  int tile_y;
829  int tile_Ox;
831  int tile_Oy;
833  int tw;
835  int th;
837  int numcomps;
842  /* UniPG>> */
844  int marknum;
849  /* <<UniPG */
859 
860 /* <----------------------------------------------------------- */
861 /* new output management of the codestream information and index */
862 
866 typedef struct opj_tccp_info {
895 }
897 
901 typedef struct opj_tile_v2_info {
902 
904  int tileno;
913 
916 
918 
922 typedef struct opj_codestream_info_v2 {
923  /* Tile info */
936 
939 
942 
944  opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */
945 
947 
948 
952 typedef struct opj_tp_index {
959 
961 
965 typedef struct opj_tile_index {
968 
977 
978  /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
985  /* <<UniPG */
986 
991 
993 
997 typedef struct opj_codestream_index {
1002 
1005 
1006  /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
1013  /* <<UniPG */
1014 
1018  opj_tile_index_t *tile_index; /* FIXME not used for the moment */
1019 
1021 /* -----------------------------------------------------------> */
1022 
1023 /*
1024 ==========================================================
1025  Metadata from the JP2file
1026 ==========================================================
1027 */
1028 
1033 typedef struct opj_jp2_metadata {
1036 
1038 
1043 typedef struct opj_jp2_index {
1046 
1047 } opj_jp2_index_t;
1048 
1049 
1050 #ifdef __cplusplus
1051 extern "C" {
1052 #endif
1053 
1054 
1055 /*
1056 ==========================================================
1057  openjpeg version
1058 ==========================================================
1059 */
1060 
1061 /* Get the version of the openjpeg library*/
1062 OPJ_API const char * OPJ_CALLCONV opj_version(void);
1063 
1064 /*
1065 ==========================================================
1066  image functions definitions
1067 ==========================================================
1068 */
1069 
1079  opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
1080 
1087 
1098  opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
1099 
1110 
1119 OPJ_API void OPJ_CALLCONV opj_image_data_free(void* ptr);
1120 
1121 /*
1122 ==========================================================
1123  stream functions definitions
1124 ==========================================================
1125 */
1126 
1135  OPJ_BOOL p_is_input);
1136 
1146  OPJ_BOOL p_is_input);
1147 
1155 
1162  opj_stream_read_fn p_function);
1163 
1170  opj_stream_write_fn p_function);
1171 
1178  opj_stream_skip_fn p_function);
1179 
1187  opj_stream_seek_fn p_function);
1188 
1196  void * p_data, opj_stream_free_user_data_fn p_function);
1197 
1205  opj_stream_t* p_stream, OPJ_UINT64 data_length);
1206 
1213  const char *fname, OPJ_BOOL p_is_read_stream);
1214 
1221  const char *fname,
1222  OPJ_SIZE_T p_buffer_size,
1223  OPJ_BOOL p_is_read_stream);
1224 
1225 /*
1226 ==========================================================
1227  event manager functions definitions
1228 ==========================================================
1229 */
1237  opj_msg_callback p_callback,
1238  void * p_user_data);
1246  opj_msg_callback p_callback,
1247  void * p_user_data);
1255  opj_msg_callback p_callback,
1256  void * p_user_data);
1257 
1258 /*
1259 ==========================================================
1260  codec functions definitions
1261 ==========================================================
1262 */
1263 
1271  OPJ_CODEC_FORMAT format);
1272 
1279 
1286  opj_stream_t *p_stream);
1287 
1288 
1294  opj_dparameters_t *parameters);
1295 
1306  opj_dparameters_t *parameters);
1307 
1328  int num_threads);
1329 
1340  opj_codec_t *p_codec,
1341  opj_image_t **p_image);
1342 
1343 
1370  OPJ_UINT32 numcomps,
1371  const OPJ_UINT32* comps_indices,
1372  OPJ_BOOL apply_color_transforms);
1373 
1397  opj_image_t* p_image,
1398  OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
1399  OPJ_INT32 p_end_x, OPJ_INT32 p_end_y);
1400 
1410  opj_stream_t *p_stream,
1411  opj_image_t *p_image);
1412 
1424  opj_stream_t *p_stream,
1425  opj_image_t *p_image,
1426  OPJ_UINT32 tile_index);
1427 
1436  opj_codec_t *p_codec, OPJ_UINT32 res_factor);
1437 
1451  OPJ_UINT32 p_tile_index,
1452  OPJ_BYTE * p_data,
1453  OPJ_UINT32 p_data_size,
1454  opj_stream_t *p_stream);
1455 
1478  opj_stream_t * p_stream,
1479  OPJ_UINT32 * p_tile_index,
1480  OPJ_UINT32 * p_data_size,
1481  OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
1482  OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
1483  OPJ_UINT32 * p_nb_comps,
1484  OPJ_BOOL * p_should_go_on);
1485 
1501  OPJ_UINT32 p_tile_index,
1502  OPJ_BYTE * p_data,
1503  OPJ_UINT32 p_data_size,
1504  opj_stream_t *p_stream);
1505 
1506 /* COMPRESSION FUNCTIONS*/
1507 
1514 
1537  opj_cparameters_t *parameters);
1538 
1546  opj_cparameters_t *parameters,
1547  opj_image_t *image);
1548 
1556  opj_image_t * p_image,
1557  opj_stream_t *p_stream);
1558 
1565  opj_stream_t *p_stream);
1566 
1575  opj_stream_t *p_stream);
1576 /*
1577 ==========================================================
1578  codec output functions definitions
1579 ==========================================================
1580 */
1581 /* EXPERIMENTAL FUNCTIONS FOR NOW, USED ONLY IN J2K_DUMP*/
1582 
1588  **cstr_info);
1589 
1590 
1600  OPJ_INT32 info_flag,
1601  FILE* output_stream);
1602 
1612  opj_codec_t *p_codec);
1613 
1623  opj_codec_t *p_codec);
1624 
1626  **p_cstr_index);
1627 
1628 
1638  opj_codec_t *p_codec);
1639 
1649 
1650 
1651 /*
1652 ==========================================================
1653  MCT functions
1654 ==========================================================
1655 */
1656 
1668  OPJ_FLOAT32 * pEncodingMatrix,
1669  OPJ_INT32 * p_dc_shift,
1670  OPJ_UINT32 pNbComp);
1671 
1672 /*
1673 ==========================================================
1674  Thread functions
1675 ==========================================================
1676 */
1677 
1682 
1685 
1686 
1687 #ifdef __cplusplus
1688 }
1689 #endif
1690 
1691 #endif /* OPENJPEG_H */