|
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 * All rights reserved. 00010 * 00011 * Redistribution and use in source and binary forms, with or without 00012 * modification, are permitted provided that the following conditions 00013 * are met: 00014 * 1. Redistributions of source code must retain the above copyright 00015 * notice, this list of conditions and the following disclaimer. 00016 * 2. Redistributions in binary form must reproduce the above copyright 00017 * notice, this list of conditions and the following disclaimer in the 00018 * documentation and/or other materials provided with the distribution. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' 00021 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00022 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00023 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00024 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00025 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00026 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00029 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00030 * POSSIBILITY OF SUCH DAMAGE. 00031 */ 00032 #ifndef __J2K_H 00033 #define __J2K_H 00034 00043 00044 #define J2K_CP_CSTY_PRT 0x01 00045 #define J2K_CP_CSTY_SOP 0x02 00046 #define J2K_CP_CSTY_EPH 0x04 00047 #define J2K_CCP_CSTY_PRT 0x01 00048 #define J2K_CCP_CBLKSTY_LAZY 0x01 00049 #define J2K_CCP_CBLKSTY_RESET 0x02 00050 #define J2K_CCP_CBLKSTY_TERMALL 0x04 00051 #define J2K_CCP_CBLKSTY_VSC 0x08 00052 #define J2K_CCP_CBLKSTY_PTERM 0x10 00053 #define J2K_CCP_CBLKSTY_SEGSYM 0x20 00054 #define J2K_CCP_QNTSTY_NOQNT 0 00055 #define J2K_CCP_QNTSTY_SIQNT 1 00056 #define J2K_CCP_QNTSTY_SEQNT 2 00057 00058 /* ----------------------------------------------------------------------- */ 00059 00060 #define J2K_MS_SOC 0xff4f 00061 #define J2K_MS_SOT 0xff90 00062 #define J2K_MS_SOD 0xff93 00063 #define J2K_MS_EOC 0xffd9 00064 #define J2K_MS_SIZ 0xff51 00065 #define J2K_MS_COD 0xff52 00066 #define J2K_MS_COC 0xff53 00067 #define J2K_MS_RGN 0xff5e 00068 #define J2K_MS_QCD 0xff5c 00069 #define J2K_MS_QCC 0xff5d 00070 #define J2K_MS_POC 0xff5f 00071 #define J2K_MS_TLM 0xff55 00072 #define J2K_MS_PLM 0xff57 00073 #define J2K_MS_PLT 0xff58 00074 #define J2K_MS_PPM 0xff60 00075 #define J2K_MS_PPT 0xff61 00076 #define J2K_MS_SOP 0xff91 00077 #define J2K_MS_EPH 0xff92 00078 #define J2K_MS_CRG 0xff63 00079 #define J2K_MS_COM 0xff64 00080 /* UniPG>> */ 00081 #ifdef USE_JPWL 00082 #define J2K_MS_EPC 0xff68 00083 #define J2K_MS_EPB 0xff66 00084 #define J2K_MS_ESD 0xff67 00085 #define J2K_MS_RED 0xff69 00086 #endif /* USE_JPWL */ 00087 #ifdef USE_JPSEC 00088 #define J2K_MS_SEC 0xff65 00089 #define J2K_MS_INSEC 0xff94 00090 #endif /* USE_JPSEC */ 00091 /* <<UniPG */ 00092 00093 00094 /* ----------------------------------------------------------------------- */ 00095 00100 typedef enum J2K_STATUS { 00101 J2K_STATE_MHSOC = 0x0001, 00102 J2K_STATE_MHSIZ = 0x0002, 00103 J2K_STATE_MH = 0x0004, 00104 J2K_STATE_TPHSOT = 0x0008, 00105 J2K_STATE_TPH = 0x0010, 00106 J2K_STATE_MT = 0x0020, 00107 J2K_STATE_NEOC = 0x0040, 00108 J2K_STATE_ERR = 0x0080 00109 } J2K_STATUS; 00110 00111 /* ----------------------------------------------------------------------- */ 00112 00116 typedef enum T2_MODE { 00117 THRESH_CALC = 0, 00118 FINAL_PASS = 1 00119 }J2K_T2_MODE; 00120 00124 typedef struct opj_stepsize { 00126 int expn; 00128 int mant; 00129 } opj_stepsize_t; 00130 00134 typedef struct opj_tccp { 00136 int csty; 00138 int numresolutions; 00140 int cblkw; 00142 int cblkh; 00144 int cblksty; 00146 int qmfbid; 00148 int qntsty; 00150 opj_stepsize_t stepsizes[J2K_MAXBANDS]; 00152 int numgbits; 00154 int roishift; 00156 int prcw[J2K_MAXRLVLS]; 00158 int prch[J2K_MAXRLVLS]; 00159 } opj_tccp_t; 00160 00166 typedef struct opj_tcp { 00168 int first; 00170 int csty; 00172 OPJ_PROG_ORDER prg; 00174 int numlayers; 00176 int mct; 00178 float rates[100]; 00180 int numpocs; 00182 int POC; 00184 opj_poc_t pocs[32]; 00186 unsigned char *ppt_data; 00188 unsigned char *ppt_data_first; 00190 int ppt; 00192 int ppt_store; 00194 int ppt_len; 00196 float distoratio[100]; 00198 opj_tccp_t *tccps; 00199 } opj_tcp_t; 00200 00204 typedef struct opj_cp { 00206 OPJ_CINEMA_MODE cinema; 00208 int max_comp_size; 00210 int img_size; 00212 OPJ_RSIZ_CAPABILITIES rsiz; 00214 char tp_on; 00216 char tp_flag; 00218 int tp_pos; 00220 int disto_alloc; 00222 int fixed_alloc; 00224 int fixed_quality; 00226 int reduce; 00228 int layer; 00230 OPJ_LIMIT_DECODING limit_decoding; 00232 int tx0; 00234 int ty0; 00236 int tdx; 00238 int tdy; 00240 char *comment; 00242 int tw; 00244 int th; 00246 int *tileno; 00248 int tileno_size; 00250 unsigned char *ppm_data; 00252 unsigned char *ppm_data_first; 00254 int ppm; 00256 int ppm_store; 00258 int ppm_previous; 00260 int ppm_len; 00262 opj_tcp_t *tcps; 00264 int *matrice; 00265 /* UniPG>> */ 00266 #ifdef USE_JPWL 00267 00268 opj_bool epc_on; 00270 opj_bool epb_on; 00272 opj_bool esd_on; 00274 opj_bool info_on; 00276 opj_bool red_on; 00278 int hprot_MH; 00280 int hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS]; 00282 int hprot_TPH[JPWL_MAX_NO_TILESPECS]; 00284 int pprot_tileno[JPWL_MAX_NO_PACKSPECS]; 00286 int pprot_packno[JPWL_MAX_NO_PACKSPECS]; 00288 int pprot[JPWL_MAX_NO_PACKSPECS]; 00290 int sens_size; 00292 int sens_addr; 00294 int sens_range; 00296 int sens_MH; 00298 int sens_TPH_tileno[JPWL_MAX_NO_TILESPECS]; 00300 int sens_TPH[JPWL_MAX_NO_TILESPECS]; 00302 opj_bool correct; 00304 int exp_comps; 00306 int max_tiles; 00307 #endif /* USE_JPWL */ 00308 /* <<UniPG */ 00309 } opj_cp_t; 00310 00314 typedef struct opj_j2k { 00316 opj_common_ptr cinfo; 00317 00319 int state; 00321 int curtileno; 00323 int tp_num; 00325 int cur_tp_num; 00327 int *cur_totnum_tp; 00332 int tlm_start; 00335 int totnum_tp; 00340 unsigned char *eot; 00345 int sot_start; 00346 int sod_start; 00351 int pos_correction; 00353 unsigned char **tile_data; 00355 int *tile_len; 00360 opj_tcp_t *default_tcp; 00362 opj_image_t *image; 00364 opj_cp_t *cp; 00366 opj_codestream_info_t *cstr_info; 00368 opj_cio_t *cio; 00369 } opj_j2k_t; 00370 00373 /* ----------------------------------------------------------------------- */ 00379 opj_j2k_t* j2k_create_decompress(opj_common_ptr cinfo); 00384 void j2k_destroy_decompress(opj_j2k_t *j2k); 00391 void j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters); 00399 opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info); 00407 opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info); 00413 opj_j2k_t* j2k_create_compress(opj_common_ptr cinfo); 00418 void j2k_destroy_compress(opj_j2k_t *j2k); 00426 void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_t *image); 00430 char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order); 00439 opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); 00440 00441 /* ----------------------------------------------------------------------- */ 00445 00446 #endif /* __J2K_H */
1.7.5.1