Skip to main content

SMPTE ST 2042-1 VC-2 Pseudocode Language Parsing Software

This repository contains software tools for parsing the pseudocode language used in the SMPTE ST 2042-1 (VC-2) professional video codec specification documents.

As well as a parser capable of generating Abstract Syntax Trees (ASTs) for pseudocode listings, tools are also provided for translating the pseudocode language into Python and also pretty-printed, syntax highlighted Word documents for inclusions in specifications.

Installation

To install from PyPI use:

$ pip install vc2_pseudocode_parser

Alternatively, to install directly from a checkout of this repository:

$ python setup.py install --user

This software requires Python 3.6 or later.

To enable support for generating Word documents, python-docx must also be installed (e.g. using pip install python-docx).

Example usage

As an example, consider the following pseudocode listing:

color_spec(state, video_parameters):
    # (11.4.10.1)
    custom_color_spec_flag = read_bool(state)
    if (custom_color_spec_flag):
        index = read_uint(state)
        preset_color_spec(video_parameters, index)
        # NB: index 0 is 'custom'
        if (index == 0):
            color_primaries(state, video_parameters)  # 11.3.9.1
            color_matrix(state, video_parameters)  # 11.3.9.2
            transfer_function(state, video_parameters)  # 11.3.9.3

This may be converted into Python as follows:

$ vc2-pseudocode-to-python listing.pc listing.py
$ cat listing.py
# This file was automatically translated from a pseudocode listing.

def color_spec(state, video_parameters):
    """
    (11.4.10.1)
    """
    custom_color_spec_flag = read_bool(state)
    if custom_color_spec_flag:
        index = read_uint(state)
        preset_color_spec(video_parameters, index)
        # NB: index 0 is 'custom'
        if index == 0:
            color_primaries(state, video_parameters)  # 11.3.9.1
            color_matrix(state, video_parameters)  # 11.3.9.2
            transfer_function(state, video_parameters)  # 11.3.9.3

Or into a Word document with tabular listings as follows:

$ vc2-pseudocode-to-docx listing.pc listing.docx

Table showing source listing

For a more thorough introduction, see the vc2_pseudocode_parser manual (also available in PDF format).

Development

Testing dependencies may be installed using:

$ pip install -r requirements-test.txt

Tests are then run using:

$ py.test

Though typechecking (using MyPy) is performed as part of the test suite, it may be run manually using:

$ ./run_mypy.sh

Documentation build dependencies can be obtained using:

$ pip install -r requirements-docs.txt

And the documentation built using:

$ make -C docs html latexpdf

Experimental software

The tools in this repository are experimental in nature. They are part of an informal thread of work to see how enhanced machine readability of pseudocode specifications may prove valuable to implementers and specification authors alike. Contact Jonathan Heathcote or John Fletcher for more information.

License

This software is distributed under the GNU General Public License version 3, © BBC 2021.

Metadata

Release files for vc2-pseudocode-parser 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vc2-pseudocode-parser 1.0.0
File Size Uploaded
vc2_pseudocode_parser-1.0.0.tar.gz 29.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vc2-pseudocode-parser 1.0.0
File Interpreter ABI Platform
vc2_pseudocode_parser-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 74.0 kB

Release files / vc2_pseudocode_parser-1.0.0.tar.gz

Download URL vc2_pseudocode_parser-1.0.0.tar.gz
Size 29.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bfcd8b14d9ba06ff2ef5b6d5eb5cb5ac56896fda6810a4cca625be4bc5e86b01
BLAKE2b-256 checksum
How to use checksums
d6128080893d2ab2fa0433a033b7cfd64daf06678ed7f499abf7ff0598c85f92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release files / vc2_pseudocode_parser-1.0.0-py3-none-any.whl

Download URL vc2_pseudocode_parser-1.0.0-py3-none-any.whl
Size 44.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b36cbb0be1e7246f3a5b85cbb79fa5fb38226449f392612020e13993a556a78d
BLAKE2b-256 checksum
How to use checksums
b2ee17c3db38dbed61e24b7e950bc15669e7ea2481c2d5c92e89ad038ffaaa7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page