vc2_bit_widths.picture_packing: Pack test patterns into pictures

This module contains a simple packing algorithm which attempts to efficiently pack a collection of test patterns onto a small number of test pictures.

API

pack_test_patterns(width, height, test_pattern_specifications)

Given a picture size and a series of test patterns, pack those patterns onto as few pictures as possible.

Parameters
width, heightint

The size of the pictures on to which the test patterns should be allocated.

test_pattern_specifications{key: TestPatternSpecification, …}

The test patterns to be packed.

Returns
pictures[numpy.array, …]

A series of pictures containing test patterns.

locations{key: (picture_number, tx, ty), …}

For each of the supplied test patterns, gives the index of the picture it was assigned to and the coordinates (within the targeted filter array) of the array value which will be maximised/minimised.

If any of the supplied test patterns are too large to fit in the specified width and height, those patterns will be omitted (and corresponding entries in the ‘locations’ will also be omitted).

Example output

The pack_test_patterns() function takes a dictionary of TestPatternSpecification or OptimisedTestPatternSpecification objects and arranges these over as few pictures as possible. An example output picture is shown below:

An example HD picture containing a selection of test patterns.

In typical use, several independent sets of packed test pictures should be created. One set can be created for all analysis transform test patterns. For synthesis transform test patterns, the patterns should be divided up into groups based on the quantisation index which should be used.