OpenJPEG  2.2.0
Macros | Functions | Variables
jp2.c File Reference
#include "opj_includes.h"

Macros

#define OPJ_BOX_SIZE   1024
 
#define OPJ_UNUSED(x)   (void)x
 

Functions

static OPJ_BOOL opj_jp2_setup_end_header_writing (opj_jp2_t *jp2, opj_event_mgr_t *p_manager)
 Sets up the procedures to do on writing header after the codestream. More...
 
static OPJ_BOOL opj_jp2_setup_end_header_reading (opj_jp2_t *jp2, opj_event_mgr_t *p_manager)
 Sets up the procedures to do on reading header after the codestream. More...
 
static OPJ_BOOL opj_jp2_read_header_procedure (opj_jp2_t *jp2, opj_stream_private_t *stream, opj_event_mgr_t *p_manager)
 Reads a jpeg2000 file header structure. More...
 
static OPJ_BOOL opj_jp2_exec (opj_jp2_t *jp2, opj_procedure_list_t *p_procedure_list, opj_stream_private_t *stream, opj_event_mgr_t *p_manager)
 Executes the given procedures on the given codec. More...
 
static OPJ_BOOL opj_jp2_read_boxhdr (opj_jp2_box_t *box, OPJ_UINT32 *p_number_bytes_read, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
 Reads a box header. More...
 
static OPJ_BOOL opj_jp2_setup_encoding_validation (opj_jp2_t *jp2, opj_event_mgr_t *p_manager)
 Sets up the validation ,i.e. More...
 
static OPJ_BOOL opj_jp2_setup_header_writing (opj_jp2_t *jp2, opj_event_mgr_t *p_manager)
 Sets up the procedures to do on writing header. More...
 
static OPJ_BOOL opj_jp2_default_validation (opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
 
static const opj_jp2_header_handler_topj_jp2_img_find_handler (OPJ_UINT32 p_id)
 Finds the image execution function related to the given box id. More...
 
static const opj_jp2_header_handler_topj_jp2_find_handler (OPJ_UINT32 p_id)
 Finds the execution function related to the given box id. More...
 
static OPJ_BOOL opj_jp2_read_boxhdr_char (opj_jp2_box_t *box, OPJ_BYTE *p_data, OPJ_UINT32 *p_number_bytes_read, OPJ_UINT32 p_box_max_size, opj_event_mgr_t *p_manager)
 Reads a box header. More...
 
static OPJ_BOOL opj_jp2_setup_decoding_validation (opj_jp2_t *jp2, opj_event_mgr_t *p_manager)
 Sets up the validation ,i.e. More...
 
static OPJ_BOOL opj_jp2_setup_header_reading (opj_jp2_t *jp2, opj_event_mgr_t *p_manager)
 Sets up the procedures to do on reading header. More...
 
static OPJ_BOOL opj_jp2_check_color (opj_image_t *image, opj_jp2_color_t *color, opj_event_mgr_t *p_manager)
 
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)
 Decode an image from a JPEG-2000 file stream. More...
 
void opj_jp2_setup_decoder (opj_jp2_t *jp2, opj_dparameters_t *parameters)
 Setup the decoder decoding parameters using user parameters. More...
 
OPJ_BOOL opj_jp2_set_threads (opj_jp2_t *jp2, OPJ_UINT32 num_threads)
 
OPJ_BOOL opj_jp2_setup_encoder (opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_t *image, opj_event_mgr_t *p_manager)
 Setup the encoder parameters using the current image and using user parameters. More...
 
OPJ_BOOL opj_jp2_encode (opj_jp2_t *jp2, opj_stream_private_t *stream, opj_event_mgr_t *p_manager)
 Encode an image into a JPEG-2000 file stream. More...
 
OPJ_BOOL opj_jp2_end_decompress (opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
 Ends the decompression procedures and possibiliy add data to be read after the codestream. More...
 
OPJ_BOOL opj_jp2_end_compress (opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
 Ends the compression procedures and possibiliy add data to be read after the codestream. More...
 
OPJ_BOOL opj_jp2_start_compress (opj_jp2_t *jp2, opj_stream_private_t *stream, opj_image_t *p_image, opj_event_mgr_t *p_manager)
 Starts a compression scheme, i.e. More...
 
static OPJ_BOOL opj_jpip_skip_iptr (opj_jp2_t *jp2, opj_stream_private_t *stream, 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 jpeg2000 file header structure. More...
 
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)
 Reads a tile header. More...
 
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)
 Writes a tile. More...
 
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)
 Decode tile data. More...
 
void opj_jp2_destroy (opj_jp2_t *jp2)
 Destroy a JP2 decompressor handle. More...
 
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)
 Sets the given area to be decoded. More...
 
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_jp2_topj_jp2_create (OPJ_BOOL p_is_decoder)
 Creates a jpeg2000 file decompressor. More...
 
