[trunk] Fix all C90 issues using gcc -pedantic -Wno-long-long to track them

As a side effect, fix all comment style to remove extra gcc output

Fixes issue 173
This commit is contained in:
Mathieu Malaterre 2012-09-10 09:04:47 +00:00
parent 3135642ff5
commit 20beb093a1
11 changed files with 193 additions and 176 deletions

View File

@ -811,7 +811,7 @@ int main(int argc, char **argv)
}
if (!parameters.nb_tile_to_decode) {
// Optional if you want decode the entire image
/* Optional if you want decode the entire image */
if (!opj_set_decode_area(l_codec, image, parameters.DA_x0,
parameters.DA_y0, parameters.DA_x1, parameters.DA_y1)){
fprintf(stderr, "ERROR -> j2k_to_image: failed to set the decoded area\n");
@ -834,7 +834,7 @@ int main(int argc, char **argv)
}
else {
// It is just here to illustrate how to use the resolution after set parameters
/* It is just here to illustrate how to use the resolution after set parameters */
/*if (!opj_set_decoded_resolution_factor(l_codec, 5)) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to set the resolution factor tile!\n");
opj_destroy_codec(l_codec);

View File

@ -66,7 +66,7 @@ _itoa(int i, char *a, int r) {
* Default callback function.
* Do nothing.
*/
static void opj_default_callback (const char *msg, void *client_data){};
static void opj_default_callback (const char *msg, void *client_data){}
/* ----------------------------------------------------------------------- */
opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {

View File

@ -40,21 +40,23 @@ used for
<li>Debugging messages
</ul>
*/
//typedef struct opj_event_mgr
//{
// /** Data to call the event manager upon */
// void * m_error_data;
// /** Data to call the event manager upon */
// void * m_warning_data;
// /** Data to call the event manager upon */
// void * m_info_data;
// /** Error message callback if available, NULL otherwise */
// opj_msg_callback error_handler;
// /** Warning message callback if available, NULL otherwise */
// opj_msg_callback warning_handler;
// /** Debug message callback if available, NULL otherwise */
// opj_msg_callback info_handler;
//} opj_event_mgr_t;
#if 0
typedef struct opj_event_mgr
{
/** Data to call the event manager upon */
void * m_error_data;
/** Data to call the event manager upon */
void * m_warning_data;
/** Data to call the event manager upon */
void * m_info_data;
/** Error message callback if available, NULL otherwise */
opj_msg_callback error_handler;
/** Warning message callback if available, NULL otherwise */
opj_msg_callback warning_handler;
/** Debug message callback if available, NULL otherwise */
opj_msg_callback info_handler;
} opj_event_mgr_t;
#endif
#define EVT_ERROR 1 /**< Error event type */
#define EVT_WARNING 2 /**< Warning event type */

View File

@ -1465,18 +1465,18 @@ opj_bool opj_j2k_check_poc_val( const opj_poc_t *p_pocs,
}
index = step_r * p_pocs->resno0;
// take each resolution for each poc
/* take each resolution for each poc */
for (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno)
{
OPJ_UINT32 res_index = index + p_pocs->compno0 * step_c;
// take each comp of each resolution for each poc
/* take each comp of each resolution for each poc */
for (compno = p_pocs->compno0 ; compno < p_pocs->compno1 ; ++compno) {
OPJ_UINT32 comp_index = res_index + layno0 * step_l;
// and finally take each layer of each res of ...
/* and finally take each layer of each res of ... */
for (layno = layno0; layno < p_pocs->layno1 ; ++layno) {
//index = step_r * resno + step_c * compno + step_l * layno;
/*index = step_r * resno + step_c * compno + step_l * layno;*/
packet_array[comp_index] = 1;
comp_index += step_l;
}
@ -1488,24 +1488,24 @@ opj_bool opj_j2k_check_poc_val( const opj_poc_t *p_pocs,
}
++p_pocs;
// iterate through all the pocs
/* iterate through all the pocs */
for (i = 1; i < p_nb_pocs ; ++i) {
OPJ_UINT32 l_last_layno1 = (p_pocs-1)->layno1 ;
layno0 = (p_pocs->layno1 > l_last_layno1)? l_last_layno1 : 0;
index = step_r * p_pocs->resno0;
// take each resolution for each poc
/* take each resolution for each poc */
for (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno) {
OPJ_UINT32 res_index = index + p_pocs->compno0 * step_c;
// take each comp of each resolution for each poc
/* take each comp of each resolution for each poc */
for (compno = p_pocs->compno0 ; compno < p_pocs->compno1 ; ++compno) {
OPJ_UINT32 comp_index = res_index + layno0 * step_l;
// and finally take each layer of each res of ...
/* and finally take each layer of each res of ... */
for (layno = layno0; layno < p_pocs->layno1 ; ++layno) {
//index = step_r * resno + step_c * compno + step_l * layno;
/*index = step_r * resno + step_c * compno + step_l * layno;*/
packet_array[comp_index] = 1;
comp_index += step_l;
}
@ -1524,7 +1524,7 @@ opj_bool opj_j2k_check_poc_val( const opj_poc_t *p_pocs,
for (resno = 0; resno < p_nb_resolutions; ++resno) {
for (compno = 0; compno < p_num_comps; ++compno) {
loss |= (packet_array[index]!=1);
//index = step_r * resno + step_c * compno + step_l * layno;
/*index = step_r * resno + step_c * compno + step_l * layno;*/
index += step_c;
}
}
@ -2174,7 +2174,7 @@ opj_bool opj_j2k_write_com( opj_j2k_v2_t *p_j2k,
const OPJ_CHAR *l_comment;
OPJ_BYTE * l_current_ptr = 00;
// preconditions
/* preconditions */
assert(p_j2k != 00);
assert(p_stream != 00);
assert(p_manager != 00);
@ -2419,12 +2419,13 @@ opj_bool opj_j2k_write_coc( opj_j2k_v2_t *p_j2k,
l_coc_size = 5 + l_comp_room + opj_j2k_get_SPCod_SPCoc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
if (l_coc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
OPJ_BYTE *new_header_tile_data;
p_j2k->m_specific_param.m_encoder.m_header_tile_data
= (OPJ_BYTE*)opj_realloc(
p_j2k->m_specific_param.m_encoder.m_header_tile_data,
l_coc_size);
OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_coc_size);
new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_coc_size);
if (! new_header_tile_data) {
opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
@ -2851,7 +2852,7 @@ opj_bool opj_j2k_write_poc( opj_j2k_v2_t *p_j2k,
opj_tccp_t *l_tccp = 00;
OPJ_UINT32 l_poc_room;
// preconditions
/* preconditions */
assert(p_j2k != 00);
assert(p_manager != 00);
assert(p_stream != 00);
@ -3501,13 +3502,14 @@ opj_bool j2k_read_ppm_v3 (
l_N_ppm = l_cp->ppm_len - l_cp->ppm_data_read;
}
else {
OPJ_BYTE *new_ppm_data;
opj_read_bytes(p_header_data,&l_N_ppm,4); /* First N_ppm */
p_header_data+=4;
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);
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;
@ -3551,9 +3553,10 @@ opj_bool j2k_read_ppm_v3 (
/* Next Ippm series is a complete series ?*/
if (l_remaining_data > l_N_ppm) {
OPJ_BYTE *new_ppm_data;
/* 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);
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;
@ -3574,8 +3577,9 @@ opj_bool j2k_read_ppm_v3 (
/* Need to read an incomplete Ippm series*/
if (l_remaining_data) {
OPJ_BYTE *new_ppm_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);
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;
@ -3706,9 +3710,10 @@ static opj_bool opj_j2k_read_ppt ( opj_j2k_v2_t *p_j2k,
/* memset(l_tcp->ppt_buffer,0,l_tcp->ppt_len); */
}
else {
OPJ_BYTE *new_ppt_buffer;
l_tcp->ppt_len += p_header_size;
OPJ_BYTE *new_ppt_buffer = (OPJ_BYTE *) opj_realloc(l_tcp->ppt_buffer, l_tcp->ppt_len);
new_ppt_buffer = (OPJ_BYTE *) opj_realloc(l_tcp->ppt_buffer, l_tcp->ppt_len);
if (! new_ppt_buffer) {
opj_free(l_tcp->ppt_buffer);
l_tcp->ppt_buffer = NULL;
@ -3738,7 +3743,7 @@ opj_bool opj_j2k_write_tlm( opj_j2k_v2_t *p_j2k,
OPJ_BYTE * l_current_data = 00;
OPJ_UINT32 l_tlm_size;
// preconditions
/* preconditions */
assert(p_j2k != 00);
assert(p_manager != 00);
assert(p_stream != 00);
@ -3761,7 +3766,7 @@ opj_bool opj_j2k_write_tlm( opj_j2k_v2_t *p_j2k,
l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
/* change the way data is written to avoid seeking if possible */
// TODO
/* TODO */
p_j2k->m_specific_param.m_encoder.m_tlm_start = opj_stream_tell(p_stream);
opj_write_bytes(l_current_data,J2K_MS_TLM,2); /* TLM */
@ -4017,8 +4022,9 @@ opj_bool opj_j2k_read_sot ( opj_j2k_v2_t *p_j2k,
}
if ( l_current_part >= p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps ){
opj_tp_index_t *new_tp_index;
p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps += 10;
opj_tp_index_t *new_tp_index = (opj_tp_index_t *) opj_realloc(
new_tp_index = (opj_tp_index_t *) opj_realloc(
p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index,
p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps * sizeof(opj_tp_index_t));
if (! new_tp_index) {
@ -4190,10 +4196,10 @@ opj_bool opj_j2k_read_sod (opj_j2k_v2_t *p_j2k,
OPJ_BYTE *l_new_current_data = (OPJ_BYTE *) opj_realloc(*l_current_data, *l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_length);
if (! l_new_current_data) {
opj_free(*l_current_data);
// nothing more is done as l_current_data will be set to null, and just
// afterward we enter in the error path
// and the actual tile_len is updated (committed) at the end of the
// function.
/*nothing more is done as l_current_data will be set to null, and just
afterward we enter in the error path
and the actual tile_len is updated (committed) at the end of the
function. */
}
*l_current_data = l_new_current_data;
}
@ -4964,9 +4970,10 @@ static opj_bool opj_j2k_read_mct ( opj_j2k_v2_t *p_j2k,
/* NOT FOUND */
if (i == l_tcp->m_nb_mct_records) {
if (l_tcp->m_nb_mct_records == l_tcp->m_nb_max_mct_records) {
opj_mct_data_t *new_mct_records;
l_tcp->m_nb_max_mct_records += J2K_MCT_DEFAULT_NB_RECORDS;
opj_mct_data_t *new_mct_records = (opj_mct_data_t *) opj_realloc(l_tcp->m_mct_records, l_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
new_mct_records = (opj_mct_data_t *) opj_realloc(l_tcp->m_mct_records, l_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
if (! new_mct_records) {
opj_free(l_tcp->m_mct_records);
l_tcp->m_mct_records = NULL;
@ -5174,9 +5181,10 @@ opj_bool opj_j2k_read_mcc ( opj_j2k_v2_t *p_j2k,
/** NOT FOUND */
if (i == l_tcp->m_nb_mcc_records) {
if (l_tcp->m_nb_mcc_records == l_tcp->m_nb_max_mcc_records) {
opj_simple_mcc_decorrelation_data_t *new_mcc_records;
l_tcp->m_nb_max_mcc_records += J2K_MCC_DEFAULT_NB_RECORDS;
opj_simple_mcc_decorrelation_data_t *new_mcc_records = (opj_simple_mcc_decorrelation_data_t *) opj_realloc(
new_mcc_records = (opj_simple_mcc_decorrelation_data_t *) opj_realloc(
l_tcp->m_mcc_records, l_tcp->m_nb_max_mcc_records * sizeof(opj_simple_mcc_decorrelation_data_t));
if (! new_mcc_records) {
opj_free(l_tcp->m_mcc_records);
@ -5844,7 +5852,7 @@ void opj_j2k_setup_encoder( opj_j2k_v2_t *p_j2k,
if (parameters->numpocs) {
/* initialisation of POC */
l_res = opj_j2k_check_poc_val(parameters->POC,parameters->numpocs, parameters->numresolution, image->numcomps, parameters->tcp_numlayers, p_manager);
// TODO
/* TODO */
}
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
@ -5876,7 +5884,7 @@ void opj_j2k_setup_encoder( opj_j2k_v2_t *p_j2k,
if (parameters->numpocs) {
/* initialisation of POC */
tcp->POC = 1;
// TODO
/* TODO */
for (i = 0; i < (unsigned int) parameters->numpocs; i++) {
if((tileno == parameters->POC[i].tile - 1) || (parameters->POC[i].tile == -1)) {
opj_poc_t *tcp_poc = &tcp->pocs[numpocs_tile];
@ -5962,10 +5970,10 @@ void opj_j2k_setup_encoder( opj_j2k_v2_t *p_j2k,
}
if(parameters->cp_cinema) {
//Precinct size for lowest frequency subband=128
/*Precinct size for lowest frequency subband=128*/
tccp->prcw[0] = 7;
tccp->prch[0] = 7;
//Precinct size at all other resolutions = 256
/*Precinct size at all other resolutions = 256*/
for (j = 1; j < tccp->numresolutions; j++) {
tccp->prcw[j] = 8;
tccp->prch[j] = 8;
@ -6007,7 +6015,7 @@ void opj_j2k_setup_encoder( opj_j2k_v2_t *p_j2k,
}
p++;
/*printf("\nsize precinct for level %d : %d,%d\n", it_res,tccp->prcw[it_res], tccp->prch[it_res]); */
} //end for
} /*end for*/
} else {
for (j = 0; j < tccp->numresolutions; j++) {
tccp->prcw[j] = 15;
@ -6032,8 +6040,9 @@ static opj_bool opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index, OPJ_UIN
/* expand the list? */
if ((cstr_index->marknum + 1) > cstr_index->maxmarknum) {
opj_marker_info_t *new_marker;
cstr_index->maxmarknum = 100 + (int) ((float) cstr_index->maxmarknum * 1.0F);
opj_marker_info_t *new_marker = (opj_marker_info_t *) opj_realloc(cstr_index->marker, cstr_index->maxmarknum *sizeof(opj_marker_info_t));
new_marker = (opj_marker_info_t *) opj_realloc(cstr_index->marker, cstr_index->maxmarknum *sizeof(opj_marker_info_t));
if (! new_marker) {
opj_free(cstr_index->marker);
cstr_index->marker = NULL;
@ -6060,8 +6069,9 @@ static opj_bool opj_j2k_add_tlmarker(OPJ_UINT32 tileno, opj_codestream_index_t *
/* expand the list? */
if ((cstr_index->tile_index[tileno].marknum + 1) > cstr_index->tile_index[tileno].maxmarknum) {
opj_marker_info_t *new_marker;
cstr_index->tile_index[tileno].maxmarknum = 100 + (int) ((float) cstr_index->tile_index[tileno].maxmarknum * 1.0F);
opj_marker_info_t *new_marker = (opj_marker_info_t *) opj_realloc(
new_marker = (opj_marker_info_t *) opj_realloc(
cstr_index->tile_index[tileno].marker,
cstr_index->tile_index[tileno].maxmarknum *sizeof(opj_marker_info_t));
if (! new_marker) {
@ -6226,7 +6236,7 @@ opj_bool opj_j2k_setup_mct_encoding(opj_tcp_v2_t * p_tcp, opj_image_t * p_image)
OPJ_FLOAT32 * l_data, * l_current_data;
opj_tccp_t * l_tccp;
// preconditions
/* preconditions */
assert(p_tcp != 00);
if (p_tcp->mct != 2) {
@ -6235,9 +6245,10 @@ opj_bool opj_j2k_setup_mct_encoding(opj_tcp_v2_t * p_tcp, opj_image_t * p_image)
if (p_tcp->m_mct_decoding_matrix) {
if (p_tcp->m_nb_mct_records == p_tcp->m_nb_max_mct_records) {
opj_mct_data_t *new_mct_records;
p_tcp->m_nb_max_mct_records += J2K_MCT_DEFAULT_NB_RECORDS;
opj_mct_data_t *new_mct_records = (opj_mct_data_t *) opj_realloc(p_tcp->m_mct_records, p_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
new_mct_records = (opj_mct_data_t *) opj_realloc(p_tcp->m_mct_records, p_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
if (! new_mct_records) {
opj_free(p_tcp->m_mct_records);
p_tcp->m_mct_records = NULL;
@ -6276,8 +6287,9 @@ opj_bool opj_j2k_setup_mct_encoding(opj_tcp_v2_t * p_tcp, opj_image_t * p_image)
}
if (p_tcp->m_nb_mct_records == p_tcp->m_nb_max_mct_records) {
opj_mct_data_t *new_mct_records;
p_tcp->m_nb_max_mct_records += J2K_MCT_DEFAULT_NB_RECORDS;
opj_mct_data_t *new_mct_records = (opj_mct_data_t *) opj_realloc(p_tcp->m_mct_records, p_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
new_mct_records = (opj_mct_data_t *) opj_realloc(p_tcp->m_mct_records, p_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
if (! new_mct_records) {
opj_free(p_tcp->m_mct_records);
p_tcp->m_mct_records = NULL;
@ -6338,8 +6350,9 @@ opj_bool opj_j2k_setup_mct_encoding(opj_tcp_v2_t * p_tcp, opj_image_t * p_image)
++p_tcp->m_nb_mct_records;
if (p_tcp->m_nb_mcc_records == p_tcp->m_nb_max_mcc_records) {
opj_simple_mcc_decorrelation_data_t *new_mcc_records;
p_tcp->m_nb_max_mcc_records += J2K_MCT_DEFAULT_NB_RECORDS;
opj_simple_mcc_decorrelation_data_t *new_mcc_records = (opj_simple_mcc_decorrelation_data_t *) opj_realloc(
new_mcc_records = (opj_simple_mcc_decorrelation_data_t *) opj_realloc(
p_tcp->m_mcc_records, p_tcp->m_nb_max_mcc_records * sizeof(opj_simple_mcc_decorrelation_data_t));
if (! new_mcc_records) {
opj_free(p_tcp->m_mcc_records);
@ -8779,8 +8792,8 @@ static opj_bool opj_j2k_decode_one_tile ( opj_j2k_v2_t *p_j2k,
if (! l_new_current_data) {
opj_free(l_current_data);
l_current_data = NULL;
// TODO: LH: why tile numbering policy used in messages differs from
// the one used in opj_j2k_decode_tiles() ?
/* TODO: LH: why tile numbering policy used in messages differs from
the one used in opj_j2k_decode_tiles() ? */
opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory to decode tile %d/%d\n", l_current_tile_no, (p_j2k->m_cp.th * p_j2k->m_cp.tw) - 1);
return OPJ_FALSE;
}
@ -9071,7 +9084,7 @@ opj_bool opj_j2k_start_compress(opj_j2k_v2_t *p_j2k,
p_j2k->m_private_image = opj_image_create0();
opj_copy_image_header(p_image, p_j2k->m_private_image);
// TODO_MSD: Find a better way
/* TODO_MSD: Find a better way */
if (p_image->comps) {
OPJ_UINT32 it_comp;
for (it_comp = 0 ; it_comp < p_image->numcomps; it_comp++) {

View File

@ -527,7 +527,7 @@ OPJ_BYTE * opj_jp2_write_ihdr(opj_jp2_v2_t *jp2,
{
unsigned char * l_ihdr_data,* l_current_ihdr_ptr;
// preconditions
/* preconditions */
assert(jp2 != 00);
assert(p_nb_bytes_written != 00);
@ -581,7 +581,7 @@ OPJ_BYTE * opj_jp2_write_bpcc( opj_jp2_v2_t *jp2,
int l_bpcc_size = 8 + jp2->numcomps;
unsigned char * l_bpcc_data,* l_current_bpcc_ptr;
// preconditions
/* preconditions */
assert(jp2 != 00);
assert(p_nb_bytes_written != 00);
@ -650,7 +650,7 @@ OPJ_BYTE * opj_jp2_write_colr( opj_jp2_v2_t *jp2,
unsigned int l_colr_size = 11;
unsigned char * l_colr_data,* l_current_colr_ptr;
// preconditions
/* preconditions */
assert(jp2 != 00);
assert(p_nb_bytes_written != 00);
@ -1124,7 +1124,7 @@ opj_bool opj_jp2_write_jp2h(opj_jp2_v2_t *jp2,
/* to store the data of the super box */
unsigned char l_jp2h_data [8];
// preconditions
/* preconditions */
assert(stream != 00);
assert(jp2 != 00);
assert(p_manager != 00);
@ -1215,7 +1215,7 @@ opj_bool opj_jp2_write_ftyp(opj_jp2_v2_t *jp2,
unsigned char * l_ftyp_data, * l_current_data_ptr;
opj_bool l_result;
// preconditions
/* preconditions */
assert(cio != 00);
assert(jp2 != 00);
assert(p_manager != 00);
@ -1265,7 +1265,7 @@ opj_bool opj_jp2_write_jp2c(opj_jp2_v2_t *jp2,
OPJ_OFF_T j2k_codestream_exit;
OPJ_BYTE l_data_header [8];
// preconditions
/* preconditions */
assert(jp2 != 00);
assert(cio != 00);
assert(p_manager != 00);
@ -1302,7 +1302,7 @@ opj_bool opj_jp2_write_jp( opj_jp2_v2_t *jp2,
/* 12 bytes will be read */
unsigned char l_signature_data [12];
// preconditions
/* preconditions */
assert(cio != 00);
assert(jp2 != 00);
assert(p_manager != 00);
@ -1416,7 +1416,7 @@ void opj_jp2_setup_encoder( opj_jp2_v2_t *jp2,
jp2->precedence = 0; /* PRECEDENCE */
jp2->approx = 0; /* APPROX */
// jp2->jpip_on = parameters->jpip_on;
/* jp2->jpip_on = parameters->jpip_on; */
}
opj_bool opj_jp2_encode(opj_jp2_v2_t *jp2,
@ -1603,9 +1603,9 @@ opj_bool opj_jp2_read_header_procedure( opj_jp2_v2_t *jp2,
l_nb_bytes_read = opj_stream_read_data(stream,l_current_data,l_current_data_size,p_manager);
if (l_nb_bytes_read != l_current_data_size) {
opj_event_msg_v2(p_manager, EVT_ERROR, "Problem with reading JPEG2000 box, stream error\n");
// TODO: LH: why nothing is freed here (as
// all other returns imply a free, even
// in the nominal case)?
/* TODO: LH: why nothing is freed here (as
all other returns imply a free, even
in the nominal case)? */
return OPJ_FALSE;
}

View File

@ -201,15 +201,15 @@ double mct_getnorm_real(int compno) {
opj_bool mct_encode_custom(
// MCT data
/* MCT data */
OPJ_BYTE * pCodingdata,
// size of components
/* size of components */
OPJ_UINT32 n,
// components
/* components */
OPJ_BYTE ** pData,
// nb of components (i.e. size of pData)
/* nb of components (i.e. size of pData) */
OPJ_UINT32 pNbComp,
// tells if the data is signed
/* tells if the data is signed */
OPJ_UINT32 isSigned)
{
OPJ_FLOAT32 * lMct = (OPJ_FLOAT32 *) pCodingdata;

View File

@ -363,7 +363,7 @@ opj_mqc_t* mqc_create(void) {
void mqc_destroy(opj_mqc_t *mqc) {
if(mqc) {
#ifdef MQC_PERF_OPT
if (mqc->buffer) { // TODO: LH: this test is pointless as free() is a no-op on 0
if (mqc->buffer) { /* TODO: LH: this test is pointless as free() is a no-op on 0 */
opj_free(mqc->buffer);
}
#endif

View File

@ -621,15 +621,15 @@ opj_pi_iterator_t *pi_create_decode_v2( opj_image_t *p_image,
OPJ_UINT32 p_tile_no
)
{
// loop
/* loop */
OPJ_UINT32 pino;
OPJ_UINT32 compno, resno;
// to store w, h, dx and dy fro all components and resolutions
/* to store w, h, dx and dy fro all components and resolutions */
OPJ_UINT32 * l_tmp_data;
OPJ_UINT32 ** l_tmp_ptr;
// encoding prameters to set
/* encoding prameters to set */
OPJ_UINT32 l_max_res;
OPJ_UINT32 l_max_prec;
OPJ_INT32 l_tx0,l_tx1,l_ty0,l_ty1;
@ -638,7 +638,7 @@ opj_pi_iterator_t *pi_create_decode_v2( opj_image_t *p_image,
OPJ_UINT32 l_step_p , l_step_c , l_step_r , l_step_l ;
OPJ_UINT32 l_data_stride;
// pointers
/* pointers */
opj_pi_iterator_t *l_pi = 00;
opj_tcp_v2_t *l_tcp = 00;
const opj_tccp_t *l_tccp = 00;
@ -647,12 +647,12 @@ opj_pi_iterator_t *pi_create_decode_v2( opj_image_t *p_image,
opj_pi_iterator_t * l_current_pi = 00;
OPJ_UINT32 * l_encoding_value_ptr = 00;
// preconditions in debug
/* preconditions in debug */
assert(p_cp != 00);
assert(p_image != 00);
assert(p_tile_no < p_cp->tw * p_cp->th);
// initializations
/* initializations */
l_tcp = &p_cp->tcps[p_tile_no];
l_bound = l_tcp->numpocs+1;
@ -673,7 +673,7 @@ opj_pi_iterator_t *pi_create_decode_v2( opj_image_t *p_image,
return 00;
}
// memory allocation for pi
/* memory allocation for pi */
l_pi = pi_create(p_image, p_cp, p_tile_no);
if (!l_pi) {
opj_free(l_tmp_data);
@ -682,26 +682,26 @@ opj_pi_iterator_t *pi_create_decode_v2( opj_image_t *p_image,
}
l_encoding_value_ptr = l_tmp_data;
// update pointer array
/* update pointer array */
for
(compno = 0; compno < p_image->numcomps; ++compno)
{
l_tmp_ptr[compno] = l_encoding_value_ptr;
l_encoding_value_ptr += l_data_stride;
}
// get encoding parameters
/* get encoding parameters */
get_all_encoding_parameters(p_image,p_cp,p_tile_no,&l_tx0,&l_tx1,&l_ty0,&l_ty1,&l_dx_min,&l_dy_min,&l_max_prec,&l_max_res,l_tmp_ptr);
// step calculations
/* step calculations */
l_step_p = 1;
l_step_c = l_max_prec * l_step_p;
l_step_r = p_image->numcomps * l_step_c;
l_step_l = l_max_res * l_step_r;
// set values for first packet iterator
/* set values for first packet iterator */
l_current_pi = l_pi;
// memory allocation for include
/* memory allocation for include */
l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16));
if
(!l_current_pi->include)
@ -713,7 +713,7 @@ opj_pi_iterator_t *pi_create_decode_v2( opj_image_t *p_image,
}
memset(l_current_pi->include,0, (l_tcp->numlayers + 1) * l_step_l* sizeof(OPJ_INT16));
// special treatment for the first packet iterator
/* special treatment for the first packet iterator */
l_current_comp = l_current_pi->comps;
l_img_comp = p_image->comps;
l_tccp = l_tcp->tccps;
@ -723,8 +723,8 @@ opj_pi_iterator_t *pi_create_decode_v2( opj_image_t *p_image,
l_current_pi->tx1 = l_tx1;
l_current_pi->ty1 = l_ty1;
//l_current_pi->dx = l_img_comp->dx;
//l_current_pi->dy = l_img_comp->dy;
/*l_current_pi->dx = l_img_comp->dx;*/
/*l_current_pi->dy = l_img_comp->dy;*/
l_current_pi->step_p = l_step_p;
l_current_pi->step_c = l_step_c;
@ -767,8 +767,8 @@ opj_pi_iterator_t *pi_create_decode_v2( opj_image_t *p_image,
l_current_pi->ty0 = l_ty0;
l_current_pi->tx1 = l_tx1;
l_current_pi->ty1 = l_ty1;
//l_current_pi->dx = l_dx_min;
//l_current_pi->dy = l_dy_min;
/*l_current_pi->dx = l_dx_min;*/
/*l_current_pi->dy = l_dy_min;*/
l_current_pi->step_p = l_step_p;
l_current_pi->step_c = l_step_c;
l_current_pi->step_r = l_step_r;
@ -797,7 +797,7 @@ opj_pi_iterator_t *pi_create_decode_v2( opj_image_t *p_image,
++l_img_comp;
++l_tccp;
}
// special treatment
/* special treatment*/
l_current_pi->include = (l_current_pi-1)->include;
++l_current_pi;
}
@ -967,15 +967,15 @@ opj_pi_iterator_t *pi_initialise_encode_v2(
J2K_T2_MODE p_t2_mode
)
{
// loop
/* loop*/
OPJ_UINT32 pino;
OPJ_UINT32 compno, resno;
// to store w, h, dx and dy fro all components and resolutions
/* to store w, h, dx and dy fro all components and resolutions*/
OPJ_UINT32 * l_tmp_data;
OPJ_UINT32 ** l_tmp_ptr;
// encoding prameters to set
/* encoding prameters to set*/
OPJ_UINT32 l_max_res;
OPJ_UINT32 l_max_prec;
OPJ_INT32 l_tx0,l_tx1,l_ty0,l_ty1;
@ -984,7 +984,7 @@ opj_pi_iterator_t *pi_initialise_encode_v2(
OPJ_UINT32 l_step_p , l_step_c , l_step_r , l_step_l ;
OPJ_UINT32 l_data_stride;
// pointers
/* pointers*/
opj_pi_iterator_t *l_pi = 00;
opj_tcp_v2_t *l_tcp = 00;
const opj_tccp_t *l_tccp = 00;
@ -993,12 +993,12 @@ opj_pi_iterator_t *pi_initialise_encode_v2(
opj_pi_iterator_t * l_current_pi = 00;
OPJ_UINT32 * l_encoding_value_ptr = 00;
// preconditions in debug
/* preconditions in debug*/
assert(p_cp != 00);
assert(p_image != 00);
assert(p_tile_no < p_cp->tw * p_cp->th);
// initializations
/* initializations*/
l_tcp = &p_cp->tcps[p_tile_no];
l_bound = l_tcp->numpocs+1;
@ -1016,7 +1016,7 @@ opj_pi_iterator_t *pi_initialise_encode_v2(
return 00;
}
// memory allocation for pi
/* memory allocation for pi*/
l_pi = pi_create(p_image,p_cp,p_tile_no);
if (!l_pi) {
opj_free(l_tmp_data);
@ -1025,26 +1025,26 @@ opj_pi_iterator_t *pi_initialise_encode_v2(
}
l_encoding_value_ptr = l_tmp_data;
// update pointer array
/* update pointer array*/
for (compno = 0; compno < p_image->numcomps; ++compno) {
l_tmp_ptr[compno] = l_encoding_value_ptr;
l_encoding_value_ptr += l_data_stride;
}
// get encoding parameters
/* get encoding parameters*/
get_all_encoding_parameters(p_image,p_cp,p_tile_no,&l_tx0,&l_tx1,&l_ty0,&l_ty1,&l_dx_min,&l_dy_min,&l_max_prec,&l_max_res,l_tmp_ptr);
// step calculations
/* step calculations*/
l_step_p = 1;
l_step_c = l_max_prec * l_step_p;
l_step_r = p_image->numcomps * l_step_c;
l_step_l = l_max_res * l_step_r;
// set values for first packet iterator
/* set values for first packet iterator*/
l_pi->tp_on = p_cp->m_specific_param.m_enc.m_tp_on;
l_current_pi = l_pi;
// memory allocation for include
/* memory allocation for include*/
l_current_pi->include = (OPJ_INT16*) opj_calloc(l_tcp->numlayers * l_step_l, sizeof(OPJ_INT16));
if (!l_current_pi->include) {
opj_free(l_tmp_data);
@ -1054,7 +1054,7 @@ opj_pi_iterator_t *pi_initialise_encode_v2(
}
memset(l_current_pi->include,0,l_tcp->numlayers * l_step_l* sizeof(OPJ_INT16));
// special treatment for the first packet iterator
/* special treatment for the first packet iterator*/
l_current_comp = l_current_pi->comps;
l_img_comp = p_image->comps;
l_tccp = l_tcp->tccps;
@ -1128,7 +1128,7 @@ opj_pi_iterator_t *pi_initialise_encode_v2(
++l_tccp;
}
// special treatment
/* special treatment*/
l_current_pi->include = (l_current_pi-1)->include;
++l_current_pi;
}
@ -1604,31 +1604,31 @@ void get_all_encoding_parameters(
OPJ_UINT32 ** p_resolutions
)
{
// loop
/* loop*/
OPJ_UINT32 compno, resno;
// pointers
/* pointers*/
const opj_tcp_v2_t *tcp = 00;
const opj_tccp_t * l_tccp = 00;
const opj_image_comp_t * l_img_comp = 00;
// to store l_dx, l_dy, w and h for each resolution and component.
/* to store l_dx, l_dy, w and h for each resolution and component.*/
OPJ_UINT32 * lResolutionPtr;
// position in x and y of tile
/* position in x and y of tile*/
OPJ_UINT32 p, q;
// preconditions in debug
/* preconditions in debug*/
assert(p_cp != 00);
assert(p_image != 00);
assert(tileno < p_cp->tw * p_cp->th);
// initializations
/* initializations*/
tcp = &p_cp->tcps [tileno];
l_tccp = tcp->tccps;
l_img_comp = p_image->comps;
// position in x and y of tile
/* position in x and y of tile*/
p = tileno % p_cp->tw;
q = tileno / p_cp->tw;
@ -1639,18 +1639,18 @@ void get_all_encoding_parameters(
*p_ty0 = int_max(p_cp->ty0 + q * p_cp->tdy, p_image->y0);
*p_ty1 = int_min(p_cp->ty0 + (q + 1) * p_cp->tdy, p_image->y1);
// max precision and resolution is 0 (can only grow)
/* max precision and resolution is 0 (can only grow)*/
*p_max_prec = 0;
*p_max_res = 0;
// take the largest value for dx_min and dy_min
/* take the largest value for dx_min and dy_min*/
*p_dx_min = 0x7fffffff;
*p_dy_min = 0x7fffffff;
for
(compno = 0; compno < p_image->numcomps; ++compno)
{
// aritmetic variables to calculate
/* aritmetic variables to calculate*/
OPJ_UINT32 l_level_no;
OPJ_INT32 l_rx0, l_ry0, l_rx1, l_ry1;
OPJ_INT32 l_px0, l_py0, l_px1, py1;
@ -1670,23 +1670,23 @@ void get_all_encoding_parameters(
*p_max_res = l_tccp->numresolutions;
}
// use custom size for precincts
/* use custom size for precincts*/
l_level_no = l_tccp->numresolutions - 1;
for
(resno = 0; resno < l_tccp->numresolutions; ++resno)
{
OPJ_UINT32 l_dx, l_dy;
// precinct width and height
/* precinct width and height*/
l_pdx = l_tccp->prcw[resno];
l_pdy = l_tccp->prch[resno];
*lResolutionPtr++ = l_pdx;
*lResolutionPtr++ = l_pdy;
l_dx = l_img_comp->dx * (1 << (l_pdx + l_level_no));
l_dy = l_img_comp->dy * (1 << (l_pdy + l_level_no));
// take the minimum size for l_dx for each comp and resolution
/* take the minimum size for l_dx for each comp and resolution*/
*p_dx_min = int_min(*p_dx_min, l_dx);
*p_dy_min = int_min(*p_dy_min, l_dy);
// various calculations of extents
/* various calculations of extents*/
l_rx0 = int_ceildivpow2(l_tcx0, l_level_no);
l_ry0 = int_ceildivpow2(l_tcy0, l_level_no);
@ -1701,7 +1701,7 @@ void get_all_encoding_parameters(
*lResolutionPtr++ = l_pw;
*lResolutionPtr++ = l_ph;
l_product = l_pw * l_ph;
// update precision
/* update precision*/
if
(l_product > *p_max_prec)
{
@ -1718,29 +1718,29 @@ opj_pi_iterator_t * pi_create( const opj_image_t *image,
const opj_cp_v2_t *cp,
OPJ_UINT32 tileno )
{
// loop
/* loop*/
OPJ_UINT32 pino, compno;
// number of poc in the p_pi
/* number of poc in the p_pi*/
OPJ_UINT32 l_poc_bound;
// pointers to tile coding parameters and components.
/* pointers to tile coding parameters and components.*/
opj_pi_iterator_t *l_pi = 00;
opj_tcp_v2_t *tcp = 00;
const opj_tccp_t *tccp = 00;
// current packet iterator being allocated
/* current packet iterator being allocated*/
opj_pi_iterator_t *l_current_pi = 00;
// preconditions in debug
/* preconditions in debug*/
assert(cp != 00);
assert(image != 00);
assert(tileno < cp->tw * cp->th);
// initializations
/* initializations*/
tcp = &cp->tcps[tileno];
l_poc_bound = tcp->numpocs+1;
// memory allocations
/* memory allocations*/
l_pi = (opj_pi_iterator_t*) opj_calloc((l_poc_bound), sizeof(opj_pi_iterator_t));
if (!l_pi) {
return NULL;
@ -1789,27 +1789,27 @@ void pi_update_encode_poc_and_final (opj_cp_v2_t *p_cp,
OPJ_UINT32 p_dx_min,
OPJ_UINT32 p_dy_min)
{
// loop
/* loop*/
OPJ_UINT32 pino;
// tile coding parameter
/* tile coding parameter*/
opj_tcp_v2_t *l_tcp = 00;
// current poc being updated
/* current poc being updated*/
opj_poc_t * l_current_poc = 00;
// number of pocs
/* number of pocs*/
OPJ_UINT32 l_poc_bound;
// preconditions in debug
/* preconditions in debug*/
assert(p_cp != 00);
assert(p_tileno < p_cp->tw * p_cp->th);
// initializations
/* initializations*/
l_tcp = &p_cp->tcps [p_tileno];
/* number of iterations in the loop */
l_poc_bound = l_tcp->numpocs+1;
// start at first element, and to make sure the compiler will not make a calculation each time in the loop
// store a pointer to the current element to modify rather than l_tcp->pocs[i]
/* start at first element, and to make sure the compiler will not make a calculation each time in the loop
store a pointer to the current element to modify rather than l_tcp->pocs[i]*/
l_current_poc = l_tcp->pocs;
l_current_poc->compS = l_current_poc->compno0;
@ -1818,7 +1818,7 @@ void pi_update_encode_poc_and_final (opj_cp_v2_t *p_cp,
l_current_poc->resE = l_current_poc->resno1;
l_current_poc->layE = l_current_poc->layno1;
// special treatment for the first element
/* special treatment for the first element*/
l_current_poc->layS = 0;
l_current_poc->prg = l_current_poc->prg1;
l_current_poc->prcS = 0;
@ -1840,7 +1840,7 @@ void pi_update_encode_poc_and_final (opj_cp_v2_t *p_cp,
l_current_poc->layE = l_current_poc->layno1;
l_current_poc->prg = l_current_poc->prg1;
l_current_poc->prcS = 0;
// special treatment here different from the first element
/* special treatment here different from the first element*/
l_current_poc->layS = (l_current_poc->layE > (l_current_poc-1)->layE) ? l_current_poc->layE : 0;
l_current_poc->prcE = p_max_prec;
@ -1866,27 +1866,27 @@ void pi_update_encode_not_poc ( opj_cp_v2_t *p_cp,
OPJ_UINT32 p_dx_min,
OPJ_UINT32 p_dy_min)
{
// loop
/* loop*/
OPJ_UINT32 pino;
// tile coding parameter
/* tile coding parameter*/
opj_tcp_v2_t *l_tcp = 00;
// current poc being updated
/* current poc being updated*/
opj_poc_t * l_current_poc = 00;
// number of pocs
/* number of pocs*/
OPJ_UINT32 l_poc_bound;
// preconditions in debug
/* preconditions in debug*/
assert(p_cp != 00);
assert(p_tileno < p_cp->tw * p_cp->th);
// initializations
/* initializations*/
l_tcp = &p_cp->tcps [p_tileno];
/* number of iterations in the loop */
l_poc_bound = l_tcp->numpocs+1;
// start at first element, and to make sure the compiler will not make a calculation each time in the loop
// store a pointer to the current element to modify rather than l_tcp->pocs[i]
/* start at first element, and to make sure the compiler will not make a calculation each time in the loop
store a pointer to the current element to modify rather than l_tcp->pocs[i]*/
l_current_poc = l_tcp->pocs;
for (pino = 0; pino < l_poc_bound ; ++pino) {
@ -1924,7 +1924,7 @@ void pi_destroy_v2(
opj_free(p_pi->include);
p_pi->include = 00;
}
// TODO
/* TODO*/
for
(pino = 0; pino < p_nb_elements; ++pino)
{
@ -1954,20 +1954,20 @@ void pi_destroy_v2(
void pi_update_decode_poc (opj_pi_iterator_t * p_pi,opj_tcp_v2_t * p_tcp,OPJ_UINT32 p_max_precision,OPJ_UINT32 p_max_res)
{
// loop
/* loop*/
OPJ_UINT32 pino;
// encoding prameters to set
/* encoding prameters to set*/
OPJ_UINT32 l_bound;
opj_pi_iterator_t * l_current_pi = 00;
opj_poc_t* l_current_poc = 0;
// preconditions in debug
/* preconditions in debug*/
assert(p_pi != 00);
assert(p_tcp != 00);
// initializations
/* initializations*/
l_bound = p_tcp->numpocs+1;
l_current_pi = p_pi;
l_current_poc = p_tcp->pocs;
@ -1993,18 +1993,18 @@ void pi_update_decode_poc (opj_pi_iterator_t * p_pi,opj_tcp_v2_t * p_tcp,OPJ_UIN
void pi_update_decode_not_poc (opj_pi_iterator_t * p_pi,opj_tcp_v2_t * p_tcp,OPJ_UINT32 p_max_precision,OPJ_UINT32 p_max_res)
{
// loop
/* loop*/
OPJ_UINT32 pino;
// encoding prameters to set
/* encoding prameters to set*/
OPJ_UINT32 l_bound;
opj_pi_iterator_t * l_current_pi = 00;
// preconditions in debug
/* preconditions in debug*/
assert(p_tcp != 00);
assert(p_pi != 00);
// initializations
/* initializations*/
l_bound = p_tcp->numpocs+1;
l_current_pi = p_pi;
@ -2353,7 +2353,7 @@ OPJ_INT32 pi_check_next_level( OPJ_INT32 pos,
break;
default:
if(tcp->tx0_t == tcp->txE){
//TY
/*TY*/
if(tcp->ty0_t == tcp->tyE){
l=pi_check_next_level(i-1,cp,tileno,pino,prog);
if(l==1){
@ -2363,14 +2363,14 @@ OPJ_INT32 pi_check_next_level( OPJ_INT32 pos,
}
}else{
return 1;
}//TY
}/*TY*/
}else{
return 1;
}
break;
}//end case P
}//end switch
}//end for
}//end if
}/*end case P*/
}/*end switch*/
}/*end for*/
}/*end if*/
return 0;
}

View File

@ -1727,8 +1727,8 @@ opj_bool opj_t1_decode_cblks( opj_t1_t* t1,
}
}
}
//opj_free(cblk->segs);
//cblk->segs = 00;
/*opj_free(cblk->segs);*/
/*cblk->segs = 00;*/
} /* cblkno */
} /* precno */
} /* bandno */

View File

@ -92,7 +92,7 @@ Tier-1 coding (coding of code-block coefficients)
*/
typedef struct opj_t1 {
/** codec context */
opj_common_ptr cinfo; // TODO MSD : TO BE REMOVED
opj_common_ptr cinfo; /* TODO MSD : TO BE REMOVED */
/** MQC component */
opj_mqc_t *mqc;

View File

@ -397,7 +397,7 @@ static opj_bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, in
opj_tcd_seg_t* new_segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, (index + 1) * sizeof(opj_tcd_seg_t));
if (!new_segs) {
/* opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory to init segment #%d\n", index); */
// TODO: tell cblk has no segment (in order to update the range of valid indices)
/* TODO: tell cblk has no segment (in order to update the range of valid indices)*/
cblk->segs = NULL;
return OPJ_FALSE;
}
@ -567,7 +567,7 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
segno = 0;
if (!cblk->numsegs) {
if (OPJ_FALSE == t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 1)) {
// TODO: LH: shall we destroy bio here ?
/* TODO: LH: shall we destroy bio here ?*/
opj_event_msg(t2->cinfo, EVT_WARNING, "Not enough memory to init segment #%d\n", segno);
return -999;
}
@ -576,7 +576,7 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
if (cblk->segs[segno].numpasses == cblk->segs[segno].maxpasses) {
++segno;
if (OPJ_FALSE == t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0)) {
// TODO: LH: shall we destroy bio here ?
/* TODO: LH: shall we destroy bio here ?*/
opj_event_msg(t2->cinfo, EVT_WARNING, "Not enough memory to init segment #%d\n", segno);
return -999;
}
@ -591,7 +591,7 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
if (n > 0) {
++segno;
if (OPJ_FALSE == t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0)) {
// TODO: LH: shall we destroy bio here ?
/* TODO: LH: shall we destroy bio here ? */
opj_event_msg(t2->cinfo, EVT_WARNING, "Not enough memory to init segment #%d\n", segno);
return -999;
}
@ -660,6 +660,7 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
}
do {
unsigned char * new_data;
if (c + seg->newlen > src + len) {
return -999;
}
@ -684,12 +685,12 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
#endif /* USE_JPWL */
unsigned char * new_data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char));
new_data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char));
if (! new_data) {
opj_event_msg(t2->cinfo, EVT_ERROR, "JPWL: Not enough memory for codeblock data %d (p=%d, b=%d, r=%d, c=%d)\n",
seg->newlen, cblkno, precno, bandno, resno, compno);
cblk->data = 0;
cblk->len = 0; // TODO: LH: other things to reset ?
cblk->len = 0; /* TODO: LH: other things to reset ?*/
opj_free(cblk->data);
return -999;
}
@ -912,8 +913,8 @@ opj_bool t2_encode_packets_v2(
info_PK->start_pos = ((l_cp->m_specific_param.m_enc.m_tp_on | l_tcp->POC)&& info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1;
}
info_PK->end_pos = info_PK->start_pos + l_nb_bytes - 1;
info_PK->end_ph_pos += info_PK->start_pos - 1; // End of packet header which now only represents the distance
// to start of packet is incremented by value of start of packet
info_PK->end_ph_pos += info_PK->start_pos - 1; /* End of packet header which now only represents the distance
to start of packet is incremented by value of start of packet*/
}
cstr_info->packno++;
@ -1401,8 +1402,8 @@ static opj_bool t2_encode_packet_v2(
/* </EPH> */
/* << INDEX */
// End of packet header position. Currently only represents the distance to start of packet
// Will be updated later by incrementing with packet start value
/* End of packet header position. Currently only represents the distance to start of packet
Will be updated later by incrementing with packet start value*/
if(cstr_info && cstr_info->index_write) {
opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
info_PK->end_ph_pos = (OPJ_INT32)(c - dest);
@ -1960,9 +1961,10 @@ static opj_bool t2_init_seg_v2(opj_tcd_cblk_dec_v2_t* cblk, OPJ_UINT32 index, OP
OPJ_UINT32 l_nb_segs = index + 1;
if (l_nb_segs > cblk->m_current_max_segs) {
opj_tcd_seg_t* new_segs;
cblk->m_current_max_segs += J2K_DEFAULT_NB_SEGS;
opj_tcd_seg_t* new_segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, cblk->m_current_max_segs * sizeof(opj_tcd_seg_t));
new_segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, cblk->m_current_max_segs * sizeof(opj_tcd_seg_t));
if(! new_segs) {
opj_free(cblk->segs);
cblk->segs = NULL;