|
OpenJPEG
1.5.0
|
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 00141 typedef enum CODEC_FORMAT { 00142 CODEC_UNKNOWN = -1, 00143 CODEC_J2K = 0, 00144 CODEC_JPT = 1, 00145 CODEC_JP2 = 2 00146 } OPJ_CODEC_FORMAT; 00147 00151 typedef enum LIMIT_DECODING { 00152 NO_LIMITATION = 0, 00153 LIMIT_TO_MAIN_HEADER = 1, 00154 DECODE_ALL_BUT_PACKETS = 2 00155 } OPJ_LIMIT_DECODING; 00156 00157 /* 00158 ========================================================== 00159 event manager typedef definitions 00160 ========================================================== 00161 */ 00162 00168 typedef void (*opj_msg_callback) (const char *msg, void *client_data); 00169 00179 typedef struct opj_event_mgr { 00181 opj_msg_callback error_handler; 00183 opj_msg_callback warning_handler; 00185 opj_msg_callback info_handler; 00186 } opj_event_mgr_t; 00187 00188 00189 /* 00190 ========================================================== 00191 codec typedef definitions 00192 ========================================================== 00193 */ 00194 00198 typedef struct opj_poc { 00200 int resno0, compno0; 00202 int layno1, resno1, compno1; 00204 int layno0, precno0, precno1; 00206 OPJ_PROG_ORDER prg1,prg; 00208 char progorder[5]; 00210 int tile; 00212 int tx0,tx1,ty0,ty1; 00214 int layS, resS, compS, prcS; 00216 int layE, resE, compE, prcE; 00218 int txS,txE,tyS,tyE,dx,dy; 00220 int lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t; 00221 } opj_poc_t; 00222 00226 typedef struct opj_cparameters { 00228 opj_bool tile_size_on; 00230 int cp_tx0; 00232 int cp_ty0; 00234 int cp_tdx; 00236 int cp_tdy; 00238 int cp_disto_alloc; 00240 int cp_fixed_alloc; 00242 int cp_fixed_quality; 00244 int *cp_matrice; 00246 char *cp_comment; 00248 int csty; 00250 OPJ_PROG_ORDER prog_order; 00252 opj_poc_t POC[32]; 00254 int numpocs; 00256 int tcp_numlayers; 00258 float tcp_rates[100]; 00260 float tcp_distoratio[100]; 00262 int numresolution; 00264 int cblockw_init; 00266 int cblockh_init; 00268 int mode; 00270 int irreversible; 00272 int roi_compno; 00274 int roi_shift; 00275 /* number of precinct size specifications */ 00276 int res_spec; 00278 int prcw_init[J2K_MAXRLVLS]; 00280 int prch_init[J2K_MAXRLVLS]; 00281 00285 char infile[OPJ_PATH_LEN]; 00287 char outfile[OPJ_PATH_LEN]; 00289 int index_on; 00291 char index[OPJ_PATH_LEN]; 00293 int image_offset_x0; 00295 int image_offset_y0; 00297 int subsampling_dx; 00299 int subsampling_dy; 00301 int decod_format; 00303 int cod_format; 00306 /* UniPG>> */ 00310 opj_bool jpwl_epc_on; 00312 int jpwl_hprot_MH; 00314 int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS]; 00316 int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS]; 00318 int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS]; 00320 int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS]; 00322 int jpwl_pprot[JPWL_MAX_NO_PACKSPECS]; 00324 int jpwl_sens_size; 00326 int jpwl_sens_addr; 00328 int jpwl_sens_range; 00330 int jpwl_sens_MH; 00332 int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS]; 00334 int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS]; 00336 /* <<UniPG */ 00337 00339 OPJ_CINEMA_MODE cp_cinema; 00341 int max_comp_size; 00343 OPJ_RSIZ_CAPABILITIES cp_rsiz; 00345 char tp_on; 00347 char tp_flag; 00349 char tcp_mct; 00351 opj_bool jpip_on; 00352 } opj_cparameters_t; 00353 00354 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001 00355 00359 typedef struct opj_dparameters { 00367 int cp_reduce; 00374 int cp_layer; 00375 00379 char infile[OPJ_PATH_LEN]; 00381 char outfile[OPJ_PATH_LEN]; 00383 int decod_format; 00385 int cod_format; 00388 /* UniPG>> */ 00392 opj_bool jpwl_correct; 00394 int jpwl_exp_comps; 00396 int jpwl_max_tiles; 00398 /* <<UniPG */ 00399 00406 OPJ_LIMIT_DECODING cp_limit_decoding; 00407 00408 unsigned int flags; 00409 } opj_dparameters_t; 00410 00413 #define opj_common_fields \ 00414 opj_event_mgr_t *event_mgr; \ 00415 void * client_data; \ 00416 opj_bool is_decompressor; \ 00417 OPJ_CODEC_FORMAT codec_format; \ 00418 void *j2k_handle; \ 00419 void *jp2_handle; \ 00420 void *mj2_handle 00422 /* Routines that are to be used by both halves of the library are declared 00423 * to receive a pointer to this structure. There are no actual instances of 00424 * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t. 00425 */ 00426 typedef struct opj_common_struct { 00427 opj_common_fields; /* Fields common to both master struct types */ 00428 /* Additional fields follow in an actual opj_cinfo_t or 00429 * opj_dinfo_t. All three structs must agree on these 00430 * initial fields! (This would be a lot cleaner in C++.) 00431 */ 00432 } opj_common_struct_t; 00433 00434 typedef opj_common_struct_t * opj_common_ptr; 00435 00439 typedef struct opj_cinfo { 00441 opj_common_fields; 00442 /* other specific fields go here */ 00443 } opj_cinfo_t; 00444 00448 typedef struct opj_dinfo { 00450 opj_common_fields; 00451 /* other specific fields go here */ 00452 } opj_dinfo_t; 00453 00454 /* 00455 ========================================================== 00456 I/O stream typedef definitions 00457 ========================================================== 00458 */ 00459 00460 /* 00461 * Stream open flags. 00462 */ 00464 #define OPJ_STREAM_READ 0x0001 00465 00466 #define OPJ_STREAM_WRITE 0x0002 00467 00471 typedef struct opj_cio { 00473 opj_common_ptr cinfo; 00474 00476 int openmode; 00478 unsigned char *buffer; 00480 int length; 00481 00483 unsigned char *start; 00485 unsigned char *end; 00487 unsigned char *bp; 00488 } opj_cio_t; 00489 00490 /* 00491 ========================================================== 00492 image typedef definitions 00493 ========================================================== 00494 */ 00495 00499 typedef struct opj_image_comp { 00501 int dx; 00503 int dy; 00505 int w; 00507 int h; 00509 int x0; 00511 int y0; 00513 int prec; 00515 int bpp; 00517 int sgnd; 00519 int resno_decoded; 00521 int factor; 00523 int *data; 00524 } opj_image_comp_t; 00525 00529 typedef struct opj_image { 00531 int x0; 00533 int y0; 00535 int x1; 00537 int y1; 00539 int numcomps; 00541 OPJ_COLOR_SPACE color_space; 00543 opj_image_comp_t *comps; 00545 unsigned char *icc_profile_buf; 00547 int icc_profile_len; 00548 } opj_image_t; 00549 00553 typedef struct opj_image_comptparm { 00555 int dx; 00557 int dy; 00559 int w; 00561 int h; 00563 int x0; 00565 int y0; 00567 int prec; 00569 int bpp; 00571 int sgnd; 00572 } opj_image_cmptparm_t; 00573 00574 /* 00575 ========================================================== 00576 Information on the JPEG 2000 codestream 00577 ========================================================== 00578 */ 00579 00583 typedef struct opj_packet_info { 00585 int start_pos; 00587 int end_ph_pos; 00589 int end_pos; 00591 double disto; 00592 } opj_packet_info_t; 00593 00594 00595 /* UniPG>> */ 00599 typedef struct opj_marker_info_t { 00601 unsigned short int type; 00603 int pos; 00605 int len; 00606 } opj_marker_info_t; 00607 /* <<UniPG */ 00608 00612 typedef struct opj_tp_info { 00614 int tp_start_pos; 00616 int tp_end_header; 00618 int tp_end_pos; 00620 int tp_start_pack; 00622 int tp_numpacks; 00623 } opj_tp_info_t; 00624 00628 typedef struct opj_tile_info { 00630 double *thresh; 00632 int tileno; 00634 int start_pos; 00636 int end_header; 00638 int end_pos; 00640 int pw[33]; 00642 int ph[33]; 00644 int pdx[33]; 00646 int pdy[33]; 00648 opj_packet_info_t *packet; 00650 int numpix; 00652 double distotile; 00654 int marknum; 00656 opj_marker_info_t *marker; 00658 int maxmarknum; 00660 int num_tps; 00662 opj_tp_info_t *tp; 00663 } opj_tile_info_t; 00664 00668 typedef struct opj_codestream_info { 00670 double D_max; 00672 int packno; 00674 int index_write; 00676 int image_w; 00678 int image_h; 00680 OPJ_PROG_ORDER prog; 00682 int tile_x; 00684 int tile_y; 00686 int tile_Ox; 00688 int tile_Oy; 00690 int tw; 00692 int th; 00694 int numcomps; 00696 int numlayers; 00698 int *numdecompos; 00699 /* UniPG>> */ 00701 int marknum; 00703 opj_marker_info_t *marker; 00705 int maxmarknum; 00706 /* <<UniPG */ 00708 int main_head_start; 00710 int main_head_end; 00712 int codestream_size; 00714 opj_tile_info_t *tile; 00715 } opj_codestream_info_t; 00716 00717 #ifdef __cplusplus 00718 extern "C" { 00719 #endif 00720 00721 00722 /* 00723 ========================================================== 00724 openjpeg version 00725 ========================================================== 00726 */ 00727 00728 OPJ_API const char * OPJ_CALLCONV opj_version(void); 00729 00730 /* 00731 ========================================================== 00732 image functions definitions 00733 ========================================================== 00734 */ 00735 00743 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc); 00744 00749 OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image); 00750 00751 /* 00752 ========================================================== 00753 stream functions definitions 00754 ========================================================== 00755 */ 00756 00768 OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length); 00769 00774 OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio); 00775 00781 OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio); 00787 OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos); 00788 00789 /* 00790 ========================================================== 00791 event manager functions definitions 00792 ========================================================== 00793 */ 00794 00795 OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context); 00796 00797 /* 00798 ========================================================== 00799 codec functions definitions 00800 ========================================================== 00801 */ 00807 OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format); 00812 OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo); 00817 OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters); 00824 OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters); 00831 OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio); 00832 00840 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); 00846 OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format); 00851 OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo); 00873 OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters); 00880 OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image); 00889 OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index); 00898 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); 00903 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info); 00904 00905 00906 #ifdef __cplusplus 00907 } 00908 #endif 00909 00910 #endif /* OPENJPEG_H */
1.7.5.1