Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/LibOpenJPEG/openjpeg.h view on Meta::CPAN
/*@{*/
/** 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 */
/** Digital Cinema compliance 0-not compliant, 1-compliant*/
OPJ_CINEMA_MODE cp_cinema;
/** Maximum rate for each component. If == 0, component size limitation is not considered */
int max_comp_size;
/** 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
encoding without offset concerning all the components. */
void * mct_data;
} opj_cparameters_t;
#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;
} opj_dparameters_t;
/**
* JPEG2000 codec V2.
* */
typedef void * opj_codec_t;
/*
==========================================================
I/O stream typedef definitions
==========================================================
*/
/**
* Stream open flags.
* */
/** The stream was opened for reading. */
#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) ;
/*
* 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) ;
/*
* Callback function prototype for skip function
*/
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) ;
/*
* Callback function prototype for free user data function
*/
typedef void (* opj_stream_free_user_data_fn) (void * p_user_data) ;
/*
* JPEG2000 Stream.
*/
typedef void * opj_stream_t;
/*
==========================================================
image typedef definitions
==========================================================
*/
/**
* 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;
} 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;
} opj_image_t;
/**
* 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;
} opj_image_cmptparm_t;
/*
==========================================================
src/Source/LibOpenJPEG/openjpeg.h view on Meta::CPAN
codec functions definitions
==========================================================
*/
/**
* Creates a J2K/JP2 decompression structure
* @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);
/**
* Destroy a decompressor handle
*
* @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.
*/
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);
/**
* 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
*
* @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 );
/**
* 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.
*
* @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);
/**
* 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).
*
* @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 );
/**
* 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
* */
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
*
* @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);
/**
* Set the resolution factor of the decoded image
* @param p_codec the jpeg2000 codec.
* @param res_factor resolution factor to set
*
* @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);
/**
* 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
* 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.
*
* @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 );
/**
* Reads a tile header. This function is compulsory and allows one to know the size of the tile thta 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.
*/
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.
*
* @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 );
/* 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
*/
OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
/**
Set encoding parameters to default values, that means :
<ul>
<li>Lossless
<li>1 tile
<li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
<li>Size of code-block : 64 x 64
<li>Number of resolutions: 6
<li>No SOP marker in the codestream
<li>No EPH marker in the codestream
<li>No sub-sampling in x or y direction
<li>No mode switch activated
<li>Progression order: LRCP
<li>No index file
<li>No ROI upshifted
<li>No offset of the origin of the image
<li>No offset of the origin of the tiles
<li>Reversible DWT 5-3
</ul>
@param parameters Compression 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
*/
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
*/
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_start_compress ( opj_codec_t *p_codec,
opj_image_t * p_image,
opj_stream_t *p_stream);
/**
( run in 0.647 second using v1.01-cache-2.11-cpan-8450f2e95f3 )