📄 ebcot_encoder.h
字号:
cause access violations, which means that the base of the allocated memory is below the location pointed to by the `interleaved_context_buffer' field. For ease of deallocation, this base address is kept in the `context_buffer_handle' field. `d_cells' points to an array of distortion accumulation cells, each of which accommodates a nominal cell size of 8x8 samples. Vertically adjacent cells are separated by `d_cell_row_gap' entries in this array. `exploit_visual_masking' indicates whether or not the MSE distortion metric should be modified to account for visual masking phenomena. This is generally desirable if the objective is to optimize for visual quality. `masking_exponent' identifies the exponent for the local masking strength computation. If the sample values are normalized so that their magnitudes lie in the nominal range from 0 to 1.0, then the masking strength is found by taking a local average of the sample magnitudes, after first raising them to the power of this exponent. Each sample is then conceptually divided by (1 + a suitably scaled version of this masking strength) before computing the MSE contribution. `max_masked_sensitivity_reduction' holds the maximum value of the `fully_masked_sensitivity_reduction' field in the `ebcot_band_info' structure, taken over all subbands. It is used to calculate a global gain for visually masked distortion values so as to best utilize the dynamic range available for the representation of distortion-rate slopes. `coder_state' holds the current state of the arithmetic coder. Its contents may be periodically saved to the `saved_states' array in order to allow reconstruction of the number of bits required to uniquely recover all coded symbols up to that point. `zc_lut' identifies the zero-coding lookup table to be used in selecting coding contexts based upon the significance of the eight immediate neighbours. An appropriate pointer will be inserted here for the relevant subband. `initial_mse_lut' points to one of the two global LUT's `ebcot_initial_mse_lut' or `ebcot_lossless_initial_mse_lut', depending upon whether the current coding pass involves potential refinement to the LSB of a lossless representation of the relevant sample values. MSE estimation is different in this case, since the dequantizer will not be introducing any half steps. Similarly, `refinement_mse_lut' points to one of the two global LUT's `ebcot_refinement_mse_lut' or `ebcot_lossless_refinement_mse_lut', depending upon whether the current coding pass involves potential refinement to the LSB of a lossless representation of the relevant subband sample values. `contexts' holds the context state information used by the adaptive arithmetic coder. Its entries are set to some initial state (usually equi-probable distributions) before coding each block. `saved_states' holds the arithmetic coding state information during each successive pass through the block samples. Currently we save all the intermediate states and compute the number of bytes required to uniquely decode the symbols encoded for the relevant pass only once all passes have been encoded. In a hardware solution, a more incremental technique might be employed, but this would complement our current software implementation. `cumulative_wmse' holds the cumulative amounts by which each successive block coding pass reduces the weighted MSE of the reconstructed image. These numbers should be exact for orthogonal transforms. They should also be exact for any transform, subject to the assumption that quantization errors are uncorrelated (unlikely to be strictly valid in practice). Thus, the entries should increase from pass to pass. These numbers will be used to compute slopes on the convex hull of the rate distortion curve once the block has been completely coded. `roi_mask' points to an array with `max_height' entries which is used to store pointers to the rows of the mask returned by calls to `forward_roi__check_roi'. *//*****************************************************************************//* block_coding_pass_func *//*****************************************************************************/typedef void /* David T Cvis mod */ (*block_coding_pass_func)(block_master_ptr master); /* This prototype defines the form of the lowest level functions in the block coding algorithm. It uses the supplied `master' object to determine the subblocks with the code-block which must be coded, as well as the size and location of each subblock and all parameters relevant to the current coding pass. The function fills in the `delta_mse' field of each distortion cell in the `d_cells' array identified in the `master' structure, to reflect the normalized reduction in MSE which may be attributed to the coding pass for each distortion cell in the code-block. See the definition of `distortion_cell' for more information. *//*****************************************************************************//* ebcot_pass_info *//*****************************************************************************/typedef struct ebcot_pass_info { std_int cumulative_bytes; rd_slope_type rd_slope; std_short terminated; } ebcot_pass_info, *ebcot_pass_info_ptr; /* This structure manages information concerning the code size and the rate-distortion slope at the end of any given block coding pass. `cumulative_bytes' holds the number of code bytes which are required to uniquely decode all symbols up to and including the completion of the relevant pass. `rd_slope' holds a quantized representation of the slope of the rate-distortion curve at each block coding pass. Specifically, the slope value, S, is proportional to `delta_MSE' / `delta_RATE' where `delta_MSE' is the drop in Weighted MSE and `delta_RATE' is the increase in bit-rate since the last pass which lay on the convex hull of the rate-distortion curve. It should be noted, however, that S is related to the integer value in `rd_slope' via the exponent-mantissa relationship discussed with the definition of `rd_slope_type'. Coding passes whose rate-distortion performance does not lie on the convex hull of the rate-distortion curve are assigned `rd_slope' = 0, except when the relevant coding pass does not reduce the distortion at all, in which case we assign `rd_slope' = -1. Apart from these two special cases, all points which lie on the convex hull of the rate-distortion curve are assigned integral slope values in the range 1 <= `rd_slope' < (1^16), which means that the actual range of legal slopes is (1+2^{-Mbits}) <= S < 2^{2^{Ebits}}, where Ebits and Mbits are the RD_SLOPE_EXPONENT_BITS and RD_SLOPE_MANTISSA_BITS values, respectively. For more information, consult the definition of the `rd_slope_type' data type. `terminated' is a flag which is true (non-zero) if the arithmetic codeword generation process was terminated at the end of this coding pass. Of course, the last coding pass has this flag set, but other intermediate coding passes may also be terminated to enable parallelism and/or memory savings in certain hardware implementations and also to facilitate the lazy coding mode and error resilience. *//*****************************************************************************//* ebcot_block_info *//*****************************************************************************/typedef struct ebcot_block_info { int top_row, left_col, rows, cols; dst_heap_unit_ptr first_unit; int first_pos; int max_passes, num_passes, old_passes; ebcot_pass_info_ptr passes; int insignificant_msbs; int byte_count_bits, old_byte_count_bits; } ebcot_block_info, *ebcot_block_info_ptr; /* This structure maintains summary information for each coded block. An array of these structures is managed from the `ebcot_band_info' structure, with one entry for each block in the subband within the relevant tile. Pointers into this array are also managed by the `ebcot_packet_info' structure which represents an organization of the blocks in the subband into packets. In our current implementation the information in these structures is examined and used to construct the final bit-stream, only once all code blocks in the image have been coded. `top_row', `left_col', `rows' and `cols' hold the block dimensions and the indices of the first row and column in the block. Indices are relative to the upper left hand sample in the relevant subband-tile. They are not expressed relative to the absolute canvas coordinate system. `first_unit' points to the first `heap_unit' which contains code words for the block. The `first_pos' field identifies the location within this heap unit of the first code word generated for the block. Code bits for each block always commence on whole word boundaries within the heap unit structures. `max_passes' identifies the maximum number of coding passes which can be used to represent the coded block; this is the number which are generated during the block coding phase. Not all of these coding passes need necessarily be included in the bit-stream. `old_passes' is a utility variable which is used by the layered bit-stream formation algorithm. It represents the number of coding passes which have been included in previously formed bit-stream layers. `num_passes', on the other hand, represents the total number of coding passes which are to be included in all bit-stream layers up to and including the current layer. `passes' points to an array which is capable of holding `max_passes' entries, which describe the code size and rate-distortion slope at the end of each coding pass. In practice, we do not allocate a separate array for each code block, but allocate a single array which holds the concatenated `passes' arrays from all code blocks in all tiles of the subband. The first code block's `passes' field points to the head of this single allocated array. `insignificant_msbs' indicates the number of bit-planes, starting from the most significant magnitude bit of the IMPLEMENTATION_PRECISION-bit sign-magnitude words, for which all samples in the block were found to have zero magnitude. `byte_count_bits' is used by the T2 coding engine to code the number of bytes between successive termination and/or truncation points. Specifically, `byte_count_bits' holds the number of bytes per coding pass which were last used to signal differential code length information. To signal a new length quantity, L, corresponding to P new coding passes, we required the value of `byte_count_bits', B, to satisfy L < 2^(B*floor(log_2(P))). A comma code is used to increment the value of B until this condition is satisfied, after which the value of L is signalled using B*floor(log_2(P)) bits. The `old_byte_count_bits' field is used to save the value of `byte_count_bits' when conducting trials for rate control. For more information, consult the "ebcot_send_bits.c" file. *//*****************************************************************************//* ebcot_packet_band_info *//*****************************************************************************/typedef struct ebcot_packet_band_info { int blocks_high, blocks_wide, total_blocks, block_row_gap; ebcot_block_info_ptr blocks; struct ebcot_band_info *band; struct tag_tree_node *inclusion_tree; struct tag_tree_node *insignificant_msbs_tree; struct tag_tree_node *inclusion_tree_copy; struct tag_tree_node *insignificant_msbs_tree_copy; struct ebcot_band_tile_info *next; } ebcot_packet_band_info, *ebcot_packet_band_info_ptr; /* Holds information specific to a given packet within a subband. `blocks_high' and `blocks_wide' hold the number of blocks required to span the height and width of the packet within the relevant subband, while `total_blocks' holds the product of these two fields. The `block_row_gap' field identifies the total number of code-blocks between consecutive rows of blocks within the `blocks' array. In practice, this is identical to the `blocks_wide' field in the corresponding `ebcot_band_info' structure. `blocks' points to the first block of the packet. It is actually a pointer into the `blocks' array managed by the corresponding `ebcot_band_info' structure. Each entry stores code words and summary information collected while coding the relevant block. Note that this field may be NULL if the packet contains no blocks; this can happen. `band' points to corresponding `ebcot_band_info' structure. `inclusion_tree' and `insignificant_msbs_tree' point to tag-tree structures which manage the efficient writing of tag bits to represent two types of information for the packet. The `inclusion_tree' structure is used to represent information about whether or not any coding passes have been included into the bit-stream so far, for each of the blocks in the packet. The `insignificant_msbs_tree' structure is used to represent information embodied in the `insignificant_msbs' field of each `ebcot_block_info' structure for blocks within the packet. Beyond this brief description, the use of these data structures is best understood by reading the comments appearing with the definition of tag trees in "ebcot_send_bits.h" and the implementation of the `form_packet' function in "ebcot_send_bits.c". `inclusion_tree_copy' and `insignificant_msbs_tree_copy' are provided to allow the state of a packet construction phase to be saved and later recalled. *//*****************************************************************************//* ebcot_packet_info *//*****************************************************************************/typedef struct ebcot_packet_info { int tnum, component_idx, level_idx, packet_idx; int xref, yref; int min_band, max_band; ebcot_packet_band_info_ptr bands; int included_layers; int *layer_bytes; } ebcot_packet_info, *ebcot_packet_info_ptr; /* Holds information specific to a given packet. `tnum', `component_idx', `level_idx' and `packet_idx'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -