Generating test cases¶
Test cases for VC-2 encoders and decoders are generated by the vc2-test-case-generator program. Below we’ll walk through the process of defining the capabilities of our codec in a ‘codec features’ file and then generating the test cases accordingly.
Defining codec features¶
In order to generate an appropriate set of test cases for a VC-2 encoder or decoder we must first enumerate the capabilities of that codec in a codec features file. This file must contain a table, in Comma Separated Values (CSV) format enumerating codec configurations to be tested. An example table is given below:
name |
hd_lossy |
hd_fragmented |
hd_lossless |
custom_8_bit_rgb |
# (11.2.1) |
||||
level |
unconstrained |
unconstrained |
unconstrained |
unconstrained |
profile |
high_quality |
high_quality |
high_quality |
high_quality |
# (11.1) |
||||
base_video_format |
hd1080p_50 |
hd1080p_50 |
hd1080p_50 |
hd1080p_50 |
picture_coding_mode |
pictures_are_frames |
pictures_are_frames |
pictures_are_frames |
pictures_are_frames |
# (11.4.3) |
||||
frame_width |
default |
default |
default |
640 |
frame_height |
default |
default |
default |
480 |
# (11.4.4) |
||||
color_diff_format_index |
default |
default |
default |
color_4_4_4 |
# (11.4.5) |
||||
source_sampling |
default |
default |
default |
progressive |
top_field_first |
default |
default |
default |
TRUE |
# (11.4.6) |
||||
frame_rate_numer |
default |
default |
default |
25 |
frame_rate_denom |
default |
default |
default |
1 |
# (11.4.7) |
||||
pixel_aspect_ratio_numer |
default |
default |
default |
1 |
pixel_aspect_ratio_denom |
default |
default |
default |
1 |
# (11.4.8) |
||||
clean_width |
default |
default |
default |
640 |
clean_height |
default |
default |
default |
480 |
left_offset |
default |
default |
default |
0 |
top_offset |
default |
default |
default |
0 |
# (11.4.9) |
||||
luma_offset |
default |
default |
default |
0 |
luma_excursion |
default |
default |
default |
255 |
color_diff_offset |
default |
default |
default |
0 |
color_diff_excursion |
default |
default |
default |
255 |
# (11.4.10) |
||||
color_primaries_index |
default |
default |
default |
hdtv |
color_matrix_index |
default |
default |
default |
rgb |
transfer_function_index |
default |
default |
default |
tv_gamma |
# (12.4.1) and (12.4.4.1) |
||||
wavelet_index |
le_gall_5_3 |
le_gall_5_3 |
le_gall_5_3 |
le_gall_5_3 |
wavelet_index_ho |
le_gall_5_3 |
le_gall_5_3 |
le_gall_5_3 |
le_gall_5_3 |
dwt_depth |
2 |
2 |
2 |
2 |
dwt_depth_ho |
0 |
0 |
0 |
0 |
# (12.4.5.2) |
||||
slices_x |
240 |
240 |
240 |
80 |
slices_y |
135 |
135 |
135 |
60 |
# Slice size, etc. |
||||
lossless |
FALSE |
FALSE |
TRUE |
FALSE |
picture_bytes |
1296000 |
1296000 |
230400 |
|
fragment_slice_count |
0 |
8 |
0 |
0 |
# (12.4.5.3) |
||||
quantization_matrix |
default |
default |
default |
4 2 2 0 4 4 2 |
The first row should provide a unique name for each codec configuration for
which test cases are to be generated with the left-most cell containing the
text name. The remaining rows specify the parameters which define the codec
configurations. Empty rows and rows whose first column starts with a # are
ignored (i.e. treated as comments).
The following parameters must be given for each codec configuration.
levelInteger or alias. The VC-2 level number (see annex (C.3)) to report in the bit stream. If not
0(the ‘unconstrained’ level), the remaining parameters below must be set to values compatible with this level, otherwise the test case generator will reject the codec configuration.The following aliases can be used in place of an integer for additional readability.
Level
Alias
0
unconstrained1
sub_sd2
sd3
hd4
d_cinema_2k5
d_cinema_4k6
uhdtv_4k7
uhdtv_8k64
progressive_hd_over_sdi65
hd_over_sd_sdi66
uhd_over_hd_sdiprofileInteger or alias. The VC-2 profile number (see annex (C.2)).
0for ‘low-delay’ or3for ‘high quality’.The following aliases can be used in place of an integer for additional readability.
Profile
Alias
0
low_delay3
high_qualitypicture_coding_modeInteger or alias. The picture coding mode to use (see section (11.5)).
The following aliases can be used in place of an integer for additional readability.
Picture Coding Mode
Alias
0
pictures_are_frames1
pictures_are_fieldsbase_video_formatInteger or alias. The base video format index to use (see section (11.3) and annex (B)).
The following aliases can be used in place of an integer for additional readability.
Base Video Format
Alias
0
custom_format1
qsif5252
qcif3
sif5254
cif5
foursif5256
foursif7
sd_480i_608
sd576i_509
hd720p_6010
hd720p_5011
hd1080i_6012
hd1080i_5013
hd1080p_6014
hd1080p_5015
dc2k16
dc4k17
uhdtv4k_6018
uhdtv4k_5019
uhdtv8k_6020
uhdtv8k_5021
hd1080p_2422
sd_pro486Note
This parameter is provided as a convenient way of setting the video parameters below to common sets of options. This parameter, and the options below, do not directly define how the video format is encoded in bitstreams – this will be determined automatically by the test case generator. In fact, the test case generator will produce test cases with several different encodings when possible.
frame_widthandframe_heightInteger or
default. The dimensions of frames (not pictures) of video (see section (11.4.3)). Ifdefault, uses the dimensions specified by thebase_video_format.color_diff_format_indexInteger, alias or
default. The color difference subsampling mode to use (see section (11.4.4)). Ifdefault, uses the mode specified by thebase_video_format.The following aliases can be used in place of an integer for additional readability.
Index
Alias
0
color_4_4_41
color_4_2_22
color_4_2_0source_samplingInteger, alias or
default. The scan format to use (see section (11.4.5)). Ifdefault, uses the mode specified by thebase_video_format.The following aliases can be used in place of an integer for additional readability.
Index
Alias
0
progressive1
interlacedNote
This parameter is used as metadata only. It should not be confused with the
picture_coding_modeparameter which determines whether each picture in a sequence contains a whole frame or a field of video.top_field_firstTRUE,FALSEordefault. Indicates, for interlaced formats, whether the earlier field in a sequence contains the top field of a frame (TRUE) or bottom field (FALSE) (see section (11.4.5)). Ifdefault, uses the mode specified by thebase_video_format.frame_rate_numerandframe_rate_denomIntegers or
default. The frame rate (see section (11.4.6)). Ifdefault, uses the mode specified by thebase_video_format.pixel_aspect_ratio_numerandpixel_aspect_ratio_denomIntegers or
default. The pixel aspect ratio (see section (11.4.7)). Ifdefault, uses the mode specified by thebase_video_format.clean_width,clean_height,left_offsetandtop_offsetIntegers or
default. The clean area (see section (11.4.8)). Ifdefault, uses the mode specified by thebase_video_format.luma_offset,luma_excursion,color_diff_offsetandcolor_diff_excursionIntegers or
default. The luma and color difference picture component signal ranges (see section (11.4.9)). Ifdefault, uses the mode specified by thebase_video_format.color_primaries_index,color_matrix_indexandtransfer_function_indexIntegers, aliases or
default. color specification options (see section (11.4.10)). Ifdefault, uses the mode specified by thebase_video_format.The following aliases can be used in place of an integer for additional readability.
Color Primaries Index
Alias
0
hdtv1
sdtv_5252
sdtv_6253
d_cinema4
uhdtvColor Matrix Index
Alias
0
hdtv1
sdtv2
reversible3
rgb4
uhdtvTransfer Function Index
Alias
0
tv_gamma1
extended_gamut2
linear3
d_cinema4
perceptual_quantizer5
hybrid_log_gammawavelet_indexandwavelet_index_hoIntegers or aliases. Wavelet transform types to use vertically and horizontally, respectively (see sections (11.4.1) and (11.4.4.1)). For symmetric transforms, these values must be the same.
The following aliases can be used in place of an integer for additional readability.
Index
Alias
0
deslauriers_dubuc_9_71
le_gall_5_32
deslauriers_dubuc_13_73
haar_no_shift4
haar_with_shift5
fidelity6
daubechies_9_7dwt_depthanddwt_depth_hoIntegers. Wavelet transform depths to use for both dimensions and horizontally only, respectively (see sections (11.4.1) and (11.4.4.1)). For symmetric transforms,
dwt_depth_homust be0.slices_xandslices_yIntegers. The number of horizontal and vertical picture slices to use (see section (12.4.5.2)).
losslessBoolean. If
FALSE, test cases will be generated for a constant bit rate (lossy) codec. IfTRUEtest cases will be generated for a lossless (variable bit rate) codec. Lossless mode is only supported by the high quality profile.picture_bytesInteger or blank. The number of bytes to use to encode the slices in each picture. Must be an integer when
losslessisFALSEand blank whenlosslessisTRUE.For the low delay profile, this sets the
slice_bytes_numeratorandslice_bytes_denominatorvalues used by the stream (see section (13.5.3.2)) to the valuepicture_bytesdivided by the number of slices per picture.For the high quality profile, when
losslessisFALSE, slices are assigned sizes using the same formula as used for the low delay profile. WhenlosslessisTRUE, slices are sized as small as possible for the data they hold.Note
This value only accounts for picture slice data, i.e. the data read by the
slicepseudocode function in section (13.5.3). It does not take into account other stream overheads (e.g. sequence headers and transform parameters). As such the resulting stream will have a slightly higher bit rate thanpicture_bytesbytes per picture.fragment_slice_countInteger.
If zero, non-fragmented picture coding is used: each picture will be coded as a single picture parse data unit.
If greater than zero, fragmented picture mode will be used (see section (14)). Pictures will be coded as several fragment parse data units containing at most
fragment_slice_countslices each.quantization_matrixList of space-separated integers or
default. Specifies the quantization matrix to be used.If
default, the default quantisation matrix for the wavelet transform specified bywavelet_index,wavelet_index_ho,dwt_depthanddwt_depth_howill be used (see annexe (D.2)).If a list of space separated integers are provided defining a quantisation matrix, these will be used instead and encoded as a custom quantisation matrix in the stream (see (12.4.5.3)).
Quantisation matrix values, if provided, should be given in the same order they would appear in the stream as defined by the
quant_matrixpseudocode function (12.4.5.3). For example for a transform with dwt_depth = 1 and dwt_depth_ho = 2, the following value:0 1 2 3 4 5
Describes the following quantization matrix:
{ 0: {"L": 0}, 1: {"H": 1}, 2: {"H": 2}, 3: {"HL": 3, "LH": 4, "HH": 5}, }
If a non
defaultvalue is given, the majority (though not all) generated test cases will use the supplied quantization matrix (with thecustom_quant_matrixflag set (12.4.5.3)).
Generating test cases¶
Once a codec features CSV has been created, with columns covering the major operating modes of the codec to be tested, the vc2-test-case-generator command can be used to generate test cases.
In the simplest case, the command should be provided with the filename of your codec features CSV:
$ vc2-test-case-generator path/to/codec_features.csv
By default, a test_cases directory will be created into which the test
cases are written. This can be changed using the --output <path> argument.
The --verbose option can be used to keep track of progress.
If only test cases for an encoder are required, the --encoder-only option
can be given. Alternatively if only decoder test cases are needed
--decoder-only can be used. By default, test cases are generated for both
encoders and decoders.
Before any test cases are generated, the test case generator internally generates and then validates a simple test stream for each column of the codec features table. This step ensures that the codec features specified are not in conflict with themselves or the VC-2 standard. If this step fails, an error message is produced indicating the problem and test case generation is aborted.
If you are using a wavelet transform combination or depth for which a default quantization matrices are not provided in the VC-2 specification (see annexe (D.2)), the test case generator will produce the following warning:
WARNING:root:No static analysis available for the wavelet used by codec '<name>'. Signal range test cases cannot be generated.
See Generating static wavelet filter analyses for instructions on this specific case.
Warning messages are otherwise only produced for degenerate codec configurations. It is very unlikely a useful codec configuration will result in a warning. If any are produced, check the values in your codec features CSV if warnings are encountered.
Test case generation typically requires several hours, depending on the codec feature sets provided.
Note
The slow runtime performance of the VC-2 conformance software is an unfortunate side effect of it being based on the pseudocode published in the VC-2 specification. This design gives a high degree of confidence that it is consistent with the specification at the cost of slow execution.
Parallel test case generation¶
To speed up test case generation on multi-core systems, independent test cases
can be generated in parallel. To do this, the --parallel argument is used.
Instead of generating test cases, when --parallel is used, the test case
generator will print a series of commands which can be executed in parallel to
generate the test cases, for example using GNU Parallel:
$ # Write test case generation commands to 'commands.txt'
$ vc2-test-case-generator path/to/codec_features.csv --parallel > commands.txt
$ # Run test case generation in parallel using GNU Parallel
$ parallel -a commands.txt
Warning
Some test cases require relatively large quantities of RAM during test case
generation. You might need to reduce the number of commands run in parallel
if your system runs out of memory. If you’re using GNU parallel, the -j
N argument can be used to set the number of parallel jobs to N (with
the default being however many CPU cores are available).
Directory structure¶
The test case generator produces a directory structure as outlined below:
test_cases/<codec feature set name>/decoder/– Test VC-2 bitstreams for decoders.<test-case-name>.vc2– VC-2 bitstream to be decoded.<test-case-name>_metadata.json– Optional metadata file provided for some tests<test-case-name>_expected/– Reference decoding of the bitstream.picture_<N>.rawpicture_<N>.json
encoder/– Test raw video streams for encoders.<test-case-name>_metadata.json– Optional metadata file provided for some tests<test-case-name>/– Raw video to be encodedpicture_<N>.rawpicture_<N>.json
The testing procedures for decoders and encoders are described in the next two sections: