[trunk] update global functions of tgt with opj_ prefix

This commit is contained in:
Mickael Savinaud 2012-10-03 15:06:58 +00:00
parent 2d52e409c2
commit f4a8f7165c
4 changed files with 60 additions and 85 deletions

View File

@ -547,15 +547,15 @@ opj_bool opj_t2_encode_packet( OPJ_UINT32 tileno,
for(bandno = 0; bandno < res->numbands; ++bandno) {
opj_tcd_precinct_v2_t *prc = &band->precincts[precno];
tgt_reset(prc->incltree);
tgt_reset(prc->imsbtree);
opj_tgt_reset(prc->incltree);
opj_tgt_reset(prc->imsbtree);
l_nb_blocks = prc->cw * prc->ch;
for (cblkno = 0; cblkno < l_nb_blocks; ++cblkno) {
opj_tcd_cblk_enc_v2_t* cblk = &prc->cblks.enc[cblkno];
cblk->numpasses = 0;
tgt_setvalue(prc->imsbtree, cblkno, band->numbps - cblk->numbps);
opj_tgt_setvalue(prc->imsbtree, cblkno, band->numbps - cblk->numbps);
}
++band;
}
@ -577,7 +577,7 @@ opj_bool opj_t2_encode_packet( OPJ_UINT32 tileno,
opj_tcd_layer_t *layer = &cblk->layers[layno];
if (!cblk->numpasses && layer->numpasses) {
tgt_setvalue(prc->incltree, cblkno, layno);
opj_tgt_setvalue(prc->incltree, cblkno, layno);
}
++cblk;
@ -593,7 +593,7 @@ opj_bool opj_t2_encode_packet( OPJ_UINT32 tileno,
/* cblk inclusion bits */
if (!cblk->numpasses) {
tgt_encode(bio, prc->incltree, cblkno, layno + 1);
opj_tgt_encode(bio, prc->incltree, cblkno, layno + 1);
} else {
opj_bio_write(bio, layer->numpasses != 0, 1);
}
@ -607,7 +607,7 @@ opj_bool opj_t2_encode_packet( OPJ_UINT32 tileno,
/* if first instance of cblk --> zero bit-planes information */
if (!cblk->numpasses) {
cblk->numlenbits = 3;
tgt_encode(bio, prc->imsbtree, cblkno, 999);
opj_tgt_encode(bio, prc->imsbtree, cblkno, 999);
}
/* number of coding passes included */
@ -804,8 +804,8 @@ opj_bool opj_t2_read_packet_header( opj_t2_v2_t* p_t2,
opj_tcd_precinct_v2_t *l_prc = &l_band->precincts[p_pi->precno];
if ( ! ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) ) {
tgt_reset(l_prc->incltree);
tgt_reset(l_prc->imsbtree);
opj_tgt_reset(l_prc->incltree);
opj_tgt_reset(l_prc->imsbtree);
l_cblk = l_prc->cblks.dec;
l_nb_code_blocks = l_prc->cw * l_prc->ch;
@ -914,7 +914,7 @@ opj_bool opj_t2_read_packet_header( opj_t2_v2_t* p_t2,
/* if cblk not yet included before --> inclusion tagtree */
if (!l_cblk->numsegs) {
l_included = tgt_decode(l_bio, l_prc->incltree, cblkno, p_pi->layno + 1);
l_included = opj_tgt_decode(l_bio, l_prc->incltree, cblkno, p_pi->layno + 1);
/* else one bit */
}
else {
@ -932,7 +932,7 @@ opj_bool opj_t2_read_packet_header( opj_t2_v2_t* p_t2,
if (!l_cblk->numsegs) {
OPJ_UINT32 i = 0;
while (!tgt_decode(l_bio, l_prc->imsbtree, cblkno, i)) {
while (!opj_tgt_decode(l_bio, l_prc->imsbtree, cblkno, i)) {
++i;
}

View File

@ -919,11 +919,11 @@ opj_bool FUNCTION ( opj_tcd_v2_t *p_tcd, \
} \
\
if (! l_current_precinct->incltree) { \
l_current_precinct->incltree = tgt_create(l_current_precinct->cw, \
l_current_precinct->incltree = opj_tgt_create(l_current_precinct->cw, \
l_current_precinct->ch); \
} \
else{ \
l_current_precinct->incltree = tgt_init(l_current_precinct->incltree, \
l_current_precinct->incltree = opj_tgt_init(l_current_precinct->incltree, \
l_current_precinct->cw, \
l_current_precinct->ch); \
} \
@ -934,12 +934,12 @@ opj_bool FUNCTION ( opj_tcd_v2_t *p_tcd, \
} \
\
if (! l_current_precinct->imsbtree) { \
l_current_precinct->imsbtree = tgt_create( \
l_current_precinct->imsbtree = opj_tgt_create( \
l_current_precinct->cw, \
l_current_precinct->ch); \
} \
else { \
l_current_precinct->imsbtree = tgt_init( \
l_current_precinct->imsbtree = opj_tgt_init( \
l_current_precinct->imsbtree, \
l_current_precinct->cw, \
l_current_precinct->ch); \
@ -1419,9 +1419,9 @@ void opj_tcd_free_tile(opj_tcd_v2_t *p_tcd)
l_nb_precincts = l_band->precincts_data_size / sizeof(opj_tcd_precinct_v2_t);
for (precno = 0; precno < l_nb_precincts; ++precno) {
tgt_destroy(l_precinct->incltree);
opj_tgt_destroy(l_precinct->incltree);
l_precinct->incltree = 00;
tgt_destroy(l_precinct->imsbtree);
opj_tgt_destroy(l_precinct->imsbtree);
l_precinct->imsbtree = 00;
(*l_tcd_code_block_deallocate) (l_precinct);
++l_precinct;

View File

@ -37,7 +37,7 @@
==========================================================
*/
opj_tgt_tree_t *tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
OPJ_INT32 nplh[32];
OPJ_INT32 nplv[32];
opj_tgt_node_t *node = 00;
@ -112,7 +112,7 @@ opj_tgt_tree_t *tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
}
}
node->parent = 0;
tgt_reset(tree);
opj_tgt_reset(tree);
return tree;
}
@ -124,7 +124,7 @@ opj_tgt_tree_t *tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
* @param p_num_leafs_v the height of the array of leafs of the tree
* @return a new tag-tree if successful, NULL otherwise
*/
opj_tgt_tree_t *tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, OPJ_UINT32 p_num_leafs_v)
opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, OPJ_UINT32 p_num_leafs_v)
{
OPJ_INT32 l_nplh[32];
OPJ_INT32 l_nplv[32];
@ -137,14 +137,11 @@ opj_tgt_tree_t *tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, OPJ_U
OPJ_UINT32 n;
OPJ_UINT32 l_node_size;
if
(! p_tree)
{
if (! p_tree){
return 00;
}
if
((p_tree->numleafsh != p_num_leafs_h) || (p_tree->numleafsv != p_num_leafs_v))
{
if ((p_tree->numleafsh != p_num_leafs_h) || (p_tree->numleafsv != p_num_leafs_v)) {
p_tree->numleafsh = p_num_leafs_h;
p_tree->numleafsv = p_num_leafs_v;
@ -163,22 +160,17 @@ opj_tgt_tree_t *tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, OPJ_U
while (n > 1);
/* ADD */
if
(p_tree->numnodes == 0)
{
tgt_destroy(p_tree);
if (p_tree->numnodes == 0) {
opj_tgt_destroy(p_tree);
return 00;
}
l_node_size = p_tree->numnodes * sizeof(opj_tgt_node_t);
if
(l_node_size > p_tree->nodes_size)
{
if (l_node_size > p_tree->nodes_size) {
opj_tgt_node_t* new_nodes = (opj_tgt_node_t*) opj_realloc(p_tree->nodes, l_node_size);
if
(! p_tree->nodes)
{
fprintf(stderr, "Not enough memory to reinitialize the tag tree\n");
tgt_destroy(p_tree);
if (! p_tree->nodes) {
fprintf(stderr, "ERROR Not enough memory to reinitialize the tag tree\n");
opj_tgt_destroy(p_tree);
return 00;
}
p_tree->nodes = new_nodes;
@ -189,20 +181,13 @@ opj_tgt_tree_t *tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, OPJ_U
l_parent_node = &p_tree->nodes[p_tree->numleafsh * p_tree->numleafsv];
l_parent_node0 = l_parent_node;
for
(i = 0; i < l_num_levels - 1; ++i)
{
for
(j = 0; j < l_nplv[i]; ++j)
{
for (i = 0; i < l_num_levels - 1; ++i) {
for (j = 0; j < l_nplv[i]; ++j) {
k = l_nplh[i];
while
(--k >= 0)
{
while (--k >= 0) {
l_node->parent = l_parent_node;
++l_node;
if (--k >= 0)
{
if (--k >= 0) {
l_node->parent = l_parent_node;
++l_node;
}
@ -221,17 +206,12 @@ opj_tgt_tree_t *tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, OPJ_U
}
l_node->parent = 0;
}
tgt_reset(p_tree);
opj_tgt_reset(p_tree);
return p_tree;
}
/*void tgt_destroy(opj_tgt_tree_t *tree) {
opj_free(tree->nodes);
opj_free(tree);
}*/
void tgt_destroy(opj_tgt_tree_t *p_tree)
void opj_tgt_destroy(opj_tgt_tree_t *p_tree)
{
if (! p_tree) {
return;
@ -244,20 +224,7 @@ void tgt_destroy(opj_tgt_tree_t *p_tree)
opj_free(p_tree);
}
/*void tgt_reset(opj_tgt_tree_t *tree) {
int i;
if (NULL == tree)
return;
for (i = 0; i < tree->numnodes; i++) {
tree->nodes[i].value = 999;
tree->nodes[i].low = 0;
tree->nodes[i].known = 0;
}
}*/
void tgt_reset(opj_tgt_tree_t *p_tree) {
void opj_tgt_reset(opj_tgt_tree_t *p_tree) {
OPJ_UINT32 i;
opj_tgt_node_t * l_current_node = 00;;
@ -275,7 +242,7 @@ void tgt_reset(opj_tgt_tree_t *p_tree) {
}
}
void tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 value) {
void opj_tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 value) {
opj_tgt_node_t *node;
node = &tree->nodes[leafno];
while (node && node->value > value) {
@ -284,7 +251,7 @@ void tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 value) {
}
}
void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold) {
void opj_tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold) {
opj_tgt_node_t *stk[31];
opj_tgt_node_t **stkptr;
opj_tgt_node_t *node;
@ -324,7 +291,7 @@ void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT
}
}
OPJ_UINT32 tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold) {
OPJ_UINT32 opj_tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold) {
opj_tgt_node_t *stk[31];
opj_tgt_node_t **stkptr;
opj_tgt_node_t *node;

View File

@ -47,10 +47,10 @@ are used by some function in T2.C.
Tag node
*/
typedef struct opj_tgt_node {
struct opj_tgt_node *parent;
OPJ_INT32 value;
OPJ_INT32 low;
OPJ_UINT32 known;
struct opj_tgt_node *parent;
OPJ_INT32 value;
OPJ_INT32 low;
OPJ_UINT32 known;
} opj_tgt_node_t;
/**
@ -75,7 +75,7 @@ Create a tag-tree
@param numleafsv Height of the array of leafs of the tree
@return Returns a new tag-tree if successful, returns NULL otherwise
*/
opj_tgt_tree_t *tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv);
opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv);
/**
* Reinitialises a tag-tree from an exixting one.
@ -85,26 +85,28 @@ opj_tgt_tree_t *tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv);
* @param p_num_leafs_v the height of the array of leafs of the tree
* @return a new tag-tree if successful, NULL otherwise
*/
opj_tgt_tree_t *tgt_init(opj_tgt_tree_t * p_tree, OPJ_UINT32 p_num_leafs_h, OPJ_UINT32 p_num_leafs_v);
opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree,
OPJ_UINT32 p_num_leafs_h,
OPJ_UINT32 p_num_leafs_v);
/**
Destroy a tag-tree, liberating memory
@param tree Tag-tree to destroy
*/
void tgt_destroy(opj_tgt_tree_t *tree);
void opj_tgt_destroy(opj_tgt_tree_t *tree);
/**
Reset a tag-tree (set all leaves to 0)
@param tree Tag-tree to reset
*/
void tgt_reset(opj_tgt_tree_t *tree);
void opj_tgt_reset(opj_tgt_tree_t *tree);
/**
Set the value of a leaf of a tag-tree
@param tree Tag-tree to modify
@param leafno Number that identifies the leaf to modify
@param value New value of the leaf
*/
void tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 value);
void opj_tgt_setvalue(opj_tgt_tree_t *tree,
OPJ_UINT32 leafno,
OPJ_INT32 value);
/**
Encode the value of a leaf of the tag-tree up to a given threshold
@param bio Pointer to a BIO handle
@ -112,7 +114,10 @@ Encode the value of a leaf of the tag-tree up to a given threshold
@param leafno Number that identifies the leaf to encode
@param threshold Threshold to use when encoding value of the leaf
*/
void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold);
void opj_tgt_encode(opj_bio_t *bio,
opj_tgt_tree_t *tree,
OPJ_UINT32 leafno,
OPJ_INT32 threshold);
/**
Decode the value of a leaf of the tag-tree up to a given threshold
@param bio Pointer to a BIO handle
@ -121,7 +126,10 @@ Decode the value of a leaf of the tag-tree up to a given threshold
@param threshold Threshold to use when decoding value of the leaf
@return Returns 1 if the node's value < threshold, returns 0 otherwise
*/
OPJ_UINT32 tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold);
OPJ_UINT32 opj_tgt_decode(opj_bio_t *bio,
opj_tgt_tree_t *tree,
OPJ_UINT32 leafno,
OPJ_INT32 threshold);
/* ----------------------------------------------------------------------- */
/*@}*/