From 5868e64c9c10527ff05c681dd2b6f63d2febabb8 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Sat, 10 Dec 2016 00:12:03 +0100 Subject: [PATCH 1/9] remove MSD unused code in j2k.c --- src/lib/openjp2/j2k.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index 1cff598c3..bfc318bb0 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -2577,22 +2577,6 @@ static OPJ_BOOL opj_j2k_read_cod ( opj_j2k_t *p_j2k, /* Apply the coding style to other components of the current tile or the m_default_tcp*/ opj_j2k_copy_tile_component_parameters(p_j2k); - /* Index */ -#ifdef WIP_REMOVE_MSD - if (p_j2k->cstr_info) { - /*opj_codestream_info_t *l_cstr_info = p_j2k->cstr_info;*/ - p_j2k->cstr_info->prog = l_tcp->prg; - p_j2k->cstr_info->numlayers = l_tcp->numlayers; - p_j2k->cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(l_image->numcomps * sizeof(OPJ_UINT32)); - if(!p_j2k->cstr_info->numdecompos){ - return OPJ_FALSE; - } - for (i = 0; i < l_image->numcomps; ++i) { - p_j2k->cstr_info->numdecompos[i] = l_tcp->tccps[i].numresolutions - 1; - } - } -#endif - return OPJ_TRUE; } @@ -7153,9 +7137,7 @@ static OPJ_BOOL opj_j2k_decoding_validation ( opj_j2k_t *p_j2k, /* STATE checking */ /* make sure the state is at 0 */ -#ifdef TODO_MSD - l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_NONE); -#endif + l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == 0x0000); /* POINTER validation */ @@ -8938,23 +8920,6 @@ static OPJ_BOOL opj_j2k_read_SPCod_SPCoc( opj_j2k_t *p_j2k, } } -#ifdef WIP_REMOVE_MSD - /* INDEX >> */ - if (p_j2k->cstr_info && compno == 0) { - OPJ_UINT32 l_data_size = l_tccp->numresolutions * sizeof(OPJ_UINT32); - - p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblkh = l_tccp->cblkh; - p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblkw = l_tccp->cblkw; - p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].numresolutions = l_tccp->numresolutions; - p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblksty = l_tccp->cblksty; - p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].qmfbid = l_tccp->qmfbid; - - memcpy(p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].pdx,l_tccp->prcw, l_data_size); - memcpy(p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].pdy,l_tccp->prch, l_data_size); - } - /* << INDEX */ -#endif - return OPJ_TRUE; } From 43991a806c69c3d171cbf788998c67aaf9c17c7f Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Sat, 10 Dec 2016 21:49:45 +0100 Subject: [PATCH 2/9] Check the return value of a function to return a clear error message --- src/lib/openjp2/j2k.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index bfc318bb0..dc7e43b37 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -6475,8 +6475,13 @@ OPJ_BOOL opj_j2k_setup_encoder( opj_j2k_t *p_j2k, } if (parameters->numpocs) { /* initialisation of POC */ - opj_j2k_check_poc_val(parameters->POC,parameters->numpocs, (OPJ_UINT32)parameters->numresolution, image->numcomps, (OPJ_UINT32)parameters->tcp_numlayers, p_manager); - /* TODO MSD use the return value*/ + if (!opj_j2k_check_poc_val( parameters->POC, + parameters->numpocs, + (OPJ_UINT32)parameters->numresolution, + image->numcomps, + (OPJ_UINT32)parameters->tcp_numlayers, + p_manager) ) + opj_event_msg(p_manager , EVT_ERROR, "POC values are not correct.\n"); } for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { From df7228d7e5abd44b0fba6b253498df22f5c1d374 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Sat, 10 Dec 2016 21:54:05 +0100 Subject: [PATCH 3/9] remove not useful comment --- src/lib/openjp2/j2k.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index dc7e43b37..cbe74d5f4 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -10214,7 +10214,6 @@ OPJ_BOOL opj_j2k_start_compress(opj_j2k_t *p_j2k, } opj_copy_image_header(p_image, p_j2k->m_private_image); - /* 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++) { From 969d9d2f3b15c8a71a706ac58d773e17b8e31aa4 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Sat, 10 Dec 2016 22:16:17 +0100 Subject: [PATCH 4/9] replace ifdef statement by a more clear one --- src/lib/openjp2/tcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index 7a29c4914..597025dc1 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -42,8 +42,7 @@ /* ----------------------------------------------------------------------- */ -/* TODO MSD: */ -#ifdef TODO_MSD +#ifdef TCD_DUMPÅ“ void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) { int tileno, compno, resno, bandno, precno;/*, cblkno;*/ From acc44bca9824e63536092fa5721dc18a840da179 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Sat, 10 Dec 2016 22:17:42 +0100 Subject: [PATCH 5/9] remove wrong character --- src/lib/openjp2/tcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index 597025dc1..a4dfe82a9 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -42,7 +42,7 @@ /* ----------------------------------------------------------------------- */ -#ifdef TCD_DUMPÅ“ +#ifdef TCD_DUMP void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) { int tileno, compno, resno, bandno, precno;/*, cblkno;*/ From f49e94bbcc0e8b564a0f813b1f6083c36587da3f Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Sat, 10 Dec 2016 23:25:45 +0100 Subject: [PATCH 6/9] clean the comments related to tcd_dump function --- src/lib/openjp2/tcd.c | 28 +++++----------------------- src/lib/openjp2/tcd.h | 5 ----- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index a4dfe82a9..4e85fb7b6 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -43,6 +43,11 @@ /* ----------------------------------------------------------------------- */ #ifdef TCD_DUMP +/** +Dump the content of a tcd structure +*/ +static void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t *img); + void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) { int tileno, compno, resno, bandno, precno;/*, cblkno;*/ @@ -1278,29 +1283,6 @@ OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd, p_tcd->tcd_tileno = p_tile_no; p_tcd->tcp = &(p_tcd->cp->tcps[p_tile_no]); -#ifdef TODO_MSD /* FIXME */ - /* INDEX >> */ - if(p_cstr_info) { - OPJ_UINT32 resno, compno, numprec = 0; - for (compno = 0; compno < (OPJ_UINT32) p_cstr_info->numcomps; compno++) { - opj_tcp_t *tcp = &p_tcd->cp->tcps[0]; - opj_tccp_t *tccp = &tcp->tccps[compno]; - opj_tcd_tilecomp_t *tilec_idx = &p_tcd->tcd_image->tiles->comps[compno]; - for (resno = 0; resno < tilec_idx->numresolutions; resno++) { - opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[resno]; - p_cstr_info->tile[p_tile_no].pw[resno] = res_idx->pw; - p_cstr_info->tile[p_tile_no].ph[resno] = res_idx->ph; - numprec += res_idx->pw * res_idx->ph; - p_cstr_info->tile[p_tile_no].pdx[resno] = tccp->prcw[resno]; - p_cstr_info->tile[p_tile_no].pdy[resno] = tccp->prch[resno]; - } - } - p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t *) opj_malloc(p_cstr_info->numlayers * numprec * sizeof(opj_packet_info_t)); - p_cstr_info->packno = 0; - } - /* << INDEX */ -#endif - /*--------------TIER2------------------*/ /* FIXME _ProfStart(PGROUP_T2); */ l_data_read = 0; diff --git a/src/lib/openjp2/tcd.h b/src/lib/openjp2/tcd.h index 07f8379af..7969b8d54 100644 --- a/src/lib/openjp2/tcd.h +++ b/src/lib/openjp2/tcd.h @@ -226,11 +226,6 @@ typedef struct opj_tcd /*@{*/ /* ----------------------------------------------------------------------- */ -/** -Dump the content of a tcd structure -*/ -/*void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t *img);*/ /* TODO MSD shoul use the new v2 structures */ - /** Create a new TCD handle @param p_is_decoder FIXME DOC From 0793a1d0804217ce0d5a987149654e71ccda330d Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Sat, 10 Dec 2016 23:27:19 +0100 Subject: [PATCH 7/9] remove unuseful comments --- src/lib/openjp2/bio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/openjp2/bio.c b/src/lib/openjp2/bio.c index 269769b45..3dc83f3f3 100644 --- a/src/lib/openjp2/bio.c +++ b/src/lib/openjp2/bio.c @@ -100,7 +100,7 @@ static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio) { static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) { if (bio->ct == 0) { - opj_bio_byteout(bio); /* MSD: why not check the return value of this function ? */ + opj_bio_byteout(bio); } bio->ct--; bio->buf |= b << bio->ct; @@ -108,7 +108,7 @@ static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) { static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio) { if (bio->ct == 0) { - opj_bio_bytein(bio); /* MSD: why not check the return value of this function ? */ + opj_bio_bytein(bio); } bio->ct--; return (bio->buf >> bio->ct) & 1; From 68809eee992fc36b027dedad9edbbbf40d38bf38 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Sat, 10 Dec 2016 23:28:50 +0100 Subject: [PATCH 8/9] remove unuseful comments --- src/lib/openjp2/j2k.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/openjp2/j2k.h b/src/lib/openjp2/j2k.h index 358e07396..80eaf7b26 100644 --- a/src/lib/openjp2/j2k.h +++ b/src/lib/openjp2/j2k.h @@ -357,9 +357,9 @@ typedef struct opj_cp /** Rsiz*/ OPJ_UINT16 rsiz; /** XTOsiz */ - OPJ_UINT32 tx0; /* MSD see norm */ + OPJ_UINT32 tx0; /** YTOsiz */ - OPJ_UINT32 ty0; /* MSD see norm */ + OPJ_UINT32 ty0; /** XTsiz */ OPJ_UINT32 tdx; /** YTsiz */ From 5c1e99867c3ce229828a70ca2b56e17ff9848a70 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Sat, 10 Dec 2016 23:31:48 +0100 Subject: [PATCH 9/9] remove unused code related to index recording which is not really functionnal --- src/lib/openjp2/t2.c | 44 -------------------------------------------- 1 file changed, 44 deletions(-) diff --git a/src/lib/openjp2/t2.c b/src/lib/openjp2/t2.c index 5a8d440c7..f880c1c35 100644 --- a/src/lib/openjp2/t2.c +++ b/src/lib/openjp2/t2.c @@ -244,7 +244,6 @@ OPJ_BOOL opj_t2_encode_packets( opj_t2_t* p_t2, for (poc = 0; poc < pocno ; ++poc) { OPJ_UINT32 l_tp_num = compno; - /* TODO MSD : check why this function cannot fail (cf. v1) */ opj_pi_create_encode(l_pi, l_cp,p_tile_no,poc,l_tp_num,p_tp_pos,p_t2_mode); if (l_current_pi->poc.prg == OPJ_PROG_UNKNOWN) { @@ -362,21 +361,9 @@ OPJ_BOOL opj_t2_decode_packets( opj_t2_t *p_t2, OPJ_UINT32 l_nb_bytes_read; OPJ_UINT32 l_nb_pocs = l_tcp->numpocs + 1; opj_pi_iterator_t *l_current_pi = 00; -#ifdef TODO_MSD - OPJ_UINT32 curtp = 0; - OPJ_UINT32 tp_start_packno; -#endif opj_packet_info_t *l_pack_info = 00; opj_image_comp_t* l_img_comp = 00; - OPJ_ARG_NOT_USED(p_cstr_index); - -#ifdef TODO_MSD - if (p_cstr_index) { - l_pack_info = p_cstr_index->tile_index[p_tile_no].packet; - } -#endif - /* create a packet iterator */ l_pi = opj_pi_create_decode(l_image, l_cp, p_tile_no); if (!l_pi) { @@ -446,41 +433,11 @@ OPJ_BOOL opj_t2_decode_packets( opj_t2_t *p_t2, l_current_data += l_nb_bytes_read; p_max_len -= l_nb_bytes_read; - /* INDEX >> */ -#ifdef TODO_MSD - if(p_cstr_info) { - opj_tile_info_v2_t *info_TL = &p_cstr_info->tile[p_tile_no]; - opj_packet_info_t *info_PK = &info_TL->packet[p_cstr_info->packno]; - tp_start_packno = 0; - if (!p_cstr_info->packno) { - info_PK->start_pos = info_TL->end_header + 1; - } else if (info_TL->packet[p_cstr_info->packno-1].end_pos >= (OPJ_INT32)p_cstr_info->tile[p_tile_no].tp[curtp].tp_end_pos){ /* New tile part */ - info_TL->tp[curtp].tp_numpacks = p_cstr_info->packno - tp_start_packno; /* Number of packets in previous tile-part */ - tp_start_packno = p_cstr_info->packno; - curtp++; - info_PK->start_pos = p_cstr_info->tile[p_tile_no].tp[curtp].tp_end_header+1; - } else { - info_PK->start_pos = (l_cp->m_specific_param.m_enc.m_tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[p_cstr_info->packno - 1].end_pos + 1; - } - info_PK->end_pos = info_PK->start_pos + l_nb_bytes_read - 1; - info_PK->end_ph_pos += info_PK->start_pos - 1; /* End of packet header which now only represents the distance */ - ++p_cstr_info->packno; - } -#endif - /* << INDEX */ } ++l_current_pi; opj_free(first_pass_failed); } - /* INDEX >> */ -#ifdef TODO_MSD - if - (p_cstr_info) { - p_cstr_info->tile[p_tile_no].tp[curtp].tp_numpacks = p_cstr_info->packno - tp_start_packno; /* Number of packets in last tile-part */ - } -#endif - /* << INDEX */ /* don't forget to release pi */ opj_pi_destroy(l_pi,l_nb_pocs); @@ -941,7 +898,6 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2, l_present = opj_bio_read(l_bio, 1); JAS_FPRINTF(stderr, "present=%d \n", l_present ); if (!l_present) { - /* TODO MSD: no test to control the output of this function*/ opj_bio_inalign(l_bio); l_header_data += opj_bio_numbytes(l_bio); opj_bio_destroy(l_bio);