remove deprecated v1 style function tcd_decode_tile; rename tcd_decode_tile_v2 to opj_tcd_decode_tile
remove deprecated v1 style function tcd_free_decode remove deprecated v1 style function tcd_free_decode_tile
This commit is contained in:
parent
dbc4c47b15
commit
d275fc90cf
@ -4782,7 +4782,7 @@ opj_bool opj_j2k_read_eoc ( opj_j2k_v2_t *p_j2k,
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
l_success = tcd_decode_tile_v2(l_tcd, l_tcp->m_data, l_tcp->m_data_size, i, p_j2k->cstr_index);
|
||||
l_success = opj_tcd_decode_tile(l_tcd, l_tcp->m_data, l_tcp->m_data_size, i, p_j2k->cstr_index);
|
||||
/* cleanup */
|
||||
|
||||
if (! l_success) {
|
||||
@ -7514,7 +7514,7 @@ opj_bool opj_j2k_decode_tile ( opj_j2k_v2_t * p_j2k,
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if (! tcd_decode_tile_v2( p_j2k->m_tcd,
|
||||
if (! opj_tcd_decode_tile( p_j2k->m_tcd,
|
||||
l_tcp->m_data,
|
||||
l_tcp->m_data_size,
|
||||
p_tile_index,
|
||||
|
@ -573,213 +573,6 @@ opj_bool opj_tcd_rateallocate( opj_tcd_v2_t *tcd,
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) {
|
||||
int l;
|
||||
int compno;
|
||||
int eof = 0;
|
||||
double tile_time, t1_time, dwt_time;
|
||||
opj_tcd_tile_t *tile = NULL;
|
||||
|
||||
opj_t1_t *t1 = NULL; /* T1 component */
|
||||
opj_t2_t *t2 = NULL; /* T2 component */
|
||||
|
||||
tcd->tcd_tileno = tileno;
|
||||
tcd->tcd_tile = &(tcd->tcd_image->tiles[tileno]);
|
||||
tcd->tcp = &(tcd->cp->tcps[tileno]);
|
||||
tile = tcd->tcd_tile;
|
||||
|
||||
tile_time = opj_clock(); /* time needed to decode a tile */
|
||||
opj_event_msg(tcd->cinfo, EVT_INFO, "tile %d of %d\n", tileno + 1, tcd->cp->tw * tcd->cp->th);
|
||||
|
||||
/* INDEX >> */
|
||||
if(cstr_info) {
|
||||
int resno, compno, numprec = 0;
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
opj_tcp_t *tcp = &tcd->cp->tcps[0];
|
||||
opj_tccp_t *tccp = &tcp->tccps[compno];
|
||||
opj_tcd_tilecomp_t *tilec_idx = &tile->comps[compno];
|
||||
for (resno = 0; resno < tilec_idx->numresolutions; resno++) {
|
||||
opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[resno];
|
||||
cstr_info->tile[tileno].pw[resno] = res_idx->pw;
|
||||
cstr_info->tile[tileno].ph[resno] = res_idx->ph;
|
||||
numprec += res_idx->pw * res_idx->ph;
|
||||
if (tccp->csty & J2K_CP_CSTY_PRT) {
|
||||
cstr_info->tile[tileno].pdx[resno] = tccp->prcw[resno];
|
||||
cstr_info->tile[tileno].pdy[resno] = tccp->prch[resno];
|
||||
}
|
||||
else {
|
||||
cstr_info->tile[tileno].pdx[resno] = 15;
|
||||
cstr_info->tile[tileno].pdy[resno] = 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
cstr_info->tile[tileno].packet = (opj_packet_info_t *) opj_malloc(cstr_info->numlayers * numprec * sizeof(opj_packet_info_t));
|
||||
cstr_info->packno = 0;
|
||||
}
|
||||
/* << INDEX */
|
||||
|
||||
/*--------------TIER2------------------*/
|
||||
|
||||
t2 = t2_create(tcd->cinfo, tcd->image, tcd->cp);
|
||||
l = t2_decode_packets(t2, src, len, tileno, tile, cstr_info);
|
||||
t2_destroy(t2);
|
||||
|
||||
if (l == -999) {
|
||||
eof = 1;
|
||||
opj_event_msg(tcd->cinfo, EVT_ERROR, "tcd_decode: incomplete bistream\n");
|
||||
}
|
||||
|
||||
/*------------------TIER1-----------------*/
|
||||
|
||||
t1_time = opj_clock(); /* time needed to decode a tile */
|
||||
t1 = t1_create(tcd->cinfo);
|
||||
for (compno = 0; compno < tile->numcomps; ++compno) {
|
||||
opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
|
||||
/* The +3 is headroom required by the vectorized DWT */
|
||||
tilec->data = (int*) opj_aligned_malloc((((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0))+3) * sizeof(int));
|
||||
t1_decode_cblks(t1, tilec, &tcd->tcp->tccps[compno]);
|
||||
}
|
||||
t1_destroy(t1);
|
||||
t1_time = opj_clock() - t1_time;
|
||||
opj_event_msg(tcd->cinfo, EVT_INFO, "- tiers-1 took %f s\n", t1_time);
|
||||
|
||||
/*----------------DWT---------------------*/
|
||||
|
||||
dwt_time = opj_clock(); /* time needed to decode a tile */
|
||||
for (compno = 0; compno < tile->numcomps; compno++) {
|
||||
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
|
||||
int numres2decode;
|
||||
|
||||
if (tcd->cp->reduce != 0) {
|
||||
tcd->image->comps[compno].resno_decoded =
|
||||
tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
|
||||
if (tcd->image->comps[compno].resno_decoded < 0) {
|
||||
opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number "
|
||||
" of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
numres2decode = tcd->image->comps[compno].resno_decoded + 1;
|
||||
if(numres2decode > 0){
|
||||
if (tcd->tcp->tccps[compno].qmfbid == 1) {
|
||||
dwt_decode(tilec, numres2decode);
|
||||
} else {
|
||||
dwt_decode_real(tilec, numres2decode);
|
||||
}
|
||||
}
|
||||
}
|
||||
dwt_time = opj_clock() - dwt_time;
|
||||
opj_event_msg(tcd->cinfo, EVT_INFO, "- dwt took %f s\n", dwt_time);
|
||||
|
||||
/*----------------MCT-------------------*/
|
||||
|
||||
if (tcd->tcp->mct) {
|
||||
int n = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0);
|
||||
|
||||
if (tile->numcomps >= 3 ){
|
||||
if (tcd->tcp->tccps[0].qmfbid == 1) {
|
||||
mct_decode(
|
||||
tile->comps[0].data,
|
||||
tile->comps[1].data,
|
||||
tile->comps[2].data,
|
||||
n);
|
||||
} else {
|
||||
mct_decode_real(
|
||||
(float*)tile->comps[0].data,
|
||||
(float*)tile->comps[1].data,
|
||||
(float*)tile->comps[2].data,
|
||||
n);
|
||||
}
|
||||
} else{
|
||||
opj_event_msg(tcd->cinfo, EVT_WARNING,"Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",tile->numcomps);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------TILE-------------------*/
|
||||
|
||||
for (compno = 0; compno < tile->numcomps; ++compno) {
|
||||
opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
|
||||
opj_image_comp_t* imagec = &tcd->image->comps[compno];
|
||||
opj_tcd_resolution_t* res = &tilec->resolutions[imagec->resno_decoded];
|
||||
int adjust = imagec->sgnd ? 0 : 1 << (imagec->prec - 1);
|
||||
int min = imagec->sgnd ? -(1 << (imagec->prec - 1)) : 0;
|
||||
int max = imagec->sgnd ? (1 << (imagec->prec - 1)) - 1 : (1 << imagec->prec) - 1;
|
||||
|
||||
int tw = tilec->x1 - tilec->x0;
|
||||
int w = imagec->w;
|
||||
|
||||
int offset_x = int_ceildivpow2(imagec->x0, imagec->factor);
|
||||
int offset_y = int_ceildivpow2(imagec->y0, imagec->factor);
|
||||
|
||||
int i, j;
|
||||
if(!imagec->data){
|
||||
imagec->data = (int*) opj_malloc(imagec->w * imagec->h * sizeof(int));
|
||||
}
|
||||
if(tcd->tcp->tccps[compno].qmfbid == 1) {
|
||||
for(j = res->y0; j < res->y1; ++j) {
|
||||
for(i = res->x0; i < res->x1; ++i) {
|
||||
int v = tilec->data[i - res->x0 + (j - res->y0) * tw];
|
||||
v += adjust;
|
||||
imagec->data[(i - offset_x) + (j - offset_y) * w] = int_clamp(v, min, max);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(j = res->y0; j < res->y1; ++j) {
|
||||
for(i = res->x0; i < res->x1; ++i) {
|
||||
float tmp = ((float*)tilec->data)[i - res->x0 + (j - res->y0) * tw];
|
||||
int v = lrintf(tmp);
|
||||
v += adjust;
|
||||
imagec->data[(i - offset_x) + (j - offset_y) * w] = int_clamp(v, min, max);
|
||||
}
|
||||
}
|
||||
}
|
||||
opj_aligned_free(tilec->data);
|
||||
}
|
||||
|
||||
tile_time = opj_clock() - tile_time; /* time needed to decode a tile */
|
||||
opj_event_msg(tcd->cinfo, EVT_INFO, "- tile decoded in %f s\n", tile_time);
|
||||
|
||||
if (eof) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
void tcd_free_decode(opj_tcd_t *tcd) {
|
||||
opj_tcd_image_t *tcd_image = tcd->tcd_image;
|
||||
opj_free(tcd_image->tiles);
|
||||
}
|
||||
|
||||
void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) {
|
||||
int compno,resno,bandno,precno;
|
||||
|
||||
opj_tcd_image_t *tcd_image = tcd->tcd_image;
|
||||
|
||||
opj_tcd_tile_t *tile = &tcd_image->tiles[tileno];
|
||||
for (compno = 0; compno < tile->numcomps; compno++) {
|
||||
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
|
||||
for (resno = 0; resno < tilec->numresolutions; resno++) {
|
||||
opj_tcd_resolution_t *res = &tilec->resolutions[resno];
|
||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
||||
opj_tcd_band_t *band = &res->bands[bandno];
|
||||
for (precno = 0; precno < res->ph * res->pw; precno++) {
|
||||
opj_tcd_precinct_t *prec = &band->precincts[precno];
|
||||
if (prec->imsbtree != NULL) tgt_destroy(prec->imsbtree);
|
||||
if (prec->incltree != NULL) tgt_destroy(prec->incltree);
|
||||
}
|
||||
opj_free(band->precincts);
|
||||
}
|
||||
}
|
||||
opj_free(tilec->resolutions);
|
||||
}
|
||||
opj_free(tile->comps);
|
||||
}
|
||||
|
||||
|
||||
opj_bool opj_tcd_init( opj_tcd_v2_t *p_tcd,
|
||||
opj_image_t * p_image,
|
||||
opj_cp_v2_t * p_cp )
|
||||
@ -1377,12 +1170,12 @@ opj_bool opj_tcd_encode_tile( opj_tcd_v2_t *p_tcd,
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
opj_bool tcd_decode_tile_v2(
|
||||
opj_tcd_v2_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_bool opj_tcd_decode_tile( opj_tcd_v2_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_UINT32 l_data_read;
|
||||
p_tcd->tcd_tileno = p_tile_no;
|
||||
|
@ -399,23 +399,6 @@ opj_bool opj_tcd_rateallocate( opj_tcd_v2_t *tcd,
|
||||
OPJ_UINT32 len,
|
||||
opj_codestream_info_t *cstr_info);
|
||||
|
||||
/**
|
||||
Decode a tile from a buffer into a raw image
|
||||
@param tcd TCD handle
|
||||
@param src Source buffer
|
||||
@param len Length of source buffer
|
||||
@param tileno Number that identifies one of the tiles to be decoded
|
||||
@param cstr_info Codestream information structure
|
||||
*/
|
||||
opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info);
|
||||
/**
|
||||
Free the memory allocated for decoding
|
||||
@param tcd TCD handle
|
||||
*/
|
||||
void tcd_free_decode(opj_tcd_t *tcd);
|
||||
void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the maximum tile size that will be taken by the tile once decoded.
|
||||
*/
|
||||
@ -446,11 +429,11 @@ 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
|
||||
*/
|
||||
opj_bool tcd_decode_tile_v2(opj_tcd_v2_t *tcd,
|
||||
OPJ_BYTE *src,
|
||||
OPJ_UINT32 len,
|
||||
OPJ_UINT32 tileno,
|
||||
opj_codestream_index_t *cstr_info);
|
||||
opj_bool opj_tcd_decode_tile( opj_tcd_v2_t *tcd,
|
||||
OPJ_BYTE *src,
|
||||
OPJ_UINT32 len,
|
||||
OPJ_UINT32 tileno,
|
||||
opj_codestream_index_t *cstr_info);
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user