OpenJPEG  2.0.0
openjpeg.h
Go to the documentation of this file.
1  /*
2  * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
3  * Copyright (c) 2002-2007, Professor Benoit Macq
4  * Copyright (c) 2001-2003, David Janssens
5  * Copyright (c) 2002-2003, Yannick Verschueren
6  * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
7  * Copyright (c) 2005, Herve Drolon, FreeImage Team
8  * Copyright (c) 2006-2007, Parvatha Elangovan
9  * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
10  * Copyright (c) 2010-2011, Kaori Hagihara
11  * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
12  * Copyright (c) 2012, CS Systemes d'Information, France
13  * All rights reserved.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  * notice, this list of conditions and the following disclaimer.
20  * 2. Redistributions in binary form must reproduce the above copyright
21  * notice, this list of conditions and the following disclaimer in the
22  * documentation and/or other materials provided with the distribution.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
25  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 #ifndef OPENJPEG_H
37 #define OPENJPEG_H
38 
39 
40 /*
41 ==========================================================
42  Compiler directives
43 ==========================================================
44 */
45 
46 /* deprecated attribute */
47 #ifdef __GNUC__
48  #define OPJ_DEPRECATED(func) func __attribute__ ((deprecated))
49 #elif defined(_MSC_VER)
50  #define OPJ_DEPRECATED(func) __declspec(deprecated) func
51 #else
52  #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
53  #define OPJ_DEPRECATED(func) func
54 #endif
55 
56 #if defined(OPJ_STATIC) || !defined(_WIN32)
57 /* http://gcc.gnu.org/wiki/Visibility */
58 #if __GNUC__ >= 4
59 #define OPJ_API __attribute__ ((visibility ("default")))
60 #define OPJ_LOCAL __attribute__ ((visibility ("hidden")))
61 #else
62 #define OPJ_API
63 #define OPJ_LOCAL
64 #endif
65 #define OPJ_CALLCONV
66 #else
67 #define OPJ_CALLCONV __stdcall
68 /*
69 The following ifdef block is the standard way of creating macros which make exporting
70 from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
71 symbol defined on the command line. this symbol should not be defined on any project
72 that uses this DLL. This way any other project whose source files include this file see
73 OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
74 defined with this macro as being exported.
75 */
76 #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
77 #define OPJ_API __declspec(dllexport)
78 #else
79 #define OPJ_API __declspec(dllimport)
80 #endif /* OPJ_EXPORTS */
81 #endif /* !OPJ_STATIC || !_WIN32 */
82 
83 typedef int OPJ_BOOL;
84 #define OPJ_TRUE 1
85 #define OPJ_FALSE 0
86 
87 typedef char OPJ_CHAR;
88 typedef float OPJ_FLOAT32;
89 typedef double OPJ_FLOAT64;
90 typedef unsigned char OPJ_BYTE;
91 
92 #include "opj_stdint.h"
93 
94 typedef int8_t OPJ_INT8;
95 typedef uint8_t OPJ_UINT8;
96 typedef int16_t OPJ_INT16;
97 typedef uint16_t OPJ_UINT16;
98 typedef int32_t OPJ_INT32;
99 typedef uint32_t OPJ_UINT32;
100 typedef int64_t OPJ_INT64;
101 typedef uint64_t OPJ_UINT64;
102 
103 typedef int64_t OPJ_OFF_T; /* 64-bit file offset type */
104 
105 #include <stdio.h>
106 typedef size_t OPJ_SIZE_T;
107 
108 /* Avoid compile-time warning because parameter is not used */
109 #define OPJ_ARG_NOT_USED(x) (void)(x)
110 
111 /*
112 ==========================================================
113  Useful constant definitions
114 ==========================================================
115 */
116 
117 #define OPJ_PATH_LEN 4096
119 #define OPJ_J2K_MAXRLVLS 33
120 #define OPJ_J2K_MAXBANDS (3*OPJ_J2K_MAXRLVLS-2)
122 #define OPJ_J2K_DEFAULT_NB_SEGS 10
123 #define OPJ_J2K_STREAM_CHUNK_SIZE 0x100000
124 #define OPJ_J2K_DEFAULT_HEADER_SIZE 1000
125 #define OPJ_J2K_MCC_DEFAULT_NB_RECORDS 10
126 #define OPJ_J2K_MCT_DEFAULT_NB_RECORDS 10
127 
128 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
129 #define JPWL_MAX_NO_TILESPECS 16
130 #define JPWL_MAX_NO_PACKSPECS 16
131 #define JPWL_MAX_NO_MARKERS 512
132 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename"
133 #define JPWL_EXPECTED_COMPONENTS 3
134 #define JPWL_MAXIMUM_TILES 8192
135 #define JPWL_MAXIMUM_HAMMING 2
136 #define JPWL_MAXIMUM_EPB_ROOM 65450
137 /* <<UniPG */
138 
143 #define OPJ_IMG_INFO 1
144 #define OPJ_J2K_MH_INFO 2
145 #define OPJ_J2K_TH_INFO 4
146 /*FIXME #define OPJ_J2K_CSTR_INFO 6*/
147 #define OPJ_J2K_MH_IND 16
148 #define OPJ_J2K_TH_IND 32
149 /*FIXME #define OPJ_J2K_CSTR_IND 48*/
150 #define OPJ_JP2_INFO 128
151 #define OPJ_JP2_IND 256
154 /*
155 ==========================================================
156  enum definitions
157 ==========================================================
158 */
159 
162 typedef enum RSIZ_CAPABILITIES {
166  OPJ_MCT = 0x8100
168 
172 typedef enum CINEMA_MODE {
173  OPJ_OFF = 0,
178 
182 typedef enum PROG_ORDER {
184  OPJ_LRCP = 0,
185  OPJ_RLCP = 1,
186  OPJ_RPCL = 2,
187  OPJ_PCRL = 3,
188  OPJ_CPRL = 4
190 
194 typedef enum COLOR_SPACE {
201 
205 typedef enum CODEC_FORMAT {
211 
212 
213 /*
214 ==========================================================
215  event manager typedef definitions
216 ==========================================================
217 */
218 
224 typedef void (*opj_msg_callback) (const char *msg, void *client_data);
225 
226 /*
227 ==========================================================
228  codec typedef definitions
229 ==========================================================
230 */
231 
236 typedef struct opj_poc {
259 } opj_poc_t;
260 
264 typedef struct opj_cparameters {
268  int cp_tx0;
270  int cp_ty0;
272  int cp_tdx;
274  int cp_tdy;
284  char *cp_comment;
286  int csty;
296  float tcp_rates[100];
298  float tcp_distoratio[100];
306  int mode;
313  /* number of precinct size specifications */
314  int res_spec;
319 
327  int index_on;
344 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
374 /* <<UniPG */
375 
383  char tp_on;
385  char tp_flag;
387  char tcp_mct;
392  void * mct_data;
394 
395 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
396 
400 typedef struct opj_dparameters {
416 
427 
438 
443 
446 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
456 /* <<UniPG */
457 
458  unsigned int flags;
459 
461 
462 
466 typedef void * opj_codec_t;
467 
468 /*
469 ==========================================================
470  I/O stream typedef definitions
471 ==========================================================
472 */
473 
478 #define OPJ_STREAM_READ OPJ_TRUE
479 
480 #define OPJ_STREAM_WRITE OPJ_FALSE
481 
482 /*
483  * Callback function prototype for read function
484  */
485 typedef OPJ_SIZE_T (* opj_stream_read_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
486 
487 /*
488  * Callback function prototype for write function
489  */
490 typedef OPJ_SIZE_T (* opj_stream_write_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
491 
492 /*
493  * Callback function prototype for skip function
494  */
495 typedef OPJ_OFF_T (* opj_stream_skip_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
496 
497 /*
498  * Callback function prototype for seek function
499  */
500 typedef OPJ_BOOL (* opj_stream_seek_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
501 
502 /*
503  * JPEG2000 Stream.
504  */
505 typedef void * opj_stream_t;
506 
507 /*
508 ==========================================================
509  image typedef definitions
510 ==========================================================
511 */
512 
516 typedef struct opj_image_comp {
542 
546 typedef struct opj_image {
565 } opj_image_t;
566 
567 
571 typedef struct opj_image_comptparm {
591 
592 
593 /*
594 ==========================================================
595  Information on the JPEG 2000 codestream
596 ==========================================================
597 */
598 /* QUITE EXPERIMENTAL FOR THE MOMENT */
599 
603 typedef struct opj_packet_info {
611  double disto;
613 
614 
615 /* UniPG>> */
619 typedef struct opj_marker_info {
621  unsigned short int type;
625  int len;
627 /* <<UniPG */
628 
632 typedef struct opj_tp_info {
643 } opj_tp_info_t;
644 
648 typedef struct opj_tile_info {
650  double *thresh;
652  int tileno;
658  int end_pos;
660  int pw[33];
662  int ph[33];
664  int pdx[33];
666  int pdy[33];
670  int numpix;
672  double distotile;
674  int marknum;
680  int num_tps;
684 
688 typedef struct opj_codestream_info {
690  double D_max;
692  int packno;
696  int image_w;
698  int image_h;
702  int tile_x;
704  int tile_y;
706  int tile_Ox;
708  int tile_Oy;
710  int tw;
712  int th;
714  int numcomps;
719 /* UniPG>> */
721  int marknum;
726 /* <<UniPG */
736 
737 /* <----------------------------------------------------------- */
738 /* new output managment of the codestream information and index */
739 
743 typedef struct opj_tccp_info
744 {
773 }
775 
779 typedef struct opj_tile_v2_info {
780 
782  int tileno;
791 
794 
796 
800 typedef struct opj_codestream_info_v2 {
801  /* Tile info */
814 
817 
820 
822  opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */
823 
825 
826 
830 typedef struct opj_tp_index {
837 
839 
843 typedef struct opj_tile_index {
846 
855 
856  /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
863  /* <<UniPG */
864 
869 
871 
875 typedef struct opj_codestream_index {
880 
883 
884 /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
891 /* <<UniPG */
892 
896  opj_tile_index_t *tile_index; /* FIXME not used for the moment */
897 
899 /* -----------------------------------------------------------> */
900 
901 /*
902 ==========================================================
903  Metadata from the JP2file
904 ==========================================================
905 */
906 
911 typedef struct opj_jp2_metadata {
914 
916 
921 typedef struct opj_jp2_index {
924 
926 
927 
928 #ifdef __cplusplus
929 extern "C" {
930 #endif
931 
932 
933 /*
934 ==========================================================
935  openjpeg version
936 ==========================================================
937 */
938 
939 /* Get the version of the openjpeg library*/
940 OPJ_API const char * OPJ_CALLCONV opj_version(void);
941 
942 /*
943 ==========================================================
944  image functions definitions
945 ==========================================================
946 */
947 
957 
964 
975 
976 /*
977 ==========================================================
978  stream functions definitions
979 ==========================================================
980 */
981 
990 
1000 
1008 
1016 
1023 
1030 
1037 
1044 
1050 OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data);
1051 
1059 
1067 
1074 
1082  OPJ_SIZE_T p_buffer_size,
1083  OPJ_BOOL p_is_read_stream));
1084 
1091  OPJ_SIZE_T p_buffer_size,
1092  OPJ_BOOL p_is_read_stream);
1093 
1094 /*
1095 ==========================================================
1096  event manager functions definitions
1097 ==========================================================
1098 */
1106  opj_msg_callback p_callback,
1107  void * p_user_data);
1115  opj_msg_callback p_callback,
1116  void * p_user_data);
1124  opj_msg_callback p_callback,
1125  void * p_user_data);
1126 
1127 /*
1128 ==========================================================
1129  codec functions definitions
1130 ==========================================================
1131 */
1132 
1140 
1147 
1154  opj_stream_t *p_stream);
1155 
1156 
1162 
1173  opj_dparameters_t *parameters );
1174 
1185  opj_codec_t *p_codec,
1186  opj_image_t **p_image);
1187 
1201  opj_image_t* p_image,
1202  OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
1203  OPJ_INT32 p_end_x, OPJ_INT32 p_end_y );
1204 
1214  opj_stream_t *p_stream,
1215  opj_image_t *p_image);
1216 
1228  opj_stream_t *p_stream,
1229  opj_image_t *p_image,
1230  OPJ_UINT32 tile_index);
1231 
1240 
1254  OPJ_UINT32 p_tile_index,
1255  OPJ_BYTE * p_data,
1256  OPJ_UINT32 p_data_size,
1257  opj_stream_t *p_stream );
1258 
1281  opj_stream_t * p_stream,
1282  OPJ_UINT32 * p_tile_index,
1283  OPJ_UINT32 * p_data_size,
1284  OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
1285  OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
1286  OPJ_UINT32 * p_nb_comps,
1287  OPJ_BOOL * p_should_go_on );
1288 
1302  OPJ_UINT32 p_tile_index,
1303  OPJ_BYTE * p_data,
1304  OPJ_UINT32 p_data_size,
1305  opj_stream_t *p_stream );
1306 
1307 /* COMPRESSION FUNCTIONS*/
1308 
1315 
1338 
1346  opj_cparameters_t *parameters,
1347  opj_image_t *image);
1348 
1356  opj_image_t * p_image,
1357  opj_stream_t *p_stream);
1358 
1365  opj_stream_t *p_stream);
1366 
1375  opj_stream_t *p_stream);
1376 /*
1377 ==========================================================
1378  codec output functions definitions
1379 ==========================================================
1380 */
1381 /* EXPERIMENTAL FUNCTIONS FOR NOW, USED ONLY IN J2K_DUMP*/
1382 
1388 
1389 
1399  OPJ_INT32 info_flag,
1400  FILE* output_stream);
1401 
1411 
1421 
1423 
1424 
1434 
1444 
1445 
1446 /*
1447 ==========================================================
1448  MCT functions
1449 ==========================================================
1450 */
1451 
1463  OPJ_FLOAT32 * pEncodingMatrix,
1464  OPJ_INT32 * p_dc_shift,
1465  OPJ_UINT32 pNbComp);
1466 
1467 
1468 
1469 #ifdef __cplusplus
1470 }
1471 #endif
1472 
1473 #endif /* OPENJPEG_H */