📄 ebcot_encoder.h
字号:
typedef struct ebcot_component_info { int tnum, component_idx; canvas_dims dims; int hor_subsampling, vert_subsampling; int num_levels; ebcot_level_info_ptr levels; block_master master; sample_buffer_heap_ref sample_buffer_heap_mgr; int respect_frames; } ebcot_component_info, *ebcot_component_info_ptr; /* This structure encapsulates all state information for a given image component within a particular tile. `tnum' and `component_idx' identify the coordinates of the component. The `dims' structure holds the location and dimensions of the image component within the relevant tile, at its full resolution. The `hor_subsampling' and `vert_subsampling' fields identify the horizontal and vertical sub-sampling factors for this component; these may be used to recover the entries in the `dims' structure from those in the `referernce_dims' structure within the containing `ebcot_tile' structure. `num_levels' holds the number of Wavelet decompostion levels, which is equal to the number of resolution levels minus 1. `levels' points to an array with `num_levels'+1 entries. The first entry manages the state of the LL band at the base of the decomposition. The n'th entry (n=1,2,...) manages stage for all subbands required to recover resolution level n, from the previous resolution. `master' is a common structure which manages the encoding of any given block of subband samples. The block parameters, common storage and a variety of intermediate results are maintained within this structure on behalf of all code-blocks in the tile-component. `sample_buffer_heap_mgr' references an object which manages the dynamic allocation of sample buffers. `respect_frames' is a flag indicating whether or not code-blocks are required to respect frame dimensions. If so, then the code-block dimensions in any given subband will be the lesser of the nominal code-block dimensions as maintained by `master->max_block_rows' and `master->max_block_cols', the frame dimensions as they appear in the relevant subband, and the packet partition dimensions as they appear in the relevant subband. Otherwise, the code-block dimensions will be the lesser of the nominal block dimensions and the packet partition dimensions for the subband. *//*****************************************************************************//* ebcot_order *//*****************************************************************************/typedef struct ebcot_order { int max_layers, max_levels, max_components; int new_progression; struct ebcot_order *next; } ebcot_order, *ebcot_order_ptr; /* Used to record each new change in packet progression order. The `max_layers', `max_levels' and `max_components' fields identify constraints on the last specified progression order, while `new_progression' specifies the new progression order to apply beyond those bounds and within any bounds specified by an ensuing `ebcot_order' structure, referenced by `next'. The information in a list of `ebcot_order' structures, managed from the `ebcot_tile' structure, directly reflects that in the POC marker. *//*****************************************************************************//* ebcot_sequence *//*****************************************************************************/typedef struct ebcot_sequence { int layer_idx; ebcot_packet_info_ptr packet; } ebcot_sequence, *ebcot_sequence_ptr; /* This structure is used to maintain the identity of a particular codestream packet in sequence. A codestream packet consists of a particular quality layer within the region identified by the `packet' pointer; this simply points into the `packets' array managed by the appropriate `ebcot_level_info' structure. *//*****************************************************************************//* ebcot_tile *//*****************************************************************************/typedef struct ebcot_tile { int tnum; canvas_dims reference_dims; int num_components; ebcot_component_info_ptr components; int num_layers; int total_packets; ebcot_sequence_ptr packet_sequence; int progression; ebcot_order_ptr progression_changes; int tile_bytes; } ebcot_tile, *ebcot_tile_ptr; /* This structure encapsulates all state information for a single tile. All parameters, with the exception of the number of image components, may change from tile-to-tile. The `tnum' field identifies the coordinate of the tile. The `reference_dims' structure describes the location and dimensions of the tile on the reference grid. The `num_components' field indicates the number of image components. This is the same in every tile, but it is convenient to keep it here. The `components' array manages the state information for each image component within the tile. We call these tile-components. The `num_layers' field holds the number of quality layers for the tile; in the current implementation it is always identical to the value held in its namesake within the `ebcot_encoder' object itself. The `total_packets' field indicates the total number of packets contained in the tile. This is the sum of the `total_packets' fields from all `ebcot_level_info' structures, all multiplied by the number of quality layers. The `packet_sequence' field points to an array with `total_packets' entries, each of which corresponds to a particular packet, in the sequence in which packets appear in the codestream. The `progression' and `progression_changes' fields are used to derive the packet sequence; they represent the progression style from the COD marker and the additional information from any POC marker, respectively. The `tile_bytes' field holds the total number of bytes required to represent all packets from the tile in the codestream; it is computed during layer formation, immediately before outputting packets to the codestream. The value is required because tile headers must include a field stating the total number of bytes in the tile. *//* ========================================================================= *//* ---------------------------- Bit-Stream Layers -------------------------- *//* ========================================================================= *//*****************************************************************************//* ebcot_layer_info *//*****************************************************************************/typedef struct ebcot_layer_info { int max_cumulative_bytes; int actual_cumulative_bytes; int optimize; rd_slope_type rd_threshold; } ebcot_layer_info, *ebcot_layer_info_ptr; /* This structure keeps track of information involved in the formation of bit-stream layers. A bit-stream layer is composed of a collection of coding passes from some or all of the subband code blocks. The layer may be assembled in an optimal way subject to some target bit-rate. Alternatively, it may be assembled more rapidly to approximately achieve some target bit-rate. The encoder accepts command line arguments to identify the number of bit-stream layers and any special bit-rates for which a full optimization is requested. The fields of this structure have the following interpretation: `max_cumulative_bytes' holds the maximum number of bytes which can be consumed by this and any previous bit-stream layers, together. This is a hard maximum if `optimize' is non-zero (true); othewise, it represents a target bit-rate. `actual_cumulative_bytes' identifies the actual number of bytes which are consumed by this and any previous bit-stream layers. It is not known until after the bit-stream layer has been formed. `rd_threshold' is the rate-distortion threshold associated with the bit-stream layer. The layer includes all coding passes from all code blocks, such that the rate-distortion slope associated with that coding pass is greater than or equal to this threshold. The threshold is determined iteratively if `optimize' is true, in order to find the smallest threshold which is compatible with the `max_cumulative_bytes' constraint. If `optimize' is zero (false), however, the threshold is estimated from summary information accumulated during block coding. *//* ========================================================================= *//* ----------------------------- Encoder Object ---------------------------- *//* ========================================================================= *//*****************************************************************************//* ebcot_encoder *//*****************************************************************************/typedef struct ebcot_encoder { encoder_obj base; stream_out_ref stream; forward_roi_ref roi; int num_components; int num_tiles; int current_tile_idx; ebcot_tile_ptr tiles; int max_component_rows, max_component_cols; int num_layers; ebcot_layer_info_ptr layer_info; dst_codeword_heap_ref code_heap_mgr; ebcot_vpw_info_ptr vpw_info; std_int rd_slope_rates[1<<RD_SLOPE_EXPONENT_BITS]; int reverse_tiles; int omit_last_tile_length; std_int cpu_time; } ebcot_encoder_obj, *ebcot_encoder_ref; /* This structure represents the encoder object itself. The additional fields have the following interpretations: forward_info_ref info; `stream' holds a reference to the `stream_out' object to which the final bit-stream should be written. Interaction with this object is essential to ensure correct rate-control behaviour. `roi' holds a reference to the ROI object which may modify the entropy coder's behaviour in particular code-blocks. `num_tiles' indicates the total number of tiles which represent the image. `current_tile_idx' holds the zero-based index of the current tile for which information is being passed across the `encoder__push_line' interface function. `tiles' points to an array with `num_tiles' structures, which manage the state and coding parameters of each tile. Most properties of the coder are derived separately from each `ebcot_tile' structure. `num_layers' holds the number of R-D optimal quality layers which we will use to represent the compressed image. It makes relatively little sense to deliberately construct a bit-stream with different numbers of quality layers in each tile, so we make no provision for this during compression; the decompressor should be able to deal with the possibility though. `layer_info' points to an array with one entry for each quality layer, which identifies the target size for that layer and other information which is used during bit-stream formation to produce bit-streams which have particular properties. The information in this array need never be included in the codestream itself, since the decoder need only be aware of the number of layers to expect. `code_heap_mgr' references an object which manages the dynamic memory allocation for storage of generated code words. `vpw_info' points to an `ebcot_vpw_info' structure which manages all progressive visual weighting information. `rd_slope_rates' is an array with one entry for each valid exponent in the exponent-mantissa representation used for rate-distortion slopes, as discussed in the definition of the `rd_slope_type' data type. The entry at location k in this array accumulates the total number of code bytes from all code blocks in all subbands from all coding passes whose rate-distortion slope is greater than or equal to 2^k, where k runs from 0 to 2^{Ebits}-1. `reverse_tiles' is a flag indicating whether or not we should reverse the order of appearance of tiles in the codestream, just for a lark. `omit_last_tile_length' is a flag indicating whether or not th tile-length field should be set to 0 for the last tile in the codestream. `cpu_time' accumulates the CPU time associated with all block coding operations. If CPU time is not required, it should hold a negative value. *//* ========================================================================= *//* --------------------------- External Functions -------------------------- *//* ========================================================================= */extern void ebcot_set_pass_funcs(ebcot_band_info_ptr band, block_master_ptr master);#endif /* EBCOT_ENCODER_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -