OpenJPEG  1.5.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) 2010-2011, Kaori Hagihara
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in the
19  * documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 #ifndef OPENJPEG_H
34 #define OPENJPEG_H
35 
36 
37 /*
38 ==========================================================
39  Compiler directives
40 ==========================================================
41 */
42 
43 #if defined(OPJ_STATIC) || !defined(_WIN32)
44 #define OPJ_API
45 #define OPJ_CALLCONV
46 #else
47 #define OPJ_CALLCONV __stdcall
48 /*
49 The following ifdef block is the standard way of creating macros which make exporting
50 from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
51 symbol defined on the command line. this symbol should not be defined on any project
52 that uses this DLL. This way any other project whose source files include this file see
53 OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
54 defined with this macro as being exported.
55 */
56 #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
57 #define OPJ_API __declspec(dllexport)
58 #else
59 #define OPJ_API __declspec(dllimport)
60 #endif /* OPJ_EXPORTS */
61 #endif /* !OPJ_STATIC || !_WIN32 */
62 
63 typedef int opj_bool;
64 #define OPJ_TRUE 1
65 #define OPJ_FALSE 0
66 
67 /* Avoid compile-time warning because parameter is not used */
68 #define OPJ_ARG_NOT_USED(x) (void)(x)
69 /*
70 ==========================================================
71  Useful constant definitions
72 ==========================================================
73 */
74 
75 #define OPJ_PATH_LEN 4096
77 #define J2K_MAXRLVLS 33
78 #define J2K_MAXBANDS (3*J2K_MAXRLVLS-2)
80 /* UniPG>> */
81 #define JPWL_MAX_NO_TILESPECS 16
82 #define JPWL_MAX_NO_PACKSPECS 16
83 #define JPWL_MAX_NO_MARKERS 512
84 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename"
85 #define JPWL_EXPECTED_COMPONENTS 3
86 #define JPWL_MAXIMUM_TILES 8192
87 #define JPWL_MAXIMUM_HAMMING 2
88 #define JPWL_MAXIMUM_EPB_ROOM 65450
89 /* <<UniPG */
90 
91 /*
92 ==========================================================
93  enum definitions
94 ==========================================================
95 */
99 typedef enum RSIZ_CAPABILITIES {
100  STD_RSIZ = 0,
101  CINEMA2K = 3,
102  CINEMA4K = 4
104 
108 typedef enum CINEMA_MODE {
109  OFF = 0,
114 
118 typedef enum PROG_ORDER {
120  LRCP = 0,
121  RLCP = 1,
122  RPCL = 2,
123  PCRL = 3,
124  CPRL = 4
126 
130 typedef enum COLOR_SPACE {
137 
141 typedef enum CODEC_FORMAT {
143  CODEC_J2K = 0,
144  CODEC_JPT = 1,
147 
151 typedef enum LIMIT_DECODING {
156 
157 /*
158 ==========================================================
159  event manager typedef definitions
160 ==========================================================
161 */
162 
168 typedef void (*opj_msg_callback) (const char *msg, void *client_data);
169 
179 typedef struct opj_event_mgr {
187 
188 
189 /*
190 ==========================================================
191  codec typedef definitions
192 ==========================================================
193 */
194 
198 typedef struct opj_poc {
208  char progorder[5];
210  int tile;
212  int tx0,tx1,ty0,ty1;
214  int layS, resS, compS, prcS;
216  int layE, resE, compE, prcE;
221 } opj_poc_t;
222 
226 typedef struct opj_cparameters {
230  int cp_tx0;
232  int cp_ty0;
234  int cp_tdx;
236  int cp_tdy;
246  char *cp_comment;
248  int csty;
254  int numpocs;
258  float tcp_rates[100];
260  float tcp_distoratio[100];
268  int mode;
275  /* number of precinct size specifications */
276  int res_spec;
281 
289  int index_on;
306 /* UniPG>> */
336 /* <<UniPG */
337 
345  char tp_on;
347  char tp_flag;
349  char tcp_mct;
353 
354 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
355 
359 typedef struct opj_dparameters {
374  int cp_layer;
375 
388 /* UniPG>> */
398 /* <<UniPG */
399 
407 
408  unsigned int flags;
410 
413 #define opj_common_fields \
414  opj_event_mgr_t *event_mgr; \
415  void * client_data; \
416  opj_bool is_decompressor; \
417  OPJ_CODEC_FORMAT codec_format; \
418  void *j2k_handle; \
419  void *jp2_handle; \
420  void *mj2_handle
422 /* Routines that are to be used by both halves of the library are declared
423  * to receive a pointer to this structure. There are no actual instances of
424  * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t.
425  */
426 typedef struct opj_common_struct {
427  opj_common_fields; /* Fields common to both master struct types */
428  /* Additional fields follow in an actual opj_cinfo_t or
429  * opj_dinfo_t. All three structs must agree on these
430  * initial fields! (This would be a lot cleaner in C++.)
431  */
433 
435 
439 typedef struct opj_cinfo {
442  /* other specific fields go here */
443 } opj_cinfo_t;
444 
448 typedef struct opj_dinfo {
451  /* other specific fields go here */
452 } opj_dinfo_t;
453 
454 /*
455 ==========================================================
456  I/O stream typedef definitions
457 ==========================================================
458 */
459 
460 /*
461  * Stream open flags.
462  */
464 #define OPJ_STREAM_READ 0x0001
465 
466 #define OPJ_STREAM_WRITE 0x0002
467 
471 typedef struct opj_cio {
474 
476  int openmode;
478  unsigned char *buffer;
480  int length;
481 
483  unsigned char *start;
485  unsigned char *end;
487  unsigned char *bp;
488 } opj_cio_t;
489 
490 /*
491 ==========================================================
492  image typedef definitions
493 ==========================================================
494 */
495 
499 typedef struct opj_image_comp {
501  int dx;
503  int dy;
505  int w;
507  int h;
509  int x0;
511  int y0;
513  int prec;
515  int bpp;
517  int sgnd;
521  int factor;
523  int *data;
525 
529 typedef struct opj_image {
531  int x0;
533  int y0;
535  int x1;
537  int y1;
539  int numcomps;
545  unsigned char *icc_profile_buf;
548 } opj_image_t;
549 
553 typedef struct opj_image_comptparm {
555  int dx;
557  int dy;
559  int w;
561  int h;
563  int x0;
565  int y0;
567  int prec;
569  int bpp;
571  int sgnd;
573 
574 /*
575 ==========================================================
576  Information on the JPEG 2000 codestream
577 ==========================================================
578 */
579 
583 typedef struct opj_packet_info {
589  int end_pos;
591  double disto;
593 
594 
595 /* UniPG>> */
599 typedef struct opj_marker_info_t {
601  unsigned short int type;
603  int pos;
605  int len;
607 /* <<UniPG */
608 
612 typedef struct opj_tp_info {
623 } opj_tp_info_t;
624 
628 typedef struct opj_tile_info {
630  double *thresh;
632  int tileno;
638  int end_pos;
640  int pw[33];
642  int ph[33];
644  int pdx[33];
646  int pdy[33];
650  int numpix;
652  double distotile;
654  int marknum;
660  int num_tps;
664 
668 typedef struct opj_codestream_info {
670  double D_max;
672  int packno;
676  int image_w;
678  int image_h;
682  int tile_x;
684  int tile_y;
686  int tile_Ox;
688  int tile_Oy;
690  int tw;
692  int th;
694  int numcomps;
699 /* UniPG>> */
701  int marknum;
706 /* <<UniPG */
716 
717 #ifdef __cplusplus
718 extern "C" {
719 #endif
720 
721 
722 /*
723 ==========================================================
724  openjpeg version
725 ==========================================================
726 */
727 
728 OPJ_API const char * OPJ_CALLCONV opj_version(void);
729 
730 /*
731 ==========================================================
732  image functions definitions
733 ==========================================================
734 */
735 
744 
750 
751 /*
752 ==========================================================
753  stream functions definitions
754 ==========================================================
755 */
756 
768 OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
769 
775 
787 OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
788 
789 /*
790 ==========================================================
791  event manager functions definitions
792 ==========================================================
793 */
794 
796 
797 /*
798 ==========================================================
799  codec functions definitions
800 ==========================================================
801 */
832 
889 OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
904 
905 
906 #ifdef __cplusplus
907 }
908 #endif
909 
910 #endif /* OPENJPEG_H */