/* * 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 * 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 <[email protected]> * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France * Copyright (c) 2012, CS Systemes d'Information, France * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef OPJ_J2K_H #define OPJ_J2K_H /** @file j2k.h @brief The JPEG-2000 Codestream Reader/Writer (J2K) The functions in J2K.C have for goal to read/write the several parts of the codestream: markers and data. */ /** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */ /*@{*/ #define J2K_CP_CSTY_PRT … #define J2K_CP_CSTY_SOP … #define J2K_CP_CSTY_EPH … #define J2K_CCP_CSTY_PRT … #define J2K_CCP_CBLKSTY_LAZY … #define J2K_CCP_CBLKSTY_RESET … #define J2K_CCP_CBLKSTY_TERMALL … #define J2K_CCP_CBLKSTY_VSC … #define J2K_CCP_CBLKSTY_PTERM … #define J2K_CCP_CBLKSTY_SEGSYM … #define J2K_CCP_CBLKSTY_HT … #define J2K_CCP_CBLKSTY_HTMIXED … #define J2K_CCP_QNTSTY_NOQNT … #define J2K_CCP_QNTSTY_SIQNT … #define J2K_CCP_QNTSTY_SEQNT … /* ----------------------------------------------------------------------- */ #define J2K_MS_SOC … #define J2K_MS_SOT … #define J2K_MS_SOD … #define J2K_MS_EOC … #define J2K_MS_CAP … #define J2K_MS_SIZ … #define J2K_MS_COD … #define J2K_MS_COC … #define J2K_MS_CPF … #define J2K_MS_RGN … #define J2K_MS_QCD … #define J2K_MS_QCC … #define J2K_MS_POC … #define J2K_MS_TLM … #define J2K_MS_PLM … #define J2K_MS_PLT … #define J2K_MS_PPM … #define J2K_MS_PPT … #define J2K_MS_SOP … #define J2K_MS_EPH … #define J2K_MS_CRG … #define J2K_MS_COM … #define J2K_MS_CBD … #define J2K_MS_MCC … #define J2K_MS_MCT … #define J2K_MS_MCO … #define J2K_MS_UNK … /* UniPG>> */ #ifdef USE_JPWL #define J2K_MS_EPC … #define J2K_MS_EPB … #define J2K_MS_ESD … #define J2K_MS_RED … #endif /* USE_JPWL */ #ifdef USE_JPSEC #define J2K_MS_SEC … #define J2K_MS_INSEC … #endif /* USE_JPSEC */ /* <<UniPG */ #define J2K_MAX_POCS … #define J2K_TCD_MATRIX_MAX_LAYER_COUNT … #define J2K_TCD_MATRIX_MAX_RESOLUTION_COUNT … /* ----------------------------------------------------------------------- */ /** * Values that specify the status of the decoding process when decoding the main header. * These values may be combined with a | operator. * */ J2K_STATUS; /** * Type of elements storing in the MCT data */ J2K_MCT_ELEMENT_TYPE; /** * Type of MCT array */ J2K_MCT_ARRAY_TYPE; /* ----------------------------------------------------------------------- */ /** T2 encoding mode */ J2K_T2_MODE; /** * Quantization stepsize */ opj_stepsize_t; /** Tile-component coding parameters */ opj_tccp_t; /** * FIXME DOC */ opj_mct_data_t; /** * FIXME DOC */ opj_simple_mcc_decorrelation_data_t; 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) */ opj_tcp_t; /** Rate allocation strategy */ J2K_QUALITY_LAYER_ALLOCATION_STRATEGY; opj_encoding_param_t; opj_decoding_param_t; /** * Coding parameters */ opj_cp_t; opj_j2k_dec_t; opj_j2k_enc_t; struct opj_tcd; /** JPEG-2000 codestream reader/writer */ opj_j2k_t; /** @name Exported functions */ /*@{*/ /* ----------------------------------------------------------------------- */ /** Setup the decoder decoding parameters using user parameters. Decoding parameters are returned in p_j2k->cp. @param p_j2k J2K decompressor handle @param parameters decompression parameters */ void opj_j2k_setup_decoder(void *p_j2k, opj_dparameters_t *parameters); void opj_j2k_decoder_set_strict_mode(void *j2k, OPJ_BOOL strict); OPJ_BOOL opj_j2k_set_threads(void *j2k, OPJ_UINT32 num_threads); /** * Creates a J2K compression structure * * @return Returns a handle to a J2K compressor if successful, returns NULL otherwise */ opj_j2k_t* opj_j2k_create_compress(void); OPJ_BOOL opj_j2k_setup_encoder(void *p_j2k, opj_cparameters_t *parameters, opj_image_t *image, opj_event_mgr_t * p_manager); /** Converts an enum type progression order to string type */ const 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(void *j2k, opj_stream_private_t *p_stream, opj_event_mgr_t * p_manager); /** * Reads a jpeg2000 codestream header structure. * * @param p_stream the stream to read data from. * @param j2k the jpeg2000 codec. * @param p_image FIXME DOC * @param p_manager the user event manager. * * @return true if the box is valid. */ OPJ_BOOL opj_j2k_read_header(opj_stream_private_t *p_stream, void* j2k, opj_image_t** p_image, opj_event_mgr_t* p_manager); /** * Destroys a jpeg2000 codec. * * @param j2k the jpeg20000 structure to destroy. */ void opj_j2k_destroy(void *j2k); /** * Destroys a codestream index structure. * * @param p_cstr_ind the codestream index parameter to destroy. */ void j2k_destroy_cstr_index(opj_codestream_index_t *p_cstr_ind); /** * Decode tile data. * @param j2k the jpeg2000 codec. * @param p_tile_index * @param p_data FIXME DOC * @param p_data_size FIXME DOC * @param p_stream the stream to write data to. * @param p_manager the user event manager. */ OPJ_BOOL opj_j2k_decode_tile(void * j2k, OPJ_UINT32 p_tile_index, OPJ_BYTE * p_data, OPJ_UINT32 p_data_size, opj_stream_private_t *p_stream, opj_event_mgr_t * p_manager); /** * Reads a tile header. * @param j2k the jpeg2000 codec. * @param p_tile_index FIXME DOC * @param p_data_size FIXME DOC * @param p_tile_x0 FIXME DOC * @param p_tile_y0 FIXME DOC * @param p_tile_x1 FIXME DOC * @param p_tile_y1 FIXME DOC * @param p_nb_comps FIXME DOC * @param p_go_on FIXME DOC * @param p_stream the stream to write data to. * @param p_manager the user event manager. */ OPJ_BOOL opj_j2k_read_tile_header(void * j2k, OPJ_UINT32 * p_tile_index, OPJ_UINT32 * p_data_size, OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0, OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1, OPJ_UINT32 * p_nb_comps, OPJ_BOOL * p_go_on, opj_stream_private_t *p_stream, opj_event_mgr_t * p_manager); /** Sets the indices of the components to decode. * * @param j2k the jpeg2000 codec. * @param numcomps Number of components to decode. * @param comps_indices Array of num_compts indices (numbering starting at 0) * corresponding to the components to decode. * @param p_manager Event manager * * @return OPJ_TRUE in case of success. */ OPJ_BOOL opj_j2k_set_decoded_components(void *j2k, OPJ_UINT32 numcomps, const OPJ_UINT32* comps_indices, opj_event_mgr_t * p_manager); /** * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading. * * @param j2k the jpeg2000 codec. * @param p_image FIXME DOC * @param p_start_x the left position of the rectangle to decode (in image coordinates). * @param p_start_y the up position of the rectangle to decode (in image coordinates). * @param p_end_x the right position of the rectangle to decode (in image coordinates). * @param p_end_y the bottom position of the rectangle to decode (in image coordinates). * @param p_manager the user event manager * * @return true if the area could be set. */ OPJ_BOOL opj_j2k_set_decode_area(void *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, opj_event_mgr_t * p_manager); /** * Creates a J2K decompression structure. * * @return a handle to a J2K decompressor if successful, NULL otherwise. */ opj_j2k_t* opj_j2k_create_decompress(void); /** * Dump some elements from the J2K decompression structure . * *@param j2k the jpeg2000 codec. *@param flag flag to describe what elements are dump. *@param out_stream output stream where dump the elements. * */ void j2k_dump(void* j2k, OPJ_INT32 flag, FILE* out_stream); /** * Dump an image header structure. * *@param image the image header to dump. *@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); /** * Dump a component image header structure. * *@param comp the component image header to dump. *@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); /** * Get the codestream info from a JPEG2000 codec. * *@param j2k the component image header to dump. * *@return the codestream information extract from the jpg2000 codec */ opj_codestream_info_v2_t* j2k_get_cstr_info(void* j2k); /** * Get the codestream index from a JPEG2000 codec. * *@param j2k the component image header to dump. * *@return the codestream index extract from the jpg2000 codec */ opj_codestream_index_t* j2k_get_cstr_index(void* j2k); /** * Decode an image from a JPEG-2000 codestream * @param j2k J2K decompressor handle * @param p_stream FIXME DOC * @param p_image FIXME DOC * @param p_manager FIXME DOC * @return FIXME DOC */ OPJ_BOOL opj_j2k_decode(void *j2k, opj_stream_private_t *p_stream, opj_image_t *p_image, opj_event_mgr_t *p_manager); OPJ_BOOL opj_j2k_get_tile(void *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(void *j2k, OPJ_UINT32 res_factor, opj_event_mgr_t * p_manager); /** * Specify extra options for the encoder. * * @param j2k the jpeg2000 codec. * @param p_options options * @param p_manager the user event manager * * @see opj_encoder_set_extra_options() for more details. */ OPJ_BOOL opj_j2k_encoder_set_extra_options( void *j2k, const char* const* p_options, opj_event_mgr_t * p_manager); /** * Writes a tile. * @param j2k the jpeg2000 codec. * @param p_tile_index FIXME DOC * @param p_data FIXME DOC * @param p_data_size FIXME DOC * @param p_stream the stream to write data to. * @param p_manager the user event manager. */ OPJ_BOOL opj_j2k_write_tile(void * j2k, OPJ_UINT32 p_tile_index, OPJ_BYTE * p_data, OPJ_UINT32 p_data_size, opj_stream_private_t *p_stream, opj_event_mgr_t * p_manager); /** * Encodes an image into a JPEG-2000 codestream */ OPJ_BOOL opj_j2k_encode(void * j2k, opj_stream_private_t *cio, opj_event_mgr_t * p_manager); /** * Starts a compression scheme, i.e. validates the codec parameters, writes the header. * * @param j2k the jpeg2000 codec. * @param p_stream the stream object. * @param p_image FIXME DOC * @param p_manager the user event manager. * * @return true if the codec is valid. */ OPJ_BOOL opj_j2k_start_compress(void *j2k, opj_stream_private_t *p_stream, opj_image_t * p_image, opj_event_mgr_t * p_manager); /** * Ends the compression procedures and possibiliy add data to be read after the * codestream. */ OPJ_BOOL opj_j2k_end_compress(void *j2k, opj_stream_private_t *cio, opj_event_mgr_t * p_manager); OPJ_BOOL opj_j2k_setup_mct_encoding(opj_tcp_t * p_tcp, opj_image_t * p_image); #endif /* OPJ_J2K_H */