void jp2_dump (opj_jp2_t *p_jp2, OPJ_INT32 flag, FILE *out_stream)
 Dump some elements from the JP2 decompression structure . More...
 
opj_codestream_index_tjp2_get_cstr_index (opj_jp2_t *p_jp2)
 Get the codestream index from a JPEG2000 codec. More...
 
opj_codestream_info_v2_tjp2_get_cstr_info (opj_jp2_t *p_jp2)
 Get the codestream info from a JPEG2000 codec. More...
 
OPJ_BOOL opj_jp2_set_decoded_resolution_factor (opj_jp2_t *p_jp2, OPJ_UINT32 res_factor, opj_event_mgr_t *p_manager)
 
Local static functions
static OPJ_BOOL opj_jp2_read_ihdr (opj_jp2_t *jp2, OPJ_BYTE *p_image_header_data, OPJ_UINT32 p_image_header_size, opj_event_mgr_t *p_manager)
 Reads a IHDR box - Image Header box. More...
 
static OPJ_BYTEopj_jp2_write_ihdr (opj_jp2_t *jp2, OPJ_UINT32 *p_nb_bytes_written)
 Writes the Image Header box - Image Header box. More...
 
static OPJ_BYTEopj_jp2_write_bpcc (opj_jp2_t *jp2, OPJ_UINT32 *p_nb_bytes_written)
 Writes the Bit per Component box. More...
 
static OPJ_BOOL opj_jp2_read_bpcc (opj_jp2_t *jp2, OPJ_BYTE *p_bpc_header_data, OPJ_UINT32 p_bpc_header_size, opj_event_mgr_t *p_manager)
 Reads a Bit per Component box. More...
 
static OPJ_BOOL opj_jp2_read_cdef (opj_jp2_t *jp2, OPJ_BYTE *p_cdef_header_data, OPJ_UINT32 p_cdef_header_size, opj_event_mgr_t *p_manager)
 
static void opj_jp2_apply_cdef (opj_image_t *image, opj_jp2_color_t *color, opj_event_mgr_t *)
 
static OPJ_BYTEopj_jp2_write_cdef (opj_jp2_t *jp2, OPJ_UINT32 *p_nb_bytes_written)
 Writes the Channel Definition box. More...
 
static OPJ_BYTEopj_jp2_write_colr (opj_jp2_t *jp2, OPJ_UINT32 *p_nb_bytes_written)
 Writes the Colour Specification box. More...
 
static OPJ_BOOL opj_jp2_write_ftyp (opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
 Writes a FTYP box - File type box. More...
 
static OPJ_BOOL opj_jp2_read_ftyp (opj_jp2_t *jp2, OPJ_BYTE *p_header_data, OPJ_UINT32 p_header_size, opj_event_mgr_t *p_manager)
 Reads a a FTYP box - File type box. More...
 
static OPJ_BOOL opj_jp2_skip_jp2c (opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
 
static OPJ_BOOL opj_jp2_read_jp2h (opj_jp2_t *jp2, OPJ_BYTE *p_header_data, OPJ_UINT32 p_header_size, opj_event_mgr_t *p_manager)
 Reads the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box). More...
 
static OPJ_BOOL opj_jp2_write_jp2h (opj_jp2_t *jp2, opj_stream_private_t *stream, opj_event_mgr_t *p_manager)
 Writes the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box). More...
 
static OPJ_BOOL opj_jp2_write_jp2c (opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
 Writes the Jpeg2000 codestream Header box - JP2C Header box. More...
 
static OPJ_BOOL opj_jp2_read_jp (opj_jp2_t *jp2, OPJ_BYTE *p_header_data, OPJ_UINT32 p_header_size, opj_event_mgr_t *p_manager)
 Reads a jpeg2000 file signature box. More...
 
static OPJ_BOOL opj_jp2_write_jp (opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
 Writes a jpeg2000 file signature box. More...
 
static OPJ_BOOL opj_jp2_apply_pclr (opj_image_t *image, opj_jp2_color_t *color, opj_event_mgr_t *p_manager)
 Apply collected palette data. More...
 
static void opj_jp2_free_pclr (opj_jp2_color_t *color)
 
static OPJ_BOOL opj_jp2_read_pclr (opj_jp2_t *jp2, OPJ_BYTE *p_pclr_header_data, OPJ_UINT32 p_pclr_header_size, opj_event_mgr_t *p_manager)
 Collect palette data. More...
 
static OPJ_BOOL opj_jp2_read_cmap (opj_jp2_t *jp2, OPJ_BYTE *p_cmap_header_data, OPJ_UINT32 p_cmap_header_size, opj_event_mgr_t *p_manager)
 Collect component mapping data. More...
 
static OPJ_BOOL opj_jp2_read_colr (opj_jp2_t *jp2, OPJ_BYTE *p_colr_header_data, OPJ_UINT32 p_colr_header_size, opj_event_mgr_t *p_manager)
 Reads the Color Specification box. More...
 

Variables

static const opj_jp2_header_handler_t jp2_header []
 
static const opj_jp2_header_handler_t jp2_img_header []
 

Function Documentation

static OPJ_BOOL opj_jp2_check_color ( opj_image_t image,
opj_jp2_color_t color,
opj_event_mgr_t p_manager 
)
static
static OPJ_BOOL opj_jp2_default_validation ( opj_jp2_t jp2,
opj_stream_private_t cio,
opj_event_mgr_t p_manager 
)
static
static OPJ_BOOL opj_jp2_exec ( opj_jp2_t jp2,
opj_procedure_list_t p_procedure_list,
opj_stream_private_t stream,
opj_event_mgr_t p_manager 
)
static

Executes the given procedures on the given codec.

Parameters
p_procedure_listthe list of procedures to execute
jp2the jpeg2000 file codec to execute the procedures on.
streamthe stream to execute the procedures on.
p_managerthe user manager.
Returns
true if all the procedures were successfully executed.

References opj_procedure_list_clear(), opj_procedure_list_get_first_procedure(), opj_procedure_list_get_nb_procedures(), and OPJ_TRUE.

Referenced by opj_jp2_end_compress(), opj_jp2_end_decompress(), opj_jp2_read_header(), and opj_jp2_start_compress().

static const opj_jp2_header_handler_t * opj_jp2_find_handler ( OPJ_UINT32  p_id)
static

Finds the execution function related to the given box id.

Parameters
p_idthe id of the handler to fetch.
Returns
the given handler or NULL if it could not be found.

References jp2_header.

Referenced by opj_jp2_read_header_procedure().

static const opj_jp2_header_handler_t * opj_jp2_img_find_handler ( OPJ_UINT32  p_id)
static

Finds the image execution function related to the given box id.

Parameters
p_idthe id of the handler to fetch.
Returns
the given handler or NULL if it could not be found.
Parameters
p_idthe id of the handler to fetch.
Returns
the given handler or 00 if it could not be found.

References jp2_img_header.

Referenced by opj_jp2_read_header_procedure(), and opj_jp2_read_jp2h().

static OPJ_BOOL opj_jp2_read_boxhdr ( opj_jp2_box_t box,
OPJ_UINT32 p_number_bytes_read,
opj_stream_private_t cio,
opj_event_mgr_t p_manager 
)
static

Reads a box header.

The box is the way data is packed inside a jpeg2000 file structure.

Parameters
ciothe input stream to read data from.
boxthe box structure to fill.
p_number_bytes_readpointer to an int that will store the number of bytes read from the stream (shoul usually be 2).
p_manageruser event manager.
Returns
true if the box is recognized, false otherwise

References EVT_ERROR, opj_jp2_box::length, opj_event_msg(), OPJ_FALSE, opj_read_bytes, opj_stream_get_number_byte_left(), opj_stream_read_data(), OPJ_TRUE, and opj_jp2_box::type.

Referenced by opj_jp2_read_header_procedure().

static OPJ_BOOL opj_jp2_read_boxhdr_char ( opj_jp2_box_t box,
OPJ_BYTE p_data,
OPJ_UINT32 p_number_bytes_read,
OPJ_UINT32  p_box_max_size,
opj_event_mgr_t p_manager 
)
static

Reads a box header.

The box is the way data is packed inside a jpeg2000 file structure. Data is read from a character string

Parameters
boxthe box structure to fill.
p_datathe character string to read data from.
p_number_bytes_readpointer to an int that will store the number of bytes read from the stream (shoul usually be 2).
p_box_max_sizethe maximum number of bytes in the box.
p_managerFIXME DOC
Returns
true if the box is recognized, false otherwise

References EVT_ERROR, opj_jp2_box::length, opj_event_msg(), OPJ_FALSE, opj_read_bytes, OPJ_TRUE, and opj_jp2_box::type.

Referenced by opj_jp2_read_jp2h().

static OPJ_BOOL opj_jp2_read_header_procedure ( opj_jp2_t jp2,
opj_stream_private_t stream,
opj_event_mgr_t p_manager 
)
static
static OPJ_BOOL opj_jp2_setup_decoding_validation ( opj_jp2_t jp2,
opj_event_mgr_t p_manager 
)
static

Sets up the validation ,i.e.

adds the procedures to launch to make sure the codec parameters are valid. Developpers wanting to extend the library can add their own validation procedures.

References OPJ_TRUE, and OPJ_UNUSED.

Referenced by opj_jp2_read_header().

static OPJ_BOOL opj_jp2_setup_encoding_validation ( opj_jp2_t jp2,
opj_event_mgr_t p_manager 
)
static

Sets up the validation ,i.e.

adds the procedures to launch to make sure the codec parameters are valid. Developpers wanting to extend the library can add their own validation procedures.

References opj_jp2::m_validation_list, OPJ_FALSE, opj_jp2_default_validation(), opj_procedure_list_add_procedure(), and OPJ_TRUE.

Referenced by opj_jp2_start_compress().

static OPJ_BOOL opj_jp2_setup_end_header_reading ( opj_jp2_t jp2,
opj_event_mgr_t p_manager 
)
static

Sets up the procedures to do on reading header after the codestream.

Developpers wanting to extend the library can add their own writing procedures.

References opj_jp2::m_procedure_list, OPJ_FALSE, opj_jp2_read_header_procedure(), opj_procedure_list_add_procedure(), and OPJ_TRUE.

Referenced by opj_jp2_end_decompress().

static OPJ_BOOL opj_jp2_setup_end_header_writing ( opj_jp2_t jp2,
opj_event_mgr_t p_manager 
)
static

Sets up the procedures to do on writing header after the codestream.

Developpers wanting to extend the library can add their own writing procedures.

References opj_jp2::jpip_on, opj_jp2::m_procedure_list, OPJ_FALSE, opj_jp2_write_jp2c(), opj_procedure_list_add_procedure(), and OPJ_TRUE.

Referenced by opj_jp2_end_compress().

static OPJ_BOOL opj_jp2_setup_header_reading ( opj_jp2_t jp2,
opj_event_mgr_t p_manager 
)
static

Sets up the procedures to do on reading header.

Developpers wanting to extend the library can add their own writing procedures.

References opj_jp2::m_procedure_list, OPJ_FALSE, opj_jp2_read_header_procedure(), opj_procedure_list_add_procedure(), and OPJ_TRUE.

Referenced by opj_jp2_read_header().

static OPJ_BOOL opj_jp2_setup_header_writing ( opj_jp2_t jp2,
opj_event_mgr_t p_manager 
)
static

Sets up the procedures to do on writing header.

Developpers wanting to extend the library can add their own writing procedures.

References opj_jp2::jpip_on, opj_jp2::m_procedure_list, OPJ_FALSE, opj_jp2_skip_jp2c(), opj_jp2_write_ftyp(), opj_jp2_write_jp(), opj_jp2_write_jp2h(), opj_jpip_skip_iptr(), opj_procedure_list_add_procedure(), and OPJ_TRUE.

Referenced by opj_jp2_start_compress().

static OPJ_BOOL opj_jpip_skip_iptr ( opj_jp2_t jp2,
opj_stream_private_t stream,
opj_event_mgr_t p_manager 
)
static

Variable Documentation

const opj_jp2_header_handler_t jp2_header[]
static
Initial value:
= {
}
static OPJ_BOOL opj_jp2_read_ftyp(opj_jp2_t *jp2, OPJ_BYTE *p_header_data, OPJ_UINT32 p_header_size, opj_event_mgr_t *p_manager)
Reads a a FTYP box - File type box.
Definition: jp2.c:2570
#define JP2_JP
JPEG 2000 signature box.
Definition: jp2.h:49
#define JP2_JP2H
JP2 header box (super-box)
Definition: jp2.h:51
#define JP2_FTYP
File type box.
Definition: jp2.h:50
static OPJ_BOOL opj_jp2_read_jp(opj_jp2_t *jp2, OPJ_BYTE *p_header_data, OPJ_UINT32 p_header_size, opj_event_mgr_t *p_manager)
Reads a jpeg2000 file signature box.
Definition: jp2.c:2521
static OPJ_BOOL opj_jp2_read_jp2h(opj_jp2_t *jp2, OPJ_BYTE *p_header_data, OPJ_UINT32 p_header_size, opj_event_mgr_t *p_manager)
Reads the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
Definition: jp2.c:2675

Referenced by opj_jp2_find_handler().

const opj_jp2_header_handler_t jp2_img_header[]
static
Initial value:
= {
}
static OPJ_BOOL opj_jp2_read_colr(opj_jp2_t *jp2, OPJ_BYTE *p_colr_header_data, OPJ_UINT32 p_colr_header_size, opj_event_mgr_t *p_manager)
Reads the Color Specification box.
Definition: jp2.c:1452
static OPJ_BOOL opj_jp2_read_bpcc(opj_jp2_t *jp2, OPJ_BYTE *p_bpc_header_data, OPJ_UINT32 p_bpc_header_size, opj_event_mgr_t *p_manager)
Reads a Bit per Component box.
Definition: jp2.c:721
#define JP2_IHDR
Image header box.
Definition: jp2.h:52
static OPJ_BOOL opj_jp2_read_pclr(opj_jp2_t *jp2, OPJ_BYTE *p_pclr_header_data, OPJ_UINT32 p_pclr_header_size, opj_event_mgr_t *p_manager)
Collect palette data.
Definition: jp2.c:1140
#define JP2_CDEF
Channel Definition box.
Definition: jp2.h:58
#define JP2_BPCC
Bits per component box.
Definition: jp2.h:60
static OPJ_BOOL opj_jp2_read_cmap(opj_jp2_t *jp2, OPJ_BYTE *p_cmap_header_data, OPJ_UINT32 p_cmap_header_size, opj_event_mgr_t *p_manager)
Collect component mapping data.
Definition: jp2.c:1254
static OPJ_BOOL opj_jp2_read_ihdr(opj_jp2_t *jp2, OPJ_BYTE *p_image_header_data, OPJ_UINT32 p_image_header_size, opj_event_mgr_t *p_manager)
Reads a IHDR box - Image Header box.
Definition: jp2.c:561
#define JP2_CMAP
Component Mapping box.
Definition: jp2.h:57
#define JP2_PCLR
Palette box.
Definition: jp2.h:56
static OPJ_BOOL opj_jp2_read_cdef(opj_jp2_t *jp2, OPJ_BYTE *p_cdef_header_data, OPJ_UINT32 p_cdef_header_size, opj_event_mgr_t *p_manager)
Definition: jp2.c:1380
#define JP2_COLR
Colour specification box.
Definition: jp2.h:53

Referenced by opj_jp2_img_find_handler().