vc2_bit_widths.signal_bounds
: Finding bounds for filter output values¶
The vc2_bit_widths.signal_bounds
module contains functions for
computing theoretical lower- and upper-bounds for VC-2 codec intermediate and
final values.
Finding signal bounds¶
The following functions may be used to convert algebraic descriptions of a VC-2 filters into worst-case signal ranges (according to an affine arithmetic based model of rounding and quantisation).
The process of finding signal bounds is split into two stages:
Finding a generic algebraic expression for worst-case signal bounds.
Evaluating those expressions for a particular picture bit width.
The two steps are split this way to allow step 2 to be inexpensively repeated for different picture bit widths.
Analysis filter¶
-
analysis_filter_bounds
(expression)¶ Find the lower- and upper-bound reachable in a
LinExp
describing an analysis filter.The filter expression must consist of only affine error symbols (
AAError
) and symbols of the form(_, x, y)
representing pixel values in an input picture.- Parameters
- expression
LinExp
- expression
- Returns
-
evaluate_analysis_filter_bounds
(lower_bound_exp, upper_bound_exp, num_bits)¶ Convert a pair of symbolic analysis filter bounds into concrete, numerical lower/upper bounds for an input picture signal with the specified number of bits.
- Parameters
- lower_bound_exp
LinExp
- upper_bound_exp
LinExp
Analysis filter bounds expressions from
analysis_filter_bounds()
.- num_bitsint
The number of bits in the signal values being analysed.
- lower_bound_exp
- Returns
- lower_boundint
- upper_boundint
The concrete (numerical) bounds for the analysis filter given
num_bits
input pictures.
Synthesis filter¶
-
synthesis_filter_bounds
(expression)¶ Find the lower- and upper-bound reachable in a
LinExp
describing a synthesis filter.The filter expression must contain only affine error symbols (
AAError
) and symbols of the form((_, level, orient), x, y)
representing transform coefficients.- Parameters
- expression
LinExp
- expression
- Returns
- (lower_bound, upper_bound)
LinExp
Lower and upper bounds for the signal level in terms of the symbols of the form
LinExp("signal_LEVEL_ORIENT_min")
andLinExp("signal_LEVEL_ORIENT_max")
, representing the minimum and maximum signal levels for transform coefficients in levelLEVEL
and orientationORIENT
respectively.
- (lower_bound, upper_bound)
-
evaluate_synthesis_filter_bounds
(lower_bound_exp, upper_bound_exp, coeff_bounds)¶ Convert a pair of symbolic synthesis filter bounds into concrete, numerical lower/upper bounds given the bounds of the input transform coefficients.
- Parameters
- lower_bound_exp
LinExp
- upper_bound_exp
LinExp
Synthesis filter bounds expressions from
synthesis_filter_bounds()
.- coeff_bounds{(level, orient): (lower_bound, upper_bound), …}
For each transform coefficient, the concrete lower and upper bounds (e.g. as computed using
evaluate_analysis_filter_bounds()
andvc2_bit_widths.quantisation.maximum_dequantised_magnitude()
for each transform subband).
- lower_bound_exp
- Returns
- lower_boundint
- upper_boundint
The concrete (numerical) bounds for the synthesis filter.
Integer representation utilities¶
The following utility functions compute the relationship between bit-width and numerical range.
-
twos_compliment_bits
(value)¶ How many bits does the provided integer require for a two’s compliment (signed) integer representation?
-
signed_integer_range
(num_bits)¶ Return the lower- and upper-bound values for a signed integer with the specified number of bits.
-
unsigned_integer_range
(num_bits)¶ Return the lower- and upper-bound values for an unsigned integer with the specified number of bits.
The following function may be used to pessimistically round values to integers:
-
round_away_from_zero
(value)¶ Round a number away from zero.