diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2017-05-15 12:21:30 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2017-05-15 12:21:30 +0200 |
| commit | 3c2972f924857016bb454201c7e92f25de9105ee (patch) | |
| tree | dee91c4c200c2e97c83fd4c46588bf923f23852c /src/lib/openjp2 | |
| parent | 28d2eabca79d06378843d1e94fecfb4a5e22178d (diff) | |
Reformat: apply reformattin on .h files (#128)
Diffstat (limited to 'src/lib/openjp2')
31 files changed, 2676 insertions, 2596 deletions
diff --git a/src/lib/openjp2/bio.h b/src/lib/openjp2/bio.h index fba24284..d55dd42a 100644 --- a/src/lib/openjp2/bio.h +++ b/src/lib/openjp2/bio.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,7 +8,7 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. @@ -40,7 +40,7 @@ #include <stddef.h> /* ptrdiff_t */ -/** +/** @file bio.h @brief Implementation of an individual bit input-output (BIO) @@ -54,23 +54,23 @@ The functions in BIO.C have for goal to realize an individual bit input - output Individual bit input-output stream (BIO) */ typedef struct opj_bio { - /** pointer to the start of the buffer */ - OPJ_BYTE *start; - /** pointer to the end of the buffer */ - OPJ_BYTE *end; - /** pointer to the present position in the buffer */ - OPJ_BYTE *bp; - /** temporary place where each byte is read or written */ - OPJ_UINT32 buf; - /** coder : number of bits free to write. decoder : number of bits read */ - OPJ_UINT32 ct; + /** pointer to the start of the buffer */ + OPJ_BYTE *start; + /** pointer to the end of the buffer */ + OPJ_BYTE *end; + /** pointer to the present position in the buffer */ + OPJ_BYTE *bp; + /** temporary place where each byte is read or written */ + OPJ_UINT32 buf; + /** coder : number of bits free to write. decoder : number of bits read */ + OPJ_UINT32 ct; } opj_bio_t; /** @name Exported functions */ /*@{*/ /* ----------------------------------------------------------------------- */ /** -Create a new BIO handle +Create a new BIO handle @return Returns a new BIO handle if successful, returns NULL otherwise */ opj_bio_t* opj_bio_create(void); @@ -89,14 +89,14 @@ ptrdiff_t opj_bio_numbytes(opj_bio_t *bio); Init encoder @param bio BIO handle @param bp Output buffer -@param len Output buffer length +@param len Output buffer length */ void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len); /** Init decoder @param bio BIO handle @param bp Input buffer -@param len Input buffer length +@param len Input buffer length */ void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len); /** @@ -109,7 +109,7 @@ void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n); /** Read bits @param bio BIO handle -@param n Number of bits to read +@param n Number of bits to read @return Returns the corresponding read number */ OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n); diff --git a/src/lib/openjp2/cidx_manager.h b/src/lib/openjp2/cidx_manager.h index d0bbef88..a3532521 100644 --- a/src/lib/openjp2/cidx_manager.h +++ b/src/lib/openjp2/cidx_manager.h @@ -40,7 +40,7 @@ #include "openjpeg.h" -/* +/* * Write Codestream index box (superbox) * * @param[in] offset offset of j2k codestream @@ -50,10 +50,11 @@ * @param[in] j2klen length of j2k codestream * @return length of cidx box */ -int opj_write_cidx( int offset, opj_stream_private_t *cio, opj_codestream_info_t cstr_info, int j2klen, - opj_event_mgr_t * p_manager ); +int opj_write_cidx(int offset, opj_stream_private_t *cio, + opj_codestream_info_t cstr_info, int j2klen, + opj_event_mgr_t * p_manager); -/* +/* * Check if EPH option is used * * @param[in] coff offset of j2k codestream @@ -62,7 +63,8 @@ int opj_write_cidx( int offset, opj_stream_private_t *cio, opj_codestream_info_t * @param[in] cio file output handle * @return true if EPH is used */ -OPJ_BOOL opj_check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); +OPJ_BOOL opj_check_EPHuse(int coff, opj_marker_info_t *markers, int marknum, + opj_stream_private_t *cio, + opj_event_mgr_t * p_manager); #endif /* !CIDX_MANAGER_H_ */ diff --git a/src/lib/openjp2/cio.h b/src/lib/openjp2/cio.h index 4ea03ff3..ae13389d 100644 --- a/src/lib/openjp2/cio.h +++ b/src/lib/openjp2/cio.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,10 +8,10 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team - * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR + * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR * Copyright (c) 2012, CS Systemes d'Information, France * All rights reserved. * @@ -54,19 +54,19 @@ The functions in CIO.C have for goal to realize a byte input / output process. /* ----------------------------------------------------------------------- */ #if defined(OPJ_BIG_ENDIAN) - #define opj_write_bytes opj_write_bytes_BE - #define opj_read_bytes opj_read_bytes_BE - #define opj_write_double opj_write_double_BE - #define opj_read_double opj_read_double_BE - #define opj_write_float opj_write_float_BE - #define opj_read_float opj_read_float_BE +#define opj_write_bytes opj_write_bytes_BE +#define opj_read_bytes opj_read_bytes_BE +#define opj_write_double opj_write_double_BE +#define opj_read_double opj_read_double_BE +#define opj_write_float opj_write_float_BE +#define opj_read_float opj_read_float_BE #else - #define opj_write_bytes opj_write_bytes_LE - #define opj_read_bytes opj_read_bytes_LE - #define opj_write_double opj_write_double_LE - #define opj_read_double opj_read_double_LE - #define opj_write_float opj_write_float_LE - #define opj_read_float opj_read_float_LE +#define opj_write_bytes opj_write_bytes_LE +#define opj_read_bytes opj_read_bytes_LE +#define opj_write_double opj_write_double_LE +#define opj_read_double opj_read_double_LE +#define opj_write_float opj_write_float_LE +#define opj_read_float opj_read_float_LE #endif @@ -78,87 +78,88 @@ The functions in CIO.C have for goal to realize a byte input / output process. /** Byte input-output stream. */ -typedef struct opj_stream_private -{ - /** - * User data, be it files, ... The actual data depends on the type of the stream. - */ - void * m_user_data; - - /** - * Pointer to function to free m_user_data (NULL at initialization) - * when destroying the stream. If pointer is NULL the function is not - * called and the m_user_data is not freed (even if non-NULL). - */ - opj_stream_free_user_data_fn m_free_user_data_fn; - - /** - * User data length - */ - OPJ_UINT64 m_user_data_length; - - /** - * Pointer to actual read function (NULL at the initialization of the cio. - */ - opj_stream_read_fn m_read_fn; - - /** - * Pointer to actual write function (NULL at the initialization of the cio. - */ - opj_stream_write_fn m_write_fn; - - /** - * Pointer to actual skip function (NULL at the initialization of the cio. - * There is no seek function to prevent from back and forth slow procedures. - */ - opj_stream_skip_fn m_skip_fn; - - /** - * Pointer to actual seek function (if available). - */ - opj_stream_seek_fn m_seek_fn; - - /** - * Actual data stored into the stream if readed from. Data is read by chunk of fixed size. - * you should never access this data directly. - */ - OPJ_BYTE * m_stored_data; - - /** - * Pointer to the current read data. - */ - OPJ_BYTE * m_current_data; +typedef struct opj_stream_private { + /** + * User data, be it files, ... The actual data depends on the type of the stream. + */ + void * m_user_data; + + /** + * Pointer to function to free m_user_data (NULL at initialization) + * when destroying the stream. If pointer is NULL the function is not + * called and the m_user_data is not freed (even if non-NULL). + */ + opj_stream_free_user_data_fn m_free_user_data_fn; + + /** + * User data length + */ + OPJ_UINT64 m_user_data_length; + + /** + * Pointer to actual read function (NULL at the initialization of the cio. + */ + opj_stream_read_fn m_read_fn; + + /** + * Pointer to actual write function (NULL at the initialization of the cio. + */ + opj_stream_write_fn m_write_fn; + + /** + * Pointer to actual skip function (NULL at the initialization of the cio. + * There is no seek function to prevent from back and forth slow procedures. + */ + opj_stream_skip_fn m_skip_fn; + + /** + * Pointer to actual seek function (if available). + */ + opj_stream_seek_fn m_seek_fn; + + /** + * Actual data stored into the stream if readed from. Data is read by chunk of fixed size. + * you should never access this data directly. + */ + OPJ_BYTE * m_stored_data; + + /** + * Pointer to the current read data. + */ + OPJ_BYTE * m_current_data; /** * FIXME DOC. */ - OPJ_OFF_T (* m_opj_skip)(struct opj_stream_private * ,OPJ_OFF_T , struct opj_event_mgr *); + OPJ_OFF_T(* m_opj_skip)(struct opj_stream_private *, OPJ_OFF_T, + struct opj_event_mgr *); /** * FIXME DOC. */ - OPJ_BOOL (* m_opj_seek) (struct opj_stream_private * , OPJ_OFF_T , struct opj_event_mgr *); + OPJ_BOOL(* m_opj_seek)(struct opj_stream_private *, OPJ_OFF_T, + struct opj_event_mgr *); - /** - * number of bytes containing in the buffer. - */ - OPJ_SIZE_T m_bytes_in_buffer; + /** + * number of bytes containing in the buffer. + */ + OPJ_SIZE_T m_bytes_in_buffer; - /** - * The number of bytes read/written from the beginning of the stream - */ - OPJ_OFF_T m_byte_offset; + /** + * The number of bytes read/written from the beginning of the stream + */ + OPJ_OFF_T m_byte_offset; - /** - * The size of the buffer. - */ - OPJ_SIZE_T m_buffer_size; + /** + * The size of the buffer. + */ + OPJ_SIZE_T m_buffer_size; - /** - * Flags to tell the status of the stream. - * Used with OPJ_STREAM_STATUS_* defines. - */ - OPJ_UINT32 m_status; + /** + * Flags to tell the status of the stream. + * Used with OPJ_STREAM_STATUS_* defines. + */ + OPJ_UINT32 m_status; } opj_stream_private_t; @@ -168,221 +169,238 @@ opj_stream_private_t; /* ----------------------------------------------------------------------- */ /** * Write some bytes to the given data buffer, this function is used in Big Endian cpus. - * @param p_buffer pointer the data buffer to write data to. - * @param p_value the value to write - * @param p_nb_bytes the number of bytes to write + * @param p_buffer pointer the data buffer to write data to. + * @param p_value the value to write + * @param p_nb_bytes the number of bytes to write */ -void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes); +void opj_write_bytes_BE(OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, + OPJ_UINT32 p_nb_bytes); /** * Reads some bytes from the given data buffer, this function is used in Big Endian cpus. - * @param p_buffer pointer the data buffer to read data from. - * @param p_value pointer to the value that will store the data. - * @param p_nb_bytes the nb bytes to read. - * @return the number of bytes read or -1 if an error occurred. + * @param p_buffer pointer the data buffer to read data from. + * @param p_value pointer to the value that will store the data. + * @param p_nb_bytes the nb bytes to read. + * @return the number of bytes read or -1 if an error occurred. */ -void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes); +void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, + OPJ_UINT32 p_nb_bytes); /** * Write some bytes to the given data buffer, this function is used in Little Endian cpus. - * @param p_buffer pointer the data buffer to write data to. - * @param p_value the value to write - * @param p_nb_bytes the number of bytes to write - * @return the number of bytes written or -1 if an error occurred + * @param p_buffer pointer the data buffer to write data to. + * @param p_value the value to write + * @param p_nb_bytes the number of bytes to write + * @return the number of bytes written or -1 if an error occurred */ -void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes); +void opj_write_bytes_LE(OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, + OPJ_UINT32 p_nb_bytes); /** * Reads some bytes from the given data buffer, this function is used in Little Endian cpus. - * @param p_buffer pointer the data buffer to read data from. - * @param p_value pointer to the value that will store the data. - * @param p_nb_bytes the nb bytes to read. - * @return the number of bytes read or -1 if an error occurred. + * @param p_buffer pointer the data buffer to read data from. + * @param p_value pointer to the value that will store the data. + * @param p_nb_bytes the nb bytes to read. + * @return the number of bytes read or -1 if an error occurred. */ -void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes); +void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, + OPJ_UINT32 p_nb_bytes); /** * Write some bytes to the given data buffer, this function is used in Little Endian cpus. - * @param p_buffer pointer the data buffer to write data to. - * @param p_value the value to write + * @param p_buffer pointer the data buffer to write data to. + * @param p_value the value to write */ void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value); /*** * Write some bytes to the given data buffer, this function is used in Big Endian cpus. - * @param p_buffer pointer the data buffer to write data to. - * @param p_value the value to write + * @param p_buffer pointer the data buffer to write data to. + * @param p_value the value to write */ void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value); /** * Reads some bytes from the given data buffer, this function is used in Little Endian cpus. - * @param p_buffer pointer the data buffer to read data from. - * @param p_value pointer to the value that will store the data. + * @param p_buffer pointer the data buffer to read data from. + * @param p_value pointer to the value that will store the data. */ void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value); /** * Reads some bytes from the given data buffer, this function is used in Big Endian cpus. - * @param p_buffer pointer the data buffer to read data from. - * @param p_value pointer to the value that will store the data. + * @param p_buffer pointer the data buffer to read data from. + * @param p_value pointer to the value that will store the data. */ void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value); /** * Reads some bytes from the given data buffer, this function is used in Little Endian cpus. - * @param p_buffer pointer the data buffer to read data from. - * @param p_value pointer to the value that will store the data. + * @param p_buffer pointer the data buffer to read data from. + * @param p_value pointer to the value that will store the data. */ void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value); /** * Reads some bytes from the given data buffer, this function is used in Big Endian cpus. - * @param p_buffer pointer the data buffer to read data from. - * @param p_value pointer to the value that will store the data. + * @param p_buffer pointer the data buffer to read data from. + * @param p_value pointer to the value that will store the data. */ void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value); /** * Write some bytes to the given data buffer, this function is used in Little Endian cpus. - * @param p_buffer pointer the data buffer to write data to. - * @param p_value the value to write + * @param p_buffer pointer the data buffer to write data to. + * @param p_value the value to write */ void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value); /*** * Write some bytes to the given data buffer, this function is used in Big Endian cpus. - * @param p_buffer pointer the data buffer to write data to. - * @param p_value the value to write + * @param p_buffer pointer the data buffer to write data to. + * @param p_value the value to write */ void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value); /** * Reads some bytes from the stream. - * @param p_stream the stream to read data from. - * @param p_buffer pointer to the data buffer that will receive the data. - * @param p_size number of bytes to read. - * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes read, or -1 if an error occurred or if the stream is at the end. + * @param p_stream the stream to read data from. + * @param p_buffer pointer to the data buffer that will receive the data. + * @param p_size number of bytes to read. + * @param p_event_mgr the user event manager to be notified of special events. + * @return the number of bytes read, or -1 if an error occurred or if the stream is at the end. */ -OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr); +OPJ_SIZE_T opj_stream_read_data(opj_stream_private_t * p_stream, + OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr); /** * Writes some bytes to the stream. - * @param p_stream the stream to write data to. - * @param p_buffer pointer to the data buffer holds the data to be writtent. - * @param p_size number of bytes to write. - * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes writtent, or -1 if an error occurred. + * @param p_stream the stream to write data to. + * @param p_buffer pointer to the data buffer holds the data to be writtent. + * @param p_size number of bytes to write. + * @param p_event_mgr the user event manager to be notified of special events. + * @return the number of bytes writtent, or -1 if an error occurred. */ -OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr); +OPJ_SIZE_T opj_stream_write_data(opj_stream_private_t * p_stream, + const OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, + struct opj_event_mgr * p_event_mgr); /** * Writes the content of the stream buffer to the stream. - * @param p_stream the stream to write data to. - * @param p_event_mgr the user event manager to be notified of special events. - * @return true if the data could be flushed, false else. + * @param p_stream the stream to write data to. + * @param p_event_mgr the user event manager to be notified of special events. + * @return true if the data could be flushed, false else. */ -OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * p_event_mgr); +OPJ_BOOL opj_stream_flush(opj_stream_private_t * p_stream, + struct opj_event_mgr * p_event_mgr); /** * Skips a number of bytes from the stream. - * @param p_stream the stream to skip data from. - * @param p_size the number of bytes to skip. - * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes skipped, or -1 if an error occurred. + * @param p_stream the stream to skip data from. + * @param p_size the number of bytes to skip. + * @param p_event_mgr the user event manager to be notified of special events. + * @return the number of bytes skipped, or -1 if an error occurred. */ -OPJ_OFF_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); +OPJ_OFF_T opj_stream_skip(opj_stream_private_t * p_stream, OPJ_OFF_T p_size, + struct opj_event_mgr * p_event_mgr); /** * Tells the byte offset on the stream (similar to ftell). * - * @param p_stream the stream to get the information from. + * @param p_stream the stream to get the information from. * - * @return the current position o fthe stream. + * @return the current position o fthe stream. */ -OPJ_OFF_T opj_stream_tell (const opj_stream_private_t * p_stream); +OPJ_OFF_T opj_stream_tell(const opj_stream_private_t * p_stream); /** * Get the number of bytes left before the end of the stream (similar to cio_numbytesleft). * - * @param p_stream the stream to get the information from. + * @param p_stream the stream to get the information from. * - * @return Number of bytes left before the end of the stream. + * @return Number of bytes left before the end of the stream. */ -OPJ_OFF_T opj_stream_get_number_byte_left (const opj_stream_private_t * p_stream); +OPJ_OFF_T opj_stream_get_number_byte_left(const opj_stream_private_t * + p_stream); /** * Skips a number of bytes from the stream. - * @param p_stream the stream to skip data from. - * @param p_size the number of bytes to skip. - * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes skipped, or -1 if an error occurred. + * @param p_stream the stream to skip data from. + * @param p_size the number of bytes to skip. + * @param p_event_mgr the user event manager to be notified of special events. + * @return the number of bytes skipped, or -1 if an error occurred. */ -OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); +OPJ_OFF_T opj_stream_write_skip(opj_stream_private_t * p_stream, + OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); /** * Skips a number of bytes from the stream. - * @param p_stream the stream to skip data from. - * @param p_size the number of bytes to skip. - * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes skipped, or -1 if an error occurred. + * @param p_stream the stream to skip data from. + * @param p_size the number of bytes to skip. + * @param p_event_mgr the user event manager to be notified of special events. + * @return the number of bytes skipped, or -1 if an error occurred. */ -OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); +OPJ_OFF_T opj_stream_read_skip(opj_stream_private_t * p_stream, + OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); /** * Skips a number of bytes from the stream. - * @param p_stream the stream to skip data from. - * @param p_size the number of bytes to skip. - * @param p_event_mgr the user event manager to be notified of special events. - * @return OPJ_TRUE if success, or OPJ_FALSE if an error occurred. + * @param p_stream the stream to skip data from. + * @param p_size the number of bytes to skip. + * @param p_event_mgr the user event manager to be notified of special events. + * @return OPJ_TRUE if success, or OPJ_FALSE if an error occurred. */ -OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); +OPJ_BOOL opj_stream_read_seek(opj_stream_private_t * p_stream, OPJ_OFF_T p_size, + struct opj_event_mgr * p_event_mgr); /** * Skips a number of bytes from the stream. - * @param p_stream the stream to skip data from. - * @param p_size the number of bytes to skip. - * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes skipped, or -1 if an error occurred. + * @param p_stream the stream to skip data from. + * @param p_size the number of bytes to skip. + * @param p_event_mgr the user event manager to be notified of special events. + * @return the number of bytes skipped, or -1 if an error occurred. */ -OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); +OPJ_BOOL opj_stream_write_seek(opj_stream_private_t * p_stream, + OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); /** * Seeks a number of bytes from the stream. - * @param p_stream the stream to skip data from. - * @param p_size the number of bytes to skip. - * @param p_event_mgr the user event manager to be notified of special events. - * @return true if the stream is seekable. + * @param p_stream the stream to skip data from. + * @param p_size the number of bytes to skip. + * @param p_event_mgr the user event manager to be notified of special events. + * @return true if the stream is seekable. */ -OPJ_BOOL opj_stream_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); +OPJ_BOOL opj_stream_seek(opj_stream_private_t * p_stream, OPJ_OFF_T p_size, + struct opj_event_mgr * p_event_mgr); /** * Tells if the given stream is seekable. */ -OPJ_BOOL opj_stream_has_seek (const opj_stream_private_t * p_stream); +OPJ_BOOL opj_stream_has_seek(const opj_stream_private_t * p_stream); /** * FIXME DOC. */ -OPJ_SIZE_T opj_stream_default_read (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data); +OPJ_SIZE_T opj_stream_default_read(void * p_buffer, OPJ_SIZE_T p_nb_bytes, + void * p_user_data); /** * FIXME DOC. */ -OPJ_SIZE_T opj_stream_default_write (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data); +OPJ_SIZE_T opj_stream_default_write(void * p_buffer, OPJ_SIZE_T p_nb_bytes, + void * p_user_data); /** * FIXME DOC. */ -OPJ_OFF_T opj_stream_default_skip (OPJ_OFF_T p_nb_bytes, void * p_user_data); +OPJ_OFF_T opj_stream_default_skip(OPJ_OFF_T p_nb_bytes, void * p_user_data); /** * FIXME DOC. */ -OPJ_BOOL opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data); +OPJ_BOOL opj_stream_default_seek(OPJ_OFF_T p_nb_bytes, void * p_user_data); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/src/lib/openjp2/dwt.h b/src/lib/openjp2/dwt.h index 5321175b..b3939c6f 100644 --- a/src/lib/openjp2/dwt.h +++ b/src/lib/openjp2/dwt.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,7 +8,7 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. @@ -67,7 +67,8 @@ Apply a reversible inverse DWT transform to a component of an image. @param tilec Tile component information (current tile) @param numres Number of resolution levels to decode */ -OPJ_BOOL opj_dwt_decode(opj_thread_pool_t* tp, opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres); +OPJ_BOOL opj_dwt_decode(opj_thread_pool_t* tp, opj_tcd_tilecomp_t* tilec, + OPJ_UINT32 numres); /** Get the gain of a subband for the reversible 5-3 DWT. @@ -83,18 +84,19 @@ Get the norm of a wavelet function of a subband at a specified level for the rev */ OPJ_FLOAT64 opj_dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient); /** -Forward 9-7 wavelet transform in 2-D. +Forward 9-7 wavelet transform in 2-D. Apply an irreversible DWT transform to a component of an image. @param tilec Tile component information (current tile) */ OPJ_BOOL opj_dwt_encode_real(opj_tcd_tilecomp_t * tilec); /** -Inverse 9-7 wavelet transform in 2-D. +Inverse 9-7 wavelet transform in 2-D. Apply an irreversible inverse DWT transform to a component of an image. @param tilec Tile component information (current tile) @param numres Number of resolution levels to decode */ -OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* OPJ_RESTRICT tilec, OPJ_UINT32 numres); +OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* OPJ_RESTRICT tilec, + OPJ_UINT32 numres); /** Get the gain of a subband for the irreversible 9-7 DWT. @@ -110,7 +112,7 @@ Get the norm of a wavelet function of a subband at a specified level for the irr */ OPJ_FLOAT64 opj_dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient); /** -Explicit calculation of the Quantization Stepsizes +Explicit calculation of the Quantization Stepsizes @param tccp Tile-component coding parameters @param prec Precint analyzed */ diff --git a/src/lib/openjp2/event.h b/src/lib/openjp2/event.h index fa8604ed..964fc1a6 100644 --- a/src/lib/openjp2/event.h +++ b/src/lib/openjp2/event.h @@ -1,11 +1,11 @@ /* - * 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 + * 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) 2005, Herve Drolon, FreeImage Team - * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR + * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR * Copyright (c) 2012, CS Systemes d'Information, France * All rights reserved. * @@ -40,33 +40,32 @@ The functions in EVENT.C have for goal to send output messages (errors, warnings */ /** Message handler object -used for +used for <ul> <li>Error messages <li>Warning messages <li>Debugging messages </ul> */ -typedef struct opj_event_mgr -{ - /** Data to call the event manager upon */ - void * m_error_data; - /** Data to call the event manager upon */ - void * m_warning_data; - /** Data to call the event manager upon */ - void * m_info_data; - /** Error message callback if available, NULL otherwise */ - opj_msg_callback error_handler; - /** Warning message callback if available, NULL otherwise */ - opj_msg_callback warning_handler; - /** Debug message callback if available, NULL otherwise */ - opj_msg_callback info_handler; +typedef struct opj_event_mgr { + /** Data to call the event manager upon */ + void * m_error_data; + /** Data to call the event manager upon */ + void * m_warning_data; + /** Data to call the event manager upon */ + void * m_info_data; + /** Error message callback if available, NULL otherwise */ + opj_msg_callback error_handler; + /** Warning message callback if available, NULL otherwise */ + opj_msg_callback warning_handler; + /** Debug message callback if available, NULL otherwise */ + opj_msg_callback info_handler; } opj_event_mgr_t; -#define EVT_ERROR 1 /**< Error event type */ -#define EVT_WARNING 2 /**< Warning event type */ -#define EVT_INFO 4 /**< Debug event type */ +#define EVT_ERROR 1 /**< Error event type */ +#define EVT_WARNING 2 /**< Warning event type */ +#define EVT_INFO 4 /**< Debug event type */ /** @defgroup EVENT EVENT - Implementation of a event callback system */ /*@{*/ @@ -81,13 +80,14 @@ typedef struct opj_event_mgr /** * Write formatted data to a string and send the string to a user callback. * - * @param event_mgr Event handler - * @param event_type Event type or callback to use to send the message - * @param fmt Format-control string (plus optional arguments) + * @param event_mgr Event handler + * @param event_type Event type or callback to use to send the message + * @param fmt Format-control string (plus optional arguments) * * @return Returns true if successful, returns false otherwise */ -OPJ_BOOL opj_event_msg(opj_event_mgr_t* event_mgr, OPJ_INT32 event_type, const char *fmt, ...); +OPJ_BOOL opj_event_msg(opj_event_mgr_t* event_mgr, OPJ_INT32 event_type, + const char *fmt, ...); /* ----------------------------------------------------------------------- */ /** diff --git a/src/lib/openjp2/function_list.h b/src/lib/openjp2/function_list.h index ab091b7b..e669695d 100644 --- a/src/lib/openjp2/function_list.h +++ b/src/lib/openjp2/function_list.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -32,7 +32,7 @@ #ifndef __FUNCTION_LIST_H #define __FUNCTION_LIST_H -/** +/** * @file function_list.h * @brief Implementation of a list of procedures. @@ -54,20 +54,19 @@ typedef void (*opj_procedure)(void); /** * A list of procedures. */ -typedef struct opj_procedure_list -{ - /** - * The number of validation procedures. - */ - OPJ_UINT32 m_nb_procedures; - /** - * The number of the array of validation procedures. - */ - OPJ_UINT32 m_nb_max_procedures; - /** - * The array of procedures. - */ - opj_procedure * m_procedures; +typedef struct opj_procedure_list { + /** + * The number of validation procedures. + */ + OPJ_UINT32 m_nb_procedures; + /** + * The number of the array of validation procedures. + */ + OPJ_UINT32 m_nb_max_procedures; + /** + * The array of procedures. + */ + opj_procedure * m_procedures; } opj_procedure_list_t; @@ -76,7 +75,7 @@ typedef struct opj_procedure_list /** * Creates a validation list. * - * @return the newly created validation list. + * @return the newly created validation list. */ opj_procedure_list_t * opj_procedure_list_create(void); @@ -90,41 +89,44 @@ void opj_procedure_list_destroy(opj_procedure_list_t * p_list); /** * Adds a new validation procedure. * - * @param p_validation_list the list of procedure to modify. - * @param p_procedure the procedure to add. + * @param p_validation_list the list of procedure to modify. + * @param p_procedure the procedure to add. * - * @return OPJ_TRUE if the procedure could be added. + * @return OPJ_TRUE if the procedure could be added. */ -OPJ_BOOL opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_list, opj_procedure p_procedure, opj_event_mgr_t* p_manager); +OPJ_BOOL opj_procedure_list_add_procedure(opj_procedure_list_t * + p_validation_list, opj_procedure p_procedure, opj_event_mgr_t* p_manager); /** * Gets the number of validation procedures. * - * @param p_validation_list the list of procedure to modify. + * @param p_validation_list the list of procedure to modify. * * @return the number of validation procedures. */ -OPJ_UINT32 opj_procedure_list_get_nb_procedures (opj_procedure_list_t * p_validation_list); +OPJ_UINT32 opj_procedure_list_get_nb_procedures(opj_procedure_list_t * + p_validation_list); /** * Gets the pointer on the first validation procedure. This function is similar to the C++ * iterator class to iterate through all the procedures inside the validation list. * the caller does not take ownership of the pointer. * - * @param p_validation_list the list of procedure to get the first procedure from. + * @param p_validation_list the list of procedure to get the first procedure from. * - * @return a pointer to the first procedure. + * @return a pointer to the first procedure. */ -opj_procedure* opj_procedure_list_get_first_procedure (opj_procedure_list_t * p_validation_list); +opj_procedure* opj_procedure_list_get_first_procedure(opj_procedure_list_t * + p_validation_list); /** * Clears the list of validation procedures. * - * @param p_validation_list the list of procedure to clear. + * @param p_validation_list the list of procedure to clear. * */ -void opj_procedure_list_clear (opj_procedure_list_t * p_validation_list); +void opj_procedure_list_clear(opj_procedure_list_t * p_validation_list); /*@}*/ #endif /* __FUNCTION_LIST_H */ diff --git a/src/lib/openjp2/image.h b/src/lib/openjp2/image.h index e0e2772d..e47b3aab 100644 --- a/src/lib/openjp2/image.h +++ b/src/lib/openjp2/image.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -55,12 +55,14 @@ opj_image_t* opj_image_create0(void); /** * Updates the components characteristics of the image from the coding parameters. * - * @param p_image_header the image header to update. - * @param p_cp the coding parameters from which to update the image. + * @param p_image_header the image header to update. + * @param p_cp the coding parameters from which to update the image. */ -void opj_image_comp_header_update(opj_image_t * p_image, const struct opj_cp* p_cp); +void opj_image_comp_header_update(opj_image_t * p_image, + const struct opj_cp* p_cp); -void opj_copy_image_header(const opj_image_t* p_image_src, opj_image_t* p_image_dest); +void opj_copy_image_header(const opj_image_t* p_image_src, + opj_image_t* p_image_dest); /*@}*/ diff --git a/src/lib/openjp2/indexbox_manager.h b/src/lib/openjp2/indexbox_manager.h index ebcde8fe..238114bd 100644 --- a/src/lib/openjp2/indexbox_manager.h +++ b/src/lib/openjp2/indexbox_manager.h @@ -56,7 +56,7 @@ #define JPIP_PHLD 0x70686c64 /* Place holder */ -/* +/* * Write tile-part Index table box (superbox) * * @param[in] coff offset of j2k codestream @@ -65,11 +65,12 @@ * @param[in] cio file output handle * @return length of tpix box */ -int opj_write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); +int opj_write_tpix(int coff, opj_codestream_info_t cstr_info, int j2klen, + opj_stream_private_t *cio, + opj_event_mgr_t * p_manager); -/* +/* * Write tile header index table box (superbox) * * @param[in] coff offset of j2k codestream @@ -77,10 +78,11 @@ int opj_write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_s * @param[in] cio file output handle * @return length of thix box */ -int opj_write_thix( int coff, opj_codestream_info_t cstr_info, opj_stream_private_t *cio, opj_event_mgr_t * p_manager ); +int opj_write_thix(int coff, opj_codestream_info_t cstr_info, + opj_stream_private_t *cio, opj_event_mgr_t * p_manager); -/* +/* * Write precinct packet index table box (superbox) * * @param[in] coff offset of j2k codestream @@ -90,11 +92,12 @@ int opj_write_thix( int coff, opj_codestream_info_t cstr_info, opj_stream_privat * @param[in] cio file output handle * @return length of ppix box */ -int opj_write_ppix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); +int opj_write_ppix(int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, + int j2klen, opj_stream_private_t *cio, + opj_event_mgr_t * p_manager); -/* +/* * Write packet header index table box (superbox) * * @param[in] coff offset of j2k codestream @@ -104,10 +107,11 @@ int opj_write_ppix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, * @param[in] cio file output handle * @return length of ppix box */ -int opj_write_phix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); +int opj_write_phix(int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, + int j2klen, opj_stream_private_t *cio, + opj_event_mgr_t * p_manager); -/* +/* * Write manifest box (box) * * @param[in] second number to be visited @@ -116,13 +120,13 @@ int opj_write_phix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, * @param[in] cio file output handle */ -void opj_write_manf(int second, - int v, - opj_jp2_box_t *box, +void opj_write_manf(int second, + int v, + opj_jp2_box_t *box, opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); + opj_event_mgr_t * p_manager); -/* +/* * Write main header index table (box) * * @param[in] coff offset of j2k codestream @@ -130,19 +134,24 @@ void opj_write_manf(int second, * @param[in] cio file output handle * @return length of mainmhix box */ -int opj_write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); +int opj_write_mainmhix(int coff, opj_codestream_info_t cstr_info, + opj_stream_private_t *cio, + opj_event_mgr_t * p_manager); -int opj_write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); +int opj_write_phixfaix(int coff, int compno, opj_codestream_info_t cstr_info, + OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio, + opj_event_mgr_t * p_manager); -int opj_write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); +int opj_write_ppixfaix(int coff, int compno, opj_codestream_info_t cstr_info, + OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio, + opj_event_mgr_t * p_manager); -int opj_write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); +int opj_write_tilemhix(int coff, opj_codestream_info_t cstr_info, int tileno, + opj_stream_private_t *cio, + opj_event_mgr_t * p_manager); -int opj_write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); +int opj_write_tpixfaix(int coff, int compno, opj_codestream_info_t cstr_info, + int j2klen, opj_stream_private_t *cio, + opj_event_mgr_t * p_manager); #endif /* !INDEXBOX_MANAGER_H_ */ diff --git a/src/lib/openjp2/invert.h b/src/lib/openjp2/invert.h index 2fae8e54..d1c560c5 100644 --- a/src/lib/openjp2/invert.h +++ b/src/lib/openjp2/invert.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -48,17 +48,17 @@ The function in INVERT.H compute a matrix inversion with a LUP method * Calculates a n x n double matrix inversion with a LUP method. Data is aligned, rows after rows (or columns after columns). * The function does not take ownership of any memory block, data must be fred by the user. * - * @param pSrcMatrix the matrix to invert. - * @param pDestMatrix data to store the inverted matrix. + * @param pSrcMatrix the matrix to invert. + * @param pDestMatrix data to store the inverted matrix. * @param n size of the matrix * @return OPJ_TRUE if the inversion is successful, OPJ_FALSE if the matrix is singular. */ OPJ_BOOL opj_matrix_inversion_f(OPJ_FLOAT32 * pSrcMatrix, - OPJ_FLOAT32 * pDestMatrix, + OPJ_FLOAT32 * pDestMatrix, OPJ_UINT32 nb_compo); /* ----------------------------------------------------------------------- */ /*@}*/ /*@}*/ -#endif /* __INVERT_H */ +#endif /* __INVERT_H */ diff --git a/src/lib/openjp2/j2k.h b/src/lib/openjp2/j2k.h index 7e68b3af..fe65cd87 100644 --- a/src/lib/openjp2/j2k.h +++ b/src/lib/openjp2/j2k.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,12 +8,12 @@ * 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-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-2012, Centre National d'Etudes Spatiales (CNES), France + * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France * Copyright (c) 2012, CS Systemes d'Information, France * * All rights reserved. @@ -69,39 +69,39 @@ The functions in J2K.C have for goal to read/write the several parts of the code /* ----------------------------------------------------------------------- */ -#define J2K_MS_SOC 0xff4f /**< SOC marker value */ -#define J2K_MS_SOT 0xff90 /**< SOT marker value */ -#define J2K_MS_SOD 0xff93 /**< SOD marker value */ -#define J2K_MS_EOC 0xffd9 /**< EOC marker value */ -#define J2K_MS_SIZ 0xff51 /**< SIZ marker value */ -#define J2K_MS_COD 0xff52 /**< COD marker value */ -#define J2K_MS_COC 0xff53 /**< COC marker value */ -#define J2K_MS_RGN 0xff5e /**< RGN marker value */ -#define J2K_MS_QCD 0xff5c /**< QCD marker value */ -#define J2K_MS_QCC 0xff5d /**< QCC marker value */ -#define J2K_MS_POC 0xff5f /**< POC marker value */ -#define J2K_MS_TLM 0xff55 /**< TLM marker value */ -#define J2K_MS_PLM 0xff57 /**< PLM marker value */ -#define J2K_MS_PLT 0xff58 /**< PLT marker value */ -#define J2K_MS_PPM 0xff60 /**< PPM marker value */ -#define J2K_MS_PPT 0xff61 /**< PPT marker value */ -#define J2K_MS_SOP 0xff91 /**< SOP marker value */ -#define J2K_MS_EPH 0xff92 /**< EPH marker value */ -#define J2K_MS_CRG 0xff63 /**< CRG marker value */ -#define J2K_MS_COM 0xff64 /**< COM marker value */ -#define J2K_MS_CBD 0xff78 /**< CBD marker value */ -#define J2K_MS_MCC 0xff75 /**< MCC marker value */ -#define J2K_MS_MCT 0xff74 /**< MCT marker value */ -#define J2K_MS_MCO 0xff77 /**< MCO marker value */ - -#define J2K_MS_UNK 0 /**< UNKNOWN marker value */ +#define J2K_MS_SOC 0xff4f /**< SOC marker value */ +#define J2K_MS_SOT 0xff90 /**< SOT marker value */ +#define J2K_MS_SOD 0xff93 /**< SOD marker value */ +#define J2K_MS_EOC 0xffd9 /**< EOC marker value */ +#define J2K_MS_SIZ 0xff51 /**< SIZ marker value */ +#define J2K_MS_COD 0xff52 /**< COD marker value */ +#define J2K_MS_COC 0xff53 /**< COC marker value */ +#define J2K_MS_RGN 0xff5e /**< RGN marker value */ +#define J2K_MS_QCD 0xff5c /**< QCD marker value */ +#define J2K_MS_QCC 0xff5d /**< QCC marker value */ +#define J2K_MS_POC 0xff5f /**< POC marker value */ +#define J2K_MS_TLM 0xff55 /**< TLM marker value */ +#define J2K_MS_PLM 0xff57 /**< PLM marker value */ +#define J2K_MS_PLT 0xff58 /**< PLT marker value */ +#define J2K_MS_PPM 0xff60 /**< PPM marker value */ +#define J2K_MS_PPT 0xff61 /**< PPT marker value */ +#define J2K_MS_SOP 0xff91 /**< SOP marker value */ +#define J2K_MS_EPH 0xff92 /**< EPH marker value */ +#define J2K_MS_CRG 0xff63 /**< CRG marker value */ +#define J2K_MS_COM 0xff64 /**< COM marker value */ +#define J2K_MS_CBD 0xff78 /**< CBD marker value */ +#define J2K_MS_MCC 0xff75 /**< MCC marker value */ +#define J2K_MS_MCT 0xff74 /**< MCT marker value */ +#define J2K_MS_MCO 0xff77 /**< MCO marker value */ + +#define J2K_MS_UNK 0 /**< UNKNOWN marker value */ /* UniPG>> */ #ifdef USE_JPWL -#define J2K_MS_EPC 0xff68 /**< EPC marker value (Part 11: JPEG 2000 for Wireless) */ -#define J2K_MS_EPB 0xff66 /**< EPB marker value (Part 11: JPEG 2000 for Wireless) */ -#define J2K_MS_ESD 0xff67 /**< ESD marker value (Part 11: JPEG 2000 for Wireless) */ -#define J2K_MS_RED 0xff69 /**< RED marker value (Part 11: JPEG 2000 for Wireless) */ +#define J2K_MS_EPC 0xff68 /**< EPC marker value (Part 11: JPEG 2000 for Wireless) */ +#define J2K_MS_EPB 0xff66 /**< EPB marker value (Part 11: JPEG 2000 for Wireless) */ +#define J2K_MS_ESD 0xff67 /**< ESD marker value (Part 11: JPEG 2000 for Wireless) */ +#define J2K_MS_RED 0xff69 /**< RED marker value (Part 11: JPEG 2000 for Wireless) */ #endif /* USE_JPWL */ #ifdef USE_JPSEC #define J2K_MS_SEC 0xff65 /**< SEC marker value (Part 8: Secure JPEG 2000) */ @@ -116,91 +116,88 @@ The functions in J2K.C have for goal to read/write the several parts of the code * These values may be combined with a | operator. * */ typedef enum J2K_STATUS { - J2K_STATE_NONE = 0x0000, /**< a SOC marker is expected */ - J2K_STATE_MHSOC = 0x0001, /**< a SOC marker is expected */ - J2K_STATE_MHSIZ = 0x0002, /**< a SIZ marker is expected */ - J2K_STATE_MH = 0x0004, /**< the decoding process is in the main header */ - J2K_STATE_TPHSOT = 0x0008, /**< the decoding process is in a tile part header and expects a SOT marker */ - J2K_STATE_TPH = 0x0010, /**< the decoding process is in a tile part header */ - J2K_STATE_MT = 0x0020, /**< the EOC marker has just been read */ - J2K_STATE_NEOC = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */ - - J2K_STATE_EOC = 0x0100, /**< the decoding process has encountered the EOC marker */ - J2K_STATE_ERR = 0x8000 /**< the decoding process has encountered an error (FIXME warning V1 = 0x0080)*/ + J2K_STATE_NONE = 0x0000, /**< a SOC marker is expected */ + J2K_STATE_MHSOC = 0x0001, /**< a SOC marker is expected */ + J2K_STATE_MHSIZ = 0x0002, /**< a SIZ marker is expected */ + J2K_STATE_MH = 0x0004, /**< the decoding process is in the main header */ + J2K_STATE_TPHSOT = 0x0008, /**< the decoding process is in a tile part header and expects a SOT marker */ + J2K_STATE_TPH = 0x0010, /**< the decoding process is in a tile part header */ + J2K_STATE_MT = 0x0020, /**< the EOC marker has just been read */ + J2K_STATE_NEOC = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */ + + J2K_STATE_EOC = 0x0100, /**< the decoding process has encountered the EOC marker */ + J2K_STATE_ERR = 0x8000 /**< the decoding process has encountered an error (FIXME warning V1 = 0x0080)*/ } J2K_STATUS; /** * Type of elements storing in the MCT data */ -typedef enum MCT_ELEMENT_TYPE -{ - MCT_TYPE_INT16 = 0, /** MCT data is stored as signed shorts*/ - MCT_TYPE_INT32 = 1, /** MCT data is stored as signed integers*/ - MCT_TYPE_FLOAT = 2, /** MCT data is stored as floats*/ - MCT_TYPE_DOUBLE = 3 /** MCT data is stored as doubles*/ +typedef enum MCT_ELEMENT_TYPE { + MCT_TYPE_INT16 = 0, /** MCT data is stored as signed shorts*/ + MCT_TYPE_INT32 = 1, /** MCT data is stored as signed integers*/ + MCT_TYPE_FLOAT = 2, /** MCT data is stored as floats*/ + MCT_TYPE_DOUBLE = 3 /** MCT data is stored as doubles*/ } J2K_MCT_ELEMENT_TYPE; /** * Type of MCT array */ -typedef enum MCT_ARRAY_TYPE -{ - MCT_TYPE_DEPENDENCY = 0, - MCT_TYPE_DECORRELATION = 1, - MCT_TYPE_OFFSET = 2 +typedef enum MCT_ARRAY_TYPE { + MCT_TYPE_DEPENDENCY = 0, + MCT_TYPE_DECORRELATION = 1, + MCT_TYPE_OFFSET = 2 } J2K_MCT_ARRAY_TYPE; /* ----------------------------------------------------------------------- */ -/** -T2 encoding mode +/** +T2 encoding mode */ typedef enum T2_MODE { - THRESH_CALC = 0, /** Function called in Rate allocation process*/ - FINAL_PASS = 1 /** Function called in Tier 2 process*/ -}J2K_T2_MODE; + THRESH_CALC = 0, /** Function called in Rate allocation process*/ + FINAL_PASS = 1 /** Function called in Tier 2 process*/ +} J2K_T2_MODE; /** * Quantization stepsize */ typedef struct opj_stepsize { - /** exponent */ - OPJ_INT32 expn; - /** mantissa */ - OPJ_INT32 mant; + /** exponent */ + OPJ_INT32 expn; + /** mantissa */ + OPJ_INT32 mant; } opj_stepsize_t; /** Tile-component coding parameters */ -typedef struct opj_tccp -{ - /** coding style */ - OPJ_UINT32 csty; - /** number of resolutions */ - OPJ_UINT32 numresolutions; - /** code-blocks width */ - OPJ_UINT32 cblkw; - /** code-blocks height */ - OPJ_UINT32 cblkh; - /** code-block coding style */ - OPJ_UINT32 cblksty; - /** discrete wavelet transform identifier */ - OPJ_UINT32 qmfbid; - /** quantisation style */ - OPJ_UINT32 qntsty; - /** stepsizes used for quantization */ - 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[OPJ_J2K_MAXRLVLS]; - /** precinct height */ - OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS]; - /** the dc_level_shift **/ - OPJ_INT32 m_dc_level_shift; +typedef struct opj_tccp { + /** coding style */ + OPJ_UINT32 csty; + /** number of resolutions */ + OPJ_UINT32 numresolutions; + /** code-blocks width */ + OPJ_UINT32 cblkw; + /** code-blocks height */ + OPJ_UINT32 cblkh; + /** code-block coding style */ + OPJ_UINT32 cblksty; + /** discrete wavelet transform identifier */ + OPJ_UINT32 qmfbid; + /** quantisation style */ + OPJ_UINT32 qntsty; + /** stepsizes used for quantization */ + 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[OPJ_J2K_MAXRLVLS]; + /** precinct height */ + OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS]; + /** the dc_level_shift **/ + OPJ_INT32 m_dc_level_shift; } opj_tccp_t; @@ -209,33 +206,30 @@ opj_tccp_t; /** * FIXME DOC */ -typedef struct opj_mct_data -{ - J2K_MCT_ELEMENT_TYPE m_element_type; - J2K_MCT_ARRAY_TYPE m_array_type; - OPJ_UINT32 m_index; - OPJ_BYTE * m_data; - OPJ_UINT32 m_data_size; +typedef struct opj_mct_data { + J2K_MCT_ELEMENT_TYPE m_element_type; + J2K_MCT_ARRAY_TYPE m_array_type; + OPJ_UINT32 m_index; + OPJ_BYTE * m_data; + OPJ_UINT32 m_data_size; } opj_mct_data_t; /** * FIXME DOC */ -typedef struct opj_simple_mcc_decorrelation_data -{ - OPJ_UINT32 m_index; - OPJ_UINT32 m_nb_comps; - opj_mct_data_t * m_decorrelation_array; - opj_mct_data_t * m_offset_array; - OPJ_BITFIELD m_is_irreversible : 1; +typedef struct opj_simple_mcc_decorrelation_data { + OPJ_UINT32 m_index; + OPJ_UINT32 m_nb_comps; + opj_mct_data_t * m_decorrelation_array; + opj_mct_data_t * m_offset_array; + 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; +typedef struct opj_ppx_struct { + OPJ_BYTE* m_data; /* m_data == NULL => Zppx not read yet */ + OPJ_UINT32 m_data_size; } opj_ppx; /** @@ -243,106 +237,103 @@ 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 -{ - /** coding style */ - OPJ_UINT32 csty; - /** progression order */ - OPJ_PROG_ORDER prg; - /** number of layers */ - OPJ_UINT32 numlayers; - OPJ_UINT32 num_layers_to_decode; - /** multi-component transform identifier */ - OPJ_UINT32 mct; - /** rates of layers */ - OPJ_FLOAT32 rates[100]; - /** number of progression order changes */ - OPJ_UINT32 numpocs; - /** progression order changes */ - opj_poc_t pocs[32]; - - /** 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; - /** Number of bytes stored inside ppt_data*/ - OPJ_UINT32 ppt_data_size; - /** size of ppt_data*/ - OPJ_UINT32 ppt_len; - /** add fixed_quality */ - OPJ_FLOAT32 distoratio[100]; - /** tile-component coding parameters */ - opj_tccp_t *tccps; - /** number of tile parts for the tile. */ - OPJ_UINT32 m_nb_tile_parts; - /** data for the tile */ - OPJ_BYTE * m_data; - /** size of data */ - OPJ_UINT32 m_data_size; - /** encoding norms */ - OPJ_FLOAT64 * mct_norms; - /** the mct decoding matrix */ - OPJ_FLOAT32 * m_mct_decoding_matrix; - /** the mct coding matrix */ - OPJ_FLOAT32 * m_mct_coding_matrix; - /** mct records */ - opj_mct_data_t * m_mct_records; - /** the number of mct records. */ - OPJ_UINT32 m_nb_mct_records; - /** the max number of mct records. */ - OPJ_UINT32 m_nb_max_mct_records; - /** mcc records */ - opj_simple_mcc_decorrelation_data_t * m_mcc_records; - /** the number of mct records. */ - OPJ_UINT32 m_nb_mcc_records; - /** the max number of mct records. */ - OPJ_UINT32 m_nb_max_mcc_records; - - - /***** 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_BITFIELD ppt : 1; - /** indicates if a POC marker has been used O:NO, 1:YES */ - OPJ_BITFIELD POC : 1; +typedef struct opj_tcp { + /** coding style */ + OPJ_UINT32 csty; + /** progression order */ + OPJ_PROG_ORDER prg; + /** number of layers */ + OPJ_UINT32 numlayers; + OPJ_UINT32 num_layers_to_decode; + /** multi-component transform identifier */ + OPJ_UINT32 mct; + /** rates of layers */ + OPJ_FLOAT32 rates[100]; + /** number of progression order changes */ + OPJ_UINT32 numpocs; + /** progression order changes */ + opj_poc_t pocs[32]; + + /** 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; + /** Number of bytes stored inside ppt_data*/ + OPJ_UINT32 ppt_data_size; + /** size of ppt_data*/ + OPJ_UINT32 ppt_len; + /** add fixed_quality */ + OPJ_FLOAT32 distoratio[100]; + /** tile-component coding parameters */ + opj_tccp_t *tccps; + /** number of tile parts for the tile. */ + OPJ_UINT32 m_nb_tile_parts; + /** data for the tile */ + OPJ_BYTE * m_data; + /** size of data */ + OPJ_UINT32 m_data_size; + /** encoding norms */ + OPJ_FLOAT64 * mct_norms; + /** the mct decoding matrix */ + OPJ_FLOAT32 * m_mct_decoding_matrix; + /** the mct coding matrix */ + OPJ_FLOAT32 * m_mct_coding_matrix; + /** mct records */ + opj_mct_data_t * m_mct_records; + /** the number of mct records. */ + OPJ_UINT32 m_nb_mct_records; + /** the max number of mct records. */ + OPJ_UINT32 m_nb_max_mct_records; + /** mcc records */ + opj_simple_mcc_decorrelation_data_t * m_mcc_records; + /** the number of mct records. */ + OPJ_UINT32 m_nb_mcc_records; + /** the max number of mct records. */ + OPJ_UINT32 m_nb_max_mcc_records; + + + /***** 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_BITFIELD ppt : 1; + /** indicates if a POC marker has been used O:NO, 1:YES */ + OPJ_BITFIELD POC : 1; } opj_tcp_t; -typedef struct opj_encoding_param -{ - /** 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*/ - OPJ_INT32 m_tp_pos; - /** fixed layer */ - OPJ_INT32 *m_matrice; - /** Flag determining tile part generation*/ - OPJ_BYTE m_tp_flag; - /** allocation by rate/distortion */ - OPJ_BITFIELD m_disto_alloc : 1; - /** allocation by fixed layer */ - OPJ_BITFIELD m_fixed_alloc : 1; - /** add fixed_quality */ - OPJ_BITFIELD m_fixed_quality : 1; - /** Enabling Tile part generation*/ - OPJ_BITFIELD m_tp_on : 1; +typedef struct opj_encoding_param { + /** 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*/ + OPJ_INT32 m_tp_pos; + /** fixed layer */ + OPJ_INT32 *m_matrice; + /** Flag determining tile part generation*/ + OPJ_BYTE m_tp_flag; + /** allocation by rate/distortion */ + OPJ_BITFIELD m_disto_alloc : 1; + /** allocation by fixed layer */ + OPJ_BITFIELD m_fixed_alloc : 1; + /** add fixed_quality */ + OPJ_BITFIELD m_fixed_quality : 1; + /** Enabling Tile part generation*/ + OPJ_BITFIELD m_tp_on : 1; } opj_encoding_param_t; -typedef struct opj_decoding_param -{ - /** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */ - OPJ_UINT32 m_reduce; - /** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */ - OPJ_UINT32 m_layer; +typedef struct opj_decoding_param { + /** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */ + OPJ_UINT32 m_reduce; + /** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */ + OPJ_UINT32 m_layer; } opj_decoding_param_t; @@ -350,199 +341,195 @@ opj_decoding_param_t; /** * Coding parameters */ -typedef struct opj_cp -{ - /** Size of the image in bits*/ - /*int img_size;*/ - /** Rsiz*/ +typedef struct opj_cp { + /** Size of the image in bits*/ + /*int img_size;*/ + /** Rsiz*/ OPJ_UINT16 rsiz; - /** XTOsiz */ - OPJ_UINT32 tx0; /* MSD see norm */ - /** YTOsiz */ - OPJ_UINT32 ty0; /* MSD see norm */ - /** XTsiz */ - OPJ_UINT32 tdx; - /** YTsiz */ - OPJ_UINT32 tdy; - /** comment */ - OPJ_CHAR *comment; - /** number of tiles in width */ - OPJ_UINT32 tw; - /** number of tiles in heigth */ - OPJ_UINT32 th; - - /** 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; - /** size of the ppm_data*/ - OPJ_UINT32 ppm_data_read; - - OPJ_BYTE *ppm_data_current; - - /** packet header storage original buffer */ - OPJ_BYTE *ppm_buffer; - /** pointer remaining on the first byte of the first header if ppm is used */ - OPJ_BYTE *ppm_data_first; - /** Number of bytes actually stored inside the ppm_data */ - OPJ_UINT32 ppm_data_size; - /** use in case of multiple marker PPM (number of info already store) */ - OPJ_INT32 ppm_store; - /** use in case of multiple marker PPM (case on non-finished previous info) */ - OPJ_INT32 ppm_previous; - - /** tile coding parameters */ - opj_tcp_t *tcps; - - union - { - opj_decoding_param_t m_dec; - opj_encoding_param_t m_enc; - } - m_specific_param; - - -/* UniPG>> */ + /** XTOsiz */ + OPJ_UINT32 tx0; /* MSD see norm */ + /** YTOsiz */ + OPJ_UINT32 ty0; /* MSD see norm */ + /** XTsiz */ + OPJ_UINT32 tdx; + /** YTsiz */ + OPJ_UINT32 tdy; + /** comment */ + OPJ_CHAR *comment; + /** number of tiles in width */ + OPJ_UINT32 tw; + /** number of tiles in heigth */ + OPJ_UINT32 th; + + /** 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; + /** size of the ppm_data*/ + OPJ_UINT32 ppm_data_read; + + OPJ_BYTE *ppm_data_current; + + /** packet header storage original buffer */ + OPJ_BYTE *ppm_buffer; + /** pointer remaining on the first byte of the first header if ppm is used */ + OPJ_BYTE *ppm_data_first; + /** Number of bytes actually stored inside the ppm_data */ + OPJ_UINT32 ppm_data_size; + /** use in case of multiple marker PPM (number of info already store) */ + OPJ_INT32 ppm_store; + /** use in case of multiple marker PPM (case on non-finished previous info) */ + OPJ_INT32 ppm_previous; + + /** tile coding parameters */ + opj_tcp_t *tcps; + + union { + opj_decoding_param_t m_dec; + opj_encoding_param_t m_enc; + } + m_specific_param; + + + /* 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 */ - OPJ_UINT32 max_tiles; + /** 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 */ + OPJ_UINT32 max_tiles; #endif /* USE_JPWL */ - /******** FLAGS *********/ - /** if ppm == 1 --> there was a PPM marker*/ - OPJ_BITFIELD ppm : 1; - /** tells if the parameter is a coding or decoding one */ - OPJ_BITFIELD m_is_decoder : 1; -/* <<UniPG */ + /******** FLAGS *********/ + /** if ppm == 1 --> there was a PPM marker*/ + OPJ_BITFIELD ppm : 1; + /** tells if the parameter is a coding or decoding one */ + OPJ_BITFIELD m_is_decoder : 1; + /* <<UniPG */ } opj_cp_t; -typedef struct opj_j2k_dec -{ - /** locate in which part of the codestream the decoder is (main header, tile header, end) */ - OPJ_UINT32 m_state; - /** - * store decoding parameters common to all tiles (information like COD, COC in main header) - */ - opj_tcp_t *m_default_tcp; - OPJ_BYTE *m_header_data; - OPJ_UINT32 m_header_data_size; - /** to tell the tile part length */ - OPJ_UINT32 m_sot_length; - /** Only tiles index in the correct range will be decoded.*/ - OPJ_UINT32 m_start_tile_x; - OPJ_UINT32 m_start_tile_y; - OPJ_UINT32 m_end_tile_x; - OPJ_UINT32 m_end_tile_y; - /** - * Decoded area set by the user - */ - OPJ_UINT32 m_DA_x0; - OPJ_UINT32 m_DA_y0; - OPJ_UINT32 m_DA_x1; - OPJ_UINT32 m_DA_y1; - - /** Index of the tile to decode (used in get_tile) */ - OPJ_INT32 m_tile_ind_to_dec; - /** Position of the last SOT marker read */ - OPJ_OFF_T m_last_sot_read_pos; - - /** - * Indicate that the current tile-part is assume as the last tile part of the codestream. - * 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; - /** to tell that a tile can be decoded. */ - 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; +typedef struct opj_j2k_dec { + /** locate in which part of the codestream the decoder is (main header, tile header, end) */ + OPJ_UINT32 m_state; + /** + * store decoding parameters common to all tiles (information like COD, COC in main header) + */ + opj_tcp_t *m_default_tcp; + OPJ_BYTE *m_header_data; + OPJ_UINT32 m_header_data_size; + /** to tell the tile part length */ + OPJ_UINT32 m_sot_length; + /** Only tiles index in the correct range will be decoded.*/ + OPJ_UINT32 m_start_tile_x; + OPJ_UINT32 m_start_tile_y; + OPJ_UINT32 m_end_tile_x; + OPJ_UINT32 m_end_tile_y; + /** + * Decoded area set by the user + */ + OPJ_UINT32 m_DA_x0; + OPJ_UINT32 m_DA_y0; + OPJ_UINT32 m_DA_x1; + OPJ_UINT32 m_DA_y1; + + /** Index of the tile to decode (used in get_tile) */ + OPJ_INT32 m_tile_ind_to_dec; + /** Position of the last SOT marker read */ + OPJ_OFF_T m_last_sot_read_pos; + + /** + * Indicate that the current tile-part is assume as the last tile part of the codestream. + * 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; + /** to tell that a tile can be decoded. */ + 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; -typedef struct opj_j2k_enc -{ - /** Tile part number, regardless of poc, for each new poc, tp is reset to 1*/ - OPJ_UINT32 m_current_poc_tile_part_number; /* tp_num */ +typedef struct opj_j2k_enc { + /** Tile part number, regardless of poc, for each new poc, tp is reset to 1*/ + OPJ_UINT32 m_current_poc_tile_part_number; /* tp_num */ - /** Tile part number currently coding, taking into account POC. m_current_tile_part_number holds the total number of tile parts while encoding the last tile part.*/ - OPJ_UINT32 m_current_tile_part_number; /*cur_tp_num */ + /** Tile part number currently coding, taking into account POC. m_current_tile_part_number holds the total number of tile parts while encoding the last tile part.*/ + OPJ_UINT32 m_current_tile_part_number; /*cur_tp_num */ - /** - locate the start position of the TLM marker - after encoding the tilepart, a jump (in j2k_write_sod) is done to the TLM marker to store the value of its length. - */ + /** + locate the start position of the TLM marker + after encoding the tilepart, a jump (in j2k_write_sod) is done to the TLM marker to store the value of its length. + */ OPJ_OFF_T m_tlm_start; - /** - * Stores the sizes of the tlm. - */ - OPJ_BYTE * m_tlm_sot_offsets_buffer; - /** - * The current offset of the tlm buffer. - */ - OPJ_BYTE * m_tlm_sot_offsets_current; + /** + * Stores the sizes of the tlm. + */ + OPJ_BYTE * m_tlm_sot_offsets_buffer; + /** + * The current offset of the tlm buffer. + */ + OPJ_BYTE * m_tlm_sot_offsets_current; - /** Total num of tile parts in whole image = num tiles* num tileparts in each tile*/ - /** used in TLMmarker*/ - OPJ_UINT32 m_total_tile_parts; /* totnum_tp */ + /** Total num of tile parts in whole image = num tiles* num tileparts in each tile*/ + /** used in TLMmarker*/ + OPJ_UINT32 m_total_tile_parts; /* totnum_tp */ - /* encoded data for a tile */ - OPJ_BYTE * m_encoded_tile_data; + /* encoded data for a tile */ + OPJ_BYTE * m_encoded_tile_data; - /* size of the encoded_data */ - OPJ_UINT32 m_encoded_tile_size; + /* size of the encoded_data */ + OPJ_UINT32 m_encoded_tile_size; - /* encoded data for a tile */ - OPJ_BYTE * m_header_tile_data; + /* encoded data for a tile */ + OPJ_BYTE * m_header_tile_data; - /* size of the encoded_data */ - OPJ_UINT32 m_header_tile_data_size; + /* size of the encoded_data */ + OPJ_UINT32 m_header_tile_data_size; } opj_j2k_enc_t; @@ -553,42 +540,40 @@ struct opj_tcd; /** JPEG-2000 codestream reader/writer */ -typedef struct opj_j2k -{ - /* J2K codestream is decoded*/ - OPJ_BOOL m_is_decoder; +typedef struct opj_j2k { + /* J2K codestream is decoded*/ + OPJ_BOOL m_is_decoder; - /* FIXME DOC*/ - union - { - opj_j2k_dec_t m_decoder; - opj_j2k_enc_t m_encoder; - } - m_specific_param; + /* FIXME DOC*/ + union { + opj_j2k_dec_t m_decoder; + opj_j2k_enc_t m_encoder; + } + m_specific_param; - /** pointer to the internal/private encoded / decoded image */ - opj_image_t* m_private_image; + /** pointer to the internal/private encoded / decoded image */ + opj_image_t* m_private_image; - /* pointer to the output image (decoded)*/ - opj_image_t* m_output_image; + /* pointer to the output image (decoded)*/ + opj_image_t* m_output_image; - /** Coding parameters */ - opj_cp_t m_cp; + /** Coding parameters */ + opj_cp_t m_cp; - /** the list of procedures to exec **/ - opj_procedure_list_t * m_procedure_list; + /** the list of procedures to exec **/ + opj_procedure_list_t * m_procedure_list; - /** the list of validation procedures to follow to make sure the code is valid **/ - opj_procedure_list_t * m_validation_list; + /** the list of validation procedures to follow to make sure the code is valid **/ + opj_procedure_list_t * m_validation_list; - /** helper used to write the index file */ - opj_codestream_index_t *cstr_index; + /** helper used to write the index file */ + opj_codestream_index_t *cstr_index; - /** number of the tile curently concern by coding/decoding */ - OPJ_UINT32 m_current_tile_number; + /** number of the tile curently concern by coding/decoding */ + OPJ_UINT32 m_current_tile_number; - /** the current tile coder/decoder **/ - struct opj_tcd * m_tcd; + /** the current tile coder/decoder **/ + struct opj_tcd * m_tcd; /** Number of threads to use */ int m_num_threads; @@ -607,7 +592,7 @@ opj_j2k_t; /** Setup the decoder decoding parameters using user parameters. -Decoding parameters are returned in j2k->cp. +Decoding parameters are returned in j2k->cp. @param j2k J2K decompressor handle @param parameters decompression parameters */ @@ -623,10 +608,10 @@ OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads); opj_j2k_t* opj_j2k_create_compress(void); -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); +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); /** Converts an enum type progression order to string type @@ -656,87 +641,87 @@ 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_j2k_t* p_j2k, - opj_image_t** p_image, - opj_event_mgr_t* p_manager ); +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); /** * Destroys a jpeg2000 codec. * - * @param p_j2k the jpeg20000 structure to destroy. + * @param p_j2k the jpeg20000 structure to destroy. */ -void opj_j2k_destroy (opj_j2k_t *p_j2k); +void opj_j2k_destroy(opj_j2k_t *p_j2k); /** * Destroys a codestream index structure. * - * @param p_cstr_ind the codestream index parameter to destroy. + * @param p_cstr_ind the codestream index parameter to destroy. */ -void j2k_destroy_cstr_index (opj_codestream_index_t *p_cstr_ind); +void j2k_destroy_cstr_index(opj_codestream_index_t *p_cstr_ind); /** * Decode tile data. - * @param p_j2k the jpeg2000 codec. - * @param p_tile_index + * @param p_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. + * @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_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 ); +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, + opj_stream_private_t *p_stream, + opj_event_mgr_t * p_manager); /** * Reads a tile header. - * @param p_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. + * @param p_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 ( opj_j2k_t * p_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 ); +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, + 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 given area to be decoded. This function should be called right after opj_read_header and before any tile header reading. * - * @param p_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 + * @param p_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. + * @return true if the area could be set. */ -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, - opj_event_mgr_t * p_manager ); +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, + opj_event_mgr_t * p_manager); /** * Creates a J2K decompression structure. @@ -749,48 +734,50 @@ opj_j2k_t* opj_j2k_create_decompress(void); /** * Dump some elements from the J2K decompression structure . * - *@param p_j2k the jpeg2000 codec. - *@param flag flag to describe what elments are dump. - *@param out_stream output stream where dump the elements. + *@param p_j2k the jpeg2000 codec. + *@param flag flag to describe what elments are dump. + *@param out_stream output stream where dump the elements. * */ -void j2k_dump (opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream); +void j2k_dump(opj_j2k_t* p_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. + *@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); +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. + *@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); +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 p_j2k the component image header to dump. + *@param p_j2k the component image header to dump. * - *@return the codestream information extract from the jpg2000 codec + *@return the codestream information extract from the jpg2000 codec */ opj_codestream_info_v2_t* j2k_get_cstr_info(opj_j2k_t* p_j2k); /** * Get the codestream index from a JPEG2000 codec. * - *@param p_j2k the component image header to dump. + *@param p_j2k the component image header to dump. * - *@return the codestream index extract from the jpg2000 codec + *@return the codestream index extract from the jpg2000 codec */ opj_codestream_index_t* j2k_get_cstr_index(opj_j2k_t* p_j2k); @@ -808,64 +795,64 @@ OPJ_BOOL opj_j2k_decode(opj_j2k_t *j2k, opj_event_mgr_t *p_manager); -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_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_UINT32 res_factor, - opj_event_mgr_t * p_manager); +OPJ_BOOL opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k, + OPJ_UINT32 res_factor, + opj_event_mgr_t * p_manager); /** * Writes a tile. - * @param p_j2k the jpeg2000 codec. + * @param p_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. + * @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_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 ); +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, + 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( opj_j2k_t * p_j2k, - opj_stream_private_t *cio, - opj_event_mgr_t * p_manager ); +OPJ_BOOL opj_j2k_encode(opj_j2k_t * p_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 p_j2k the jpeg2000 codec. - * @param p_stream the stream object. - * @param p_image FIXME DOC - * @param p_manager the user event manager. + * @param p_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(opj_j2k_t *p_j2k, - opj_stream_private_t *p_stream, - opj_image_t * p_image, - opj_event_mgr_t * p_manager); + 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( opj_j2k_t *p_j2k, - opj_stream_private_t *cio, - opj_event_mgr_t * p_manager); +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_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 */ diff --git a/src/lib/openjp2/jp2.h b/src/lib/openjp2/jp2.h index b54d0bfd..7ca5b598 100644 --- a/src/lib/openjp2/jp2.h +++ b/src/lib/openjp2/jp2.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,7 +8,7 @@ * Copyright (c) 2002-2014, Professor Benoit Macq * Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2005, Herve Drolon, FreeImage Team - * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR + * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR * Copyright (c) 2012, CS Systemes d'Information, France * All rights reserved. * @@ -70,56 +70,50 @@ /* ----------------------------------------------------------------------- */ -typedef enum -{ - JP2_STATE_NONE = 0x0, - JP2_STATE_SIGNATURE = 0x1, - JP2_STATE_FILE_TYPE = 0x2, - JP2_STATE_HEADER = 0x4, - JP2_STATE_CODESTREAM = 0x8, - JP2_STATE_END_CODESTREAM = 0x10, - JP2_STATE_UNKNOWN = 0x7fffffff /* ISO C restricts enumerator values to range of 'int' */ +typedef enum { + JP2_STATE_NONE = 0x0, + JP2_STATE_SIGNATURE = 0x1, + JP2_STATE_FILE_TYPE = 0x2, + JP2_STATE_HEADER = 0x4, + JP2_STATE_CODESTREAM = 0x8, + JP2_STATE_END_CODESTREAM = 0x10, + JP2_STATE_UNKNOWN = 0x7fffffff /* ISO C restricts enumerator values to range of 'int' */ } JP2_STATE; -typedef enum -{ - JP2_IMG_STATE_NONE = 0x0, - JP2_IMG_STATE_UNKNOWN = 0x7fffffff +typedef enum { + JP2_IMG_STATE_NONE = 0x0, + JP2_IMG_STATE_UNKNOWN = 0x7fffffff } JP2_IMG_STATE; -/** +/** Channel description: channel index, type, association */ -typedef struct opj_jp2_cdef_info -{ +typedef struct opj_jp2_cdef_info { OPJ_UINT16 cn, typ, asoc; } opj_jp2_cdef_info_t; -/** +/** Channel descriptions and number of descriptions */ -typedef struct opj_jp2_cdef -{ +typedef struct opj_jp2_cdef { opj_jp2_cdef_info_t *info; OPJ_UINT16 n; } opj_jp2_cdef_t; -/** +/** Component mappings: channel index, mapping type, palette index */ -typedef struct opj_jp2_cmap_comp -{ +typedef struct opj_jp2_cmap_comp { OPJ_UINT16 cmp; OPJ_BYTE mtyp, pcol; } opj_jp2_cmap_comp_t; -/** +/** Palette data: table entries, palette columns */ -typedef struct opj_jp2_pclr -{ +typedef struct opj_jp2_pclr { OPJ_UINT32 *entries; OPJ_BYTE *channel_sign; OPJ_BYTE *channel_size; @@ -128,11 +122,10 @@ typedef struct opj_jp2_pclr OPJ_BYTE nr_channels; } opj_jp2_pclr_t; -/** -Collector for ICC profile, palette, component mapping, channel description +/** +Collector for ICC profile, palette, component mapping, channel description */ -typedef struct opj_jp2_color -{ +typedef struct opj_jp2_color { OPJ_BYTE *icc_profile_buf; OPJ_UINT32 icc_profile_len; @@ -141,59 +134,58 @@ typedef struct opj_jp2_color OPJ_BYTE jp2_has_colr; } opj_jp2_color_t; -/** +/** JP2 component */ typedef struct opj_jp2_comps { - OPJ_UINT32 depth; - OPJ_UINT32 sgnd; - OPJ_UINT32 bpcc; + OPJ_UINT32 depth; + OPJ_UINT32 sgnd; + OPJ_UINT32 bpcc; } opj_jp2_comps_t; /** JPEG-2000 file format reader/writer */ -typedef struct opj_jp2 -{ - /** handle to the J2K codec */ - opj_j2k_t *j2k; - /** list of validation procedures */ - struct opj_procedure_list * m_validation_list; - /** list of execution procedures */ - struct opj_procedure_list * m_procedure_list; - - /* width of image */ - OPJ_UINT32 w; - /* height of image */ - OPJ_UINT32 h; - /* number of components in the image */ - OPJ_UINT32 numcomps; - OPJ_UINT32 bpc; - OPJ_UINT32 C; - OPJ_UINT32 UnkC; - OPJ_UINT32 IPR; - OPJ_UINT32 meth; - OPJ_UINT32 approx; - OPJ_UINT32 enumcs; - OPJ_UINT32 precedence; - OPJ_UINT32 brand; - OPJ_UINT32 minversion; - OPJ_UINT32 numcl; - OPJ_UINT32 *cl; - opj_jp2_comps_t *comps; - /* FIXME: The following two variables are used to save offset - as we write out a JP2 file to disk. This mecanism is not flexible - as codec writers will need to extand those fields as new part - of the standard are implemented. - */ +typedef struct opj_jp2 { + /** handle to the J2K codec */ + opj_j2k_t *j2k; + /** list of validation procedures */ + struct opj_procedure_list * m_validation_list; + /** list of execution procedures */ + struct opj_procedure_list * m_procedure_list; + + /* width of image */ + OPJ_UINT32 w; + /* height of image */ + OPJ_UINT32 h; + /* number of components in the image */ + OPJ_UINT32 numcomps; + OPJ_UINT32 bpc; + OPJ_UINT32 C; + OPJ_UINT32 UnkC; + OPJ_UINT32 IPR; + OPJ_UINT32 meth; + OPJ_UINT32 approx; + OPJ_UINT32 enumcs; + OPJ_UINT32 precedence; + OPJ_UINT32 brand; + OPJ_UINT32 minversion; + OPJ_UINT32 numcl; + OPJ_UINT32 *cl; + opj_jp2_comps_t *comps; + /* FIXME: The following two variables are used to save offset + as we write out a JP2 file to disk. This mecanism is not flexible + as codec writers will need to extand those fields as new part + of the standard are implemented. + */ OPJ_OFF_T j2k_codestream_offset; OPJ_OFF_T jpip_iptr_offset; - OPJ_BOOL jpip_on; - OPJ_UINT32 jp2_state; - OPJ_UINT32 jp2_img_state; + OPJ_BOOL jpip_on; + OPJ_UINT32 jp2_state; + OPJ_UINT32 jp2_img_state; + + opj_jp2_color_t color; - opj_jp2_color_t color; - OPJ_BOOL ignore_pclr_cmap_cdef; } opj_jp2_t; @@ -207,28 +199,26 @@ typedef struct opj_jp2_box { OPJ_INT32 init_pos; } opj_jp2_box_t; -typedef struct opj_jp2_header_handler -{ - /* marker value */ - OPJ_UINT32 id; - /* action linked to the marker */ - OPJ_BOOL (*handler) ( opj_jp2_t *jp2, - OPJ_BYTE *p_header_data, - OPJ_UINT32 p_header_size, - opj_event_mgr_t * p_manager); +typedef struct opj_jp2_header_handler { + /* marker value */ + OPJ_UINT32 id; + /* action linked to the marker */ + OPJ_BOOL(*handler)(opj_jp2_t *jp2, + OPJ_BYTE *p_header_data, + OPJ_UINT32 p_header_size, + opj_event_mgr_t * p_manager); } opj_jp2_header_handler_t; -typedef struct opj_jp2_img_header_writer_handler -{ - /* action to perform */ - OPJ_BYTE* (*handler) (opj_jp2_t *jp2, OPJ_UINT32 * p_data_size); - /* result of the action : data */ - OPJ_BYTE* m_data; - /* size of data */ - OPJ_UINT32 m_size; -} +typedef struct opj_jp2_img_header_writer_handler { + /* action to perform */ + OPJ_BYTE* (*handler)(opj_jp2_t *jp2, OPJ_UINT32 * p_data_size); + /* result of the action : data */ + OPJ_BYTE* m_data; + /* size of data */ + OPJ_UINT32 m_size; +} opj_jp2_img_header_writer_handler_t; /** @name Exported functions */ @@ -256,12 +246,12 @@ OPJ_BOOL opj_jp2_set_threads(opj_jp2_t *jp2, OPJ_UINT32 num_threads); */ OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2, opj_stream_private_t *p_stream, - opj_image_t* p_image, - opj_event_mgr_t * p_manager); + opj_image_t* p_image, + opj_event_mgr_t * p_manager); /** - * Setup the encoder parameters using the current image and using user parameters. - * Coding parameters are returned in jp2->j2k->cp. + * Setup the encoder parameters using the current image and using user parameters. + * Coding parameters are returned in jp2->j2k->cp. * * @param jp2 JP2 compressor handle * @param parameters compression parameters @@ -269,10 +259,10 @@ OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2, * @param p_manager FIXME DOC * @return OPJ_TRUE if successful, OPJ_FALSE otherwise */ -OPJ_BOOL opj_jp2_setup_encoder( opj_jp2_t *jp2, - opj_cparameters_t *parameters, - opj_image_t *image, - opj_event_mgr_t * p_manager); +OPJ_BOOL opj_jp2_setup_encoder(opj_jp2_t *jp2, + opj_cparameters_t *parameters, + opj_image_t *image, + opj_event_mgr_t * p_manager); /** Encode an image into a JPEG-2000 file stream @@ -281,9 +271,9 @@ Encode an image into a JPEG-2000 file stream @param p_manager event manager @return Returns true if successful, returns false otherwise */ -OPJ_BOOL opj_jp2_encode( opj_jp2_t *jp2, - opj_stream_private_t *stream, - opj_event_mgr_t * p_manager); +OPJ_BOOL opj_jp2_encode(opj_jp2_t *jp2, + opj_stream_private_t *stream, + opj_event_mgr_t * p_manager); /** @@ -306,9 +296,9 @@ OPJ_BOOL opj_jp2_start_compress(opj_jp2_t *jp2, * Ends the compression procedures and possibiliy add data to be read after the * codestream. */ -OPJ_BOOL opj_jp2_end_compress( opj_jp2_t *jp2, - opj_stream_private_t *cio, - opj_event_mgr_t * p_manager); +OPJ_BOOL opj_jp2_end_compress(opj_jp2_t *jp2, + opj_stream_private_t *cio, + opj_event_mgr_t * p_manager); /* ----------------------------------------------------------------------- */ @@ -316,7 +306,7 @@ OPJ_BOOL opj_jp2_end_compress( opj_jp2_t *jp2, * Ends the decompression procedures and possibiliy add data to be read after the * codestream. */ -OPJ_BOOL opj_jp2_end_decompress(opj_jp2_t *jp2, +OPJ_BOOL opj_jp2_end_decompress(opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t * p_manager); @@ -330,10 +320,10 @@ OPJ_BOOL opj_jp2_end_decompress(opj_jp2_t *jp2, * * @return true if the box is valid. */ -OPJ_BOOL opj_jp2_read_header( opj_stream_private_t *p_stream, - opj_jp2_t *jp2, - opj_image_t ** p_image, - opj_event_mgr_t * p_manager ); +OPJ_BOOL opj_jp2_read_header(opj_stream_private_t *p_stream, + opj_jp2_t *jp2, + opj_image_t ** p_image, + opj_event_mgr_t * p_manager); /** * Reads a tile header. @@ -349,17 +339,17 @@ OPJ_BOOL opj_jp2_read_header( opj_stream_private_t *p_stream, * @param p_stream the stream to write data to. * @param p_manager the user event manager. */ -OPJ_BOOL opj_jp2_read_tile_header ( opj_jp2_t * p_jp2, - 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 ); +OPJ_BOOL opj_jp2_read_tile_header(opj_jp2_t * p_jp2, + 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); /** * Writes a tile. @@ -371,12 +361,12 @@ OPJ_BOOL opj_jp2_read_tile_header ( opj_jp2_t * p_jp2, * @param p_stream the stream to write data to. * @param p_manager the user event manager. */ -OPJ_BOOL opj_jp2_write_tile ( opj_jp2_t *p_jp2, - 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 ); +OPJ_BOOL opj_jp2_write_tile(opj_jp2_t *p_jp2, + 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); /** * Decode tile data. @@ -389,19 +379,19 @@ OPJ_BOOL opj_jp2_write_tile ( opj_jp2_t *p_jp2, * * @return FIXME DOC */ -OPJ_BOOL opj_jp2_decode_tile ( opj_jp2_t * p_jp2, - 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 ); +OPJ_BOOL opj_jp2_decode_tile(opj_jp2_t * p_jp2, + 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); /** * Creates a jpeg2000 file decompressor. * * @return an empty jpeg2000 file codec. */ -opj_jp2_t* opj_jp2_create (OPJ_BOOL p_is_decoder); +opj_jp2_t* opj_jp2_create(OPJ_BOOL p_is_decoder); /** Destroy a JP2 decompressor handle @@ -423,28 +413,28 @@ void opj_jp2_destroy(opj_jp2_t *jp2); * * @return true if the area could be set. */ -OPJ_BOOL opj_jp2_set_decode_area( opj_jp2_t *p_jp2, - 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 ); - - /** - * - */ -OPJ_BOOL opj_jp2_get_tile( opj_jp2_t *p_jp2, - opj_stream_private_t *p_stream, - opj_image_t* p_image, - opj_event_mgr_t * p_manager, - OPJ_UINT32 tile_index ); +OPJ_BOOL opj_jp2_set_decode_area(opj_jp2_t *p_jp2, + 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); + +/** +* +*/ +OPJ_BOOL opj_jp2_get_tile(opj_jp2_t *p_jp2, + opj_stream_private_t *p_stream, + opj_image_t* p_image, + opj_event_mgr_t * p_manager, + OPJ_UINT32 tile_index); /** - * + * */ -OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2, - OPJ_UINT32 res_factor, - opj_event_mgr_t * p_manager); +OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2, + OPJ_UINT32 res_factor, + opj_event_mgr_t * p_manager); /* TODO MSD: clean these 3 functions */ @@ -456,7 +446,7 @@ OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2, *@param out_stream output stream where dump the elements. * */ -void jp2_dump (opj_jp2_t* p_jp2, OPJ_INT32 flag, FILE* out_stream); +void jp2_dump(opj_jp2_t* p_jp2, OPJ_INT32 flag, FILE* out_stream); /** * Get the codestream info from a JPEG2000 codec. diff --git a/src/lib/openjp2/mct.h b/src/lib/openjp2/mct.h index 1bc722e3..293cdfe8 100644 --- a/src/lib/openjp2/mct.h +++ b/src/lib/openjp2/mct.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,10 +8,10 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team - * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR + * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR * Copyright (c) 2012, CS Systemes d'Information, France * All rights reserved. * @@ -60,7 +60,8 @@ Apply a reversible multi-component transform to an image @param c2 Samples blue component @param n Number of samples for each component */ -void opj_mct_encode(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1, OPJ_INT32* OPJ_RESTRICT c2, OPJ_UINT32 n); +void opj_mct_encode(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1, + OPJ_INT32* OPJ_RESTRICT c2, OPJ_UINT32 n); /** Apply a reversible multi-component inverse transform to an image @param c0 Samples for luminance component @@ -68,11 +69,12 @@ Apply a reversible multi-component inverse transform to an image @param c2 Samples for blue chrominance component @param n Number of samples for each component */ -void opj_mct_decode(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1, OPJ_INT32* OPJ_RESTRICT c2, OPJ_UINT32 n); +void opj_mct_decode(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1, + OPJ_INT32* OPJ_RESTRICT c2, OPJ_UINT32 n); /** Get norm of the basis function used for the reversible multi-component transform @param compno Number of the component (0->Y, 1->U, 2->V) -@return +@return */ OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno); @@ -83,7 +85,8 @@ Apply an irreversible multi-component transform to an image @param c2 Samples blue component @param n Number of samples for each component */ -void opj_mct_encode_real(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1, OPJ_INT32* OPJ_RESTRICT c2, OPJ_UINT32 n); +void opj_mct_encode_real(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1, + OPJ_INT32* OPJ_RESTRICT c2, OPJ_UINT32 n); /** Apply an irreversible multi-component inverse transform to an image @param c0 Samples for luminance component @@ -91,11 +94,12 @@ Apply an irreversible multi-component inverse transform to an image @param c2 Samples for blue chrominance component @param n Number of samples for each component */ -void opj_mct_decode_real(OPJ_FLOAT32* OPJ_RESTRICT c0, OPJ_FLOAT32* OPJ_RESTRICT c1, OPJ_FLOAT32* OPJ_RESTRICT c2, OPJ_UINT32 n); +void opj_mct_decode_real(OPJ_FLOAT32* OPJ_RESTRICT c0, + OPJ_FLOAT32* OPJ_RESTRICT c1, OPJ_FLOAT32* OPJ_RESTRICT c2, OPJ_UINT32 n); /** Get norm of the basis function used for the irreversible multi-component transform @param compno Number of the component (0->Y, 1->U, 2->V) -@return +@return */ OPJ_FLOAT64 opj_mct_getnorm_real(OPJ_UINT32 compno); @@ -109,11 +113,11 @@ FIXME DOC @return OPJ_FALSE if function encounter a problem, OPJ_TRUE otherwise */ OPJ_BOOL opj_mct_encode_custom( - OPJ_BYTE * p_coding_data, - OPJ_UINT32 n, - OPJ_BYTE ** p_data, - OPJ_UINT32 p_nb_comp, - OPJ_UINT32 is_signed); + OPJ_BYTE * p_coding_data, + OPJ_UINT32 n, + OPJ_BYTE ** p_data, + OPJ_UINT32 p_nb_comp, + OPJ_UINT32 is_signed); /** FIXME DOC @param pDecodingData MCT data @@ -124,29 +128,29 @@ FIXME DOC @return OPJ_FALSE if function encounter a problem, OPJ_TRUE otherwise */ OPJ_BOOL opj_mct_decode_custom( - OPJ_BYTE * pDecodingData, - OPJ_UINT32 n, - OPJ_BYTE ** pData, - OPJ_UINT32 pNbComp, - OPJ_UINT32 isSigned); + OPJ_BYTE * pDecodingData, + OPJ_UINT32 n, + OPJ_BYTE ** pData, + OPJ_UINT32 pNbComp, + OPJ_UINT32 isSigned); /** FIXME DOC @param pNorms MCT data @param p_nb_comps size of components @param pMatrix components -@return +@return */ -void opj_calculate_norms( OPJ_FLOAT64 * pNorms, - OPJ_UINT32 p_nb_comps, - OPJ_FLOAT32 * pMatrix); +void opj_calculate_norms(OPJ_FLOAT64 * pNorms, + OPJ_UINT32 p_nb_comps, + OPJ_FLOAT32 * pMatrix); /** -FIXME DOC +FIXME DOC */ -const OPJ_FLOAT64 * opj_mct_get_mct_norms (void); +const OPJ_FLOAT64 * opj_mct_get_mct_norms(void); /** -FIXME DOC +FIXME DOC */ -const OPJ_FLOAT64 * opj_mct_get_mct_norms_real (void); +const OPJ_FLOAT64 * opj_mct_get_mct_norms_real(void); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/src/lib/openjp2/mqc.h b/src/lib/openjp2/mqc.h index 491ee50e..8417bb0a 100644 --- a/src/lib/openjp2/mqc.h +++ b/src/lib/openjp2/mqc.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,7 +8,7 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr> @@ -53,14 +53,14 @@ in MQC.C are used by some function in T1.C. This struct defines the state of a context. */ typedef struct opj_mqc_state { - /** the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff) */ - OPJ_UINT32 qeval; - /** the Most Probable Symbol (0 or 1) */ - OPJ_UINT32 mps; - /** next state if the next encoded symbol is the MPS */ - struct opj_mqc_state *nmps; - /** next state if the next encoded symbol is the LPS */ - struct opj_mqc_state *nlps; + /** the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff) */ + OPJ_UINT32 qeval; + /** the Most Probable Symbol (0 or 1) */ + OPJ_UINT32 mps; + /** next state if the next encoded symbol is the MPS */ + struct opj_mqc_state *nmps; + /** next state if the next encoded symbol is the LPS */ + struct opj_mqc_state *nlps; } opj_mqc_state_t; #define MQC_NUMCTXS 19 @@ -69,17 +69,17 @@ typedef struct opj_mqc_state { MQ coder */ typedef struct opj_mqc { - OPJ_UINT32 c; - OPJ_UINT32 a; - OPJ_UINT32 ct; - OPJ_BYTE *bp; - OPJ_BYTE *start; - OPJ_BYTE *end; - opj_mqc_state_t *ctxs[MQC_NUMCTXS]; - opj_mqc_state_t **curctx; - const OPJ_BYTE *lut_ctxno_zc_orient; /* lut_ctxno_zc shifted by 256 * bandno */ + OPJ_UINT32 c; + OPJ_UINT32 a; + OPJ_UINT32 ct; + OPJ_BYTE *bp; + OPJ_BYTE *start; + OPJ_BYTE *end; + opj_mqc_state_t *ctxs[MQC_NUMCTXS]; + opj_mqc_state_t **curctx; + const OPJ_BYTE *lut_ctxno_zc_orient; /* lut_ctxno_zc shifted by 256 * bandno */ #ifdef MQC_PERF_OPT - unsigned char *buffer; + unsigned char *buffer; #endif } opj_mqc_t; @@ -89,7 +89,7 @@ typedef struct opj_mqc { /*@{*/ /* ----------------------------------------------------------------------- */ /** -Create a new MQC handle +Create a new MQC handle @return Returns a new MQC handle if successful, returns NULL otherwise */ opj_mqc_t* opj_mqc_create(void); @@ -105,7 +105,7 @@ Return the number of bytes written/read since initialisation */ OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc); /** -Reset the states of all the context of the coder/decoder +Reset the states of all the context of the coder/decoder (each context is set to a state where 0 and 1 are more or less equiprobable) @param mqc MQC handle */ @@ -117,7 +117,8 @@ Set the state of a particular context @param msb The MSB of the new state of the context @param prob Number that identifies the probability of the symbols for the new state of the context */ -void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob); +void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, + OPJ_INT32 prob); /** Initialize the encoder @param mqc MQC handle @@ -129,7 +130,7 @@ Set the current context used for coding/decoding @param mqc MQC handle @param ctxno Number that identifies the context */ -#define opj_mqc_setcurctx(mqc, ctxno) (mqc)->curctx = &(mqc)->ctxs[(OPJ_UINT32)(ctxno)] +#define opj_mqc_setcurctx(mqc, ctxno) (mqc)->curctx = &(mqc)->ctxs[(OPJ_UINT32)(ctxno)] /** Encode a symbol using the MQ-coder @param mqc MQC handle @@ -142,15 +143,15 @@ Flush the encoder, so that all remaining data is written */ void opj_mqc_flush(opj_mqc_t *mqc); /** -BYPASS mode switch, initialization operation. -JPEG 2000 p 505. +BYPASS mode switch, initialization operation. +JPEG 2000 p 505. <h2>Not fully implemented and tested !!</h2> @param mqc MQC handle */ void opj_mqc_bypass_init_enc(opj_mqc_t *mqc); /** -BYPASS mode switch, coding operation. -JPEG 2000 p 505. +BYPASS mode switch, coding operation. +JPEG 2000 p 505. <h2>Not fully implemented and tested !!</h2> @param mqc MQC handle @param d The symbol to be encoded (0 or 1) diff --git a/src/lib/openjp2/mqc_inl.h b/src/lib/openjp2/mqc_inl.h index 882b59f4..7e1c17d1 100644 --- a/src/lib/openjp2/mqc_inl.h +++ b/src/lib/openjp2/mqc_inl.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,7 +8,7 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr> @@ -43,17 +43,18 @@ FIXME DOC @param mqc MQC handle @return */ -static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc) { - OPJ_INT32 d; - if (mqc->a < (*mqc->curctx)->qeval) { - d = (OPJ_INT32)(1 - (*mqc->curctx)->mps); - *mqc->curctx = (*mqc->curctx)->nlps; - } else { - d = (OPJ_INT32)(*mqc->curctx)->mps; - *mqc->curctx = (*mqc->curctx)->nmps; - } +static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc) +{ + OPJ_INT32 d; + if (mqc->a < (*mqc->curctx)->qeval) { + d = (OPJ_INT32)(1 - (*mqc->curctx)->mps); + *mqc->curctx = (*mqc->curctx)->nlps; + } else { + d = (OPJ_INT32)(*mqc->curctx)->mps; + *mqc->curctx = (*mqc->curctx)->nmps; + } - return d; + return d; } /** @@ -61,19 +62,20 @@ FIXME DOC @param mqc MQC handle @return */ -static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc) { - OPJ_INT32 d; - if (mqc->a < (*mqc->curctx)->qeval) { - mqc->a = (*mqc->curctx)->qeval; - d = (OPJ_INT32)(*mqc->curctx)->mps; - *mqc->curctx = (*mqc->curctx)->nmps; - } else { - mqc->a = (*mqc->curctx)->qeval; - d = (OPJ_INT32)(1 - (*mqc->curctx)->mps); - *mqc->curctx = (*mqc->curctx)->nlps; - } +static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc) +{ + OPJ_INT32 d; + if (mqc->a < (*mqc->curctx)->qeval) { + mqc->a = (*mqc->curctx)->qeval; + d = (OPJ_INT32)(*mqc->curctx)->mps; + *mqc->curctx = (*mqc->curctx)->nmps; + } else { + mqc->a = (*mqc->curctx)->qeval; + d = (OPJ_INT32)(1 - (*mqc->curctx)->mps); + *mqc->curctx = (*mqc->curctx)->nlps; + } - return d; + return d; } /** @@ -81,39 +83,41 @@ Input a byte @param mqc MQC handle */ #ifdef MQC_PERF_OPT -static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc) { - unsigned int i = *((unsigned int *) mqc->bp); - mqc->c += i & 0xffff00; - mqc->ct = i & 0x0f; - mqc->bp += (i >> 2) & 0x04; +static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc) +{ + unsigned int i = *((unsigned int *) mqc->bp); + mqc->c += i & 0xffff00; + mqc->ct = i & 0x0f; + mqc->bp += (i >> 2) & 0x04; } #else -static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc) { - if (mqc->bp != mqc->end) { - OPJ_UINT32 c; - if (mqc->bp + 1 != mqc->end) { - c = *(mqc->bp + 1); - } else { - c = 0xff; - } - if (*mqc->bp == 0xff) { - if (c > 0x8f) { - mqc->c += 0xff00; - mqc->ct = 8; - } else { - mqc->bp++; - mqc->c += c << 9; - mqc->ct = 7; - } - } else { - mqc->bp++; - mqc->c += c << 8; - mqc->ct = 8; - } - } else { - mqc->c += 0xff00; - mqc->ct = 8; - } +static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc) +{ + if (mqc->bp != mqc->end) { + OPJ_UINT32 c; + if (mqc->bp + 1 != mqc->end) { + c = *(mqc->bp + 1); + } else { + c = 0xff; + } + if (*mqc->bp == 0xff) { + if (c > 0x8f) { + mqc->c += 0xff00; + mqc->ct = 8; + } else { + mqc->bp++; + mqc->c += c << 9; + mqc->ct = 7; + } + } else { + mqc->bp++; + mqc->c += c << 8; + mqc->ct = 8; + } + } else { + mqc->c += 0xff00; + mqc->ct = 8; + } } #endif @@ -121,15 +125,16 @@ static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc) { Renormalize mqc->a and mqc->c while decoding @param mqc MQC handle */ -static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc) { - do { - if (mqc->ct == 0) { - opj_mqc_bytein(mqc); - } - mqc->a <<= 1; - mqc->c <<= 1; - mqc->ct--; - } while (mqc->a < 0x8000); +static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc) +{ + do { + if (mqc->ct == 0) { + opj_mqc_bytein(mqc); + } + mqc->a <<= 1; + mqc->c <<= 1; + mqc->ct--; + } while (mqc->a < 0x8000); } /** @@ -137,23 +142,24 @@ Decode a symbol @param mqc MQC handle @return Returns the decoded symbol (0 or 1) */ -static INLINE OPJ_INT32 opj_mqc_decode(opj_mqc_t *const mqc) { - OPJ_INT32 d; - mqc->a -= (*mqc->curctx)->qeval; - if ((mqc->c >> 16) < (*mqc->curctx)->qeval) { - d = opj_mqc_lpsexchange(mqc); - opj_mqc_renormd(mqc); - } else { - mqc->c -= (*mqc->curctx)->qeval << 16; - if ((mqc->a & 0x8000) == 0) { - d = opj_mqc_mpsexchange(mqc); - opj_mqc_renormd(mqc); - } else { - d = (OPJ_INT32)(*mqc->curctx)->mps; - } - } +static INLINE OPJ_INT32 opj_mqc_decode(opj_mqc_t *const mqc) +{ + OPJ_INT32 d; + mqc->a -= (*mqc->curctx)->qeval; + if ((mqc->c >> 16) < (*mqc->curctx)->qeval) { + d = opj_mqc_lpsexchange(mqc); + opj_mqc_renormd(mqc); + } else { + mqc->c -= (*mqc->curctx)->qeval << 16; + if ((mqc->a & 0x8000) == 0) { + d = opj_mqc_mpsexchange(mqc); + opj_mqc_renormd(mqc); + } else { + d = (OPJ_INT32)(*mqc->curctx)->mps; + } + } - return d; + return d; } #endif /* __MQC_INL_H */ diff --git a/src/lib/openjp2/openjpeg.h b/src/lib/openjp2/openjpeg.h index 7912c236..c7c82fcc 100644 --- a/src/lib/openjp2/openjpeg.h +++ b/src/lib/openjp2/openjpeg.h @@ -1,110 +1,110 @@ - /* - * 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 <jerome.fimes@c-s.fr> - * Copyright (c) 2010-2011, Kaori Hagihara - * 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. - */ +/* +* 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 <jerome.fimes@c-s.fr> +* Copyright (c) 2010-2011, Kaori Hagihara +* 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 OPENJPEG_H #define OPENJPEG_H -/* +/* ========================================================== Compiler directives ========================================================== */ /* -The inline keyword is supported by C99 but not by C90. -Most compilers implement their own version of this keyword ... +The inline keyword is supported by C99 but not by C90. +Most compilers implement their own version of this keyword ... */ #ifndef INLINE - #if defined(_MSC_VER) - #define INLINE __forceinline - #elif defined(__GNUC__) - #define INLINE __inline__ - #elif defined(__MWERKS__) - #define INLINE inline - #else - /* add other compilers here ... */ - #define INLINE - #endif /* defined(<Compiler>) */ +#if defined(_MSC_VER) +#define INLINE __forceinline +#elif defined(__GNUC__) +#define INLINE __inline__ +#elif defined(__MWERKS__) +#define INLINE inline +#else +/* add other compilers here ... */ +#define INLINE +#endif /* defined(<Compiler>) */ #endif /* INLINE */ /* deprecated attribute */ #ifdef __GNUC__ - #define OPJ_DEPRECATED(func) func __attribute__ ((deprecated)) +#define OPJ_DEPRECATED(func) func __attribute__ ((deprecated)) #elif defined(_MSC_VER) - #define OPJ_DEPRECATED(func) __declspec(deprecated) func +#define OPJ_DEPRECATED(func) __declspec(deprecated) func #else - #pragma message("WARNING: You need to implement DEPRECATED for this compiler") - #define OPJ_DEPRECATED(func) func +#pragma message("WARNING: You need to implement DEPRECATED for this compiler") +#define OPJ_DEPRECATED(func) func #endif #if defined(OPJ_STATIC) || !defined(_WIN32) /* http://gcc.gnu.org/wiki/Visibility */ -# if __GNUC__ >= 4 -# if defined(OPJ_STATIC) /* static library uses "hidden" */ -# define OPJ_API __attribute__ ((visibility ("hidden"))) -# else -# define OPJ_API __attribute__ ((visibility ("default"))) -# endif -# define OPJ_LOCAL __attribute__ ((visibility ("hidden"))) -# else -# define OPJ_API -# define OPJ_LOCAL -# endif -# define OPJ_CALLCONV +# if __GNUC__ >= 4 +# if defined(OPJ_STATIC) /* static library uses "hidden" */ +# define OPJ_API __attribute__ ((visibility ("hidden"))) +# else +# define OPJ_API __attribute__ ((visibility ("default"))) +# endif +# define OPJ_LOCAL __attribute__ ((visibility ("hidden"))) +# else +# define OPJ_API +# define OPJ_LOCAL +# endif +# define OPJ_CALLCONV #else -# define OPJ_CALLCONV __stdcall +# define OPJ_CALLCONV __stdcall /* -The following ifdef block is the standard way of creating macros which make exporting +The following ifdef block is the standard way of creating macros which make exporting from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS symbol defined on the command line. this symbol should not be defined on any project -that uses this DLL. This way any other project whose source files include this file see +that uses this DLL. This way any other project whose source files include this file see OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols defined with this macro as being exported. */ -# if defined(OPJ_EXPORTS) || defined(DLL_EXPORT) -# define OPJ_API __declspec(dllexport) -# else -# define OPJ_API __declspec(dllimport) -# endif /* OPJ_EXPORTS */ +# if defined(OPJ_EXPORTS) || defined(DLL_EXPORT) +# define OPJ_API __declspec(dllexport) +# else +# define OPJ_API __declspec(dllimport) +# endif /* OPJ_EXPORTS */ #endif /* !OPJ_STATIC || !_WIN32 */ typedef int OPJ_BOOL; @@ -135,7 +135,7 @@ typedef size_t OPJ_SIZE_T; /* Avoid compile-time warning because parameter is not used */ #define OPJ_ARG_NOT_USED(x) (void)(x) -/* +/* ========================================================== Useful constant definitions ========================================================== @@ -143,19 +143,19 @@ typedef size_t OPJ_SIZE_T; #define OPJ_PATH_LEN 4096 /**< Maximum allowed size for filenames */ -#define OPJ_J2K_MAXRLVLS 33 /**< Number of maximum resolution level authorized */ -#define OPJ_J2K_MAXBANDS (3*OPJ_J2K_MAXRLVLS-2) /**< Number of maximum sub-band linked to number of resolution level */ +#define OPJ_J2K_MAXRLVLS 33 /**< Number of maximum resolution level authorized */ +#define OPJ_J2K_MAXBANDS (3*OPJ_J2K_MAXRLVLS-2) /**< Number of maximum sub-band linked to number of resolution level */ -#define OPJ_J2K_DEFAULT_NB_SEGS 10 -#define OPJ_J2K_STREAM_CHUNK_SIZE 0x100000 /** 1 mega by default */ -#define OPJ_J2K_DEFAULT_HEADER_SIZE 1000 -#define OPJ_J2K_MCC_DEFAULT_NB_RECORDS 10 -#define OPJ_J2K_MCT_DEFAULT_NB_RECORDS 10 +#define OPJ_J2K_DEFAULT_NB_SEGS 10 +#define OPJ_J2K_STREAM_CHUNK_SIZE 0x100000 /** 1 mega by default */ +#define OPJ_J2K_DEFAULT_HEADER_SIZE 1000 +#define OPJ_J2K_MCC_DEFAULT_NB_RECORDS 10 +#define OPJ_J2K_MCT_DEFAULT_NB_RECORDS 10 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */ -#define JPWL_MAX_NO_TILESPECS 16 /**< Maximum number of tile parts expected by JPWL: increase at your will */ -#define JPWL_MAX_NO_PACKSPECS 16 /**< Maximum number of packet parts expected by JPWL: increase at your will */ -#define JPWL_MAX_NO_MARKERS 512 /**< Maximum number of JPWL markers: increase at your will */ +#define JPWL_MAX_NO_TILESPECS 16 /**< Maximum number of tile parts expected by JPWL: increase at your will */ +#define JPWL_MAX_NO_PACKSPECS 16 /**< Maximum number of packet parts expected by JPWL: increase at your will */ +#define JPWL_MAX_NO_MARKERS 512 /**< Maximum number of JPWL markers: increase at your will */ #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */ #define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */ #define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */ @@ -167,15 +167,15 @@ typedef size_t OPJ_SIZE_T; * EXPERIMENTAL FOR THE MOMENT * Supported options about file information used only in j2k_dump */ -#define OPJ_IMG_INFO 1 /**< Basic image information provided to the user */ -#define OPJ_J2K_MH_INFO 2 /**< Codestream information based only on the main header */ -#define OPJ_J2K_TH_INFO 4 /**< Tile information based on the current tile header */ -#define OPJ_J2K_TCH_INFO 8 /**< Tile/Component information of all tiles */ -#define OPJ_J2K_MH_IND 16 /**< Codestream index based only on the main header */ -#define OPJ_J2K_TH_IND 32 /**< Tile index based on the current tile */ -/*FIXME #define OPJ_J2K_CSTR_IND 48*/ /**< */ -#define OPJ_JP2_INFO 128 /**< JP2 file information */ -#define OPJ_JP2_IND 256 /**< JP2 file index */ +#define OPJ_IMG_INFO 1 /**< Basic image information provided to the user */ +#define OPJ_J2K_MH_INFO 2 /**< Codestream information based only on the main header */ +#define OPJ_J2K_TH_INFO 4 /**< Tile information based on the current tile header */ +#define OPJ_J2K_TCH_INFO 8 /**< Tile/Component information of all tiles */ +#define OPJ_J2K_MH_IND 16 /**< Codestream index based only on the main header */ +#define OPJ_J2K_TH_IND 32 /**< Tile index based on the current tile */ +/*FIXME #define OPJ_J2K_CSTR_IND 48*/ /**< */ +#define OPJ_JP2_INFO 128 /**< JP2 file information */ +#define OPJ_JP2_IND 256 /**< JP2 file index */ /** * JPEG 2000 Profiles, see Table A.10 from 15444-1 (updated in various AMD) @@ -228,12 +228,12 @@ typedef size_t OPJ_SIZE_T; /** * JPEG 2000 codestream and component size limits in cinema profiles * */ -#define OPJ_CINEMA_24_CS 1302083 /** Maximum codestream length for 24fps */ +#define OPJ_CINEMA_24_CS 1302083 /** Maximum codestream length for 24fps */ #define OPJ_CINEMA_48_CS 651041 /** Maximum codestream length for 48fps */ #define OPJ_CINEMA_24_COMP 1041666 /** Maximum size per color component for 2K & 4K @ 24fps */ -#define OPJ_CINEMA_48_COMP 520833 /** Maximum size per color component for 2K @ 48fps */ +#define OPJ_CINEMA_48_COMP 520833 /** Maximum size per color component for 2K @ 48fps */ -/* +/* ========================================================== enum definitions ========================================================== @@ -244,9 +244,9 @@ typedef size_t OPJ_SIZE_T; * Rsiz Capabilities * */ typedef enum RSIZ_CAPABILITIES { - OPJ_STD_RSIZ = 0, /** Standard JPEG2000 profile*/ - OPJ_CINEMA2K = 3, /** Profile name for a 2K image*/ - OPJ_CINEMA4K = 4, /** Profile name for a 4K image*/ + OPJ_STD_RSIZ = 0, /** Standard JPEG2000 profile*/ + OPJ_CINEMA2K = 3, /** Profile name for a 2K image*/ + OPJ_CINEMA4K = 4, /** Profile name for a 4K image*/ OPJ_MCT = 0x8100 } OPJ_RSIZ_CAPABILITIES; @@ -255,33 +255,33 @@ typedef enum RSIZ_CAPABILITIES { * Digital cinema operation mode * */ typedef enum CINEMA_MODE { - OPJ_OFF = 0, /** Not Digital Cinema*/ - OPJ_CINEMA2K_24 = 1, /** 2K Digital Cinema at 24 fps*/ - OPJ_CINEMA2K_48 = 2, /** 2K Digital Cinema at 48 fps*/ - OPJ_CINEMA4K_24 = 3 /** 4K Digital Cinema at 24 fps*/ -}OPJ_CINEMA_MODE; + OPJ_OFF = 0, /** Not Digital Cinema*/ + OPJ_CINEMA2K_24 = 1, /** 2K Digital Cinema at 24 fps*/ + OPJ_CINEMA2K_48 = 2, /** 2K Digital Cinema at 48 fps*/ + OPJ_CINEMA4K_24 = 3 /** 4K Digital Cinema at 24 fps*/ +} OPJ_CINEMA_MODE; -/** +/** * Progression order * */ typedef enum PROG_ORDER { - OPJ_PROG_UNKNOWN = -1, /**< place-holder */ - OPJ_LRCP = 0, /**< layer-resolution-component-precinct order */ - OPJ_RLCP = 1, /**< resolution-layer-component-precinct order */ - OPJ_RPCL = 2, /**< resolution-precinct-component-layer order */ - OPJ_PCRL = 3, /**< precinct-component-resolution-layer order */ - OPJ_CPRL = 4 /**< component-precinct-resolution-layer order */ + OPJ_PROG_UNKNOWN = -1, /**< place-holder */ + OPJ_LRCP = 0, /**< layer-resolution-component-precinct order */ + OPJ_RLCP = 1, /**< resolution-layer-component-precinct order */ + OPJ_RPCL = 2, /**< resolution-precinct-component-layer order */ + OPJ_PCRL = 3, /**< precinct-component-resolution-layer order */ + OPJ_CPRL = 4 /**< component-precinct-resolution-layer order */ } OPJ_PROG_ORDER; /** * Supported image color spaces */ typedef enum COLOR_SPACE { - OPJ_CLRSPC_UNKNOWN = -1, /**< not supported by the library */ - OPJ_CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */ - OPJ_CLRSPC_SRGB = 1, /**< sRGB */ - OPJ_CLRSPC_GRAY = 2, /**< grayscale */ - OPJ_CLRSPC_SYCC = 3, /**< YUV */ + OPJ_CLRSPC_UNKNOWN = -1, /**< not supported by the library */ + OPJ_CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */ + OPJ_CLRSPC_SRGB = 1, /**< sRGB */ + OPJ_CLRSPC_GRAY = 2, /**< grayscale */ + OPJ_CLRSPC_SYCC = 3, /**< YUV */ OPJ_CLRSPC_EYCC = 4, /**< e-YCC */ OPJ_CLRSPC_CMYK = 5 /**< CMYK */ } OPJ_COLOR_SPACE; @@ -290,16 +290,16 @@ typedef enum COLOR_SPACE { * Supported codec */ typedef enum CODEC_FORMAT { - OPJ_CODEC_UNKNOWN = -1, /**< place-holder */ - OPJ_CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */ - OPJ_CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */ - OPJ_CODEC_JP2 = 2, /**< JP2 file format : read/write */ - OPJ_CODEC_JPP = 3, /**< JPP-stream (JPEG 2000, JPIP) : to be coded */ - OPJ_CODEC_JPX = 4 /**< JPX file format (JPEG 2000 Part-2) : to be coded */ + OPJ_CODEC_UNKNOWN = -1, /**< place-holder */ + OPJ_CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */ + OPJ_CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */ + OPJ_CODEC_JP2 = 2, /**< JP2 file format : read/write */ + OPJ_CODEC_JPP = 3, /**< JPP-stream (JPEG 2000, JPIP) : to be coded */ + OPJ_CODEC_JPX = 4 /**< JPX file format (JPEG 2000 Part-2) : to be coded */ } OPJ_CODEC_FORMAT; -/* +/* ========================================================== event manager typedef definitions ========================================================== @@ -308,11 +308,11 @@ typedef enum CODEC_FORMAT { /** * Callback function prototype for events * @param msg Event message - * @param client_data Client object where will be return the event message + * @param client_data Client object where will be return the event message * */ -typedef void (*opj_msg_callback) (const char *msg, void *client_data); +typedef void (*opj_msg_callback)(const char *msg, void *client_data); -/* +/* ========================================================== codec typedef definitions ========================================================== @@ -320,147 +320,147 @@ typedef void (*opj_msg_callback) (const char *msg, void *client_data); /** * Progression order changes - * + * */ typedef struct opj_poc { - /** Resolution num start, Component num start, given by POC */ - OPJ_UINT32 resno0, compno0; - /** Layer num end,Resolution num end, Component num end, given by POC */ - OPJ_UINT32 layno1, resno1, compno1; - /** Layer num start,Precinct num start, Precinct num end */ - OPJ_UINT32 layno0, precno0, precno1; - /** Progression order enum*/ - OPJ_PROG_ORDER prg1,prg; - /** Progression order string*/ - OPJ_CHAR progorder[5]; - /** Tile number */ - OPJ_UINT32 tile; - /** Start and end values for Tile width and height*/ - OPJ_INT32 tx0,tx1,ty0,ty1; - /** Start value, initialised in pi_initialise_encode*/ - OPJ_UINT32 layS, resS, compS, prcS; - /** End value, initialised in pi_initialise_encode */ - OPJ_UINT32 layE, resE, compE, prcE; - /** Start and end values of Tile width and height, initialised in pi_initialise_encode*/ - OPJ_UINT32 txS,txE,tyS,tyE,dx,dy; - /** Temporary values for Tile parts, initialised in pi_create_encode */ - OPJ_UINT32 lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t; + /** Resolution num start, Component num start, given by POC */ + OPJ_UINT32 resno0, compno0; + /** Layer num end,Resolution num end, Component num end, given by POC */ + OPJ_UINT32 layno1, resno1, compno1; + /** Layer num start,Precinct num start, Precinct num end */ + OPJ_UINT32 layno0, precno0, precno1; + /** Progression order enum*/ + OPJ_PROG_ORDER prg1, prg; + /** Progression order string*/ + OPJ_CHAR progorder[5]; + /** Tile number */ + OPJ_UINT32 tile; + /** Start and end values for Tile width and height*/ + OPJ_INT32 tx0, tx1, ty0, ty1; + /** Start value, initialised in pi_initialise_encode*/ + OPJ_UINT32 layS, resS, compS, prcS; + /** End value, initialised in pi_initialise_encode */ + OPJ_UINT32 layE, resE, compE, prcE; + /** Start and end values of Tile width and height, initialised in pi_initialise_encode*/ + OPJ_UINT32 txS, txE, tyS, tyE, dx, dy; + /** Temporary values for Tile parts, initialised in pi_create_encode */ + OPJ_UINT32 lay_t, res_t, comp_t, prc_t, tx0_t, ty0_t; } opj_poc_t; /** * Compression parameters * */ typedef struct opj_cparameters { - /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */ - OPJ_BOOL tile_size_on; - /** XTOsiz */ - int cp_tx0; - /** YTOsiz */ - int cp_ty0; - /** XTsiz */ - int cp_tdx; - /** YTsiz */ - int cp_tdy; - /** allocation by rate/distortion */ - int cp_disto_alloc; - /** allocation by fixed layer */ - int cp_fixed_alloc; - /** add fixed_quality */ - int cp_fixed_quality; - /** fixed layer */ - int *cp_matrice; - /** comment for coding */ - char *cp_comment; - /** csty : coding style */ - int csty; - /** progression order (default OPJ_LRCP) */ - OPJ_PROG_ORDER prog_order; - /** progression order changes */ - opj_poc_t POC[32]; - /** number of progression order changes (POC), default to 0 */ - OPJ_UINT32 numpocs; - /** number of layers */ - int tcp_numlayers; + /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */ + OPJ_BOOL tile_size_on; + /** XTOsiz */ + int cp_tx0; + /** YTOsiz */ + int cp_ty0; + /** XTsiz */ + int cp_tdx; + /** YTsiz */ + int cp_tdy; + /** allocation by rate/distortion */ + int cp_disto_alloc; + /** allocation by fixed layer */ + int cp_fixed_alloc; + /** add fixed_quality */ + int cp_fixed_quality; + /** fixed layer */ + int *cp_matrice; + /** comment for coding */ + char *cp_comment; + /** csty : coding style */ + int csty; + /** progression order (default OPJ_LRCP) */ + OPJ_PROG_ORDER prog_order; + /** progression order changes */ + opj_poc_t POC[32]; + /** number of progression order changes (POC), default to 0 */ + OPJ_UINT32 numpocs; + /** number of layers */ + int tcp_numlayers; /** rates of layers - might be subsequently limited by the max_cs_size field */ - float tcp_rates[100]; - /** different psnr for successive layers */ - float tcp_distoratio[100]; - /** number of resolutions */ - int numresolution; - /** initial code block width, default to 64 */ - int cblockw_init; - /** initial code block height, default to 64 */ - int cblockh_init; - /** mode switch (cblk_style) */ - int mode; - /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */ - int irreversible; - /** region of interest: affected component in [0..3], -1 means no ROI */ - int roi_compno; - /** region of interest: upshift value */ - int roi_shift; - /* number of precinct size specifications */ - int res_spec; - /** initial precinct width */ - int prcw_init[OPJ_J2K_MAXRLVLS]; - /** initial precinct height */ - int prch_init[OPJ_J2K_MAXRLVLS]; - - /**@name command line encoder parameters (not used inside the library) */ - /*@{*/ - /** input file name */ - char infile[OPJ_PATH_LEN]; - /** output file name */ - char outfile[OPJ_PATH_LEN]; - /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */ - int index_on; - /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */ - char index[OPJ_PATH_LEN]; - /** subimage encoding: origin image offset in x direction */ - int image_offset_x0; - /** subimage encoding: origin image offset in y direction */ - int image_offset_y0; - /** subsampling value for dx */ - int subsampling_dx; - /** subsampling value for dy */ - int subsampling_dy; - /** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/ - int decod_format; - /** output file format 0: J2K, 1: JP2, 2: JPT */ - int cod_format; - /*@}*/ - -/* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */ - /**@name JPWL encoding parameters */ - /*@{*/ - /** enables writing of EPC in MH, thus activating JPWL */ - OPJ_BOOL jpwl_epc_on; - /** error protection method for MH (0,1,16,32,37-128) */ - int jpwl_hprot_MH; - /** tile number of header protection specification (>=0) */ - int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS]; - /** error protection methods for TPHs (0,1,16,32,37-128) */ - int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS]; - /** tile number of packet protection specification (>=0) */ - int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS]; - /** packet number of packet protection specification (>=0) */ - int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS]; - /** error protection methods for packets (0,1,16,32,37-128) */ - int jpwl_pprot[JPWL_MAX_NO_PACKSPECS]; - /** enables writing of ESD, (0=no/1/2 bytes) */ - int jpwl_sens_size; - /** sensitivity addressing size (0=auto/2/4 bytes) */ - int jpwl_sens_addr; - /** sensitivity range (0-3) */ - int jpwl_sens_range; - /** sensitivity method for MH (-1=no,0-7) */ - int jpwl_sens_MH; - /** tile number of sensitivity specification (>=0) */ - int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS]; - /** sensitivity methods for TPHs (-1=no,0-7) */ - int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS]; - /*@}*/ -/* <<UniPG */ + float tcp_rates[100]; + /** different psnr for successive layers */ + float tcp_distoratio[100]; + /** number of resolutions */ + int numresolution; + /** initial code block width, default to 64 */ + int cblockw_init; + /** initial code block height, default to 64 */ + int cblockh_init; + /** mode switch (cblk_style) */ + int mode; + /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */ + int irreversible; + /** region of interest: affected component in [0..3], -1 means no ROI */ + int roi_compno; + /** region of interest: upshift value */ + int roi_shift; + /* number of precinct size specifications */ + int res_spec; + /** initial precinct width */ + int prcw_init[OPJ_J2K_MAXRLVLS]; + /** initial precinct height */ + int prch_init[OPJ_J2K_MAXRLVLS]; + + /**@name command line encoder parameters (not used inside the library) */ + /*@{*/ + /** input file name */ + char infile[OPJ_PATH_LEN]; + /** output file name */ + char outfile[OPJ_PATH_LEN]; + /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */ + int index_on; + /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */ + char index[OPJ_PATH_LEN]; + /** subimage encoding: origin image offset in x direction */ + int image_offset_x0; + /** subimage encoding: origin image offset in y direction */ + int image_offset_y0; + /** subsampling value for dx */ + int subsampling_dx; + /** subsampling value for dy */ + int subsampling_dy; + /** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/ + int decod_format; + /** output file format 0: J2K, 1: JP2, 2: JPT */ + int cod_format; + /*@}*/ + + /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */ + /**@name JPWL encoding parameters */ + /*@{*/ + /** enables writing of EPC in MH, thus activating JPWL */ + OPJ_BOOL jpwl_epc_on; + /** error protection method for MH (0,1,16,32,37-128) */ + int jpwl_hprot_MH; + /** tile number of header protection specification (>=0) */ + int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS]; + /** error protection methods for TPHs (0,1,16,32,37-128) */ + int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS]; + /** tile number of packet protection specification (>=0) */ + int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS]; + /** packet number of packet protection specification (>=0) */ + int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS]; + /** error protection methods for packets (0,1,16,32,37-128) */ + int jpwl_pprot[JPWL_MAX_NO_PACKSPECS]; + /** enables writing of ESD, (0=no/1/2 bytes) */ + int jpwl_sens_size; + /** sensitivity addressing size (0=auto/2/4 bytes) */ + int jpwl_sens_addr; + /** sensitivity range (0-3) */ + int jpwl_sens_range; + /** sensitivity method for MH (-1=no,0-7) */ + int jpwl_sens_MH; + /** tile number of sensitivity specification (>=0) */ + int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS]; + /** sensitivity methods for TPHs (-1=no,0-7) */ + int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS]; + /*@}*/ + /* <<UniPG */ /** * DEPRECATED: use RSIZ, OPJ_PROFILE_* and MAX_COMP_SIZE instead @@ -471,23 +471,23 @@ typedef struct opj_cparameters { * Maximum size (in bytes) for each component. * If == 0, component size limitation is not considered * */ - int max_comp_size; + int max_comp_size; /** * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead * Profile name * */ OPJ_RSIZ_CAPABILITIES cp_rsiz; - /** Tile part generation*/ - char tp_on; - /** Flag for Tile part generation*/ - char tp_flag; - /** MCT (multiple component transform) */ - char tcp_mct; - /** Enable JPIP indexing*/ - OPJ_BOOL jpip_on; - /** Naive implementation of MCT restricted to a single reversible array based + /** Tile part generation*/ + char tp_on; + /** Flag for Tile part generation*/ + char tp_flag; + /** MCT (multiple component transform) */ + char tcp_mct; + /** Enable JPIP indexing*/ + OPJ_BOOL jpip_on; + /** Naive implementation of MCT restricted to a single reversible array based encoding without offset concerning all the components. */ - void * mct_data; + void * mct_data; /** * Maximum size (in bytes) for the whole codestream. * If == 0, codestream size limitation is not considered @@ -498,72 +498,72 @@ typedef struct opj_cparameters { /** RSIZ value To be used to combine OPJ_PROFILE_*, OPJ_EXTENSION_* and (sub)levels values. */ OPJ_UINT16 rsiz; -} opj_cparameters_t; +} opj_cparameters_t; -#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001 +#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001 /** * Decompression parameters * */ typedef struct opj_dparameters { - /** - Set the number of highest resolution levels to be discarded. - The image resolution is effectively divided by 2 to the power of the number of discarded levels. - The reduce factor is limited by the smallest total number of decomposition levels among tiles. - if != 0, then original dimension divided by 2^(reduce); - if == 0 or not used, image is decoded to the full resolution - */ - OPJ_UINT32 cp_reduce; - /** - Set the maximum number of quality layers to decode. - If there are less quality layers than the specified number, all the quality layers are decoded. - if != 0, then only the first "layer" layers are decoded; - if == 0 or not used, all the quality layers are decoded - */ - OPJ_UINT32 cp_layer; - - /**@name command line decoder parameters (not used inside the library) */ - /*@{*/ - /** input file name */ - char infile[OPJ_PATH_LEN]; - /** output file name */ - char outfile[OPJ_PATH_LEN]; - /** input file format 0: J2K, 1: JP2, 2: JPT */ - int decod_format; - /** output file format 0: PGX, 1: PxM, 2: BMP */ - int cod_format; - - /** Decoding area left boundary */ - OPJ_UINT32 DA_x0; - /** Decoding area right boundary */ - OPJ_UINT32 DA_x1; - /** Decoding area up boundary */ - OPJ_UINT32 DA_y0; - /** Decoding area bottom boundary */ - OPJ_UINT32 DA_y1; - /** Verbose mode */ - OPJ_BOOL m_verbose; - - /** tile number ot the decoded tile*/ - OPJ_UINT32 tile_index; - /** Nb of tile to decode */ - OPJ_UINT32 nb_tile_to_decode; - - /*@}*/ - -/* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */ - /**@name JPWL decoding parameters */ - /*@{*/ - /** activates the JPWL correction capabilities */ - OPJ_BOOL jpwl_correct; - /** expected number of components */ - int jpwl_exp_comps; - /** maximum number of tiles */ - int jpwl_max_tiles; - /*@}*/ -/* <<UniPG */ - - unsigned int flags; + /** + Set the number of highest resolution levels to be discarded. + The image resolution is effectively divided by 2 to the power of the number of discarded levels. + The reduce factor is limited by the smallest total number of decomposition levels among tiles. + if != 0, then original dimension divided by 2^(reduce); + if == 0 or not used, image is decoded to the full resolution + */ + OPJ_UINT32 cp_reduce; + /** + Set the maximum number of quality layers to decode. + If there are less quality layers than the specified number, all the quality layers are decoded. + if != 0, then only the first "layer" layers are decoded; + if == 0 or not used, all the quality layers are decoded + */ + OPJ_UINT32 cp_layer; + + /**@name command line decoder parameters (not used inside the library) */ + /*@{*/ + /** input file name */ + char infile[OPJ_PATH_LEN]; + /** output file name */ + char outfile[OPJ_PATH_LEN]; + /** input file format 0: J2K, 1: JP2, 2: JPT */ + int decod_format; + /** output file format 0: PGX, 1: PxM, 2: BMP */ + int cod_format; + + /** Decoding area left boundary */ + OPJ_UINT32 DA_x0; + /** Decoding area right boundary */ + OPJ_UINT32 DA_x1; + /** Decoding area up boundary */ + OPJ_UINT32 DA_y0; + /** Decoding area bottom boundary */ + OPJ_UINT32 DA_y1; + /** Verbose mode */ + OPJ_BOOL m_verbose; + + /** tile number ot the decoded tile*/ + OPJ_UINT32 tile_index; + /** Nb of tile to decode */ + OPJ_UINT32 nb_tile_to_decode; + + /*@}*/ + + /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */ + /**@name JPWL decoding parameters */ + /*@{*/ + /** activates the JPWL correction capabilities */ + OPJ_BOOL jpwl_correct; + /** expected number of components */ + int jpwl_exp_comps; + /** maximum number of tiles */ + int jpwl_max_tiles; + /*@}*/ + /* <<UniPG */ + + unsigned int flags; } opj_dparameters_t; @@ -573,7 +573,7 @@ typedef struct opj_dparameters { * */ typedef void * opj_codec_t; -/* +/* ========================================================== I/O stream typedef definitions ========================================================== @@ -583,41 +583,45 @@ typedef void * opj_codec_t; * Stream open flags. * */ /** The stream was opened for reading. */ -#define OPJ_STREAM_READ OPJ_TRUE +#define OPJ_STREAM_READ OPJ_TRUE /** The stream was opened for writing. */ #define OPJ_STREAM_WRITE OPJ_FALSE /* * Callback function prototype for read function */ -typedef OPJ_SIZE_T (* opj_stream_read_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ; +typedef OPJ_SIZE_T(* opj_stream_read_fn)(void * p_buffer, OPJ_SIZE_T p_nb_bytes, + void * p_user_data) ; /* * Callback function prototype for write function */ -typedef OPJ_SIZE_T (* opj_stream_write_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ; +typedef OPJ_SIZE_T(* opj_stream_write_fn)(void * p_buffer, + OPJ_SIZE_T p_nb_bytes, void * p_user_data) ; /* * Callback function prototype for skip function */ -typedef OPJ_OFF_T (* opj_stream_skip_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ; +typedef OPJ_OFF_T(* opj_stream_skip_fn)(OPJ_OFF_T p_nb_bytes, + void * p_user_data) ; /* * Callback function prototype for seek function */ -typedef OPJ_BOOL (* opj_stream_seek_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ; +typedef OPJ_BOOL(* opj_stream_seek_fn)(OPJ_OFF_T p_nb_bytes, + void * p_user_data) ; /* * Callback function prototype for free user data function */ -typedef void (* opj_stream_free_user_data_fn) (void * p_user_data) ; +typedef void (* opj_stream_free_user_data_fn)(void * p_user_data) ; /* * JPEG2000 Stream. */ typedef void * opj_stream_t; -/* +/* ========================================================== image typedef definitions ========================================================== @@ -627,56 +631,56 @@ typedef void * opj_stream_t; * Defines a single image component * */ typedef struct opj_image_comp { - /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */ - OPJ_UINT32 dx; - /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */ - OPJ_UINT32 dy; - /** data width */ - OPJ_UINT32 w; - /** data height */ - OPJ_UINT32 h; - /** x component offset compared to the whole image */ - OPJ_UINT32 x0; - /** y component offset compared to the whole image */ - OPJ_UINT32 y0; - /** precision */ - OPJ_UINT32 prec; - /** image depth in bits */ - OPJ_UINT32 bpp; - /** signed (1) / unsigned (0) */ - OPJ_UINT32 sgnd; - /** number of decoded resolution */ - OPJ_UINT32 resno_decoded; - /** number of division by 2 of the out image compared to the original size of image */ - OPJ_UINT32 factor; - /** image component data */ - OPJ_INT32 *data; - /** alpha channel */ - OPJ_UINT16 alpha; + /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */ + OPJ_UINT32 dx; + /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */ + OPJ_UINT32 dy; + /** data width */ + OPJ_UINT32 w; + /** data height */ + OPJ_UINT32 h; + /** x component offset compared to the whole image */ + OPJ_UINT32 x0; + /** y component offset compared to the whole image */ + OPJ_UINT32 y0; + /** precision */ + OPJ_UINT32 prec; + /** image depth in bits */ + OPJ_UINT32 bpp; + /** signed (1) / unsigned (0) */ + OPJ_UINT32 sgnd; + /** number of decoded resolution */ + OPJ_UINT32 resno_decoded; + /** number of division by 2 of the out image compared to the original size of image */ + OPJ_UINT32 factor; + /** image component data */ + OPJ_INT32 *data; + /** alpha channel */ + OPJ_UINT16 alpha; } opj_image_comp_t; -/** +/** * Defines image data and characteristics * */ typedef struct opj_image { - /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */ - OPJ_UINT32 x0; - /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */ - OPJ_UINT32 y0; - /** Xsiz: width of the reference grid */ - OPJ_UINT32 x1; - /** Ysiz: height of the reference grid */ - OPJ_UINT32 y1; - /** number of components in the image */ - OPJ_UINT32 numcomps; - /** color space: sRGB, Greyscale or YUV */ - OPJ_COLOR_SPACE color_space; - /** image components */ - opj_image_comp_t *comps; - /** 'restricted' ICC profile */ - OPJ_BYTE *icc_profile_buf; - /** size of ICC profile */ - OPJ_UINT32 icc_profile_len; + /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */ + OPJ_UINT32 x0; + /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */ + OPJ_UINT32 y0; + /** Xsiz: width of the reference grid */ + OPJ_UINT32 x1; + /** Ysiz: height of the reference grid */ + OPJ_UINT32 y1; + /** number of components in the image */ + OPJ_UINT32 numcomps; + /** color space: sRGB, Greyscale or YUV */ + OPJ_COLOR_SPACE color_space; + /** image components */ + opj_image_comp_t *comps; + /** 'restricted' ICC profile */ + OPJ_BYTE *icc_profile_buf; + /** size of ICC profile */ + OPJ_UINT32 icc_profile_len; } opj_image_t; @@ -684,28 +688,28 @@ typedef struct opj_image { * Component parameters structure used by the opj_image_create function * */ typedef struct opj_image_comptparm { - /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */ - OPJ_UINT32 dx; - /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */ - OPJ_UINT32 dy; - /** data width */ - OPJ_UINT32 w; - /** data height */ - OPJ_UINT32 h; - /** x component offset compared to the whole image */ - OPJ_UINT32 x0; - /** y component offset compared to the whole image */ - OPJ_UINT32 y0; - /** precision */ - OPJ_UINT32 prec; - /** image depth in bits */ - OPJ_UINT32 bpp; - /** signed (1) / unsigned (0) */ - OPJ_UINT32 sgnd; + /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */ + OPJ_UINT32 dx; + /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */ + OPJ_UINT32 dy; + /** data width */ + OPJ_UINT32 w; + /** data height */ + OPJ_UINT32 h; + /** x component offset compared to the whole image */ + OPJ_UINT32 x0; + /** y component offset compared to the whole image */ + OPJ_UINT32 y0; + /** precision */ + OPJ_UINT32 prec; + /** image depth in bits */ + OPJ_UINT32 bpp; + /** signed (1) / unsigned (0) */ + OPJ_UINT32 sgnd; } opj_image_cmptparm_t; -/* +/* ========================================================== Information on the JPEG 2000 codestream ========================================================== @@ -716,14 +720,14 @@ typedef struct opj_image_comptparm { * Index structure : Information concerning a packet inside tile * */ typedef struct opj_packet_info { - /** packet start position (including SOP marker if it exists) */ - OPJ_OFF_T start_pos; - /** end of packet header position (including EPH marker if it exists)*/ - OPJ_OFF_T end_ph_pos; - /** packet end position */ - OPJ_OFF_T end_pos; - /** packet distorsion */ - double disto; + /** packet start position (including SOP marker if it exists) */ + OPJ_OFF_T start_pos; + /** end of packet header position (including EPH marker if it exists)*/ + OPJ_OFF_T end_ph_pos; + /** packet end position */ + OPJ_OFF_T end_pos; + /** packet distorsion */ + double disto; } opj_packet_info_t; @@ -732,12 +736,12 @@ typedef struct opj_packet_info { * Marker structure * */ typedef struct opj_marker_info { - /** marker type */ - unsigned short int type; - /** position in codestream */ - OPJ_OFF_T pos; - /** length, marker val included */ - int len; + /** marker type */ + unsigned short int type; + /** position in codestream */ + OPJ_OFF_T pos; + /** length, marker val included */ + int len; } opj_marker_info_t; /* <<UniPG */ @@ -745,108 +749,108 @@ typedef struct opj_marker_info { * Index structure : Information concerning tile-parts */ typedef struct opj_tp_info { - /** start position of tile part */ - int tp_start_pos; - /** end position of tile part header */ - int tp_end_header; - /** end position of tile part */ - int tp_end_pos; - /** start packet of tile part */ - int tp_start_pack; - /** number of packets of tile part */ - int tp_numpacks; + /** start position of tile part */ + int tp_start_pos; + /** end position of tile part header */ + int tp_end_header; + /** end position of tile part */ + int tp_end_pos; + /** start packet of tile part */ + int tp_start_pack; + /** number of packets of tile part */ + int tp_numpacks; } opj_tp_info_t; /** * Index structure : information regarding tiles */ typedef struct opj_tile_info { - /** value of thresh for each layer by tile cfr. Marcela */ - double *thresh; - /** number of tile */ - int tileno; - /** start position */ - int start_pos; - /** end position of the header */ - int end_header; - /** end position */ - int end_pos; - /** precinct number for each resolution level (width) */ - int pw[33]; - /** precinct number for each resolution level (height) */ - int ph[33]; - /** precinct size (in power of 2), in X for each resolution level */ - int pdx[33]; - /** precinct size (in power of 2), in Y for each resolution level */ - int pdy[33]; - /** information concerning packets inside tile */ - opj_packet_info_t *packet; - /** add fixed_quality */ - int numpix; - /** add fixed_quality */ - double distotile; - /** number of markers */ - int marknum; - /** list of markers */ - opj_marker_info_t *marker; - /** actual size of markers array */ - int maxmarknum; - /** number of tile parts */ - int num_tps; - /** information concerning tile parts */ - opj_tp_info_t *tp; + /** value of thresh for each layer by tile cfr. Marcela */ + double *thresh; + /** number of tile */ + int tileno; + /** start position */ + int start_pos; + /** end position of the header */ + int end_header; + /** end position */ + int end_pos; + /** precinct number for each resolution level (width) */ + int pw[33]; + /** precinct number for each resolution level (height) */ + int ph[33]; + /** precinct size (in power of 2), in X for each resolution level */ + int pdx[33]; + /** precinct size (in power of 2), in Y for each resolution level */ + int pdy[33]; + /** information concerning packets inside tile */ + opj_packet_info_t *packet; + /** add fixed_quality */ + int numpix; + /** add fixed_quality */ + double distotile; + /** number of markers */ + int marknum; + /** list of markers */ + opj_marker_info_t *marker; + /** actual size of markers array */ + int maxmarknum; + /** number of tile parts */ + int num_tps; + /** information concerning tile parts */ + opj_tp_info_t *tp; } opj_tile_info_t; /** * Index structure of the codestream */ typedef struct opj_codestream_info { - /** maximum distortion reduction on the whole image (add for Marcela) */ - double D_max; - /** packet number */ - int packno; - /** writing the packet in the index with t2_encode_packets */ - int index_write; - /** image width */ - int image_w; - /** image height */ - int image_h; - /** progression order */ - OPJ_PROG_ORDER prog; - /** tile size in x */ - int tile_x; - /** tile size in y */ - int tile_y; - /** */ - int tile_Ox; - /** */ - int tile_Oy; - /** number of tiles in X */ - int tw; - /** number of tiles in Y */ - int th; - /** component numbers */ - int numcomps; - /** number of layer */ - int numlayers; - /** number of decomposition for each component */ - int *numdecompos; -/* UniPG>> */ - /** number of markers */ - int marknum; - /** list of markers */ - opj_marker_info_t *marker; - /** actual size of markers array */ - int maxmarknum; -/* <<UniPG */ - /** main header position */ - int main_head_start; - /** main header position */ - int main_head_end; - /** codestream's size */ - int codestream_size; - /** information regarding tiles inside image */ - opj_tile_info_t *tile; + /** maximum distortion reduction on the whole image (add for Marcela) */ + double D_max; + /** packet number */ + int packno; + /** writing the packet in the index with t2_encode_packets */ + int index_write; + /** image width */ + int image_w; + /** image height */ + int image_h; + /** progression order */ + OPJ_PROG_ORDER prog; + /** tile size in x */ + int tile_x; + /** tile size in y */ + int tile_y; + /** */ + int tile_Ox; + /** */ + int tile_Oy; + /** number of tiles in X */ + int tw; + /** number of tiles in Y */ + int th; + /** component numbers */ + int numcomps; + /** number of layer */ + int numlayers; + /** number of decomposition for each component */ + int *numdecompos; + /* UniPG>> */ + /** number of markers */ + int marknum; + /** list of markers */ + opj_marker_info_t *marker; + /** actual size of markers array */ + int maxmarknum; + /* <<UniPG */ + /** main header position */ + int main_head_start; + /** main header position */ + int main_head_end; + /** codestream's size */ + int codestream_size; + /** information regarding tiles inside image */ + opj_tile_info_t *tile; } opj_codestream_info_t; /* <----------------------------------------------------------- */ @@ -855,36 +859,35 @@ typedef struct opj_codestream_info { /** * Tile-component coding parameters information */ -typedef struct opj_tccp_info -{ - /** component index */ - OPJ_UINT32 compno; - /** coding style */ - OPJ_UINT32 csty; - /** number of resolutions */ - OPJ_UINT32 numresolutions; - /** code-blocks width */ - OPJ_UINT32 cblkw; - /** code-blocks height */ - OPJ_UINT32 cblkh; - /** code-block coding style */ - OPJ_UINT32 cblksty; - /** discrete wavelet transform identifier */ - OPJ_UINT32 qmfbid; - /** quantisation style */ - OPJ_UINT32 qntsty; - /** stepsizes used for quantization */ - OPJ_UINT32 stepsizes_mant[OPJ_J2K_MAXBANDS]; - /** stepsizes used for quantization */ - OPJ_UINT32 stepsizes_expn[OPJ_J2K_MAXBANDS]; - /** number of guard bits */ - OPJ_UINT32 numgbits; - /** Region Of Interest shift */ - OPJ_INT32 roishift; - /** precinct width */ - OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS]; - /** precinct height */ - OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS]; +typedef struct opj_tccp_info { + /** component index */ + OPJ_UINT32 compno; + /** coding style */ + OPJ_UINT32 csty; + /** number of resolutions */ + OPJ_UINT32 numresolutions; + /** code-blocks width */ + OPJ_UINT32 cblkw; + /** code-blocks height */ + OPJ_UINT32 cblkh; + /** code-block coding style */ + OPJ_UINT32 cblksty; + /** discrete wavelet transform identifier */ + OPJ_UINT32 qmfbid; + /** quantisation style */ + OPJ_UINT32 qntsty; + /** stepsizes used for quantization */ + OPJ_UINT32 stepsizes_mant[OPJ_J2K_MAXBANDS]; + /** stepsizes used for quantization */ + OPJ_UINT32 stepsizes_expn[OPJ_J2K_MAXBANDS]; + /** number of guard bits */ + OPJ_UINT32 numgbits; + /** Region Of Interest shift */ + OPJ_INT32 roishift; + /** precinct width */ + OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS]; + /** precinct height */ + OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS]; } opj_tccp_info_t; @@ -893,19 +896,19 @@ opj_tccp_info_t; */ typedef struct opj_tile_v2_info { - /** number (index) of tile */ - int tileno; - /** coding style */ - OPJ_UINT32 csty; - /** progression order */ - OPJ_PROG_ORDER prg; - /** number of layers */ - OPJ_UINT32 numlayers; - /** multi-component transform identifier */ - OPJ_UINT32 mct; + /** number (index) of tile */ + int tileno; + /** coding style */ + OPJ_UINT32 csty; + /** progression order */ + OPJ_PROG_ORDER prg; + /** number of layers */ + OPJ_UINT32 numlayers; + /** multi-component transform identifier */ + OPJ_UINT32 mct; - /** information concerning tile component parameters*/ - opj_tccp_info_t *tccp_info; + /** information concerning tile component parameters*/ + opj_tccp_info_t *tccp_info; } opj_tile_info_v2_t; @@ -913,28 +916,28 @@ typedef struct opj_tile_v2_info { * Information structure about the codestream (FIXME should be expand and enhance) */ typedef struct opj_codestream_info_v2 { - /* Tile info */ - /** tile origin in x = XTOsiz */ - OPJ_UINT32 tx0; - /** tile origin in y = YTOsiz */ - OPJ_UINT32 ty0; - /** tile size in x = XTsiz */ - OPJ_UINT32 tdx; - /** tile size in y = YTsiz */ - OPJ_UINT32 tdy; - /** number of tiles in X */ - OPJ_UINT32 tw; - /** number of tiles in Y */ - OPJ_UINT32 th; - - /** number of components*/ - OPJ_UINT32 nbcomps; - - /** Default information regarding tiles inside image */ - opj_tile_info_v2_t m_default_tile_info; - - /** information regarding tiles inside image */ - opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */ + /* Tile info */ + /** tile origin in x = XTOsiz */ + OPJ_UINT32 tx0; + /** tile origin in y = YTOsiz */ + OPJ_UINT32 ty0; + /** tile size in x = XTsiz */ + OPJ_UINT32 tdx; + /** tile size in y = YTsiz */ + OPJ_UINT32 tdy; + /** number of tiles in X */ + OPJ_UINT32 tw; + /** number of tiles in Y */ + OPJ_UINT32 th; + + /** number of components*/ + OPJ_UINT32 nbcomps; + + /** Default information regarding tiles inside image */ + opj_tile_info_v2_t m_default_tile_info; + + /** information regarding tiles inside image */ + opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */ } opj_codestream_info_v2_t; @@ -943,12 +946,12 @@ typedef struct opj_codestream_info_v2 { * Index structure about a tile part */ typedef struct opj_tp_index { - /** start position */ - OPJ_OFF_T start_pos; - /** end position of the header */ - OPJ_OFF_T end_header; - /** end position */ - OPJ_OFF_T end_pos; + /** start position */ + OPJ_OFF_T start_pos; + /** end position of the header */ + OPJ_OFF_T end_header; + /** end position */ + OPJ_OFF_T end_pos; } opj_tp_index_t; @@ -956,31 +959,31 @@ typedef struct opj_tp_index { * Index structure about a tile */ typedef struct opj_tile_index { - /** tile index */ - OPJ_UINT32 tileno; - - /** number of tile parts */ - OPJ_UINT32 nb_tps; - /** current nb of tile part (allocated)*/ - OPJ_UINT32 current_nb_tps; - /** current tile-part index */ - OPJ_UINT32 current_tpsno; - /** information concerning tile parts */ - opj_tp_index_t *tp_index; - - /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */ - /** number of markers */ - OPJ_UINT32 marknum; - /** list of markers */ - opj_marker_info_t *marker; - /** actual size of markers array */ - OPJ_UINT32 maxmarknum; - /* <<UniPG */ - - /** packet number */ - OPJ_UINT32 nb_packet; - /** information concerning packets inside tile */ - opj_packet_info_t *packet_index; + /** tile index */ + OPJ_UINT32 tileno; + + /** number of tile parts */ + OPJ_UINT32 nb_tps; + /** current nb of tile part (allocated)*/ + OPJ_UINT32 current_nb_tps; + /** current tile-part index */ + OPJ_UINT32 current_tpsno; + /** information concerning tile parts */ + opj_tp_index_t *tp_index; + + /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */ + /** number of markers */ + OPJ_UINT32 marknum; + /** list of markers */ + opj_marker_info_t *marker; + /** actual size of markers array */ + OPJ_UINT32 maxmarknum; + /* <<UniPG */ + + /** packet number */ + OPJ_UINT32 nb_packet; + /** information concerning packets inside tile */ + opj_packet_info_t *packet_index; } opj_tile_index_t; @@ -988,29 +991,29 @@ typedef struct opj_tile_index { * Index structure of the codestream (FIXME should be expand and enhance) */ typedef struct opj_codestream_index { - /** main header start position (SOC position) */ - OPJ_OFF_T main_head_start; - /** main header end position (first SOT position) */ - OPJ_OFF_T main_head_end; - - /** codestream's size */ - OPJ_UINT64 codestream_size; - -/* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */ - /** number of markers */ - OPJ_UINT32 marknum; - /** list of markers */ - opj_marker_info_t *marker; - /** actual size of markers array */ - OPJ_UINT32 maxmarknum; -/* <<UniPG */ - - /** */ - OPJ_UINT32 nb_of_tiles; - /** */ - opj_tile_index_t *tile_index; /* FIXME not used for the moment */ - -}opj_codestream_index_t; + /** main header start position (SOC position) */ + OPJ_OFF_T main_head_start; + /** main header end position (first SOT position) */ + OPJ_OFF_T main_head_end; + + /** codestream's size */ + OPJ_UINT64 codestream_size; + + /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */ + /** number of markers */ + OPJ_UINT32 marknum; + /** list of markers */ + opj_marker_info_t *marker; + /** actual size of markers array */ + OPJ_UINT32 maxmarknum; + /* <<UniPG */ + + /** */ + OPJ_UINT32 nb_of_tiles; + /** */ + opj_tile_index_t *tile_index; /* FIXME not used for the moment */ + +} opj_codestream_index_t; /* -----------------------------------------------------------> */ /* @@ -1024,8 +1027,8 @@ typedef struct opj_codestream_index { * EXPERIMENTAL FOR THE MOMENT */ typedef struct opj_jp2_metadata { - /** */ - OPJ_INT32 not_used; + /** */ + OPJ_INT32 not_used; } opj_jp2_metadata_t; @@ -1034,8 +1037,8 @@ typedef struct opj_jp2_metadata { * EXPERIMENTAL FOR THE MOMENT */ typedef struct opj_jp2_index { - /** */ - OPJ_INT32 not_used; + /** */ + OPJ_INT32 not_used; } opj_jp2_index_t; @@ -1045,7 +1048,7 @@ extern "C" { #endif -/* +/* ========================================================== openjpeg version ========================================================== @@ -1054,7 +1057,7 @@ extern "C" { /* Get the version of the openjpeg library*/ OPJ_API const char * OPJ_CALLCONV opj_version(void); -/* +/* ========================================================== image functions definitions ========================================================== @@ -1068,7 +1071,8 @@ OPJ_API const char * OPJ_CALLCONV opj_version(void); * @param clrspc image color space * @return returns a new image structure if successful, returns NULL otherwise * */ -OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc); +OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, + opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc); /** * Deallocate any resources associated with an image @@ -1080,15 +1084,16 @@ OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image); /** * Creates an image without allocating memory for the image (used in the new version of the library). * - * @param numcmpts the number of components - * @param cmptparms the components parameters - * @param clrspc the image color space + * @param numcmpts the number of components + * @param cmptparms the components parameters + * @param clrspc the image color space * - * @return a new image structure if successful, NULL otherwise. + * @return a new image structure if successful, NULL otherwise. */ -OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc); +OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, + opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc); -/* +/* ========================================================== stream functions definitions ========================================================== @@ -1097,65 +1102,72 @@ OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj /** * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream. * - * @param p_is_input if set to true then the stream will be an input stream, an output stream else. + * @param p_is_input if set to true then the stream will be an input stream, an output stream else. * - * @return a stream object. + * @return a stream object. */ -OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create(OPJ_BOOL p_is_input); +OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create( + OPJ_BOOL p_is_input); /** * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream. * - * @param p_buffer_size FIXME DOC - * @param p_is_input if set to true then the stream will be an input stream, an output stream else. + * @param p_buffer_size FIXME DOC + * @param p_is_input if set to true then the stream will be an input stream, an output stream else. * - * @return a stream object. + * @return a stream object. */ -OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size, OPJ_BOOL p_is_input); +OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size, + OPJ_BOOL p_is_input); /** * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must * close its own implementation of the stream. * - * @param p_stream the stream to destroy. + * @param p_stream the stream to destroy. */ OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream); - + /** * Sets the given function to be used as a read function. - * @param p_stream the stream to modify - * @param p_function the function to use a read function. + * @param p_stream the stream to modify + * @param p_function the function to use a read function. */ -OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_stream_read_fn p_function); +OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, + opj_stream_read_fn p_function); /** * Sets the given function to be used as a write function. - * @param p_stream the stream to modify - * @param p_function the function to use a write function. + * @param p_stream the stream to modify + * @param p_function the function to use a write function. */ -OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, opj_stream_write_fn p_function); +OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, + opj_stream_write_fn p_function); /** * Sets the given function to be used as a skip function. - * @param p_stream the stream to modify - * @param p_function the function to use a skip function. + * @param p_stream the stream to modify + * @param p_function the function to use a skip function. */ -OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, opj_stream_skip_fn p_function); +OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, + opj_stream_skip_fn p_function); /** * Sets the given function to be used as a seek function, the stream is then seekable. - * @param p_stream the stream to modify - * @param p_function the function to use a skip function. + * @param p_stream the stream to modify + * @param p_function the function to use a skip function. */ -OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, opj_stream_seek_fn p_function); +OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, + opj_stream_seek_fn p_function); /** * Sets the given data to be used as a user data for the stream. - * @param p_stream the stream to modify - * @param p_data the data to set. - * @param p_function the function to free p_data when opj_stream_destroy() is called. + * @param p_stream the stream to modify + * @param p_data the data to set. + * @param p_function the function to free p_data when opj_stream_destroy() is called. */ -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); +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); /** * Sets the length of the user data for the stream. @@ -1163,25 +1175,28 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * @param p_stream the stream to modify * @param data_length length of the user_data. */ -OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream, OPJ_UINT64 data_length); +OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length( + opj_stream_t* p_stream, OPJ_UINT64 data_length); /** * Create a stream from a file identified with its filename with default parameters (helper function) * @param fname the filename of the file to stream * @param p_is_read_stream whether the stream is a read stream (true) or not (false) */ -OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (const char *fname, OPJ_BOOL p_is_read_stream); - +OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream( + const char *fname, OPJ_BOOL p_is_read_stream); + /** Create a stream from a file identified with its filename with a specific buffer size * @param fname the filename of the file to stream * @param p_buffer_size size of the chunk used to stream * @param p_is_read_stream whether the stream is a read stream (true) or not (false) */ -OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (const char *fname, - OPJ_SIZE_T p_buffer_size, - OPJ_BOOL p_is_read_stream); - -/* +OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream( + const char *fname, + OPJ_SIZE_T p_buffer_size, + OPJ_BOOL p_is_read_stream); + +/* ========================================================== event manager functions definitions ========================================================== @@ -1192,9 +1207,9 @@ OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (const char *fn * @param p_callback the callback function which will be used * @param p_user_data client object where will be returned the message */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, - opj_msg_callback p_callback, - void * p_user_data); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, + opj_msg_callback p_callback, + void * p_user_data); /** * Set the warning handler use by openjpeg. * @param p_codec the codec previously initialise @@ -1202,19 +1217,19 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, * @param p_user_data client object where will be returned the message */ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec, - opj_msg_callback p_callback, - void * p_user_data); + opj_msg_callback p_callback, + void * p_user_data); /** * Set the error handler use by openjpeg. * @param p_codec the codec previously initialise * @param p_callback the callback function which will be used * @param p_user_data client object where will be returned the message */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, - opj_msg_callback p_callback, - void * p_user_data); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, + opj_msg_callback p_callback, + void * p_user_data); -/* +/* ========================================================== codec functions definitions ========================================================== @@ -1222,45 +1237,47 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, /** * Creates a J2K/JP2 decompression structure - * @param format Decoder to select + * @param format Decoder to select * * @return Returns a handle to a decompressor if successful, returns NULL otherwise * */ -OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format); +OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_decompress( + OPJ_CODEC_FORMAT format); /** * Destroy a decompressor handle * - * @param p_codec decompressor handle to destroy + * @param p_codec decompressor handle to destroy */ OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec); /** * Read after the codestream if necessary - * @param p_codec the JPEG2000 codec to read. - * @param p_stream the JPEG2000 stream. + * @param p_codec the JPEG2000 codec to read. + * @param p_stream the JPEG2000 stream. */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_decompress ( opj_codec_t *p_codec, - opj_stream_t *p_stream); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_decompress(opj_codec_t *p_codec, + opj_stream_t *p_stream); /** * Set decoding parameters to default values * @param parameters Decompression parameters */ -OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters); +OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters( + opj_dparameters_t *parameters); /** * Setup the decoder with decompression parameters provided by the user and with the message handler * provided by the user. * - * @param p_codec decompressor handler - * @param parameters decompression parameters + * @param p_codec decompressor handler + * @param parameters decompression parameters * - * @return true if the decoder is correctly set + * @return true if the decoder is correctly set */ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec, - opj_dparameters_t *parameters ); + opj_dparameters_t *parameters); /** * Allocates worker threads for the compressor/decompressor. @@ -1279,151 +1296,152 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec, * @return OPJ_TRUE if the decoder is correctly set */ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_codec_set_threads(opj_codec_t *p_codec, - int num_threads); + int num_threads); /** * Decodes an image header. * - * @param p_stream the jpeg2000 stream. - * @param p_codec the jpeg2000 codec to read. - * @param p_image the image structure initialized with the characteristics of encoded image. + * @param p_stream the jpeg2000 stream. + * @param p_codec the jpeg2000 codec to read. + * @param p_image the image structure initialized with the characteristics of encoded image. * - * @return true if the main header of the codestream and the JP2 header is correctly read. + * @return true if the main header of the codestream and the JP2 header is correctly read. */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_header ( opj_stream_t *p_stream, - opj_codec_t *p_codec, - opj_image_t **p_image); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream, + opj_codec_t *p_codec, + opj_image_t **p_image); /** * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading. * - * @param p_codec the jpeg2000 codec. - * @param p_image the decoded image previously setted by opj_read_header - * @param p_start_x the left 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_start_y the up 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_codec the jpeg2000 codec. + * @param p_image the decoded image previously setted by opj_read_header + * @param p_start_x the left 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_start_y the up position of the rectangle to decode (in image coordinates). + * @param p_end_y the bottom position of the rectangle to decode (in image coordinates). * - * @return true if the area could be set. + * @return true if the area could be set. */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decode_area( opj_codec_t *p_codec, - 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_API OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(opj_codec_t *p_codec, + 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); /** * Decode an image from a JPEG-2000 codestream * - * @param p_decompressor decompressor handle - * @param p_stream Input buffer stream - * @param p_image the decoded image - * @return true if success, otherwise false + * @param p_decompressor decompressor handle + * @param p_stream Input buffer stream + * @param p_image the decoded image + * @return true if success, otherwise false * */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode( opj_codec_t *p_decompressor, - opj_stream_t *p_stream, - opj_image_t *p_image); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode(opj_codec_t *p_decompressor, + opj_stream_t *p_stream, + opj_image_t *p_image); /** * Get the decoded tile from the codec * - * @param p_codec the jpeg2000 codec. - * @param p_stream input streamm - * @param p_image output image - * @param tile_index index of the tile which will be decode + * @param p_codec the jpeg2000 codec. + * @param p_stream input streamm + * @param p_image output image + * @param tile_index index of the tile which will be decode * - * @return true if success, otherwise false + * @return true if success, otherwise false */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile( opj_codec_t *p_codec, - opj_stream_t *p_stream, - opj_image_t *p_image, - OPJ_UINT32 tile_index); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(opj_codec_t *p_codec, + opj_stream_t *p_stream, + opj_image_t *p_image, + OPJ_UINT32 tile_index); /** * Set the resolution factor of the decoded image - * @param p_codec the jpeg2000 codec. - * @param res_factor resolution factor to set + * @param p_codec the jpeg2000 codec. + * @param res_factor resolution factor to set * - * @return true if success, otherwise false + * @return true if success, otherwise false */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OPJ_UINT32 res_factor); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor( + opj_codec_t *p_codec, OPJ_UINT32 res_factor); /** * Writes a tile with the given data. * - * @param p_codec the jpeg2000 codec. - * @param p_tile_index the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence. - * @param p_data pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set. - * @param p_data_size this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of + * @param p_codec the jpeg2000 codec. + * @param p_tile_index the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence. + * @param p_data pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set. + * @param p_data_size this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of * tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes, depending on the precision of the given component. - * @param p_stream the stream to write data to. + * @param p_stream the stream to write data to. * - * @return true if the data could be written. + * @return true if the data could be written. */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_write_tile ( opj_codec_t *p_codec, - OPJ_UINT32 p_tile_index, - OPJ_BYTE * p_data, - OPJ_UINT32 p_data_size, - opj_stream_t *p_stream ); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_write_tile(opj_codec_t *p_codec, + OPJ_UINT32 p_tile_index, + OPJ_BYTE * p_data, + OPJ_UINT32 p_data_size, + opj_stream_t *p_stream); /** * Reads a tile header. This function is compulsory and allows one to know the size of the tile that will be decoded. * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile. * - * @param p_codec the jpeg2000 codec. - * @param p_tile_index pointer to a value that will hold the index of the tile being decoded, in case of success. - * @param p_data_size pointer to a value that will hold the maximum size of the decoded data, in case of success. In case - * of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same - * as depicted in opj_write_tile. - * @param p_tile_x0 pointer to a value that will hold the x0 pos of the tile (in the image). - * @param p_tile_y0 pointer to a value that will hold the y0 pos of the tile (in the image). - * @param p_tile_x1 pointer to a value that will hold the x1 pos of the tile (in the image). - * @param p_tile_y1 pointer to a value that will hold the y1 pos of the tile (in the image). - * @param p_nb_comps pointer to a value that will hold the number of components in the tile. - * @param p_should_go_on pointer to a boolean that will hold the fact that the decoding should go on. In case the - * codestream is over at the time of the call, the value will be set to false. The user should then stop - * the decoding. - * @param p_stream the stream to decode. - * @return true if the tile header could be decoded. In case the decoding should end, the returned value is still true. - * returning false may be the result of a shortage of memory or an internal error. + * @param p_codec the jpeg2000 codec. + * @param p_tile_index pointer to a value that will hold the index of the tile being decoded, in case of success. + * @param p_data_size pointer to a value that will hold the maximum size of the decoded data, in case of success. In case + * of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same + * as depicted in opj_write_tile. + * @param p_tile_x0 pointer to a value that will hold the x0 pos of the tile (in the image). + * @param p_tile_y0 pointer to a value that will hold the y0 pos of the tile (in the image). + * @param p_tile_x1 pointer to a value that will hold the x1 pos of the tile (in the image). + * @param p_tile_y1 pointer to a value that will hold the y1 pos of the tile (in the image). + * @param p_nb_comps pointer to a value that will hold the number of components in the tile. + * @param p_should_go_on pointer to a boolean that will hold the fact that the decoding should go on. In case the + * codestream is over at the time of the call, the value will be set to false. The user should then stop + * the decoding. + * @param p_stream the stream to decode. + * @return true if the tile header could be decoded. In case the decoding should end, the returned value is still true. + * returning false may be the result of a shortage of memory or an internal error. */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_tile_header( opj_codec_t *p_codec, - opj_stream_t * p_stream, - 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_should_go_on ); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_tile_header(opj_codec_t *p_codec, + opj_stream_t * p_stream, + 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_should_go_on); /** * Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before. * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile. * - * @param p_codec the jpeg2000 codec. - * @param p_tile_index the index of the tile being decoded, this should be the value set by opj_read_tile_header. - * @param p_data pointer to a memory block that will hold the decoded data. - * @param p_data_size size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header. - * @param p_stream the stream to decode. + * @param p_codec the jpeg2000 codec. + * @param p_tile_index the index of the tile being decoded, this should be the value set by opj_read_tile_header. + * @param p_data pointer to a memory block that will hold the decoded data. + * @param p_data_size size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header. + * @param p_stream the stream to decode. * - * @return true if the data could be decoded. + * @return true if the data could be decoded. */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data( opj_codec_t *p_codec, - OPJ_UINT32 p_tile_index, - OPJ_BYTE * p_data, - OPJ_UINT32 p_data_size, - opj_stream_t *p_stream ); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(opj_codec_t *p_codec, + OPJ_UINT32 p_tile_index, + OPJ_BYTE * p_data, + OPJ_UINT32 p_data_size, + opj_stream_t *p_stream); /* COMPRESSION FUNCTIONS*/ /** * Creates a J2K/JP2 compression structure - * @param format Coder to select - * @return Returns a handle to a compressor if successful, returns NULL otherwise + * @param format Coder to select + * @return Returns a handle to a compressor if successful, returns NULL otherwise */ OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format); /** -Set encoding parameters to default values, that means : +Set encoding parameters to default values, that means : <ul> <li>Lossless <li>1 tile @@ -1443,45 +1461,46 @@ Set encoding parameters to default values, that means : </ul> @param parameters Compression parameters */ -OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters); +OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters( + opj_cparameters_t *parameters); /** * Setup the encoder parameters using the current image and using user parameters. - * @param p_codec Compressor handle - * @param parameters Compression parameters - * @param image Input filled image + * @param p_codec Compressor handle + * @param parameters Compression parameters + * @param image Input filled image */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec, - opj_cparameters_t *parameters, - opj_image_t *image); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec, + opj_cparameters_t *parameters, + opj_image_t *image); /** * Start to compress the current image. - * @param p_codec Compressor handle - * @param image Input filled image - * @param p_stream Input stgream + * @param p_codec Compressor handle + * @param image Input filled image + * @param p_stream Input stgream */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_start_compress ( opj_codec_t *p_codec, - opj_image_t * p_image, - opj_stream_t *p_stream); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_start_compress(opj_codec_t *p_codec, + opj_image_t * p_image, + opj_stream_t *p_stream); /** * End to compress the current image. - * @param p_codec Compressor handle - * @param p_stream Input stgream + * @param p_codec Compressor handle + * @param p_stream Input stgream */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec, - opj_stream_t *p_stream); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_compress(opj_codec_t *p_codec, + opj_stream_t *p_stream); /** * Encode an image into a JPEG-2000 codestream - * @param p_codec compressor handle - * @param p_stream Output buffer stream + * @param p_codec compressor handle + * @param p_stream Output buffer stream * - * @return Returns true if successful, returns false otherwise + * @return Returns true if successful, returns false otherwise */ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_codec, - opj_stream_t *p_stream); + opj_stream_t *p_stream); /* ========================================================== codec output functions definitions @@ -1493,60 +1512,65 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_codec, Destroy Codestream information after compression or decompression @param cstr_info Codestream information structure */ -OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t **cstr_info); +OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t + **cstr_info); /** * Dump the codec information into the output stream * - * @param p_codec the jpeg2000 codec. - * @param info_flag type of information dump. - * @param output_stream output stream where dump the informations get from the codec. + * @param p_codec the jpeg2000 codec. + * @param info_flag type of information dump. + * @param output_stream output stream where dump the informations get from the codec. * */ -OPJ_API void OPJ_CALLCONV opj_dump_codec( opj_codec_t *p_codec, - OPJ_INT32 info_flag, - FILE* output_stream); +OPJ_API void OPJ_CALLCONV opj_dump_codec(opj_codec_t *p_codec, + OPJ_INT32 info_flag, + FILE* output_stream); /** * Get the codestream information from the codec * - * @param p_codec the jpeg2000 codec. + * @param p_codec the jpeg2000 codec. * - * @return a pointer to a codestream information structure. + * @return a pointer to a codestream information structure. * */ -OPJ_API opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(opj_codec_t *p_codec); +OPJ_API opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info( + opj_codec_t *p_codec); /** * Get the codestream index from the codec * - * @param p_codec the jpeg2000 codec. + * @param p_codec the jpeg2000 codec. * - * @return a pointer to a codestream index structure. + * @return a pointer to a codestream index structure. * */ -OPJ_API opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(opj_codec_t *p_codec); +OPJ_API opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index( + opj_codec_t *p_codec); -OPJ_API void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index); +OPJ_API void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t + **p_cstr_index); /** * Get the JP2 file information from the codec FIXME * - * @param p_codec the jpeg2000 codec. + * @param p_codec the jpeg2000 codec. * - * @return a pointer to a JP2 metadata structure. + * @return a pointer to a JP2 metadata structure. * */ -OPJ_API opj_jp2_metadata_t* OPJ_CALLCONV opj_get_jp2_metadata(opj_codec_t *p_codec); +OPJ_API opj_jp2_metadata_t* OPJ_CALLCONV opj_get_jp2_metadata( + opj_codec_t *p_codec); /** * Get the JP2 file index from the codec FIXME * - * @param p_codec the jpeg2000 codec. + * @param p_codec the jpeg2000 codec. * - * @return a pointer to a JP2 index structure. + * @return a pointer to a JP2 index structure. * */ OPJ_API opj_jp2_index_t* OPJ_CALLCONV opj_get_jp2_index(opj_codec_t *p_codec); @@ -1561,17 +1585,17 @@ OPJ_API opj_jp2_index_t* OPJ_CALLCONV opj_get_jp2_index(opj_codec_t *p_codec); /** * Sets the MCT matrix to use. * - * @param parameters the parameters to change. - * @param pEncodingMatrix the encoding matrix. - * @param p_dc_shift the dc shift coefficients to use. - * @param pNbComp the number of components of the image. + * @param parameters the parameters to change. + * @param pEncodingMatrix the encoding matrix. + * @param p_dc_shift the dc shift coefficients to use. + * @param pNbComp the number of components of the image. * - * @return true if the parameters could be set. + * @return true if the parameters could be set. */ -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_MCT( opj_cparameters_t *parameters, - OPJ_FLOAT32 * pEncodingMatrix, - OPJ_INT32 * p_dc_shift, - OPJ_UINT32 pNbComp); +OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters, + OPJ_FLOAT32 * pEncodingMatrix, + OPJ_INT32 * p_dc_shift, + OPJ_UINT32 pNbComp); /* ========================================================== diff --git a/src/lib/openjp2/opj_clock.h b/src/lib/openjp2/opj_clock.h index 6f5168b5..a50eef24 100644 --- a/src/lib/openjp2/opj_clock.h +++ b/src/lib/openjp2/opj_clock.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * diff --git a/src/lib/openjp2/opj_codec.h b/src/lib/openjp2/opj_codec.h index c88005d7..00ce9ab9 100644 --- a/src/lib/openjp2/opj_codec.h +++ b/src/lib/openjp2/opj_codec.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -39,114 +39,110 @@ /** * Main codec handler used for compression or decompression. */ -typedef struct opj_codec_private -{ +typedef struct opj_codec_private { /** FIXME DOC */ - union - { + union { /** * Decompression handler. */ - struct opj_decompression - { + struct opj_decompression { /** Main header reading function handler */ - OPJ_BOOL (*opj_read_header) ( struct opj_stream_private * cio, - void * p_codec, - opj_image_t **p_image, - struct opj_event_mgr * p_manager); + OPJ_BOOL(*opj_read_header)(struct opj_stream_private * cio, + void * p_codec, + opj_image_t **p_image, + struct opj_event_mgr * p_manager); /** Decoding function */ - OPJ_BOOL (*opj_decode) ( void * p_codec, - struct opj_stream_private * p_cio, - opj_image_t * p_image, - struct opj_event_mgr * p_manager); + OPJ_BOOL(*opj_decode)(void * p_codec, + struct opj_stream_private * p_cio, + opj_image_t * p_image, + struct opj_event_mgr * p_manager); /** FIXME DOC */ - OPJ_BOOL (*opj_read_tile_header)( void * p_codec, - 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_should_go_on, - struct opj_stream_private * p_cio, - struct opj_event_mgr * p_manager); + OPJ_BOOL(*opj_read_tile_header)(void * p_codec, + 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_should_go_on, + struct opj_stream_private * p_cio, + struct opj_event_mgr * p_manager); /** FIXME DOC */ - OPJ_BOOL (*opj_decode_tile_data)( void * p_codec, - OPJ_UINT32 p_tile_index, - OPJ_BYTE * p_data, - OPJ_UINT32 p_data_size, - struct opj_stream_private * p_cio, - struct opj_event_mgr * p_manager); + OPJ_BOOL(*opj_decode_tile_data)(void * p_codec, + OPJ_UINT32 p_tile_index, + OPJ_BYTE * p_data, + OPJ_UINT32 p_data_size, + struct opj_stream_private * p_cio, + struct opj_event_mgr * p_manager); /** Reading function used after codestream if necessary */ - OPJ_BOOL (* opj_end_decompress) ( void *p_codec, - struct opj_stream_private * cio, - struct opj_event_mgr * p_manager); + OPJ_BOOL(* opj_end_decompress)(void *p_codec, + struct opj_stream_private * cio, + struct opj_event_mgr * p_manager); /** Codec destroy function handler */ - void (*opj_destroy) (void * p_codec); + void (*opj_destroy)(void * p_codec); /** Setup decoder function handler */ - void (*opj_setup_decoder) ( void * p_codec, opj_dparameters_t * p_param); + void (*opj_setup_decoder)(void * p_codec, opj_dparameters_t * p_param); /** Set decode area function handler */ - OPJ_BOOL (*opj_set_decode_area) ( void * p_codec, - opj_image_t * p_image, - OPJ_INT32 p_start_x, - OPJ_INT32 p_end_x, - OPJ_INT32 p_start_y, - OPJ_INT32 p_end_y, - struct opj_event_mgr * p_manager); + OPJ_BOOL(*opj_set_decode_area)(void * p_codec, + opj_image_t * p_image, + OPJ_INT32 p_start_x, + OPJ_INT32 p_end_x, + OPJ_INT32 p_start_y, + OPJ_INT32 p_end_y, + struct opj_event_mgr * p_manager); /** Get tile function */ - OPJ_BOOL (*opj_get_decoded_tile) ( void *p_codec, - opj_stream_private_t * p_cio, - opj_image_t *p_image, - struct opj_event_mgr * p_manager, - OPJ_UINT32 tile_index); + OPJ_BOOL(*opj_get_decoded_tile)(void *p_codec, + opj_stream_private_t * p_cio, + opj_image_t *p_image, + struct opj_event_mgr * p_manager, + OPJ_UINT32 tile_index); /** Set the decoded resolution factor */ - OPJ_BOOL (*opj_set_decoded_resolution_factor) ( void * p_codec, - OPJ_UINT32 res_factor, - opj_event_mgr_t * p_manager); + OPJ_BOOL(*opj_set_decoded_resolution_factor)(void * p_codec, + OPJ_UINT32 res_factor, + opj_event_mgr_t * p_manager); } m_decompression; /** * Compression handler. FIXME DOC */ - struct opj_compression - { - OPJ_BOOL (* opj_start_compress) ( void *p_codec, - struct opj_stream_private * cio, - struct opj_image * p_image, - struct opj_event_mgr * p_manager); - - OPJ_BOOL (* opj_encode) ( void * p_codec, - struct opj_stream_private *p_cio, - struct opj_event_mgr * p_manager); - - OPJ_BOOL (* opj_write_tile) ( void * p_codec, - OPJ_UINT32 p_tile_index, - OPJ_BYTE * p_data, - OPJ_UINT32 p_data_size, - struct opj_stream_private * p_cio, + struct opj_compression { + OPJ_BOOL(* opj_start_compress)(void *p_codec, + struct opj_stream_private * cio, + struct opj_image * p_image, + struct opj_event_mgr * p_manager); + + OPJ_BOOL(* opj_encode)(void * p_codec, + struct opj_stream_private *p_cio, + struct opj_event_mgr * p_manager); + + OPJ_BOOL(* opj_write_tile)(void * p_codec, + OPJ_UINT32 p_tile_index, + OPJ_BYTE * p_data, + OPJ_UINT32 p_data_size, + struct opj_stream_private * p_cio, + struct opj_event_mgr * p_manager); + + OPJ_BOOL(* opj_end_compress)(void * p_codec, + struct opj_stream_private * p_cio, + struct opj_event_mgr * p_manager); + + void (* opj_destroy)(void * p_codec); + + OPJ_BOOL(* opj_setup_encoder)(void * p_codec, + opj_cparameters_t * p_param, + struct opj_image * p_image, struct opj_event_mgr * p_manager); - - OPJ_BOOL (* opj_end_compress) ( void * p_codec, - struct opj_stream_private * p_cio, - struct opj_event_mgr * p_manager); - - void (* opj_destroy) (void * p_codec); - - OPJ_BOOL (* opj_setup_encoder) ( void * p_codec, - opj_cparameters_t * p_param, - struct opj_image * p_image, - struct opj_event_mgr * p_manager); } m_compression; } m_codec_data; /** FIXME DOC*/ @@ -155,12 +151,13 @@ typedef struct opj_codec_private opj_event_mgr_t m_event_mgr; /** Flag to indicate if the codec is used to decode or encode*/ OPJ_BOOL is_decompressor; - void (*opj_dump_codec) (void * p_codec, OPJ_INT32 info_flag, FILE* output_stream); + void (*opj_dump_codec)(void * p_codec, OPJ_INT32 info_flag, + FILE* output_stream); opj_codestream_info_v2_t* (*opj_get_codec_info)(void* p_codec); opj_codestream_index_t* (*opj_get_codec_index)(void* p_codec); /** Set number of threads */ - OPJ_BOOL (*opj_set_threads) ( void * p_codec, OPJ_UINT32 num_threads ); + OPJ_BOOL(*opj_set_threads)(void * p_codec, OPJ_UINT32 num_threads); } opj_codec_private_t; diff --git a/src/lib/openjp2/opj_includes.h b/src/lib/openjp2/opj_includes.h index e3de42da..98ade3fd 100644 --- a/src/lib/openjp2/opj_includes.h +++ b/src/lib/openjp2/opj_includes.h @@ -1,11 +1,11 @@ /* - * 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 + * 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) 2005, Herve Drolon, FreeImage Team - * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR + * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR * Copyright (c) 2012, CS Systemes d'Information, France * All rights reserved. * @@ -71,11 +71,11 @@ #if defined(WIN32) && !defined(Windows95) && !defined(__BORLANDC__) && \ !(defined(_MSC_VER) && _MSC_VER < 1400) && \ !(defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x800) - /* - Windows '95 and Borland C do not support _lseeki64 - Visual Studio does not support _fseeki64 and _ftelli64 until the 2005 release. - Without these interfaces, files over 2GB in size are not supported for Windows. - */ +/* + Windows '95 and Borland C do not support _lseeki64 + Visual Studio does not support _fseeki64 and _ftelli64 until the 2005 release. + Without these interfaces, files over 2GB in size are not supported for Windows. +*/ # define OPJ_FSEEK(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence) # define OPJ_FSTAT(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff) # define OPJ_FTELL(stream) /* __int64 */ _ftelli64(stream) @@ -105,83 +105,86 @@ /* Are restricted pointers available? (C99) */ #if (__STDC_VERSION__ >= 199901L) - #define OPJ_RESTRICT restrict +#define OPJ_RESTRICT restrict #else - /* Not a C99 compiler */ - #if defined(__GNUC__) - #define OPJ_RESTRICT __restrict__ +/* Not a C99 compiler */ +#if defined(__GNUC__) +#define OPJ_RESTRICT __restrict__ /* vc14 (2015) outputs wrong results. Need to check OPJ_RESTRICT usage (or a bug in vc14) - #elif defined(_MSC_VER) && (_MSC_VER >= 1400) - #define OPJ_RESTRICT __restrict + #elif defined(_MSC_VER) && (_MSC_VER >= 1400) + #define OPJ_RESTRICT __restrict */ - #else - #define OPJ_RESTRICT /* restrict */ - #endif +#else +#define OPJ_RESTRICT /* restrict */ +#endif #endif #ifdef __has_attribute - #if __has_attribute(no_sanitize) - #define OPJ_NOSANITIZE(kind) __attribute__((no_sanitize(kind))) - #endif +#if __has_attribute(no_sanitize) +#define OPJ_NOSANITIZE(kind) __attribute__((no_sanitize(kind))) +#endif #endif #ifndef OPJ_NOSANITIZE - #define OPJ_NOSANITIZE(kind) +#define OPJ_NOSANITIZE(kind) #endif /* MSVC before 2013 and Borland C do not have lrintf */ #if defined(_MSC_VER) #include <intrin.h> -static INLINE long opj_lrintf(float f){ +static INLINE long opj_lrintf(float f) +{ #ifdef _M_X64 - return _mm_cvt_ss2si(_mm_load_ss(&f)); + return _mm_cvt_ss2si(_mm_load_ss(&f)); - /* commented out line breaks many tests */ - /* return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); */ + /* commented out line breaks many tests */ + /* return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); */ #elif defined(_M_IX86) int i; - _asm{ + _asm{ fld f fistp i }; - + return i; -#else - return (long)((f>0.0f) ? (f + 0.5f) : (f - 0.5f)); +#else + return (long)((f>0.0f) ? (f + 0.5f) : (f - 0.5f)); #endif } #elif defined(__BORLANDC__) -static INLINE long opj_lrintf(float f) { +static INLINE long opj_lrintf(float f) +{ #ifdef _M_X64 - return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); + return (long)((f > 0.0f) ? (f + 0.5f) : (f - 0.5f)); #else - int i; + int i; - _asm { - fld f - fistp i - }; + _asm { + fld f + fistp i + }; - return i; + return i; #endif } #else -static INLINE long opj_lrintf(float f) { - return lrintf(f); +static INLINE long opj_lrintf(float f) +{ + return lrintf(f); } #endif #if defined(_MSC_VER) && (_MSC_VER < 1400) - #define vsnprintf _vsnprintf +#define vsnprintf _vsnprintf #endif /* MSVC x86 is really bad at doing int64 = int32 * int32 on its own. Use intrinsic. */ #if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86) -# include <intrin.h> -# pragma intrinsic(__emul) +# include <intrin.h> +# pragma intrinsic(__emul) #endif /* Type to use for bit-fields in internal headers */ diff --git a/src/lib/openjp2/opj_intmath.h b/src/lib/openjp2/opj_intmath.h index 3f7934c4..03a446f1 100644 --- a/src/lib/openjp2/opj_intmath.h +++ b/src/lib/openjp2/opj_intmath.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,7 +8,7 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. @@ -53,41 +53,46 @@ The functions in OPJ_INTMATH.H have for goal to realize operations on integers. Get the minimum of two integers @return Returns a if a < b else b */ -static INLINE OPJ_INT32 opj_int_min(OPJ_INT32 a, OPJ_INT32 b) { - return a < b ? a : b; +static INLINE OPJ_INT32 opj_int_min(OPJ_INT32 a, OPJ_INT32 b) +{ + return a < b ? a : b; } /** Get the minimum of two integers @return Returns a if a < b else b */ -static INLINE OPJ_UINT32 opj_uint_min(OPJ_UINT32 a, OPJ_UINT32 b) { - return a < b ? a : b; +static INLINE OPJ_UINT32 opj_uint_min(OPJ_UINT32 a, OPJ_UINT32 b) +{ + return a < b ? a : b; } /** Get the maximum of two integers @return Returns a if a > b else b */ -static INLINE OPJ_INT32 opj_int_max(OPJ_INT32 a, OPJ_INT32 b) { - return (a > b) ? a : b; +static INLINE OPJ_INT32 opj_int_max(OPJ_INT32 a, OPJ_INT32 b) +{ + return (a > b) ? a : b; } /** Get the maximum of two integers @return Returns a if a > b else b */ -static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b) { - return (a > b) ? a : b; +static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b) +{ + return (a > b) ? a : b; } /** Get the saturated sum of two unsigned integers @return Returns saturated sum of a+b */ -static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b) { - OPJ_UINT64 sum = (OPJ_UINT64)a + (OPJ_UINT64)b; - return (OPJ_UINT32)(-(OPJ_INT32)(sum >> 32)) | (OPJ_UINT32)sum; +static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b) +{ + OPJ_UINT64 sum = (OPJ_UINT64)a + (OPJ_UINT64)b; + return (OPJ_UINT32)(-(OPJ_INT32)(sum >> 32)) | (OPJ_UINT32)sum; } /** @@ -96,93 +101,105 @@ Clamp an integer inside an interval <ul> <li>Returns a if (min < a < max) <li>Returns max if (a > max) -<li>Returns min if (a < min) +<li>Returns min if (a < min) </ul> */ -static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max) { - if (a < min) - return min; - if (a > max) - return max; - return a; +static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min, + OPJ_INT32 max) +{ + if (a < min) { + return min; + } + if (a > max) { + return max; + } + return a; } /** @return Get absolute value of integer */ -static INLINE OPJ_INT32 opj_int_abs(OPJ_INT32 a) { - return a < 0 ? -a : a; +static INLINE OPJ_INT32 opj_int_abs(OPJ_INT32 a) +{ + return a < 0 ? -a : a; } /** Divide an integer and round upwards @return Returns a divided by b */ -static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) { - assert(b); - return (a + b - 1) / b; +static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) +{ + assert(b); + return (a + b - 1) / b; } /** Divide an integer and round upwards @return Returns a divided by b */ -static INLINE OPJ_UINT32 opj_uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b) { - assert(b); - return (a + b - 1) / b; +static INLINE OPJ_UINT32 opj_uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b) +{ + assert(b); + return (a + b - 1) / b; } /** Divide an integer by a power of 2 and round upwards @return Returns a divided by 2^b */ -static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) { - return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b); +static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) +{ + return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b); } /** Divide a 64bits integer by a power of 2 and round upwards @return Returns a divided by 2^b */ -static INLINE OPJ_INT32 opj_int64_ceildivpow2(OPJ_INT64 a, OPJ_INT32 b) { - return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b); +static INLINE OPJ_INT32 opj_int64_ceildivpow2(OPJ_INT64 a, OPJ_INT32 b) +{ + return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b); } /** Divide an integer by a power of 2 and round upwards @return Returns a divided by 2^b */ -static INLINE OPJ_UINT32 opj_uint_ceildivpow2(OPJ_UINT32 a, OPJ_UINT32 b) { - return (OPJ_UINT32)((a + ((OPJ_UINT64)1U << b) - 1U) >> b); +static INLINE OPJ_UINT32 opj_uint_ceildivpow2(OPJ_UINT32 a, OPJ_UINT32 b) +{ + return (OPJ_UINT32)((a + ((OPJ_UINT64)1U << b) - 1U) >> b); } /** Divide an integer by a power of 2 and round downwards @return Returns a divided by 2^b */ -static INLINE OPJ_INT32 opj_int_floordivpow2(OPJ_INT32 a, OPJ_INT32 b) { - return a >> b; +static INLINE OPJ_INT32 opj_int_floordivpow2(OPJ_INT32 a, OPJ_INT32 b) +{ + return a >> b; } /** Get logarithm of an integer and round downwards @return Returns log2(a) */ -static INLINE OPJ_INT32 opj_int_floorlog2(OPJ_INT32 a) { - OPJ_INT32 l; - for (l = 0; a > 1; l++) { - a >>= 1; - } - return l; +static INLINE OPJ_INT32 opj_int_floorlog2(OPJ_INT32 a) +{ + OPJ_INT32 l; + for (l = 0; a > 1; l++) { + a >>= 1; + } + return l; } /** Get logarithm of an integer and round downwards @return Returns log2(a) */ -static INLINE OPJ_UINT32 opj_uint_floorlog2(OPJ_UINT32 a) { - OPJ_UINT32 l; - for (l = 0; a > 1; ++l) - { - a >>= 1; - } - return l; +static INLINE OPJ_UINT32 opj_uint_floorlog2(OPJ_UINT32 a) +{ + OPJ_UINT32 l; + for (l = 0; a > 1; ++l) { + a >>= 1; + } + return l; } /** @@ -191,28 +208,31 @@ Multiply two fixed-precision rational numbers. @param b @return Returns a * b */ -static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) { +static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) +{ #if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86) - OPJ_INT64 temp = __emul(a, b); + OPJ_INT64 temp = __emul(a, b); #else - OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ; + OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ; #endif - temp += 4096; - assert((temp >> 13) <= (OPJ_INT64)0x7FFFFFFF); - assert((temp >> 13) >= (-(OPJ_INT64)0x7FFFFFFF - (OPJ_INT64)1)); - return (OPJ_INT32) (temp >> 13); + temp += 4096; + assert((temp >> 13) <= (OPJ_INT64)0x7FFFFFFF); + assert((temp >> 13) >= (-(OPJ_INT64)0x7FFFFFFF - (OPJ_INT64)1)); + return (OPJ_INT32)(temp >> 13); } -static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b) { +static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b) +{ #if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86) - OPJ_INT64 temp = __emul(a, b); + OPJ_INT64 temp = __emul(a, b); #else - OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ; + OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ; #endif - temp += 4096; - assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) <= (OPJ_INT64)0x7FFFFFFF); - assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) >= (-(OPJ_INT64)0x7FFFFFFF - (OPJ_INT64)1)); - return (OPJ_INT32) (temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) ; + temp += 4096; + assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) <= (OPJ_INT64)0x7FFFFFFF); + assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) >= (-(OPJ_INT64)0x7FFFFFFF - + (OPJ_INT64)1)); + return (OPJ_INT32)(temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) ; } /* ----------------------------------------------------------------------- */ diff --git a/src/lib/openjp2/opj_inttypes.h b/src/lib/openjp2/opj_inttypes.h index e74aed6a..2c9749a1 100644 --- a/src/lib/openjp2/opj_inttypes.h +++ b/src/lib/openjp2/opj_inttypes.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * diff --git a/src/lib/openjp2/opj_malloc.h b/src/lib/openjp2/opj_malloc.h index 1b3fced9..c8c2fc2d 100644 --- a/src/lib/openjp2/opj_malloc.h +++ b/src/lib/openjp2/opj_malloc.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * diff --git a/src/lib/openjp2/opj_stdint.h b/src/lib/openjp2/opj_stdint.h index b8556a19..f26c921c 100644 --- a/src/lib/openjp2/opj_stdint.h +++ b/src/lib/openjp2/opj_stdint.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * diff --git a/src/lib/openjp2/pi.h b/src/lib/openjp2/pi.h index 265d5b1e..a16995bd 100644 --- a/src/lib/openjp2/pi.h +++ b/src/lib/openjp2/pi.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,7 +8,7 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. @@ -53,58 +53,58 @@ by some function in T2.C. FIXME DOC */ typedef struct opj_pi_resolution { - OPJ_UINT32 pdx, pdy; - OPJ_UINT32 pw, ph; + OPJ_UINT32 pdx, pdy; + OPJ_UINT32 pw, ph; } opj_pi_resolution_t; /** FIXME DOC */ typedef struct opj_pi_comp { - OPJ_UINT32 dx, dy; - /** number of resolution levels */ - OPJ_UINT32 numresolutions; - opj_pi_resolution_t *resolutions; + OPJ_UINT32 dx, dy; + /** number of resolution levels */ + OPJ_UINT32 numresolutions; + opj_pi_resolution_t *resolutions; } opj_pi_comp_t; /** Packet iterator */ typedef struct opj_pi_iterator { - /** Enabling Tile part generation*/ - OPJ_BYTE tp_on; - /** precise if the packet has been already used (useful for progression order change) */ - OPJ_INT16 *include; - /** layer step used to localize the packet in the include vector */ - OPJ_UINT32 step_l; - /** resolution step used to localize the packet in the include vector */ - OPJ_UINT32 step_r; - /** component step used to localize the packet in the include vector */ - OPJ_UINT32 step_c; - /** precinct step used to localize the packet in the include vector */ - OPJ_UINT32 step_p; - /** component that identify the packet */ - OPJ_UINT32 compno; - /** resolution that identify the packet */ - OPJ_UINT32 resno; - /** precinct that identify the packet */ - OPJ_UINT32 precno; - /** layer that identify the packet */ - OPJ_UINT32 layno; - /** 0 if the first packet */ - OPJ_BOOL first; - /** progression order change information */ - opj_poc_t poc; - /** number of components in the image */ - OPJ_UINT32 numcomps; - /** Components*/ - opj_pi_comp_t *comps; - /** FIXME DOC*/ - OPJ_INT32 tx0, ty0, tx1, ty1; - /** FIXME DOC*/ - OPJ_INT32 x, y; - /** FIXME DOC*/ - OPJ_UINT32 dx, dy; + /** Enabling Tile part generation*/ + OPJ_BYTE tp_on; + /** precise if the packet has been already used (useful for progression order change) */ + OPJ_INT16 *include; + /** layer step used to localize the packet in the include vector */ + OPJ_UINT32 step_l; + /** resolution step used to localize the packet in the include vector */ + OPJ_UINT32 step_r; + /** component step used to localize the packet in the include vector */ + OPJ_UINT32 step_c; + /** precinct step used to localize the packet in the include vector */ + OPJ_UINT32 step_p; + /** component that identify the packet */ + OPJ_UINT32 compno; + /** resolution that identify the packet */ + OPJ_UINT32 resno; + /** precinct that identify the packet */ + OPJ_UINT32 precno; + /** layer that identify the packet */ + OPJ_UINT32 layno; + /** 0 if the first packet */ + OPJ_BOOL first; + /** progression order change information */ + opj_poc_t poc; + /** number of components in the image */ + OPJ_UINT32 numcomps; + /** Components*/ + opj_pi_comp_t *comps; + /** FIXME DOC*/ + OPJ_INT32 tx0, ty0, tx1, ty1; + /** FIXME DOC*/ + OPJ_INT32 x, y; + /** FIXME DOC*/ + OPJ_UINT32 dx, dy; } opj_pi_iterator_t; /** @name Exported functions */ @@ -113,28 +113,28 @@ typedef struct opj_pi_iterator { /** * Creates a packet iterator for encoding. * - * @param image the image being encoded. - * @param cp the coding parameters. - * @param tileno index of the tile being encoded. - * @param t2_mode the type of pass for generating the packet iterator + * @param image the image being encoded. + * @param cp the coding parameters. + * @param tileno index of the tile being encoded. + * @param t2_mode the type of pass for generating the packet iterator * - * @return a list of packet iterator that points to the first packet of the tile (not true). + * @return a list of packet iterator that points to the first packet of the tile (not true). */ opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *image, - opj_cp_t *cp, - OPJ_UINT32 tileno, - J2K_T2_MODE t2_mode); + opj_cp_t *cp, + OPJ_UINT32 tileno, + J2K_T2_MODE t2_mode); /** * Updates the encoding parameters of the codec. * - * @param p_image the image being encoded. - * @param p_cp the coding parameters. - * @param p_tile_no index of the tile being encoded. + * @param p_image the image being encoded. + * @param p_cp the coding parameters. + * @param p_tile_no index of the tile being encoded. */ -void opj_pi_update_encoding_parameters( const opj_image_t *p_image, - opj_cp_t *p_cp, - OPJ_UINT32 p_tile_no ); +void opj_pi_update_encoding_parameters(const opj_image_t *p_image, + opj_cp_t *p_cp, + OPJ_UINT32 p_tile_no); /** Modify the packet iterator for enabling tile part generation @@ -146,13 +146,13 @@ Modify the packet iterator for enabling tile part generation @param tppos The position of the tile part flag in the progression order @param t2_mode FIXME DOC */ -void opj_pi_create_encode( opj_pi_iterator_t *pi, - opj_cp_t *cp, - OPJ_UINT32 tileno, - OPJ_UINT32 pino, - OPJ_UINT32 tpnum, - OPJ_INT32 tppos, - J2K_T2_MODE t2_mode); +void opj_pi_create_encode(opj_pi_iterator_t *pi, + opj_cp_t *cp, + OPJ_UINT32 tileno, + OPJ_UINT32 pino, + OPJ_UINT32 tpnum, + OPJ_INT32 tppos, + J2K_T2_MODE t2_mode); /** Create a packet iterator for Decoder @@ -162,14 +162,14 @@ Create a packet iterator for Decoder @return Returns a packet iterator that points to the first packet of the tile @see opj_pi_destroy */ -opj_pi_iterator_t *opj_pi_create_decode(opj_image_t * image, +opj_pi_iterator_t *opj_pi_create_decode(opj_image_t * image, opj_cp_t * cp, OPJ_UINT32 tileno); /** * Destroys a packet iterator array. * - * @param p_pi the packet iterator array to destroy. - * @param p_nb_elements the number of elements in the array. + * @param p_pi the packet iterator array to destroy. + * @param p_nb_elements the number of elements in the array. */ void opj_pi_destroy(opj_pi_iterator_t *p_pi, OPJ_UINT32 p_nb_elements); diff --git a/src/lib/openjp2/raw.h b/src/lib/openjp2/raw.h index 572c6661..9a32c83d 100644 --- a/src/lib/openjp2/raw.h +++ b/src/lib/openjp2/raw.h @@ -1,12 +1,12 @@ /* - * 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 + * 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) 2003-2007, Francois-Olivier Devaux + * Copyright (c) 2003-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. @@ -50,27 +50,27 @@ with the corresponding mode switch. RAW encoding operations */ typedef struct opj_raw { - /** temporary buffer where bits are coded or decoded */ - OPJ_BYTE c; - /** number of bits already read or free to write */ - OPJ_UINT32 ct; - /** maximum length to decode */ - OPJ_UINT32 lenmax; - /** length decoded */ - OPJ_UINT32 len; - /** pointer to the current position in the buffer */ - OPJ_BYTE *bp; - /** pointer to the start of the buffer */ - OPJ_BYTE *start; - /** pointer to the end of the buffer */ - OPJ_BYTE *end; + /** temporary buffer where bits are coded or decoded */ + OPJ_BYTE c; + /** number of bits already read or free to write */ + OPJ_UINT32 ct; + /** maximum length to decode */ + OPJ_UINT32 lenmax; + /** length decoded */ + OPJ_UINT32 len; + /** pointer to the current position in the buffer */ + OPJ_BYTE *bp; + /** pointer to the start of the buffer */ + OPJ_BYTE *start; + /** pointer to the end of the buffer */ + OPJ_BYTE *end; } opj_raw_t; /** @name Exported functions */ /*@{*/ /* ----------------------------------------------------------------------- */ /** -Create a new RAW handle +Create a new RAW handle @return Returns a new RAW handle if successful, returns NULL otherwise */ opj_raw_t* opj_raw_create(void); diff --git a/src/lib/openjp2/t1.h b/src/lib/openjp2/t1.h index c3fb7bed..31a2d9f3 100644 --- a/src/lib/openjp2/t1.h +++ b/src/lib/openjp2/t1.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,7 +8,7 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. @@ -90,8 +90,8 @@ in T1.C are used by some function in TCD.C. #define T1_NMSEDEC_FRACBITS (T1_NMSEDEC_BITS-1) -#define T1_TYPE_MQ 0 /**< Normal coding using entropy coder */ -#define T1_TYPE_RAW 1 /**< No encoding the information is store under raw format in codestream (mode switch RAW)*/ +#define T1_TYPE_MQ 0 /**< Normal coding using entropy coder */ +#define T1_TYPE_RAW 1 /**< No encoding the information is store under raw format in codestream (mode switch RAW)*/ /* Those flags are used by opj_colflag_t */ #define T1_COLFLAG_RBS 4U /* RBS = Row Bit Shift */ @@ -124,26 +124,26 @@ Tier-1 coding (coding of code-block coefficients) */ typedef struct opj_t1 { - /** MQC component */ - opj_mqc_t *mqc; - /** RAW component */ - opj_raw_t *raw; - - OPJ_INT32 *data; - opj_flag_t *flags; - /** Addition flag array such that colflags[1+0] is for state of col=0,row=0..3, - colflags[1+1] for col=1, row=0..3, colflags[1+flags_stride] for col=0,row=4..7, ... - This array avoids too much cache trashing when processing by 4 vertical samples - as done in the various decoding steps. */ - opj_colflag_t* colflags; - OPJ_UINT32 w; - OPJ_UINT32 h; - OPJ_UINT32 datasize; - OPJ_UINT32 flagssize; - OPJ_UINT32 flags_stride; - OPJ_UINT32 colflags_size; - OPJ_UINT32 data_stride; - OPJ_BOOL encoder; + /** MQC component */ + opj_mqc_t *mqc; + /** RAW component */ + opj_raw_t *raw; + + OPJ_INT32 *data; + opj_flag_t *flags; + /** Addition flag array such that colflags[1+0] is for state of col=0,row=0..3, + colflags[1+1] for col=1, row=0..3, colflags[1+flags_stride] for col=0,row=4..7, ... + This array avoids too much cache trashing when processing by 4 vertical samples + as done in the various decoding steps. */ + opj_colflag_t* colflags; + OPJ_UINT32 w; + OPJ_UINT32 h; + OPJ_UINT32 datasize; + OPJ_UINT32 flagssize; + OPJ_UINT32 flags_stride; + OPJ_UINT32 colflags_size; + OPJ_UINT32 data_stride; + OPJ_BOOL encoder; } opj_t1_t; #define MACRO_t1_flags(x,y) t1->flags[((x)*(t1->flags_stride))+(y)] @@ -160,11 +160,11 @@ Encode the code-blocks of a tile @param mct_norms FIXME DOC @param mct_numcomps Number of components used for MCT */ -OPJ_BOOL opj_t1_encode_cblks( opj_t1_t *t1, - opj_tcd_tile_t *tile, - opj_tcp_t *tcp, - const OPJ_FLOAT64 * mct_norms, - OPJ_UINT32 mct_numcomps); +OPJ_BOOL opj_t1_encode_cblks(opj_t1_t *t1, + opj_tcd_tile_t *tile, + opj_tcp_t *tcp, + const OPJ_FLOAT64 * mct_norms, + OPJ_UINT32 mct_numcomps); /** Decode the code-blocks of a tile @@ -172,10 +172,10 @@ Decode the code-blocks of a tile @param tilec The tile to decode @param tccp Tile coding parameters */ -void opj_t1_decode_cblks( opj_thread_pool_t* tp, - volatile OPJ_BOOL* pret, - opj_tcd_tilecomp_t* tilec, - opj_tccp_t* tccp); +void opj_t1_decode_cblks(opj_thread_pool_t* tp, + volatile OPJ_BOOL* pret, + opj_tcd_tilecomp_t* tilec, + opj_tccp_t* tccp); diff --git a/src/lib/openjp2/t1_luts.h b/src/lib/openjp2/t1_luts.h index 561133fb..8402b7a8 100644 --- a/src/lib/openjp2/t1_luts.h +++ b/src/lib/openjp2/t1_luts.h @@ -1,143 +1,143 @@ /* This file was automatically generated by t1_generate_luts.c */ static const OPJ_BYTE lut_ctxno_zc[1024] = { - 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 0, 3, 3, 6, 3, 6, 6, 8, 3, 6, 6, 8, 6, 8, 8, 8, 1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, - 1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, - 1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, - 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, - 1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, - 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, - 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, - 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8 + 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 0, 3, 3, 6, 3, 6, 6, 8, 3, 6, 6, 8, 6, 8, 8, 8, 1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, + 1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, + 1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, + 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, + 1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, + 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, + 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, + 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8 }; static const OPJ_BYTE lut_ctxno_sc[256] = { - 0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd, - 0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xb, 0xc, 0xb, 0xd, 0xc, 0xd, 0xc, - 0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xd, 0x9, 0xa, 0xd, 0xd, 0xa, 0xa, - 0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xb, 0x9, 0xa, 0xd, 0xc, 0xa, 0x9, - 0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xd, 0xc, 0xd, 0xb, 0xc, 0xb, 0xc, - 0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xb, 0xc, 0xb, 0xb, 0xb, 0xb, 0xb, - 0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xd, 0x9, 0xa, 0xb, 0xc, 0xa, 0x9, - 0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xb, 0x9, 0xa, 0xb, 0xb, 0xa, 0xa, - 0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xb, 0x9, 0xa, 0xb, 0xb, 0xa, 0xa, - 0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xd, 0x9, 0xa, 0xb, 0xc, 0xa, 0x9, - 0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xb, 0xc, 0xb, 0xb, 0xb, 0xb, 0xb, - 0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xd, 0xc, 0xd, 0xb, 0xc, 0xb, 0xc, - 0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xb, 0x9, 0xa, 0xd, 0xc, 0xa, 0x9, - 0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xd, 0x9, 0xa, 0xd, 0xd, 0xa, 0xa, - 0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xb, 0xc, 0xb, 0xd, 0xc, 0xd, 0xc, - 0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd + 0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd, + 0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xb, 0xc, 0xb, 0xd, 0xc, 0xd, 0xc, + 0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xd, 0x9, 0xa, 0xd, 0xd, 0xa, 0xa, + 0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xb, 0x9, 0xa, 0xd, 0xc, 0xa, 0x9, + 0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xd, 0xc, 0xd, 0xb, 0xc, 0xb, 0xc, + 0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xb, 0xc, 0xb, 0xb, 0xb, 0xb, 0xb, + 0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xd, 0x9, 0xa, 0xb, 0xc, 0xa, 0x9, + 0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xb, 0x9, 0xa, 0xb, 0xb, 0xa, 0xa, + 0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xb, 0x9, 0xa, 0xb, 0xb, 0xa, 0xa, + 0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xd, 0x9, 0xa, 0xb, 0xc, 0xa, 0x9, + 0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xb, 0xc, 0xb, 0xb, 0xb, 0xb, 0xb, + 0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xd, 0xc, 0xd, 0xb, 0xc, 0xb, 0xc, + 0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xb, 0x9, 0xa, 0xd, 0xc, 0xa, 0x9, + 0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xd, 0x9, 0xa, 0xd, 0xd, 0xa, 0xa, + 0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xb, 0xc, 0xb, 0xd, 0xc, 0xd, 0xc, + 0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd }; static const OPJ_BYTE lut_spb[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, - 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, - 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; static const OPJ_INT16 lut_nmsedec_sig[1U << T1_NMSEDEC_BITS] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0180, 0x0300, 0x0480, 0x0600, 0x0780, 0x0900, 0x0a80, - 0x0c00, 0x0d80, 0x0f00, 0x1080, 0x1200, 0x1380, 0x1500, 0x1680, - 0x1800, 0x1980, 0x1b00, 0x1c80, 0x1e00, 0x1f80, 0x2100, 0x2280, - 0x2400, 0x2580, 0x2700, 0x2880, 0x2a00, 0x2b80, 0x2d00, 0x2e80, - 0x3000, 0x3180, 0x3300, 0x3480, 0x3600, 0x3780, 0x3900, 0x3a80, - 0x3c00, 0x3d80, 0x3f00, 0x4080, 0x4200, 0x4380, 0x4500, 0x4680, - 0x4800, 0x4980, 0x4b00, 0x4c80, 0x4e00, 0x4f80, 0x5100, 0x5280, - 0x5400, 0x5580, 0x5700, 0x5880, 0x5a00, 0x5b80, 0x5d00, 0x5e80, - 0x6000, 0x6180, 0x6300, 0x6480, 0x6600, 0x6780, 0x6900, 0x6a80, - 0x6c00, 0x6d80, 0x6f00, 0x7080, 0x7200, 0x7380, 0x7500, 0x7680 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0180, 0x0300, 0x0480, 0x0600, 0x0780, 0x0900, 0x0a80, + 0x0c00, 0x0d80, 0x0f00, 0x1080, 0x1200, 0x1380, 0x1500, 0x1680, + 0x1800, 0x1980, 0x1b00, 0x1c80, 0x1e00, 0x1f80, 0x2100, 0x2280, + 0x2400, 0x2580, 0x2700, 0x2880, 0x2a00, 0x2b80, 0x2d00, 0x2e80, + 0x3000, 0x3180, 0x3300, 0x3480, 0x3600, 0x3780, 0x3900, 0x3a80, + 0x3c00, 0x3d80, 0x3f00, 0x4080, 0x4200, 0x4380, 0x4500, 0x4680, + 0x4800, 0x4980, 0x4b00, 0x4c80, 0x4e00, 0x4f80, 0x5100, 0x5280, + 0x5400, 0x5580, 0x5700, 0x5880, 0x5a00, 0x5b80, 0x5d00, 0x5e80, + 0x6000, 0x6180, 0x6300, 0x6480, 0x6600, 0x6780, 0x6900, 0x6a80, + 0x6c00, 0x6d80, 0x6f00, 0x7080, 0x7200, 0x7380, 0x7500, 0x7680 }; static const OPJ_INT16 lut_nmsedec_sig0[1U << T1_NMSEDEC_BITS] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080, - 0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200, - 0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400, - 0x0480, 0x0500, 0x0580, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780, - 0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b80, 0x0c00, - 0x0c80, 0x0d00, 0x0e00, 0x0e80, 0x0f00, 0x1000, 0x1080, 0x1180, - 0x1200, 0x1300, 0x1380, 0x1480, 0x1500, 0x1600, 0x1700, 0x1780, - 0x1880, 0x1980, 0x1a80, 0x1b00, 0x1c00, 0x1d00, 0x1e00, 0x1f00, - 0x2000, 0x2100, 0x2200, 0x2300, 0x2400, 0x2500, 0x2680, 0x2780, - 0x2880, 0x2980, 0x2b00, 0x2c00, 0x2d00, 0x2e80, 0x2f80, 0x3100, - 0x3200, 0x3380, 0x3480, 0x3600, 0x3700, 0x3880, 0x3a00, 0x3b00, - 0x3c80, 0x3e00, 0x3f80, 0x4080, 0x4200, 0x4380, 0x4500, 0x4680, - 0x4800, 0x4980, 0x4b00, 0x4c80, 0x4e00, 0x4f80, 0x5180, 0x5300, - 0x5480, 0x5600, 0x5800, 0x5980, 0x5b00, 0x5d00, 0x5e80, 0x6080, - 0x6200, 0x6400, 0x6580, 0x6780, 0x6900, 0x6b00, 0x6d00, 0x6e80, - 0x7080, 0x7280, 0x7480, 0x7600, 0x7800, 0x7a00, 0x7c00, 0x7e00 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080, + 0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200, + 0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400, + 0x0480, 0x0500, 0x0580, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780, + 0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b80, 0x0c00, + 0x0c80, 0x0d00, 0x0e00, 0x0e80, 0x0f00, 0x1000, 0x1080, 0x1180, + 0x1200, 0x1300, 0x1380, 0x1480, 0x1500, 0x1600, 0x1700, 0x1780, + 0x1880, 0x1980, 0x1a80, 0x1b00, 0x1c00, 0x1d00, 0x1e00, 0x1f00, + 0x2000, 0x2100, 0x2200, 0x2300, 0x2400, 0x2500, 0x2680, 0x2780, + 0x2880, 0x2980, 0x2b00, 0x2c00, 0x2d00, 0x2e80, 0x2f80, 0x3100, + 0x3200, 0x3380, 0x3480, 0x3600, 0x3700, 0x3880, 0x3a00, 0x3b00, + 0x3c80, 0x3e00, 0x3f80, 0x4080, 0x4200, 0x4380, 0x4500, 0x4680, + 0x4800, 0x4980, 0x4b00, 0x4c80, 0x4e00, 0x4f80, 0x5180, 0x5300, + 0x5480, 0x5600, 0x5800, 0x5980, 0x5b00, 0x5d00, 0x5e80, 0x6080, + 0x6200, 0x6400, 0x6580, 0x6780, 0x6900, 0x6b00, 0x6d00, 0x6e80, + 0x7080, 0x7280, 0x7480, 0x7600, 0x7800, 0x7a00, 0x7c00, 0x7e00 }; static const OPJ_INT16 lut_nmsedec_ref[1U << T1_NMSEDEC_BITS] = { - 0x1800, 0x1780, 0x1700, 0x1680, 0x1600, 0x1580, 0x1500, 0x1480, - 0x1400, 0x1380, 0x1300, 0x1280, 0x1200, 0x1180, 0x1100, 0x1080, - 0x1000, 0x0f80, 0x0f00, 0x0e80, 0x0e00, 0x0d80, 0x0d00, 0x0c80, - 0x0c00, 0x0b80, 0x0b00, 0x0a80, 0x0a00, 0x0980, 0x0900, 0x0880, - 0x0800, 0x0780, 0x0700, 0x0680, 0x0600, 0x0580, 0x0500, 0x0480, - 0x0400, 0x0380, 0x0300, 0x0280, 0x0200, 0x0180, 0x0100, 0x0080, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380, - 0x0400, 0x0480, 0x0500, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780, - 0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b00, 0x0b80, - 0x0c00, 0x0c80, 0x0d00, 0x0d80, 0x0e00, 0x0e80, 0x0f00, 0x0f80, - 0x1000, 0x1080, 0x1100, 0x1180, 0x1200, 0x1280, 0x1300, 0x1380, - 0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780 + 0x1800, 0x1780, 0x1700, 0x1680, 0x1600, 0x1580, 0x1500, 0x1480, + 0x1400, 0x1380, 0x1300, 0x1280, 0x1200, 0x1180, 0x1100, 0x1080, + 0x1000, 0x0f80, 0x0f00, 0x0e80, 0x0e00, 0x0d80, 0x0d00, 0x0c80, + 0x0c00, 0x0b80, 0x0b00, 0x0a80, 0x0a00, 0x0980, 0x0900, 0x0880, + 0x0800, 0x0780, 0x0700, 0x0680, 0x0600, 0x0580, 0x0500, 0x0480, + 0x0400, 0x0380, 0x0300, 0x0280, 0x0200, 0x0180, 0x0100, 0x0080, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380, + 0x0400, 0x0480, 0x0500, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780, + 0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b00, 0x0b80, + 0x0c00, 0x0c80, 0x0d00, 0x0d80, 0x0e00, 0x0e80, 0x0f00, 0x0f80, + 0x1000, 0x1080, 0x1100, 0x1180, 0x1200, 0x1280, 0x1300, 0x1380, + 0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780 }; static const OPJ_INT16 lut_nmsedec_ref0[1U << T1_NMSEDEC_BITS] = { - 0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x1b00, 0x1a80, 0x1980, - 0x1880, 0x1780, 0x1700, 0x1600, 0x1500, 0x1480, 0x1380, 0x1300, - 0x1200, 0x1180, 0x1080, 0x1000, 0x0f00, 0x0e80, 0x0e00, 0x0d00, - 0x0c80, 0x0c00, 0x0b80, 0x0a80, 0x0a00, 0x0980, 0x0900, 0x0880, - 0x0800, 0x0780, 0x0700, 0x0680, 0x0600, 0x0580, 0x0580, 0x0500, - 0x0480, 0x0400, 0x0400, 0x0380, 0x0300, 0x0300, 0x0280, 0x0280, - 0x0200, 0x0200, 0x0180, 0x0180, 0x0100, 0x0100, 0x0100, 0x0080, - 0x0080, 0x0080, 0x0080, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080, - 0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200, - 0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400, - 0x0480, 0x0500, 0x0580, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780, - 0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b80, 0x0c00, - 0x0c80, 0x0d00, 0x0e00, 0x0e80, 0x0f00, 0x1000, 0x1080, 0x1180, - 0x1200, 0x1300, 0x1380, 0x1480, 0x1500, 0x1600, 0x1700, 0x1780, - 0x1880, 0x1980, 0x1a80, 0x1b00, 0x1c00, 0x1d00, 0x1e00, 0x1f00 + 0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x1b00, 0x1a80, 0x1980, + 0x1880, 0x1780, 0x1700, 0x1600, 0x1500, 0x1480, 0x1380, 0x1300, + 0x1200, 0x1180, 0x1080, 0x1000, 0x0f00, 0x0e80, 0x0e00, 0x0d00, + 0x0c80, 0x0c00, 0x0b80, 0x0a80, 0x0a00, 0x0980, 0x0900, 0x0880, + 0x0800, 0x0780, 0x0700, 0x0680, 0x0600, 0x0580, 0x0580, 0x0500, + 0x0480, 0x0400, 0x0400, 0x0380, 0x0300, 0x0300, 0x0280, 0x0280, + 0x0200, 0x0200, 0x0180, 0x0180, 0x0100, 0x0100, 0x0100, 0x0080, + 0x0080, 0x0080, 0x0080, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080, + 0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200, + 0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400, + 0x0480, 0x0500, 0x0580, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780, + 0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b80, 0x0c00, + 0x0c80, 0x0d00, 0x0e00, 0x0e80, 0x0f00, 0x1000, 0x1080, 0x1180, + 0x1200, 0x1300, 0x1380, 0x1480, 0x1500, 0x1600, 0x1700, 0x1780, + 0x1880, 0x1980, 0x1a80, 0x1b00, 0x1c00, 0x1d00, 0x1e00, 0x1f00 }; diff --git a/src/lib/openjp2/t2.h b/src/lib/openjp2/t2.h index 3b652eea..b80891b7 100644 --- a/src/lib/openjp2/t2.h +++ b/src/lib/openjp2/t2.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,10 +8,10 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team - * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR + * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR * Copyright (c) 2012, CS Systemes d'Information, France * All rights reserved. * @@ -52,10 +52,10 @@ Tier-2 coding */ typedef struct opj_t2 { - /** Encoding: pointer to the src image. Decoding: pointer to the dst image. */ - opj_image_t *image; - /** pointer to the image coding parameters */ - opj_cp_t *cp; + /** Encoding: pointer to the src image. Decoding: pointer to the dst image. */ + opj_image_t *image; + /** pointer to the image coding parameters */ + opj_cp_t *cp; } opj_t2_t; /** @name Exported functions */ @@ -77,18 +77,18 @@ Encode the packets of a tile to a destination buffer @param pino FIXME DOC @param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass */ -OPJ_BOOL opj_t2_encode_packets( opj_t2_t* t2, - OPJ_UINT32 tileno, - opj_tcd_tile_t *tile, - OPJ_UINT32 maxlayers, - OPJ_BYTE *dest, - OPJ_UINT32 * p_data_written, - OPJ_UINT32 len, - opj_codestream_info_t *cstr_info, - OPJ_UINT32 tpnum, - OPJ_INT32 tppos, - OPJ_UINT32 pino, - J2K_T2_MODE t2_mode); +OPJ_BOOL opj_t2_encode_packets(opj_t2_t* t2, + OPJ_UINT32 tileno, + opj_tcd_tile_t *tile, + OPJ_UINT32 maxlayers, + OPJ_BYTE *dest, + OPJ_UINT32 * p_data_written, + OPJ_UINT32 len, + opj_codestream_info_t *cstr_info, + OPJ_UINT32 tpnum, + OPJ_INT32 tppos, + OPJ_UINT32 pino, + J2K_T2_MODE t2_mode); /** Decode the packets of a tile from a source buffer @@ -102,21 +102,21 @@ Decode the packets of a tile from a source buffer @return FIXME DOC */ -OPJ_BOOL opj_t2_decode_packets( opj_t2_t *t2, - OPJ_UINT32 tileno, - opj_tcd_tile_t *tile, - OPJ_BYTE *src, - OPJ_UINT32 * p_data_read, - OPJ_UINT32 len, - opj_codestream_index_t *cstr_info, - opj_event_mgr_t *p_manager); +OPJ_BOOL opj_t2_decode_packets(opj_t2_t *t2, + OPJ_UINT32 tileno, + opj_tcd_tile_t *tile, + OPJ_BYTE *src, + OPJ_UINT32 * p_data_read, + OPJ_UINT32 len, + opj_codestream_index_t *cstr_info, + opj_event_mgr_t *p_manager); /** * Creates a Tier 2 handle * - * @param p_image Source or destination image - * @param p_cp Image coding parameters. - * @return a new T2 handle if successful, NULL otherwise. + * @param p_image Source or destination image + * @param p_cp Image coding parameters. + * @return a new T2 handle if successful, NULL otherwise. */ opj_t2_t* opj_t2_create(opj_image_t *p_image, opj_cp_t *p_cp); diff --git a/src/lib/openjp2/tcd.h b/src/lib/openjp2/tcd.h index 76eff005..913979a8 100644 --- a/src/lib/openjp2/tcd.h +++ b/src/lib/openjp2/tcd.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,10 +8,10 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team - * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR + * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR * Copyright (c) 2012, CS Systemes d'Information, France * All rights reserved. * @@ -53,120 +53,129 @@ each other. The functions in TCD.C are used by other functions in J2K.C. FIXME DOC */ typedef struct opj_tcd_seg { - OPJ_BYTE ** data; - OPJ_UINT32 dataindex; - OPJ_UINT32 numpasses; - OPJ_UINT32 real_num_passes; - OPJ_UINT32 len; - OPJ_UINT32 maxpasses; - OPJ_UINT32 numnewpasses; - OPJ_UINT32 newlen; + OPJ_BYTE ** data; + OPJ_UINT32 dataindex; + OPJ_UINT32 numpasses; + OPJ_UINT32 real_num_passes; + OPJ_UINT32 len; + OPJ_UINT32 maxpasses; + OPJ_UINT32 numnewpasses; + OPJ_UINT32 newlen; } opj_tcd_seg_t; /** FIXME DOC */ typedef struct opj_tcd_pass { - OPJ_UINT32 rate; - OPJ_FLOAT64 distortiondec; - OPJ_UINT32 len; - OPJ_BITFIELD term : 1; + OPJ_UINT32 rate; + OPJ_FLOAT64 distortiondec; + OPJ_UINT32 len; + OPJ_BITFIELD term : 1; } opj_tcd_pass_t; /** FIXME DOC */ typedef struct opj_tcd_layer { - OPJ_UINT32 numpasses; /* Number of passes in the layer */ - OPJ_UINT32 len; /* len of information */ - OPJ_FLOAT64 disto; /* add for index (Cfr. Marcela) */ - OPJ_BYTE *data; /* data */ + OPJ_UINT32 numpasses; /* Number of passes in the layer */ + OPJ_UINT32 len; /* len of information */ + OPJ_FLOAT64 disto; /* add for index (Cfr. Marcela) */ + OPJ_BYTE *data; /* data */ } opj_tcd_layer_t; /** FIXME DOC */ typedef struct opj_tcd_cblk_enc { - OPJ_BYTE* data; /* Data */ - opj_tcd_layer_t* layers; /* layer information */ - opj_tcd_pass_t* passes; /* information about the passes */ - OPJ_INT32 x0, y0, x1, y1; /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */ - OPJ_UINT32 numbps; - OPJ_UINT32 numlenbits; - OPJ_UINT32 data_size; /* Size of allocated data buffer */ - OPJ_UINT32 numpasses; /* number of pass already done for the code-blocks */ - OPJ_UINT32 numpassesinlayers; /* number of passes in the layer */ - OPJ_UINT32 totalpasses; /* total number of passes */ + OPJ_BYTE* data; /* Data */ + opj_tcd_layer_t* layers; /* layer information */ + opj_tcd_pass_t* passes; /* information about the passes */ + OPJ_INT32 x0, y0, x1, + y1; /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */ + OPJ_UINT32 numbps; + OPJ_UINT32 numlenbits; + OPJ_UINT32 data_size; /* Size of allocated data buffer */ + OPJ_UINT32 + numpasses; /* number of pass already done for the code-blocks */ + OPJ_UINT32 numpassesinlayers; /* number of passes in the layer */ + OPJ_UINT32 totalpasses; /* total number of passes */ } opj_tcd_cblk_enc_t; typedef struct opj_tcd_cblk_dec { - OPJ_BYTE * data; /* Data */ - opj_tcd_seg_t* segs; /* segments information */ - OPJ_INT32 x0, y0, x1, y1; /* position of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */ - OPJ_UINT32 numbps; - OPJ_UINT32 numlenbits; - OPJ_UINT32 data_max_size; /* Size of allocated data buffer */ - OPJ_UINT32 data_current_size; /* Size of used data buffer */ - OPJ_UINT32 numnewpasses; /* number of pass added to the code-blocks */ - OPJ_UINT32 numsegs; /* number of segments */ - OPJ_UINT32 real_num_segs; - OPJ_UINT32 m_current_max_segs; + OPJ_BYTE * data; /* Data */ + opj_tcd_seg_t* segs; /* segments information */ + OPJ_INT32 x0, y0, x1, + y1; /* position of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */ + OPJ_UINT32 numbps; + OPJ_UINT32 numlenbits; + OPJ_UINT32 data_max_size; /* Size of allocated data buffer */ + OPJ_UINT32 data_current_size; /* Size of used data buffer */ + OPJ_UINT32 numnewpasses; /* number of pass added to the code-blocks */ + OPJ_UINT32 numsegs; /* number of segments */ + OPJ_UINT32 real_num_segs; + OPJ_UINT32 m_current_max_segs; } opj_tcd_cblk_dec_t; /** FIXME DOC */ typedef struct opj_tcd_precinct { - OPJ_INT32 x0, y0, x1, y1; /* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */ - OPJ_UINT32 cw, ch; /* number of precinct in width and height */ - union{ /* code-blocks information */ - opj_tcd_cblk_enc_t* enc; - opj_tcd_cblk_dec_t* dec; - void* blocks; - } cblks; - OPJ_UINT32 block_size; /* size taken by cblks (in bytes) */ - opj_tgt_tree_t *incltree; /* inclusion tree */ - opj_tgt_tree_t *imsbtree; /* IMSB tree */ + OPJ_INT32 x0, y0, x1, + y1; /* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */ + OPJ_UINT32 cw, ch; /* number of precinct in width and height */ + union { /* code-blocks information */ + opj_tcd_cblk_enc_t* enc; + opj_tcd_cblk_dec_t* dec; + void* blocks; + } cblks; + OPJ_UINT32 block_size; /* size taken by cblks (in bytes) */ + opj_tgt_tree_t *incltree; /* inclusion tree */ + opj_tgt_tree_t *imsbtree; /* IMSB tree */ } opj_tcd_precinct_t; /** FIXME DOC */ typedef struct opj_tcd_band { - OPJ_INT32 x0, y0, x1, y1; /* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */ - OPJ_UINT32 bandno; - opj_tcd_precinct_t *precincts; /* precinct information */ - OPJ_UINT32 precincts_data_size; /* size of data taken by precincts */ - OPJ_INT32 numbps; - OPJ_FLOAT32 stepsize; + OPJ_INT32 x0, y0, x1, + y1; /* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */ + OPJ_UINT32 bandno; + opj_tcd_precinct_t *precincts; /* precinct information */ + OPJ_UINT32 precincts_data_size; /* size of data taken by precincts */ + OPJ_INT32 numbps; + OPJ_FLOAT32 stepsize; } opj_tcd_band_t; /** FIXME DOC */ typedef struct opj_tcd_resolution { - OPJ_INT32 x0, y0, x1, y1; /* dimension of the resolution level : left upper corner (x0, y0) right low corner (x1,y1) */ - OPJ_UINT32 pw, ph; - OPJ_UINT32 numbands; /* number sub-band for the resolution level */ - opj_tcd_band_t bands[3]; /* subband information */ + OPJ_INT32 x0, y0, x1, + y1; /* dimension of the resolution level : left upper corner (x0, y0) right low corner (x1,y1) */ + OPJ_UINT32 pw, ph; + OPJ_UINT32 numbands; /* number sub-band for the resolution level */ + opj_tcd_band_t bands[3]; /* subband information */ } opj_tcd_resolution_t; /** FIXME DOC */ -typedef struct opj_tcd_tilecomp -{ - OPJ_INT32 x0, y0, x1, y1; /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */ - OPJ_UINT32 numresolutions; /* number of resolutions level */ - OPJ_UINT32 minimum_num_resolutions; /* number of resolutions level to decode (at max)*/ - opj_tcd_resolution_t *resolutions; /* resolutions information */ - OPJ_UINT32 resolutions_size; /* size of data for resolutions (in bytes) */ - OPJ_INT32 *data; /* data of the component */ - OPJ_BOOL ownsData; /* if true, then need to free after usage, otherwise do not free */ - OPJ_UINT32 data_size_needed; /* we may either need to allocate this amount of data, or re-use image data and ignore this value */ - OPJ_UINT32 data_size; /* size of the data of the component */ - OPJ_INT32 numpix; /* add fixed_quality */ +typedef struct opj_tcd_tilecomp { + OPJ_INT32 x0, y0, x1, + y1; /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */ + OPJ_UINT32 numresolutions; /* number of resolutions level */ + OPJ_UINT32 + minimum_num_resolutions; /* number of resolutions level to decode (at max)*/ + opj_tcd_resolution_t *resolutions; /* resolutions information */ + OPJ_UINT32 + resolutions_size; /* size of data for resolutions (in bytes) */ + OPJ_INT32 *data; /* data of the component */ + OPJ_BOOL ownsData; /* if true, then need to free after usage, otherwise do not free */ + OPJ_UINT32 + data_size_needed; /* we may either need to allocate this amount of data, or re-use image data and ignore this value */ + OPJ_UINT32 data_size; /* size of the data of the component */ + OPJ_INT32 numpix; /* add fixed_quality */ } opj_tcd_tilecomp_t; @@ -174,21 +183,21 @@ typedef struct opj_tcd_tilecomp FIXME DOC */ typedef struct opj_tcd_tile { - OPJ_INT32 x0, y0, x1, y1; /* dimension of the tile : left upper corner (x0, y0) right low corner (x1,y1) */ - OPJ_UINT32 numcomps; /* number of components in tile */ - opj_tcd_tilecomp_t *comps; /* Components information */ - OPJ_INT32 numpix; /* add fixed_quality */ - OPJ_FLOAT64 distotile; /* add fixed_quality */ - OPJ_FLOAT64 distolayer[100]; /* add fixed_quality */ - OPJ_UINT32 packno; /* packet number */ + OPJ_INT32 x0, y0, x1, + y1; /* dimension of the tile : left upper corner (x0, y0) right low corner (x1,y1) */ + OPJ_UINT32 numcomps; /* number of components in tile */ + opj_tcd_tilecomp_t *comps; /* Components information */ + OPJ_INT32 numpix; /* add fixed_quality */ + OPJ_FLOAT64 distotile; /* add fixed_quality */ + OPJ_FLOAT64 distolayer[100]; /* add fixed_quality */ + OPJ_UINT32 packno; /* packet number */ } opj_tcd_tile_t; /** FIXME DOC */ -typedef struct opj_tcd_image -{ - opj_tcd_tile_t *tiles; /* Tiles information */ +typedef struct opj_tcd_image { + opj_tcd_tile_t *tiles; /* Tiles information */ } opj_tcd_image_t; @@ -196,29 +205,28 @@ opj_tcd_image_t; /** Tile coder/decoder */ -typedef struct opj_tcd -{ - /** Position of the tilepart flag in Progression order*/ - OPJ_INT32 tp_pos; - /** Tile part number*/ - OPJ_UINT32 tp_num; - /** Current tile part number*/ - OPJ_UINT32 cur_tp_num; - /** Total number of tileparts of the current tile*/ - OPJ_UINT32 cur_totnum_tp; - /** Current Packet iterator number */ - OPJ_UINT32 cur_pino; - /** info on each image tile */ - opj_tcd_image_t *tcd_image; - /** image header */ - opj_image_t *image; - /** coding parameters */ - opj_cp_t *cp; - /** coding/decoding parameters common to all tiles */ - opj_tcp_t *tcp; - /** current encoded/decoded tile */ - OPJ_UINT32 tcd_tileno; - /** tell if the tcd is a decoder. */ +typedef struct opj_tcd { + /** Position of the tilepart flag in Progression order*/ + OPJ_INT32 tp_pos; + /** Tile part number*/ + OPJ_UINT32 tp_num; + /** Current tile part number*/ + OPJ_UINT32 cur_tp_num; + /** Total number of tileparts of the current tile*/ + OPJ_UINT32 cur_totnum_tp; + /** Current Packet iterator number */ + OPJ_UINT32 cur_pino; + /** info on each image tile */ + opj_tcd_image_t *tcd_image; + /** image header */ + opj_image_t *image; + /** coding parameters */ + opj_cp_t *cp; + /** coding/decoding parameters common to all tiles */ + opj_tcp_t *tcp; + /** current encoded/decoded tile */ + OPJ_UINT32 tcd_tileno; + /** tell if the tcd is a decoder. */ OPJ_BITFIELD m_is_decoder : 1; /** Thread pool */ opj_thread_pool_t* thread_pool; @@ -231,7 +239,7 @@ typedef struct opj_tcd /** Dump the content of a tcd structure */ -/*void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t *img);*/ /* TODO MSD shoul use the new v2 structures */ +/*void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t *img);*/ /* TODO MSD shoul use the new v2 structures */ /** Create a new TCD handle @@ -248,66 +256,68 @@ void opj_tcd_destroy(opj_tcd_t *tcd); /** * Initialize the tile coder and may reuse some memory. - * @param p_tcd TCD handle. - * @param p_image raw image. - * @param p_cp coding parameters. + * @param p_tcd TCD handle. + * @param p_image raw image. + * @param p_cp coding parameters. * @param p_tp thread pool * * @return true if the encoding values could be set (false otherwise). */ -OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd, - opj_image_t * p_image, - opj_cp_t * p_cp, - opj_thread_pool_t* p_tp); +OPJ_BOOL opj_tcd_init(opj_tcd_t *p_tcd, + opj_image_t * p_image, + opj_cp_t * p_cp, + opj_thread_pool_t* p_tp); /** * Allocates memory for decoding a specific tile. * - * @param p_tcd the tile decoder. - * @param p_tile_no the index of the tile received in sequence. This not necessarily lead to the + * @param p_tcd the tile decoder. + * @param p_tile_no the index of the tile received in sequence. This not necessarily lead to the * tile at index p_tile_no. * @param p_manager the event manager. * - * @return true if the remaining data is sufficient. + * @return true if the remaining data is sufficient. */ -OPJ_BOOL opj_tcd_init_decode_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager); +OPJ_BOOL opj_tcd_init_decode_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, + opj_event_mgr_t* p_manager); -void opj_tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno, OPJ_UINT32 final); +void opj_tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno, + OPJ_UINT32 final); void opj_tcd_rateallocate_fixed(opj_tcd_t *tcd); -void opj_tcd_makelayer( opj_tcd_t *tcd, - OPJ_UINT32 layno, - OPJ_FLOAT64 thresh, - OPJ_UINT32 final); +void opj_tcd_makelayer(opj_tcd_t *tcd, + OPJ_UINT32 layno, + OPJ_FLOAT64 thresh, + OPJ_UINT32 final); -OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd, - OPJ_BYTE *dest, - OPJ_UINT32 * p_data_written, - OPJ_UINT32 len, - opj_codestream_info_t *cstr_info); +OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd, + OPJ_BYTE *dest, + OPJ_UINT32 * p_data_written, + OPJ_UINT32 len, + opj_codestream_info_t *cstr_info); /** * Gets the maximum tile size that will be taken by the tile once decoded. */ -OPJ_UINT32 opj_tcd_get_decoded_tile_size (opj_tcd_t *p_tcd ); +OPJ_UINT32 opj_tcd_get_decoded_tile_size(opj_tcd_t *p_tcd); /** * Encodes a tile from the raw image into the given buffer. - * @param p_tcd Tile Coder handle - * @param p_tile_no Index of the tile to encode. - * @param p_dest Destination buffer - * @param p_data_written pointer to an int that is incremented by the number of bytes really written on p_dest - * @param p_len Maximum length of the destination buffer - * @param p_cstr_info Codestream information structure + * @param p_tcd Tile Coder handle + * @param p_tile_no Index of the tile to encode. + * @param p_dest Destination buffer + * @param p_data_written pointer to an int that is incremented by the number of bytes really written on p_dest + * @param p_len Maximum length of the destination buffer + * @param p_cstr_info Codestream information structure * @return true if the coding is successful. */ -OPJ_BOOL opj_tcd_encode_tile( opj_tcd_t *p_tcd, - OPJ_UINT32 p_tile_no, - OPJ_BYTE *p_dest, - OPJ_UINT32 * p_data_written, - OPJ_UINT32 p_len, - struct opj_codestream_info *p_cstr_info); +OPJ_BOOL opj_tcd_encode_tile(opj_tcd_t *p_tcd, + OPJ_UINT32 p_tile_no, + OPJ_BYTE *p_dest, + OPJ_UINT32 * p_data_written, + OPJ_UINT32 p_len, + struct opj_codestream_info *p_cstr_info); /** @@ -319,44 +329,44 @@ Decode a tile from a buffer into a raw image @param cstr_info FIXME DOC @param manager the event manager. */ -OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *tcd, - OPJ_BYTE *src, - OPJ_UINT32 len, - OPJ_UINT32 tileno, - opj_codestream_index_t *cstr_info, - opj_event_mgr_t *manager); +OPJ_BOOL opj_tcd_decode_tile(opj_tcd_t *tcd, + OPJ_BYTE *src, + OPJ_UINT32 len, + OPJ_UINT32 tileno, + opj_codestream_index_t *cstr_info, + opj_event_mgr_t *manager); /** * Copies tile data from the system onto the given memory block. */ -OPJ_BOOL opj_tcd_update_tile_data ( opj_tcd_t *p_tcd, - OPJ_BYTE * p_dest, - OPJ_UINT32 p_dest_length ); +OPJ_BOOL opj_tcd_update_tile_data(opj_tcd_t *p_tcd, + OPJ_BYTE * p_dest, + OPJ_UINT32 p_dest_length); /** * */ -OPJ_UINT32 opj_tcd_get_encoded_tile_size ( opj_tcd_t *p_tcd ); +OPJ_UINT32 opj_tcd_get_encoded_tile_size(opj_tcd_t *p_tcd); /** * Initialize the tile coder and may reuse some meory. * - * @param p_tcd TCD handle. - * @param p_tile_no current tile index to encode. + * @param p_tcd TCD handle. + * @param p_tile_no current tile index to encode. * @param p_manager the event manager. * * @return true if the encoding values could be set (false otherwise). */ -OPJ_BOOL opj_tcd_init_encode_tile ( opj_tcd_t *p_tcd, - OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager ); +OPJ_BOOL opj_tcd_init_encode_tile(opj_tcd_t *p_tcd, + OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager); /** * Copies tile data from the given memory block onto the system. */ -OPJ_BOOL opj_tcd_copy_tile_data (opj_tcd_t *p_tcd, - OPJ_BYTE * p_src, - OPJ_UINT32 p_src_length ); +OPJ_BOOL opj_tcd_copy_tile_data(opj_tcd_t *p_tcd, + OPJ_BYTE * p_src, + OPJ_UINT32 p_src_length); /** * Allocates tile component data diff --git a/src/lib/openjp2/tgt.h b/src/lib/openjp2/tgt.h index 10223805..0ed0e658 100644 --- a/src/lib/openjp2/tgt.h +++ b/src/lib/openjp2/tgt.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -8,11 +8,11 @@ * 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-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr> - * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France + * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France * Copyright (c) 2012, CS Systemes d'Information, France * All rights reserved. * @@ -64,13 +64,12 @@ typedef struct opj_tgt_node { /** Tag tree */ -typedef struct opj_tgt_tree -{ - OPJ_UINT32 numleafsh; - OPJ_UINT32 numleafsv; - OPJ_UINT32 numnodes; - opj_tgt_node_t *nodes; - OPJ_UINT32 nodes_size; /* maximum size taken by nodes */ +typedef struct opj_tgt_tree { + OPJ_UINT32 numleafsh; + OPJ_UINT32 numleafsv; + OPJ_UINT32 numnodes; + opj_tgt_node_t *nodes; + OPJ_UINT32 nodes_size; /* maximum size taken by nodes */ } opj_tgt_tree_t; @@ -83,19 +82,20 @@ Create a tag-tree @param numleafsv Height of the array of leafs of the tree @return Returns a new tag-tree if successful, returns NULL otherwise */ -opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv, opj_event_mgr_t *manager); +opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv, + opj_event_mgr_t *manager); /** * Reinitialises a tag-tree from an exixting one. * - * @param p_tree the tree to reinitialize. - * @param p_num_leafs_h the width of the array of leafs of the tree - * @param p_num_leafs_v the height of the array of leafs of the tree + * @param p_tree the tree to reinitialize. + * @param p_num_leafs_h the width of the array of leafs of the tree + * @param p_num_leafs_v the height of the array of leafs of the tree * @param p_manager the event manager - * @return a new tag-tree if successful, NULL otherwise + * @return a new tag-tree if successful, NULL otherwise */ -opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree, - OPJ_UINT32 p_num_leafs_h, +opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree, + OPJ_UINT32 p_num_leafs_h, OPJ_UINT32 p_num_leafs_v, opj_event_mgr_t *p_manager); /** Destroy a tag-tree, liberating memory @@ -113,8 +113,8 @@ Set the value of a leaf of a tag-tree @param leafno Number that identifies the leaf to modify @param value New value of the leaf */ -void opj_tgt_setvalue(opj_tgt_tree_t *tree, - OPJ_UINT32 leafno, +void opj_tgt_setvalue(opj_tgt_tree_t *tree, + OPJ_UINT32 leafno, OPJ_INT32 value); /** Encode the value of a leaf of the tag-tree up to a given threshold @@ -123,9 +123,9 @@ Encode the value of a leaf of the tag-tree up to a given threshold @param leafno Number that identifies the leaf to encode @param threshold Threshold to use when encoding value of the leaf */ -void opj_tgt_encode(opj_bio_t *bio, - opj_tgt_tree_t *tree, - OPJ_UINT32 leafno, +void opj_tgt_encode(opj_bio_t *bio, + opj_tgt_tree_t *tree, + OPJ_UINT32 leafno, OPJ_INT32 threshold); /** Decode the value of a leaf of the tag-tree up to a given threshold @@ -135,9 +135,9 @@ Decode the value of a leaf of the tag-tree up to a given threshold @param threshold Threshold to use when decoding value of the leaf @return Returns 1 if the node's value < threshold, returns 0 otherwise */ -OPJ_UINT32 opj_tgt_decode(opj_bio_t *bio, - opj_tgt_tree_t *tree, - OPJ_UINT32 leafno, +OPJ_UINT32 opj_tgt_decode(opj_bio_t *bio, + opj_tgt_tree_t *tree, + OPJ_UINT32 leafno, OPJ_INT32 threshold); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/src/lib/openjp2/thread.h b/src/lib/openjp2/thread.h index 241e6d88..c89e19b4 100644 --- a/src/lib/openjp2/thread.h +++ b/src/lib/openjp2/thread.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * @@ -151,13 +151,13 @@ typedef void (*opj_thread_fn)(void* user_data); * @return a thread handle or NULL in case of failure (can for example happen if the library * is built without thread support) */ -opj_thread_t* opj_thread_create( opj_thread_fn thread_fn, void* user_data ); +opj_thread_t* opj_thread_create(opj_thread_fn thread_fn, void* user_data); /** Wait for a thread to be finished and release associated resources to the * thread handle. * @param thread the thread to wait for being finished. */ -void opj_thread_join( opj_thread_t* thread ); +void opj_thread_join(opj_thread_t* thread); /*@}*/ @@ -180,10 +180,11 @@ typedef void (*opj_tls_free_func)(void* value); * @param tls thread local storage handle * @param key key whose value to set. * @param value value to set (may be NULL). - * @param free_func function to call currently installed value. + * @param free_func function to call currently installed value. * @return OPJ_TRUE if successful. */ -OPJ_BOOL opj_tls_set(opj_tls_t* tls, int key, void* value, opj_tls_free_func free_func); +OPJ_BOOL opj_tls_set(opj_tls_t* tls, int key, void* value, + opj_tls_free_func free_func); /*@}*/ @@ -221,7 +222,8 @@ typedef void (*opj_job_fn)(void* user_data, opj_tls_t* tls); * @param user_data User data provided to thread_fn. * @return OPJ_TRUE if the job was successfully submitted. */ -OPJ_BOOL opj_thread_pool_submit_job(opj_thread_pool_t* tp, opj_job_fn job_fn, void* user_data); +OPJ_BOOL opj_thread_pool_submit_job(opj_thread_pool_t* tp, opj_job_fn job_fn, + void* user_data); /** Wait that no more than max_remaining_jobs jobs are remaining in the queue of * the thread pool. The aim of this function is to avoid submitting too many @@ -232,7 +234,8 @@ OPJ_BOOL opj_thread_pool_submit_job(opj_thread_pool_t* tp, opj_job_fn job_fn, vo * @param tp the thread pool handle * @param max_remaining_jobs maximum number of jobs allowed to be queued without waiting. */ -void opj_thread_pool_wait_completion(opj_thread_pool_t* tp, int max_remaining_jobs); +void opj_thread_pool_wait_completion(opj_thread_pool_t* tp, + int max_remaining_jobs); /** Return the number of threads associated with the thread pool. * diff --git a/src/lib/openjp2/tls_keys.h b/src/lib/openjp2/tls_keys.h index fb26498d..ba0373a7 100644 --- a/src/lib/openjp2/tls_keys.h +++ b/src/lib/openjp2/tls_keys.h @@ -1,6 +1,6 @@ /* - * 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 + * 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. * |
