Logo Search packages:      
Sourcecode: gdcm version File versions

int tgt_decode ( opj_bio_t bio,
opj_tgt_tree_t tree,
int  leafno,
int  threshold 
)

Decode the value of a leaf of the tag-tree up to a given threshold

Parameters:
bio Pointer to a BIO handle
tree Tag-tree to decode
leafno Number that identifies the leaf to decode
threshold Threshold to use when decoding value of the leaf
Returns:
Returns 1 if the node's value < threshold, returns 0 otherwise

Definition at line 177 of file tgt.c.

References bio_read(), opj_tgt_node::low, opj_tgt_tree::nodes, opj_tgt_node::parent, and opj_tgt_node::value.

Referenced by t2_decode_packet().

                                                                                {
      opj_tgt_node_t *stk[31];
      opj_tgt_node_t **stkptr;
      opj_tgt_node_t *node;
      int low;

      stkptr = stk;
      node = &tree->nodes[leafno];
      while (node->parent) {
            *stkptr++ = node;
            node = node->parent;
      }
      
      low = 0;
      for (;;) {
            if (low > node->low) {
                  node->low = low;
            } else {
                  low = node->low;
            }
            while (low < threshold && low < node->value) {
                  if (bio_read(bio, 1)) {
                        node->value = low;
                  } else {
                        ++low;
                  }
            }
            node->low = low;
            if (stkptr == stk) {
                  break;
            }
            node = *--stkptr;
      }
      
      return (node->value < threshold) ? 1 : 0;
}


Generated by  Doxygen 1.6.0   Back to index