|
OpenJPEG
1.5.1
|
00001 /* 00002 * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium 00003 * Copyright (c) 2002-2007, Professor Benoit Macq 00004 * Copyright (c) 2001-2003, David Janssens 00005 * Copyright (c) 2002-2003, Yannick Verschueren 00006 * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe 00007 * Copyright (c) 2005, Herve Drolon, FreeImage Team 00008 * Copyright (c) 2006-2007, Parvatha Elangovan 00009 * Copyright (c) 2010-2011, Kaori Hagihara 00010 * All rights reserved. 00011 * 00012 * Redistribution and use in source and binary forms, with or without 00013 * modification, are permitted provided that the following conditions 00014 * are met: 00015 * 1. Redistributions of source code must retain the above copyright 00016 * notice, this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright 00018 * notice, this list of conditions and the following disclaimer in the 00019 * documentation and/or other materials provided with the distribution. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' 00022 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00024 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00025 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00026 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00027 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00030 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00031 * POSSIBILITY OF SUCH DAMAGE. 00032 */ 00033 #ifndef OPENJPEG_H 00034 #define OPENJPEG_H 00035 00036 00037 /* 00038 ========================================================== 00039 Compiler directives 00040 ========================================================== 00041 */ 00042 00043 #if defined(OPJ_STATIC) || !defined(_WIN32) 00044 #define OPJ_API 00045 #define OPJ_CALLCONV 00046 #else 00047 #define OPJ_CALLCONV __stdcall 00048 /* 00049 The following ifdef block is the standard way of creating macros which make exporting 00050 from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS 00051 symbol defined on the command line. this symbol should not be defined on any project 00052 that uses this DLL. This way any other project whose source files include this file see 00053 OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols 00054 defined with this macro as being exported. 00055 */ 00056 #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT) 00057 #define OPJ_API __declspec(dllexport) 00058 #else 00059 #define OPJ_API __declspec(dllimport) 00060 #endif /* OPJ_EXPORTS */ 00061 #endif /* !OPJ_STATIC || !_WIN32 */ 00062 00063 typedef int opj_bool; 00064 #define OPJ_TRUE 1 00065 #define OPJ_FALSE 0 00066 00067 /* Avoid compile-time warning because parameter is not used */ 00068 #define OPJ_ARG_NOT_USED(x) (void)(x) 00069 /* 00070 ========================================================== 00071 Useful constant definitions 00072 ========================================================== 00073 */ 00074 00075 #define OPJ_PATH_LEN 4096 00077 #define J2K_MAXRLVLS 33 00078 #define J2K_MAXBANDS (3*J2K_MAXRLVLS-2) 00080 /* UniPG>> */ 00081 #define JPWL_MAX_NO_TILESPECS 16 00082 #define JPWL_MAX_NO_PACKSPECS 16 00083 #define JPWL_MAX_NO_MARKERS 512 00084 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" 00085 #define JPWL_EXPECTED_COMPONENTS 3 00086 #define JPWL_MAXIMUM_TILES 8192 00087 #define JPWL_MAXIMUM_HAMMING 2 00088 #define JPWL_MAXIMUM_EPB_ROOM 65450 00089 /* <<UniPG */ 00090 00091 /* 00092 ========================================================== 00093 enum definitions 00094 ========================================================== 00095 */ 00099 typedef enum RSIZ_CAPABILITIES { 00100 STD_RSIZ = 0, 00101 CINEMA2K = 3, 00102 CINEMA4K = 4 00103 } OPJ_RSIZ_CAPABILITIES; 00104 00108 typedef enum CINEMA_MODE { 00109 OFF = 0, 00110 CINEMA2K_24 = 1, 00111 CINEMA2K_48 = 2, 00112 CINEMA4K_24 = 3 00113 }OPJ_CINEMA_MODE; 00114 00118 typedef enum PROG_ORDER { 00119 PROG_UNKNOWN = -1, 00120 LRCP = 0, 00121 RLCP = 1, 00122 RPCL = 2, 00123 PCRL = 3, 00124 CPRL = 4 00125 } OPJ_PROG_ORDER; 00126 00130 typedef enum COLOR_SPACE { 00131 CLRSPC_UNKNOWN = -1, 00132 CLRSPC_UNSPECIFIED = 0, 00133 CLRSPC_SRGB = 1, 00134 CLRSPC_GRAY = 2, 00135 CLRSPC_SYCC = 3 00136 } OPJ_COLOR_SPACE; 00137 00138 #define ENUMCS_SRGB 16 00139 #define ENUMCS_GRAY 17 00140 #define ENUMCS_SYCC 18 00141 00145 typedef enum CODEC_FORMAT { 00146 CODEC_UNKNOWN = -1, 00147 CODEC_J2K = 0, 00148 CODEC_JPT = 1, 00149 CODEC_JP2 = 2 00150 } OPJ_CODEC_FORMAT; 00151 00155 typedef enum LIMIT_DECODING { 00156 NO_LIMITATION = 0, 00157 LIMIT_TO_MAIN_HEADER = 1, 00158 DECODE_ALL_BUT_PACKETS = 2 00159 } OPJ_LIMIT_DECODING; 00160 00161 /* 00162 ========================================================== 00163 event manager typedef definitions 00164 ========================================================== 00165 */ 00166 00172 typedef void (*opj_msg_callback) (const char *msg, void *client_data); 00173 00183 typedef struct opj_event_mgr { 00185 opj_msg_callback error_handler; 00187 opj_msg_callback warning_handler; 00189 opj_msg_callback info_handler; 00190 } opj_event_mgr_t; 00191 00192 00193 /* 00194 ========================================================== 00195 codec typedef definitions 00196 ========================================================== 00197 */ 00198 00202 typedef struct opj_poc { 00204 int resno0, compno0; 00206 int layno1, resno1, compno1; 00208 int layno0, precno0, precno1; 00210 OPJ_PROG_ORDER prg1,prg; 00212 char progorder[5]; 00214 int tile; 00216 int tx0,tx1,ty0,ty1; 00218 int layS, resS, compS, prcS; 00220 int layE, resE, compE, prcE; 00222 int txS,txE,tyS,tyE,dx,dy; 00224 int lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t; 00225 } opj_poc_t; 00226 00230 typedef struct opj_cparameters { 00232 opj_bool tile_size_on; 00234 int cp_tx0; 00236 int cp_ty0; 00238 int cp_tdx; 00240 int cp_tdy; 00242 int cp_disto_alloc; 00244 int cp_fixed_alloc; 00246 int cp_fixed_quality; 00248 int *cp_matrice; 00250 char *cp_comment; 00252 int csty; 00254 OPJ_PROG_ORDER prog_order; 00256 opj_poc_t POC[32]; 00258 int numpocs; 00260 int tcp_numlayers; 00262 float tcp_rates[100]; 00264 float tcp_distoratio[100]; 00266 int numresolution; 00268 int cblockw_init; 00270 int cblockh_init; 00272 int mode; 00274 int irreversible; 00276 int roi_compno; 00278 int roi_shift; 00279 /* number of precinct size specifications */ 00280 int res_spec; 00282 int prcw_init[J2K_MAXRLVLS]; 00284 int prch_init[J2K_MAXRLVLS]; 00285 00289 char infile[OPJ_PATH_LEN]; 00291 char outfile[OPJ_PATH_LEN]; 00293 int index_on; 00295 char index[OPJ_PATH_LEN]; 00297 int image_offset_x0; 00299 int image_offset_y0; 00301 int subsampling_dx; 00303 int subsampling_dy; 00305 int decod_format; 00307 int cod_format; 00310 /* UniPG>> */ 00314 opj_bool jpwl_epc_on; 00316 int jpwl_hprot_MH; 00318 int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS]; 00320 int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS]; 00322 int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS]; 00324 int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS]; 00326 int jpwl_pprot[JPWL_MAX_NO_PACKSPECS]; 00328 int jpwl_sens_size; 00330 int jpwl_sens_addr; 00332 int jpwl_sens_range; 00334 int jpwl_sens_MH; 00336 int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS]; 00338 int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS]; 00340 /* <<UniPG */ 00341 00343 OPJ_CINEMA_MODE cp_cinema; 00345 int max_comp_size; 00347 OPJ_RSIZ_CAPABILITIES cp_rsiz; 00349 char tp_on; 00351 char tp_flag; 00353 char tcp_mct; 00355 opj_bool jpip_on; 00356 } opj_cparameters_t; 00357 00358 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001 00359 00363 typedef struct opj_dparameters { 00371 int cp_reduce; 00378 int cp_layer; 00379 00383 char infile[OPJ_PATH_LEN]; 00385 char outfile[OPJ_PATH_LEN]; 00387 int decod_format; 00389 int cod_format; 00392 /* UniPG>> */ 00396 opj_bool jpwl_correct; 00398 int jpwl_exp_comps; 00400 int jpwl_max_tiles; 00402 /* <<UniPG */ 00403 00410 OPJ_LIMIT_DECODING cp_limit_decoding; 00411 00412 unsigned int flags; 00413 } opj_dparameters_t; 00414 00417 #define opj_common_fields \ 00418 opj_event_mgr_t *event_mgr; \ 00419 void * client_data; \ 00420 opj_bool is_decompressor; \ 00421 OPJ_CODEC_FORMAT codec_format; \ 00422 void *j2k_handle; \ 00423 void *jp2_handle; \ 00424 void *mj2_handle 00426 /* Routines that are to be used by both halves of the library are declared 00427 * to receive a pointer to this structure. There are no actual instances of 00428 * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t. 00429 */ 00430 typedef struct opj_common_struct { 00431 opj_common_fields; /* Fields common to both master struct types */ 00432 /* Additional fields follow in an actual opj_cinfo_t or 00433 * opj_dinfo_t. All three structs must agree on these 00434 * initial fields! (This would be a lot cleaner in C++.) 00435 */ 00436 } opj_common_struct_t; 00437 00438 typedef opj_common_struct_t * opj_common_ptr; 00439 00443 typedef struct opj_cinfo { 00445 opj_common_fields; 00446 /* other specific fields go here */ 00447 } opj_cinfo_t; 00448 00452 typedef struct opj_dinfo { 00454 opj_common_fields; 00455 /* other specific fields go here */ 00456 } opj_dinfo_t; 00457 00458 /* 00459 ========================================================== 00460 I/O stream typedef definitions 00461 ========================================================== 00462 */ 00463 00464 /* 00465 * Stream open flags. 00466 */ 00468 #define OPJ_STREAM_READ 0x0001 00469 00470 #define OPJ_STREAM_WRITE 0x0002 00471 00475 typedef struct opj_cio { 00477 opj_common_ptr cinfo; 00478 00480 int openmode; 00482 unsigned char *buffer; 00484 int length; 00485 00487 unsigned char *start; 00489 unsigned char *end; 00491 unsigned char *bp; 00492 } opj_cio_t; 00493 00494 /* 00495 ========================================================== 00496 image typedef definitions 00497 ========================================================== 00498 */ 00499 00503 typedef struct opj_image_comp { 00505 int dx; 00507 int dy; 00509 int w; 00511 int h; 00513 int x0; 00515 int y0; 00517 int prec; 00519 int bpp; 00521 int sgnd; 00523 int resno_decoded; 00525 int factor; 00527 int *data; 00528 } opj_image_comp_t; 00529 00533 typedef struct opj_image { 00535 int x0; 00537 int y0; 00539 int x1; 00541 int y1; 00543 int numcomps; 00545 OPJ_COLOR_SPACE color_space; 00547 opj_image_comp_t *comps; 00549 unsigned char *icc_profile_buf; 00551 int icc_profile_len; 00552 } opj_image_t; 00553 00557 typedef struct opj_image_comptparm { 00559 int dx; 00561 int dy; 00563 int w; 00565 int h; 00567 int x0; 00569 int y0; 00571 int prec; 00573 int bpp; 00575 int sgnd; 00576 } opj_image_cmptparm_t; 00577 00578 /* 00579 ========================================================== 00580 Information on the JPEG 2000 codestream 00581 ========================================================== 00582 */ 00583 00587 typedef struct opj_packet_info { 00589 int start_pos; 00591 int end_ph_pos; 00593 int end_pos; 00595 double disto; 00596 } opj_packet_info_t; 00597 00598 00599 /* UniPG>> */ 00603 typedef struct opj_marker_info_t { 00605 unsigned short int type; 00607 int pos; 00609 int len; 00610 } opj_marker_info_t; 00611 /* <<UniPG */ 00612 00616 typedef struct opj_tp_info { 00618 int tp_start_pos; 00620 int tp_end_header; 00622 int tp_end_pos; 00624 int tp_start_pack; 00626 int tp_numpacks; 00627 } opj_tp_info_t; 00628 00632 typedef struct opj_tile_info { 00634 double *thresh; 00636 int tileno; 00638 int start_pos; 00640 int end_header; 00642 int end_pos; 00644 int pw[33]; 00646 int ph[33]; 00648 int pdx[33]; 00650 int pdy[33]; 00652 opj_packet_info_t *packet; 00654 int numpix; 00656 double distotile; 00658 int marknum; 00660 opj_marker_info_t *marker; 00662 int maxmarknum; 00664 int num_tps; 00666 opj_tp_info_t *tp; 00667 } opj_tile_info_t; 00668 00672 typedef struct opj_codestream_info { 00674 double D_max; 00676 int packno; 00678 int index_write; 00680 int image_w; 00682 int image_h; 00684 OPJ_PROG_ORDER prog; 00686 int tile_x; 00688 int tile_y; 00690 int tile_Ox; 00692 int tile_Oy; 00694 int tw; 00696 int th; 00698 int numcomps; 00700 int numlayers; 00702 int *numdecompos; 00703 /* UniPG>> */ 00705 int marknum; 00707 opj_marker_info_t *marker; 00709 int maxmarknum; 00710 /* <<UniPG */ 00712 int main_head_start; 00714 int main_head_end; 00716 int codestream_size; 00718 opj_tile_info_t *tile; 00719 } opj_codestream_info_t; 00720 00721 #ifdef __cplusplus 00722 extern "C" { 00723 #endif 00724 00725 00726 /* 00727 ========================================================== 00728 openjpeg version 00729 ========================================================== 00730 */ 00731 00732 OPJ_API const char * OPJ_CALLCONV opj_version(void); 00733 00734 /* 00735 ========================================================== 00736 image functions definitions 00737 ========================================================== 00738 */ 00739 00747 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc); 00748 00753 OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image); 00754 00755 /* 00756 ========================================================== 00757 stream functions definitions 00758 ========================================================== 00759 */ 00760 00772 OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length); 00773 00778 OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio); 00779 00785 OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio); 00791 OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos); 00792 00793 /* 00794 ========================================================== 00795 event manager functions definitions 00796 ========================================================== 00797 */ 00798 00799 OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context); 00800 00801 /* 00802 ========================================================== 00803 codec functions definitions 00804 ========================================================== 00805 */ 00811 OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format); 00816 OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo); 00821 OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters); 00828 OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters); 00835 OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio); 00836 00844 OPJ_API opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *cio, opj_codestream_info_t *cstr_info); 00850 OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format); 00855 OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo); 00877 OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters); 00884 OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image); 00893 OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index); 00902 OPJ_API opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); 00907 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info); 00908 00909 00910 #ifdef __cplusplus 00911 } 00912 #endif 00913 00914 #endif /* OPENJPEG_H */
1.7.5.1