|
Encoder
4.4
VC-5 Sample Encoder
|
Go to the source code of this file.
Data Structures | |
| struct | _codec_state |
| struct | _codec_state::_picture_aspect_ratio |
| Picture aspect ratio read from the encoded sample. More... | |
| struct | _codec |
| Fields that are common to the encoder and decoder. More... | |
Typedefs | |
| typedef enum _codec_tag | CODEC_TAG |
| Tags that define elements in the bitstream. More... | |
| typedef enum _image_format | IMAGE_FORMAT |
| Format of the encoded sample. More... | |
| typedef enum _section_number | SECTION_NUMBER |
| typedef uint32_t | ENABLED_SECTIONS |
| typedef struct _codec_state | CODEC_STATE |
| typedef struct _codec | CODEC |
| Fields that are common to the encoder and decoder. | |
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... | |
| uint32_t | RepackedEncoderVersion (uint32_t value) |
| void | SetCodecVersion (uint8_t version[3], uint16_t value) |
| Unpack the version tag value into its components. | |
| IMAGE_FORMAT | DefaultImageFormat (PIXEL_FORMAT pixel_format) |
| Set the image format using the pixel 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 | UpdateSampleFlags (CODEC_STATE *codec, TAGWORD value) |
| CODEC_ERROR | UpdateCodecFlags (CODEC_STATE *codec, TAGWORD value) |
| CODEC_ERROR | UpdateFrameStructureFlags (CODEC_STATE *codec, TAGWORD value) |
| Update the flags that describe the frame structure. 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... | |
| const char * | ImageFormatString (IMAGE_FORMAT image_format) |
| Return a string for the name of the image format. | |
| 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. | |
State of the decoder while decoding a sample.
The codec state contains information about the current state of the decoding process. The codec state is updated as the bitstream is decoded.
The encoder process maintains the codec state during encoding to mimic the codec state in the decoder. It is not necessary to encode parameters into the bitstream if the decoding process will automatically determine the same information. For example, after decoding a subband, the decoder will increment the subband number, so the encoder does not have to write the next subband number in the bitstream if the subbands are transmitted in numerical order.
(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.
| typedef struct _codec_state CODEC_STATE |
The codec state contains information about the decoding process obtained as a sample is decoded. The information is transient and is only used while decoding a sample. The decoder data structure contains information that should persist from onen sample to the next.
The codec state is initialized using information in the decoder data structure at the start of decoding a sample.
The intent is that the encoder can operate the same state machine during encoding and any information available in the state machine does not have to be encoded into the sample as it is assumed that the decoder can and will derive the same information. For example, the dimensions of the first subband can be computed from the encoded dimensions and the number of wavelet levels, so it is not necessary to encode this information. Likewise, after the last band in a wavelet is decoded the dimensions of the bands in the wavelet at the next level can be deduced and it is not necessary to encode this information into the sample.
| typedef enum _codec_tag CODEC_TAG |
Tags that define elements in the bitstream.
All syntax elements in the encoded bitstream begin with a 16-bit tag that specifies the type of element. The 16-bit tag is followed by a 16-bit value, forming a tag-value pair.
If the tag is a negative number, then the actual tag is the negation of the tag value and the negative sign indicates that the tag and its value are an optional tag value pair. If the tag is a positive value, then the segment is required. A decoder must be able to decode all required tag-value pairs, but can skip tag-value pairs that are optional.
In a VC-5 Part 1 bitstream, the image width and height are an upper bound on the dimensions of each channel represented in the bitstream. In a VC-5 Part 3 bitstream, the image width and height are the actual dimensions of the image represented in the bitstream. The width and height of the image and each pattern element is sufficient to determine the width and height of each component array.
A range of tags is reserved for chunks and the value is the size of the chunk.
| typedef enum _image_format IMAGE_FORMAT |
Format of the encoded sample.
The VC-5 Part 3 can support four bitstream representations of the encoded image.
The image format must be specified for any VC-5 Part 3 bitstream.
| enum _codec_tag |
Tags that define elements in the bitstream.
All syntax elements in the encoded bitstream begin with a 16-bit tag that specifies the type of element. The 16-bit tag is followed by a 16-bit value, forming a tag-value pair.
If the tag is a negative number, then the actual tag is the negation of the tag value and the negative sign indicates that the tag and its value are an optional tag value pair. If the tag is a positive value, then the segment is required. A decoder must be able to decode all required tag-value pairs, but can skip tag-value pairs that are optional.
In a VC-5 Part 1 bitstream, the image width and height are an upper bound on the dimensions of each channel represented in the bitstream. In a VC-5 Part 3 bitstream, the image width and height are the actual dimensions of the image represented in the bitstream. The width and height of the image and each pattern element is sufficient to determine the width and height of each component array.
A range of tags is reserved for chunks and the value is the size of the chunk.
| enum _image_format |
Format of the encoded sample.
The VC-5 Part 3 can support four bitstream representations of the encoded image.
The image format must be specified for any VC-5 Part 3 bitstream.
| enum _section_number |
| enum band_encoding |
Band encoding method.
Several different schemes have been tried for entropy coding the highpass bands. The baseline profile only supports the run lengths encoding method.
The run lengths encoding method using a Huffman code to encode runs of zeros and highpass coefficient magnitudes (unsigned). Runs of zeros can extend across row boundaries, so large sections of a highpass band that are mostly zeros can be encoded very efficiently.
| 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.
| 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.
| int InputPrecision | ( | PIXEL_FORMAT | format | ) |
Return the precision of a pixel format.
This routine returns the actual precision of a pixel format.
| 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.

| 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.
| 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.

| 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.
| 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.
| 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.