Create separate type for bit-fields.
[openjpeg.git] / src / lib / openjp2 / j2k.h
index bff80bece7a3629ff7aed13d8dcc641638f2ad29..cc725b79af0c65f70ffbb92fe69560d4ae24a8b6 100644 (file)
@@ -1,13 +1,20 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * Copyright (c) 2006-2007, Parvatha Elangovan
  * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * Copyright (c) 2011, Mickael Savinaud, Communications & Systemes <mickael.savinaud@c-s.fr>
+ * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France 
+ * Copyright (c) 2012, CS Systemes d'Information, France
  *
  * All rights reserved.
  *
@@ -58,6 +65,8 @@ The functions in J2K.C have for goal to read/write the several parts of the code
 #define J2K_CCP_QNTSTY_SIQNT 1
 #define J2K_CCP_QNTSTY_SEQNT 2
 
+#define OPJ_J2K_DEFAULT_CBLK_DATA_SIZE 8192
+
 /* ----------------------------------------------------------------------- */
 
 #define J2K_MS_SOC 0xff4f      /**< SOC marker value */
@@ -156,9 +165,9 @@ typedef enum T2_MODE {
  */
 typedef struct opj_stepsize {
        /** exponent */
-       int expn;
+       OPJ_INT32 expn;
        /** mantissa */
-       int mant;
+       OPJ_INT32 mant;
 } opj_stepsize_t;
 
 /**
@@ -181,60 +190,21 @@ typedef struct opj_tccp
        /** quantisation style */
        OPJ_UINT32 qntsty;
        /** stepsizes used for quantization */
-       opj_stepsize_t stepsizes[J2K_MAXBANDS];
+       opj_stepsize_t stepsizes[OPJ_J2K_MAXBANDS];
        /** number of guard bits */
        OPJ_UINT32 numgbits;
        /** Region Of Interest shift */
        OPJ_INT32 roishift;
        /** precinct width */
-       OPJ_UINT32 prcw[J2K_MAXRLVLS];
+       OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS];
        /** precinct height */
-       OPJ_UINT32 prch[J2K_MAXRLVLS];
+       OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS];
        /** the dc_level_shift **/
        OPJ_INT32 m_dc_level_shift;
 }
 opj_tccp_t;
 
 
-/** V1 STYLE
-Tile coding parameters : 
-this structure is used to store coding/decoding parameters common to all
-tiles (information like COD, COC in main header)
-*/
-typedef struct opj_tcp {
-       /** 1 : first part-tile of a tile */
-       int first;
-       /** coding style */
-       int csty;
-       /** progression order */
-       OPJ_PROG_ORDER prg;
-       /** number of layers */
-       int numlayers;
-       /** multi-component transform identifier */
-       int mct;
-       /** rates of layers */
-       float rates[100];
-       /** number of progression order changes */
-       int numpocs;
-       /** indicates if a POC marker has been used O:NO, 1:YES */
-       int POC;
-       /** progression order changes */
-       opj_poc_t pocs[32];
-       /** packet header store there for futur use in t2_decode_packet */
-       unsigned char *ppt_data;
-       /** pointer remaining on the first byte of the first header if ppt is used */
-       unsigned char *ppt_data_first;
-       /** If ppt == 1 --> there was a PPT marker for the present tile */
-       int ppt;
-       /** used in case of multiple marker PPT (number of info already stored) */
-       int ppt_store;
-       /** ppmbug1 */
-       int ppt_len;
-       /** add fixed_quality */
-       float distoratio[100];
-       /** tile-component coding parameters */
-       opj_tccp_t *tccps;
-} opj_tcp_t;
 
 /**
  * FIXME DOC
@@ -258,16 +228,22 @@ typedef struct opj_simple_mcc_decorrelation_data
        OPJ_UINT32                       m_nb_comps;
        opj_mct_data_t *         m_decorrelation_array;
        opj_mct_data_t *         m_offset_array;
-       OPJ_UINT32                       m_is_irreversible : 1;
+       OPJ_BITFIELD             m_is_irreversible : 1;
 }
 opj_simple_mcc_decorrelation_data_t;
 
+typedef struct opj_ppx_struct
+{
+       OPJ_BYTE*   m_data; /* m_data == NULL => Zppx not read yet */
+       OPJ_UINT32      m_data_size;
+} opj_ppx;
+
 /**
 Tile coding parameters :
 this structure is used to store coding/decoding parameters common to all
 tiles (information like COD, COC in main header)
 */
