Encoder  4.4
VC-5 Sample Encoder
codec.c File Reference

Functions

CODEC_ERROR PrepareCodecState (CODEC_STATE *codec)
 Initialize the codec state to before encoding or decoding the bitstream. More...
 
uint32_t EncoderVersion (uint32_t value)
 Reformat a segment value into the encoder version. More...
 
void SetCodecVersion (uint8_t version[3], uint16_t value)
 Unpack the version tag value into its components.
 
bool ValidImageFormat (IMAGE_FORMAT image_format)
 Return true if the image format is valid.
 
IMAGE_FORMAT DefaultImageFormat (PIXEL_FORMAT pixel_format)
 Set the image format using the pixel format.
 
const char * ImageFormatString (IMAGE_FORMAT image_format)
 Return a string for the name of the image format.
 
int EncodedPrecision (PIXEL_FORMAT format)
 Return the encoded precision for an input pixel format. More...
 
int InputPrecision (PIXEL_FORMAT format)
 Return the precision of a pixel format. More...
 
CODEC_ERROR UpdatePrescaleTable (CODEC_STATE *codec, TAGWORD value)
 Unpack the tag value into the prescale table. More...
 
CODEC_ERROR UpdateFrameStructureFlags (CODEC_STATE *codec, TAGWORD value)
 Update the flags that describe the frame structure. More...
 
CODEC_ERROR InitCodecState (CODEC_STATE *state)
 Initialize the codec state using the default constructor. More...
 
int LowpassChannelOffset (CODEC_STATE *codec, PIXEL_FORMAT output_format)
 Compute the channel offset added to each lowpass pixel value. More...
 
CODEC_ERROR SetBandCoding (CODEC_STATE *codec, TAGWORD value)
 Set the flags that determine the band coding. More...
 
bool IsPartEnabled (ENABLED_PARTS enabled_parts, int part_number)
 Return true if the specified part is enabled at runtime. More...
 
bool IsSectionEnabled (ENABLED_SECTIONS enabled_sections, SECTION_NUMBER section_number)
 Return true if the specified type of section is enabled.
 
bool IsImageSectionEnabled (ENABLED_PARTS enabled_parts, ENABLED_SECTIONS enabled_sections)
 Return true if image sections are enabled.
 

Detailed Description

Implementation of functions that are common to the reference decoder and encoder

(c) 2013 Society of Motion Picture & Television Engineers LLC and Woodman Labs, Inc. All rights reserved–use subject to compliance with end user license agreement.

Function Documentation

◆ EncodedPrecision()

int EncodedPrecision ( PIXEL_FORMAT  format)

Return the encoded precision for an input pixel format.

This routine computes the encoded precision that should be used for an input frame with the specified pixel format.

This routine is not currently used since all input formats are encoded using 12 bits of precision.

◆ EncoderVersion()

uint32_t EncoderVersion ( uint32_t  value)

Reformat a segment value into the encoder version.

The version of the encoder that created the clip may be encoded into every sample.

Todo:
Document the encoder version number format

◆ InitCodecState()

CODEC_ERROR InitCodecState ( CODEC_STATE state)

Initialize the codec state using the default constructor.

This routine is like a default constructor in C++ as it guarantees that the codec state is initialized to a know starting state with all pointers set to NULL and all counters set to zero.

The routine PrepareCodecState is used to set default values for the codec state prior to decoding a sample.

◆ InputPrecision()

int InputPrecision ( PIXEL_FORMAT  format)

Return the precision of a pixel format.

This routine returns the actual precision of a pixel format.

◆ IsPartEnabled()

bool IsPartEnabled ( ENABLED_PARTS  enabled_parts,
int  part_number 
)

Return true if the specified part is enabled at runtime.

This predicate is used to test whether a specific part in the VC-5 standard is enabled at runtime by this codec implementation.

Here is the caller graph for this function:

◆ LowpassChannelOffset()

int LowpassChannelOffset ( CODEC_STATE codec,
PIXEL_FORMAT  output_format 
)

Compute the channel offset added to each lowpass pixel value.

The channel offset is added to each pixel value when decoding the lowpass band. It corrects for rounding errors that occur during encoding and depends on the output format since the rounding errors are not present at higher output bit depths.

◆ PrepareCodecState()

CODEC_ERROR PrepareCodecState ( CODEC_STATE codec)

Initialize the codec state to before encoding or decoding the bitstream.

Most of the codec state can be deduced from the decoding parameters. For example, the dimensions of the first wavelet band in the bitstream can be deduced from the encoded frame dimensions and the structure of the wavelet tree.

The encoder will not insert parameters into the bitstream if the values of the parameters are the same as in the codec state. This routine should initialize the codec state with correct values if those values can be inferred by the decoder, otherwise the use incorrect or default values.

Note that the default encoded format is YUV 4:2:2, but this format is not supported by the baseline profile encoder so the encoded format must be explicitly written into the bitstream.

Todo:
Add more default values required to properly initialize the codec state.
Here is the caller graph for this function:

◆ SetBandCoding()

CODEC_ERROR SetBandCoding ( CODEC_STATE codec,
TAGWORD  value 
)

Set the flags that determine the band coding.

There can be up to 15 different codebooks as specified by the lower four bigs in the band coding flags. Use the default codebook if the active codebook is zero.

The baseline profile does not allow difference coding or alternative codebooks.

◆ UpdateFrameStructureFlags()

CODEC_ERROR UpdateFrameStructureFlags ( CODEC_STATE codec,
TAGWORD  value 
)

Update the flags that describe the frame structure.

The frame structure includes characteristics such as interlaced versus progressive and top or bottom field first.

◆ UpdatePrescaleTable()

CODEC_ERROR UpdatePrescaleTable ( CODEC_STATE codec,
TAGWORD  value 
)

Unpack the tag value into the prescale table.

The prescale table contains the prescale value for each wavelet in the transform. The prescale value is a right shift that is applied to the input data before the wavelet is computed.

The prescale table is used for all transforms and does not depend on the channel number.