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

📄 ebcot_encoder.h

📁 关于视频压缩的jpeg2000压缩算法,C编写
💻 H
📖 第 1 页 / 共 4 页
字号:
/*****************************************************************************//* 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: VM6.0                                                            *//* Last Revised: 19 January, 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 Reservedi 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 Reservedi 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.                               *//*****************************************************************************/#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'     function; this is a constant, generally equal to the `max_width' value.         `causal' is a flag identifying whether or not the context formation     process should be vertically stripe-causal.         `reset' is a flag identifying whether or not the probability     models should be reinitialized at the beginning of each coding pass.         `terminate_each_pass' is a flag identifying whether or not the     arithmetic code-word generation process should be terminated at the     end of each coding pass.  Note that this need not necessarily be     accompanied by model reset.         `lazy' is a flag identifying whether or not the lazy coding mode     is to be used, as parametrized by the `full_effort_msbs' field (see     below).         `easy_termination' is a flag identifying whether or not to use a     simplified algorithm for computing the termination length for each     arithmetic codeword segment.  The decoder does not need to know about     this.         `error_resilient_termination' is a flag identifying whether or not     to use the predictable error resilient termination policy.  In the     current implementation, the easy termination policy is identical to     the error resilient termination policy.         `bit_idx' identifies the bit position of the current magnitude bit     plane.  It is initially set to IMPLEMENTATION_PRECISION-2 (bit position     indices are zero-based) and then decremented for each successive     bit-plane.         `first_bit_idx' holds the value of `bit_idx' in the first bit-plane     for which any sample was significant.         `full_effort_msbs' holds the number of most significant bit-planes,     starting with the first bit-plane in which the relevant code-block is     first found to be significant, for which arithmetic coding is used in     all passes.  After this point, only the main coding pass (i.e. that     in which samples with previously all-zero neighbourhoods are coded)     receives the full coding effort, and the other passes are performed     without the aid of arithmetic coding, sending the raw binary symbols     directly to the bit-stream.  Note that this behaviour occurs only     when the `elias' flag is turned on.         `block_mag' holds the inclusive OR of the magnitude bits from all     samples in the block (i.e the IMPLEMENTATION_PRECISION-1 least     significant bits from each IMPLEMENTATION_PRECISION-bit word).         `interleaved_sample_buffer' points to the buffer which holds the     samples to be encoded.  The sample buffer is organized in terms of     stripes.  Specifically, the stripes appear one after the other, with     some intervening spacing to avoid access violations at boundaries.     The four rows of each stripe are interleaved and corresponding samples     from adjacent stripes are separated by `stripe_gap' entries     in the array.         `interleaved_context_buffer' points to a common context buffer which     is used for all code-blocks.  It has the same interleaved stripe     organization as the `interleaved_sample_buffer' array.  There is a single     16-bit context word for each sample, which is updated only when the     sample or one of its immediate neighbours becomes significant.  The     value of `stripe_gap' is chosen to be sufficiently large to     ensure that accesses of up to eight stripe columns beyond the last     sample in any stripe will not cause any access violations or overwrite     real data.  Also, accesses one stripe column to the left and a full     stripe before the first sample in the code-block or four samples to the     right and a full stripe after the last sample in the code-block will not

⌨️ 快捷键说明

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