-typedef struct opj_tcp_v2
+typedef struct opj_tcp
 {
        /** coding style */
        OPJ_UINT32 csty;
@@ -284,7 +260,13 @@ typedef struct opj_tcp_v2
        OPJ_UINT32 numpocs;
        /** progression order changes */
        opj_poc_t pocs[32];
-       /** packet header store there for futur use in t2_decode_packet */
+       
+       /** number of ppt markers (reserved size) */
+       OPJ_UINT32 ppt_markers_count;
+       /** ppt markers data (table indexed by Zppt) */
+       opj_ppx* ppt_markers;
+       
+       /** packet header store there for future use in t2_decode_packet */
        OPJ_BYTE *ppt_data;
        /** used to keep a track of the allocated memory */
        OPJ_BYTE *ppt_buffer;
@@ -323,130 +305,19 @@ typedef struct opj_tcp_v2
 
 
        /***** FLAGS *******/
+       /** If cod == 1 --> there was a COD marker for the present tile */
+       OPJ_BITFIELD cod : 1;
        /** If ppt == 1 --> there was a PPT marker for the present tile */
-       OPJ_UINT32 ppt : 1;
+       OPJ_BITFIELD ppt : 1;
        /** indicates if a POC marker has been used O:NO, 1:YES */
-       OPJ_UINT32 POC : 1;
-} opj_tcp_v2_t;
-
-
+       OPJ_BITFIELD POC : 1;
+} opj_tcp_t;
 
 
 
