📄 ebcot_encoder.h
字号:
/*****************************************************************************/
/* Copyright 1998, Hewlett-Packard Company */
/* All rights reserved */
/* File: "ebcot_encoder.h" */
/* Description: Principle header file for the EBCOT encoder */
/* Author: David Taubman */
/* Affiliation: Hewlett-Packard and */
/* The University of New South Wales, Australia */
/* Version: VM8.0 */
/* Last Revised: 28 July, 2000 */
/*****************************************************************************/
/*****************************************************************************/
/* Modified by David Taubman to support new termination methods for parallel */
/* coding options, to enable more efficient implementations and to support */
/* error resilience. Copyright 1999 by Hewlett-Packard Company with all */
/* rights reserved for the modified parts. */
/*****************************************************************************/
/*****************************************************************************/
/* Modified to combine entropy coders */
/* Copyright 1999 Science Applications International Corporation (SAIC). */
/* Copyright 1999 University of Arizona, Arizona Board of Regents. */
/* All Rights Reserved for modified parts. */
/*****************************************************************************/
/*****************************************************************************/
/* Modified to include TCQ */
/* Copyright 1999 Science Applications International Corporation (SAIC). */
/* Copyright 1995 University of Arizona, Arizona Board of Regents. */
/* All Rights Reserved for modified parts. */
/*****************************************************************************/
/*****************************************************************************/
/* Modified by David Taubman to include masking-sensitive distortion */
/* calculations for R-D optimization (`-Cvis' option). Material identified */
/* by "David T Cvis mod" comments has been added by David Taubman; it is */
/* copyrighted by the University of New South Wales (Copyright 1999) with */
/* all rights reserved for the modified parts. */
/*****************************************************************************/
/*****************************************************************************/
/* Modified by David Taubman to support arbitrary reference points for the */
/* transform and the various regular partitions, so as to facilitate */
/* cropping and geometric transformations in the compressed domain and to */
/* enable full support for CRF's single-sample overlap Wavelet transform, */
/* as originally documented in Seoul. Changes are too numerous to flag */
/* individually within the code. Changes copyrighted by HP with all rights */
/* reserved for the modified parts. */
/*****************************************************************************/
/*****************************************************************************/
/* 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. */
/*****************************************************************************/
/*****************************************************************************/
/* 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. */
/*****************************************************************************/
/*****************************************************************************/
/* Modified for general wavelet decompositions. */
/* Copyright 2000 Science Applications International Corporation (SAIC). */
/* Copyright 1995 University of Arizona, Arizona Board of Regents. */
/* All Rights Reserved for modified parts. */
/*****************************************************************************/
/*****************************************************************************/
/* Modified by David Taubman to incorporate changes to the POC marker (used */
/* to be POD). Changes are quite extensive and not always explicitly */
/* When flagged, the relevant comment string is "DST POC mod". */
/* Generally, any reference to tile-parts (e.g. through variable names */
/* containing the string `tpart' are part of this modification, since the */
/* compressor did not previously need to be tile-part aware. */
/* Copyright 2000 The University of New South Wales. */
/* All rights reserved for the modified parts. */
/*****************************************************************************/
#ifndef EBCOT_ENCODER_H
#define EBCOT_ENCODER_H
#include <ifc.h>
#include <dst_arith_encoder.h>
#include "ebcot_common.h"
#include "ebcot_constants.h"
typedef struct ebcot_vpw_info *ebcot_vpw_info_ptr; /* Forward declaration. */
/* ========================================================================= */
/* -------------------------- Rate-Distortion Slopes ----------------------- */
/* ========================================================================= */
#define RD_SLOPE_EXPONENT_BITS 6
#define RD_SLOPE_MANTISSA_BITS 9
/*****************************************************************************/
/* rd_slope_type */
/*****************************************************************************/
typedef std_short rd_slope_type;
/* This definition identifies the data type used to represent
rate-distortion slopes. We use a type of 16-bit floating point
representation, in which the least-significant RD_SLOPE_MANTISSA_BITS
bits correspond to the mantissa, M, and the next RD_SLOPE_EXPONENT_BITS
most significant bits correspond to the mantissa, E. Unlike general
floating point representations, legal values of E muse be non-negative,
in the range 0 to 2^{Ebits}-1, where Ebits is the RD_SLOPE_EXPONENT_BITS
value. The rate-distortion slope value which is represented is given
by 2^E*(1 + 2^{-Mbits}*M), where Mbits is the RD_SLOPE_MANTISSA_BITS
value. This slope corresponds to an appropriately scaled representation
of the reduction in distortion, divided by the increase in bit-rate
between two points on the convex hull of the rate-distortion curve.
Given that Ebits+Mbits < 16, negative values for instances of the
`rd_slope_type' type are clearly illegal. In addition, however, we
insist that a value of 0 should also be illegal. This means that
legal slopes must lie in the range (1+2^{-Mbits}) through
2^{2^{Ebits}-1}*(2-2^{-Mbits}). The illegal values are used to signal
special conditions, as discussed in the comments appearing with
the definition of the `ebcot_pass_info' structure. */
/* ========================================================================= */
/* -------------------------- Block Coding Structure ----------------------- */
/* ========================================================================= */
/* Begin David T Cvis mod */
/*****************************************************************************/
/* distortion_cell */
/*****************************************************************************/
typedef
struct distortion_cell {
std_int delta_mse;
float visibility_factor;
} distortion_cell, *distortion_cell_ptr;
/* This structure manages the calculation and visual weighting of distortion
in each code-block. The unweighted MSE distortion is accumulated only
over the relatively small cell size (8x8 in the current implementation)
and contributions from different cells are accumulated only after
weighting by the relevant `visibility_factor'.
`delta_mse' holds a normalized fixed-point representation of the
amount by which the squared error in the cell's samples is reduced
by the symbols encoded during the most recent coding pass.
Specifically, to obtain the absolute reduction in mean squared error
of the IMPLEMENTATION_PRECISION-bit sample values, the return value
should be divided by 2^13 and then multiplied by 2^(2P-2), where P
is the zero-based index of the relevant bit-plane.
`visibility_factor' is a measure of the visibility of artifacts.
Smaller values mean that the relative visibility of artifacts is
reduced by the presence of texture, noise or other nearby signals.
The visibility factor is applied to the cell's distortion estimate
after each coding pass to arrive at a more visually meaningful
distortion estimate. */
/* End David T Cvis mod */
/*****************************************************************************/
/* block_master */
/*****************************************************************************/
typedef
struct block_master {
int max_height, max_width, height, width;
int max_stripes, stripes;
int interleaved_row_gap, sample_row_gap;
int causal, reset, terminate_each_pass, lazy;
int easy_termination, error_resilient_termination;
ifc_int bit_idx;
ifc_int first_bit_idx;
int full_effort_msbs;
ifc_int block_mag;
ifc_int *interleaved_sample_buffer;
std_short *interleaved_context_buffer, *context_buffer_handle;
/* Begin David T Cvis mod */
distortion_cell_ptr d_cells;
int d_cell_row_gap;
int exploit_visual_masking;
float masking_exponent;
float max_masked_sensitivity_reduction;
/* End David T Cvis mod */
dst_arith_state coder_state;
std_byte *zc_lut;
std_short *initial_mse_lut;
std_short *refinement_mse_lut;
dst_context_state contexts[EBCOT_TOTAL_CONTEXTS];
dst_arith_state saved_states[MAX_PASSES];
double cumulative_wmse[MAX_PASSES];
std_byte **roi_mask;
/* begin segment marker insertion code - Sarnoff Corp. */
int segmark;
/* end segment marker insertion code - Sarnoff Corp. */
int include_all_passes;
} block_master, *block_master_ptr;
/* There is one instance of this structure for each tile-component.
It holds all intermediate information involved in the coding of a
single block of samples. Many of its fields must be initialized
for each new block.
`max_height' and `max_width' identify the maximum height and width
of each code block, whereas `height' and `width' hold the actual height
and width of the current code-block being processed.
`max_stripes' holds the maximum number of stripes, each of which
holds four rows (some of these rows may possibly be missing in the last
stripe of the code-block), whereas `stripes' holds the actual number
of vertical stripes in a given code-block.
`interleaved_row_gap' holds the gap between samples with the same
position in vertically adjacent stripes within the
`interleaved_sample_buffer'.
`sample_row_gap' holds the gap between samples on consecutive
lines within the sample buffers supplied to the `encode_block'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -