SDK

Introduction

V-Nova’s VC-6 SDK includes a VC-6 codec library implemented in C++ and comes with a C-Style API. It provides encode and decode functionality as well as some additional utilities. There are variants of the SDK that target different platforms;

  • Linux OpenCL version

  • Linux C++ version

  • Windows OpenCL version

  • Windows C++ versionclinfo

The OpenCL versions support GPU acceleration, but for platforms where this is not available the C++ provides an implementation that has been optimised to exploit the parallel processing capabilities of the latest CPU architectures.

SDK Content

The SDK is made up of the following components:

  • Header Files

  • Libraries

  • Sample files

  • Sample binaries and scripts

  • API Reference

  • Documentation

Getting Started (OpenCL)

If the intention is to integrate and test the VC-6 codec on a platform with GPU (OpenCL) acceleration, the user should ensure that at least one OpenCL-enabled device is set up on the development machine. A command-line tool named clinfo can be used to check up and running OpenCL devices.

Clinfo

For Windows machines, binary releases can be downloaded from this github repo.

For Linux systems, clinfo can be installed via the package manager. For example on Ubuntu:

apt-get install clinfo

By running the clinfo command, you will either get a single line indicating you have 0 platforms in your system, or extensive details of each available platform and device will be presented. What is important are the number of platforms and number of devices in each platform and if the desired device (for example a dedicated Nvidia GPU on the machine) is listed. If the expected platforms cannot be found, the device drivers should be installed.

Driver Installation

For dedicated GPUs, follow the target vendor's instructions. For Intel CPU with Integrated GPU:

First check if Intel integrated GPU can be seen in the clinfo as installing the OpenCL CPU drivers may override your Intel GPU drivers. We recommend using the integrated GPU than the CPU itself. Intel integrated GPUs 4000 series and above have the capability of running OpenCL. If an integrated GPU is not available and there are no OpenCL devices please install the an appropriate driver from this link:

Windows

In Intel Download Center, select Processors or Graphics. Then select your operating system and processor/graphics model and finally download and install the driver. A system restart is probably required.

Linux

The user will be guided to a GitHub repo in which installing or building guides are provided.

Sample Code Dry Run

A simple program named info_init.cpp can be found in the samples directory. If the development environment and target OpenCL runtime are set up correctly, you should be able to compile and run the program and get a console output with VC-6 SDK version and the OpenCL device picked for runtime with the following format:

Codec Version: <ReleaseNumber-CommitHash ><CodecType><OpenCL Device>

Selecting Device

If multiple OpenCL-enabled devices are available on a machine, it is very likely that the output of the previous command does not show the intended device. This can be controlled by setting OCL_DEVICE environment variable.

This environment variable can be used to specify the OpenCL device picked by the codec if more than one exists. The variable can be assigned both numbers and strings. If a number (starting from 0) N is used, the codec will pick the (N-1)th device appearing in the clinfo output. A case-sensitive string can be also used and the codec will try to match that with device descriptions and pick the first match. For example, if an intel Core i9 CPU is the second listed device in clinfo, all three following settings will pick that device:

OCL_DEVICE=1 OR OCL_DEVICE=Intel OR OCL_DEVICE=Core

Kernel Caching

Compiling OpenCL binaries for each device/codec-version combination will take a noticeable amount of time. This can be avoided by caching the compiled binaries in a temporary folder. The user can set this location by setting their desired address in OCL_BIN_LOC environment variable. The codec will both look for the prebuilt binaries and write them in this location if they are not already there.

The info_init program can be used with --build-kernels option to compile and cache the binaries to OCL_BIN_LOC location. In this program it is also demonstrated how to use encrypted kernels.

In order to use the info_init to create binaries from the encrypted kernels, first you should set the OCL_BIN_LOC variable to a writable directory, and then invoke the info_init program with --build-kernels and set --kernel-dir-enc option to path to the encrypted kernels' directory.

VC-6 Codec Concepts

At a high-level the VC-6 codec requires three components to operate:

  • Context: an environment that contains a set of channels, streams and common objects (including the device, platform, context, etc).

  • Stream(s): encoder or decoder instances

  • Channel(s): interfaces to the streams

Auxiliary objects are required to setup these main objects and manage the details of the encoding process. The most important of these objects can be enumerated as:

  • Stream configuration: contains the necessary information to setup a stream

  • Channel configuration: contains the necessary information to setup a channel

  • Picture description: holds dimensions and format data of a picture/video

  • VC-6 error type: contains error code and other error information

  • Video reader: an optional tool to read raw video (yuv or rgb) or VC-6 video frames. (Included in the utilities).

A basic VC-6 encoder program would create a context and a number of channels (per image/video). The streams, as codec instances, can be created explicitly and then become connected to channels via a process called linking. The developer can choose to let the codec handle the streams and their connections to channels for simple usecases. And finally, the encoding can take place by calling a set of channel-specific API calls. A high-level workflow of the program can be described as:

  1. Creating a context

  2. Creating channel configurations and video readers

  3. Creating channels

  4. Creating stream configurations and streams(optional)

  5. Linking channels and streams

  6. performing the following loop:

    1. 1. Begin channel input

    2. Preparing the input (preferably using video reader)

    3. End channel input

    4. Begin channel output

    5. Flush the channel

    6. Wait/Query channel output

    7. Discard and release the output

Last updated