OpenJPEG 2.1.2

openjpeg.h

Go to the documentation of this file.
00001  /*
00002  * The copyright in this software is being made available under the 2-clauses 
00003  * BSD License, included below. This software may be subject to other third 
00004  * party and contributor rights, including patent rights, and no such rights
00005  * are granted under this license.
00006  *
00007  * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
00008  * Copyright (c) 2002-2014, Professor Benoit Macq
00009  * Copyright (c) 2001-2003, David Janssens
00010  * Copyright (c) 2002-2003, Yannick Verschueren
00011  * Copyright (c) 2003-2007, Francois-Olivier Devaux 
00012  * Copyright (c) 2003-2014, Antonin Descampe
00013  * Copyright (c) 2005, Herve Drolon, FreeImage Team
00014  * Copyright (c) 2006-2007, Parvatha Elangovan
00015  * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
00016  * Copyright (c) 2010-2011, Kaori Hagihara
00017  * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France 
00018  * Copyright (c) 2012, CS Systemes d'Information, France
00019  * All rights reserved.
00020  *
00021  * Redistribution and use in source and binary forms, with or without
00022  * modification, are permitted provided that the following conditions
00023  * are met:
00024  * 1. Redistributions of source code must retain the above copyright
00025  *    notice, this list of conditions and the following disclaimer.
00026  * 2. Redistributions in binary form must reproduce the above copyright
00027  *    notice, this list of conditions and the following disclaimer in the
00028  *    documentation and/or other materials provided with the distribution.
00029  *
00030  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
00031  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00032  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00033  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00034  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00035  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00036  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00037  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00038  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00039  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00040  * POSSIBILITY OF SUCH DAMAGE.
00041  */
00042 #ifndef OPENJPEG_H
00043 #define OPENJPEG_H
00044 
00045 
00046 /* 
00047 ==========================================================
00048    Compiler directives
00049 ==========================================================
00050 */
00051 
00052 /*
00053 The inline keyword is supported by C99 but not by C90. 
00054 Most compilers implement their own version of this keyword ... 
00055 */
00056 #ifndef INLINE
00057         #if defined(_MSC_VER)
00058                 #define INLINE __forceinline
00059         #elif defined(__GNUC__)
00060                 #define INLINE __inline__
00061         #elif defined(__MWERKS__)
00062                 #define INLINE inline
00063         #else 
00064                 /* add other compilers here ... */
00065                 #define INLINE 
00066         #endif /* defined(<Compiler>) */
00067 #endif /* INLINE */
00068 
00069 /* deprecated attribute */
00070 #ifdef __GNUC__
00071         #define OPJ_DEPRECATED(func) func __attribute__ ((deprecated))
00072 #elif defined(_MSC_VER)
00073         #define OPJ_DEPRECATED(func) __declspec(deprecated) func
00074 #else
00075         #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
00076         #define OPJ_DEPRECATED(func) func
00077 #endif
00078 
00079 #if defined(OPJ_STATIC) || !defined(_WIN32)
00080 /* http://gcc.gnu.org/wiki/Visibility */
00081 #       if __GNUC__ >= 4
00082 #               if defined(OPJ_STATIC) /* static library uses "hidden" */
00083 #                       define OPJ_API    __attribute__ ((visibility ("hidden")))
00084 #               else
00085 #                       define OPJ_API    __attribute__ ((visibility ("default")))
00086 #               endif
00087 #               define OPJ_LOCAL  __attribute__ ((visibility ("hidden")))
00088 #       else
00089 #               define OPJ_API
00090 #               define OPJ_LOCAL
00091 #       endif
00092 #       define OPJ_CALLCONV
00093 #else
00094 #       define OPJ_CALLCONV __stdcall
00095 /*
00096 The following ifdef block is the standard way of creating macros which make exporting 
00097 from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
00098 symbol defined on the command line. this symbol should not be defined on any project
00099 that uses this DLL. This way any other project whose source files include this file see 
00100 OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols
00101 defined with this macro as being exported.
00102 */
00103 #       if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
00104 #               define OPJ_API __declspec(dllexport)
00105 #       else
00106 #               define OPJ_API __declspec(dllimport)
00107 #       endif /* OPJ_EXPORTS */
00108 #endif /* !OPJ_STATIC || !_WIN32 */
00109 
00110 typedef int OPJ_BOOL;
00111 #define OPJ_TRUE 1
00112 #define OPJ_FALSE 0
00113 
00114 typedef char          OPJ_CHAR;
00115 typedef float         OPJ_FLOAT32;
00116 typedef double        OPJ_FLOAT64;
00117 typedef unsigned char OPJ_BYTE;
00118 
00119 #include "opj_stdint.h"
00120 
00121 typedef int8_t   OPJ_INT8;
00122 typedef uint8_t  OPJ_UINT8;
00123 typedef int16_t  OPJ_INT16;
00124 typedef uint16_t OPJ_UINT16;
00125 typedef int32_t  OPJ_INT32;
00126 typedef uint32_t OPJ_UINT32;
00127 typedef int64_t  OPJ_INT64;
00128 typedef uint64_t OPJ_UINT64;
00129 
00130 typedef int64_t  OPJ_OFF_T; /* 64-bit file offset type */
00131 
00132 #include <stdio.h>
00133 typedef size_t   OPJ_SIZE_T;
00134 
00135 /* Avoid compile-time warning because parameter is not used */
00136 #define OPJ_ARG_NOT_USED(x) (void)(x)
00137 
00138 /* 
00139 ==========================================================
00140    Useful constant definitions
00141 ==========================================================
00142 */
00143 
00144 #define OPJ_PATH_LEN 4096 
00146 #define OPJ_J2K_MAXRLVLS 33                                     
00147 #define OPJ_J2K_MAXBANDS (3*OPJ_J2K_MAXRLVLS-2) 
00149 #define OPJ_J2K_DEFAULT_NB_SEGS                         10
00150 #define OPJ_J2K_STREAM_CHUNK_SIZE                       0x100000 
00151 #define OPJ_J2K_DEFAULT_HEADER_SIZE                     1000
00152 #define OPJ_J2K_MCC_DEFAULT_NB_RECORDS          10
00153 #define OPJ_J2K_MCT_DEFAULT_NB_RECORDS          10
00154 
00155 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
00156 #define JPWL_MAX_NO_TILESPECS   16 
00157 #define JPWL_MAX_NO_PACKSPECS   16 
00158 #define JPWL_MAX_NO_MARKERS     512 
00159 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" 
00160 #define JPWL_EXPECTED_COMPONENTS 3 
00161 #define JPWL_MAXIMUM_TILES 8192 
00162 #define JPWL_MAXIMUM_HAMMING 2 
00163 #define JPWL_MAXIMUM_EPB_ROOM 65450 
00164 /* <<UniPG */
00165 
00170 #define OPJ_IMG_INFO            1       
00171 #define OPJ_J2K_MH_INFO         2       
00172 #define OPJ_J2K_TH_INFO         4       
00173 #define OPJ_J2K_TCH_INFO        8       
00174 #define OPJ_J2K_MH_IND          16      
00175 #define OPJ_J2K_TH_IND          32      
00176 /*FIXME #define OPJ_J2K_CSTR_IND        48*/    
00177 #define OPJ_JP2_INFO            128     
00178 #define OPJ_JP2_IND                     256     
00194 #define OPJ_PROFILE_NONE        0x0000 
00195 #define OPJ_PROFILE_0           0x0001 
00196 #define OPJ_PROFILE_1           0x0002 
00197 #define OPJ_PROFILE_PART2       0x8000 
00198 #define OPJ_PROFILE_CINEMA_2K   0x0003 
00199 #define OPJ_PROFILE_CINEMA_4K   0x0004 
00200 #define OPJ_PROFILE_CINEMA_S2K  0x0005 
00201 #define OPJ_PROFILE_CINEMA_S4K  0x0006 
00202 #define OPJ_PROFILE_CINEMA_LTS  0x0007 
00203 #define OPJ_PROFILE_BC_SINGLE   0x0100 
00204 #define OPJ_PROFILE_BC_MULTI    0x0200 
00205 #define OPJ_PROFILE_BC_MULTI_R  0x0300 
00206 #define OPJ_PROFILE_IMF_2K      0x0400 
00207 #define OPJ_PROFILE_IMF_4K      0x0401 
00208 #define OPJ_PROFILE_IMF_8K      0x0402 
00209 #define OPJ_PROFILE_IMF_2K_R    0x0403 
00210 #define OPJ_PROFILE_IMF_4K_R    0x0800 
00211 #define OPJ_PROFILE_IMF_8K_R    0x0801  
00216 #define OPJ_EXTENSION_NONE      0x0000 
00217 #define OPJ_EXTENSION_MCT       0x0100  
00222 #define OPJ_IS_CINEMA(v)     (((v) >= OPJ_PROFILE_CINEMA_2K)&&((v) <= OPJ_PROFILE_CINEMA_S4K))
00223 #define OPJ_IS_STORAGE(v)    ((v) == OPJ_PROFILE_CINEMA_LTS)
00224 #define OPJ_IS_BROADCAST(v)  (((v) >= OPJ_PROFILE_BC_SINGLE)&&((v) <= ((OPJ_PROFILE_BC_MULTI_R) | (0x000b))))
00225 #define OPJ_IS_IMF(v)        (((v) >= OPJ_PROFILE_IMF_2K)&&((v) <= ((OPJ_PROFILE_IMF_8K_R) | (0x009b))))
00226 #define OPJ_IS_PART2(v)      ((v) & OPJ_PROFILE_PART2)
00227 
00231 #define OPJ_CINEMA_24_CS     1302083    
00232 #define OPJ_CINEMA_48_CS     651041     
00233 #define OPJ_CINEMA_24_COMP   1041666    
00234 #define OPJ_CINEMA_48_COMP   520833             
00236 /* 
00237 ==========================================================
00238    enum definitions
00239 ==========================================================
00240 */
00241 
00246 typedef enum RSIZ_CAPABILITIES {
00247     OPJ_STD_RSIZ = 0,           
00248     OPJ_CINEMA2K = 3,           
00249     OPJ_CINEMA4K = 4,           
00250     OPJ_MCT = 0x8100
00251 } OPJ_RSIZ_CAPABILITIES;
00252 
00257 typedef enum CINEMA_MODE {
00258     OPJ_OFF = 0,                        
00259     OPJ_CINEMA2K_24 = 1,        
00260     OPJ_CINEMA2K_48 = 2,        
00261     OPJ_CINEMA4K_24 = 3         
00262 }OPJ_CINEMA_MODE;
00263 
00267 typedef enum PROG_ORDER {
00268         OPJ_PROG_UNKNOWN = -1,  
00269         OPJ_LRCP = 0,                   
00270         OPJ_RLCP = 1,                   
00271         OPJ_RPCL = 2,                   
00272         OPJ_PCRL = 3,                   
00273         OPJ_CPRL = 4                    
00274 } OPJ_PROG_ORDER;
00275 
00279 typedef enum COLOR_SPACE {
00280     OPJ_CLRSPC_UNKNOWN = -1,    
00281     OPJ_CLRSPC_UNSPECIFIED = 0, 
00282     OPJ_CLRSPC_SRGB = 1,                
00283     OPJ_CLRSPC_GRAY = 2,                
00284     OPJ_CLRSPC_SYCC = 3,                
00285     OPJ_CLRSPC_EYCC = 4,        
00286     OPJ_CLRSPC_CMYK = 5         
00287 } OPJ_COLOR_SPACE;
00288 
00292 typedef enum CODEC_FORMAT {
00293         OPJ_CODEC_UNKNOWN = -1, 
00294         OPJ_CODEC_J2K  = 0,             
00295         OPJ_CODEC_JPT  = 1,             
00296     OPJ_CODEC_JP2  = 2,         
00297     OPJ_CODEC_JPP  = 3,         
00298     OPJ_CODEC_JPX  = 4          
00299 } OPJ_CODEC_FORMAT;
00300 
00301 
00302 /* 
00303 ==========================================================
00304    event manager typedef definitions
00305 ==========================================================
00306 */
00307 
00313 typedef void (*opj_msg_callback) (const char *msg, void *client_data);
00314 
00315 /* 
00316 ==========================================================
00317    codec typedef definitions
00318 ==========================================================
00319 */
00320 
00325 typedef struct opj_poc {
00327         OPJ_UINT32 resno0, compno0;
00329         OPJ_UINT32 layno1, resno1, compno1;
00331         OPJ_UINT32 layno0, precno0, precno1;
00333         OPJ_PROG_ORDER prg1,prg;
00335         OPJ_CHAR progorder[5];
00337         OPJ_UINT32 tile;
00339         OPJ_INT32 tx0,tx1,ty0,ty1;
00341         OPJ_UINT32 layS, resS, compS, prcS;
00343         OPJ_UINT32 layE, resE, compE, prcE;
00345         OPJ_UINT32 txS,txE,tyS,tyE,dx,dy;
00347         OPJ_UINT32 lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t;
00348 } opj_poc_t;
00349 
00353 typedef struct opj_cparameters {
00355         OPJ_BOOL tile_size_on;
00357         int cp_tx0;
00359         int cp_ty0;
00361         int cp_tdx;
00363         int cp_tdy;
00365         int cp_disto_alloc;
00367         int cp_fixed_alloc;
00369         int cp_fixed_quality;
00371         int *cp_matrice;
00373         char *cp_comment;
00375         int csty;
00377         OPJ_PROG_ORDER prog_order;
00379         opj_poc_t POC[32];
00381         OPJ_UINT32 numpocs;
00383         int tcp_numlayers;
00385         float tcp_rates[100];
00387         float tcp_distoratio[100];
00389         int numresolution;
00391         int cblockw_init;
00393         int cblockh_init;
00395         int mode;
00397         int irreversible;
00399         int roi_compno;
00401         int roi_shift;
00402         /* number of precinct size specifications */
00403         int res_spec;
00405         int prcw_init[OPJ_J2K_MAXRLVLS];
00407         int prch_init[OPJ_J2K_MAXRLVLS];
00408 
00412         char infile[OPJ_PATH_LEN];
00414         char outfile[OPJ_PATH_LEN];
00416         int index_on;
00418         char index[OPJ_PATH_LEN];
00420         int image_offset_x0;
00422         int image_offset_y0;
00424         int subsampling_dx;
00426         int subsampling_dy;
00428         int decod_format;
00430         int cod_format;
00433 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
00437         OPJ_BOOL jpwl_epc_on;
00439         int jpwl_hprot_MH;
00441         int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
00443         int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
00445         int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
00447         int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
00449         int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
00451         int jpwl_sens_size;
00453         int jpwl_sens_addr;
00455         int jpwl_sens_range;
00457         int jpwl_sens_MH;
00459         int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
00461         int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
00463 /* <<UniPG */
00464 
00469     OPJ_CINEMA_MODE cp_cinema;
00474         int max_comp_size;
00479     OPJ_RSIZ_CAPABILITIES cp_rsiz;
00481         char tp_on;
00483         char tp_flag;
00485         char tcp_mct;
00487         OPJ_BOOL jpip_on;
00490         void * mct_data;
00497     int max_cs_size;
00500     OPJ_UINT16 rsiz;
00501 } opj_cparameters_t;  
00502 
00503 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG      0x0001
00504 
00508 typedef struct opj_dparameters {
00516         OPJ_UINT32 cp_reduce;
00523         OPJ_UINT32 cp_layer;
00524 
00528         char infile[OPJ_PATH_LEN];
00530         char outfile[OPJ_PATH_LEN];
00532         int decod_format;
00534         int cod_format;
00535 
00537         OPJ_UINT32 DA_x0;
00539         OPJ_UINT32 DA_x1;
00541         OPJ_UINT32 DA_y0;
00543         OPJ_UINT32 DA_y1;
00545         OPJ_BOOL m_verbose;
00546 
00548         OPJ_UINT32 tile_index;
00550         OPJ_UINT32 nb_tile_to_decode;
00551 
00554 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
00558         OPJ_BOOL jpwl_correct;
00560         int jpwl_exp_comps;
00562         int jpwl_max_tiles;
00564 /* <<UniPG */
00565 
00566         unsigned int flags;
00567 
00568 } opj_dparameters_t;
00569 
00570 
00574 typedef void * opj_codec_t;
00575 
00576 /* 
00577 ==========================================================
00578    I/O stream typedef definitions
00579 ==========================================================
00580 */
00581 
00586 #define OPJ_STREAM_READ OPJ_TRUE
00587 
00588 #define OPJ_STREAM_WRITE OPJ_FALSE
00589 
00590 /*
00591  * Callback function prototype for read function
00592  */
00593 typedef OPJ_SIZE_T (* opj_stream_read_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
00594 
00595 /*
00596  * Callback function prototype for write function
00597  */
00598 typedef OPJ_SIZE_T (* opj_stream_write_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
00599 
00600 /*
00601  * Callback function prototype for skip function
00602  */
00603 typedef OPJ_OFF_T (* opj_stream_skip_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
00604 
00605 /*
00606  * Callback function prototype for seek function
00607  */
00608 typedef OPJ_BOOL (* opj_stream_seek_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
00609 
00610 /*
00611  * Callback function prototype for free user data function
00612  */
00613 typedef void (* opj_stream_free_user_data_fn) (void * p_user_data) ;
00614 
00615 /*
00616  * JPEG2000 Stream.
00617  */
00618 typedef void * opj_stream_t;
00619 
00620 /* 
00621 ==========================================================
00622    image typedef definitions
00623 ==========================================================
00624 */
00625 
00629 typedef struct opj_image_comp {
00631         OPJ_UINT32 dx;
00633         OPJ_UINT32 dy;
00635         OPJ_UINT32 w;
00637         OPJ_UINT32 h;
00639         OPJ_UINT32 x0;
00641         OPJ_UINT32 y0;
00643         OPJ_UINT32 prec;
00645         OPJ_UINT32 bpp;
00647         OPJ_UINT32 sgnd;
00649         OPJ_UINT32 resno_decoded;
00651         OPJ_UINT32 factor;
00653         OPJ_INT32 *data;
00655   OPJ_UINT16 alpha;
00656 } opj_image_comp_t;
00657 
00661 typedef struct opj_image {
00663         OPJ_UINT32 x0;
00665         OPJ_UINT32 y0;
00667         OPJ_UINT32 x1;
00669         OPJ_UINT32 y1;
00671         OPJ_UINT32 numcomps;
00673         OPJ_COLOR_SPACE color_space;
00675         opj_image_comp_t *comps;
00677         OPJ_BYTE *icc_profile_buf;
00679         OPJ_UINT32 icc_profile_len;
00680 } opj_image_t;
00681 
00682 
00686 typedef struct opj_image_comptparm {
00688         OPJ_UINT32 dx;
00690         OPJ_UINT32 dy;
00692         OPJ_UINT32 w;
00694         OPJ_UINT32 h;
00696         OPJ_UINT32 x0;
00698         OPJ_UINT32 y0;
00700         OPJ_UINT32 prec;
00702         OPJ_UINT32 bpp;
00704         OPJ_UINT32 sgnd;
00705 } opj_image_cmptparm_t;
00706 
00707 
00708 /* 
00709 ==========================================================
00710    Information on the JPEG 2000 codestream
00711 ==========================================================
00712 */
00713 /* QUITE EXPERIMENTAL FOR THE MOMENT */
00714 
00718 typedef struct opj_packet_info {
00720         OPJ_OFF_T start_pos;
00722         OPJ_OFF_T end_ph_pos;
00724         OPJ_OFF_T end_pos;
00726         double disto;
00727 } opj_packet_info_t;
00728 
00729 
00730 /* UniPG>> */
00734 typedef struct opj_marker_info {
00736         unsigned short int type;
00738         OPJ_OFF_T pos;
00740         int len;
00741 } opj_marker_info_t;
00742 /* <<UniPG */
00743 
00747 typedef struct opj_tp_info {
00749         int tp_start_pos;
00751         int tp_end_header;
00753         int tp_end_pos;
00755         int tp_start_pack;
00757         int tp_numpacks;
00758 } opj_tp_info_t;
00759 
00763 typedef struct opj_tile_info {
00765         double *thresh;
00767         int tileno;
00769         int start_pos;
00771         int end_header;
00773         int end_pos;
00775         int pw[33];
00777         int ph[33];
00779         int pdx[33];
00781         int pdy[33];
00783         opj_packet_info_t *packet;
00785         int numpix;
00787         double distotile;
00789         int marknum;
00791         opj_marker_info_t *marker;
00793         int maxmarknum;
00795         int num_tps;
00797         opj_tp_info_t *tp;
00798 } opj_tile_info_t;
00799 
00803 typedef struct opj_codestream_info {
00805         double D_max;
00807         int packno;
00809         int index_write;
00811         int image_w;
00813         int image_h;
00815         OPJ_PROG_ORDER prog;
00817         int tile_x;
00819         int tile_y;
00821         int tile_Ox;
00823         int tile_Oy;
00825         int tw;
00827         int th;
00829         int numcomps;
00831         int numlayers;
00833         int *numdecompos;
00834 /* UniPG>> */
00836         int marknum;
00838         opj_marker_info_t *marker;
00840         int maxmarknum;
00841 /* <<UniPG */
00843         int main_head_start;
00845         int main_head_end;
00847         int codestream_size;
00849         opj_tile_info_t *tile;
00850 } opj_codestream_info_t;
00851 
00852 /* <----------------------------------------------------------- */
00853 /* new output management of the codestream information and index */
00854 
00858 typedef struct opj_tccp_info
00859 {
00861         OPJ_UINT32 compno;
00863         OPJ_UINT32 csty;
00865         OPJ_UINT32 numresolutions;
00867         OPJ_UINT32 cblkw;
00869         OPJ_UINT32 cblkh;
00871         OPJ_UINT32 cblksty;
00873         OPJ_UINT32 qmfbid;
00875         OPJ_UINT32 qntsty;
00877         OPJ_UINT32 stepsizes_mant[OPJ_J2K_MAXBANDS];
00879         OPJ_UINT32 stepsizes_expn[OPJ_J2K_MAXBANDS];
00881         OPJ_UINT32 numgbits;
00883         OPJ_INT32 roishift;
00885         OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS];
00887         OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS];
00888 }
00889 opj_tccp_info_t;
00890 
00894 typedef struct opj_tile_v2_info {
00895 
00897         int tileno;
00899         OPJ_UINT32 csty;
00901         OPJ_PROG_ORDER prg;
00903         OPJ_UINT32 numlayers;
00905         OPJ_UINT32 mct;
00906 
00908         opj_tccp_info_t *tccp_info;
00909 
00910 } opj_tile_info_v2_t;
00911 
00915 typedef struct opj_codestream_info_v2 {
00916         /* Tile info */
00918         OPJ_UINT32 tx0;
00920         OPJ_UINT32 ty0;
00922         OPJ_UINT32 tdx;
00924         OPJ_UINT32 tdy;
00926         OPJ_UINT32 tw;
00928         OPJ_UINT32 th;
00929 
00931         OPJ_UINT32 nbcomps;
00932 
00934         opj_tile_info_v2_t m_default_tile_info;
00935 
00937         opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */
00938 
00939 } opj_codestream_info_v2_t;
00940 
00941 
00945 typedef struct opj_tp_index {
00947         OPJ_OFF_T start_pos;
00949         OPJ_OFF_T end_header;
00951         OPJ_OFF_T end_pos;
00952 
00953 } opj_tp_index_t;
00954 
00958 typedef struct opj_tile_index {
00960         OPJ_UINT32 tileno;
00961 
00963         OPJ_UINT32 nb_tps;
00965         OPJ_UINT32 current_nb_tps;
00967         OPJ_UINT32 current_tpsno;
00969         opj_tp_index_t *tp_index;
00970 
00971         /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
00973                 OPJ_UINT32 marknum;
00975                 opj_marker_info_t *marker;
00977                 OPJ_UINT32 maxmarknum;
00978         /* <<UniPG */
00979 
00981         OPJ_UINT32 nb_packet;
00983         opj_packet_info_t *packet_index;
00984 
00985 } opj_tile_index_t;
00986 
00990 typedef struct opj_codestream_index {
00992         OPJ_OFF_T main_head_start;
00994         OPJ_OFF_T main_head_end;
00995 
00997         OPJ_UINT64 codestream_size;
00998 
00999 /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
01001         OPJ_UINT32 marknum;
01003         opj_marker_info_t *marker;
01005         OPJ_UINT32 maxmarknum;
01006 /* <<UniPG */
01007 
01009         OPJ_UINT32 nb_of_tiles;
01011         opj_tile_index_t *tile_index; /* FIXME not used for the moment */
01012 
01013 }opj_codestream_index_t;
01014 /* -----------------------------------------------------------> */
01015 
01016 /*
01017 ==========================================================
01018    Metadata from the JP2file
01019 ==========================================================
01020 */
01021 
01026 typedef struct opj_jp2_metadata {
01028         OPJ_INT32       not_used;
01029 
01030 } opj_jp2_metadata_t;
01031 
01036 typedef struct opj_jp2_index {
01038         OPJ_INT32       not_used;
01039 
01040 } opj_jp2_index_t;
01041 
01042 
01043 #ifdef __cplusplus
01044 extern "C" {
01045 #endif
01046 
01047 
01048 /* 
01049 ==========================================================
01050    openjpeg version
01051 ==========================================================
01052 */
01053 
01054 /* Get the version of the openjpeg library*/
01055 OPJ_API const char * OPJ_CALLCONV opj_version(void);
01056 
01057 /* 
01058 ==========================================================
01059    image functions definitions
01060 ==========================================================
01061 */
01062 
01071 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
01072 
01078 OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
01079 
01089 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
01090 
01091 /* 
01092 ==========================================================
01093    stream functions definitions
01094 ==========================================================
01095 */
01096 
01104 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create(OPJ_BOOL p_is_input);
01105 
01114 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size, OPJ_BOOL p_is_input);
01115 
01122 OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream);
01123  
01129 OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_stream_read_fn p_function);
01130 
01136 OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, opj_stream_write_fn p_function);
01137 
01143 OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, opj_stream_skip_fn p_function);
01144 
01150 OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, opj_stream_seek_fn p_function);
01151 
01158 OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data, opj_stream_free_user_data_fn p_function);
01159 
01166 OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream, OPJ_UINT64 data_length);
01167 
01173 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (const char *fname, OPJ_BOOL p_is_read_stream);
01174  
01180 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (const char *fname,
01181                                                                      OPJ_SIZE_T p_buffer_size,
01182                                                                      OPJ_BOOL p_is_read_stream);
01183  
01184 /* 
01185 ==========================================================
01186    event manager functions definitions
01187 ==========================================================
01188 */
01195 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, 
01196                                                    opj_msg_callback p_callback,
01197                                                    void * p_user_data);
01204 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec,
01205                                                       opj_msg_callback p_callback,
01206                                                       void * p_user_data);
01213 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, 
01214                                                     opj_msg_callback p_callback,
01215                                                     void * p_user_data);
01216 
01217 /* 
01218 ==========================================================
01219    codec functions definitions
01220 ==========================================================
01221 */
01222 
01229 OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
01230 
01236 OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec);
01237 
01243 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_decompress (      opj_codec_t *p_codec,
01244                                                                                                         opj_stream_t *p_stream);
01245 
01246 
01251 OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
01252 
01262 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
01263                                                                                                 opj_dparameters_t *parameters );
01264 
01274 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_header ( opj_stream_t *p_stream,
01275                                                                                                 opj_codec_t *p_codec,
01276                                                                                                 opj_image_t **p_image);
01277 
01290 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(      opj_codec_t *p_codec,
01291                                                                                                         opj_image_t* p_image,
01292                                                                                                         OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
01293                                                                                                         OPJ_INT32 p_end_x, OPJ_INT32 p_end_y );
01294 
01303 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode(   opj_codec_t *p_decompressor,
01304                                             opj_stream_t *p_stream,
01305                                             opj_image_t *p_image);
01306 
01317 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(     opj_codec_t *p_codec,
01318                                                                                                         opj_stream_t *p_stream,
01319                                                                                                         opj_image_t *p_image,
01320                                                                                                         OPJ_UINT32 tile_index);
01321 
01329 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OPJ_UINT32 res_factor);
01330 
01343 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_write_tile (  opj_codec_t *p_codec,
01344                                                                                                 OPJ_UINT32 p_tile_index,
01345                                                                                                 OPJ_BYTE * p_data,
01346                                                                                                 OPJ_UINT32 p_data_size,
01347                                                                                                 opj_stream_t *p_stream );
01348 
01370 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_tile_header(     opj_codec_t *p_codec,
01371                                                                                                 opj_stream_t * p_stream,
01372                                                                                                 OPJ_UINT32 * p_tile_index,
01373                                                                                                 OPJ_UINT32 * p_data_size,
01374                                                                                                 OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
01375                                                                                                 OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
01376                                                                                                 OPJ_UINT32 * p_nb_comps,
01377                                                                                                 OPJ_BOOL * p_should_go_on );
01378 
01391 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(     opj_codec_t *p_codec,
01392                                                                                                         OPJ_UINT32 p_tile_index,
01393                                                                                                         OPJ_BYTE * p_data,
01394                                                                                                         OPJ_UINT32 p_data_size,
01395                                                                                                         opj_stream_t *p_stream );
01396 
01397 /* COMPRESSION FUNCTIONS*/
01398 
01404 OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
01405 
01427 OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
01428 
01435 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec, 
01436                                                                                                 opj_cparameters_t *parameters, 
01437                                                                                                 opj_image_t *image);
01438 
01445 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_start_compress (      opj_codec_t *p_codec,
01446                                                                                                         opj_image_t * p_image,
01447                                                                                                         opj_stream_t *p_stream);
01448 
01454 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec,
01455                                                                                                 opj_stream_t *p_stream);
01456 
01464 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_codec,
01465                                          opj_stream_t *p_stream);
01466 /*
01467 ==========================================================
01468    codec output functions definitions
01469 ==========================================================
01470 */
01471 /* EXPERIMENTAL FUNCTIONS FOR NOW, USED ONLY IN J2K_DUMP*/
01472 
01477 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t **cstr_info);
01478 
01479 
01488 OPJ_API void OPJ_CALLCONV opj_dump_codec(       opj_codec_t *p_codec,
01489                                                                                         OPJ_INT32 info_flag,
01490                                                                                         FILE* output_stream);
01491 
01500 OPJ_API opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(opj_codec_t *p_codec);
01501 
01510 OPJ_API opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(opj_codec_t *p_codec);
01511 
01512 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index);
01513 
01514 
01523 OPJ_API opj_jp2_metadata_t* OPJ_CALLCONV opj_get_jp2_metadata(opj_codec_t *p_codec);
01524 
01533 OPJ_API opj_jp2_index_t* OPJ_CALLCONV opj_get_jp2_index(opj_codec_t *p_codec);
01534 
01535 
01536 /*
01537 ==========================================================
01538    MCT functions
01539 ==========================================================
01540 */
01541 
01552 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_MCT( opj_cparameters_t *parameters,
01553                                                    OPJ_FLOAT32 * pEncodingMatrix,
01554                                                    OPJ_INT32 * p_dc_shift,
01555                                                    OPJ_UINT32 pNbComp);
01556 
01557 
01558 
01559 #ifdef __cplusplus
01560 }
01561 #endif
01562 
01563 #endif /* OPENJPEG_H */