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

📄 ebcot_receive_bits.h

📁 JPEG2000实现的源码
💻 H
字号:
/*****************************************************************************/
/* Copyright 1998, Hewlett-Packard Company                                   */
/* All rights reserved                                                       */
/* File: "ebcot_receive_bits.h"                                              */
/* Description: Header file for "ebcot_receive_bits.c"                       */
/* Author: David Taubman                                                     */
/* Affiliation: Hewlett-Packard and                                          */
/*              The University of New South Wales, Australia                 */
/* Version: VM7.0                                                            */
/* Last Revised: 24 March, 2000                                              */
/*****************************************************************************/

/*****************************************************************************/
/* Modified by David Taubman to support interface modifications, arbitrary   */
/* changes in coding parameters from component to component and from tile    */
/* to tile, packet partitions, rich packet sequencing conventions and to     */
/* support the full generality of PART-1 of the JPEG2000                     */
/* standard, and to support most anticipated generality of PART-2.  Changes  */
/* are too numerous to flag individually within the code, which in some      */
/* places has been completely rewritten.  All changes copyrighted by HP with */
/* all rights reserved for the modified parts.                               */
/*****************************************************************************/

/*****************************************************************************/
/* Modified by David Taubman to implement changes in Tokyo between CD and    */
/* FCD for Part-1 of the standard.  Copyrighted by HP with all rights        */
/* reserved for the modified parts.                                          */
/*****************************************************************************/

#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;
    int last_byte_ff;
    stream_in_ref stream;
    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.
         `stream' holds a reference to the `stream_in' object from
     which new bytes should be recovered via the `stream_in__pull_head_bytes'
     interface function.
         `except' is the `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 tag_tree_node_ptr
  ebcot_create_tag_tree(int rows, int cols);

extern void
  ebcot_destroy_tag_tree(tag_tree_node_ptr tree);

extern void
  ebcot_get_packet_head_and_body(ebcot_decoder_ref self,
                                 ebcot_precinct_info_ptr precinct,
                                 block_master_ptr master,
                                 int layer_idx);
 /* The bracketing `stream__start_packet' and `stream__end_packet' calls are
    the responsibility of the user. */

extern void
  ebcot_parse_to_length(ebcot_decoder_ref self, int max_bytes);

#endif /* EBCOT_RECEIVE_BITS_H */

⌨️ 快捷键说明

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