-/** V1 STYLE
-Coding parameters
-*/
-typedef struct opj_cp {
-       /** Digital cinema profile*/
-       OPJ_CINEMA_MODE cinema;
-       /** Maximum rate for each component. If == 0, component size limitation is not considered */
-       int max_comp_size;
-       /** Size of the image in bits*/
-       int img_size;
-       /** Rsiz*/
-       OPJ_RSIZ_CAPABILITIES rsiz;
-       /** Enabling Tile part generation*/
-       char tp_on;
-       /** Flag determining tile part generation*/
-       char tp_flag;
-       /** Position of tile part flag in progression order*/
-       int tp_pos;
-       /** allocation by rate/distortion */
-       int disto_alloc;
-       /** allocation by fixed layer */
-       int fixed_alloc;
-       /** add fixed_quality */
-       int fixed_quality;
-       /** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */
-       int reduce;
-       /** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
-       int layer;
-       /** if == NO_LIMITATION, decode entire codestream; if == LIMIT_TO_MAIN_HEADER then only decode the main header */
-       OPJ_LIMIT_DECODING limit_decoding;
-       /** XTOsiz */
-       int tx0;
-       /** YTOsiz */
-       int ty0;
-       /** XTsiz */
-       int tdx;
-       /** YTsiz */
-       int tdy;
-       /** comment for coding */
-       char *comment;
-       /** number of tiles in width */
-       int tw;
-       /** number of tiles in heigth */
-       int th;
-       /** ID number of the tiles present in the codestream */
-       int *tileno;
-       /** size of the vector tileno */
-       int tileno_size;
-       /** packet header store there for futur use in t2_decode_packet */
-       unsigned char *ppm_data;
-       /** pointer remaining on the first byte of the first header if ppm is used */
-       unsigned char *ppm_data_first;
-       /** if ppm == 1 --> there was a PPM marker for the present tile */
-       int ppm;
-       /** use in case of multiple marker PPM (number of info already store) */
-       int ppm_store;
-       /** use in case of multiple marker PPM (case on non-finished previous info) */
-       int ppm_previous;
-       /** ppmbug1 */
-       int ppm_len;
-       /** tile coding parameters */
-       opj_tcp_t *tcps;
-       /** fixed layer */
-       int *matrice;
-/* UniPG>> */
-#ifdef USE_JPWL
-       /** enables writing of EPC in MH, thus activating JPWL */
-       opj_bool epc_on;
-       /** enables writing of EPB, in case of activated JPWL */
-       opj_bool epb_on;
-       /** enables writing of ESD, in case of activated JPWL */
-       opj_bool esd_on;
-       /** enables writing of informative techniques of ESD, in case of activated JPWL */
-       opj_bool info_on;
-       /** enables writing of RED, in case of activated JPWL */
-       opj_bool red_on;
-       /** error protection method for MH (0,1,16,32,37-128) */
-       int hprot_MH;
-       /** tile number of header protection specification (>=0) */
-       int hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-       /** error protection methods for TPHs (0,1,16,32,37-128) */
-       int hprot_TPH[JPWL_MAX_NO_TILESPECS];
-       /** tile number of packet protection specification (>=0) */
-       int pprot_tileno[JPWL_MAX_NO_PACKSPECS];
-       /** packet number of packet protection specification (>=0) */
-       int pprot_packno[JPWL_MAX_NO_PACKSPECS];
-       /** error protection methods for packets (0,1,16,32,37-128) */
-       int pprot[JPWL_MAX_NO_PACKSPECS];
-       /** enables writing of ESD, (0/2/4 bytes) */
-       int sens_size;
-       /** sensitivity addressing size (0=auto/2/4 bytes) */
-       int sens_addr;
-       /** sensitivity range (0-3) */
-       int sens_range;
-       /** sensitivity method for MH (-1,0-7) */
-       int sens_MH;
-       /** tile number of sensitivity specification (>=0) */
-       int sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-       /** sensitivity methods for TPHs (-1,0-7) */
-       int sens_TPH[JPWL_MAX_NO_TILESPECS];
-       /** enables JPWL correction at the decoder */
-       opj_bool correct;
-       /** expected number of components at the decoder */
-       int exp_comps;
-       /** maximum number of tiles at the decoder */
-       int max_tiles;
-#endif /* USE_JPWL */
-/* <<UniPG */
-} opj_cp_t;
 
 typedef struct opj_encoding_param
 {
-       /** Digital cinema profile*/
-       OPJ_CINEMA_MODE m_cinema;
        /** Maximum rate for each component. If == 0, component size limitation is not considered */
        OPJ_UINT32 m_max_comp_size;
        /** Position of tile part flag in progression order*/
@@ -456,13 +327,13 @@ typedef struct opj_encoding_param
        /** Flag determining tile part generation*/
        OPJ_BYTE m_tp_flag;
        /** allocation by rate/distortion */
-       OPJ_UINT32 m_disto_alloc : 1;
+       OPJ_BITFIELD m_disto_alloc : 1;
        /** allocation by fixed layer */
-       OPJ_UINT32 m_fixed_alloc : 1;
+       OPJ_BITFIELD m_fixed_alloc : 1;
        /** add fixed_quality */
-       OPJ_UINT32 m_fixed_quality : 1;
+       OPJ_BITFIELD m_fixed_quality : 1;
        /** Enabling Tile part generation*/
-       OPJ_UINT32 m_tp_on : 1;
+       OPJ_BITFIELD m_tp_on : 1;
 }
 opj_encoding_param_t;
 
@@ -479,12 +350,12 @@ opj_decoding_param_t;
 /**
  * Coding parameters
  */
-typedef struct opj_cp_v2
+typedef struct opj_cp
 {
        /** Size of the image in bits*/
        /*int img_size;*/
        /** Rsiz*/
-       OPJ_RSIZ_CAPABILITIES rsiz;
+    OPJ_UINT16 rsiz;
        /** XTOsiz */
        OPJ_UINT32 tx0; /* MSD see norm */
        /** YTOsiz */
@@ -500,7 +371,12 @@ typedef struct opj_cp_v2
        /** number of tiles in heigth */
        OPJ_UINT32 th;
 
-       /** packet header store there for futur use in t2_decode_packet */
+       /** number of ppm markers (reserved size) */
+       OPJ_UINT32 ppm_markers_count;
+       /** ppm markers data (table indexed by Zppm) */
+       opj_ppx* ppm_markers;
+       
+       /** packet header store there for future use in t2_decode_packet */
        OPJ_BYTE *ppm_data;
        /** size of the ppm_data*/
        OPJ_UINT32 ppm_len;
@@ -521,7 +397,7 @@ typedef struct opj_cp_v2
        OPJ_INT32 ppm_previous;
 
        /** tile coding parameters */
-       opj_tcp_v2_t *tcps;
+       opj_tcp_t *tcps;
 
        union
        {
@@ -534,15 +410,15 @@ typedef struct opj_cp_v2
 /* UniPG>> */
 #ifdef USE_JPWL
        /** enables writing of EPC in MH, thus activating JPWL */
-       opj_bool epc_on;
+       OPJ_BOOL epc_on;
        /** enables writing of EPB, in case of activated JPWL */
-       opj_bool epb_on;
+       OPJ_BOOL epb_on;
        /** enables writing of ESD, in case of activated JPWL */
-       opj_bool esd_on;
+       OPJ_BOOL esd_on;
        /** enables writing of informative techniques of ESD, in case of activated JPWL */
-       opj_bool info_on;
+       OPJ_BOOL info_on;
        /** enables writing of RED, in case of activated JPWL */
-       opj_bool red_on;
+       OPJ_BOOL red_on;
        /** error protection method for MH (0,1,16,32,37-128) */
        int hprot_MH;
        /** tile number of header protection specification (>=0) */
@@ -568,7 +444,7 @@ typedef struct opj_cp_v2
        /** sensitivity methods for TPHs (-1,0-7) */
        int sens_TPH[JPWL_MAX_NO_TILESPECS];
        /** enables JPWL correction at the decoder */
-       opj_bool correct;
+       OPJ_BOOL correct;
        /** expected number of components at the decoder */
        int exp_comps;
        /** maximum number of tiles at the decoder */
@@ -577,11 +453,11 @@ typedef struct opj_cp_v2
 
        /******** FLAGS *********/
        /** if ppm == 1 --> there was a PPM marker*/
-       OPJ_UINT32 ppm : 1;
+       OPJ_BITFIELD ppm : 1;
        /** tells if the parameter is a coding or decoding one */
-       OPJ_UINT32 m_is_decoder : 1;
+       OPJ_BITFIELD m_is_decoder : 1;
 /* <<UniPG */
-} opj_cp_v2_t;
+} opj_cp_t;
 
 
 typedef struct opj_j2k_dec
@@ -591,7 +467,7 @@ typedef struct opj_j2k_dec
        /**
         * store decoding parameters common to all tiles (information like COD, COC in main header)
         */
-       opj_tcp_v2_t *m_default_tcp;
+       opj_tcp_t *m_default_tcp;
        OPJ_BYTE  *m_header_data;
        OPJ_UINT32 m_header_data_size;
        /** to tell the tile part length */
@@ -619,11 +495,14 @@ typedef struct opj_j2k_dec
         * It is useful in the case of PSot is equal to zero. The sot length will be compute in the
         * SOD reader function. FIXME NOT USED for the moment
         */
-       opj_bool   m_last_tile_part;
+       OPJ_BOOL   m_last_tile_part;
        /** to tell that a tile can be decoded. */
-       OPJ_UINT32 m_can_decode                 : 1;
-       OPJ_UINT32 m_discard_tiles              : 1;
-       OPJ_UINT32 m_skip_data                  : 1;
+       OPJ_BITFIELD m_can_decode         : 1;
+       OPJ_BITFIELD m_discard_tiles  : 1;
+       OPJ_BITFIELD m_skip_data          : 1;
+       /** TNsot correction : see issue 254 **/
+       OPJ_BITFIELD m_nb_tile_parts_correction_checked : 1;
+       OPJ_BITFIELD m_nb_tile_parts_correction : 1;
 
 } opj_j2k_dec_t;
 
@@ -670,14 +549,14 @@ typedef struct opj_j2k_enc
 
 
 
-struct opj_tcd_v2;
+struct opj_tcd;
 /**
 JPEG-2000 codestream reader/writer
 */
 typedef struct opj_j2k
 {
        /* J2K codestream is decoded*/
-       opj_bool m_is_decoder;
+       OPJ_BOOL m_is_decoder;
 
        /* FIXME DOC*/
        union
@@ -694,13 +573,13 @@ typedef struct opj_j2k
        opj_image_t* m_output_image;
 
        /** Coding parameters */
-       opj_cp_v2_t m_cp;
+       opj_cp_t m_cp;
 
        /** the list of procedures to exec **/
-       struct opj_procedure_list *     m_procedure_list;
+       opj_procedure_list_t *  m_procedure_list;
 
        /** the list of validation procedures to follow to make sure the code is valid **/
-       struct opj_procedure_list *     m_validation_list;
+       opj_procedure_list_t *  m_validation_list;
 
        /** helper used to write the index file */
        opj_codestream_index_t *cstr_index;
@@ -709,8 +588,7 @@ typedef struct opj_j2k
        OPJ_UINT32 m_current_tile_number;
 
        /** the current tile coder/decoder **/
-       struct opj_tcd_v2 *     m_tcd;
-
+       struct opj_tcd *        m_tcd;
 }
 opj_j2k_t;
 
