OpenJPEG  1.5.1
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 
138 #define ENUMCS_SRGB 16
139 #define ENUMCS_GRAY 17
140 #define ENUMCS_SYCC 18
141 
145 typedef enum CODEC_FORMAT {
147  CODEC_J2K = 0,
148  CODEC_JPT = 1,
151 
155 typedef enum LIMIT_DECODING {
160 
161 /*
162 ==========================================================
163  event manager typedef definitions
164 ==========================================================
165 */
166 
172 typedef void (*opj_msg_callback) (const char *msg, void *client_data);
173 
183 typedef struct opj_event_mgr {
191 
192 
193 /*
194 ==========================================================
195  codec typedef definitions
196 ==========================================================
197 */
198 
202 typedef struct opj_poc {
212  char progorder[5];
214  int tile;
216  int tx0,tx1,ty0,ty1;
218  int layS, resS, compS, prcS;
220  int layE, resE, compE, prcE;
225 } opj_poc_t;
226 
230 typedef struct opj_cparameters {
234  int cp_tx0;
236  int cp_ty0;
238  int cp_tdx;
240  int cp_tdy;
250  char *cp_comment;
252  int csty;
258  int numpocs;
262  float tcp_rates[100];
264  float tcp_distoratio[100];
272  int mode;
279  /* number of precinct size specifications */
280  int res_spec;
285 
293  int index_on;
310 /* UniPG>> */
340 /* <<UniPG */
341 
349  char tp_on;
351  char tp_flag;
353  char tcp_mct;
357 
358 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
359 
363 typedef struct opj_dparameters {
378  int cp_layer;
379 
392 /* UniPG>> */
402 /* <<UniPG */
403 
411 
412  unsigned int flags;
414 
417 #define opj_common_fields \
418  opj_event_mgr_t *event_mgr; \
419  void * client_data; \
420  opj_bool is_decompressor; \
421  OPJ_CODEC_FORMAT codec_format; \
422  void *j2k_handle; \
423  void *jp2_handle; \
424  void *mj2_handle
426 /* Routines that are to be used by both halves of the library are declared
427  * to receive a pointer to this structure. There are no actual instances of
428  * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t.
429  */
430 typedef struct opj_common_struct {
431  opj_common_fields; /* Fields common to both master struct types */
432  /* Additional fields follow in an actual opj_cinfo_t or
433  * opj_dinfo_t. All three structs must agree on these
434  * initial fields! (This would be a lot cleaner in C++.)
435  */
437 
439 
443 typedef struct opj_cinfo {
446  /* other specific fields go here */
447 } opj_cinfo_t;
448 
452 typedef struct opj_dinfo {
455  /* other specific fields go here */
456 } opj_dinfo_t;
457 
458 /*
459 ==========================================================
460  I/O stream typedef definitions
461 ==========================================================
462 */
463 
464 /*
465  * Stream open flags.
466  */
468 #define OPJ_STREAM_READ 0x0001
469 
470 #define OPJ_STREAM_WRITE 0x0002
471 
475 typedef struct opj_cio {
478 
480  int openmode;
482  unsigned char *buffer;
484  int length;
485 
487  unsigned char *start;
489  unsigned char *end;
491  unsigned char *bp;
492 } opj_cio_t;
493 
494 /*
495 ==========================================================
496  image typedef definitions
497 ==========================================================
498 */
499 
503 typedef struct opj_image_comp {
505  int dx;
507  int dy;
509  int w;
511  int h;
513  int x0;
515  int y0;
517  int prec;
519  int bpp;
521  int sgnd;
525  int factor;
527  int *data;
529 
533 typedef struct opj_image {
535  int x0;
537  int y0;
539  int x1;
541  int y1;
543  int numcomps;
549  unsigned char *icc_profile_buf;
552 } opj_image_t;
553 
557 typedef struct opj_image_comptparm {
559  int dx;
561  int dy;
563  int w;
565  int h;
567  int x0;
569  int y0;
571  int prec;
573  int bpp;
575  int sgnd;
577 
578 /*
579 ==========================================================
580  Information on the JPEG 2000 codestream
581 ==========================================================
582 */
583 
587 typedef struct opj_packet_info {
593  int end_pos;
595  double disto;
597 
598 
599 /* UniPG>> */
603 typedef struct opj_marker_info_t {
605  unsigned short int type;
607  int pos;
609  int len;
611 /* <<UniPG */
612 
616 typedef struct opj_tp_info {
627 } opj_tp_info_t;
628 
632 typedef struct opj_tile_info {
634  double *thresh;
636  int tileno;
642  int end_pos;
644  int pw[33];
646  int ph[33];
648  int pdx[33];
650  int pdy[33];
654  int numpix;
656  double distotile;
658  int marknum;
664  int num_tps;
668 
672 typedef struct opj_codestream_info {
674  double D_max;
676  int packno;
680  int image_w;
682  int image_h;
686  int tile_x;
688  int tile_y;
690  int tile_Ox;
692  int tile_Oy;
694  int tw;
696  int th;
698  int numcomps;
703 /* UniPG>> */
705  int marknum;
710 /* <<UniPG */
720 
721 #ifdef __cplusplus
722 extern "C" {
723 #endif
724 
725 
726 /*
727 ==========================================================
728  openjpeg version
729 ==========================================================
730 */
731 
732 OPJ_API const char * OPJ_CALLCONV opj_version(void);
733 
734 /*
735 ==========================================================
736  image functions definitions
737 ==========================================================
738 */
739 
748 
754 
755 /*
756 ==========================================================
757  stream functions definitions
758 ==========================================================
759 */
760 
772 OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
773 
779 
791 OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
792 
793 /*
794 ==========================================================
795  event manager functions definitions
796 ==========================================================
797 */
798 
800 
801 /*
802 ==========================================================
803  codec functions definitions
804 ==========================================================
805 */
836 
893 OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
908 
909 
910 #ifdef __cplusplus
911 }
912 #endif
913 
914 #endif /* OPENJPEG_H */