Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove comments and unused code link to MSD marked comments #874

Open
wants to merge 9 commits into
base: openjpeg-2.1
Choose a base branch
from
4 changes: 2 additions & 2 deletions src/lib/openjp2/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ 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;
}

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;
Expand Down
47 changes: 8 additions & 39 deletions src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -6491,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++) {
Expand Down Expand Up @@ -7153,9 +7142,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 */
Expand Down Expand Up @@ -8938,23 +8925,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;
}

Expand Down Expand Up @@ -10244,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++) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/openjp2/j2k.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
44 changes: 0 additions & 44 deletions src/lib/openjp2/t2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
31 changes: 6 additions & 25 deletions src/lib/openjp2/tcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@

/* ----------------------------------------------------------------------- */

/* TODO MSD: */
#ifdef TODO_MSD
#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;*/

Expand Down Expand Up @@ -1279,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;
Expand Down
5 changes: 0 additions & 5 deletions src/lib/openjp2/tcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down