#ifdef USE_JPWL
/* update markers struct */
/*
- j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOC, p_stream_tell(p_stream) - 2, 2);
+ opj_bool res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOC, p_stream_tell(p_stream) - 2, 2);
*/
assert( 0 && "TODO" );
#endif /* USE_JPWL */
l_cp->ppm_data_read = 0;
l_cp->ppm_data = (OPJ_BYTE *) opj_malloc(l_cp->ppm_len);
+ l_cp->ppm_buffer = l_cp->ppm_data;
if (l_cp->ppm_data == 00) {
- opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory reading ppm marker\n");
+ opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory to read ppm marker\n");
return OPJ_FALSE;
}
memset(l_cp->ppm_data,0,l_cp->ppm_len);
p_header_size-=4;
/* Increase the size of ppm_data to add the new Ippm series*/
+ assert(l_cp->ppm_data == l_cp->ppm_buffer && "We need ppm_data and ppm_buffer to be the same when reallocating");
OPJ_BYTE *new_ppm_data = (OPJ_BYTE *) opj_realloc(l_cp->ppm_data, l_cp->ppm_len + l_N_ppm);
if (! new_ppm_data) {
opj_free(l_cp->ppm_data);
l_cp->ppm_data = NULL;
+ l_cp->ppm_buffer = NULL; /* TODO: no need for a new local variable: ppm_buffer and ppm_data are enough */
l_cp->ppm_len = 0;
opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory to increase the size of ppm_data to add the new Ippm series\n");
return OPJ_FALSE;
}
l_cp->ppm_data = new_ppm_data;
+ l_cp->ppm_buffer = l_cp->ppm_data;
/* Keep the position of the place where concatenate the new series*/
l_cp->ppm_data_current = &(l_cp->ppm_data[l_cp->ppm_len]);
/* Next Ippm series is a complete series ?*/
if (l_remaining_data > l_N_ppm) {
/* Increase the size of ppm_data to add the new Ippm series*/
+ assert(l_cp->ppm_data == l_cp->ppm_buffer && "We need ppm_data and ppm_buffer to be the same when reallocating");
OPJ_BYTE *new_ppm_data = (OPJ_BYTE *) opj_realloc(l_cp->ppm_data, l_cp->ppm_len + l_N_ppm);
if (! new_ppm_data) {
opj_free(l_cp->ppm_data);
l_cp->ppm_data = NULL;
+ l_cp->ppm_buffer = NULL; /* TODO: no need for a new local variable: ppm_buffer and ppm_data are enough */
l_cp->ppm_len = 0;
opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory to increase the size of ppm_data to add the new (complete) Ippm series\n");
return OPJ_FALSE;
}
l_cp->ppm_data = new_ppm_data;
+ l_cp->ppm_buffer = l_cp->ppm_data;
/* Keep the position of the place where concatenate the new series */
l_cp->ppm_data_current = &(l_cp->ppm_data[l_cp->ppm_len]);
/* Need to read an incomplete Ippm series*/
if (l_remaining_data) {
+ assert(l_cp->ppm_data == l_cp->ppm_buffer && "We need ppm_data and ppm_buffer to be the same when reallocating");
OPJ_BYTE *new_ppm_data = (OPJ_BYTE *) opj_realloc(l_cp->ppm_data, l_cp->ppm_len + l_N_ppm);
if (! new_ppm_data) {
opj_free(l_cp->ppm_data);
l_cp->ppm_data = NULL;
+ l_cp->ppm_buffer = NULL; /* TODO: no need for a new local variable: ppm_buffer and ppm_data are enough */
l_cp->ppm_len = 0;
opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory to increase the size of ppm_data to add the new (incomplete) Ippm series\n");
return OPJ_FALSE;
}
l_cp->ppm_data = new_ppm_data;
+ l_cp->ppm_buffer = l_cp->ppm_data;
/* Keep the position of the place where concatenate the new series*/
l_cp->ppm_data_current = &(l_cp->ppm_data[l_cp->ppm_len]);
#ifdef USE_JPWL
/* update markers struct */
/*
- j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOT, p_j2k->sot_start, len + 2);
+ opj_bool res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOT, p_j2k->sot_start, len + 2);
*/
assert( 0 && "TODO" );
#endif /* USE_JPWL */
/* UniPG>> */
#ifdef USE_JPWL
/* update markers struct */
- /*j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOD, p_j2k->sod_start, 2);
+ /*opj_bool res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOD, p_j2k->sod_start, 2);
*/
assert( 0 && "TODO" );
#endif /* USE_JPWL */
#ifdef USE_JPWL
/* update markers struct */
/*
- j2k_add_marker(p_j2k->cstr_info, J2K_MS_EOC, p_stream_tell(p_stream) - 2, 2);
+ opj_bool res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_EOC, p_stream_tell(p_stream) - 2, 2);
*/
#endif /* USE_JPWL */
opj_tcp_v2_t * l_current_tile = 00;
OPJ_UINT32 i;
- if
- (p_cp == 00)
+ if (p_cp == 00)
{
return;
}
- if
- (p_cp->tcps != 00)
+ if (p_cp->tcps != 00)
{
l_current_tile = p_cp->tcps;
l_nb_tiles = p_cp->th * p_cp->tw;
- for
- (i = 0; i < l_nb_tiles; ++i)
+ for (i = 0; i < l_nb_tiles; ++i)
{
opj_j2k_tcp_destroy(l_current_tile);
++l_current_tile;
opj_free(p_cp->tcps);
p_cp->tcps = 00;
}
- if
- (p_cp->ppm_buffer != 00)
+ opj_free(p_cp->ppm_buffer);
+ p_cp->ppm_buffer = 00;
+ p_cp->ppm_data = NULL; /* ppm_data belongs to the allocated buffer pointed by ppm_buffer */
+ opj_free(p_cp->comment);
+ p_cp->comment = 00;
+ if (! p_cp->m_is_decoder)
{
- opj_free(p_cp->ppm_buffer);
- p_cp->ppm_buffer = 00;
- }
- if
- (p_cp->comment != 00)
- {
- opj_free(p_cp->comment);
- p_cp->comment = 00;
- }
- if
- (! p_cp->m_is_decoder)
- {
- if
- (p_cp->m_specific_param.m_enc.m_matrice)
- {
- opj_free(p_cp->m_specific_param.m_enc.m_matrice);
- p_cp->m_specific_param.m_enc.m_matrice = 00;
- }
+ opj_free(p_cp->m_specific_param.m_enc.m_matrice);
+ p_cp->m_specific_param.m_enc.m_matrice = 00;
}
}