vc2_conformance.picture_generators: Picture generators

The vc2_conformance.picture_generators module contains routines for generating video sequences for arbitrary VC-2 video formats.

The picture generators in this module are used to generate encoder and decoder test cases (vc2_conformance.test_cases).

All picture generator functions take a VideoParameters, and PictureCodingModes as their arguments, defining the desired VC-2 video format. They then yield a sequence of {"Y": [[int, ...], ...], "C1": [[int, ...], ...], "C2": [[int, ...], ...], "pic_num": int} dictionaries containing integer picture component values, ready for encoding or writing to a file.

The following picture generators are provided.

moving_sprite(video_parameters, picture_coding_mode, num_frames=10)

A video sequence containing a simple moving synthetic image.

This sequence consists of a 128 by 128 pixel sprite (shown below) on a black background which traverses the screen from left-to-right moving 16 pixels to the right every frame (or 8 every field). By default the sequence is 10 frames long.

../_images/pointer.png

This test sequence may be used to verify that interlacing, pixel aspect ratio and frame-rate metadata is being correctly reported by a codec for display purposes.

For interlaced formats (see scan_format (11.4.5)), sequential fields will contain the sprite at different horizontal positions, regardless of whether pictures are fields or frames (see picture coding mode (11.5)). As a result, when frames are viewed as a set of raw interleaved fields, ragged edges will be visible.

Conversely, for progressive formats, sequential fields contain alternate lines from the same moment in time and when interleaved should produce smooth edges, regardless of the picture coding mode.

In the very first field of the sequence, the left edge of the white triangle will touch the edge of the frame. In interlaced formats, the top line of white pixels in the sprite will always be located on the top field. As a result, the line immediately below should always appear shifted to the right when top-field-first field order is used and shifted to the left when bottom-field-first order is used (see ‘top field first parameter’ (11.3)).

The sprite should be square with the white triangle having equal height and length and the hypotenuse lying at an angle of 45 degrees. The circular cut-out should be a perfect circle. This verifies that the pictures are displayed with the correct pixel aspect ratio (11.4.7).

The text in the sprite is provided to check that the correct picture orientation has been used.

The colors of the characters ‘V’, ‘C’ and ‘2’ are colored saturated primary red, green, and blue for the color primaries used (11.4.10.2). This provides a basic verification that the color components have been provided to the display system and decoded correctly.

static_sprite(video_parameters, picture_coding_mode)

A video sequence containing a exactly one frame containing a synthetic image.

This sequence consists of a 128 by 128 pixel sprite (shown below) located at the top-left corner of the frame on a black background.

../_images/pointer.png

This test sequence may be used to verify that interlacing, pixel aspect ratio and frame-rate metadata is being correctly reported by a codec for display purposes.

For if incorrect field ordering is specified, edges will appear ragged and not smooth.

The sprite should be square with the white triangle having equal height and length and the hypotenuse lying at an angle of 45 degrees. The circular cut-out should be a perfect circle. This verifies that the pictures are displayed with the correct pixel aspect ratio (11.4.7).

The text in the sprite is provided to check that the correct picture orientation has been used.

The colors of the characters ‘V’, ‘C’ and ‘2’ are colored saturated primary red, green, and blue for the color primaries used (11.4.10.2). This provides a basic verification that the color components have been provided to the display system and decoded correctly.

mid_gray(video_parameters, picture_coding_mode)

A video sequence containing exactly one empty mid-gray frame.

‘Mid gray’ is defined as having each color component set to the integer value exactly half-way along its range. When encoded using VC-2 all transform coefficients will be zero.

The actual color will differ depending on the color model used and the signal offsets specified, though typically a gray color is produced.

white_noise(video_parameters, picture_coding_mode, num_frames=1, seed=0)

A video sequence containing uniformly distributed pseudo-random full-range signal values.

Note

Because all picture components are filled with noise, the resulting pictures will contain ‘color’ noise rather than black-and-white noise. This may include out-of-gamut signals.

By default a single frame is produced, but the num_frames argument may be used to specify more.

By default a fixed seed is used, but alternative seeds may be provided in the seed argument.

linear_ramps(video_parameters, picture_coding_mode)

An video sequence containing exactly one frame with a series of linear color ramps (illustrated below).

../_images/linear_ramps.png

The frame is split into horizontal bands which contain, top to bottom:

  • A black-to-white linear ramp

  • A black-to-red linear ramp

  • A black-to-green linear ramp

  • A black-to-blue linear ramp

The color ramps are linear in intensity. For most color formats (using a non-linear transfer function) this produces a non-linear ramp in coded pixel values. Further, the ramp will not be perceptually linear since human vision does not have a linear response.

This is provided for the purposes of checking that metadata related to color is correctly passed through for display purposes.

Longer sequences may be produced by repeating the pictures produced by the above generators:

repeat_pictures(pictures, count)

Repeat a sequence of pictures produced by a picture generator to produce a longer sequence.

Note

Where the picture coding mode indicates that pictures represents fields (not frames), an even number of pictures (i.e. a whole number of frames) is always generated. This means that, for example, a single-frame picture generator will generate two pictures for these formats.