@@ -737,7 +615,7 @@ void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
 opj_j2k_t* opj_j2k_create_compress(void);
 
 
-void opj_j2k_setup_encoder(    opj_j2k_t *p_j2k,
+OPJ_BOOL opj_j2k_setup_encoder(        opj_j2k_t *p_j2k,
                                                    opj_cparameters_t *parameters,
                                                    opj_image_t *image,
                                                    opj_event_mgr_t * p_manager);
@@ -756,7 +634,7 @@ char *opj_j2k_convert_progression_order(OPJ_PROG_ORDER prg_order);
  * Ends the decompression procedures and possibiliy add data to be read after the
  * codestream.
  */
-opj_bool opj_j2k_end_decompress(opj_j2k_t *j2k,
+OPJ_BOOL opj_j2k_end_decompress(opj_j2k_t *j2k,
                                 opj_stream_private_t *p_stream,
                                 opj_event_mgr_t * p_manager);
 
@@ -770,7 +648,7 @@ opj_bool opj_j2k_end_decompress(opj_j2k_t *j2k,
  *
  * @return true if the box is valid.
  */
-opj_bool opj_j2k_read_header(  opj_stream_private_t *p_stream,
+OPJ_BOOL opj_j2k_read_header(  opj_stream_private_t *p_stream,
                                 opj_j2k_t* p_j2k,
                                 opj_image_t** p_image,
                                 opj_event_mgr_t* p_manager );
@@ -799,7 +677,7 @@ void j2k_destroy_cstr_index (opj_codestream_index_t *p_cstr_ind);
  * @param      p_stream                        the stream to write data to.
  * @param      p_manager       the user event manager.
  */
-opj_bool opj_j2k_decode_tile (  opj_j2k_t * p_j2k,
+OPJ_BOOL opj_j2k_decode_tile (  opj_j2k_t * p_j2k,
                                 OPJ_UINT32 p_tile_index,
                                 OPJ_BYTE * p_data,
                                 OPJ_UINT32 p_data_size,
@@ -820,7 +698,7 @@ opj_bool opj_j2k_decode_tile (  opj_j2k_t * p_j2k,
  * @param      p_stream                        the stream to write data to.
  * @param      p_manager       the user event manager.
  */
-opj_bool opj_j2k_read_tile_header ( opj_j2k_t * p_j2k,
+OPJ_BOOL opj_j2k_read_tile_header ( opj_j2k_t * p_j2k,
                                     OPJ_UINT32 * p_tile_index,
                                     OPJ_UINT32 * p_data_size,
                                     OPJ_INT32 * p_tile_x0,
@@ -828,7 +706,7 @@ opj_bool opj_j2k_read_tile_header ( opj_j2k_t * p_j2k,
                                     OPJ_INT32 * p_tile_x1,
                                     OPJ_INT32 * p_tile_y1,
                                     OPJ_UINT32 * p_nb_comps,
-                                    opj_bool * p_go_on,
+                                    OPJ_BOOL * p_go_on,
                                     opj_stream_private_t *p_stream,
                                     opj_event_mgr_t * p_manager );
 
@@ -846,7 +724,7 @@ opj_bool opj_j2k_read_tile_header ( opj_j2k_t * p_j2k,
  *
  * @return     true                    if the area could be set.
  */
-opj_bool opj_j2k_set_decode_area(      opj_j2k_t *p_j2k,
+OPJ_BOOL opj_j2k_set_decode_area(      opj_j2k_t *p_j2k,
                                                                    opj_image_t* p_image,
                                                                    OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
                                                                    OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
@@ -879,7 +757,7 @@ void j2k_dump (opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream);
  *@param dev_dump_flag         flag to describe if we are in the case of this function is use outside j2k_dump function
  *@param out_stream                    output stream where dump the elements.
  */
-void j2k_dump_image_header(opj_image_t* image, opj_bool dev_dump_flag, FILE* out_stream);
+void j2k_dump_image_header(opj_image_t* image, OPJ_BOOL dev_dump_flag, FILE* out_stream);
 
 /**
  * Dump a component image header structure.
@@ -888,7 +766,7 @@ void j2k_dump_image_header(opj_image_t* image, opj_bool dev_dump_flag, FILE* out
  *@param dev_dump_flag         flag to describe if we are in the case of this function is use outside j2k_dump function
  *@param out_stream                    output stream where dump the elements.
  */
-void j2k_dump_image_comp_header(opj_image_comp_t* comp, opj_bool dev_dump_flag, FILE* out_stream);
+void j2k_dump_image_comp_header(opj_image_comp_t* comp, OPJ_BOOL dev_dump_flag, FILE* out_stream);
 
 /**
  * Get the codestream info from a JPEG2000 codec.
@@ -916,19 +794,19 @@ opj_codestream_index_t* j2k_get_cstr_index(opj_j2k_t* p_j2k);
  * @param p_manager FIXME DOC
  * @return FIXME DOC
 */
-opj_bool opj_j2k_decode(opj_j2k_t *j2k,
+OPJ_BOOL opj_j2k_decode(opj_j2k_t *j2k,
                         opj_stream_private_t *p_stream,
                         opj_image_t *p_image,
                         opj_event_mgr_t *p_manager);
 
 
-opj_bool opj_j2k_get_tile(     opj_j2k_t *p_j2k,
+OPJ_BOOL opj_j2k_get_tile(     opj_j2k_t *p_j2k,
                                                opj_stream_private_t *p_stream,
                                                opj_image_t* p_image,
                                                opj_event_mgr_t * p_manager,
                                                    OPJ_UINT32 tile_index );
 
-opj_bool opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k, 
+OPJ_BOOL opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k, 
                                                OPJ_UINT32 res_factor,
                                                opj_event_mgr_t * p_manager);
 
@@ -942,7 +820,7 @@ opj_bool opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k,
  * @param      p_stream                        the stream to write data to.
  * @param      p_manager       the user event manager.
  */
-opj_bool opj_j2k_write_tile (  opj_j2k_t * p_j2k,
+OPJ_BOOL opj_j2k_write_tile (  opj_j2k_t * p_j2k,
                                                            OPJ_UINT32 p_tile_index,
                                                            OPJ_BYTE * p_data,
                                                            OPJ_UINT32 p_data_size,
@@ -952,7 +830,7 @@ opj_bool opj_j2k_write_tile (       opj_j2k_t * p_j2k,
 /**
  * Encodes an image into a JPEG-2000 codestream
  */
-opj_bool opj_j2k_encode_v2(    opj_j2k_t * p_j2k,
+OPJ_BOOL opj_j2k_encode(       opj_j2k_t * p_j2k,
                                                opj_stream_private_t *cio,
                                                opj_event_mgr_t * p_manager );
 
@@ -966,7 +844,7 @@ opj_bool opj_j2k_encode_v2( opj_j2k_t * p_j2k,
  *
  * @return true if the codec is valid.
  */
-opj_bool opj_j2k_start_compress(opj_j2k_t *p_j2k,
+OPJ_BOOL opj_j2k_start_compress(opj_j2k_t *p_j2k,
                                                            opj_stream_private_t *p_stream,
                                                            opj_image_t * p_image,
                                                            opj_event_mgr_t * p_manager);
@@ -975,11 +853,11 @@ opj_bool opj_j2k_start_compress(opj_j2k_t *p_j2k,
  * Ends the compression procedures and possibiliy add data to be read after the
  * codestream.
  */
-opj_bool opj_j2k_end_compress(         opj_j2k_t *p_j2k,
+OPJ_BOOL opj_j2k_end_compress(         opj_j2k_t *p_j2k,
                                                            opj_stream_private_t *cio,
                                                            opj_event_mgr_t * p_manager);
 
-opj_bool opj_j2k_setup_mct_encoding (opj_tcp_v2_t * p_tcp, opj_image_t * p_image);
+OPJ_BOOL opj_j2k_setup_mct_encoding (opj_tcp_t * p_tcp, opj_image_t * p_image);
 
 
 #endif /* __J2K_H */