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;
}
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;
/* 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);
}
/* 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 */
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;
/* 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 {
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;
}
} \
\
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); \
} \
} \
\
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); \
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;
==========================================================
*/
-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;
}
}
node->parent = 0;
- tgt_reset(tree);
+ opj_tgt_reset(tree);
return tree;
}
* @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];
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;
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;
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;
}
}
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;
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;;
}
}
-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) {
}
}
-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;
}
}
-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;
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;
/**
@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.
* @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
@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
@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);
/* ----------------------------------------------------------------------- */
/*@}*/