⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ebcot_receive_bits.h

📁 JPEG2000 EBCOT算法源码
💻 H
字号:
/*****************************************************************************/
/* File name: "ebcot_receive_bits.h"                                         */
/* Author: David Taubman                                                     */
/* Copyright 1998, Hewlett-Packard Company                                   */
/* All rights reserved                                                       */
/*****************************************************************************/
#ifndef EBCOT_RECEIVE_BITS_H
#define EBCOT_RECEIVE_BITS_H
#include <setjmp.h>
#include "ebcot_decoder.h"

/* ========================================================================= */
/* -------------------------------- Tag Trees ------------------------------ */
/* ========================================================================= */

/*****************************************************************************/
/*                                tag_tree_node                              */
/*****************************************************************************/

typedef
  struct tag_tree_node {
    int value;
    int lower_bound;
    struct tag_tree_node *child;
    struct tag_tree_node *parent;
  } tag_tree_node, *tag_tree_node_ptr;

  /* This structure represents a single node in a tag tree.  Tag trees are
     always navigated from the leaves to the root so the entire tree may be
     accessed by knowing where all the leaves are (see definition of the
     `tag_tree' structure) and knowing each leaf's parent.  The `parent'
     field enables this navigation.
         The process of decoding tag bits is driven from the leaves.
     Specifically, a request arrives to decode tag bits for a given leaf to
     determine whether or not the leaf's `value' field is less than some
     threshold, T.  The request is propagated up the tree to the root, leaving
     behind `child' pointers in order to allow the path from the leaf
     to be retraced.  Once decoding is complete, each non-leaf node's, `value'
     field will hold the minimum of the `value' fields in all descendant nodes.
     The `value' field of every node is initialized to INT_MAX, while the
     `lower_bound' field is initialized to 0.  During decoding, the following
     steps are taken:
       For each node in the path to the leaf, starting from the root of the
       tree, do the following:
         a) while (`lower_bound' < T) and (`lower_bound < `value')
            -> receive a tag bit from the bit-stream.
            If a 0 is received
               -> increment `lower_bound' by 1.
            Otherwise,
               -> set `value' equal to `lower_bound'.
         b) Set the child node's `lower_bound' field equal to the current
            `lower_bound' value.
     In this way, we can tell that a node's value has been completely
     decoded by checking whether or not the `value' and `lower_bound' fields
     are identical. */

/* ========================================================================= */
/* ------------------------------ Tag Buffering ---------------------------- */
/* ========================================================================= */

/*****************************************************************************/
/*                                 tag_buffer                                */
/*****************************************************************************/

typedef
  struct tag_buffer {
    std_byte byte;
    int available_bits;
    int retrieved_bytes;
    bitstream_source_ref source;
    jmp_buf *except;
  } tag_buffer, *tag_buffer_ptr;

  /* This structure is provided to manage the recovery of byte-aligned tag
     information from the bit-stream.  We generally keep tag information for
     an entire resolution level in the wavelet transform together.
         `byte' is used to accumulate the next byte of tag information.  The
     number of bit positions which have not yet been read is identified by
     the `available_bits' field.
         `retrieved_bytes' holds the total number of bytes which have been
     retrieved from the bit-stream since the object was last reset.
         `source' holds a reference to the `bitstream_source' object from
     which new bytes should be recovered.
         `except' points to a `jmp_buf' structure which holds the contents
     of the execution stack at the point to which exceptional conditions
     should return via the standard ANSI C `longjmp' function.  In this
     case the relevant exceptional condition is that associated with
     premature termination of the source bit-stream. */

/* ========================================================================= */
/* ---------------------------- External Functions ------------------------- */
/* ========================================================================= */

extern void
  ebcot_load_bit_stream(the_decoder_ref self);
extern void
  ebcot_parse_bit_stream(the_decoder_ref self);

#endif /* EBCOT_RECEIVE_BITS_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -