vc2_conformance.pseudocode
: VC-2 pseudocode function implementations¶
The vc2_conformance.pseudocode
module contains implementations of
many of the VC-2 pseudocode functions and associated data structures. In
particular, it includes everything which can be used as-is in the construction
of encoders, decoders and so on without any alterations.
The VC-2 pseudocode is augmented by a modest number of additional functions or
data structure fields. For instance, additional fields are added to
State
which are used by
conformance checking routines and forward wavelet transform routines.
vc2_conformance.pseudocode.arrays
¶
VC-2 style 2D array functions (5.5).
-
new_array
(*dimensions)¶ (5.4.2) Makes an N-dimensional array out of nested lists. Dimensions are given in the same order as they are indexed, e.g.
new_array(height, width)
, likearray[y][x]
.
-
width
(a)¶ (5.5.4)
-
height
(a)¶ (5.5.4)
-
row
(a, k)¶ (15.4.1) A 1D-array-like view into a row of a (2D) nested list as returned by
new_array()
.
-
class
column
(a, k)¶ (15.4.1) A 1D-array-like view into a column of a (2D) nested list as returned by
new_array()
.
-
delete_rows_after
(a, k)¶ (15.4.5) Delete rows ‘k’ and after in ‘a’.
-
delete_columns_after
(a, k)¶ (15.4.5) Delete columns ‘k’ and after in ‘a’.
vc2_conformance.pseudocode.offsetting
¶
Picture component offsetting routines (15)
This module collects picture component value offsetting functions from (15) and augments these with complementary de-offsetting functions (inferred from, but not defined by the standard).
-
offset_picture
(state, current_picture)¶ (15.5) Remove picture value offsets (added during encoding).
- Parameters
- state
vc2_conformance.pseudocode.state.State
Where
luma_depth
andcolor_diff_depth
are defined.- current_picture{comp: [[pixel_value, …], …], …}
Will be mutated in-place.
- state
-
offset_component
(state, comp_data, c)¶ (15.5) Remove picture value offsets from a single component.
-
remove_offset_picture
(state, current_picture)¶ Inverse of offset_picture (15.5). Centers picture values around zero.
-
remove_offset_component
(state, comp_data, c)¶ Inverse of offset_component (15.5). Centers picture values around zero.
- Parameters
- state
vc2_conformance.pseudocode.state.State
Where
luma_depth
andcolor_diff_depth
are defined.- current_picture{comp: [[pixel_value, …], …], …}
Will be mutated in-place.
- state
vc2_conformance.pseudocode.parse_code_functions
¶
Parse code classification functions (Table 10.2)
These functions all take a ‘state’ dictionary containing at least
parse_code
which should be an int or ParseCodes
enum value.
-
is_seq_header
(state)¶ (Table 10.2)
-
is_end_of_sequence
(state)¶ (Table 10.2)
-
is_auxiliary_data
(state)¶ (Table 10.2)
-
is_padding_data
(state)¶ (Table 10.2)
-
is_ld
(state)¶ (Table 10.2)
-
is_hq
(state)¶ (Table 10.2)
-
is_picture
(state)¶ (Table 10.2)
-
is_fragment
(state)¶ (Table 10.2)
-
using_dc_prediction
(state)¶ (Table 10.2)
vc2_conformance.pseudocode.picture_decoding
¶
This module contains the wavelet synthesis filters and associated functions defined in the pseudocode of the VC-2 standard (15).
See also vc2_conformance.pseudocode.picture_encoding
.
-
inverse_wavelet_transform
(state)¶ (15.3)
-
idwt
(state, coeff_data)¶ (15.4.1)
Inverse Discrete Wavelet Transform.
- Parameters
- state
State
A state dictionary containing at least the following:
wavelet_index
wavelet_index_ho
dwt_depth
dwt_depth_ho
- coeff_data{level: {orientation: [[coeff, …], …], …}, …}
The complete (power-of-two dimensioned) transform coefficient data.
- state
- Returns
- picture[[pixel_value, …], …]
The synthesized picture.
-
h_synthesis
(state, L_data, H_data)¶ (15.4.2) Horizontal-only synthesis.
-
vh_synthesis
(state, LL_data, HL_data, LH_data, HH_data)¶ (15.4.3) Interleaved vertical and horizontal synthesis.
-
oned_synthesis
(A, filter_index)¶ (15.4.4.1) and (15.4.4.3). Acts in-place on ‘A’
-
filter_bit_shift
(state)¶ (15.4.2) Return the bit shift for the current horizontal-only filter.
-
lift1
(A, L, D, taps, S)¶ (15.4.4.1) Update even, add odd.
-
lift2
(A, L, D, taps, S)¶ (15.4.4.1) Update even, subtract odd.
-
lift3
(A, L, D, taps, S)¶ (15.4.4.1) Update odd, add even.
-
lift4
(A, L, D, taps, S)¶ (15.4.4.1) Update odd, subtract even.
-
idwt_pad_removal
(state, pic, c)¶ (15.4.5)
-
offset_picture
(state, current_picture)¶ (15.5) Remove picture value offsets (added during encoding).
- Parameters
- state
vc2_conformance.pseudocode.state.State
Where
luma_depth
andcolor_diff_depth
are defined.- current_picture{comp: [[pixel_value, …], …], …}
Will be mutated in-place.
- state
-
offset_component
(state, comp_data, c)¶ (15.5) Remove picture value offsets from a single component.
-
clip_picture
(state, current_picture)¶ (15.5)
-
clip_component
(state, comp_data, c)¶ (15.5)
-
SYNTHESIS_LIFTING_FUNCTION_TYPES
= {...}¶ Lookup from lifting function ID to function implementation for implementing wavelet synthesis.
vc2_conformance.pseudocode.picture_encoding
¶
This module is the inverse of the
vc2_conformance.pseudocode.picture_decoding
module and contains
functions for performing wavelet analysis filtering.
This functionality is not specified by the standard but is used to generate simple bitstreams (and test cases) in this software (and its test suite).
-
picture_encode
(state, current_picture)¶ Inverse of picture_decode (15.2).
- Parameters
- state
vc2_conformance.pseudocode.state.State
A state dictionary containing at least:
luma_width
luma_height
color_diff_width
color_diff_height
luma_depth
color_diff_depth
wavelet_index
wavelet_index_ho
dwt_depth
dwt_depth_ho
The following entries will be added/replaced with the encoded picture.
y_transform
c1_transform
c3_transform
- current_picture{component: [[value, …], …], …}
The picture to be encoded.
- state
-
forward_wavelet_transform
(state, current_picture)¶ (15.3)
-
dwt
(state, picture)¶ Discrete Wavelet Transform, inverse of idwt (15.4.1)
- Parameters
- state
State
A state dictionary containing at least the following:
wavelet_index
wavelet_index_ho
dwt_depth
dwt_depth_ho
- picture[[pixel_value, …], …]
The synthesized picture.
- state
- Returns
- coeff_data{level: {orientation: [[coeff, …], …], …}, …}
The complete (power-of-two dimensioned) transform coefficient data.
-
h_analysis
(state, data)¶ Horizontal-only analysis, inverse of h_synthesis (15.4.2).
Returns a tuple (L_data, H_data)
-
vh_analysis
(state, data)¶ Interleaved vertical and horizontal analysis, inverse of vh_synthesis (15.4.3).
Returns a tuple (LL_data, HL_data, LH_data, HH_data)
-
oned_analysis
(A, filter_index)¶ Inverse of oned_synthesis (15.4.4.1) and (15.4.4.3). Acts in-place on ‘A’
-
dwt_pad_addition
(state, pic, c)¶ Inverse of idwt_pad_removal (15.4.5): pads a picture to a size compatible with wavelet filtering at the level specified by the provided
State
.Extra values are obtained by copying the final pixels in the existing rows and columns.
-
remove_offset_picture
(state, current_picture)¶ Inverse of offset_picture (15.5). Centers picture values around zero.
-
remove_offset_component
(state, comp_data, c)¶ Inverse of offset_component (15.5). Centers picture values around zero.
- Parameters
- state
vc2_conformance.pseudocode.state.State
Where
luma_depth
andcolor_diff_depth
are defined.- current_picture{comp: [[pixel_value, …], …], …}
Will be mutated in-place.
- state
-
ANALYSIS_LIFTING_FUNCTION_TYPES
= {...}¶ Lookup from lifting function ID to function implementation for implementing wavelet analysis.
vc2_conformance.pseudocode.quantization
¶
Quantization-related VC-2 pseudocode routines (13.3).
-
inverse_quant
(quantized_coeff, quant_index)¶ (13.3.1)
-
forward_quant
(coeff, quant_index)¶ (13.3.1) Based on the informative note 1.
-
quant_factor
(index)¶ (13.3.2)
-
quant_offset
(index)¶ (13.3.2)
vc2_conformance.pseudocode.slice_sizes
¶
Slice size computation functions (13)
All of the functions below take a ‘state’ argument which should be a dictionary-like object containing the following entries:
"luma_width"
"luma_height"
"color_diff_width"
"color_diff_height"
"dwt_depth"
"dwt_depth_ho"
The slice_bytes()
, slice_top()
, slice_bottom()
,
slice_left()
, slice_right()
and
slices_have_same_dimensions()
functions all additionally require the
following entries:
"slices_x"
"slices_y"
Finally slice_bytes()
function requires the following further values:
"slice_bytes_numerator"
"slice_bytes_denominator"
The ‘c’ or ‘comp’ arguments should be set to one of the following strings:
"Y"
"C1"
"C2"
The slices_have_same_dimensions()
utility is added beyond the VC-2
pseudocode functions which determines if all slices will contain the same
number of samples or not.
-
subband_width
(state, level, comp)¶ (13.2.3)
-
subband_height
(state, level, comp)¶ (13.2.3)
-
slice_bytes
(state, sx, sy)¶ (13.5.3.2) Compute the number of bytes in a low-delay picture slice.
-
slice_left
(state, sx, c, level)¶ (13.5.6.2) Get the x coordinate of the LHS of the given slice.
-
slice_right
(state, sx, c, level)¶ (13.5.6.2) Get the x coordinate of the RHS of the given slice.
-
slice_top
(state, sy, c, level)¶ (13.5.6.2) Get the y coordinate of the top of the given slice.
-
slice_bottom
(state, sy, c, level)¶ (13.5.6.2) Get the y coordinate of the bottom of the given slice.
-
slices_have_same_dimensions
(state)¶ Utility function, not part of the standard. Tests whether all picture slices will have the same dimensions.
vc2_conformance.pseudocode.state
¶
A fixeddict
for the ‘state’ object used by the
pseudocode in the VC-2 spec.
-
fixeddict
State
¶ The global state variable type.
Entries prefixed with an underscore (
_
) are not specified by the VC-2 pseudocode but may be used by the conformance software.- Keys
- video_parameters
VideoParameters
Set by (10.4.1) parse_sequence
- parse_code
ParseCodes
Set by (10.5.1) parse_info
- next_parse_offsetint
Set by (10.5.1) parse_info
- previous_parse_offsetint
Set by (10.5.1) parse_info
- picture_coding_mode
PictureCodingModes
Set by (11.1) sequence_header
- major_versionint
Set by (11.2.1) parse_parameters
- minor_versionint
Set by (11.2.1) parse_parameters
- profile
Profiles
Set by (11.2.1) parse_parameters
- level
Profiles
Set by (11.2.1) parse_parameters
- luma_widthint
Set by (11.6.2) picture_dimensions
- luma_heightint
Set by (11.6.2) picture_dimensions
- color_diff_widthint
Set by (11.6.2) picture_dimensions
- color_diff_heightint
Set by (11.6.2) picture_dimensions
- luma_depthint
Set by (11.6.3) video_depth
- color_diff_depthint
Set by (11.6.3) video_depth
- picture_numberint
Set by (12.2) picture_header and (14.2) fragment_header
- wavelet_index
WaveletFilters
Set by (12.4.1) transform_parameters
- dwt_depthint
Set by (12.4.1) transform_parameters
- wavelet_index_ho
WaveletFilters
Set by (12.4.4.1) extended_transform_parameters
- dwt_depth_hoint
Set by (12.4.4.1) extended_transform_parameters
- slices_xint
Set by (12.4.5.2) slice_parameters
- slices_yint
Set by (12.4.5.2) slice_parameters
- slice_bytes_numeratorint
Set by (12.4.5.2) slice_parameters
- slice_bytes_denominatorint
Set by (12.4.5.2) slice_parameters
- slice_prefix_bytesint
Set by (12.4.5.2) slice_parameters
- slice_size_scalerint
Set by (12.4.5.2) slice_parameters
- quant_matrix{level: {orient: int, …}, …}
Set by (12.4.5.3) quant_matrix
- quantizer{level: {orient: int, …}, …}
Set by (13.5.5) slice_quantizers
- y_transform{level: {orient: [[int, …], …], …}, …}
Set by (13.5.6.3) slice_band. The dequantised luma transform data read from the bitstream. A 2D array for each subband, indexed as [level][orient][y][x].
- c1_transform{level: {orient: [[int, …], …], …}, …}
Set by (13.5.6.3) slice_band and (13.5.6.4) color_diff_slice_band. The dequantised color difference 1 transform data read from the bitstream. A 2D array for each subband, indexed as [level][orient][y][x].
- c2_transform{level: {orient: [[int, …], …], …}, …}
Set by (13.5.6.3) slice_band and (13.5.6.4) color_diff_slice_band. The dequantised color difference 2 transform data read from the bitstream. A 2D array for each subband, indexed as [level][orient][y][x].
- fragment_data_lengthint
Set by (14.2) fragment_header
- fragment_slice_countint
Set by (14.2) fragment_header
- fragment_x_offsetint
Set by (14.2) fragment_header
- fragment_y_offsetint
Set by (14.2) fragment_header
- fragment_slices_receivedint
Set by (14.4) fragment_data
- fragmented_picture_doneint
Set by (14.4) fragment_data
- current_picture{‘pic_num’: int, ‘Y’: [[int, …], …], ‘C1’: [[int, …], …], ‘C2’: [[int, …], …]}
Set by (15.2) picture_decode, contains the decoded picture.
- next_bitint
Set by (A.2.1) read_*
- current_byteint
Set by (A.2.1) read_*
- bits_leftint
Bits left in the current bounded block (A.4.2)
- _generic_sequence_matcher
vc2_conformance.symbol_re.Matcher
Not in spec, used by
vc2_conformance.decoder
. AMatcher
which checks that the sequence follows the specified general pattern of data units (10.4.1) (e.g. start with a sequence header, end with end of sequence). Other matchers will test for, e.g. level-defined patterns.- _output_picture_callbackfunction({‘pic_num’: int, ‘Y’: [[int, …], …], ‘C1’: [[int, …], …], ‘C2’: [[int, …], …]},
VideoParameters
,PictureCodingModes
) Not in spec, used by
vc2_conformance.decoder
. A callback function to call whenoutput_picture
(15.2) is called. This callback (if defined) will be passed the picture, video parameters and picture coding mode.- _num_pictures_in_sequenceint
Not in spec, used by
vc2_conformance.decoder
. (10.4.3) and (12.2) A counter of how many pictures have been encountered in the current sequence. Used to determine if all fields have been received (when pictures are fields) and that the earliest fields have an even picture number. Initialised in parse_sequence (10.4.1) and incremented invc2_conformance.decoder.assertions.assert_picture_number_incremented_as_expected()
, called in picture_header (12.2), and fragment_header (14.2).- _last_parse_info_offsetint
Not in spec, used by
vc2_conformance.decoder
. (10.5.1) parse_info related state. The byte offset of the previously read parse_info block.- _recorded_bytes
bytearray
Not in spec, used by
vc2_conformance.decoder
. (11.1) sequence_header requires that repeats must be byte-for-byte identical. To facilitate this, thevc2_conformance.decoder.io.record_bitstream_start()
andvc2_conformance.decoder.io.record_bitstream_finish()
functions are used to make a recording. When this entry is absent, read_byte works as usual. If it is abytearray
, whenever a byte has been completely read, it will be placed into this array.- _last_sequence_header_bytes
bytearray
Not in spec, used by
vc2_conformance.decoder
. (11.1) the bitstream bytes of the data which encoded the previous sequence_header in the sequence. Not present if no previous sequence_header has appeared.- _last_sequence_header_offsetint
Not in spec, used by
vc2_conformance.decoder
. (11.1) the bitstream offset in bytes of the data which encoded the previous sequence_header in the sequence. Not present if no previous sequence_header has appeared.- _expected_major_versionint
Not in spec, used by
vc2_conformance.decoder
. Used to record the expected major_version (11.2.1) for this sequence according to the constraints listed in (11.2.2). This field is set bylog_version_lower_bound()
.- _last_picture_number_offset(byte offset, next bit)
Not in spec, used by
vc2_conformance.decoder
. (12.2) picture_header and (14.2) fragment_header: The offset of the last picture number encountered in the sequence (or absent if no pictures have yet been encountered).- _last_picture_numberint
Not in spec, used by
vc2_conformance.decoder
. (12.2) picture_header and (14.2) fragment_header: The last picture number encountered in the sequence (or absent if no pictures have yet been encountered).- _picture_initial_fragment_offset(byte offset, next bit)
Not in spec, used by
vc2_conformance.decoder
. (14) The offset in the bitstream of the last fragment with fragment_slice_count==0.- _fragment_slices_remainingint
Not in spec, used by
vc2_conformance.decoder
. (14) The number of fragment slices which remain to be received in the current picture. Initialised to zero by parse_sequence (10.4.1), reset to the number of slices per picture by initialize_fragment_state (14.3) and decremented whenever a slice is received by fragment_data (14.4).- _filefile-like
The Python file-like object from which the bitstream will be read by read_byte (A.2.1) .
- _level_sequence_matcher
vc2_conformance.symbol_re.Matcher
Not in spec, used by
vc2_conformance.decoder
. AMatcher
which checks that the sequence follows the pattern dictated by the current level. Populated after the first (11.2.1) parse_parameters is encountered (and should therefore be ignored until that point).- _level_constrained_values{key: value, …}
Not in spec, used by
vc2_conformance.decoder
. A dictionary which will be incrementally populated with values read or computed from the bitstream which are constrained by the level constraints table (seevc2_conformance.level_constraints.LEVEL_CONSTRAINTS
andvc2_conformance.decoder.assertions.assert_level_constraint()
).
- video_parameters
vc2_conformance.pseudocode.vc2_math
¶
Mathematical functions and operators defined in the spec (5.5.3)
-
intlog2_float
(n)¶ (5.5.3) Implemented as described in the spec, requiring floating point arithmetic.
In practice, the alternative implementation in
intlog2()
should be used instead since it does not rely on floating point arithmetic (and is therefore faster and has unlimited precision).
-
intlog2
(n)¶ (5.5.3) Implemented via pure integer, arbitrary-precision operations.
-
sign
(a)¶ (5.5.3)
-
clip
(a, b, t)¶ (5.5.3)
-
mean
(*S)¶ (5.5.3)
vc2_conformance.pseudocode.video_parameters
¶
Video parameter computation functions (11)
The functions in this module make up the purely functional (i.e. non bitstream-reading) logic for computing video parameters. This predominantly consists of preset-loading and component dimension calculation routines.
For functions below which take a ‘state’ argument, this should be a
dictionary-like object (e.g.
State
) with the following
entries:
"frame_width"
"frame_height"
"luma_width"
"luma_height"
"color_diff_width"
"color_diff_height"
"luma_depth"
"color_diff_depth"
"picture_coding_mode"
-
fixeddict
VideoParameters
¶ (11.4) Video parameters struct.
- Keys
- frame_widthint
Set by (11.4.3) frame_size
- frame_heightint
Set by (11.4.3) frame_size
- color_diff_format_index
ColorDifferenceSamplingFormats
Set by (11.4.4) color_diff_sampling_format
- source_sampling
SourceSamplingModes
Set by (11.4.5) scan_format
- top_field_firstbool
Set by (11.4.5) set_source_defaults
- frame_rate_numerint
Set by (11.4.6) frame_rate
- frame_rate_denomint
Set by (11.4.6) frame_rate
- pixel_aspect_ratio_numerint
Set by (11.4.7) aspect_ratio
- pixel_aspect_ratio_denomint
Set by (11.4.7) aspect_ratio
- clean_widthint
Set by (11.4.8) clean_area
- clean_heightint
Set by (11.4.8) clean_area
- left_offsetint
Set by (11.4.8) clean_area
- top_offsetint
Set by (11.4.8) clean_area
- luma_offsetint
Set by (11.4.9) signal_range
- luma_excursionint
Set by (11.4.9) signal_range
- color_diff_offsetint
Set by (11.4.9) signal_range
- color_diff_excursionint
Set by (11.4.9) signal_range
- color_primaries_index
PresetColorPrimaries
Set by (11.4.10.2) color_primaries
- color_matrix_index
PresetColorMatrices
Set by (11.4.10.3) color_matrix
- transfer_function_index
PresetTransferFunctions
Set by (11.4.10.4) transfer_function
-
set_source_defaults
(base_video_format)¶ (11.4.2) Create a
VideoParameters
object with the parameters specified in a base video format.
-
set_coding_parameters
(state, video_parameters)¶ (11.6.1) Set picture coding mode parameter.
-
picture_dimensions
(state, video_parameters)¶ (11.6.2) Compute the picture component dimensions in global state.
-
video_depth
(state, video_parameters)¶ (11.6.3) Compute the bits-per-sample for the decoded video.
-
preset_frame_rate
(video_parameters, index)¶ (11.4.6) Set frame rate from preset.
-
preset_pixel_aspect_ratio
(video_parameters, index)¶ (11.4.7) Set pixel aspect ratio from preset.
-
preset_signal_range
(video_parameters, index)¶ (11.4.7) Set signal range from preset.
-
preset_color_primaries
(video_parameters, index)¶ (11.4.10.2) Set the color primaries parameter from a preset.
-
preset_color_matrix
(video_parameters, index)¶ (11.4.10.3) Set the color matrix parameter from a preset.
-
preset_transfer_function
(video_parameters, index)¶ (11.4.10.4) Set the transfer function parameter from a preset.
-
preset_color_spec
(video_parameters, index)¶ (11.4.10.1) Load a preset color specification.
vc2_conformance.pseudocode.metadata
¶
The vc2_conformance.pseudocode.metadata
module is used to record the
relationship between the functions in the vc2_conformance
software
and the pseudocode functions in the VC-2 specification documents. This
information has two main uses:
To produce more helpful error messages which include cross-references to published specifications.
To enable automatic verification that the behaviour of this software exactly matches the published specifications (see
verification
).
Implementing pseudocode functions¶
Functions in the codebase which implement a pseudocode function in the
specification must be labelled as such using the ref_pseudocode()
decorator:
>>> from vc2_conformance.pseudocode.metadata import ref_pseudocode
>>> @ref_pseudocode
... def parse_info(state):
... '''(10.5.1) Read a parse_info header.'''
... byte_align()
... read_uint_lit(state, 4)
... state["parse_code"] = read_uint_lit(state, 1)
... state["next_parse_offset"] = read_uint_lit(state, 4)
... state["previous_parse_offset"] = read_uint_lit(state, 4)
The ref_pseudocode()
decorator will log the existence of the decorated
function, along with the reference to the spec at the start of its docstring.
By default, it is implied that a decorated function does not deviate from the
pseudocode – a fact which is verified by the verification
module in
the test suite. When a function does deviate (for example for use in
serialisation/deserialisation) or is not defined in the spec, the deviation
argument should be provided. This is used by the verification
logic
to determine how the function will be verified. See
Pseudocode deviations for the allowed values. For example:
>>> @ref_pseudocode(deviation="serdes")
... def parse_parameters(serdes, state):
... '''(11.2.1)'''
... state["major_version"] = serdes.uint("major_version")
... state["minor_version"] = serdes.uint("minor_version")
... state["profile"] = serdes.uint("profile")
... state["level"] = serdes.uint("level")
-
ref_pseudocode
(*args, **kwargs)¶ Decorator for marking functions which are derived from the VC-2 pseudocode.
Example usage:
@ref_pseudocode def parse_info(state): ''''(10.5.1) Read a parse_info header.''' # ... @ref_pseudocode("10.5.1", deviation="alternative_implementation") def parse_info(state): '''Some alternative implementation of parse info.'''
- Parameters
- deviationstr or None
If this function deviates from the pseudocode in any way, indicates the nature of this deviation. None indicates that this function exactly matches the pseudocode.
Automatic checks for pseudocode equivalence in the test suite (see
verification
) will use this value to determine how exactly this function must match the pseudocode for tests to pass. See Pseudocode deviations for details of values this field may hold.- document, sectionstr or None
The name of the document and section defining this function. If None, will be extracted from the function docstring. Defaults to the main VC-2 specification. If not provided, and not found in the docstring, a
TypeError
will be thrown.When extracted from a docstring, a reference of one of the following forms must be used at the start of the docstring:
(1.2.3)
: Reference a section in the main VC-2 spec(SMPTE ST 20402-2:2017: 1.2.3)
: Reference a section in another spec
- namestr or None
The name of the pseudocode function this function implements. If None, the provided function’s name will be used.
Accessing the metadata¶
After all submodules of vc2_conformance
have been loaded, the
pseudocode_derived_functions
list will be populated with
PseudocodeDerivedFunction
instances for every pseudocode derived
function annotated with ref_pseudocode()
.
-
class
PseudocodeDerivedFunction
(function, deviation=None, document=None, section=None, name=None)¶ A record of a pseudocode-derived function within this codebase.
- Parameters
- functionfunction
The Python function which was derived from a pseudocode function.
- deviationstr or None
If this function deviates from the pseudocode in any way, indicates the nature of this deviation. None indicates that this function exactly matches the pseudocode.
Automatic checks for pseudocode equivalence in the test suite (see
verification
) will use this value to determine how exactly this function must match the pseudocode for tests to pass. See Pseudocode deviations for details of values this field may hold.- document, sectionstr or None
The name of the document and section defining this function. If None, will be extracted from the function docstring. Defaults to the main VC-2 specification. If not provided, and not found in the docstring, a
TypeError
will be thrown.When extracted from a docstring, a reference of one of the following forms must be used at the start of the docstring:
(1.2.3)
: Reference a section in the main VC-2 spec(SMPTE ST 20402-2:2017: 1.2.3)
: Reference a section in another spec
- namestr or None
The name of the pseudocode function this function implements. If None, the provided function’s name will be used.
-
property
citation
¶ A human-readable citation string for this pseudocode function.
-
pseudocode_derived_functions
= [PseudocodeDerivedFunction, ...]¶ The complete set of
PseudocodeDerivedFunctions
in this code base, in no particular order.Warning
This array is only completely populated once every module of
vc2_conformance
has been loaded.
Pseudocode tracebacks¶
The make_pseudocode_traceback()
function may be used to convert a
Python traceback into a pseudocode function traceback.
-
make_pseudocode_traceback
(tb)¶ Given a
traceback.extract_tb()
generated traceback description, return a list ofPseudocodeDerivedFunction
objects for the stack trace, most recently called last. Entries in the traceback which don’t have a corresponding pseudocode-derived function are omitted.