📄 ebcot_send_bits.h
字号:
/*****************************************************************************/
/* Copyright 1998, Hewlett-Packard Company */
/* All rights reserved */
/* File: "ebcot_send_bits.h" */
/* Description: Header file for "ebcot_send_bits.c" */
/* Author: David Taubman */
/* Affiliation: Hewlett-Packard and */
/* The University of New South Wales, Australia */
/* Version: VM7.0 */
/* Last Revised: 11 April, 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 to incorporate scan based rate control. Material identified by */
/* "CRIL Technology/SAIC Scan Buffer" comments has been added by Fabrice */
/* Pelleau and Olivier Duffez of CRIL Technology and Tom Flohr of SAIC. */
/* Copyright 2000 CRIL Technology */
/* Copyright 2000 CNES */
/* Copyright 2000 Science Applications International Corporation (SAIC). */
/* All Rights Reserved for modified parts. */
/*****************************************************************************/
#ifndef EBCOT_SEND_BITS_H
#define EBCOT_SEND_BITS_H
#include "ebcot_encoder.h"
/* ========================================================================= */
/* -------------------------------- Tag Trees ------------------------------ */
/* ========================================================================= */
/*****************************************************************************/
/* tag_tree_node */
/*****************************************************************************/
typedef
struct tag_tree_node {
int value;
int lower_bound;
int value_known;
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 sending tag bits is driven from the leaves.
Specifically, a request arrives to send tag bits for a given leaf to
represent 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. In each non-leaf node, the `value' field holds the
minimum of the `value' fields in all descendant nodes. During coding,
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')
-> send a 0 bit
-> increment `lower_bound' by 1.
b) if (`lower_bound' < T) and (`value_known' is false)
-> send a 1 bit
-> set `value_known' to true.
c) Set the child node's `lower_bound' field equal to the current
`lower_bound' value.
This algorithm has the effect of encoding whether or not any given leaf
is less than an arbitrary threshold, T, and, if it is less than T,
encoding the actual value. Moreover, the algorithm avoids redundancy as
the threshold and leaf which we are interested in are arbitrary selected
in subsequent coding steps. It is a highly generalized quad-tree
coding algorithm, which is particularly useful in coding the tag
information we want to insert into our bit-stream.
During initialization, the `lower_bound' field of each node is set
to 0; the `value_known' flag is set to 0 (false); and the `value'
field is set to INT_MAX. */
/* ========================================================================= */
/* ------------------------------ Tag Buffering ---------------------------- */
/* ========================================================================= */
/*****************************************************************************/
/* tag_buffer */
/*****************************************************************************/
typedef
struct tag_buffer {
std_byte byte;
int available_bits;
int stored_bytes;
int max_stored_bytes;
std_byte *store;
} tag_buffer, *tag_buffer_ptr;
/* This structure is provided to manage the buffering of tag information
for writing into the bit-stream. Tags are buffered in a dynamically
growing array, which is byte oriented and padded, until the point
comes to actually write the block of tag information into 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 written is identified by
the `available_bits' field.
`store' points to an array with `max_stored_bytes' elements, of which
`stored_bytes' currently hold valid entries. The array may occasionally
need to be reallocated if initial sizing is found to be insufficient. */
/* ========================================================================= */
/* ---------------------------- 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_send_bit_stream(ebcot_encoder_ref self);
/* CRIL Technology/SAIC Scan Buffer end */
extern void
ebcot_send_scan_buffer_bit_stream(ebcot_encoder_ref self);
/* CRIL Technology/SAIC Scan Buffer end */
#endif /* EBCOT_SEND_BITS_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -