Merge pull request #558 from mayeut/remove-printf
Remove printf/fprintf to stdout/stderr throughout openjp2 lib
This commit is contained in:
commit
7c688c3453
@ -95,6 +95,12 @@ OPJ_BOOL opj_event_msg(opj_event_mgr_t* event_mgr, OPJ_INT32 event_type, const c
|
||||
*/
|
||||
void opj_set_default_event_handler(opj_event_mgr_t * p_manager);
|
||||
|
||||
/*
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC poison printf fprintf
|
||||
#endif
|
||||
*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
/*@}*/
|
||||
|
@ -69,8 +69,11 @@ void opj_procedure_list_destroy(opj_procedure_list_t * p_list)
|
||||
opj_free(p_list);
|
||||
}
|
||||
|
||||
OPJ_BOOL opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_list, opj_procedure p_procedure)
|
||||
OPJ_BOOL opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_list, opj_procedure p_procedure, opj_event_mgr_t* p_manager )
|
||||
{
|
||||
|
||||
assert(p_manager != NULL);
|
||||
|
||||
if (p_validation_list->m_nb_max_procedures == p_validation_list->m_nb_procedures)
|
||||
{
|
||||
opj_procedure * new_procedures;
|
||||
@ -84,9 +87,7 @@ OPJ_BOOL opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_l
|
||||
opj_free(p_validation_list->m_procedures);
|
||||
p_validation_list->m_nb_max_procedures = 0;
|
||||
p_validation_list->m_nb_procedures = 0;
|
||||
/* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add a new validation procedure\n"); */
|
||||
fprintf(stderr, "Not enough memory to add a new validation procedure\n");
|
||||
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add a new validation procedure\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
else
|
||||
|
@ -95,7 +95,7 @@ void opj_procedure_list_destroy(opj_procedure_list_t * p_list);
|
||||
*
|
||||
* @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_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.
|
||||
|
@ -47,7 +47,8 @@ opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptpa
|
||||
/* allocate memory for the per-component information */
|
||||
image->comps = (opj_image_comp_t*)opj_calloc(1,image->numcomps * sizeof(opj_image_comp_t));
|
||||
if(!image->comps) {
|
||||
fprintf(stderr,"Unable to allocate memory for image.\n");
|
||||
/* TODO replace with event manager, breaks API */
|
||||
/* fprintf(stderr,"Unable to allocate memory for image.\n"); */
|
||||
opj_image_destroy(image);
|
||||
return NULL;
|
||||
}
|
||||
@ -65,7 +66,8 @@ opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptpa
|
||||
comp->sgnd = cmptparms[compno].sgnd;
|
||||
comp->data = (OPJ_INT32*) opj_calloc(comp->w * comp->h, sizeof(OPJ_INT32));
|
||||
if(!comp->data) {
|
||||
fprintf(stderr,"Unable to allocate memory for image.\n");
|
||||
/* TODO replace with event manager, breaks API */
|
||||
/* fprintf(stderr,"Unable to allocate memory for image.\n"); */
|
||||
opj_image_destroy(image);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
||||
/**
|
||||
* Sets up the procedures to do on reading header. Developpers wanting to extend the library can add their own reading procedures.
|
||||
*/
|
||||
static void opj_j2k_setup_header_reading (opj_j2k_t *p_j2k);
|
||||
static OPJ_BOOL opj_j2k_setup_header_reading (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
|
||||
|
||||
/**
|
||||
* The read header procedure.
|
||||
@ -90,19 +90,19 @@ static OPJ_BOOL opj_j2k_decoding_validation ( opj_j2k_t * p_j2k,
|
||||
* Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
|
||||
* are valid. Developpers wanting to extend the library can add their own validation procedures.
|
||||
*/
|
||||
static void opj_j2k_setup_encoding_validation (opj_j2k_t *p_j2k);
|
||||
static OPJ_BOOL opj_j2k_setup_encoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
|
||||
|
||||
/**
|
||||
* Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
|
||||
* are valid. Developpers wanting to extend the library can add their own validation procedures.
|
||||
*/
|
||||
static void opj_j2k_setup_decoding_validation (opj_j2k_t *p_j2k);
|
||||
static OPJ_BOOL opj_j2k_setup_decoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
|
||||
|
||||
/**
|
||||
* Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
|
||||
* are valid. Developpers wanting to extend the library can add their own validation procedures.
|
||||
*/
|
||||
static void opj_j2k_setup_end_compress (opj_j2k_t *p_j2k);
|
||||
static OPJ_BOOL opj_j2k_setup_end_compress (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
|
||||
|
||||
/**
|
||||
* The mct encoding validation procedure.
|
||||
@ -360,7 +360,7 @@ static OPJ_BOOL opj_j2k_post_write_tile (opj_j2k_t * p_j2k,
|
||||
* Sets up the procedures to do on writing header.
|
||||
* Developers wanting to extend the library can add their own writing procedures.
|
||||
*/
|
||||
static void opj_j2k_setup_header_writing (opj_j2k_t *p_j2k);
|
||||
static OPJ_BOOL opj_j2k_setup_header_writing (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
|
||||
|
||||
static OPJ_BOOL opj_j2k_write_first_tile_part( opj_j2k_t *p_j2k,
|
||||
OPJ_BYTE * p_data,
|
||||
@ -4938,7 +4938,7 @@ static OPJ_BOOL opj_j2k_write_regions( opj_j2k_t *p_j2k,
|
||||
|
||||
l_tccp = p_j2k->m_cp.tcps->tccps;
|
||||
|
||||
for (compno = 0; compno < p_j2k->m_private_image->numcomps; ++compno) {
|
||||
for (compno = 0; compno < p_j2k->m_private_image->numcomps; ++compno) {
|
||||
if (l_tccp->roishift) {
|
||||
|
||||
if (! opj_j2k_write_rgn(p_j2k,0,compno,p_j2k->m_private_image->numcomps,p_stream,p_manager)) {
|
||||
@ -6740,7 +6740,11 @@ OPJ_BOOL opj_j2k_read_header( opj_stream_private_t *p_stream,
|
||||
}
|
||||
|
||||
/* customization of the validation */
|
||||
opj_j2k_setup_decoding_validation(p_j2k);
|
||||
if (! opj_j2k_setup_decoding_validation(p_j2k, p_manager)) {
|
||||
opj_image_destroy(p_j2k->m_private_image);
|
||||
p_j2k->m_private_image = NULL;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* validation of the parameters codec */
|
||||
if (! opj_j2k_exec(p_j2k, p_j2k->m_validation_list, p_stream,p_manager)) {
|
||||
@ -6750,7 +6754,11 @@ OPJ_BOOL opj_j2k_read_header( opj_stream_private_t *p_stream,
|
||||
}
|
||||
|
||||
/* customization of the encoding */
|
||||
opj_j2k_setup_header_reading(p_j2k);
|
||||
if (! opj_j2k_setup_header_reading(p_j2k, p_manager)) {
|
||||
opj_image_destroy(p_j2k->m_private_image);
|
||||
p_j2k->m_private_image = NULL;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* read header */
|
||||
if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
|
||||
@ -6775,27 +6783,39 @@ OPJ_BOOL opj_j2k_read_header( opj_stream_private_t *p_stream,
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void opj_j2k_setup_header_reading (opj_j2k_t *p_j2k)
|
||||
static OPJ_BOOL opj_j2k_setup_header_reading (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions*/
|
||||
assert(p_j2k != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_read_header_procedure);
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_read_header_procedure, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* DEVELOPER CORNER, add your custom procedures */
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_copy_default_tcp_and_create_tcd);
|
||||
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_copy_default_tcp_and_create_tcd, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void opj_j2k_setup_decoding_validation (opj_j2k_t *p_j2k)
|
||||
static OPJ_BOOL opj_j2k_setup_decoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions*/
|
||||
assert(p_j2k != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,(opj_procedure)opj_j2k_build_decoder, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,(opj_procedure)opj_j2k_decoding_validation, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_build_decoder);
|
||||
opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_decoding_validation);
|
||||
/* DEVELOPER CORNER, add your custom validation procedure */
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static OPJ_BOOL opj_j2k_mct_validation ( opj_j2k_t * p_j2k,
|
||||
@ -7993,7 +8013,7 @@ OPJ_BOOL opj_j2k_read_tile_header( opj_j2k_t * p_j2k,
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/*FIXME ???*/
|
||||
if (! opj_tcd_init_decode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number)) {
|
||||
if (! opj_tcd_init_decode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number, p_manager)) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -8046,7 +8066,7 @@ OPJ_BOOL opj_j2k_decode_tile ( opj_j2k_t * p_j2k,
|
||||
l_tcp->m_data,
|
||||
l_tcp->m_data_size,
|
||||
p_tile_index,
|
||||
p_j2k->cstr_index) ) {
|
||||
p_j2k->cstr_index, p_manager) ) {
|
||||
opj_j2k_tcp_destroy(l_tcp);
|
||||
p_j2k->m_specific_param.m_decoder.m_state |= 0x8000;/*FIXME J2K_DEC_STATE_ERR;*/
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Failed to decode.\n");
|
||||
@ -9594,14 +9614,18 @@ static OPJ_BOOL opj_j2k_decode_tiles ( opj_j2k_t *p_j2k,
|
||||
/**
|
||||
* Sets up the procedures to do on decoding data. Developpers wanting to extend the library can add their own reading procedures.
|
||||
*/
|
||||
static void opj_j2k_setup_decoding (opj_j2k_t *p_j2k)
|
||||
static OPJ_BOOL opj_j2k_setup_decoding (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions*/
|
||||
assert(p_j2k != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_decode_tiles);
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_decode_tiles, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/* DEVELOPER CORNER, add your custom procedures */
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -9727,14 +9751,18 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k,
|
||||
/**
|
||||
* Sets up the procedures to do on decoding one tile. Developpers wanting to extend the library can add their own reading procedures.
|
||||
*/
|
||||
static void opj_j2k_setup_decoding_tile (opj_j2k_t *p_j2k)
|
||||
static OPJ_BOOL opj_j2k_setup_decoding_tile (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions*/
|
||||
assert(p_j2k != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_decode_one_tile);
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_decode_one_tile, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/* DEVELOPER CORNER, add your custom procedures */
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
OPJ_BOOL opj_j2k_decode(opj_j2k_t * p_j2k,
|
||||
@ -9754,7 +9782,7 @@ OPJ_BOOL opj_j2k_decode(opj_j2k_t * p_j2k,
|
||||
opj_copy_image_header(p_image, p_j2k->m_output_image);
|
||||
|
||||
/* customization of the decoding */
|
||||
opj_j2k_setup_decoding(p_j2k);
|
||||
opj_j2k_setup_decoding(p_j2k, p_manager);
|
||||
|
||||
/* Decode the codestream */
|
||||
if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
|
||||
@ -9850,7 +9878,7 @@ OPJ_BOOL opj_j2k_get_tile( opj_j2k_t *p_j2k,
|
||||
p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec = (OPJ_INT32)tile_index;
|
||||
|
||||
/* customization of the decoding */
|
||||
opj_j2k_setup_decoding_tile(p_j2k);
|
||||
opj_j2k_setup_decoding_tile(p_j2k, p_manager);
|
||||
|
||||
/* Decode the codestream */
|
||||
if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
|
||||
@ -9990,7 +10018,9 @@ OPJ_BOOL opj_j2k_end_compress( opj_j2k_t *p_j2k,
|
||||
opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* customization of the encoding */
|
||||
opj_j2k_setup_end_compress(p_j2k);
|
||||
if (! opj_j2k_setup_end_compress(p_j2k, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if (! opj_j2k_exec (p_j2k, p_j2k->m_procedure_list, p_stream, p_manager))
|
||||
{
|
||||
@ -10030,7 +10060,9 @@ OPJ_BOOL opj_j2k_start_compress(opj_j2k_t *p_j2k,
|
||||
}
|
||||
|
||||
/* customization of the validation */
|
||||
opj_j2k_setup_encoding_validation (p_j2k);
|
||||
if (! opj_j2k_setup_encoding_validation (p_j2k, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* validation of the parameters codec */
|
||||
if (! opj_j2k_exec(p_j2k,p_j2k->m_validation_list,p_stream,p_manager)) {
|
||||
@ -10038,7 +10070,9 @@ OPJ_BOOL opj_j2k_start_compress(opj_j2k_t *p_j2k,
|
||||
}
|
||||
|
||||
/* customization of the encoding */
|
||||
opj_j2k_setup_header_writing(p_j2k);
|
||||
if (! opj_j2k_setup_header_writing(p_j2k, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* write header */
|
||||
if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
|
||||
@ -10066,7 +10100,7 @@ static OPJ_BOOL opj_j2k_pre_write_tile ( opj_j2k_t * p_j2k,
|
||||
p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = 0;
|
||||
|
||||
/* initialisation before tile encoding */
|
||||
if (! opj_tcd_init_encode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number)) {
|
||||
if (! opj_tcd_init_encode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
@ -10239,76 +10273,130 @@ static OPJ_BOOL opj_j2k_post_write_tile ( opj_j2k_t * p_j2k,
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void opj_j2k_setup_end_compress (opj_j2k_t *p_j2k)
|
||||
static OPJ_BOOL opj_j2k_setup_end_compress (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(p_j2k != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
/* DEVELOPER CORNER, insert your custom procedures */
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_eoc );
|
||||
|
||||
if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) {
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_updated_tlm);
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_eoc, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_epc );
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_end_encoding );
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_destroy_header_memory);
|
||||
}
|
||||
|
||||
static void opj_j2k_setup_encoding_validation (opj_j2k_t *p_j2k)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(p_j2k != 00);
|
||||
|
||||
opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_build_encoder);
|
||||
opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_encoding_validation);
|
||||
|
||||
/* DEVELOPER CORNER, add your custom validation procedure */
|
||||
opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_mct_validation);
|
||||
}
|
||||
|
||||
static void opj_j2k_setup_header_writing (opj_j2k_t *p_j2k)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(p_j2k != 00);
|
||||
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_init_info );
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_soc );
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_siz );
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_cod );
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_qcd );
|
||||
|
||||
if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) {
|
||||
/* No need for COC or QCC, QCD and COD are used
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_all_coc );
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_all_qcc );
|
||||
*/
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_tlm );
|
||||
|
||||
if (p_j2k->m_cp.rsiz == OPJ_PROFILE_CINEMA_4K) {
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_poc );
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_updated_tlm, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_regions);
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_epc, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_end_encoding, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_destroy_header_memory, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static OPJ_BOOL opj_j2k_setup_encoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(p_j2k != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_build_encoder, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_encoding_validation, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* DEVELOPER CORNER, add your custom validation procedure */
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_mct_validation, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static OPJ_BOOL opj_j2k_setup_header_writing (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(p_j2k != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_init_info, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_soc, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_siz, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_cod, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_qcd, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) {
|
||||
/* No need for COC or QCC, QCD and COD are used
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_all_coc, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_all_qcc, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
*/
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_tlm, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if (p_j2k->m_cp.rsiz == OPJ_PROFILE_CINEMA_4K) {
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_poc, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_regions, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if (p_j2k->m_cp.comment != 00) {
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_com);
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_com, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* DEVELOPER CORNER, insert your custom procedures */
|
||||
if (p_j2k->m_cp.rsiz & OPJ_EXTENSION_MCT) {
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_mct_data_group );
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_mct_data_group, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
/* End of Developer Corner */
|
||||
|
||||
if (p_j2k->cstr_index) {
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_get_end_header );
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_get_end_header, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_create_tcd);
|
||||
opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_update_rates);
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_create_tcd, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_update_rates, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static OPJ_BOOL opj_j2k_write_first_tile_part (opj_j2k_t *p_j2k,
|
||||
|
@ -106,7 +106,7 @@ static OPJ_BOOL opj_jp2_read_cdef( opj_jp2_t * jp2,
|
||||
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);
|
||||
static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color, opj_event_mgr_t *);
|
||||
|
||||
/**
|
||||
* Writes the Channel Definition box.
|
||||
@ -326,13 +326,13 @@ static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
|
||||
* Sets up the procedures to do on writing header after the codestream.
|
||||
* Developpers wanting to extend the library can add their own writing procedures.
|
||||
*/
|
||||
static void opj_jp2_setup_end_header_writing (opj_jp2_t *jp2);
|
||||
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 reading header after the codestream.
|
||||
* Developpers wanting to extend the library can add their own writing procedures.
|
||||
*/
|
||||
static void opj_jp2_setup_end_header_reading (opj_jp2_t *jp2);
|
||||
static OPJ_BOOL opj_jp2_setup_end_header_reading (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
|
||||
|
||||
/**
|
||||
* Reads a jpeg2000 file header structure.
|
||||
@ -381,12 +381,12 @@ static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box,
|
||||
* Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
|
||||
* are valid. Developpers wanting to extend the library can add their own validation procedures.
|
||||
*/
|
||||
static void opj_jp2_setup_encoding_validation (opj_jp2_t *jp2);
|
||||
static OPJ_BOOL opj_jp2_setup_encoding_validation (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
|
||||
|
||||
/**
|
||||
* Sets up the procedures to do on writing header. Developpers wanting to extend the library can add their own writing procedures.
|
||||
*/
|
||||
static void opj_jp2_setup_header_writing (opj_jp2_t *jp2);
|
||||
static OPJ_BOOL opj_jp2_setup_header_writing (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
|
||||
|
||||
static OPJ_BOOL opj_jp2_default_validation ( opj_jp2_t * jp2,
|
||||
opj_stream_private_t *cio,
|
||||
@ -449,13 +449,13 @@ static OPJ_BOOL opj_jp2_read_boxhdr_char( opj_jp2_box_t *box,
|
||||
* Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
|
||||
* are valid. Developpers wanting to extend the library can add their own validation procedures.
|
||||
*/
|
||||
static void opj_jp2_setup_decoding_validation (opj_jp2_t *jp2);
|
||||
static OPJ_BOOL opj_jp2_setup_decoding_validation (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
|
||||
|
||||
/**
|
||||
* Sets up the procedures to do on reading header.
|
||||
* Developpers wanting to extend the library can add their own writing procedures.
|
||||
*/
|
||||
static void opj_jp2_setup_header_reading (opj_jp2_t *jp2);
|
||||
static OPJ_BOOL opj_jp2_setup_header_reading (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box,
|
||||
@ -1210,7 +1210,7 @@ static OPJ_BOOL opj_jp2_read_cmap( opj_jp2_t * jp2,
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color)
|
||||
static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color, opj_event_mgr_t *manager)
|
||||
{
|
||||
opj_jp2_cdef_info_t *info;
|
||||
OPJ_UINT16 i, n, cn, asoc, acn;
|
||||
@ -1226,7 +1226,7 @@ static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color)
|
||||
|
||||
if( cn >= image->numcomps)
|
||||
{
|
||||
fprintf(stderr, "cn=%d, numcomps=%d\n", cn, image->numcomps);
|
||||
opj_event_msg(manager, EVT_WARNING, "opj_jp2_apply_cdef: cn=%d, numcomps=%d\n", cn, image->numcomps);
|
||||
continue;
|
||||
}
|
||||
if(asoc == 0 || asoc == 65535)
|
||||
@ -1238,7 +1238,7 @@ static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color)
|
||||
acn = (OPJ_UINT16)(asoc - 1);
|
||||
if( acn >= image->numcomps )
|
||||
{
|
||||
fprintf(stderr, "acn=%d, numcomps=%d\n", acn, image->numcomps);
|
||||
opj_event_msg(manager, EVT_WARNING, "opj_jp2_apply_cdef: acn=%d, numcomps=%d\n", acn, image->numcomps);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1465,7 +1465,7 @@ OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
|
||||
|
||||
/* Apply the color space if needed */
|
||||
if(jp2->color.jp2_cdef) {
|
||||
opj_jp2_apply_cdef(p_image, &(jp2->color));
|
||||
opj_jp2_apply_cdef(p_image, &(jp2->color), p_manager);
|
||||
}
|
||||
|
||||
if(jp2->color.icc_profile_buf) {
|
||||
@ -1899,7 +1899,9 @@ OPJ_BOOL opj_jp2_end_decompress(opj_jp2_t *jp2,
|
||||
assert(p_manager != 00);
|
||||
|
||||
/* customization of the end encoding */
|
||||
opj_jp2_setup_end_header_reading(jp2);
|
||||
if (! opj_jp2_setup_end_header_reading(jp2, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* write header */
|
||||
if (! opj_jp2_exec (jp2,jp2->m_procedure_list,cio,p_manager)) {
|
||||
@ -1920,7 +1922,9 @@ OPJ_BOOL opj_jp2_end_compress( opj_jp2_t *jp2,
|
||||
assert(p_manager != 00);
|
||||
|
||||
/* customization of the end encoding */
|
||||
opj_jp2_setup_end_header_writing(jp2);
|
||||
if (! opj_jp2_setup_end_header_writing(jp2, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if (! opj_j2k_end_compress(jp2->j2k,cio,p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
@ -1930,32 +1934,49 @@ OPJ_BOOL opj_jp2_end_compress( opj_jp2_t *jp2,
|
||||
return opj_jp2_exec(jp2,jp2->m_procedure_list,cio,p_manager);
|
||||
}
|
||||
|
||||
static void opj_jp2_setup_end_header_writing (opj_jp2_t *jp2)
|
||||
static OPJ_BOOL opj_jp2_setup_end_header_writing (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(jp2 != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
#ifdef USE_JPIP
|
||||
if( jp2->jpip_on )
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_write_iptr );
|
||||
if( jp2->jpip_on ) {
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_write_iptr, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_jp2c );
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_jp2c, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/* DEVELOPER CORNER, add your custom procedures */
|
||||
#ifdef USE_JPIP
|
||||
if( jp2->jpip_on )
|
||||
{
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_write_cidx );
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_write_fidx );
|
||||
}
|
||||
{
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_write_cidx, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_write_fidx, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void opj_jp2_setup_end_header_reading (opj_jp2_t *jp2)
|
||||
static OPJ_BOOL opj_jp2_setup_end_header_reading (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(jp2 != 00);
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_read_header_procedure );
|
||||
assert(p_manager != 00);
|
||||
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_read_header_procedure, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/* DEVELOPER CORNER, add your custom procedures */
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static OPJ_BOOL opj_jp2_default_validation ( opj_jp2_t * jp2,
|
||||
@ -2190,7 +2211,9 @@ OPJ_BOOL opj_jp2_start_compress(opj_jp2_t *jp2,
|
||||
assert(p_manager != 00);
|
||||
|
||||
/* customization of the validation */
|
||||
opj_jp2_setup_encoding_validation (jp2);
|
||||
if (! opj_jp2_setup_encoding_validation (jp2, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* validation of the parameters codec */
|
||||
if (! opj_jp2_exec(jp2,jp2->m_validation_list,stream,p_manager)) {
|
||||
@ -2198,7 +2221,9 @@ OPJ_BOOL opj_jp2_start_compress(opj_jp2_t *jp2,
|
||||
}
|
||||
|
||||
/* customization of the encoding */
|
||||
opj_jp2_setup_header_writing(jp2);
|
||||
if (! opj_jp2_setup_header_writing(jp2, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* write header */
|
||||
if (! opj_jp2_exec (jp2,jp2->m_procedure_list,stream,p_manager)) {
|
||||
@ -2552,10 +2577,14 @@ OPJ_BOOL opj_jp2_read_header( opj_stream_private_t *p_stream,
|
||||
assert(p_manager != 00);
|
||||
|
||||
/* customization of the validation */
|
||||
opj_jp2_setup_decoding_validation (jp2);
|
||||
if (! opj_jp2_setup_decoding_validation (jp2, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* customization of the encoding */
|
||||
opj_jp2_setup_header_reading(jp2);
|
||||
if (! opj_jp2_setup_header_reading(jp2, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* validation of the parameters codec */
|
||||
if (! opj_jp2_exec(jp2,jp2->m_validation_list,p_stream,p_manager)) {
|
||||
@ -2573,45 +2602,73 @@ OPJ_BOOL opj_jp2_read_header( opj_stream_private_t *p_stream,
|
||||
p_manager);
|
||||
}
|
||||
|
||||
static void opj_jp2_setup_encoding_validation (opj_jp2_t *jp2)
|
||||
static OPJ_BOOL opj_jp2_setup_encoding_validation (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(jp2 != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
opj_procedure_list_add_procedure(jp2->m_validation_list, (opj_procedure)opj_jp2_default_validation);
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_validation_list, (opj_procedure)opj_jp2_default_validation, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/* DEVELOPER CORNER, add your custom validation procedure */
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void opj_jp2_setup_decoding_validation (opj_jp2_t *jp2)
|
||||
static OPJ_BOOL opj_jp2_setup_decoding_validation (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(jp2 != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
/* DEVELOPER CORNER, add your custom validation procedure */
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void opj_jp2_setup_header_writing (opj_jp2_t *jp2)
|
||||
static OPJ_BOOL opj_jp2_setup_header_writing (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(jp2 != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_jp );
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_ftyp );
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_jp2h );
|
||||
if( jp2->jpip_on )
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_skip_iptr );
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_skip_jp2c );
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_jp, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_ftyp, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_jp2h, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if( jp2->jpip_on ) {
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_skip_iptr, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_skip_jp2c,p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* DEVELOPER CORNER, insert your custom procedures */
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void opj_jp2_setup_header_reading (opj_jp2_t *jp2)
|
||||
static OPJ_BOOL opj_jp2_setup_header_reading (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
|
||||
{
|
||||
/* preconditions */
|
||||
assert(jp2 != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_read_header_procedure );
|
||||
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_read_header_procedure, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* DEVELOPER CORNER, add your custom procedures */
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
OPJ_BOOL opj_jp2_read_tile_header ( opj_jp2_t * p_jp2,
|
||||
@ -2780,7 +2837,7 @@ OPJ_BOOL opj_jp2_get_tile( opj_jp2_t *p_jp2,
|
||||
|
||||
/* Apply the color space if needed */
|
||||
if(p_jp2->color.jp2_cdef) {
|
||||
opj_jp2_apply_cdef(p_image, &(p_jp2->color));
|
||||
opj_jp2_apply_cdef(p_image, &(p_jp2->color), p_manager);
|
||||
}
|
||||
|
||||
if(p_jp2->color.icc_profile_buf) {
|
||||
|
@ -866,7 +866,8 @@ void OPJ_CALLCONV opj_dump_codec( opj_codec_t *p_codec,
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "[ERROR] Input parameter of the dump_codec function are incorrect.\n");
|
||||
/* TODO return error */
|
||||
/* fprintf(stderr, "[ERROR] Input parameter of the dump_codec function are incorrect.\n"); */
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -167,16 +167,16 @@ static INLINE long opj_lrintf(float f) {
|
||||
#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)
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
|
||||
# include <intrin.h>
|
||||
# pragma intrinsic(__emul)
|
||||
#endif
|
||||
|
||||
#include "opj_inttypes.h"
|
||||
#include "opj_clock.h"
|
||||
#include "opj_malloc.h"
|
||||
#include "function_list.h"
|
||||
#include "event.h"
|
||||
#include "function_list.h"
|
||||
#include "bio.h"
|
||||
#include "cio.h"
|
||||
|
||||
|
@ -97,7 +97,8 @@ static OPJ_BOOL opj_t2_decode_packet( opj_t2_t* t2,
|
||||
OPJ_BYTE *src,
|
||||
OPJ_UINT32 * data_read,
|
||||
OPJ_UINT32 max_length,
|
||||
opj_packet_info_t *pack_info);
|
||||
opj_packet_info_t *pack_info,
|
||||
opj_event_mgr_t *p_manager);
|
||||
|
||||
static OPJ_BOOL opj_t2_skip_packet( opj_t2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
@ -106,7 +107,8 @@ static OPJ_BOOL opj_t2_skip_packet( opj_t2_t* p_t2,
|
||||
OPJ_BYTE *p_src,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
opj_packet_info_t *p_pack_info);
|
||||
opj_packet_info_t *p_pack_info,
|
||||
opj_event_mgr_t *p_manager);
|
||||
|
||||
static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
@ -116,7 +118,8 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
|
||||
OPJ_BYTE *p_src_data,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
opj_packet_info_t *p_pack_info);
|
||||
opj_packet_info_t *p_pack_info,
|
||||
opj_event_mgr_t *p_manager);
|
||||
|
||||
static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
@ -124,14 +127,16 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
|
||||
OPJ_BYTE *p_src_data,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
opj_packet_info_t *pack_info);
|
||||
opj_packet_info_t *pack_info,
|
||||
opj_event_mgr_t *p_manager);
|
||||
|
||||
static OPJ_BOOL opj_t2_skip_packet_data(opj_t2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
opj_packet_info_t *pack_info);
|
||||
opj_packet_info_t *pack_info,
|
||||
opj_event_mgr_t *p_manager);
|
||||
|
||||
/**
|
||||
@param cblk
|
||||
@ -345,7 +350,8 @@ OPJ_BOOL opj_t2_decode_packets( opj_t2_t *p_t2,
|
||||
OPJ_BYTE *p_src,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_len,
|
||||
opj_codestream_index_t *p_cstr_index)
|
||||
opj_codestream_index_t *p_cstr_index,
|
||||
opj_event_mgr_t *p_manager)
|
||||
{
|
||||
OPJ_BYTE *l_current_data = p_src;
|
||||
opj_pi_iterator_t *l_pi = 00;
|
||||
@ -413,7 +419,7 @@ OPJ_BOOL opj_t2_decode_packets( opj_t2_t *p_t2,
|
||||
|
||||
first_pass_failed[l_current_pi->compno] = OPJ_FALSE;
|
||||
|
||||
if (! opj_t2_decode_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info)) {
|
||||
if (! opj_t2_decode_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info, p_manager)) {
|
||||
opj_pi_destroy(l_pi,l_nb_pocs);
|
||||
opj_free(first_pass_failed);
|
||||
return OPJ_FALSE;
|
||||
@ -424,7 +430,7 @@ OPJ_BOOL opj_t2_decode_packets( opj_t2_t *p_t2,
|
||||
}
|
||||
else {
|
||||
l_nb_bytes_read = 0;
|
||||
if (! opj_t2_skip_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info)) {
|
||||
if (! opj_t2_skip_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info, p_manager)) {
|
||||
opj_pi_destroy(l_pi,l_nb_pocs);
|
||||
opj_free(first_pass_failed);
|
||||
return OPJ_FALSE;
|
||||
@ -518,7 +524,8 @@ static OPJ_BOOL opj_t2_decode_packet( opj_t2_t* p_t2,
|
||||
OPJ_BYTE *p_src,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
opj_packet_info_t *p_pack_info)
|
||||
opj_packet_info_t *p_pack_info,
|
||||
opj_event_mgr_t *p_manager)
|
||||
{
|
||||
OPJ_BOOL l_read_data;
|
||||
OPJ_UINT32 l_nb_bytes_read = 0;
|
||||
@ -526,7 +533,7 @@ static OPJ_BOOL opj_t2_decode_packet( opj_t2_t* p_t2,
|
||||
|
||||
*p_data_read = 0;
|
||||
|
||||
if (! opj_t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info)) {
|
||||
if (! opj_t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
@ -538,7 +545,7 @@ static OPJ_BOOL opj_t2_decode_packet( opj_t2_t* p_t2,
|
||||
if (l_read_data) {
|
||||
l_nb_bytes_read = 0;
|
||||
|
||||
if (! opj_t2_read_packet_data(p_t2,p_tile,p_pi,p_src,&l_nb_bytes_read,p_max_length,p_pack_info)) {
|
||||
if (! opj_t2_read_packet_data(p_t2,p_tile,p_pi,p_src,&l_nb_bytes_read,p_max_length,p_pack_info, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
@ -793,7 +800,8 @@ static OPJ_BOOL opj_t2_skip_packet( opj_t2_t* p_t2,
|
||||
OPJ_BYTE *p_src,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
opj_packet_info_t *p_pack_info)
|
||||
opj_packet_info_t *p_pack_info,
|
||||
opj_event_mgr_t *p_manager)
|
||||
{
|
||||
OPJ_BOOL l_read_data;
|
||||
OPJ_UINT32 l_nb_bytes_read = 0;
|
||||
@ -801,7 +809,7 @@ static OPJ_BOOL opj_t2_skip_packet( opj_t2_t* p_t2,
|
||||
|
||||
*p_data_read = 0;
|
||||
|
||||
if (! opj_t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info)) {
|
||||
if (! opj_t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
@ -813,7 +821,7 @@ static OPJ_BOOL opj_t2_skip_packet( opj_t2_t* p_t2,
|
||||
if (l_read_data) {
|
||||
l_nb_bytes_read = 0;
|
||||
|
||||
if (! opj_t2_skip_packet_data(p_t2,p_tile,p_pi,&l_nb_bytes_read,p_max_length,p_pack_info)) {
|
||||
if (! opj_t2_skip_packet_data(p_t2,p_tile,p_pi,&l_nb_bytes_read,p_max_length,p_pack_info, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
@ -833,7 +841,8 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
|
||||
OPJ_BYTE *p_src_data,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
opj_packet_info_t *p_pack_info)
|
||||
opj_packet_info_t *p_pack_info,
|
||||
opj_event_mgr_t *p_manager)
|
||||
|
||||
{
|
||||
/* loop */
|
||||
@ -882,11 +891,9 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
|
||||
|
||||
if (p_tcp->csty & J2K_CP_CSTY_SOP) {
|
||||
if (p_max_length < 6) {
|
||||
/* TODO opj_event_msg(p_t2->cinfo->event_mgr, EVT_WARNING, "Not enough space for expected SOP marker\n"); */
|
||||
fprintf(stderr, "Not enough space for expected SOP marker\n");
|
||||
opj_event_msg(p_manager, EVT_WARNING, "Not enough space for expected SOP marker\n");
|
||||
} else if ((*l_current_data) != 0xff || (*(l_current_data + 1) != 0x91)) {
|
||||
/* TODO opj_event_msg(p_t2->cinfo->event_mgr, EVT_WARNING, "Expected SOP marker\n"); */
|
||||
fprintf(stderr, "Warning: expected SOP marker\n");
|
||||
opj_event_msg(p_manager, EVT_WARNING, "Expected SOP marker\n");
|
||||
} else {
|
||||
l_current_data += 6;
|
||||
}
|
||||
@ -937,9 +944,9 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
|
||||
/* EPH markers */
|
||||
if (p_tcp->csty & J2K_CP_CSTY_EPH) {
|
||||
if ((*l_modified_length_ptr - (OPJ_UINT32)(l_header_data - *l_header_data_start)) < 2U) {
|
||||
fprintf(stderr, "Not enough space for expected EPH marker\n");
|
||||
opj_event_msg(p_manager, EVT_WARNING, "Not enough space for expected EPH marker\n");
|
||||
} else if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
|
||||
fprintf(stderr, "Error : expected EPH marker\n");
|
||||
opj_event_msg(p_manager, EVT_WARNING, "Expected EPH marker\n");
|
||||
} else {
|
||||
l_header_data += 2;
|
||||
}
|
||||
@ -990,7 +997,7 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
|
||||
if (!l_included) {
|
||||
l_cblk->numnewpasses = 0;
|
||||
++l_cblk;
|
||||
JAS_FPRINTF(stderr, "included=%d \n", l_included);
|
||||
JAS_FPRINTF(stderr, "included=%d \n", l_included);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1065,10 +1072,9 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
|
||||
/* EPH markers */
|
||||
if (p_tcp->csty & J2K_CP_CSTY_EPH) {
|
||||
if ((*l_modified_length_ptr - (OPJ_UINT32)(l_header_data - *l_header_data_start)) < 2U) {
|
||||
fprintf(stderr, "Not enough space for expected EPH marker\n");
|
||||
opj_event_msg(p_manager, EVT_WARNING, "Not enough space for expected EPH marker\n");
|
||||
} else if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
|
||||
/* TODO opj_event_msg(t2->cinfo->event_mgr, EVT_ERROR, "Expected EPH marker\n"); */
|
||||
fprintf(stderr, "Error : expected EPH marker\n");
|
||||
opj_event_msg(p_manager, EVT_WARNING, "Expected EPH marker\n");
|
||||
} else {
|
||||
l_header_data += 2;
|
||||
}
|
||||
@ -1100,7 +1106,8 @@ static OPJ_BOOL opj_t2_read_packet_data( opj_t2_t* p_t2,
|
||||
OPJ_BYTE *p_src_data,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
opj_packet_info_t *pack_info)
|
||||
opj_packet_info_t *pack_info,
|
||||
opj_event_mgr_t* p_manager)
|
||||
{
|
||||
OPJ_UINT32 bandno, cblkno;
|
||||
OPJ_UINT32 l_nb_code_blocks;
|
||||
@ -1150,8 +1157,8 @@ static OPJ_BOOL opj_t2_read_packet_data( opj_t2_t* p_t2,
|
||||
do {
|
||||
/* Check possible overflow (on l_current_data only, assumes input args already checked) then size */
|
||||
if ((((OPJ_SIZE_T)l_current_data + (OPJ_SIZE_T)l_seg->newlen) < (OPJ_SIZE_T)l_current_data) || (l_current_data + l_seg->newlen > p_src_data + p_max_length)) {
|
||||
fprintf(stderr, "read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
|
||||
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
|
||||
opj_event_msg(p_manager, EVT_ERROR, "read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
|
||||
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
@ -1161,22 +1168,22 @@ static OPJ_BOOL opj_t2_read_packet_data( opj_t2_t* p_t2,
|
||||
|
||||
/* let's check that we are not exceeding */
|
||||
if ((l_cblk->len + l_seg->newlen) > 8192) {
|
||||
opj_event_msg(p_t2->cinfo, EVT_WARNING,
|
||||
opj_event_msg(p_manager, EVT_WARNING,
|
||||
"JPWL: segment too long (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
|
||||
l_seg->newlen, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
|
||||
if (!JPWL_ASSUME) {
|
||||
opj_event_msg(p_t2->cinfo, EVT_ERROR, "JPWL: giving up\n");
|
||||
opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_seg->newlen = 8192 - l_cblk->len;
|
||||
opj_event_msg(p_t2->cinfo, EVT_WARNING, " - truncating segment to %d\n", l_seg->newlen);
|
||||
opj_event_msg(p_manager, EVT_WARNING, " - truncating segment to %d\n", l_seg->newlen);
|
||||
break;
|
||||
};
|
||||
|
||||
#endif /* USE_JPWL */
|
||||
/* Check possible overflow on size */
|
||||
if ((l_cblk->data_current_size + l_seg->newlen) < l_cblk->data_current_size) {
|
||||
fprintf(stderr, "read: segment too long (%d) with current size (%d > %d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
|
||||
opj_event_msg(p_manager, EVT_ERROR, "read: segment too long (%d) with current size (%d > %d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
|
||||
l_seg->newlen, l_cblk->data_current_size, 0xFFFFFFFF - l_seg->newlen, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -1233,7 +1240,8 @@ static OPJ_BOOL opj_t2_skip_packet_data( opj_t2_t* p_t2,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
opj_packet_info_t *pack_info)
|
||||
opj_packet_info_t *pack_info,
|
||||
opj_event_mgr_t *p_manager)
|
||||
{
|
||||
OPJ_UINT32 bandno, cblkno;
|
||||
OPJ_UINT32 l_nb_code_blocks;
|
||||
@ -1284,7 +1292,7 @@ static OPJ_BOOL opj_t2_skip_packet_data( opj_t2_t* p_t2,
|
||||
do {
|
||||
/* Check possible overflow then size */
|
||||
if (((*p_data_read + l_seg->newlen) < (*p_data_read)) || ((*p_data_read + l_seg->newlen) > p_max_length)) {
|
||||
fprintf(stderr, "skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
|
||||
opj_event_msg(p_manager, EVT_ERROR, "skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
|
||||
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -1295,15 +1303,15 @@ static OPJ_BOOL opj_t2_skip_packet_data( opj_t2_t* p_t2,
|
||||
|
||||
/* let's check that we are not exceeding */
|
||||
if ((l_cblk->len + l_seg->newlen) > 8192) {
|
||||
opj_event_msg(p_t2->cinfo, EVT_WARNING,
|
||||
opj_event_msg(p_manager, EVT_WARNING,
|
||||
"JPWL: segment too long (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
|
||||
l_seg->newlen, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
|
||||
if (!JPWL_ASSUME) {
|
||||
opj_event_msg(p_t2->cinfo, EVT_ERROR, "JPWL: giving up\n");
|
||||
opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
|
||||
return -999;
|
||||
}
|
||||
l_seg->newlen = 8192 - l_cblk->len;
|
||||
opj_event_msg(p_t2->cinfo, EVT_WARNING, " - truncating segment to %d\n", l_seg->newlen);
|
||||
opj_event_msg(p_manager, EVT_WARNING, " - truncating segment to %d\n", l_seg->newlen);
|
||||
break;
|
||||
};
|
||||
|
||||
|
@ -108,7 +108,8 @@ OPJ_BOOL opj_t2_decode_packets( opj_t2_t *t2,
|
||||
OPJ_BYTE *src,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 len,
|
||||
opj_codestream_index_t *cstr_info);
|
||||
opj_codestream_index_t *cstr_info,
|
||||
opj_event_mgr_t *p_manager);
|
||||
|
||||
/**
|
||||
* Creates a Tier 2 handle
|
||||
|
@ -107,7 +107,7 @@ void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) {
|
||||
/**
|
||||
* Initializes tile coding/decoding
|
||||
*/
|
||||
static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, OPJ_BOOL isEncoder, OPJ_FLOAT32 fraction, OPJ_SIZE_T sizeof_block);
|
||||
static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, OPJ_BOOL isEncoder, OPJ_FLOAT32 fraction, OPJ_SIZE_T sizeof_block, opj_event_mgr_t* manager);
|
||||
|
||||
/**
|
||||
* Allocates memory for a decoding code block.
|
||||
@ -146,13 +146,14 @@ static OPJ_BOOL opj_tcd_t2_decode ( opj_tcd_t *p_tcd,
|
||||
OPJ_BYTE * p_src_data,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_src_size,
|
||||
opj_codestream_index_t *p_cstr_index );
|
||||
opj_codestream_index_t *p_cstr_index,
|
||||
opj_event_mgr_t *p_manager);
|
||||
|
||||
static OPJ_BOOL opj_tcd_t1_decode (opj_tcd_t *p_tcd);
|
||||
|
||||
static OPJ_BOOL opj_tcd_dwt_decode (opj_tcd_t *p_tcd);
|
||||
|
||||
static OPJ_BOOL opj_tcd_mct_decode (opj_tcd_t *p_tcd);
|
||||
static OPJ_BOOL opj_tcd_mct_decode (opj_tcd_t *p_tcd, opj_event_mgr_t *p_manager);
|
||||
|
||||
static OPJ_BOOL opj_tcd_dc_level_shift_decode (opj_tcd_t *p_tcd);
|
||||
|
||||
@ -655,7 +656,7 @@ OPJ_BOOL opj_alloc_tile_component_data(opj_tcd_tilecomp_t *l_tilec)
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, OPJ_BOOL isEncoder, OPJ_FLOAT32 fraction, OPJ_SIZE_T sizeof_block)
|
||||
static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, OPJ_BOOL isEncoder, OPJ_FLOAT32 fraction, OPJ_SIZE_T sizeof_block, opj_event_mgr_t* manager)
|
||||
{
|
||||
OPJ_UINT32 (*l_gain_ptr)(OPJ_UINT32) = 00;
|
||||
OPJ_UINT32 compno, resno, bandno, precno, cblkno;
|
||||
@ -711,7 +712,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
|
||||
/* testcase 1888.pdf.asan.35.988 */
|
||||
if (l_tccp->numresolutions == 0) {
|
||||
fprintf(stderr, "tiles require at least one resolution\n");
|
||||
opj_event_msg(manager, EVT_ERROR, "tiles require at least one resolution\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/*fprintf(stderr, "Tile border = %d,%d,%d,%d\n", l_tile->x0, l_tile->y0,l_tile->x1,l_tile->y1);*/
|
||||
@ -730,13 +731,13 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
/* compute l_data_size with overflow check */
|
||||
l_data_size = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0);
|
||||
if ((((OPJ_UINT32)-1) / l_data_size) < (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0)) {
|
||||
/* TODO event */
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_data_size = l_data_size * (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0);
|
||||
|
||||
if ((((OPJ_UINT32)-1) / (OPJ_UINT32)sizeof(OPJ_UINT32)) < l_data_size) {
|
||||
/* TODO event */
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_data_size = l_data_size * (OPJ_UINT32)sizeof(OPJ_UINT32);
|
||||
@ -750,6 +751,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
|
||||
l_tilec->data_size_needed = l_data_size;
|
||||
if (p_tcd->m_is_decoder && !opj_alloc_tile_component_data(l_tilec)) {
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
@ -767,8 +769,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
else if (l_data_size > l_tilec->resolutions_size) {
|
||||
opj_tcd_resolution_t* new_resolutions = (opj_tcd_resolution_t *) opj_realloc(l_tilec->resolutions, l_data_size);
|
||||
if (! new_resolutions) {
|
||||
/* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to tile resolutions\n"); */
|
||||
fprintf(stderr, "Not enough memory to tile resolutions\n");
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile resolutions\n");
|
||||
opj_free(l_tilec->resolutions);
|
||||
l_tilec->resolutions = NULL;
|
||||
l_tilec->resolutions_size = 0;
|
||||
@ -886,8 +887,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
|
||||
opj_tcd_precinct_t * new_precincts = (opj_tcd_precinct_t *) opj_realloc(l_band->precincts,/*3 * */ l_nb_precinct_size);
|
||||
if (! new_precincts) {
|
||||
/* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle band precints\n"); */
|
||||
fprintf(stderr, "Not enough memory to handle band precints\n");
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory to handle band precints\n");
|
||||
opj_free(l_band->precincts);
|
||||
l_band->precincts = NULL;
|
||||
l_band->precincts_data_size = 0;
|
||||
@ -950,8 +950,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
opj_free(l_current_precinct->cblks.blocks);
|
||||
l_current_precinct->cblks.blocks = NULL;
|
||||
l_current_precinct->block_size = 0;
|
||||
/* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory for current precinct codeblock element\n"); */
|
||||
fprintf(stderr, "Not enough memory for current precinct codeblock element\n");
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory for current precinct codeblock element\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_current_precinct->cblks.blocks = new_blocks;
|
||||
@ -965,34 +964,26 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
}
|
||||
|
||||
if (! l_current_precinct->incltree) {
|
||||
l_current_precinct->incltree = opj_tgt_create(l_current_precinct->cw,
|
||||
l_current_precinct->ch);
|
||||
l_current_precinct->incltree = opj_tgt_create(l_current_precinct->cw, l_current_precinct->ch, manager);
|
||||
}
|
||||
else{
|
||||
l_current_precinct->incltree = opj_tgt_init(l_current_precinct->incltree,
|
||||
l_current_precinct->cw,
|
||||
l_current_precinct->ch);
|
||||
l_current_precinct->incltree = opj_tgt_init(l_current_precinct->incltree, l_current_precinct->cw, l_current_precinct->ch, manager);
|
||||
}
|
||||
|
||||
if (! l_current_precinct->incltree) {
|
||||
fprintf(stderr, "WARNING: No incltree created.\n");
|
||||
opj_event_msg(manager, EVT_WARNING, "No incltree created.\n");
|
||||
/*return OPJ_FALSE;*/
|
||||
}
|
||||
|
||||
if (! l_current_precinct->imsbtree) {
|
||||
l_current_precinct->imsbtree = opj_tgt_create(
|
||||
l_current_precinct->cw,
|
||||
l_current_precinct->ch);
|
||||
l_current_precinct->imsbtree = opj_tgt_create(l_current_precinct->cw, l_current_precinct->ch, manager);
|
||||
}
|
||||
else {
|
||||
l_current_precinct->imsbtree = opj_tgt_init(
|
||||
l_current_precinct->imsbtree,
|
||||
l_current_precinct->cw,
|
||||
l_current_precinct->ch);
|
||||
l_current_precinct->imsbtree = opj_tgt_init(l_current_precinct->imsbtree, l_current_precinct->cw, l_current_precinct->ch, manager);
|
||||
}
|
||||
|
||||
if (! l_current_precinct->imsbtree) {
|
||||
fprintf(stderr, "WARNING: No imsbtree created.\n");
|
||||
opj_event_msg(manager, EVT_WARNING, "No imsbtree created.\n");
|
||||
/*return OPJ_FALSE;*/
|
||||
}
|
||||
|
||||
@ -1045,14 +1036,14 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
OPJ_BOOL opj_tcd_init_encode_tile (opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no)
|
||||
OPJ_BOOL opj_tcd_init_encode_tile (opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager)
|
||||
{
|
||||
return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_TRUE, 1.0F, sizeof(opj_tcd_cblk_enc_t));
|
||||
return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_TRUE, 1.0F, sizeof(opj_tcd_cblk_enc_t), p_manager);
|
||||
}
|
||||
|
||||
OPJ_BOOL opj_tcd_init_decode_tile (opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no)
|
||||
OPJ_BOOL opj_tcd_init_decode_tile (opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager)
|
||||
{
|
||||
return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_FALSE, 0.5F, sizeof(opj_tcd_cblk_dec_t));
|
||||
return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_FALSE, 0.5F, sizeof(opj_tcd_cblk_dec_t), p_manager);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1266,7 +1257,8 @@ OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd,
|
||||
OPJ_BYTE *p_src,
|
||||
OPJ_UINT32 p_max_length,
|
||||
OPJ_UINT32 p_tile_no,
|
||||
opj_codestream_index_t *p_cstr_index
|
||||
opj_codestream_index_t *p_cstr_index,
|
||||
opj_event_mgr_t *p_manager
|
||||
)
|
||||
{
|
||||
OPJ_UINT32 l_data_read;
|
||||
@ -1299,7 +1291,7 @@ OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd,
|
||||
/*--------------TIER2------------------*/
|
||||
/* FIXME _ProfStart(PGROUP_T2); */
|
||||
l_data_read = 0;
|
||||
if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr_index))
|
||||
if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr_index, p_manager))
|
||||
{
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -1328,7 +1320,7 @@ OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd,
|
||||
/*----------------MCT-------------------*/
|
||||
/* FIXME _ProfStart(PGROUP_MCT); */
|
||||
if
|
||||
(! opj_tcd_mct_decode(p_tcd))
|
||||
(! opj_tcd_mct_decode(p_tcd, p_manager))
|
||||
{
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -1549,7 +1541,8 @@ static OPJ_BOOL opj_tcd_t2_decode (opj_tcd_t *p_tcd,
|
||||
OPJ_BYTE * p_src_data,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_src_size,
|
||||
opj_codestream_index_t *p_cstr_index
|
||||
opj_codestream_index_t *p_cstr_index,
|
||||
opj_event_mgr_t *p_manager
|
||||
)
|
||||
{
|
||||
opj_t2_t * l_t2;
|
||||
@ -1566,7 +1559,8 @@ static OPJ_BOOL opj_tcd_t2_decode (opj_tcd_t *p_tcd,
|
||||
p_src_data,
|
||||
p_data_read,
|
||||
p_max_src_size,
|
||||
p_cstr_index)) {
|
||||
p_cstr_index,
|
||||
p_manager)) {
|
||||
opj_t2_destroy(l_t2);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -1647,7 +1641,7 @@ static OPJ_BOOL opj_tcd_dwt_decode ( opj_tcd_t *p_tcd )
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
static OPJ_BOOL opj_tcd_mct_decode ( opj_tcd_t *p_tcd )
|
||||
static OPJ_BOOL opj_tcd_mct_decode ( opj_tcd_t *p_tcd, opj_event_mgr_t *p_manager)
|
||||
{
|
||||
opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
|
||||
opj_tcp_t * l_tcp = p_tcd->tcp;
|
||||
@ -1665,7 +1659,7 @@ static OPJ_BOOL opj_tcd_mct_decode ( opj_tcd_t *p_tcd )
|
||||
if ((l_tile->comps[0].x1 - l_tile->comps[0].x0) * (l_tile->comps[0].y1 - l_tile->comps[0].y0) < (OPJ_INT32)l_samples ||
|
||||
(l_tile->comps[1].x1 - l_tile->comps[1].x0) * (l_tile->comps[1].y1 - l_tile->comps[1].y0) < (OPJ_INT32)l_samples ||
|
||||
(l_tile->comps[2].x1 - l_tile->comps[2].x0) * (l_tile->comps[2].y1 - l_tile->comps[2].y0) < (OPJ_INT32)l_samples) {
|
||||
fprintf(stderr, "Tiles don't all have the same dimension. Skip the MCT step.\n");
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Tiles don't all have the same dimension. Skip the MCT step.\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
else if (l_tcp->mct == 2) {
|
||||
@ -1717,8 +1711,7 @@ static OPJ_BOOL opj_tcd_mct_decode ( opj_tcd_t *p_tcd )
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* FIXME need to use opj_event_msg function */
|
||||
fprintf(stderr,"Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",l_tile->numcomps);
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",l_tile->numcomps);
|
||||
}
|
||||
|
||||
return OPJ_TRUE;
|
||||
|
@ -262,10 +262,11 @@ OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
|
||||
* @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.
|
||||
*/
|
||||
OPJ_BOOL opj_tcd_init_decode_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no);
|
||||
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);
|
||||
|
||||
@ -312,12 +313,14 @@ Decode a tile from a buffer into a raw image
|
||||
@param len Length of source buffer
|
||||
@param tileno Number that identifies one of the tiles to be decoded
|
||||
@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_codestream_index_t *cstr_info,
|
||||
opj_event_mgr_t *manager);
|
||||
|
||||
|
||||
/**
|
||||
@ -337,11 +340,12 @@ OPJ_UINT32 opj_tcd_get_encoded_tile_size ( opj_tcd_t *p_tcd );
|
||||
*
|
||||
* @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_UINT32 p_tile_no, opj_event_mgr_t* p_manager );
|
||||
|
||||
/**
|
||||
* Copies tile data from the given memory block onto the system.
|
||||
|
@ -45,7 +45,7 @@
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
|
||||
opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv, opj_event_mgr_t *manager) {
|
||||
OPJ_INT32 nplh[32];
|
||||
OPJ_INT32 nplv[32];
|
||||
opj_tgt_node_t *node = 00;
|
||||
@ -59,7 +59,7 @@ opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
|
||||
|
||||
tree = (opj_tgt_tree_t *) opj_calloc(1,sizeof(opj_tgt_tree_t));
|
||||
if(!tree) {
|
||||
fprintf(stderr, "ERROR in tgt_create while allocating tree\n");
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory to create Tag-tree\n");
|
||||
return 00;
|
||||
}
|
||||
|
||||
@ -81,13 +81,13 @@ opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
|
||||
/* ADD */
|
||||
if (tree->numnodes == 0) {
|
||||
opj_free(tree);
|
||||
fprintf(stderr, "WARNING in tgt_create tree->numnodes == 0, no tree created.\n");
|
||||
opj_event_msg(manager, EVT_WARNING, "tgt_create tree->numnodes == 0, no tree created.\n");
|
||||
return 00;
|
||||
}
|
||||
|
||||
tree->nodes = (opj_tgt_node_t*) opj_calloc(tree->numnodes, sizeof(opj_tgt_node_t));
|
||||
if(!tree->nodes) {
|
||||
fprintf(stderr, "ERROR in tgt_create while allocating node of the tree\n");
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory to create Tag-tree nodes\n");
|
||||
opj_free(tree);
|
||||
return 00;
|
||||
}
|
||||
@ -130,7 +130,7 @@ opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
|
||||
* @param p_num_leafs_v the height of the array of leafs of the tree
|
||||
* @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_UINT32 p_num_leafs_v)
|
||||
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)
|
||||
{
|
||||
OPJ_INT32 l_nplh[32];
|
||||
OPJ_INT32 l_nplv[32];
|
||||
@ -175,7 +175,7 @@ opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, O
|
||||
if (l_node_size > p_tree->nodes_size) {
|
||||
opj_tgt_node_t* new_nodes = (opj_tgt_node_t*) opj_realloc(p_tree->nodes, l_node_size);
|
||||
if (! new_nodes) {
|
||||
fprintf(stderr, "ERROR Not enough memory to reinitialize the tag tree\n");
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to reinitialize the tag tree\n");
|
||||
opj_tgt_destroy(p_tree);
|
||||
return 00;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ 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_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.
|
||||
@ -91,11 +91,12 @@ opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv);
|
||||
* @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
|
||||
*/
|
||||
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_UINT32 p_num_leafs_v, opj_event_mgr_t *p_manager);
|
||||
/**
|
||||
Destroy a tag-tree, liberating memory
|
||||
@param tree Tag-tree to destroy
|
||||
|
Loading…
Reference in New Issue
Block a user