AV1 Bitstream & Decoding Process Specification

Version 0.3
© 2017, The Alliance for Open Media

Last modified: 2017-11-02 13:03:02 -0700

Draft Document
This document is a work in process draft, and will change substantially before release. Do not rely on its current contents.

Find document build instructions in the README.

Abstract

This document defines the bitstream format and decoding process for the Alliance for Open Media AV1 video codec.

Scope

This document specifies the Alliance for Open Media AV1 bitstream format and decoding process.

Terms and Definitions

For the purposes of this document, the following terms and definitions apply:

AC coefficient

Any transform coefficient whose frequency indices are non-zero in at least one dimension.

Altref

(Alternative reference frame) A frame that can be used in inter coding.

Bitstream

The sequence of bits generated by encoding a sequence of frames.

Bit string

An ordered string with limited number of bits. The left most bit is the most significant bit (MSB), the right most bit is the least significant bit (LSB).

Block

A square or rectangular region of pixels consisting of one Luma and two Chroma matrices.

Block scan

A specified serial ordering of quantized coefficients.

Byte

An 8-bit bit string.

Byte alignment

One bit is byte aligned if the position of the bit is an integer multiple of eight from the position of the first bit in the bitstream.

CDEF

Constrained Directional Enhancement Filter designed to adaptively filter blocks based on identifying the direction.

CDF

Cumulative distribution function representing the probability times 32768 that a symbol has value less than or equal to a given level.

Chroma

A sample value matrix or a single sample value of one of the two color difference signals.

Note: Symbols of chroma are U and V.

Coded frame

The representation of one frame before the decoding process.

Component

One of the three sample value matrices (one luma matrix and two chroma matrices) or its single sample value.

Compound prediction

A type of inter prediction where sample values are computed by blending together predictions from two different reference frames.

Compressed header

An arithmetically encoded description of frame level settings of transform mode and probability adjustments.

DC coefficient

A transform coefficient whose frequency indices are zero in both dimensions.

Decoded frame

The frame reconstructed out of the bitstream by the decoder.

Decoder

One embodiment of the decoding process.

Decoding process

The process that derives decoded frames from syntax elements.

Dequantization

The process in which transform coefficients are obtained by scaling the quantized coefficients.

Encoder

One embodiment of the encoding process.

Encoding process

A process not specified in this Specification that generates the bitstream that conforms to the description provided in this document.

Flag

A binary variable.

Frame

The representation of video signals in the space domain, composed of one luma sample matrix (Y) and two chroma sample matrices (U and V).

Frame context

A set of probabilities used in the decoding process.

Golden frame

A frame that can be used in inter coding. Typically the golden frame is encoded with higher quality and is used as a reference for multiple inter frames.

Inter coding

Coding one block or frame using inter prediction.

Inter frame

A frame compressed by referencing previously decoded frames and which may use intra prediction or inter prediction.

Inter prediction

The process of deriving the prediction value for the current frame using previously decoded frames.

Intra coding

Coding one block or frame using intra prediction.

Intra frame

A frame compressed using only intra prediction which can be independently decoded.

Intra-only frame

A type of intra frame that does not reset the decoding process.

Note: A key frame is different to an intra-only frame even though both only use intra prediction. The difference is that a key frame fully resets the decoding process.

Intra prediction

The process of deriving the prediction value for the current sample using previously decoded sample values in the same decoded frame.

Inverse transform

The process in which a transform coefficient matrix is transformed into a spatial sample value matrix.

Key frame

A frame where the decoding process is reset. Key frames, and following frames, are always decodable without access to preceding frames. A key frame only uses intra prediction.

Level

A defined set of constraints on the values for the syntax elements and variables.

Loop filter

A filtering process applied to the reconstruction intended to reduce the visibility of block edges.

Luma

A sample value matrix or a single sample value representing the monochrome signal related to the primary colors.

Note: The symbol representing luma is Y.

Mode info

A header that specifies how a block should be predicted.

Mode info block

A luma sample value block of size 4x4 or larger and its two corresponding chroma sample value blocks (if present).

Motion vector

A two-dimensional vector used for inter prediction which refers the current frame to the reference frame, the value of which provides the coordinate offsets from a location in the current frame to a location in the reference frame.

OBU

All structures are packetized in “Open Bitstream Units” or OBUs.
Each OBU has a header, which provides identifying information for the contained data (payload).

Parse

The procedure of getting the syntax element from the bitstream.

Prediction

The implementation of the prediction process consisting of either inter or intra prediction.

Prediction process

The process of estimating the decoded sample value or data element using a predictor.

Prediction value

The value, which is the combination of the previously decoded sample values or data elements, used in the decoding process of the next sample value or data element.

Profile

A subset of syntax, semantics and algorithms defined in a part.

Quantization parameter

A variable used for scaling the quantized coefficients in the decoding process.

Quantized coefficient

A transform coefficient before dequantization.

Raster scan

Maps a two dimensional rectangular raster into a one dimensional raster, in which the entry of the one dimensional raster starts from the first row of the two dimensional raster, and the scanning then goes through the second row and the third row, and so on. Each raster row is scanned in left to right order.

Reconstruction

Obtaining the addition of the decoded residual and the corresponding prediction values.

Reference frame

A previously decoded frame used during inter prediction.

Reserved

A special syntax element value which may be used to extend this part in the future.

Residual

The differences between the reconstructed samples and the corresponding prediction values.

Sample

The basic elements that compose the frame.

Sample value

The value of a sample. This is an integer from 0 to 255 (inclusive) for 8-bit frames, from 0 to 1023 (inclusive) for 10-bit frames, and from 0 to 4095 (inclusive) for 12-bit frames.

Segmentation map

A 3-bit number containing the segment affiliation for each 4x4 block in the image. The segmentation map persists across frames.

Sequence

The highest level syntax structure of coding bitstream, including one or several consecutive coded frames.

Superblock

The top level of the block quadtree within a tile. All superblocks within a frame are the same size and are square. The superblocks may be 128x128 pixels or 64x64 pixels. A superblock may contain 1 or 2 mode info blocks, or may be bisected in each direction to create 4 sub-blocks, which may themselves be further subpartitioned, forming the block quadtree.

Switch Frame

An inter frame that can be used as a point to switch scalability layers. Switch frames overwrite all the frame buffers without forcing the use of intra coding.

Syntax element

An element of data represented in the bitstream.

Temporal delimiter OBU

An indication that the following OBUs will have a different presentation/decoding time stamp from the one of the last frame prior to the temporal delimiter.

Temporal unit

A Temporal unit consists of all the OBUs that are associated with a specific, distinct time instant. It consists of a temporal delimiter OBU, and all the OBUs that follow, up to but not including the next temporal delimiter.

Tile

A rectangular region of the frame that is intended to be able to be decoded and encoded independently, although loop-filtering across tile edges may still be applied.

Note: For AV1 this intention is only partially met. Partitioning into columns works as expected, but partitioning into rows does not. The decode of a tile depends on the decode of the tile above.

Transform block

A square transform coefficient matrix, used as input to the inverse transform process.

Transform coefficient

A scalar value, considered to be in a frequency domain, contained in a transform block.

Uncompressed header

High level description of the frame to be decoded that is encoded without the use of arithmetic encoding.

Symbols and Abbreviated Terms

DCT

Discrete Cosine Transform

ADST

Asymmetric Discrete Sine Transform

LSB

Least Significant Bit

MSB

Most Significant Bit

WHT

Walsh Hadamard Transform

The specification makes use of a number of constant integers. Constants that relate to the semantics of a particular syntax element are defined in section 6.

Additional constants are defined below:

Symbol name Value Description
REFS_PER_FRAME 7 Number of reference frames that can be used for inter prediction
TOTAL_REFS_PER_FRAME 8 Number of reference frame types (including intra type)
MV_FR_SIZE 4 Number of values that can be decoded for mv_fr
BLOCK_SIZE_GROUPS 4 Number of contexts when decoding y_mode
BLOCK_SIZES 24 Number of different block sizes used
BLOCK_INVALID 14 Sentinel value to mark partition choices that are illegal
MAX_SB_SIZE 128 Maximum size of a superblock in pixels
MAX_SB_SIZE_LOG2 7 Base 2 logarithm of maximum superblock size
MI_SIZE 4 Smallest size of a mode info block in pixels
MI_SIZE_LOG2 2 Base 2 logarithm of smallest size of a mode info block
MAX_TILE_WIDTH_SB 4096 / MAX_SB_SIZE Maximum width of a tile in units of 128x128 pixels
MAX_TILE_AREA 4096 * 2304 Maximum area of a tile in units of luma samples
MAX_TILE_AREA_SB MAX_TILE_AREA / ( MAX_SB_SIZE * MAX_SB_SIZE ) Maximum area of a tile in units of luma samples
MAX_TILE_ROWS 64 Maximum number of tile rows
MAX_TILE_COLS 64 Maximum number of tile columns
NUM_REF_FRAMES 8 Number of frames that can be stored for future reference
MAX_REF_FRAMES 4 Number of values that can be derived for ref_frame
IS_INTER_CONTEXTS 4 Number of contexts for is_inter
COMP_MODE_CONTEXTS 5 Number of contexts for comp_mode
REF_CONTEXTS 5 Number of contexts for single_ref, comp_ref and comp_bwd_ref
MAX_SEGMENTS 8 Number of segments allowed in segmentation map
SEG_LVL_ALT_Q 0 Index for quantizer segment feature
SEG_LVL_ALT_L 1 Index for loop filter segment feature
SEG_LVL_REF_FRAME 2 Index for reference frame segment feature
SEG_LVL_SKIP 3 Index for skip segment feature
SEG_LVL_MAX 6 Number of segment features
BLOCK_TYPES 2 Number of different plane types (Y or UV)
REF_TYPES 2 Number of different prediction types (intra or inter)
COEF_BANDS 6 Number of coefficient bands
PREV_COEF_CONTEXTS 6 Number of contexts for decoding AC coefficients
DC_COEF_CONTEXTS 3 Number of contexts for decoding DC coefficients
UNCONSTRAINED_NODES 3 Number of coefficient probabilities that are directly transmitted
DC_HEAD_TOKENS 6 Number of values for dc_head_token
AC_HEAD_TOKENS 5 Number of values for ac_head_token
TAIL_TOKENS 9 Number of values for tail_token
TX_SIZE_CONTEXTS 2 Number of contexts for transform size
INTERP_FILTERS 3 Number of values for interp_filter
INTERP_FILTER_CONTEXTS 4 Number of contexts for interp_filter
SKIP_CONTEXTS 3 Number of contexts for decoding skip
PARTITION_CONTEXTS_W8 4 Number of contexts when decoding partition when the block is 8 samples wide
PARTITION_CONTEXTS 20 Number of contexts when decoding partition for other block sizes
PARTITION_TYPES_W8 4 Number of values for partition when the block is 8 samples wide
PARTITION_TYPES 10 Number of values for partition for other block sizes
TX_SIZES 4 Number of square transform sizes
TX_SIZES_ALL 10 Number of transform sizes (including non-square sizes)
TX_MODES 5 Number of values for tx_mode
DCT_DCT 0 Inverse transform rows with DCT and columns with DCT
ADST_DCT 1 Inverse transform rows with DCT and columns with ADST
DCT_ADST 2 Inverse transform rows with ADST and columns with DCT
ADST_ADST 3 Inverse transform rows with ADST and columns with ADST
FLIPADST_DCT 4 Inverse transform rows with FLIPADST and columns with DCT
DCT_FLIPADST 5 Inverse transform rows with DCT and columns with FLIPADST
FLIPADST_FLIPADST 6 Inverse transform rows with FLIPADST and columns with FLIPADST
ADST_FLIPADST 7 Inverse transform rows with ADST and columns with FLIPADST
FLIPADST_ADST 8 Inverse transform rows with FLIPADST and columns with ADST
IDTX 9 Inverse transform rows with identity and columns with identity
V_DCT 10 Inverse transform rows with identity and columns with DCT
H_DCT 11 Inverse transform rows with DCT and columns with identity
V_ADST 12 Inverse transform rows with identity and columns with ADST
H_ADST 13 Inverse transform rows with ADST and columns with identity
V_FLIPADST 14 Inverse transform rows with identity and columns with FLIPADST
H_FLIPADST 15 Inverse transform rows with FLIPADST and columns with identity
MB_MODE_COUNT 17 Number of values for YMode
INTRA_MODES 13 Number of values for y_mode
COMPOUND_MODES 8 Number of values for compound_mode
COMPOUND_MODE_CONTEXTS 7 Number of contexts for compound_mode
NEW_MV_CONTEXTS 7 Number of contexts for new_mv
ZERO_MV_CONTEXTS 2 Number of contexts for zero_mv
REF_MV_CONTEXTS 9 Number of contexts for ref_mv
DRL_MODE_CONTEXTS 5 Number of contexts for drl_mode
MV_CONTEXTS 3 Number of contexts for decoding motion vectors
MV_JOINTS 4 Number of values for mv_joint
MV_CLASSES 11 Number of values for mv_class
CLASS0_SIZE 2 Number of values for mv_class0_bit
MV_OFFSET_BITS 10 Maximum number of bits for decoding motion vectors
MAX_PROB 255 Number of values allowed for a probability adjustment
MAX_MODE_LF_DELTAS 2 Number of different mode types for loop filtering
COMPANDED_MVREF_THRESH 8 Threshold at which motion vectors are considered large
MAX_LOOP_FILTER 63 Maximum value used for loop filtering
REF_SCALE_SHIFT 14 Number of bits of precision when scaling reference frames
SUBPEL_BITS 4 Number of bits of precision when choosing an inter prediction filter kernel
SUBPEL_SHIFTS 16 1 << SUBPEL_BITS
SUBPEL_MASK 15 SUBPEL_SHIFTS - 1
SCALE_SUBPEL_BITS 10 Number of bits of precision when computing inter prediction locations
MV_BORDER 128 Value used when clipping motion vectors
INTERP_EXTEND 4 Value used when clipping motion vectors
BORDERINPIXELS 160 Value used when clipping motion vectors
MAX_UPDATE_FACTOR 128 Value used in adapting probabilities
COUNT_SAT 20 Value used in adapting probabilities
BOTH_ZERO 0 Both candidates use GLOBALMV
ZERO_PLUS_PREDICTED 1 One candidate uses GLOBALMV, one uses NEARMV or NEARESTMV
BOTH_PREDICTED 2 Both candidates use NEARMV or NEARESTMV
NEW_PLUS_NON_INTRA 3 One candidate uses NEWMV, one uses GLOBALMV
BOTH_NEW 4 Both candidates use NEWMV
INTRA_PLUS_NON_INTRA 5 One candidate uses intra prediction, one uses inter prediction
BOTH_INTRA 6 Both candidates use intra prediction
INVALID_CASE 9 Sentinel value marking a case that can never occur
UNUSED_PROB 128 Defined to make usage of probabilities clearer
PALETTE_COLOR_CONTEXTS 5 Number of values for color contexts
PALETTE_MAX_COLOR_CONTEXT_HASH 8 Number of mappings between color context hash and color context
PALETTE_BLOCK_SIZES 13 Number of values for palette block size
PALETTE_Y_MODE_CONTEXTS 3 Number of values for palette Y plane mode contexts
PALETTE_UV_MODE_CONTEXTS 2 Number of values for palette U and V plane mode contexts
PALETTE_SIZES 7 Number of values for palette_size
PALETTE_COLORS 8 Number of values for palette_color
PALETTE_NUM_NEIGHBORS 3 Number of neighbors considered within palette computation
DELTA_Q_SMALL 3 Value indicating alternative encoding of quantizer index delta values
DELTA_LF_SMALL 3 Value indicating alternative encoding of loop filter delta values
QM_TOTAL_SIZE 2708 Number of values in the quantizer matrix
MAX_ANGLE_DELTA 3 Maximum magnitude of AngleDeltaY and AngleDeltaUV
ANGLE_STEP 3 Number of degrees of step per unit increase in AngleDeltaY or AngleDeltaUV.
TX_SETS_INTRA 3 Number of intra transform sets
TX_SETS_INTER 4 Number of inter transform sets
TX_SET_TYPES 6 Number of transform set types
FRAME_CONTEXTS 8 Number of slots for saving CDF information.
WARPEDMODEL_PREC_BITS 16 Internal precision of warped motion models
IDENTITY 0 Warp model is just an identity transform
TRANSLATION 1 Warp model is a pure translation
ROTZOOM 2 Warp model is a rotation + symmetric zoom + translation
AFFINE 3 Warp model is a general affine transform
GM_ABS_TRANS_BITS 12 Number of bits encoded for translational components of global motion models, if part of a ROTZOOM or AFFINE model
GM_ABS_TRANS_ONLY_BITS 9 Number of bits encoded for translational components of global motion models, if part of a TRANSLATION model
GM_ABS_ALPHA_BITS 12 Number of bits encoded for non-translational components of global motion models
DIV_LUT_PREC_BITS 14 Number of fractional bits of entries in divisor lookup table
DIV_LUT_BITS 8 Number of fractional bits for lookup in divisor lookup table
DIV_LUT_NUM 257 Number of entries in divisor lookup table
MOTION_MODES 3 Number of values for motion modes
SIMPLE 0 Use translation or global motion compensation
OBMC 1 Use overlapped block motion compensation
LOCALWARP 2 Use local warp motion compensation
LEAST_SQUARES_SAMPLES_MAX 8 Largest number of samples used when computing a local warp
TRIM_THR 16 Threshold used to compute which samples to include in local warp computation
LS_MV_MAX 256 Largest motion vector difference to include in local warp computation
LS_MAT_DOWN_BITS 2 Largest amount used when reducing precision of warp matrix
LS_MAT_MIN -(1<<22) Smallest value in warp matrix
LS_MAT_MAX (1<<22)-1 Largest value in warp matrix
WARPEDMODEL_TRANS_CLAMP 1<<23 Clamping value used for translation components of warp
WARPEDMODEL_NONDIAGAFFINE_CLAMP 1<<13 Clamping value used for matrix components of warp
INTERINTRA_MODES 4 Number of inter intra modes
WEDGE_DIRECTIONS 6 Number of wedge index values
MAX_WEDGE_SIZE 32 Largest size of wedge mask
MASK_MASTER_SIZE 64 Size of MasterMask array
CDEF_VERY_LARGE 30000 Arbitrary large value used to signal unavailable pixels
SEGMENT_ID_PREDICTED_CONTEXTS 3 Number of contexts for segment_id_predicted
IS_INTER_CONTEXTS 4 Number of contexts for is_inter
SKIP_CONTEXTS 3 Number of contexts for skip
FWD_REFS 4 Number of syntax elements for forward reference frames
BWD_REFS 3 Number of syntax elements for backward reference frames
SINGLE_REFS 7 Number of syntax elements for single reference frames
UNIDIR_COMP_REFS 4 Number of syntax elements for unidirectional compound reference frames
COMPOUND_TYPES 3 Number of values for compound_type
CFL_JOINT_SIGNS 8 Number of values for cfl_alpha_signs
CFL_ALPHABET_SIZE 16 Number of values for cfl_alpha_u and cfl_alpha_v
MV_BIT_CONTEXTS 6 Number of contexts for mv_bit
COMP_INTER_CONTEXTS 5 Number of contexts for comp_mode
COMP_REF_TYPE_CONTEXTS 5 Number of contexts for comp_ref_type
UNI_COMP_REF_CONTEXTS 3 Number of contexts for uni_comp_ref, uni_comp_ref_p1 and uni_comp_ref_p2
CFL_ALPHA_CONTEXTS 6 Number of contexts for cfl_alpha_u and cfl_alpha_v
INTRA_MODE_CONTEXTS 5 Number of contexts for intra_frame_y_mode
INTRA_EDGE_KERNELS 3 Number of filter kernels for the intra edge filter
INTRA_EDGE_TAPS 5 Number of kernel taps for the intra edge filter
FRAME_LF_COUNT 4 Number of loop filter strength values
MAX_VARTX_DEPTH 2 Maximum depth for variable transform trees
TXFM_PARTITION_CONTEXTS 16 Number of contexts for txfm_split
REF_CAT_LEVEL 640 Bonus weight for close motion vectors
MAX_REF_MV_STACK_SIZE 8 Maximum number of motion vectors in the stack
MFMV_STACK_SIZE 3 Stack size for motion field motion vectors

Conventions

The mathematical operators and their precedence rules used to describe this Specification are similar to those used in the C programming language. However, the operation of integer division with truncation is specifically defined.

In addition, an array with 2 elements used to hold a motion vector (indicated by the variable name ending with the letters Mv or Mvs) can be accessed using either normal array notation (e.g. Mv[ 0 ] and Mv[ 1 ]), or by just the name (e.g., Mv). The only operations defined when using the name are assignment and equality/inequality testing. Assignment of an array is represented using the normal notation A = B and is specified to mean the same as doing both the individual assignments A[ 0 ] = B[ 0 ] and A[ 1 ] = B[ 1 ]. Equality testing of 2 motion vectors is represented using the notation A == B and is specified to mean the same as (A[ 0 ] == B[ 0 ] && A[ 1 ] == B[ 1 ]). Inequality testing is defined as A != B and is specified to mean the same as (A[ 0 ] != B[ 0 ] || A[ 1 ] != B[ 1 ]).

When a variable is said to be representable by a signed integer with x bits, it means that the variable is greater than or equal to -(1 << (x-1)), and that the variable is less than or equal to (1 << (x-1))-1.

Arithmetic operators

   
+ Addition
Subtraction (as a binary operator) or negation (as a unary prefix operator)
* Multiplication
/ Integer division with truncation of the result toward zero. For example, 7/4 and -7/-4 are truncated to 1 and -7/4 and 7/-4 are truncated to -1.
a % b Remainder from division of a by b. Both a and b are positive integers.

Logical operators

   
a && b Logical AND operation between a and b
a || b Logical OR operation between a and b
! Logical NOT operation.

Relational operators

   
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
== Equal to
!= Not equal to

Bitwise operators

   
& AND operation
| OR operation
~ Negation operation
a >> b Shift a in 2’s complement binary integer representation format to the right by b bit positions. This operator is only used with b being a non-negative integer. Bits shifted into the MSBs as a result of the right shift have a value equal to the MSB of a prior to the shift operation.
a << b Shift a in 2’s complement binary integer representation format to the left by b bit positions. This operator is only used with b being a non-negative integer. Bits shifted into the LSBs as a result of the left shift have a value equal to 0.

Assignment

   
= Assignment operator
++ Increment, x++ is equivalent to x = x + 1. When this operator is used for an array index, the variable value is obtained before the auto increment operation
-- Decrement, i.e. x-- is equivalent to x = x - 1. When this operator is used for an array index, the variable value is obtained before the auto decrement operation
+= Addition assignment operator, for example x += 3 corresponds to x = x + 3
-= Subtraction assignment operator, for example x -= 3 corresponds to x = x - 3

Mathematical functions

The following mathematical functions (Abs, Clip3, Clip1, Min, Max, Round2 and Round2Signed) are defined as follows:

Method of describing bitstream syntax

The description style of the syntax is similar to the C programming language. Syntax elements in the bitstream are represented in bold type. Each syntax element is described by its name (using only lower case letters with underscore characters) and a descriptor for its method of coded representation. The decoding process behaves according to the value of the syntax element and to the values of previously decoded syntax elements. When a value of a syntax element is used in the syntax tables or the text, it appears in regular (i.e. not bold) type. If the value of a syntax element is being computed (e.g. being written with a default value instead of being coded in the bitstream), it also appears in regular type (e.g. tile_size).

In some cases the syntax tables may use the values of other variables derived from syntax elements values. Such variables appear in the syntax tables, or text, named by a mixture of lower case and upper case letter and without any underscore characters. Variables starting with an upper case letter are derived for the decoding of the current syntax structure and all depending syntax structures. These variables may be used in the decoding process for later syntax structures. Variables starting with a lower case letter are only used within the process from which they are derived.

Constant values appear in all upper case letters with underscore characters (e.g. MI_SIZE).

Constant lookup tables appear as words (with the first letter of each word in upper case, and remaining letters in lower case) separated with underscore characters (e.g. Block_Width[…]).

Hexadecimal notation, indicated by prefixing the hexadecimal number by 0x, may be used when the number of bits is an integer multiple of 4. For example, 0x1a represents a bit string 0001 1010.

Binary notation is indicated by prefixing the binary number by 0b. For example, 0b00011010 represents a bit string 0001 1010. Binary numbers may include underscore characters to enhance readability. If present, the underscore characters appear every 4 binary digits starting from the LSB. For example, 0b11010 may also be written as 0b1_1010.

A value equal to 0 represents a FALSE condition in a test statement. The value TRUE is represented by any value not equal to 0.

The following table lists examples of the syntax specification format. When syntax_element appears (with bold face font), it specifies that this syntax element is parsed from the bitstream.

/* A statement can be a syntax element with associated
descriptor or can be an expression used to specify its
existence, type, and value, as in the following examples */

syntax_element                                                               f(1)

/* A group of statements enclosed in brackets is a
compound statement and is treated functionally as a single
statement. */

{
    statement
    ...
}

/* A "while" structure specifies that the statement is
to be evaluated repeatedly while the condition remains
true. */

while ( condition )
    statement

/* A "do .. while" structure executes the statement once,
and then tests the condition. It repeatedly evaluates the
statement while the condition remains true. */

do
    statement
while ( condition )

/* An "if .. else" structure tests the condition first. If
it is true, the primary statement is evaluated. Otherwise,
the alternative statement is evaluated. If the alternative
statement is unnecessary to be evaluated, the "else" and
corresponding alternative statement can be omitted. */

if ( condition )
    primary statement
else
    alternative statement

/* A "for" structure evaluates the initial statement at the
beginning then tests the condition. If it is true, the primary
and subsequent statements are evaluated until the condition
becomes false. */

for ( initial statement; condition; subsequent statement )
    primary statement

Functions

Functions used for syntax description are specified in this section.

The specification of these functions makes use of a bitstream position indicator. This bitstream position indicator locates the position of the bit that is going to be read next.

get_position( ): Return the value of the bitstream position indicator.

init_bool( sz ): Initialize the arithmetic decode process for the boolean decoder with a size of sz bytes as specified in section 8.2.1.

exit_bool( ): Exit the arithmetic decode process as described in section 8.2.3.

Descriptors

The following descriptors specify the parsing of syntax elements. Lower case descriptors specify syntax elements that are represented by a fixed integer number of bits in the bitstream; upper case descriptors specify syntax elements that are represented by arithmetic coding.

f(n)

Unsigned n-bit number appearing directly in the bitstream. The bits are read from high to low order. The parsing process specified in section 8.1 is invoked and the syntax element is set equal to the return value.

le(n)

Unsigned little-endian n-byte number appearing directly in the bitstream. The parsing process for this descriptor is specified below:

le(n) {
    t = 0
    for( i = 0; i < n; i++) {
        byte                                                                 f(8)
        t += ( byte << ( i * 8 ) )
    }
    return t
}

Note: This syntax element will only be present when the bitstream position is byte aligned.

su(n)

Signed integer converted from an n+1 unsigned integer in the bitstream. (The unsigned integer corresponds to the bottom n+1 bits of the signed integer.) The parsing process for this descriptor is specified below:

su(n) {
    value                                                                    f(n+1)
    signBit = 1 << n
    if (value & signBit)
        value = value - 2 * signBit
    return value
}

B(p)

A single arithmetic encoded bit with estimated probability p/256 of being 0. The syntax element is set equal to the return value of read_bool( p ) (see section 8.2.2‎ for a specification of this process).

L(n)

Unsigned arithmetic encoded n-bit number encoded as n flags (a “literal”). The flags are read from high to low order. The syntax element is set equal to the return value of read_literal( n ) (see section 8.2.4 for a specification of this process).

S

An arithmetic encoded symbol coded from a small alphabet of at most 16 entries.

The symbol is decoded based on a context sensitive CDF (see section 8.3 for the specification of this process).

U(n)

Unsigned arithmetic encoded number with maximum number of values n (i.e. output in range 0..n-1).

This descriptor is similar to L(ceil(log2(n))), but reduces wastage incurred when encoding non-power of two value ranges by encoding 1 fewer bits for the lower part of the value range. For example, when n is equal to 5, the encodings are as follows (full binary encodings are also presented for comparison):

Value Full binary encoding U(n) encoding
0 000 00
1 001 01
2 010 10
3 011 110
4 100 111

The parsing process for this descriptor is specified below:

U( n ) {
    w = floor(log2(n)) + 1
    m = (1 << w) - n
    v                                                                        L( w - 1 )
    if (v < m)
        return v
    extra_bit                                                                L( 1 )
    return (v << 1) - m + extra_bit
}

Bitstream Syntax

This section presents the bitstream syntax in a tabular form. The meaning of each of the syntax elements is presented in Section 6.

OBU Syntax

open_bitstream_unit( sz ) {
    obu_header()
    sz -= 1 + obu_extension_flag
    if ( obu_type == OBU_SEQUENCE_HEADER )
        sequence_header_obu()
    else if ( obu_type == OBU_TD )
        temporal_delimiter_obu()
    else if ( obu_type == OBU_FRAME_HEADER )
        frame_header_obu()
    else if ( obu_type == OBU_TILE_GROUP )
        tile_group_obu( sz )
    else if ( obu_type == OBU_METADATA )
        metadata_obu( sz )
    else if ( obu_type == OBU_PADDING )
        padding_obu()
    else
        reserved_obu( sz )
    trailing_bits()
}

OBU Header Syntax

obu_header() {
    obu_forbidden_bit                                                        f(1)
    obu_type                                                                 f(4)
    obu_reserved_2bits                                                       f(2)
    obu_extension_flag                                                       f(1)
    if ( obu_extension_flag == 1 )    
        obu_extension_header()                                               f(8)
}    

OBU Extension Header Syntax

obu_extension_header() {
    temporal_id                                                              f(3)
    spatial_id                                                               f(2)
    quality_id                                                               f(2)
    reserved_flag                                                            f(1)
}    

Trailing Bits Syntax

trailing_bits( ) {
    while ( get_position( ) & 7 )
        zero_bit                                                             f(1)
}

Reserved OBU Syntax

reserved_obu( sz ) {
    for ( i = 0; i < sz; i++ )
        reserved_obu_payload_byte                                            f(8)
}    

Sequence Header OBU Syntax

sequence_header_obu( ) {
    profile_low_bit                                                          f(1)
    profile_high_bit                                                         f(1)
    Profile = (profile_high_bit << 1) + profile_low_bit
    if ( Profile == 3 )
        reserved_zero                                                        f(1)
    level                                                                    f(4)
    frame_width_bits_minus_1                                                 f(4)
    frame_height_bits_minus_1                                                f(4)
    n = frame_width_bits_minus_1 + 1
    max_frame_width_minus_1                                                  f(n)
    n = frame_height_bits_minus_1 + 1
    max_frame_height_minus_1                                                 f(n)
    frame_id_numbers_present_flag                                            f(1)
    if ( frame_id_numbers_present_flag ) {    
        frame_id_length_minus7                                               f(4)
        delta_frame_id_length_minus2                                         f(4)
    }    
    color_config( )    
}    

Color Config Syntax

color_config( ) {
    if ( Profile >= 2 ) {
        ten_or_twelve_bit                                                    f(1)
        BitDepth = ten_or_twelve_bit ? 12 : 10
    } else {
        BitDepth = 8
    }
    color_space                                                              f(5)
    transfer_function                                                        f(5)
    if ( color_space != CS_SRGB ) {
        color_range                                                          f(1)
        if ( Profile == 1 || Profile == 3 ) {
            subsampling_x                                                    f(1)
            subsampling_y                                                    f(1)
            reserved_zero                                                    f(1)
        } else {
            subsampling_x = 1
            subsampling_y = 1
        }
        if (subsampling_x && subsampling_y) {
            chroma_sample_position                                           f(2)
        }
    } else {
        color_range = 1
        if ( Profile == 1 || Profile == 3 ) {
            subsampling_x = 0
            subsampling_y = 0
            reserved_zero                                                    f(1)
        }
    }
}

Temporal Delimiter OBU Syntax

temporal_delimiter_obu( ) {
    SeenFrameHeader = 0
}

Note: The temporal delimiter has an empty payload.

Padding OBU Syntax

padding_obu( ) {
    obu_padding_length                                                       f(8)
    for ( i = 0; i < obu_padding_length; i++ )
        obu_padding_byte                                                     f(8)
}    

Metadata OBU Syntax

metadata_obu( sz ) {
    metadata_type                                                            f(16)
    if ( metadata_type == METADATA_TYPE_PRIVATE_DATA )
        metadata_private_data( sz − 2 )
    else if ( metadata_type == METADATA_TYPE_HDR_CLL ) 
        metadata_hdr_cll( sz − 2 )
    else if ( metadata_type == METADATA_TYPE_HDR_MDCV )
        metadata_hdr_mdcv( sz − 2 )
}

Metadata Private Data Syntax

metadata_private_data( sz ) {
    for ( i = 0; i < sz; i++ )
        metadata_private_data_payload_byte[ i ]                              f(8)
}

Metadata High Dynamic Range Content Light Level Syntax

metadata_hdr_cll( sz ) {
    max_cll                                                                    f(16)
    max_fall                                                                   f(16)
}

Metadata High Dynamic Range Mastering Display Color Volume Syntax

metadata_hdr_mdcv( sz ) {
    for ( i = 0; i < 3; i++ ) {    
        primary_chromaticity_x[ i ]                                            f(16)
        primary_chromaticity_y[ i ]                                            f(16)
    }
    white_point_chromaticity_x                                                 f(16)
    white_point_chromaticity_y                                                 f(16)
    luminance_max                                                              f(32)
    luminance_min                                                              f(32)
}

Frame Header OBU Syntax

frame_header_obu( sz )
    if ( SeenFrameHeader == 1 ) {
        frame_header_copy()
    } else {
        SeenFrameHeader = 1
        uncompressed_header( )
        trailing_bits( )
        if ( show_existing_frame ) {
            decode_frame( )
            SeenFrameHeader = 0
        } else {
            load_cdfs( frame_context_idx )
            TileNum = 0
            MaxTileSize = 0
            SeenFrameHeader = 1
        }
    }
}

Uncompressed Header Syntax

uncompressed_header( ) {
    idLen = frame_id_length_minus7 + 7
    show_existing_frame                                                      f(1)
    if ( show_existing_frame == 1 ) {
        frame_to_show_map_idx                                                f(3)
        refresh_frame_flags = 0
        for ( i = 0; i < FRAME_LF_COUNT; i++ )
            loop_filter_level[ i ] = 0
        if (frame_id_numbers_present_flag) {
            display_frame_id                                                 f(idLen)
        }
        CurrentVideoFrame += 1
        return
    }
    frame_type                                                               f(2)
    show_frame                                                               f(1)
    error_resilient_mode                                                     f(1)
    if ( frame_id_numbers_present_flag ) {
        current_frame_id                                                     f(idLen)
    }
    frame_size_override_flag                                                 f(1)
    FrameIsIntra = (frame_type == INTRA_ONLY_FRAME || 
                    frame_type == KEY_FRAME)
    if ( frame_type == KEY_FRAME ) {
        frame_size( )
        render_size( )
        use_128x128_superblock                                               f(1)
        allow_screen_content_tools                                           f(1)
        refresh_frame_flags = 0xFF
        CurrentVideoFrame = 0
    } else {
        if ( frame_type == INTRA_ONLY_FRAME ) {
            allow_screen_content_tools                                       f(1)
        }
        if ( error_resilient_mode ) {
            reset_frame_context = 0
        } else {
            if ( frame_type == INTRA_ONLY_FRAME ) {
                intra_reset_all                                              f(1)
                reset_frame_context = 1 + intra_reset_all
            } else {
                reset_frame_context                                          f(1)
                if ( reset_frame_context == 1 ) {
                    intra_reset_all                                          f(1)
                    reset_frame_context = 1 + intra_reset_all
                }
            }
        }
        if ( frame_type == INTRA_ONLY_FRAME ) {
            refresh_frame_flags                                              f(8)
            frame_size( )
            render_size( )
            use_128x128_superblock                                           f(1)
        } else {
            if (frame_type == SWITCH_FRAME ) {
                refresh_frame_flags = 0xFF
            } else {
                refresh_frame_flags                                          f(8)
            }
            for( i = 0; i < REFS_PER_FRAME; i++ ) {
                ref_frame_idx[ i ]                                           f(3)
                if (frame_type == SWITCH_FRAME ) {
                    ref_frame_sign_bias[ LAST_FRAME + i ] = 0
                } else {
                    ref_frame_sign_bias[ LAST_FRAME + i ]                    f(1)
                }
                if (frame_id_numbers_present_flag) {
                    n = delta_frame_id_length_minus2 + 2
                    delta_frame_id_minus1                                    f(n)
                    DeltaFrameId = delta_frame_id_minus1 + 1
                    RefFrameId = ((current_frame_id -
                                  DeltaFrameId ) % (1 << idLen))
                }
            }
            if ( frame_size_override_flag && !error_resilient_mode ) {
                frame_size_with_refs( )
            } else {
                frame_size( )
                render_size( )
            }
            allow_high_precision_mv                                          f(1)
            read_interpolation_filter( )
            if ( error_resilient_mode ) {
                can_use_previous = 0
            } else {
                can_use_previous                                             f(1)
            }
        }
    }
    if (show_frame == 0) {
        frame_offset_update                                                  f(4)
        DecodeOrder = CurrentVideoFrame + frame_offset_update
    } else {
        DecodeOrder = CurrentVideoFrame
        CurrentVideoFrame += 1
    }
    if ( !FrameIsIntra ) {
        for( i = 0; i < REFS_PER_FRAME; i++ ) {
            DecodeOrders[ LAST_FRAME + i ] = RefDecodeOrder[ ref_frame_idx[ i ] ]
        }
    }
    if ( error_resilient_mode ) {
        frame_parallel_decoding_mode = 1
    } else {
        frame_parallel_decoding_mode                                         f(1)
    }
    frame_context_idx                                                        f(3)
    if ( FrameIsIntra || error_resilient_mode ) {
        setup_past_independence ( )
        if ( frame_type == KEY_FRAME || error_resilient_mode == 1 || reset_frame_context == 3 ) {
            for ( i = 0; i < FRAME_CONTEXTS; i++ ) {
                save_cdfs( i )
            }
        } else if ( reset_frame_context == 2 ) {
            save_cdfs( frame_context_idx )
        }
        frame_context_idx = 0
    } else if ( can_use_previous ) {
        load_previous( )
    }
    loop_filter_params( )
    quantization_params( )
    segmentation_params( )
    delta_q_params( )
    AllLossless = 1
    for ( segmentId = 0; segmentId < MAX_SEGMENTS; segmentId++ ) {
        qindex = get_qindex( 1, segmentId )
        LosslessArray[ segmentId ] = qindex == 0 && deltaQYDc == 0 && deltaQUVAc == 0 && deltaQUVDc == 0
        if ( !LosslessArray[ segmentId ] )
            AllLossless = 0
        if ( using_qmatrix ) {
            if ( LosslessArray[ segmentId ] ) {
                qmLevel = 15
            } else {
                qmLevel = min_qmlevel + ( base_q_idx * ( max_qmlevel - min_qmlevel + 1 ) ) / 256
            }
            SegQMLevel[ segmentId ] = qmLevel
        }
    }
    delta_lf_params( )
    cdef_params( )
    read_tx_mode( )
    global_motion_params( )
    frame_reference_mode( )
    reduced_tx_set                                                           f(1)
    tile_info( )
}

Frame Size Syntax

frame_size( ) {
    if (frame_size_override_flag) {
        n = frame_width_bits_minus_1 + 1
        frame_width_minus_1                                                  f(n)
        n = frame_height_bits_minus_1 + 1
        frame_height_minus_1                                                 f(n)
        FrameWidth = frame_width_minus_1 + 1
        FrameHeight = frame_height_minus_1 + 1
    } else {
        FrameWidth = MaxFrameWidth
        FrameHeight = MaxFrameHeight
    }
    compute_image_size( )
}

Render Size Syntax

render_size( ) {
    render_and_frame_size_different                                          f(1)
    if ( render_and_frame_size_different == 1 ) {
        render_width_minus_1                                                 f(16)
        render_height_minus_1                                                f(16)
        RenderWidth = render_width_minus_1 + 1
        RenderHeight = render_height_minus_1 + 1
    } else {
        RenderWidth = FrameWidth
        RenderHeight = FrameHeight
    }
}

Frame Size with Refs Syntax

frame_size_with_refs( ) {
    for ( i = 0; i < REFS_PER_FRAME; i++ ) {
        found_ref                                                            f(1)
        if ( found_ref == 1 ) {
            FrameWidth = RefFrameWidth[ ref_frame_idx[ i ] ]
            FrameHeight = RefFrameHeight[ ref_frame_idx[ i ] ]
            RenderWidth = FrameWidth
            RenderHeight = FrameHeight
            break
        }
    }
    if ( found_ref == 0 ) {
        frame_size( )
        render_size( )
    } else {
        compute_image_size( )
    }
}

Compute Image Size Function

compute_image_size( ) {
    MiCols = 2 * ( ( FrameWidth + 7 ) >> 3 )
    MiRows = 2 * ( ( FrameHeight + 7 ) >> 3 )
    MaxSbCols = ( MiCols + 31 ) >> 5
    MaxSbRows = ( MiRows + 31 ) >> 5
}

Interpolation Filter Syntax

read_interpolation_filter( ) {
    is_filter_switchable                                                     f(1)
    if ( is_filter_switchable == 1 ) {
        interpolation_filter = SWITCHABLE
    } else {
        interpolation_filter                                                 f(2)
    }
}

Loop Filter Params Syntax

loop_filter_params( ) {
    loop_filter_level[ 0 ]                                                   f(6)
    loop_filter_level[ 1 ]                                                   f(6)
    if ( loop_filter_level[ 0 ] || loop_filter_level[ 1 ] ) {
        loop_filter_level[ 2 ]                                               f(6)
        loop_filter_level[ 3 ]                                               f(6)
    }
    loop_filter_sharpness                                                    f(3)
    loop_filter_delta_enabled                                                f(1)
    if ( loop_filter_delta_enabled == 1 ) {
        loop_filter_delta_update                                             f(1)
        if ( loop_filter_delta_update == 1 ) {
            for ( i = 0; i < TOTAL_REFS_PER_FRAME; i++ ) {
                update_ref_delta                                             f(1)
                if ( update_ref_delta == 1 )
                    loop_filter_ref_deltas[ i ]                              su(6)
                for ( i = 0; i < 2; i++ ) {
                    update_mode_delta                                        f(1)
                    if ( update_mode_delta == 1 )
                        loop_filter_mode_deltas[ i ]                         su(6)
                }
            }
        }
    }
}

Quantization Params Syntax

quantization_params( ) {
    base_q_idx                                                               f(8)
    deltaQYDc = read_delta_q( )
    deltaQUVDc = read_delta_q( )
    deltaQUVAc = read_delta_q( )
    using_qmatrix                                                            f(1)
    if (using_qmatrix) {
        min_qmlevel                                                          f(4)
        max_qmlevel                                                          f(4)
    }
}

Delta Quantizer Syntax

read_delta_q( ) {
    delta_coded                                                              f(1)
    if ( delta_coded ) {
        delta_q                                                              su(6)
    } else {
        delta_q = 0
    }
    return delta_q
}

Segmentation Params Syntax

segmentation_params( ) {
    segmentation_enabled                                                     f(1)
    if ( segmentation_enabled == 1 ) {
        if ( FrameIsIntra || error_resilient_mode ) {
            segmentation_update_map = 1
            segmentation_temporal_update = 0
        } else {
            segmentation_update_map                                          f(1)
            if ( segmentation_update_map == 1 )
                segmentation_temporal_update                                 f(1)
        }
        segmentation_update_data                                             f(1)
        if ( segmentation_update_data == 1 ) {
            segmentation_abs_or_delta_update                                 f(1)
            for ( i = 0; i < MAX_SEGMENTS; i++ ) {
                for ( j = 0; j < SEG_LVL_MAX; j++ ) {
                    feature_value = 0
                    feature_enabled                                          f(1)
                    FeatureEnabled[ i ][ j ] = feature_enabled
                    if ( feature_enabled == 1 ) {
                        bitsToRead = Segmentation_Feature_Bits[ j ]
                        feature_value f(bitsToRead)
                        if ( Segmentation_Feature_Signed[ j ] == 1 ) {
                            feature_sign                                     f(1)
                        }
                    }
                    FeatureData[ i ][ j ] = feature_value
                    if ( feature_sign == 1 )
                        FeatureData[ i ][ j ] *= -1
                }
            }
        }
    }
}

The constant lookup tables used in this syntax are defined as:

Segmentation_Feature_Bits[ SEG_LVL_MAX ] = { 8, 6, 6, 6, 6, 2, 0 }
Segmentation_Feature_Signed[ SEG_LVL_MAX ] = { 1, 1, 1, 1, 1, 0, 0 }

Tile Info Syntax

tile_info ( ) {
    minLog2TileCols = tile_log2(MAX_TILE_WIDTH_SB, MaxSbCols)
    maxLog2TileCols = tile_log2(1, Min(MaxSbCols, MAX_TILE_COLS))
    maxLog2TileRows = tile_log2(1, Min(MaxSbRows, MAX_TILE_ROWS))
    minLog2Tiles = Max(minLog2TileCols, 
                       tile_log2(MAX_TILE_AREA_SB, MaxSbRows * MaxSbCols))
                       
    uniform_tile_spacing_flag                                                f(1)
    if ( uniform_tile_spacing_flag ) {
        TileColsLog2 = minLog2TileCols
        while ( TileColsLog2 < maxLog2TileCols ) {
            increment_tile_cols_log2                                         f(1)
            if ( increment_tile_cols_log2 == 1 )
                TileColsLog2++
            else
                break
        }
        sizeSb = (MaxSbCols + (1 << TileColsLog2) - 1) >> TileColsLog2
        i = 0
        for (startSb = 0; startSb < MaxSbCols; startSb += sizeSb) {
          MiColStarts[ i ] = startSb << (MAX_SB_SIZE_LOG2 - MI_SIZE_LOG2)
          i += 1
        }
        MiColStarts[i] = MiCols
        TileCols = i
        
        minLog2TileRows = Max( minLog2Tiles - TileColsLog2, 0)
        maxTileHeightSb = MaxSbRows >> minLog2TileRows
        TileRowsLog2 = minLog2TileRows
        while ( TileRowsLog2 < maxLog2TileRows ) {
            increment_tile_rows_log2                                         f(1)
            if ( increment_tile_rows_log2 == 1 )
                TileRowsLog2++
            else
                break
        }
        sizeSb = (MaxSbCols + (1 << TileRowsLog2) - 1) >> TileRowsLog2
        i = 0
        for (startSb = 0; startSb < MaxSbRows; startSb += sizeSb) {
          MiRowStarts[ i ] = startSb << (MAX_SB_SIZE_LOG2 - MI_SIZE_LOG2)
          i += 1
        }
        MiRowStarts[i] = MiRows
        TileRows = i
    } else {
        widestTileSb = 0
        startSb = 0
        for ( i = 0; startSb < MaxSbCols && i < MAX_TILE_COLS; i++ ) {
            MiColStarts[ i ] = startSb << (MAX_SB_SIZE_LOG2 - MI_SIZE_LOG2)
            maxWidth = Min(MaxSbCols - startSb, MAX_TILE_WIDTH_SB)
            sizeSb = decode_uniform(maxWidth) + 1
            widestTileSb = Max( sizeSb, widestTileSb )
            startSb += sizeSb
        }
        MiColStarts[i] = MiCols
        TileCols = i
        TileColsLog2 = tile_log2(1, TileCols)

        if ( minLog2Tiles > 0 )
            maxTileAreaSb = (MaxSbRows * MaxSbCols) >> (minLog2Tiles + 1)
        else
            maxTileAreaSb = MaxSbRows * MaxSbCols
        maxTileHeightSb = Max( maxTileAreaSb / widestTileSb, 1 )

        startSb = 0
        for ( i = 0; startSb < MaxSbRows && i < MAX_TILE_ROWS; i++ ) {
            MiRowStarts[ i ] = startSb << (MAX_SB_SIZE_LOG2 - MI_SIZE_LOG2)
            maxHeight = Min(MaxSbRows - startSb, maxTileHeightSb)
            sizeSb = decode_uniform(maxHeight) + 1
            startSb += sizeSb
        }
        MiRowStarts[ i ] = mi_rows
        TileRows = i
        TileRowsLog2 = tile_log2(1, TileRows)
    }
    startMi = 0
    maxTileHeightMi = maxTileHeightSb << (MAX_SB_SIZE_LOG2 - MI_SIZE_LOG2)
    for (i = 0; i < TileRows; i++) {
      if (MiRowStarts[i+1] - startMi > maxTileHeightMi) {
        AllowDependentTileRow[i] = 0
        startMi = MiRowStarts[i+1]
      } else {
        AllowDependentTileRow[i] = 1
      }
    }
    if ( TileRowsLog2 > 0 )
        dependent_tiles                                                      f(1)
    else
        dependent_tiles = 0
    if ( TileRowsLog2 > 0 || TileColsLog2 > 0 )
        loop_filter_across_tiles                                             f(1)
    else
        loop_filter_across_tiles = 0
    tile_size_bytes_minus_1                                                  f(2)
    TileSizeBytes = tile_size_bytes_minus_1 + 1
}

Tile Size Calculation Function

tile_log2 returns the smallest value for k such that 1 << k is greater than or equal to target.

tile_log2( blkSize, target) {
  for (k = 0; (blkSize << k) < target; k++) {
  }
  return k
}

Quantizer Index Delta Parameters Syntax

delta_q_params( ) {
    segmentQuantizerActive = 0
    for ( i = 0; i < MAX_SEGMENTS; i++ ) {
        if ( seg_feature_active_idx( i, SEG_LVL_ALT_Q ) ) {
            segmentQuantizerActive = 1
        }
    }
    delta_q_res = 0
    delta_q_present = 0
    if ( segmentQuantizerActive == 0 && base_q_idx > 0 ) {
        delta_q_present                                                      f(1)
    }
    if ( delta_q_present ) {
        delta_q_res                                                          f(2)
    }
}

Loop Filter Delta Parameters Syntax

delta_lf_params( ) {
    delta_lf_present = 0
    delta_lf_res = 0
    delta_lf_multi = 0
    if ( delta_q_present ) {
        delta_lf_present                                                     f(1)
        if ( delta_lf_present ) {
            delta_lf_res                                                     f(2)
            delta_lf_multi                                                   f(1)
        }
    }
}

CDEF Params Syntax

cdef_params( ) {
    if ( !AllLossless ) {
        cdef_damping_minus_3                                                 f(2)
        CdefDamping = cdef_damping_minus_3 + 3
        cdef_bits                                                            f(2)
        CdefFilterChroma = (subsampling_x == subsampling_y)
        for (i = 0; i < (1 << cdef_bits); i++) {
            cdef_y_pri_strength[i]                                           f(4)
            cdef_y_filter_skip[i]                                            f(1)
            cdef_y_sec_strength[i]                                           f(2)
            if (cdef_y_sec_strength[i] == 3)
                cdef_y_sec_strength[i] += 1
            if (CdefFilterChroma) {
                cdef_uv_pri_strength[i]                                      f(4)
                cdef_uv_filter_skip[i]                                       f(1)
                cdef_uv_sec_strength[i]                                      f(2)
                if (cdef_uv_sec_strength[i] == 3)
                    cdef_uv_sec_strength[i] += 1
            }
        }
    }
}

TX Mode Syntax

read_tx_mode( ) {
    if ( AllLossless == 1 ) {
        TxMode = ONLY_4X4
    } else {
        tx_mode_select                                                       f(1)
        if ( tx_mode_select ) {
            TxMode = TX_MODE_SELECT
        } else {
            tx_mode                                                          f(2)
            TxMode = tx_mode
        }
    }
}

Frame Reference Mode Function

frame_reference_mode( ) {
    if ( FrameIsIntra ) {
        compoundReferenceAllowed = 0
    } else {
        compoundReferenceAllowed = 0
        for ( i = 1; i < REFS_PER_FRAME; i++ )
            if ( ref_frame_sign_bias[ i + 1 ] != ref_frame_sign_bias[ 1 ] )
                compoundReferenceAllowed = 1
    }
    if ( compoundReferenceAllowed ) {
        reference_select                                                     f(1)
        if ( reference_select ) {
            ReferenceMode = REFERENCE_MODE_SELECT
        } else {
            non_single_reference                                             f(1)
            if (non_single_reference == 0 )
                ReferenceMode = SINGLE_REFERENCE
            else
                ReferenceMode = COMPOUND_REFERENCE
        }
    } else {
        ReferenceMode = SINGLE_REFERENCE
    }
    if ( FrameIsIntra || comp_pred_mode == COMPOUND_REFERENCE) {
        allow_interintra_compound = 0
    } else {
        allow_interintra_compound                                            f(1)
    }
    if ( FrameIsIntra || comp_pred_mode == SINGLE_REFERENCE) {
        allow_masked_compound = 0
    } else {
        allow_masked_compound                                                f(1)
    }
}

Global Motion Params Syntax

global_motion_params( ) {
    if ( FrameIsIntra || error_resilient || !can_use_previous) {
        for (ref = LAST_FRAME; ref <= ALTREF_FRAME; ref++) {
            gm_type[ref] = IDENTITY
            for ( i = 0; i < 6; i++ )
                gm_params[ ref ][ i ] = (i%3 == 2) ? 1 << WARPEDMODEL_PREC_BITS : 0
        }
    }
    if ( FrameIsIntra )
        return
    for (ref = LAST_FRAME; ref <= ALTREF_FRAME; ref++) {
        is_global                                                            f(1)
        if (is_global) {
            is_rot_zoom                                                      f(1)
            if (is_rot_zoom) {
                typ = ROTZOOM
            } else {
                is_translation                                               f(1)
                typ = is_translation ? TRANSLATION : AFFINE
            }
        } else {
            typ = IDENTITY
        }
        gm_type[ref] = typ

        if (type >= ROTZOOM) {
            read_global_param(type,ref,2)
            read_global_param(type,ref,3)
            if (type == AFFINE) {
                read_global_param(type,ref,4)
                read_global_param(type,ref,5)
            } else {
                gm_params[ref][4] = -gm_params[ref][3]
                gm_params[ref][5] = gm_params[ref][2]
            }
        }
        if (type >= TRANSLATION) {
            read_global_param(type,ref,0)
            read_global_param(type,ref,1)
        }
    }
}

Global Param Syntax

read_global_param( type, ref, idx ) {
    absBits = GM_ABS_ALPHA_BITS
    precBits = GM_ALPHA_PREC_DIFF
    if (idx < 2) {
        if (type == TRANSLATION) {
            absBits = GM_ABS_TRANS_ONLY_BITS - !allow_high_precision_mv
            precBits = GM_TRANS_ONLY_PREC_BITS - !allow_high_precision_mv
        } else {
            absBits = GM_ABS_TRANS_BITS
            precBits = GM_TRANS_PREC_BITS
        }
    }
    precDiff = WARPEDMODEL_PREC_BITS - precBits
    round = (i % 3) == 2 ? (1 << WARPEDMODEL_PREC_BITS) : 0
    sub = (i % 3) == 2 ? (1 << precDiff) : 0
    mx = (1 << absBits) + 1
    r = (gm_params[ref][idx] >> precDiff) - sub
    gm_params[ref][idx] = (decode_signed_subexp_with_ref(mx,r) << precDiff) + round
}

Decode Signed Subexp With Ref Syntax

decode_signed_subexp_with_ref( mx, r ) {
    x = decode_unsigned_subexp_with_ref((n << 1) - 1, r + (n - 1))
    return x - (n - 1)
}

Decode Unsigned Subexp With Ref Syntax

decode_unsigned_subexp_with_ref( mx, r ) {
    v = decode_subexp( mx )
    if ((r << 1) <= n) {
        return inverse_recenter(r, v)
    } else {
        return n - 1 - inverse_recenter(n - 1 - r, v)
    }
}

Decode Subexp Syntax

decode_subexp( numSyms ) {
    i = 0
    mk = 0
    k = 3
    while (1) {
        b2 = i ? k + i - 1 : k
        a = 1 << b2
        if (numSyms <= mk + 3 * a) {
            return decode_uniform(numSyms - mk) + mk
        } else {
            subexp_more_bits                                                 f(1)
            if (subexp_more_bits) {
               i++
               mk += a
            } else {
               subexp_bits                                                   f(b2)
               return subexp_bits + mk
            }
        }
    }
}

Decode Uniform Syntax

decode_uniform( n ) {
    w = floor(log2(n)) + 1
    m = (1 << w) - n
    v                                                                        f( w - 1 )
    if (v < m)
        return v
    extra_bit                                                                f( 1 )
    return (v << 1) - m + extra_bit
}

Inverse Recenter Syntax

inverse_recenter( r, v ) {
  if (v > 2 * r)
    return v
  else if (v & 1)
    return r - ((v + 1) >> 1)
  else
    return r + (v >> 1)
}

Inv Recenter Noneg Function

inv_recenter_nonneg( v, m ) {
    if ( v > 2 * m )
        return v
    if ( v & 1 )
        return m - ((v + 1) >> 1)
    return m + (v >> 1)
}

Tile Group OBU Syntax

tile_group_obu( sz )
    NumTiles = TileCols * TileRows
    startBitPos = get_position( )
    tileBits = TileColsLog2 + tile_rows_log2
    tg_start                                                                 f(tileBits)
    tg_end                                                                   f(tileBits)
    trailing_bits( )
    endBitPos = get_position( )
    headerBytes = (endBitPos - startBitPos) / 8
    sz -= headerBytes
    
    for ( TileNum = tg_start; TileNum <= tg_end; TileNum++ ) {
        tileRow = TileNum / TileCols
        tileCol = TileNum % TileCols
        lastTile = TileNum == tg_end
        if ( lastTile ) {
            tile_size = sz
        } else {
            tile_size                                                        le(TileSizeBytes)
            sz -= tile_size + TileSizeBytes
        }
        MiRowStart = MiRowStarts[ tileRow ]
        MiRowEnd = MiRowStarts[ tileRow + 1 ]
        MiColStart = MiColStarts[ tileCol ]
        MiColEnd = MiColStarts[ tileCol + 1 ]
        if ( TileNum == tg_start ) {
            tileGroupRowStart = tileRow
            tileGroupColStart = tileCol
        }
        if (tileCol >= tileGroupColStart)
            AboveSameTileGroup = tileRow > tileGroupRowStart
        else
            AboveSameTileGroup = tileRow >= tileGroupRowStart
        if ( !AllowDependentTileRow[ tileRow ] )
            AboveSameTileGroup = 0
        CurrentQIndex = base_q_idx
        init_bool( tile_size )
        decode_tile( )
        exit_bool( )
    }
    if (tg_end == NumTiles - 1) {
        if ( !error_resilient_mode && !frame_parallel_decoding_mode ) {
            update_cdf( )
            save_cdfs( frame_context_idx )
        }
        decode_frame( )
        SeenFrameHeader = 0
    }
}

Decode Tile Function

decode_tile( ) {
    if ( !dependent_tiles || TileNum == tg_start)
        clear_above_context( )
    for ( i = 0; i < FRAME_LF_COUNT; i++ )
        DeltaLF[ i ] = 0
    
    sbSize = use_128x128_superblock ? BLOCK_128X128 : BLOCK_64X64
    sbSize4 = Num_4x4_Blocks_Wide[ sbSize ]
    for ( r = MiRowStart; r < MiRowEnd; r += sbSize4 ) {
        clear_left_context( )
        for ( c = MiColStart; c < MiColEnd; c += sbSize4 ) {
            ReadDeltas = delta_q_present
            clear_block_decoded_flags( c < ( MiColEnd - 1 ) )
            decode_partition( r, c, sbSize )
            decode_cdef( r, c, sbSize )
        }
    }
}

Clear Block Decoded Flags Function

clear_block_decoded_flags( notLastColumn ) {
    sbSize = use_128x128_superblock ? 128 : 64
    for ( plane = 0; plane < 1 + HasChroma * 2; plane++ ) {
        subX = (plane > 0) ? subsampling_x : 0
        subY = (plane > 0) ? subsampling_y : 0
        for ( y = -1; y <= ( sbSize >> ( MI_SIZE_LOG2 + subY ) ); y++ ) 
            for ( x = -1; x <= ( sbSize >> ( MI_SIZE_LOG2 + subX ) ); x++ ) {
                BlockDecoded[ plane ][ y ][ x ] = ( y < 0 || x < 0 )
            }
        BlockDecoded[ plane ][ -1 ][ sbSize >> ( MI_SIZE_LOG2 + subX ) ] = notLastColumn
        BlockDecoded[ plane ][ sbSize >> ( MI_SIZE_LOG2 + subY ) ][ -1 ] = 0
    }
}

Decode Partition Function

decode_partition( r, c, bSize ) {
    if ( r >= MiRows || c >= MiCols )
        return 0
    num4x4 = Num_4x4_Blocks_Wide[ bSize ]
    halfBlock4x4 = num4x4 >> 1
    quarterBlock4x4 = halfBlock4x4 >> 1
    hasRows = ( r + halfBlock4x4 ) < MiRows
    hasCols = ( c + halfBlock4x4 ) < MiCols
    if (bSize < BLOCK_8X8) {
        partition = PARTITION_NONE
    } else if ( hasRows && hasCols )
        partition                                                            S
    } else if ( hasCols ) {
        split_or_horz                                                        S
        partition = split_or_horz ? PARTITION_SPLIT : PARTITION_HORZ
    } else if ( hasRows ) {
        split_or_vert                                                        S
        partition = split_or_vert ? PARTITION_SPLIT : PARTITION_VERT
    } else {
        partition = PARTITION_SPLIT
    }
    subSize = Partition_Subsize[ partition ][ bSize ]
    splitSize = Partition_Subsize[ PARTITION_SPLIT ][ bSize ]
    if ( partition == PARTITION_NONE ) {
        decode_block( r, c, subSize )
    } else if ( partition == PARTITION_HORZ ) {
        decode_block( r, c, subSize )
        if ( hasRows )
            decode_block( r + halfBlock4x4, c, subSize )
    } else if ( partition == PARTITION_VERT ) {
        decode_block( r, c, subSize )
        if ( hasCols )
            decode_block( r, c + halfBlock4x4, subSize )
    } else if ( partition == PARTITION_SPLIT ) {
        decode_partition( r, c, subSize )
        decode_partition( r, c + halfBlock4x4, subSize )
        decode_partition( r + halfBlock4x4, c, subSize )
        decode_partition( r + halfBlock4x4, c + halfBlock4x4, subSize )
    } else if ( partition == PARTITION_HORZ_A ) {
        decode_block( r, c, splitSize )
        decode_block( r, c + halfBlock4x4, splitSize )
        decode_block( r + halfBlock4x4, c, subSize )
    } else if ( partition == PARTITION_HORZ_B ) {
        decode_block( r, c, subSize )
        decode_block( r + halfBlock4x4, c, splitSize )
        decode_block( r + halfBlock4x4, c + halfBlock4x4, splitSize )
    } else if ( partition == PARTITION_VERT_A ) {
        decode_block( r, c, splitSize )
        decode_block( r + halfBlock4x4, c, splitSize )
        decode_block( r, c + halfBlock4x4, subSize )
    } else if ( partition == PARTITION_VERT_B ) {
        decode_block( r, c, subSize )
        decode_block( r, c + halfBlock4x4, splitSize )
        decode_block( r + halfBlock4x4, c + halfBlock4x4, splitSize )
    } else if ( partition == PARTITION_HORZ_4 ) {
        decode_block( r + quarterBlock4x4 * 0, c, subSize )
        decode_block( r + quarterBlock4x4 * 1, c, subSize )
        decode_block( r + quarterBlock4x4 * 2, c, subSize )
        decode_block( r + quarterBlock4x4 * 3, c, subSize )
    } else {
        decode_block( r, c + quarterBlock4x4 * 0, subSize )
        decode_block( r, c + quarterBlock4x4 * 1, subSize )
        decode_block( r, c + quarterBlock4x4 * 2, subSize )
        decode_block( r, c + quarterBlock4x4 * 3, subSize )
    }
}

Decode Block Syntax

decode_block( r, c, subSize ) {
    MiRow = r
    MiCol = c
    MiSize = subSize
    AvailU = is_inside( r - 1, c )
    AvailL = is_inside( r, c - 1 )
    bw4 = Num_4x4_Blocks_Wide[ subSize ]
    bh4 = Num_4x4_Blocks_High[ subSize ]
    if ( bh4 == 1 && subsampling_y && (MiRow & 1) == 0 )
        HasChroma = 0
    else if ( bw4 == 1 && subsampling_x && (MiCol & 1) == 0 )
        HasChroma = 0
    else
        HasChroma = 1
    mode_info( )
    for ( y = 0; y < bh4; y++ ) {
        for ( x = 0; x < bw4; x++ ) {
            YModes [ r + y ][ c + x ] = YMode
            for( refList = 0; refList < 2; refList++ )
                RefFrames[ r + y ][ c + x ][ refList ] = RefFrame[ refList ]
            if ( is_inter ) {
                for ( dir = 0; dir < 2; dir++ ) {
                    InterpFilters[ r + y ][ c + x ][ dir ] = interp_filter[ dir ]
                }
                for( refList = 0; refList < 2; refList++ ) {
                    Mvs[ r + y ][ c + x ][ refList ] = Mv[ refList ]
                    PredMvs[ r + y ][ c + x ][ refList ] = PredMv[ refList ]
                }
            }
        }
    }
    residual( )
    for ( y = 0; y < bh4; y++ ) {
        for ( x = 0; x < bw4; x++ ) {
            Skips[ r + y ][ c + x ] = skip
            TxSizes[ r + y ][ c + x ] = tx_size
            MiSizes[ r + y ][ c + x ] = MiSize
            TileNums[ r + y ][ c + x ] = TileNum
            TileStarts[ r + y ][ c + x ] = tg_start
            SegmentIds[ r + y ][ c + x ] = segment_id
            PaletteSizes[ 0 ][ r + y ][ c + x ] = PaletteSizeY
            PaletteSizes[ 1 ][ r + y ][ c + x ] = PaletteSizeUV
            for ( i = 0; i < PaletteSizeY; i++ )
                PaletteColors[ 0 ][ r + y ][ c + x ][ i ] = palette_colors_y[ i ]
            for ( i = 0; i < PaletteSizeUV; i++ )
                PaletteColors[ 1 ][ r + y ][ c + x ][ i ] = palette_colors_u[ i ]
            for ( i = 0; i < FRAME_LF_COUNT; i++ ) {
                DeltaLFs[ r + y ][ c + x ][ i ] = DeltaLF[ i ]
        }
    }
}

Mode Info Syntax

mode_info( ) {
    if ( FrameIsIntra )
        intra_frame_mode_info( )
    else
        inter_frame_mode_info( )
}

Intra Frame Mode Info Syntax

intra_frame_mode_info( ) {
    intra_segment_id( )
    read_skip( )
    read_delta_qindex( )
    read_delta_lf( )
    ReadDeltas = 0
    read_tx_size( 1 )
    RefFrame[ 0 ] = INTRA_FRAME
    RefFrame[ 1 ] = NONE
    is_inter = 0
    intra_frame_y_mode                                                       S
    YMode = intra_frame_y_mode
    if (HasChroma) {
        uv_mode                                                              S
        UVMode = uv_mode
        if (UVMode == UV_CFL_PRED) {
            read_cfl_alphas( )
        }
    }
    intra_angle_info( )
    PaletteSizeY = 0
    PaletteSizeUV = 0
    if (( MiSize >= BLOCK_8X8 ) && ( MiSize <= BLOCK_128X128 ) &&
          allow_screen_content_tools )
        palette_mode_info( )
    transform_type( )
}

Intra Segment ID Syntax

intra_segment_id( ) {
    if ( segmentation_enabled && segmentation_update_map )
        segment_id                                                           S
    else
        segment_id = 0
    Lossless = LosslessArray[ segment_id ]
}

Skip Syntax

read_skip() {
    if ( seg_feature_active( SEG_LVL_SKIP ) ) {
        skip = 1
    } else {
        skip                                                                 S
    }
}

Quantizer Index Delta Syntax

read_delta_qindex( ) {
    if ( MiSize == BLOCK_LARGEST && skip_coeff )
        return
    if ( ReadDeltas ) {
        delta_q_abs                                                          S
        if ( delta_q_abs == DELTA_Q_SMALL ) {
            delta_q_rem_bits                                                 L(3)
            delta_q_rem_bits++
            delta_q_abs_bits                                                 L(delta_q_rem_bits)
            delta_q_abs = delta_q_abs_bits + (1 << delta_q_rem_bits) + 1
        }
        if (delta_q_abs) {
            delta_q_sign_bit                                                 L(1)
            reducedDeltaQIndex = delta_q_sign_bit ? -delta_q_abs : delta_q_abs
            CurrentQIndex = Clip3(1, 255, CurrentQIndex + (reducedDeltaQIndex << delta_q_res))
        }
    }
}

Loop Filter Delta Syntax

read_delta_lf( ) {
    if ( MiSize == BLOCK_LARGEST && skip_coeff )
        return
    if ( ReadDeltas && delta_lf_present ) {
        for ( i = 0; i < ( delta_lf_multi ? FRAME_LF_COUNT : 1 ); i++ ) {
            delta_lf_abs                                                     S
            if ( delta_lf_abs == DELTA_LF_SMALL ) {
                delta_lf_rem_bits                                            L(3)
                n = delta_lf_rem_bits + 1
                delta_lf_abs_bits                                            L(n)
                deltaLfAbs = delta_lf_abs_bits +
                               ( 1 << n ) + 1
            } else {
                deltaLfAbs = delta_lf_abs
            }
            if ( deltaLfAbs ) {
                delta_lf_sign_bit                                            L(1)
                reducedDeltaLfLevel = delta_lf_sign_bit ?
                                      -deltaLfAbs :
                                       deltaLfAbs
                DeltaLF[ i ] = Clip3( 0, MAX_LOOP_FILTER, DeltaLF[ i ] +
                                  (reducedDeltaLfLevel << delta_lf_res) )
            }
        }
    }
}

Segmentation Feature Active Function

seg_feature_active_idx( idx, feature ) {
    return segmentation_enabled && FeatureEnabled[ idx ][ feature ]
}

seg_feature_active( feature ) {
    return seg_feature_active_idx( segment_id, feature )
}

TX Size Syntax

read_tx_size( allowSelect ) {
    largestTxSize = Tx_Mode_To_Biggest_Tx_Size[ TxMode ]
    maxTxSize = Max_Tx_Size[ MiSize ]
    maxRectTxSize = Max_Tx_Size_Rect[ MiSize ]
    maxCodedTxSize = maxTxSize + Rect_Tx_Allowed[ MiSize ]
    if ( MiSize > BLOCK_4X4 ) {
        if ( allowSelect && TxMode == TX_MODE_SELECT ) {
            tx_size                                                          S
            if (tx_size > maxTxSize )
                tx_size = maxRectTxSize
        } else {
            if ( Tx_Size_Sqr_Up[ maxRectTxSize ] <= largestTxSize )
                tx_size = maxRectTxSize
            else
                tx_size = largestTxSize
        }
    } else {
        tx_size = maxRectTxSize
    }
}

The Rect_Tx_Allowed table specifies which block sizes are allowed to use a rectangular transform; the table is defined as:

Rect_Tx_Allowed[ BLOCK_SIZES ] = {
    0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0,
    0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1,
};

The Tx_Mode_To_Biggest_Tx_Size table is defined as:

Tx_Mode_To_Biggest_Tx_Size[ TX_MODES ] = {
    TX_4X4,
    TX_8X8,
    TX_16X16,
    TX_32X32,
    TX_32X32
}

Inter TX Size Syntax

read_inter_tx_size is used in inter frames to read the transform sizes.

Either a single transform size is used for the whole block, or a tree of transform sizes is generated.

As the maximum transform size is 32 samples, a block may require several transform trees to be coded.

read_inter_tx_size( ) {
    bw4 = Num_4x4_Blocks_Wide[ MiSize ]
    bh4 = Num_4x4_Blocks_High[ MiSize ]
    if (tx_mode == TX_MODE_SELECT && 
          bsize > BLOCK_4X4 && is_inter &&
          !skip && !Lossless) {
        MinTxSize = TX_32X32
        maxTxSz = Max_Tx_Size_Rect[bsize]
        txW4 = Tx_Width[ maxTxSz ] / MI_SIZE
        txH4 = Tx_Height[ maxTxSz ] / MI_SIZE
        for ( row = MiRow; row < MiRow + bh4; row += txH4 )
            for ( col = MiCol; col < MiCol + bw4; col += txW4 )
                read_var_tx_size( row, col, maxTxSz, 0 )
    } else {
        read_tx_size(!skip || !is_inter)
        for ( row = MiRow; row < MiRow + bh4; row++ )
            for ( col = MiCol; col < MiCol + bw4; col++ )
                InterTxSizes[ row ][ col ] = tx_size
        MinTxSize = Tx_Size_Sqr[ tx_size ]
    }
}

Var TX Size Syntax

read_var_tx_size is used to read a transform size tree.

The original transform size may be square or rectangular, but only square transform sizes are produced if split.

read_var_tx_size( row, col, txSz, depth) {
    if ( row >= MiRows || col >= MiCols )
        return
    if (txSz == TX_4X4 || depth == MAX_VARTX_DEPTH) {
        txfm_split = 0
    } else {
        txfm_split                                                           S
    }
    w4 = Tx_Width[ txSz ] / MI_SIZE
    h4 = Tx_Height[ txSz ] / MI_SIZE
    if (txfm_split) {
        subTxSz = Split_Tx_Size[ txSz ]
        step4 = Tx_Width[ subTxSz ] / MI_SIZE
        for (i = 0; i < h4; i += step4)
            for (j = 0; j < w4; j += step4)
                read_var_tx_size( row + i, col + j, subTxSz, depth+1)
    } else {
        for (i = 0; i < h4; i++ )
            for (j = 0; j < w4; j++ )
                InterTxSizes[ row + i ][ col + j ] = txSz
        MinTxSize = Min( MinTxSize, Tx_Size_Sqr[ txSz ] )
        tx_size = txSz
    }
}

where Split_Tx_Size defines the transform size to use if txfm_split is equal to 1, and is defined as:

Split_Tx_Size[TX_SIZES_ALL] = {
  TX_4X4,    // TX_4X4
  TX_4X4,    // TX_8X8
  TX_8X8,    // TX_16X16
  TX_16X16,  // TX_32X32
  TX_4X4,    // TX_4X8
  TX_4X4,    // TX_8X4
  TX_8X8,    // TX_8X16
  TX_8X8,    // TX_16X8
  TX_16X16,  // TX_16X32
  TX_16X16,  // TX_32X16
  TX_4X4,    // TX_4X16
  TX_4X4,    // TX_16X4
  TX_8X8,    // TX_8X32
  TX_8X8,    // TX_32X8
}

Inter Frame Mode Info Function

inter_frame_mode_info( ) {
    LeftRefFrame[ 0 ] = AvailL ? RefFrames[ MiRow ][ MiCol-1 ][ 0 ] : INTRA_FRAME
    AboveRefFrame[ 0 ] = AvailU ? RefFrames[ MiRow-1 ][ MiCol ][ 0 ] : INTRA_FRAME
    LeftRefFrame[ 1 ] = AvailL ? RefFrames[ MiRow ][ MiCol-1 ][ 1 ] : NONE
    AboveRefFrame[ 1 ] = AvailU ? RefFrames[ MiRow-1 ][ MiCol ][ 1 ] : NONE
    LeftIntra = LeftRefFrame[ 0 ] <= INTRA_FRAME
    AboveIntra = AboveRefFrame[ 0 ] <= INTRA_FRAME
    LeftSingle = LeftRefFrame[ 1 ] <= INTRA_FRAME
    AboveSingle = AboveRefFrame[ 1 ] <= INTRA_FRAME
    inter_segment_id( )
    read_skip( )
    read_delta_qindex( )
    read_delta_lf( )
    ReadDeltas = 0
    read_is_inter( )
    read_inter_tx_size( )
    if ( is_inter )
        inter_block_mode_info( )
    else
        intra_block_mode_info( )
    transform_type( )
}

Inter Segment ID Syntax

inter_segment_id( ) {
    if ( segmentation_enabled ) {
        predictedSegmentId = get_segment_id( )
        if ( segmentation_update_map ) {
            if ( segmentation_temporal_update == 1 ) {
                seg_id_predicted                                             S
                if ( seg_id_predicted )
                    segment_id = predictedSegmentId
                else
                    segment_id                                               S
                for ( i = 0; i < Num_4x4_Blocks_Wide[ MiSize ]; i++ )
                    AboveSegPredContext[ MiCol + i ] = seg_id_predicted
                for ( i = 0; i < Num_4x4_Blocks_High[ MiSize ]; i++ )
                    LeftSegPredContext[ MiRow + i ] = seg_id_predicted
            } else {
                segment_id                                                   S
            }
        } else {
            segment_id = predictedSegmentId
        }
    } else {
        segment_id = 0
    }
    Lossless = LosslessArray[ segment_id ]
}

Is Inter Syntax

read_is_inter( ) {
    if ( seg_feature_active ( SEG_LVL_REF_FRAME ) )
        is_inter = FeatureData[ segment_id ][ SEG_LVL_REF_FRAME ] != INTRA_FRAME
    else
        is_inter                                                             S
}

Get Segment ID Syntax

The predicted segment id is the smallest value found in the on-screen region of the segmentation map covered by the current block.

get_segment_id( ) {
    bw4 = Num_4x4_Blocks_Wide[ MiSize ]
    bh4 = Num_4x4_Blocks_High[ MiSize ]
    xMis = Min( MiCols - MiCol, bw4 )
    yMis = Min( MiRows - MiRow, bh4 )
    seg = 7
    for ( y = 0; y < yMis; y++ )
        for ( x = 0; x < xMis; x++ )
            seg = Min( seg, PrevSegmentIds[ MiRow + y ][ MiCol + x ] )
    return seg
}

Intra Block Mode Info Syntax

The predicted segment id is the smallest value found in the on-screen region of the segmentation map covered by the current block.

intra_block_mode_info( ) {
    RefFrame[ 0 ] = INTRA_FRAME
    RefFrame[ 1 ] = NONE
    y_mode                                                                   S
    YMode = y_mode
    if (HasChroma) {
        uv_mode                                                              S
        UVMode = uv_mode
        if (UVMode == UV_CFL_PRED) {
            read_cfl_alphas( )
        }
    }
    intra_angle_info( )
    PaletteSizeY = 0
    PaletteSizeUV = 0
    if (( MiSize >= BLOCK_8X8 ) && ( MiSize <= BLOCK_128X128 ) &&
          allow_screen_content_tools )
        palette_mode_info( )
}

Inter Block Mode Info Syntax

inter_block_mode_info( ) {
    PaletteSizeY = 0
    PaletteSizeUV = 0
    read_ref_frames( )
    for ( j = 0; j < 2; j++ ) {
        if ( RefFrame[ j ] > INTRA_FRAME ) {
            find_mv_list( j )
            find_mv_stack( j )
        }
    }
    isCompound = RefFrame[ 1 ] > INTRA_FRAME
    if ( isCompound ) {
        compound_context( )
        find_mv_stack( -1 )
    }
    if ( seg_feature_active( SEG_LVL_SKIP ) ) {
        YMode = GLOBALMV
    } else if ( isCompound ) {
        compound_mode                                                        S
        YMode = NEAREST_NEARESTMV + compound_mode
    } else {
        new_mv                                                               S
        if ( newmv == 0 ) {
            YMode = NEWMV
        } else if ( AllZero ) {
            YMode = GLOBALMV
        } else {
            zero_mv                                                          S
            if ( zero_mv == 0 ) {
                YMode = GLOBALMV
            } else {
                ref_mv                                                       S
                YMode = (ref_mv == 0) ? NEARESTMV : NEARMV
            }
        }
        YMode = NEARESTMV + inter_mode
    }
    RefMvIdx = 0
    if (YMode == NEWMV || YMode == NEW_NEWMV) {
        for (idx = 0; idx < 2; idx++) {
            if (NumMvCount > idx + 1) {
                drl_mode                                                     S
                if (drl_mode == 0) {
                  RefMvIdx = idx
                  break
                }
                RefMvIdx = idx + 1
            }
        }
    } else if ( has_nearmv( ) ) {
        RefMvIdx = 1
        for (idx = 1; idx < 3; idx++) {
            if (NumMvCount > idx + 1) {
                drl_mode                                                     S
                if ( drl_mode == 0 ) {
                    RefMvIdx = idx
                    break
                }
                RefMvIdx = idx + 1
            }
        }
    }
    assign_mv( isCompound )
    read_interintra_mode( isCompound )
    read_motion_mode( isCompound )
    read_compound_type( isCompound )
    if ( interpolation_filter == SWITCHABLE ) {
        for ( dir = 0; dir < 2; dir++ ) {
            if ( needs_interp_filter( ) ) {
                interp_filter[ dir ]                                         S
            } else {
                interp_filter[ dir ] = EIGHTTAP
            }
        }
    } else {
        for ( dir = 0; dir < 2; dir++ )
            interp_filter[ dir ] = interpolation_filter
    }
}

The function has_nearmv is defined as:

has_nearmv( ) {
    return (YMode == NEARMV || YMode == NEAR_NEARMV
            || YMode == NEAR_NEWMV || YMode == NEW_NEARMV)
}

The function needs_interp_filter is defined as:

needs_interp_filter( ) {
    if (YMode == GLOBALMV) {
        return gm_type[ RefFrame[ 0 ] ] <= TRANSLATION
    } else if (YMode == GLOBAL_GLOBALMV ) {
        return gm_type[ RefFrame[ 0 ] ] <= TRANSLATION || gm_type[ RefFrame[ 1 ] ] <= TRANSLATION
    } else {
        return 1
    }
}

Ref Frames Syntax

read_ref_frames( ) {
    if ( seg_feature_active( SEG_LVL_REF_FRAME ) ) {
        RefFrame[ 0 ] = FeatureData[ segment_id ][ SEG_LVL_REF_FRAME ]
        RefFrame[ 1 ] = NONE
    } else if ( seg_feature_active( SEG_LVL_SKIP ) ) {
        RefFrame[ 0 ] = LAST_FRAME
        RefFrame[ 1 ] = NONE
    } else {
        if ( ReferenceMode == REFERENCE_MODE_SELECT )
            comp_mode                                                        S
        else
            comp_mode = ReferenceMode
        if ( comp_mode == COMPOUND_REFERENCE ) {
            comp_ref_type                                                    S
            if (comp_ref_type == UNIDIR_COMP_REFERENCE) {
                uni_comp_ref                                                 S
                if (uni_comp_ref) {
                    RefFrame[0] = BWDREF_FRAME
                    RefFrame[1] = ALTREF_FRAME
                } else {
                    uni_comp_ref_p1                                          S
                    if (uni_comp_ref_p1) {
                        uni_comp_ref_p2                                      S
                        if (uni_comp_ref_p2) {
                          RefFrame[0] = LAST_FRAME
                          RefFrame[1] = GOLDEN_FRAME
                        } else {
                          RefFrame[0] = LAST_FRAME
                          RefFrame[1] = LAST3_FRAME
                        }
                    } else {
                        RefFrame[0] = LAST_FRAME
                        RefFrame[1] = LAST2_FRAME
                    }
                }
            } else {
                comp_ref                                                     S
                if ( comp_ref == 0 ) {
                    comp_ref_p1                                              S
                    RefFrame[ 0 ] = comp_ref_p1 ?
                                    LAST_FRAME : LAST2_FRAME
                } else {
                    comp_ref_p2                                              S
                    RefFrame[ 0 ] = comp_ref_p2 ?
                                    GOLDEN_FRAME : LAST3_FRAME
                }
                comp_bwdref                                                  S
                if ( comp_bwdref == 0 ) {
                    comp_bwdref_p1                                           S
                    RefFrame[ 1 ] = comp_bwd_ref ?
                                     ALTREF2_FRAME : BWDREF_FRAME
                } else {
                    RefFrame[ 1 ] = ALTREF_FRAME
                }
            }
        } else {
            single_ref_p1                                                    S
            if ( single_ref_p1 ) {
                single_ref_p2                                                S
                if ( single_ref_p2 == 0 ) {
                    single_ref_p6                                            S
                    RefFrame[ 0 ] = single_ref_p6 ?
                                     ALTREF2_FRAME : BWDREF_FRAME
                } else {
                    RefFrame[ 0 ] = ALTREF_FRAME
                }
            } else {
                single_ref_p3                                                S
                if ( single_ref_p3 == 0 ) {
                    single_ref_p5                                            S
                    RefFrame[ 0 ] = single_ref_p5 ?
                                     GOLDEN_FRAME : LAST3_FRAME
                } else {
                    single_ref_p4                                            S
                    RefFrame[ 0 ] = single_ref_p4 ?
                                     LAST2_FRAME : LAST_FRAME
                }
            }
            RefFrame[ 1 ] = NONE
        }
    }
}

Assign MV Function

assign_mv( isCompound ) {
    bw = Block_Width[ MiSize ]
    bh = Block_Height[ MiSize ]
    Mv[ 1 ] = ZeroMvs[ 1 ]
    PredMv[ 1 ] = ZeroMvs[ 1 ]
    for ( i = 0; i < 1 + isCompound; i++ ) {
        compMode = get_mode( i )
        if ( compMode == GLOBALMV ) {
            PredMv[ i ] = ZeroMvs[ i ]
        } else {
            pos = ( compMode == NEARESTMV ) ? 0 : RefMvIdx
            useStack = pos < NumMvFound
            if ( compMode == NEWMV && NumMvFound <= 1)
                useStack = 0
            if ( useStack ) {
                PredMv[ i ] = RefStackMv[ pos ]
                if ( YMode == NEARMV && pos > 1 ) {
                    // No clamping
                } else {
                    PredMv[ i ][ 0 ] = clamp_mv_row( PredMv[ i ][ 0 ], MV_BORDER + bh * 8)
                    PredMv[ i ][ 1 ] = clamp_mv_col( PredMv[ i ][ 1 ], MV_BORDER + bw * 8)
                }
            } else {
                PredMv[ i ] = RefListMv[ i ][ pos ]
            }
        }
        if ( compMode == NEWMV )
            read_mv( i )
    }
}

Read Motion Mode Syntax

read_motion_mode( isCompound ) {
    if ( Min( Block_Width[ MiSize ],
              Block_Height[ MiSize ] ) < 8 ) {
        motion_mode = SIMPLE
        return
    }
    if ( YMode == GLOBALMV || YMode == GLOBAL_GLOBALMV) {
        if (gm_type[ RefFrame[ 0 ] ] > TRANSLATION) {
            motion_mode = SIMPLE
            return
        }
    }
    if ( isCompound || !has_overlappable_candidates( ) ) {
        motion_mode = SIMPLE
        return
    }
    find_warp_samples()
    if ( NumSamples == 0) {
        use_obmc                                                             S
        motion_mode = use_obmc ? OBMC : SIMPLE
    } else {
        motion_mode                                                          S
    }
}

Read Inter Intra Syntax

read_interintra_mode( isCompound ) {
    if ( allow_interintra_compound && !isCompound && 
         MiSize >= BLOCK_8X8 && MiSize <= BLOCK_32X32) {
        interintra                                                           S
        if (interintra) {
            interintra_mode                                                  S
            RefFrame[1] = INTRA_FRAME
            AngleDeltaY = 0
            AngleDeltaUV = 0
            n = Wedge_Bits[ MiSize ]
            if ( n > 0 ) {
                wedge_interintra                                             S
                if (wedge_interintra) {
                    wedge_index                                              L(n)
                    wedge_sign = 0
                }
            } else {
                wedge_interintra = 0
            }
        }
    } else {
        interintra = 0
    }
}

Read Compound Type Syntax

read_compound_type( isCompound ) {
    if ( allow_masked_compound && isCompound && motion_mode == SIMPLE && MiSize >= BLOCK_8X8) {
        n = Wedge_Bits[ MiSize ]
        if ( n == 0 ) {
            compound_type                                                    S
        } else {
            compound_avg                                                     L(1)
            compound_type = compound_avg ?
                            COMPOUND_AVERAGE : COMPOUND_SEG
        }
        if ( compound_type == COMPOUND_WEDGE ) {
            wedge_index                                                      L(n)
            wedge_sign                                                       L(1)
        } else if ( compound_type == COMPOUND_SEG ) {
            mask_type                                                        L(1)
        }
    } else {
        if ( interintra ) {
            compund_type = wedge_interintra ? COMPOUND_WEDGE : COMPOUND_INTRA
        } else {
            compound_type = COMPOUND_AVERAGE
        }
    }
}

Get Mode Function

get_mode( refList ) {
    if ( refList == 0 ) {
        if (YMode < NEAREST_NEARESTMV)
            compMode = YMode
        else if (YMode == NEW_NEWMV || YMode == NEW_NEARESTMV || YMode == NEW_NEARMV)
            compMode = NEWMV
        else if (YMode == NEAREST_NEARESTMV || YMode == NEAREST_NEWMV)
            compMode = NEARESTMV
        else if (YMode == NEAR_NEARMV || YMode == NEAR_NEWMV)
            compMode = NEARMV
        else
            compMode = GLOBALMV
    } else {
        if (YMode == NEW_NEWMV || YMode == NEAREST_NEWMV || YMode == NEAR_NEWMV)
            compMode = NEWMV
        else if (YMode == NEAREST_NEARESTMV || YMode == NEW_NEARESTMV)
            compMode = NEARESTMV
        else if (YMode == NEAR_NEARMV || YMode == NEW_NEARMV)
            compMode = NEARMV
        else
            compMode = GLOBALMV
    }
    return compMode
}

MV Syntax

read_mv( ref ) {
    diffMv[ 0 ] = 0
    diffMv[ 1 ] = 0
    if ( has_nearmv( ) )
        idx = RefMvIdx - 1
    else
        idx = RefMvIdx
    if ( idx < NumMvFound )
        MvCtx = MvCtxStack[ idx ][ ref ]
    else
        MvCtx = 0
    mv_joint                                                                 S
    if ( mv_joint == MV_JOINT_HZVNZ || mv_joint == MV_JOINT_HNZVNZ )
        diffMv[ 0 ] = read_mv_component( 0 )
    if ( mv_joint == MV_JOINT_HNZVZ || mv_joint == MV_JOINT_HNZVNZ )
        diffMv[ 1 ] = read_mv_component( 1 )
    Mv[ ref ][ 0 ] = PredMv[ ref ][ 0 ] + diffMv[ 0 ]
    Mv[ ref ][ 1 ] = PredMv[ ref ][ 1 ] + diffMv[ 1 ]
}

Note: When has_nearmv() is true, the candidate motion vector to be used is at index RefMvIdx, but the CDF for the motion vectors is associated with the previous candidate.

MV Component Syntax

read_mv_component( comp ) {
    mv_sign                                                                  S
    mv_class                                                                 S
    if ( mv_class == MV_CLASS_0 ) {
        mv_class0_bit                                                        S
        mv_class0_fr                                                         S
        mv_class0_hp                                                         S
        mag = ( ( mv_class0_bit << 3 ) |
                ( mv_class0_fr << 1 ) |
                  mv_class0_hp ) + 1
    } else {
        d = 0
        for ( i = 0; i < mv_class; i++ ) {
            mv_bit                                                           S
            d |= mv_bit << i
        }
        mag = CLASS0_SIZE << ( mv_class + 2 )
        mv_fr                                                                S
        mv_hp                                                                S
        mag += ( ( d << 3 ) | ( mv_fr << 1 ) | mv_hp ) + 1
    }
    return mv_sign ? -mag : mag
}

Residual Syntax

residual( ) {
    palette_tokens( )

    sbMask = use_128x128_superblock ? 31 : 15
    subBlockMiRow = MiRow & sbMask
    subBlockMiCol = MiCol & sbMask

    for ( plane = 0; plane < 1 + HasChroma * 2; plane++ ) {
        txSz = get_tx_size( plane, tx_size )
        stepX = Tx_Width[ txSz ] >> 2
        stepY = Tx_Height[ txSz ] >> 2
        planeSz = get_plane_residual_size( MiSize, plane )
        num4x4W = Num_4x4_Blocks_Wide[ planeSz ]
        num4x4H = Num_4x4_Blocks_High[ planeSz ]
        log2W = MI_SIZE_LOG2 + Mi_Width_Log2[ planeSz ]
        log2H = MI_SIZE_LOG2 + Mi_Height_Log2[ planeSz ]
        subX = (plane > 0) ? subsampling_x : 0
        subY = (plane > 0) ? subsampling_y : 0
        baseX = (MiCol >> subX) * MI_SIZE
        baseY = (MiRow >> subY) * MI_SIZE
        candRow = (MiRow >> subY) << subY
        candCol = (MiCol >> subX) << subX

        isInterIntra = ( is_inter && RefFrame[ 1 ] == INTRA_FRAME )
        isCFL = (plane > 0 && !is_inter && UVMode == UV_CFL_PRED)

        if ( isInterIntra ) {
            if ( interintra_mode == II_DC_PRED ) mode = DC_PRED
            else if ( interintra_mode == II_V_PRED ) mode = V_PRED
            else if ( interintra_mode == II_H_PRED ) mode = H_PRED
            else mode = SMOOTH_PRED
        } else {
            mode = DC_PRED
        }

        if ( isInterIntra || isCFL ) {
            predict_intra( plane, baseX, baseY,
                           AvailL,
                           AvailU,
                           BlockDecoded[ plane ]
                                       [ ( subBlockMiRow >> subY ) - 1 ]
                                       [ ( subBlockMiCol >> subX ) + num4x4W ],
                           BlockDecoded[ plane ]
                                       [ ( subBlockMiRow >> subY ) + num4x4H ]
                                       [ ( subBlockMiCol >> subX ) - 1 ],
                           mode,
                           log2W, log2H )
        }

        if ( is_inter ) {
            predW = Block_Width[ MiSize ] >> subX
            predH = Blocks_Height[ MiSize ] >> subY
            someUseIntra = 0
            for( r = 0; r < num4x4H; r++ )
                for( c = 0; c < num4x4W; c++ )
                    if ( RefFrames[ candRow + r ][ candCol + c ][ 0 ] == INTRA_FRAME )
                        someUseIntra = 1
            if ( someUseIntra ) {
                predW = num4x4W * 4
                predH = num4x4H * 4
            }
            r = 0
            for( y = 0; y < num4x4H * 4; y += predH ) {
                c = 0
                for( x = 0; x < num4x4W * 4; x += predW ) {
                    predict_inter( plane, baseX + x, baseY + y,
                                   predW, predH,
                                   candRow + r, candCol + c)
                    c++
                }
                r++
            }
        }

        maxX = (MiCols * MI_SIZE) >> subX
        maxY = (MiRows * MI_SIZE) >> subY
        if (is_inter) {
            transform_tree( plane, baseX, baseY, num4x4W * 4, num4x4H * 4 )
        } else {
            for( y = 0; y < num4x4H; y += stepY )
                for( x = 0; x < num4x4W; x += stepX )
                    transform_block( plane, baseX, baseY, txSz, x, y)
        }
    }
}

Transform Block Syntax

transform_block(plane, baseX, baseY, txSz, x, y) {
    startX = baseX + 4 * x
    startY = baseY + 4 * y
    subX = (plane > 0) ? subsampling_x : 0
    subY = (plane > 0) ? subsampling_y : 0
    row = ( startY << subY ) >> MI_SIZE_LOG2
    col = ( startX << subX ) >> MI_SIZE_LOG2
    sbMask = use_128x128_superblock ? 31 : 15
    subBlockMiRow = row & sbMask
    subBlockMiCol = col & sbMask
    stepX = Tx_Width[ txSz ] >> MI_SIZE_LOG2
    stepY = Tx_Height[ txSz ] >> MI_SIZE_LOG2
    maxX = (MiCols * MI_SIZE) >> subX
    maxY = (MiRows * MI_SIZE) >> subY
    nonzero = 0
    if ( startX >= maxX || startY >= maxY ) {
        return
    }
    if ( !is_inter ) {
        if ( ( ( plane == 0 ) && PaletteSizeY ) ||
             ( ( plane != 0 ) && PaletteSizeUV ) ) {
            predict_palette( plane, startX, startY, x, y, txSz )
        } else if ( isCFL ) {
            predict_chroma_from_luma( plane, startX, startY, txSz )
        } else {
            mode = ( plane == 0 ) ? YMode : UVMode
            log2W = Tx_Width_Log2[ txSz ]
            log2H = Tx_Height_Log2[ txSz ]
            predict_intra( plane, startX, startY,
                           AvailL || x > 0,
                           AvailU || y > 0,
                           BlockDecoded[ plane ]
                                       [ ( subBlockMiRow >> subY ) + y - 1 ]
                                       [ ( subBlockMiCol >> subX ) + x + stepX ],
                           BlockDecoded[ plane ]
                                       [ ( subBlockMiRow >> subY ) + y + stepY ]
                                       [ ( subBlockMiCol >> subX ) + x - 1 ],
                           mode,
                           log2W, log2H )
        }
        if (plane == 0) {
            MaxLumaW = startX + stepX * 4
            MaxLumaH = startY + stepY * 4
        }
    }
    if ( !skip ) {
        nonzero = tokens( plane, startX, startY, txSz )
        reconstruct( plane, startX, startY, txSz )
    }
    for ( i = 0; i < stepY; i++ ) {
        for ( j = 0; j < stepX; j++ ) {
            LoopfilterTxSizes[ plane ]
                             [ (row >> subY) + i ]
                             [ (col >> subX) + j ] = txSz
            BlockDecoded[ plane ]
                        [ ( subBlockMiRow >> subY ) + y + i ]
                        [ ( subBlockMiCol >> subX ) + x + j ] = 1
        }
    }

    for ( i = 0; i < stepX; i++ )
        AboveNonzeroContext[ plane ][ ( startX >> 2 ) + i ] = nonzero
    for ( i = 0; i < stepY; i++ )
        LeftNonzeroContext[ plane ][ ( startY >> 2 ) + i ] = nonzero
}

Transform Tree Syntax

transform_tree is used to read a number of transform blocks arranged in a transform tree.

transform_tree( plane, startX, startY, w, h ) {
    maxX = (MiCols * MI_SIZE) >> subX
    maxY = (MiRows * MI_SIZE) >> subY
    if ( startX >= maxX || startY >= maxY ) {
        return
    }
    subX = (plane > 0) ? subsampling_x : 0
    subY = (plane > 0) ? subsampling_y : 0
    row = ( startY << subY ) >> MI_SIZE_LOG2
    col = ( startX << subX ) >> MI_SIZE_LOG2
    lumaTxSz = InterTxSizes[ row ][ col ]
    lumaW = Tx_Width[ lumaTxSz ]
    lumaH = Tx_Height[ lumaTxSz ]
    isLumaSquare = ( lumaW == lumaH )
    isSquare = ( w == h )
    becomingRect = isLumaSquare && !isSquare
    if ( w <= lumaW && h <= lumaH && !becomingRect) {
        txSz = find_tx_size( w, h )
        transform_block( plane, startX, startY, txSz, 0, 0 )
    } else {
        if ( w > h ) {
            transform_tree( plane, startX, startY, w/2, h )
            transform_tree( plane, startX + w / 2, startY, w/2, h )
        } else if ( w < h ) {
            transform_tree( plane, startX, startY, w, h/2 )
            transform_tree( plane, startX, startY + h/2, w, h/2 )
        } else {
            transform_tree( plane, startX, startY, w/2, h/2 )
            transform_tree( plane, startX + w/2, startY, w/2, h/2 )
            transform_tree( plane, startX, startY + h/2, w/2, h/2 )
            transform_tree( plane, startX + w/2, startY + h/2, w/2, h/2 )
        }
    }
}
{:.syntax }

where find_tx_size finds the transform size matching the given dimensions and is defined as:

~~~~~ c
find_tx_size( w, h ) {
    for( txSz = 0; txSz < TX_SIZES_ALL; txSz++ )
        if ( Tx_Width[ txSz ] == w && Tx_Height[ txSz ] == h )
            break
    return txSz
}

Get TX Size Function

get_tx_size( plane, txSz ) {
    return plane > 0 ? Uv_Tx_Size[ MiSize ][ txSz ][ subsampling_x ][ subsampling_y ] : txSz
}

Get Plane Residual Size Function

The get_plane_residual_size returns the size of a residual block for the specified plane. (The residual block will always have width and height at least equal to 4.)

get_plane_residual_size( subsize, plane ) {
    subx = plane > 0 ? subsampling_x : 0
    suby = plane > 0 ? subsampling_y : 0
    return Subsampled_Size[ subsize ][ subx ][ suby ]
}

The Subsampled_Size table is defined as:

Subsampled_Size[ BLOCK_SIZES ][ 2 ][ 2 ] = {
  { { BLOCK_4X4,    BLOCK_4X4},      {BLOCK_4X4,     BLOCK_4X4} },
  { { BLOCK_4X8,    BLOCK_4X4},      {BLOCK_INVALID, BLOCK_4X4} },
  { { BLOCK_8X4,    BLOCK_INVALID},  {BLOCK_4X4,     BLOCK_4X4} },
  { { BLOCK_8X8,    BLOCK_8X4},      {BLOCK_4X8,     BLOCK_4X4} },
  { {BLOCK_8X16,    BLOCK_8X8},      {BLOCK_INVALID, BLOCK_4X8} },
  { {BLOCK_16X8,    BLOCK_INVALID},  {BLOCK_8X8,     BLOCK_8X4} },
  { {BLOCK_16X16,   BLOCK_16X8},     {BLOCK_8X16,    BLOCK_8X8} },
  { {BLOCK_16X32,   BLOCK_16X16},    {BLOCK_INVALID, BLOCK_8X16} },
  { {BLOCK_32X16,   BLOCK_INVALID},  {BLOCK_16X16,   BLOCK_16X8} },
  { {BLOCK_32X32,   BLOCK_32X16},    {BLOCK_16X32,   BLOCK_16X16} },
  { {BLOCK_32X64,   BLOCK_32X32},    {BLOCK_INVALID, BLOCK_16X32} },
  { {BLOCK_64X32,   BLOCK_INVALID},  {BLOCK_32X32,   BLOCK_32X16} },
  { {BLOCK_64X64,   BLOCK_64X32},    {BLOCK_32X64,   BLOCK_32X32} }
  { {BLOCK_64X128,  BLOCK_64X64},    {BLOCK_INVALID, BLOCK_32X64} },
  { {BLOCK_128X64,  BLOCK_INVALID},  {BLOCK_64X64,   BLOCK_64X32} },
  { {BLOCK_128X128, BLOCK_128X64},   {BLOCK_64X128,  BLOCK_64X64} },
  { {BLOCK_4X16,    BLOCK_4X8},      {BLOCK_INVALID, BLOCK_4X8} },
  { {BLOCK_16X4,    BLOCK_INVALID},  {BLOCK_8X4,     BLOCK_8X4} },
  { {BLOCK_8X32,    BLOCK_8X16},     {BLOCK_INVALID, BLOCK_4X16} },
  { {BLOCK_32X8,    BLOCK_INVALID},  {BLOCK_16X8,    BLOCK_16X4} },
  { {BLOCK_16X64,   BLOCK_16X32},    {BLOCK_INVALID, BLOCK_8X32} },
  { {BLOCK_64X16,   BLOCK_INVALID},  {BLOCK_32X16,   BLOCK_32X8} },
  { {BLOCK_32X128,  BLOCK_32X64},    {BLOCK_INVALID, BLOCK_16X64} },
  { {BLOCK_128X32,  BLOCK_INVALID},  {BLOCK_64X32,   BLOCK_64X16} },
}

Token Syntax

tokens( plane, startX, startY, txSz ) {
    segEob = Tx_Width[ txSz ] * Tx_Height[ txSz ]
    PlaneTxType = compute_tx_type( plane, txSz )
    scan = get_scan( plane, txSz )
    for ( i = 0; i < segEob; i++ )
        Tokens[ i ] = 0
    for( c = 0; c < segEob; c++ ) {
        pos = scan[ c ]
        band = (txSz == TX_4X4) ? Coefband_4x4[ c ] :
                   (txSz == TX_4X8 || txSz == TX_8X4) ?
                       Coefband_4x8_8x4[ c ] :
                       Coefband_8x8_Plus[ c ]
        if ( c == 0 ) {
            dc_head_token                                                    S
            if ( dc_head_token == 0 )
                return 0
            combToken = dc_head_token
        } else if (c == segEob - 1) {
            last_head_token                                                  L(1)
            combToken = 2 * (last_head_token + 1)
        } else {
            ac_head_token                                                    S
            combToken = ac_head_token + 1
        }
        token = combToken >> 1
        moreCoefs = combToken & 1
        if ( token > ONE_TOKEN ) {
            tail_token                                                       S
            token += tail_token
        }
        TokenCache[ pos ] = Energy_Class[ token ]
        if ( token != ZERO_TOKEN ) {
            coef = read_coef( token )
            sign_bit                                                         L(1)
            Tokens[ pos ] = sign_bit ? -coef : coef
        }
        if ( !moreCoefs )
            break
    }
    return 1
}

Compute Transform Type Function

compute_tx_type( plane, txSz ) {
    txSzSqr = Tx_Size_Sqr[ txSz ]
    if ( Lossless ||
         txSzSqr > TX_32X32 ||
         ( txSzSqr >= TX_32X32 && RefFrame[ 0 ] == INTRA_FRAME) )
        return DCT_DCT
    if ( plane == 0 )
        return TxType
    if ( RefFrame[ 0 ] != INTRA_FRAME )
        return ( TxType == IDTX && txSzSqr >= TX_32X32 ) ? DCT_DCT : TxType
    return Mode_To_Txfm[ plane > 0 ? UVMode : YMode ]
}

Get Scan Function

get_mrow_scan( txSz ) {
    if ( txSz == TX_4X4 )
        return Mrow_Scan_4x4
    else if ( txSz == TX_4X8 )
        return Mrow_Scan_4x8
    else if ( txSz == TX_8X4 )
        return Mrow_Scan_8x4
    else if ( txSz == TX_8X8 )
        return Mrow_Scan_8x8
    else if ( txSz == TX_8X16 )
        return Mrow_Scan_8x16
    else if ( txSz == TX_16X8 )
        return Mrow_Scan_16x8
    else if ( txSz == TX_16X16 )
        return Mrow_Scan_16x16
    else if ( txSz == TX_16X32 )
        return Mrow_Scan_16x32
    else if ( txSz == TX_32X16 )
        return Mrow_Scan_32x16
    return mrow_scan_32x32
}

get_row_scan( txSz ) {
    if ( txSz == TX_4X4 )
        return Row_Scan_4x4
    else if ( txSz == TX_8X8 )
        return Row_Scan_8x8
    return row_scan_16x16
}

get_mcol_scan( txSz ) {
    if ( txSz == TX_4X4 )
        return Mcol_Scan_4x4
    else if ( txSz == TX_4X8 )
        return Mcol_Scan_4x8
    else if ( txSz == TX_8X4 )
        return Mcol_Scan_8x4
    else if ( txSz == TX_8X8 )
        return Mcol_Scan_8x8
    else if ( txSz == TX_8X16 )
        return Mcol_Scan_8x16
    else if ( txSz == TX_16X8 )
        return Mcol_Scan_16x8
    else if ( txSz == TX_16X16 )
        return Mcol_Scan_16x16
    else if ( txSz == TX_16X32 )
        return Mcol_Scan_16x32
    else if ( txSz == TX_32X16 )
        return Mcol_Scan_32x16
    return mcol_scan_32x32
}

get_col_scan( txSz ) {
    if ( txSz == TX_4X4 )
        return Col_Scan_4x4
    else if ( txSz == TX_8X8 )
        return Col_Scan_8x8
    return Col_Scan_16x16
}

get_default_scan( txSz ) {
    if ( txSz == TX_4X4 )
        return Default_Scan_4x4
    else if ( txSz == TX_4X8 )
        return Default_Scan_4x8
    else if ( txSz == TX_8X4 )
        return Default_Scan_8x4
    else if ( txSz == TX_8X8 )
        return Default_Scan_8x8
    else if ( txSz == TX_8X16 )
        return Default_Scan_8x16
    else if ( txSz == TX_16X8 )
        return Default_Scan_16x8
    else if ( txSz == TX_16X16 )
        return Default_Scan_16x16
    else if ( txSz == TX_16X32 )
        return Default_Scan_16x32
    else if ( txSz == TX_32X16 )
        return Default_Scan_32x16
    return Default_Scan_32x32
}

get_scan( plane, txSz ) {
    preferRow = ( PlaneTxType == ADST_DCT ||
                  PlaneTxType == V_DCT ||
                  PlaneTxType == V_ADST ||
                  PlaneTxType == V_FLIPADST )

    preferCol = ( PlaneTxType == DCT_ADST ||
                  PlaneTxType == H_DCT ||
                  PlaneTxType == H_ADST ||
                  PlaneTxType == H_FLIPADST )

    usesIdTx  = ( PlaneTxType == IDTX ||
                  PlaneTxType == V_DCT ||
                  PlaneTxType == V_ADST ||
                  PlaneTxType == V_FLIPADST ||
                  PlaneTxType == H_DCT ||
                  PlaneTxType == H_ADST ||
                  PlaneTxType == H_FLIPADST )

    preferRaster = !( txSz == TX_4X4 ||
                      txSz == TX_8X8 ||
                      txSz == TX_16X16 )

    if ( !usesIdTx ) {
        if ( txSz == TX_32X32 ) {
            if ( PlaneTxType == DCT_DCT )
                return Default_Scan_32x32
            else if ( PlaneTxType == ADST_DCT ||
                      PlaneTxType == FLIPADST_DCT )
                return H2_Scan_32x32
            else if ( PlaneTxType == DCT_ADST ||
                      PlaneTxType == DCT_FLIPADST )
                return V2_Scan_32x32
            return Qtr_Scan_32x32
        } else if ( is_inter ) {
            preferRow = 0
            preferCol = 0
        }
    }

    if (preferRow) {
        return preferRaster ? get_mrow_scan( txSz ) : get_row_scan( txSz )
    } else if (preferCol) {
        return preferRaster ? get_mcol_scan( txSz ) : get_col_scan( txSz )
    }
    return get_default_scan( txSz )
}

Coef Syntax

read_coef( token ) {
    cat = Extra_Bits[ token ][ 0 ]
    minValue = Extra_Bits[ token ][ 2 ]
    if ( cat == 0 )
        return token
    
    if ( cat < 6 ) {
        extraBitCount = Extra_Bits[ token ][ 1 ]
    } else {
        extraBitCount = BitDepth + 3 + Max( 0, Tx_Size_Sqr_Up[ tx_size ] )
        extraBitCount = Min( 18, ( ( extraBitCount + 3 ) >> 2 ) << 2 )
    }
    
    coef = 0
    count = 0
    cdfIndex = 0
    while ( count < extraBitCount ) {
        bits = Min( extraBitCount - count, 4 )
        coef_extra_bits                                                S
        coef |= coef_extra_bits << count
        count += bits
        cdfIndex += 1
    }
    return minValue + coef
}

where Extra_Bits is defined as:

Extra_Bits[ 11 ][ 3 ] = {
    { 0, 0, 0 },
    { 0, 0, 1 },
    { 0, 0, 2 },
    { 0, 0, 3 },
    { 0, 0, 4 },
    { 1, 1, 5 },
    { 2, 2, 7 },
    { 3, 3, 11 },
    { 4, 4, 19 },
    { 5, 5, 35 },
    { 6, 14, 67 }
}

Intra Angle Info Syntax

intra_angle_info( ) {
    if ( MiSize >= BLOCK_8X8 ) {
        n = 2 * MAX_ANGLE_DELTA + 1
        if ( is_directional_mode( YMode ) ) {
            angle_delta_y                                                    U(n)
            AngleDeltaY = angle_delta_y - MAX_ANGLE_DELTA
        }
        if ( is_directional_mode( UVMode ) ) {
            angle_delta_uv                                                   U(n)
            AngleDeltaUV = angle_delta_uv - MAX_ANGLE_DELTA
        }
    }
}

Is Directional Mode Function

is_directional_mode( mode ) {
    if ( ( mode >= V_PRED ) && ( mode <= D63_PRED )
         && ( MiSize >= BLOCK_8X8 ) ) {
        return 1
    }
    return 0
}

Read CFL Alphas Syntax

read_cfl_alphas() {
    cfl_alpha_signs                                                          S
    signU = (cfl_alpha_signs + 1 ) / 3
    signV = (cfl_alpha_signs + 1 ) % 3
    if (signU != CFL_SIGN_ZERO) {
        cfl_alpha_u                                                          S
        CflAlphaU = 1 + cfl_alpha_u
        if (signU == CFL_SIGN_NEG)
            CflAlphaU = -CflAlphaU
    } else {
      CflAlphaU = 0
    }
    if (signV != CFL_SIGN_ZERO) {
        cfl_alpha_v                                                          S
        CflAlphaV = 1 + cfl_alpha_v
        if (signV == CFL_SIGN_NEG)
            CflAlphaV = -CflAlphaV
    } else {
      CflAlphaV = 0
    }
}

Palette Mode Info Syntax

palette_mode_info( ) {
    if ( YMode == DC_PRED ) {
        has_palette_y                                                        S
        if ( has_palette_y ) {
            palette_size_y_minus_2                                           S
            PaletteSizeY = palette_size_y_minus_2 + 2
            cacheN = get_palette_cache( 0 )
            idx = 0
            for ( i = 0; i < cacheN && idx < PaletteSizeY; i++ ) {
                use_palette_color_cache_y                                    L(1)
                if ( use_palette_color_cache_y ) {
                    palette_colors_y[ idx ] = PaletteCache[ i ]
                    idx++
                }
            }
            if ( idx < PaletteSizeY ) {
                palette_colors_y[ idx ]                                      L(BitDepth)
                idx++
            }
            if ( idx < PaletteSizeY ) {
                minBits = BitDepth - 3
                palette_num_extra_bits_y                                     L(2)
                paletteBits = minBits + palette_num_extra_bits_y
            }
            while ( idx < PaletteSizeY ) {
                palette_delta_y                                              L(paletteBits)
                palette_delta_y++
                palette_colors_y[ idx ] =
                          Clip1( palette_colors_y[ idx - 1 ] +
                                 palette_delta_y )
                range = ( 1 << BitDepth ) - palette_colors_y[ idx ] - 1
                paletteBits = Min( paletteBits, ceil( log2( range ) ) )
                idx++
            }
            sort( palette_colors_y, 0, PaletteSizeY - 1 )
        }
    }
    if ( UVMode == DC_PRED ) {
        has_palette_uv                                                       S
        if ( has_palette_uv ) {
            palette_size_uv_minus_2                                          S
            PaletteSizeUV = palette_size_uv_minus_2 + 2
            cacheN = get_palette_cache( 1 )
            idx = 0
            for ( i = 0; i < cacheN && idx < PaletteSizeUV; i++ ) {
                use_palette_color_cache_u                                    L(1)
                if ( use_palette_color_cache_u ) {
                    palette_colors_u[ idx ] = PaletteCache[ i ]
                    idx++
                }
            }
            if ( idx < PaletteSizeUV ) {
                palette_colors_u[ idx ]                                      L(BitDepth)
                idx++
            }
            if ( idx < PaletteSizeUV ) {
                minBits = BitDepth - 3
                palette_num_extra_bits_u                                     L(2)
                paletteBits = minBits + palette_num_extra_bits_u
            }
            while ( idx < PaletteSizeUV ) {
                palette_delta_u                                              L(paletteBits)
                palette_colors_u[ idx ] = 
                          Clip1( palette_colors_u[ idx - 1 ] +
                                 palette_delta_u )
                range = ( 1 << BitDepth ) - palette_colors_u[ idx ]
                paletteBits = Min( paletteBits, ceil( log2( range ) ) )
                idx++
            }
            sort( palette_colors_u, 0, PaletteSizeUV - 1 )
            
            delta_encode_palette_colors_v                                    L(1)
            if ( delta_encode_palette_colors_v ) {
                minBits = BitDepth - 4
                maxVal = 1 << BitDepth
                palette_num_extra_bits_v                                     L(2)
                paletteBits = minBits + palette_num_extra_bits_v
                palette_colors_v[ 0 ]                                        L(BitDepth)
                for ( idx = 1; idx < PaletteSizeUV; idx++ ) {
                    palette_delta_v                                          L(paletteBits)
                    if ( palette_delta_v ) {
                        palette_delta_sign_bit_v                             L(1)
                        if ( palette_delta_sign_bit_v ) {
                            palette_delta_v = -palette_delta_v
                        }
                    }
                    val = palette_colors_v[ idx - 1 ] + palette_delta_v
                    if ( val < 0 ) val += maxVal
                    if ( val >= maxVal ) val -= maxVal
                    palette_colors_v[ idx ] = Clip1( val )
                }
            } else {
                for ( idx = 0; idx < PaletteSizeUV; idx++ ) {
                    palette_colors_v[ idx ]                                  L(BitDepth)
                }
            }
        }
    }
}

where the function get_palette_cache, which merges the above and left palettes to form a cache, is specified as follows:

get_palette_cache( plane ) {
    aboveN = 0
    if ( ( ( MiRow * MI_SIZE ) % 64 ) && AvailU ) {
        aboveN = PaletteSizes[ plane ][ MiRow - 1 ][ MiCol ]
    }
    leftN = 0
    if ( AvailL ) {
        leftN = PaletteSizes[ plane ][ MiRow ][ MiCol - 1 ]
    }
    aboveIdx = 0
    leftIdx = 0
    n = 0
    while ( aboveIdx < aboveN  && leftIdx < leftN ) {
        aboveC = PaletteColors[ plane ][ MiRow - 1 ][ MiCol ][ aboveIdx ]
        leftC = PaletteColors[ plane ][ MiRow ][ MiCol - 1 ][ leftIdx ]
        if ( leftC < aboveC ) {
            if ( n == 0 || leftC != PaletteCache[ n - 1 ] ) {
                PaletteCache[ n ] = leftC
                n++
            }
            leftIdx++
        } else {
            if ( n == 0 || aboveC != PaletteCache[ n - 1 ] ) {
                PaletteCache[ n ] = aboveC
                n++
            }
            aboveIdx++
            if ( leftC == aboveC ) {
                leftIdx++
            }
        }
    }
    while ( aboveIdx < aboveN ) {
        val = PaletteColors[ plane ][ MiRow - 1 ][ MiCol ][ aboveIdx ]
        aboveIdx++
        if ( n == 0 || val != PaletteCache[ n - 1 ] ) {
            PaletteCache[ n ] = val
            n++
        }
    }
    while ( leftIdx < leftN ) {
        val = PaletteColors[ plane ][ MiRow ][ MiCol - 1 ][ leftIdx ]
        leftIdx++
        if ( n == 0 || val != PaletteCache[ n - 1 ] ) {
            PaletteCache[ n ] = val
            n++
        }
    }
    return n
}

The function sort( arr, i1, i2 ) sorts a subarray of the array arr in-place into ascending order. The subarray to be sorted is between indices i1 and i2 inclusive.

Transform Type Syntax

transform_type( ) {
    txSz = is_inter ? min_tx_size : tx_size
    setType = get_tx_set_type( txSz )

    if ( Num_Tx_Set[ setType ] > 1 &&
         ( segmentation_enabled ? get_qindex( 1 ) : base_q_idx ) > 0 &&
         !skip &&
         !seg_feature_active( SEG_LVL_SKIP ) ) {
        if ( is_inter ) {
            set = Tx_Set_Index_Inter[ setType ]
            if ( set > 0 ) {
                inter_tx_type                                                S
                TxType = inter_tx_type
            }
        } else {
            set = Tx_Set_Index_Intra[ setType ]
            if ( set > 0 ) {
                intra_tx_type                                                S
                TxType = intra_tx_type
            }
        }
    } else {
        TxType = DCT_DCT
    }
}

Get Transform Set Type Function

get_tx_set_type( txSz ) {
    txSzSqr = Tx_Size_Sqr[ txSz ]
    txSzSqrUp = Tx_Size_Sqr_Up[ txSz ]
    if ( txSzSqr > TX_32X32 )
        return TX_SET_DCTONLY
    if ( reduced_tx_set )
        return is_inter ? TX_SET_DCT_IDTX : TX_SET_DTT4_IDTX
    if ( txSzSqrUp == TX_32X32 )
        return is_inter ? TX_SET_DCT_IDTX : TX_SET_DCTONLY
    if (is_inter)
        return txSzSqr == TX_16X16 ? TX_SET_DTT9_IDTX_1DDCT : TX_SET_ALL16
    else
        return txSzSqr == TX_16X16 ? TX_SET_DTT4_IDTX : TX_SET_DTT4_IDTX_1DDCT
}

Palette Tokens Syntax

palette_tokens( ) {
    blockHeight = Block_Height[ MiSize ]
    blockWidth = Block_Width[ MiSize ]
    onscreenHeight = Min( blockHeight, (MiRows - MiRow) * MI_SIZE )
    onscreenWidth = Min( blockWidth, (MiCols - MiCol) * MI_SIZE )

    if ( PaletteSizeY ) {
        color_index_map_y                                                    U(PaletteSizeY)
        ColorMapY[0][0] = color_index_map_y
        for ( i = 1; i < onscreenHeight + onscreenWidth - 1; i++ ) {
            for ( j = Min( i, onscreenWidth - 1 ); j >= Max( 0, i - onscreenHeight + 1 ); j-- ) {
                get_palette_color_context( ColorMapY, ( i - j ), j, PaletteSizeY )
                palette_color_idx_y                                   S
                ColorMapY[ i - j ][ j ] = ColorOrder[ palette_color_idx_y ]
            }
        }
        for ( i = 0; i < onscreenHeight; i++ ) {
            for ( j = onscreenWidth; j < blockWidth; j++ ) {
                ColorMapY[ i ][ j ] = ColorMapY[ i ][ onscreenWidth - 1 ]
            }
        }
        for ( i = onscreenHeight; i < blockHeight; i++ ) {
            for ( j = 0; j < blockWidth; j++ ) {
                ColorMapY[ i ][ j ] = ColorMapY[ onscreenHeight - 1 ][ j ]
            }
        }
    }

    if ( PaletteSizeUV ) {
        color_index_map_uv                                                   U(PaletteSizeUV)
        ColorMapUV[0][0] = color_index_map_uv
        blockHeight = blockHeight >> subsampling_y
        blockWidth = blockWidth >> subsampling_x
        onscreenHeight = onscreenHeight >> subsampling_y
        onscreenWidth = onscreenWidth >> subsampling_x

        for ( i = 1; i < onscreenHeight + onscreenWidth - 1; i++ ) {
            for ( j = Min( i, onscreenWidth - 1 ); j >= Max( 0, i - onscreenHeight + 1 ); j-- ) {
                get_palette_color_context( ColorMapUV, ( i - j ), j, PaletteSizeUV )
                palette_color_idx_uv                                  S
                ColorMapUV[ i - j ][ j ] = ColorOrder[ palette_color_idx_uv ]
            }
        }
        for ( i = 0; i < onscreenHeight; i++ ) {
            for ( j = onscreenWidth; j < blockWidth; j++ ) {
                ColorMapUV[ i ][ j ] = ColorMapUV[ i ][ onscreenWidth - 1 ]
            }
        }
        for ( i = onscreenHeight; i < blockHeight; i++ ) {
            for ( j = 0; j < blockWidth; j++ ) {
                ColorMapUV[ i ][ j ] = ColorMapUV[ onscreenHeight - 1 ][ j ]
            }
        }
    }
}

Palette Colors Syntax

get_palette_color_context( colorMap, r, c, n ) {
    for( i = 0; i < PALETTE_COLORS; i++ ) {
        scores[ i ] = 0
        ColorOrder[i] = i
    }
    if ( c > 0 ) {
        neighbor = colorMap[ r ][ c - 1 ]
        scores[ neighbor ] += 2
    }
    if ( ( r > 0 ) && ( c > 0 ) ) {
        neighbor = colorMap[ r - 1 ][ c - 1 ]
        scores[ neighbor ] += 1
    }
    if ( r > 0 ) {
        neighbor = colorMap[ r - 1 ][ c ]
        scores[ neighbor ] += 2
    }
    for ( i = 0; i < PALETTE_NUM_NEIGHBORS; i++ ) {
        maxScore = scores[ i ]
        maxIdx = i
        for ( j = i + 1; j < n; j++ ) {
            if (scores[ j ] > maxScore) {
                maxScore = scores[ j ]
                maxIdx = j
            }
        }
        if ( maxIdx != i ) {
            maxScore = scores[ maxIdx ]
            maxColorOrder = ColorOrder[ maxIdx ]
            for ( k = maxIdx; k > i; k-- ) {
                scores[ k ] = scores[ k - 1 ]
                ColorOrder[ k ] = ColorOrder[ k - 1 ]
            }
            scores[ i ] = maxScore
            ColorOrder[ i ] = maxColorOrder
        }
    }
    ColorContextHash = 0
    for( i = 0; i < PALETTE_NUM_NEIGHBORS; i++ ) {
        ColorContextHash += scores[ i ] * Palette_Color_Hash_Multipliers[ i ]
    }
}

Is Inside Function

is_inside determines whether a candidate position is accessible for motion vector prediction. Moving across the top tile edge is allowed when dependent_tiles is equal to 1 and the tile above is in the same tile group, but moving across the other tile edges is always prohibited.

In addition, if the dependency would result in having to decode too large an area, the AllowDependentTileRow array is used to break the horizontal dependency.

is_inside( candidateR, candidateC ) {
    if (candidateC >= MiColStart &&
        candidateC < MiColEnd &&
        candidateR < MiRowEnd) {
        if (candidateR >= MiRowStart)
            return 1
        if (dependent_tiles && AboveSameTileGroup) {
            return 1
        }
    }
    return 0
}

Check References Functions

This section defines some simple helper functions used in other parts of the specification:

check_forward(refFrame) {
  return ( (refFrame >= LAST_FRAME) && (refFrame <= GOLDEN_FRAME) )
} 

check_backward(refFrame) {
  return ( (refFrame >= BWDREF_FRAME) && (refFrame <= ALTREF_FRAME) )
} 

check_last_or_last2(refFrame) {
  return ( (refFrame == LAST_FRAME) || (refFrame == LAST2_FRAME) )
}

check_golden_or_last3(refFrame) {
  return ( (refFrame == GOLDEN_FRAME) || (refFrame == LAST3_FRAME) )
}

check_last(refFrame) {
  return (refFrame == LAST_FRAME)
}

check_last2(refFrame) {
  return (refFrame == LAST2_FRAME)
}

check_last3(refFrame) {
  return (refFrame == LAST3_FRAME)
}

check_golden(refFrame) {
  return (refFrame == GOLDEN_FRAME)
}

Clamp MV Row Function

clamp_mv_row( mvec, border ) {
    bh4 = Num_4x4_Blocks_High[ MiSize ]
    mbToTopEdge = -((MiRow * MI_SIZE) * 8)
    mbToBottomEdge = ((MiRows - bh4 - MiRow) * MI_SIZE) * 8
    return Clip3( mbToTopEdge - border, mbToBottomEdge + border, mvec )
}

Clamp MV Col Function

clamp_mv_col( mvec, border ) {
    bw4 = Num_4x4_Blocks_Wide[ MiSize ]
    mbToLeftEdge = -((MiCol * MI_SIZE) * 8)
    mbToRightEdge = ((MiCols - bw4 - MiCol) * MI_SIZE) * 8
    return Clip3( mbToLeftEdge - border, mbToRightEdge + border, mvec )
}

Decode CDEF Syntax

decode_cdef( r, c, bSize ) {
    if ( !AllLossless ) {
        step4 = Num_4x4_Blocks_Wide[BLOCK_64X64]
        w4 = Num_4x4_Blocks_Wide[bSize]
        h4 = Num_4x4_Blocks_High[bSize]
        for (i = r; i < Min( MiRows, r + h4 ); i += step4) {
            for (j = c; j < Min( MiCols, j + w4 ); j += step4) {
                if (sb_all_skip(i, j, step4))
                    cdef_idx[ i ][ j ] = -1
                else
                    cdef_idx[ i ][ j ]                                       S
            }
        }
    }
}

where sb_all_skip checks if all blocks are skipped and is defined as:

sb_all_skip( miRow, miCol, step4 ) {
    for( r = miRow; r < Min( MiRows, miRow + step4 ); r++ ) {
        for( c = miCol; c < Min( MiCols, miCol + step4 ); c++ ) {
            if (!SkipCoeffs[ r ][ c ])
                return 0
        }
    }
    return 1
}

Bitstream Semantics

This section specifies the meaning of the syntax elements read in the syntax structures.

OBU Semantics

The bitstream consists of a sequence of open bitstream units (OBUs).

Each OBU is given to the decoding process in turn as a bitstream along with a variable sz that gives the total number of bytes in the OBU.

OBUs must begin at a byte boundary.

Methods of framing the OBUs in a container format are outside the scope of this Specification. However, one simple method of packing OBUs is described in Annex B.

OBU Header Semantics

OBUs are structured with a header and a payload. The header identifies the type of the payload using the obu_type header parameter.

obu_forbidden_bit must be set to 0.

Note: This ensures that MPEG2 transport is possible by preventing emulation of MPEG2 transport stream ids.

obu_type specifies the type of data structure contained in the OBU payload:

obu_type Name of obu_type
0 Reserved
1 OBU_SEQUENCE_HEADER
2 OBU_TD
3 OBU_FRAME_HEADER
4 OBU_TILE_GROUP
5 OBU_METADATA
6-14 Reserved
15 OBU_PADDING

Reserved units are for future use and shall be ignored by AV1 decoder.

obu_reserved_2bits must be set to 0. The value is ignored by a decoder.

obu_extension_flag indicates if the optional obu_extension_header is present.

OBU Extension Header Semantics

temporal_id specifies the temporal level of the coded picture.

spatial_id specifies the spatial level of the coded picture.

Note: Spatial scalability here is assumed to mean that the reference pictures, if any, are from the same temporal unit and have a different spatial resolution.

quality_id specifies the quality level of the coded picture.

Note: Quality scalability here is assumed to mean that the reference pictures, if any, are from the same temporal unit and have the exact same spatial resolution.

reserved_flag must be set to 0. The value is ignored by a decoder.

Trailing Bits Semantics

zero_bit shall be equal to 0 and is inserted into the bitstream to align the bit position to a multiple of 8 bits.

Reserved OBU Semantics

The reserved OBU allows the extension of this specification with additional OBU types in a way that allows older decoders to ignore them.

reserved_obu_payload_byte is a payload byte of the reserved OBU.

Sequence Header OBU Semantics

profile_low_bit and profile_high_bit combine to make the variable Profile. AV1 supports 4 profiles:

Profile Bit depth SRGB Colorspace support Chroma subsampling
0 8 No YUV 4:2:0
1 8 Yes YUV 4:2:2, YUV 4:4:0 or YUV 4:4:4
2 10 or 12 No YUV 4:2:0
3 10 or 12 Yes YUV 4:2:2, YUV 4:4:0 or YUV 4:4:4

reserved_zero shall be equal to 0.

level specifies the level for the coded video sequence.

frame_width_bits_minus_1 specifies the number of bits minus 1 used for transmitting the frame width syntax elements.

frame_height_bits_minus_1 specifies the number of bits minus 1 used for transmitting the frame height syntax elements.

max_frame_width_minus_1 specifies the maximum frame width minus 1 for the frames represented by this sequence header.

max_frame_height_minus_1 specifies the maximum frame height minus 1 for the frames represented by this sequence header.

frame_id_numbers_present_flag specifies whether frame id numbers are present in the bitstream.

Note: Frame id numbers are not needed by the decoding process, but allow decoders to spot when frames have been missed and take an appropriate action.

frame_id_length_minus7 specifies the number of bits minus 7 used to encode the frame_id syntax element.

delta_frame_id_length_minus2 specifies the number of bits minus 2 used to encode delta_frame_id syntax elements.

Color Config Semantics

ten_or_twelve_bit equal to 1 indicates the bit depth is 12 bits; ten_or_twelve_bit equal to 0 indicates that the bit depth is 10 bits.

color_space specifies the color space of the stream:

color_space Name of color space Description
0 CS_UNKNOWN Unknown (in this case the color space must be signaled outside the AV1 bitstream).
1 CS_BT_601 Rec. ITU-R BT.601-7
2 CS_BT_709 Rec. ITU-R BT.709-6
3 CS_SMPTE_170 SMPTE-170
4 CS_SMPTE_240 SMPTE-240
5 CS_BT_2020_NCL Rec. ITU-R BT.2020-2 (nonconstant luminance)
6 CS_BT_2020_CL Rec. ITU-R BT.2020-2 (constant luminance)
7 CS_ICTCP Rec. ITU-R BT.2100-0
8 CS_SRGB sRGB (IEC 61966-2-1)
9..31 CS_RESERVED Reserved

It is a requirement of bitstream conformance that color_space is not equal to CS_SRGB when profile_low_bit is equal to 0.

transfer_function specifies specifies opto-electronic characteristics of the source video:

transfer_function Name of transfer function Description
0 TF_UNKNOWN Unknown (in this case the source video transfer function must be signaled outside the AV1 bitstream).
1 TF_BT_709 Rec. ITU-R BT.709-6, Rec. ITU-R BT.601-7 525 or 625, Rec. ITU-R BT.2020
2 TF_PQ SMPTE ST 2084:2014 / BT.2100 PQ
3 TF_HLG BT.2100 Hybrid Log-Gamma (HLG)
4..31 TF_RESERVED  

color_range specifies the black level and range of the luma and chroma signals as specified in Rec. ITU-R BT.709-6 and Rec. ITU-R BT.2020-2:

color_range Description Details
0 Studio swing For BitDepth equals 8:
Y is between 16 and 235 inclusive.
U and V are between 16 and 240 inclusive.
    For BitDepth equals 10:
Y is between 64 and 940 inclusive.
U and V are between 64 and 960 inclusive.
    For BitDepth equals 12:
Y is between 256 and 3760.
U and V are between 256 and 3840 inclusive.
1 Full swing No restriction on Y, U, V values.

Note: Note that this specification does not enforce the range of YUV values when the YUV range is signaled as Studio swing. Therefore the application should perform additional clamping and color conversion operations according to the specified range.

subsampling_x, subsampling_y specify the chroma subsampling format:

subsampling_x subsampling_y Description
0 0 YUV 4:4:4
0 1 YUV 4:4:0
1 0 YUV 4:2:2
1 1 YUV 4:2:0

It is a requirement of bitstream conformance that either subsampling_x is equal to 0 or subsampling_y is equal to 0 when profile_low_bit is equal to 1.

Note: In Chroma subsampling format 4:2:2, AV1 assumes that chroma samples are co-located with luma samples if there is no explicit signaling outside of the AV1 bitstream. When there is explicit signaling at the container level, the signaled information overrides AV1’s default assumption.

reserved_zero shall be equal to 0.

chroma_sample_position specifies the sample position for 4:2:0 streams:

chroma_sample_position Name of chroma sample position Description
0 CSP_UNKNOWN Unknown (in this case the source video transfer function must be signaled outside the AV1 bitstream)
1 CSP_VERTICAL Horizontally co-located with (0, 0) luma sample, vertical position in the middle between two luma samples
2 CSP_COLOCATED co-located with (0, 0) luma sample
3 CSP_RESERVED  

Temporal Delimiter OBU Semantics

SeenFrameHeader is a variable used to mark whether we have received the frame header for the current frame.

Padding OBU Semantics

The padding OBU offers padding from 1 to 256 bytes. Multiple padding units can be present, each padding with an arbitrary number of bytes.

obu_padding_length indicates the length of the remaining payload in bytes.

obu_padding_byte is a padding bytes. Padding bytes may have arbitrary values and have no effect on the decoding process.

Metadata OBU Semantics

metadata_type indicates the type of metadata:

metadata_type Name of metadata_type
0 METADATA_TYPE_PRIVATE_DATA
1 METADATA_TYPE_HDR_CLL
2 METADATA_TYPE_HDR_MDCV
3-65535 Reserved

Metadata Private Data Semantics

Private data allows the transfer of arbitrary, application-specific binary information.

metadata_private_data_payload_byte[ i ] carries the payload of the private data. Private data may have arbitrary values and have no effect on the decoding process.

Metadata High Dynamic Range Content Light Level Semantics

max_cll specifies the maximum content light level as specified in CEA-861.3, Appendix A.

max_fall specifies the maximum frame-average light level as specified in CEA-861.3, Appendix A.

Metadata High Dynamic Range Mastering Display Color Volume Semantics

primary_chromaticity_x[ i ] specifies a 0.16 fixed-point X chromaticity coordinate as defined by CIE 1931, where i = 0,1,2 specifies Red, Green, Blue respectively.

primary_chromaticity_y[ i ] specifies a 0.16 fixed-point Y chromaticity coordinate as defined by CIE 1931, where i = 0,1,2 specifies Red, Green, Blue respectively.

white_point_chromaticity_x[ i ] specifies a 0.16 fixed-point white X chromaticity coordinate as defined by CIE 1931.

white_point_chromaticity_y[ i ] specifies a 0.16 fixed-point white Y chromaticity coordinate as defined by CIE 1931.

luminance_max is a 24.8 fixed-point maximum luminance, represented in candelas per square meter.

luminance_min is a 18.14 fixed-point minimum luminance, represented in candelas per square meter.

Frame Header OBU Semantics

It is a requirement of bitstream conformance that a sequence header OBU has been received before a frame header OBU.

frame_header_copy is a function call that indicates that a copy of the previous frame_header_obu should be inserted at this point.

Note: Bitstreams may contain several copies of the frame_header_obu interspersed with tile_group_obu to allow for greater error resilience. However, all copies must contain identical contents.

load_cdfs( ctx ) is a function call that indicates that the CDF tables are loaded from frame context number ctx in the range 0 to (FRAME_CONTEXTS - 1). When this function is invoked, a copy of each CDF array mentioned in the semantics for setup_past_independence is loaded from an area of memory indexed by ctx. (The memory contents of these frame contexts have been initialized by previous calls to save_cdfs). Once the CDF arrays have been loaded, the last entry in each array is set to 0.

Note: The last entry in each CDF array is used to keep track of how many times the CDF has been used within the current tile. This allows the CDF to adapt faster at the start of each tile.

TileNum is a variable giving the index (zero-based) of the current tile.

MaxTileSize is a variable that tracks the largest size in bytes of each tile. (This is needed because the CDFs are updated based on the largest tile decoded.)

decode_frame is a function call that indicates that the decode frame process specified in section 7.2 should be invoked.

Uncompressed Header Semantics

show_existing_frame equal to 1, indicates the frame indexed by frame_to_show_map_idx is to be displayed; show_existing_frame equal to 0 indicates that further processing is required.

frame_to_show_map_idx specifies the frame to be displayed. It is only available if show_existing_frame is 1.

display_frame_id provides the frame number for the frame to display. It is a requirement of bitstream conformance that whenever display_frame_id is read, the value matches the value of current_frame_id at the time that the frame indexed by frame_to_show_map_idx was stored.

frame_type specifies the type of the frame:

frame_type Name of frame_type
0 KEY_FRAME
1 INTER_FRAME
2 INTRA_ONLY_FRAME
3 SWITCH_FRAME

It is possible for bitstreams to start with a non key frame and still be decodable. In this case there are a number of additional constraints on the bitstream that are detailed in section 7.3.

show_frame equal to 1 specifies that this frame should be immediately output once decoded. show_frame equal to 0 specifies that this frame should not be immediately output. (It may be output later if a later uncompressed header uses show_existing_frame equal to 1).

error_resilient_mode equal to 1 indicates that error resilient mode is enabled; error_resilient_mode equal to 0 indicates that error resilient mode is disabled.

Note: Error resilient mode allows the syntax of a frame to be decoded independently of previous frames.

current_frame_id specifies the frame number for the current frame. Frame numbers are additional information that do not affect the decoding process, but provide decoders with a way of detecting missing reference frames so that appropriate action can be taken.

frame_size_override_flag equal to 1 specifies that the frame size will be contained in the bitstream. frame_size_override_flag equal to 0 specifies that the frame size is equal to the size in the sequence header.

use_128x128_superblock, when equal to 1, indicates that superblocks are 128x128 pixels. When equal to 0, it indicates that superblocks are 64x64 pixels.

allow_screen_content_tools equal to 1 indicates that intra blocks may use palette encoding; allow_screen_content_tools equal to 0 indicates that palette encoding is never used.

intra_reset_all equal to 1 indicates that all contexts should be reset; intra_reset_all equal to 0 indicates that only the context in the frame header should be reset.

reset_frame_context specifies whether the frame contexts are reset to default values:

  • 0 means do not reset any frame context
  • 1 resets just the context specified in the frame header
  • 2 resets all contexts.

refresh_frame_flags contains a bitmask that specifies which reference frame slots will be updated with the current frame after it is decoded.

See section 7.13 for details of the frame update process.

ref_frame_idx specifies which reference frames are used by inter frames. It is a requirement of bitstream conformance that the selected reference frames match the current frame in bit depth, profile, chroma subsampling, and color space.

ref_frame_sign_bias specifies the intended direction of the motion vector in time for each reference frame. A sign bias equal to 0 indicates that the reference frame is a backwards reference; a sign bias equal to 1 indicates that the reference frame is a forwards reference.

Note: The sign bias is just an indication that can improve the accuracy of motion vector prediction and is not constrained to reflect the actual output order of pictures.

delta_frame_id_minus1 is used to calculate DeltaFrameId.

DeltaFrameId specifies the distance to the frame id for the reference frame.

RefFrameId specifies the frame id for the reference frame. It is a requirement of bitstream conformance that whenever RefFrameId is calculated, the value matches the value of current_frame_id at the time that the frame indexed by ref_frame_idx was stored.

allow_high_precision_mv equal to 0 specifies that motion vectors are specified to quarter pel precision; allow_high_precision_mv equal to 1 specifies that motion vectors are specified to eighth pel precision.

can_use_previous equal to 1 specifies that information (motion vectors and global motion settings) from a previous frame can be used when decoding the current frame. can_use_previous equal to 0 specifies that this information will not be used.

frame_parallel_decoding_mode equal to 1 indicates that parallel decoding mode is enabled; frame_parallel_decoding_mode equal to 0 indicates that parallel decoding mode is disabled.

Note: Parallel decoding mode means that the CDFs in the frame context are not updated at the end of the frame. This means that the next frame can start to be decoded as soon as the frame headers of the current frame have been processed.

frame_offset_update specifies how many frames later this frame will be shown.

DecodeOrder specifies the offset of when this frame will be shown relative to the last key frame.

DecodeOrders specifies the decode order for each reference frame.

CurrentVideoFrame counts the number of frames that have been shown since the last key frame. This variable should be initialized to zero in case the sequence starts with an intra only frame.

Note: The starting value of CurrentVideoFrame is unimportant because the decoding process only depends on the relative value between values of DecodeOrder.

frame_context_idx indicates the frame context to use.

AllLossless is a variable that is equal to 1 when all segments use lossless encoding.

reduced_tx_set equal to 1 specifies that the frame is restricted to a reduced subset of the full set of transform types.

setup_past_independence is a function call that indicates that this frame can be decoded without dependence on previous coded frames. When this function is invoked the following takes place:

  • FeatureData[ i ][ j ] and FeatureEnabled[ i ][ j ] are set equal to 0 for i = 0..7 and j = 0..3.

  • segmentation_abs_or_delta_update is set equal to 0.

  • PrevSegmentIds[ row ][ col ] is set equal to 0 for row = 0..MiRows-1 and col = 0..MiCols-1.

  • loop_filter_delta_enabled is set equal to 1.

  • loop_filter_ref_deltas[ INTRA_FRAME ] is set equal to 1.

  • loop_filter_ref_deltas[ LAST_FRAME ] is set equal to 0.

  • loop_filter_ref_deltas[ LAST2_FRAME ] is set equal to 0.

  • loop_filter_ref_deltas[ LAST3_FRAME ] is set equal to 0.

  • loop_filter_ref_deltas[ BWDREF_FRAME ] is set equal to 0.

  • loop_filter_ref_deltas[ GOLDEN_FRAME ] is set equal to -1.

  • loop_filter_ref_deltas[ ALTREF_FRAME ] is set equal to -1.

  • loop_filter_ref_deltas[ ALTREF2_FRAME ] is set equal to -1.

  • loop_filter_mode_deltas[ i ] is set equal to 0 for i = 0..1.

  • The cumulative distribution function arrays are reset to default values as follows:

    • YModeCdf is set to a copy of Default_Y_Mode_Cdf

    • UVModeCdf is set to a copy of Default_Uv_Mode_Cdf

    • PartitionW8Cdf is set to a copy of Default_Partition_W8_Cdf

    • PartitionCdf is set to a copy of Default_Partition_Cdf

    • SegmentIdCdf is set to a copy of Default_Segment_Id_Cdf

    • SegmentIdPredictedCdf is set to a copy of Default_Segment_Id_Predicted_Cdf

    • Tx8x8Cdf is set to a copy of Default_Tx_8x8_Cdf

    • Tx16x16Cdf is set to a copy of Default_Tx_16x16_Cdf

    • Tx32x32Cdf is set to a copy of Default_Tx_32x32_Cdf

    • TxfmSplitCdf is set to a copy of Default_Txfm_Split_Cdf

    • InterpFilterCdf is set to a copy of Default_Interp_Filter_Cdf

    • MotionModeCdf is set to a copy of Default_Motion_Mode_Cdf

    • NewMvCdf is set to a copy of Default_New_Mv_Cdf

    • ZeroMvCdf is set to a copy of Default_Zero_Mv_Cdf

    • RefMvCdf is set to a copy of Default_Ref_Mv_Cdf

    • CompoundModeCdf is set to a copy of Default_Compound_Mode_Cdf

    • DrlModeCdf is set to a copy of Default_Drl_Mode_Cdf

    • IsInterCdf is set to a copy of Default_Is_Inter_Cdf

    • CompModeCdf is set to a copy of Default_Comp_Mode_Cdf

    • SkipCdf is set to a copy of Default_Skip_Cdf

    • CompRefCdf is set to a copy of Default_Comp_Ref_Cdf

    • CompBwdRefCdf is set to a copy of Default_Comp_Bwd_Ref_Cdf

    • SingleRefCdf is set to a copy of Default_Single_Ref_Cdf

    • MvJointCdf[ i ] is set to a copy of Default_Mv_Joint_Cdf for i = 0..MV_CONTEXTS

    • MvClassCdf[ i ] is set to a copy of Default_Mv_Class_Cdf for i = 0..MV_CONTEXTS

    • MvClass0BitCdf is set to a copy of Default_Mv_Class0_Bit_Cdf

    • MvFrCdf[ i ] is set to a copy of Default_Mv_Fr_Cdf for i = 0..MV_CONTEXTS

    • MvClass0FrCdf[ i ] is set to a copy of Default_Mv_Class0_Fr_Cdf for i = 0..MV_CONTEXTS

    • MvClass0HpCdf is set to a copy of Default_Mv_Class0_Hp_Cdf

    • MvBitCdf is set to a copy of Default_Mv_Bit_Cdf

    • MvHpCdf is set to a copy of Default_Mv_Hp_Cdf

    • TailTokenCdf is set to a copy of Default_Tail_Token_Cdf

    • AcHeadTokenCdf is set to a copy of Default_Ac_Head_Token_Cdf

    • DcHeadTokenCdf is set to a copy of Default_Dc_Head_Token_Cdf

    • PaletteYModeCdf is set to a copy of Default_Palette_Y_Mode_Cdf

    • PaletteUVModeCdf is set to a copy of Default_Palette_Uv_Mode_Cdf

    • PaletteYSizeCdf is set to a copy of Default_Palette_Y_Size_Cdf

    • PaletteUVSizeCdf is set to a copy of Default_Palette_Uv_Size_Cdf

    • PaletteSize2YColorCdf is set to a copy of Default_Palette_Size_2_Y_Color_Cdf

    • PaletteSize2UVColorCdf is set to a copy of Default_Palette_Size_2_Uv_Color_Cdf

    • PaletteSize3YColorCdf is set to a copy of Default_Palette_Size_3_Y_Color_Cdf

    • PaletteSize3UVColorCdf is set to a copy of Default_Palette_Size_3_Uv_Color_Cdf

    • PaletteSize4YColorCdf is set to a copy of Default_Palette_Size_4_Y_Color_Cdf

    • PaletteSize4UVColorCdf is set to a copy of Default_Palette_Size_4_Uv_Color_Cdf

    • PaletteSize5YColorCdf is set to a copy of Default_Palette_Size_5_Y_Color_Cdf

    • PaletteSize5UVColorCdf is set to a copy of Default_Palette_Size_5_Uv_Color_Cdf

    • PaletteSize6YColorCdf is set to a copy of Default_Palette_Size_6_Y_Color_Cdf

    • PaletteSize6UVColorCdf is set to a copy of Default_Palette_Size_6_Uv_Color_Cdf

    • PaletteSize7YColorCdf is set to a copy of Default_Palette_Size_7_Y_Color_Cdf

    • PaletteSize7UVColorCdf is set to a copy of Default_Palette_Size_7_Uv_Color_Cdf

    • PaletteSize8YColorCdf is set to a copy of Default_Palette_Size_8_Y_Color_Cdf

    • PaletteSize8UVColorCdf is set to a copy of Default_Palette_Size_8_Uv_Color_Cdf

    • DeltaQCdf is set to a copy of Default_Delta_Q_Cdf

    • DeltaLFCdf is set to a copy of Default_Delta_Lf_Cdf

    • DeltaLFMultiCdf[ i ] is set to a copy of Default_Delta_Lf_Cdf for i = 0..FRAME_LF_COUNT-1

    • IntraTxTypeSet1Cdf is set to a copy of Default_Intra_Tx_Type_Set1_Cdf

    • IntraTxTypeSet2Cdf is set to a copy of Default_Intra_Tx_Type_Set2_Cdf

    • InterTxTypeSet1Cdf is set to a copy of Default_Inter_Tx_Type_Set1_Cdf

    • InterTxTypeSet2Cdf is set to a copy of Default_Inter_Tx_Type_Set2_Cdf

    • InterTxTypeSet3Cdf is set to a copy of Default_Inter_Tx_Type_Set3_Cdf

    • UseObmcCdf is set to a copy of Default_Use_Obmc_Cdf

    • InterIntraCdf is set to a copy of Default_Inter_Intra_Cdf

    • CompRefTypeCdf is set to a copy of Default_Comp_Ref_Type_Cdf

    • CflSignCdf is set to a copy of Default_Cfl_Sign_Cdf

    • UniCompRefCdf is set to a copy of Default_Uni_Comp_Ref_Cdf

    • WedgeInterIntraCdf is set to a copy of Default_Wedge_Inter_Intra_Cdf

    • CompoundTypeCdf is set to a copy of Default_Compound_Type_Cdf

    • InterIntraModeCdf is set to a copy of Default_Inter_Intra_Mode_Cdf

    • CflAlphaCdf is set to a copy of Default_Cfl_Alpha_Cdf

save_cdfs( ctx ) is a function call that indicates that indicates that all the CDF arrays are saved into frame context number ctx in the range 0 to (FRAME_CONTEXTS - 1). When this function is invoked the following takes place:

A copy of each CDF array mentioned in the semantics for setup_past_independence is saved in an area of memory indexed by ctx. The memory contents of these frame contexts are persistent in order to allow a subsequent inter frame to reload the CDF tables.

load_previous( ) is a function call that indicates that information from the previous frame should be loaded for use in decoding the current frame. When this function is invoked the following ordered steps apply:

  1. The variable prevFrame is set equal to ref_frame_idx[ 0 ].

  2. gm_params is set equal to SavedGmParams[ prevFrame ].

  3. The motion field estimation process in section 7.5 is invoked.

It is a requirement of bitstream conformance that prevFrame refers to a frame of the same width and height as the current frame, and that it was of type INTER_FRAME or SWITCH_FRAME. In other words, when this function is invoked, all of the following must be true:

  • RefFrameWidth[ prevFrame ] is equal to FrameWidth.

  • RefFrameHeight[ prevFrame ] is equal to FrameHeight.

  • RefFrameType[ prevFrame ] is equal to INTER_FRAME or is equal to SWITCH_FRAME.

Note: These requirements can always be satisfied when encoding a sequence by setting can_use_previous to zero if any of the conditions would fail.

Frame Size Semantics

frame_width_minus_1 plus one is the width of the frame in pixels.

frame_height_minus_1 plus one is the height of the frame in pixels.

It is a requirement of bitstream conformance that frame_width_minus_1 is less than or equal to max_frame_width_minus_1.

It is a requirement of bitstream conformance that frame_height_minus_1 is less than or equal to max_frame_height_minus_1.

Render Size Semantics

The render size is provided as a hint to the application about the desired display size. It has no effect on the decoding process.

render_and_frame_size_different equal to 0 means that the render width and height are inferred from the frame width and height. render_and_frame_size_different equal to 1 means that the render width and height are explicitly coded in the bitstream.

Note: It is legal for the bitstream to explicitly code the render dimensions in the bitstream even if they are an exact match for the frame dimensions.

render_width_minus_1 plus one is the render width of the frame in pixels.

render_height_minus_1 plus one is the render height of the frame in pixels.

Frame Size with Refs Semantics

For inter frames, the frame size is either set equal to the size of a reference frame, or can be sent explicitly.

found_ref equal to 1 indicates that the frame dimensions can be inferred from reference frame i where i is the loop counter in the syntax parsing process for frame_size_with_refs. found_ref equal to 0 indicates that the frame dimensions are not inferred from reference frame i.

Once the FrameWidth and FrameHeight have been computed for an inter frame, it is a requirement of bitstream conformance that for at least one value of i in the range 0..2, all the following conditions are true:

  • 2 * FrameWidth >= RefFrameWidth[ ref_frame_idx[ i ] ]
  • 2 * FrameHeight >= RefFrameHeight[ ref_frame_idx[ i ] ]
  • FrameWidth <= 16 * RefFrameWidth[ ref_frame_idx[ i ] ]
  • FrameHeight <= 16 * RefFrameHeight[ ref_frame_idx[ i ] ]

Note: This is a requirement even if all the blocks in an inter frame are coded using intra prediction.

Compute Image Size Semantics

When compute_image_size is invoked, if this is the first time compute_image_size is invoked, or if either FrameWidth or FrameHeight have changed in value compared to the previous time this function was invoked, then the segmentation map is cleared to all zeros by setting SegmentId[ row ][ col ] equal to 0 for row = 0..MiRows-1 and col = 0..MiCols-1.

Note: compute_image_size is not invoked and therefore segmentation map is not cleared when show_existing_frame is equal to 1 even if the shown frame has different dimensions.

Interpolation Filter Semantics

is_filter_switchable equal to 1 indicates that the filter selection is signaled at the block level; is_filter_switchable equal to 0 indicates that the filter selection is signaled at the frame level.

interpolation_filter specifies the filter selection used for performing inter prediction:

interpolation_filter Name of interpolation_filter
0 EIGHTTAP
1 EIGHTTAP_SMOOTH
2 EIGHTTAP_SHARP
3 BILINEAR
4 SWITCHABLE

Loop Filter Semantics

loop_filter_level is an array containing loop filter strength values. Different loop filter strength values from the array are used depending on the image plane being filtered, and the edge direction (vertical or horizontal) being filtered.

loop_filter_sharpness indicates the sharpness level. The loop_filter_level and loop_filter_sharpness together determine when a block edge is filtered, and by how much the filtering can change the sample values.

The loop filter process is described in section 7.9.

loop_filter_delta_enabled equal to 1 means that the filter level depends on the mode and reference frame used to predict a block. loop_filter_delta_enabled equal to 0 means that the filter level does not depend on the mode and reference frame.

loop_filter_delta_update equal to 1 means that the bitstream contains additional syntax elements that specify which mode and reference frame deltas are to be updated. loop_filter_delta_update equal to 0 means that these syntax elements are not present.

update_ref_delta equal to 1 means that the bitstream contains the syntax element loop_filter_ref_delta; update_ref_delta equal to 0 means that the bitstream does not contain this syntax element.

loop_filter_ref_deltas contains the adjustment needed for the filter level based on the chosen reference frame. If this syntax element is not present in the bitstream, it maintains its previous value.

update_mode_delta equal to 1 means that the bitstream contains the syntax element loop_filter_mode_deltas; update_mode_delta equal to 0 means that the bitstream does not contain this syntax element.

loop_filter_mode_deltas contains the adjustment needed for the filter level based on the chosen mode. If this syntax element is not present in the bitstream, it maintains its previous value.

Note: The previous values for loop_filter_mode_deltas and loop_filter_ref_deltas are intially set by the setup_past_independence function and can be subsequently modified by these syntax elements being coded in a previous frame.

Quantization Params Semantics

The residual is specified via decoded coefficients which are adjusted by one of four quantization parameters before the inverse transform is applied. The choice depends on the plane (Y or UV) and coefficient position (DC/AC coefficient). The Dequantization process is specified in section 7.7.

base_q_idx indicates the base frame qindex. This is used for Y AC coefficients and as the base value for the other quantizers.

deltaQYDc indicates the Y DC quantizer relative to base_q_idx.

deltaQUVDc indicates the UV DC quantizer relative to base_q_idx.

deltaQUVAc indicates the UV AC quantizer relative to base_q_idx.

using_qmatrix specifies that the quantizer matrix will be used to compute quantizers.

min_qmlevel specifies the smallest level in the quantizer matrix that may be used.

max_qmlevel specifies the largest level in the quantizer matrix that may be used.

Delta Quantizer Semantics

delta_coded specifies that the delta_q syntax element is present in the bitstream.

delta_q specifies an offset (relative to base_q_idx) for a particular quantization parameter.

Segmentation Params Semantics

AV1 provides a means of segmenting the image and then applying various adjustments at the segment level.

Up to 8 segments may be specified for any given frame. For each of these segments it is possible to specify:

  1. A quantizer (absolute value or delta).
  2. A loop filter strength (absolute value or delta).
  3. A prediction reference frame.
  4. A block skip mode that implies both the use of a (0,0) motion vector and that no residual will be coded.

Each of these data values for each segment may be individually updated at the frame level. Where a value is not updated in a given frame, the value from the previous frame persists. The exceptions to this are key frames, intra only frames or other frames where independence from past frame values is required (for example to enable error resilience). In such cases all values are reset as described in the semantics for setup_past_independence.

The segment affiliation (the segmentation map) is stored at the resolution of 4x4 blocks. If no explicit update is coded for a block’s segment affiliation, then it persists from frame to frame (until reset by a call to setup_past_independence).

segmentation_enabled equal to 1 indicates that this frame makes use of the segmentation tool; segmentation_enabled equal to 0 indicates that the frame does not use segmentation.

segmentation_update_map equal to 1 indicates that the segmentation map are updated during the decoding of this frame. segmentation_update_map equal to 0 means that the segmentation map from the previous frame is used.

segmentation_temporal_update equal to 1 indicates that the updates to the segmentation map are coded relative to the existing segmentation map. segmentation_temporal_update equal to 0 indicates that the new segmentation map is coded without reference to the existing segmentation map.

segmentation_update_data equal to 1 indicates that new parameters are about to be specified for each segment. segmentation_update_data equal to 0 indicates that the segmentation parameters should keep their existing values.

segmentation_abs_or_delta_update equal to 0 indicates that the segmentation parameters represent adjustments relative to the standard values. segmentation_abs_or_delta_update equal to 1 indicates that the segmentation parameters represent the actual values to be used.

feature_enabled equal to 0 indicates that the corresponding feature is unused and has value equal to 0. feature_enabled equal to 1 indicates that the feature value is coded in the bitstream.

feature_value specifies the magnitude of the feature data for a segment feature.

feature_sign equal to 1 indicates that the feature data is given by -feature_value. feature_sign equal to 0 indicates that the feature data is given by feature_value. It is a requirement of bitstream conformance that feature_sign is equal to 0 when segmentation_abs_or_delta_update is equal to 1.

Tile Info Semantics

uniform_tile_spacing_flag equal to 1 means that the tiles are uniformly spaced across the frame. (In other words, all tiles are the same size except for the ones at the right and bottom edge which can be smaller.) uniform_tile_spacing_flag equal to 0 means that the tile sizes are coded.

increment_tile_cols_log2 indicates whether the tile width is increased.

TileColsLog2 specifies the base 2 logarithm of the desired number of tiles across the frame.

TileCols specifies the number of tiles across the frame. It is a requirement of bitstream conformance that TileCols is less than or equal to MAX_TILE_COLS.

increment_tile_rows_log2 is used to compute TileRowsLog2.

TileRowsLog2 specifies the base 2 logarithm of the desired number of tiles down the frame.

Note: For small frame sizes the actual number of tiles in the frame may be smaller than the desired number because the tile size is rounded up to a multiple of the maximum superblock size.

TileRows specifies the number of tiles down the frame. It is a requirement of bitstream conformance that TileRows is less than or equal to MAX_TILE_ROWS.

sizeSb is used to specify the width/height of each tile in units of 128x128 pixels. It is a requirement of bitstream conformance that sizeSb is less than or equal to MAX_TILE_WIDTH_SB.

If uniform_tile_spacing_flag is equal to 0, it is a requirement of bitstream conformance that startSb is equal to MaxSbCols when the loop writing MiColStarts exits.

If uniform_tile_spacing_flag is equal to 0, it is a requirement of bitstream conformance that startSb is equal to MaxSbRows when the loop writing MiRowStarts exits.

Note: The requirements on startSb ensure that the sizes of each tile add up to the full size of the frame when measured in 128x128 units.

MiColStarts is an array specifying the start column (in units of 4x4 pixels) for each tile across the image.

MiRowStarts is an array specifying the start row (in units of 4x4 pixels) for each tile down the image.

maxTileHeightSb specifies the maximum height (in units of 128x128 pixels) that can be used for a tile (to avoid making tiles with too much area).

maxTileHeightMi contains the maximum height (in units of 4x4 pixels) that can be used for a tile.

AllowDependentTileRow is an array that specifies which tile rows are allowed to use syntax dependencies between tiles.

Note: The AllowDependentTileRow array ensures that the syntax decode can be split into independent units of a certain maximum size even when dependent_tiles is equal to 1.

dependent_tiles equal to 0 indicates that there are no syntax dependencies between tiles, dependent_tiles equal to 1 indicates that there can be dependencies between tiles.

Note: When dependent_tiles is equal to 1, the context determination, motion vector prediction, and intra prediction are allowed to depend on the tile above, but only if the tile above is in the same tile group.

loop_filter_across_tiles equal to 1 indicates that loop filtering is allowed across tile edges. loop_filter_across_tiles equal to 0 indicates that loop filtering is not allowed across tile edges (unless dependent_tiles is equal to 1, in which case loop filtering is allowed across tile edges for horizontal boundaries, but not across tile group edges).

tile_size_bytes_minus_1 is used to compute TileSizeBytes.

TileSizeBytes specifies the number of bytes needed to code each tile size.

Quantizer Index Delta Parameters Semantics

delta_q_present specifies whether quantizer index delta values are present in the bitstream.

delta_q_res specifies the left shift which should be applied to decoded quantizer index delta values.

Loop Filter Delta Parameters Semantics

delta_lf_present specifies whether loop filter delta values are present in the bitstream.

delta_lf_res specifies the left shift which should be applied to decoded loop filter delta values.

Global Motion Params Semantics

is_global specifies whether global motion parameters are present for a particular reference frame.

is_rot_zoom specifies whether a particular reference frame uses rotation and zoom global motion.

is_translation specifies whether a particular reference frame uses translation global motion.

Global Param Semantics

absBits is used to compute the range of values that can be used for this parameter. The values allowed are in the range -(1 « absBits) to (1 « absBits).

precBits specifies the number of fractional bits used for representing this parameter in the bitstream. All global motion parameters are stored in the model with WARPEDMODEL_PREC_BITS fractional bits, but the parameters are encoded with less precision in the bitstream.

Decode Subexp Semantics

subexp_more_bits equal to 0 specifies that the parameter is in the range mk to mk+a-1. subexp_more_bits equal to 0 specifies that the parameter is greater than mk+a-1.

subexp_bits specifies the value of the parameter minus mk.

Decode Uniform Semantics

v and extra_bit are used to compute the value of an unsigned number in the range 0 to n-1.

TX Mode Semantics

tx_mode specifies how the transform size is determined:

tx_mode Name of tx_mode
0 ONLY_4X4
1 ALLOW_8X8
2 ALLOW_16X16
3 ALLOW_32X32
4 TX_MODE_SELECT

For tx_mode not equal to 4, the inverse transform will use the largest transform size possible up to the limit set in tx_mode. For tx_mode equal to 4, the choice of size is specified explicitly for each block.

tx_mode_select equal to 1 indicates that the transform mode is specified within each mode info header. tx_mode_select equal to 0 indicates that the transform mode is computed based on the size of the block and the maximum transform size allowed by the frame header.

Frame Reference Mode Semantics

reference_select equal to 1 specifies that the mode info for inter blocks contains the syntax element comp_mode that indicates whether to use single or compound reference prediction. Reference_select equal to 0 specifies that all inter blocks will use single or compound reference prediction.

non_single_reference equal to 0 specifies that single reference prediction will be used. non_single_reference equal to 1 specifies that compound reference prediction will be used.

ReferenceMode is a variable that specifies the type of inter prediction to be used:

ReferenceMode Name of ReferenceMode
0 SINGLE_REFERENCE
1 COMPOUND_REFERENCE
2 REFERENCE_MODE_SELECT

SINGLE_REFERENCE indicates that all the inter blocks use only a single reference frame to generate motion compensated prediction.

COMPOUND_REFERENCE requires all the inter blocks to use compound mode. Single reference frame prediction is not allowed.

REFERENCE_MODE_SELECT allows each individual inter block to select between single and compound prediction modes.

allow_interintra_compound equal to 1 specifies that the mode info for inter blocks may contain the syntax element interintra. allow_interintra_compound equal to 0 specifies that the syntax element interintra will not be present in this frame.

allow_masked_compound equal to 1 specifies that the mode info for inter blocks may contain the syntax element compound_type. allow_masked_compound equal to 0 specifies that the syntax element compound_type will not be present in this frame.

Tile Group OBU Semantics

NumTiles specifies the total number of tiles in the frame.

tg_start specifies the zero-based index of the first tile in the current tile group.

It is a requirement of bitstream conformance that the value of tg_start is equal to the value of TileNum at the point that tile_group_header is invoked.

tg_end specifies the zero-based index of the last tile in the current tile group.

It is a requirement of bitstream conformance that the value of tg_end is greater than or equal to tg_start.

It is a requirement of bitstream conformance that the value of tg_end for the last tile group in each frame is equal to TileNum - 1.

Note: These requirements ensure that conceptually all tile groups are present and received in order for the purposes of specifying the decode process.

update_cdf is a function call that indicates that the CDF arrays are set equal to the final CDFs at the end of the largest tile (measured in bytes). This process is described in section 7.4.

tile_size specifies the size in bytes of the next coded tile.

Note: This size includes any padding bytes added by the exit process for the Boolean decoder. The size does not include the bytes used for tile_group_header, trailing_bits, and tile_size.

AboveSameTileGroup is a variable that specifies if the tile above can be used for dependencies, which is true if the tile is in the same tile group (and the current tile row is marked as allowing tile group dependencies).

decode_frame is a function call that indicates that the decode frame process specified in section 7.2 should be invoked.

Decode Tile Semantics

clear_left_context is a function call that indicates that some arrays used to determine the probabilities are zeroed. When this function is invoked the arrays LeftNonzeroContext and LeftSegPredContext are set equal to 0.

Note: LeftNonzeroContext[ plane ][ i ] and LeftSegPredContext[ i ] need to be set to 0 for i = 0..MiRows-1, for plane = 0..2.

clear_above_context is a function call that indicates that some arrays used to determine the probabilities are zeroed. When this function is invoked the arrays AboveNonzeroContext and AboveSegPredContext are set equal to 0.

Note: AboveNonzeroContext[ plane ][ i ] and AboveSegPredContext[ i ] need to be set to 0 for i = 0..MiCols-1, for plane = 0..2.

ReadDeltas specifies whether the current block is the first one in the current superblock. Delta values for the quantizer index and loop filter are only read on the first block of a superblock.

Clear Block Decoded Flags Semantics

clear_block_decoded_flags is a function which resets the array BlockDecoded so that all elements are set to 0 at the beginning of a superblock.

notLastColumn equal to 1 indicates that the current superblock is not in the rightmost column of the current tile. notLastColumn equal to 0 indicates that the current superblock is in the rightmost column of the current tile.

BlockDecoded is an array which stores one boolean value per 4x4 sample block per plane in the current superblock, plus a border of one 4x4 sample block on all sides of the superblock. Except for the borders, a value of 1 in BlockDecoded indicates that the corresponding 4x4 sample block has been decoded. The borders are used when computing above-right and below-left availability along the top and left edges of the superblock.

Decode Partition Semantics

partition specifies how a block is partitioned:

partition Name of partition
0 PARTITION_NONE
1 PARTITION_HORZ
2 PARTITION_VERT
3 PARTITION_SPLIT
4 PARTITION_HORZ_A
5 PARTITION_HORZ_B
6 PARTITION_VERT_A
7 PARTITION_VERT_B
8 PARTITION_HORZ_4
9 PARTITION_VERT_4

The variable subSize is computed from partition and indicates the size of the component blocks within this block:

subSize Name of subSize
0 BLOCK_4X4
1 BLOCK_4X8
2 BLOCK_8X4
3 BLOCK_8X8
4 BLOCK_8X16
5 BLOCK_16X8
6 BLOCK_16X16
7 BLOCK_16X32
8 BLOCK_32X16
9 BLOCK_32X32
10 BLOCK_32X64
11 BLOCK_64X32
12 BLOCK_64X64
13 BLOCK_64X128
14 BLOCK_128X64
15 BLOCK_128X128
16 BLOCK_4X16
17 BLOCK_16X4
18 BLOCK_8X32
19 BLOCK_32X8
20 BLOCK_16X64
21 BLOCK_64X16
22 BLOCK_32X128
23 BLOCK_128X32

The dimensions of these blocks are given in width, height order (e.g. BLOCK_8X16 corresponds to a block that is 8 pixels wide, and 16 pixels high).

It is a requirement of bitstream conformance that get_plane_residual_size( subSize, 1 ) is not equal to BLOCK_INVALID every time subSize is computed.

Note: This requirement prevents the UV blocks from being too tall or too wide (i.e. having aspect ratios outside the range 1:2 to 2:1).

split_or_vert is used to compute partition for blocks when only split or vert partitions are legal because of overlap with the right hand edge of the frame.

split_or_horz is used to compute partition for blocks when only split or horz partitions are legal because of overlap with the bottom edge of the frame.

Decode Block Semantics

MiRow is a variable holding the vertical location of the block in units of 4x4 pixels.

MiCol is a variable holding the horizontal location of the block in units of 4x4 pixels.

MiSize is a variable holding the size of the block with values having the same interpretation for the variable subSize.

HasChroma is a variable that specifies whether chroma information is coded for this block.

Variable AvailU is equal to 0 if the information from the block above cannot be used; AvailU is equal to 1 if the information from the block above can be used.

Variable AvailL is equal to 0 if the information from the block to the left can not be used; AvailL is equal to 1 if the information from the block to the left can be used.

Note: Information from a block in a different tile can be used in some circumstances if the block is above, but not if the block is to the left.

Intra Frame Mode Info Semantics

This syntax is used when coding an intra block within an intra frame.

intra_frame_y_mode specifies the direction of intra prediction filtering:

intra_frame_y_mode Name of intra_frame_y_mode
0 DC_PRED
1 V_PRED
2 H_PRED
3 D45_PRED
4 D135_PRED
5 D117_PRED
6 D153_PRED
7 D207_PRED
8 D63_PRED
9 SMOOTH_PRED
10 SMOOTH_V_PRED
11 SMOOTH_H_PRED
12 TM_PRED
13 UV_CFL_PRED

uv_mode specifies the chrominance intra prediction mode using values with the same interpretation as in the semantics for intra_frame_y_mode.

Intra and Inter Segment ID Semantics

segment_id specifies which segment is associated with the current intra block being decoded.

seg_id_predicted equal to 1 specifies that the segment_id are taken from the segmentation map. seg_id_predicted equal to 0 specifies that the syntax element segment_id are parsed.

Note: It is legal for seg_id_predicted to be equal to 0 even if the value coded for the segment_id is equal to predictedSegmentId.

Lossless is a variable which, if equal to 1, indicates that the block is coded using a special 4x4 transform designed for encoding frames that are bit-identical with the original frames.

Skip Semantics

skip equal to 0 indicates that there may be some transform coefficients to read for this block; skip equal to 1 indicates that there are no transform coefficients.

Quantizer Index Delta Semantics

delta_q_abs specifies the absolute value of the quantizer index delta value being decoded. If delta_q_abs is equal to DELTA_Q_SMALL, the value is encoded using delta_q_rem_bits and delta_q_abs_bits.

delta_q_rem_bits and delta_q_abs_bits encode the absolute value of the quantizer index delta value being decoded, where the absolute value of the quantizer index delta value is of the form:

(1 << delta_q_rem_bits) + delta_q_abs_bits + 1

delta_q_sign_bit equal to 0 indicates that the quantizer index delta value is positive; delta_q_sign_bit equal to 1 indicates that the quantizer index delta value is negative.

Loop Filter Delta Semantics

delta_lf_abs specifies the absolute value of the loop filter delta value being decoded. If delta_lf_abs is equal to DELTA_LF_SMALL, the value is encoded using delta_lf_rem_bits and delta_lf_abs_bits.

delta_lf_rem_bits and delta_lf_abs_bits encode the absolute value of the loop filter delta value being decoded, where the absolute value of the loop filter delta value is of the form:

( 1 << ( delta_lf_rem_bits + 1 ) ) + delta_lf_abs_bits + 1

delta_lf_sign_bit equal to 0 indicates that the loop filter delta value is positive; delta_lf_sign_bit equal to 1 indicates that the loop filter delta value is negative.

CDEF Params Semantics

cdef_damping_minus_3 controls the amount of damping in the deringing filter.

cdef_bits specifies the number of bits needed to specify which CDEF filter to apply.

cdef_y_pri_strength and cdef_uv_pri_strength specify the strength of the primary filter.

cdef_y_sec_strength and cdef_uv_sec_strength specify the strength of the secondary filter.

cdef_y_filter_skip and cdef_uv_filter_skip specify whether to apply the filtering for skipped blocks. Skipped blocks will only be filtered if this skip bit is equal to 1.

TX Size Semantics

tx_size specifies the transform size to be used for this block:

tx_size Name of tx_size
0 TX_4X4
1 TX_8X8
2 TX_16X16
3 TX_32X32
4 TX_4X8
5 TX_8X4
6 TX_8X16
7 TX_16X8
8 TX_16X32
9 TX_32X16

Note: tx_size is decoded for skipped intra blocks because tx_size controls the granularity of the intra prediction.

Note: The tx_size syntax element in the bitstream only explicitly codes square sizes. Rectangular sizes are signalled by transmitting a square tx_size that is larger than the block size. tx_size is then overwritten to be the largest rectangular size that fits in the block.

Inter TX Size Semantics

MinTxSize is a variable that contains a square transform size that would fit inside all the transforms within the block. In other words, if the block contains transforms of size W[i] by H[i], then MinTxSize represents a transform of size m by m, where m is equal to the smallest value in both W and H.

InterTxSizes is an array that holds the transform sizes within inter frames.

Note: TxSizes and InterTxSizes contain different values. All the values in TxSizes across a residual block will share the same value, while InterTxSizes can represent several different transform sizes within a residual block.

Var TX Size Semantics

txfm_split equal to 1 specifies that the block should be split into smaller transform sizes. txfm_split equal to 0 specifies that the block should not be split any more.

Transform Type Semantics

setType specifies the transform set type.

setType Name of setType
0 TX_SET_DCTONLY
1 TX_SET_DCT_IDTX
2 TX_SET_DTT4_IDTX
3 TX_SET_DTT4_IDTX_1DDCT
4 TX_SET_DTT9_IDTX_1DDCT
5 TX_SET_ALL16

inter_tx_type specifies the transform type for inter blocks.

intra_tx_type specifies the transform type for intra blocks.

Is Inter Semantics

is_inter equal to 0 specifies that the block is an intra block; is_inter equal to 1 specifies that the block is an inter block.

Intra Block Mode Info Semantics

This syntax is used when coding an intra block within an inter frame.

y_mode and uv_mode specify the direction of intra prediction using values with the same interpretation as for intra_frame_y_mode.

Inter Block Mode Info Semantics

This syntax is used when coding an inter block.

compound_mode specifies how the motion vector used by inter prediction is obtained when using compound prediction. An offset is added to compound_mode to compute YMode as follows:

YMode Name of YMode
13 NEARESTMV
14 NEARMV
15 GLOBALMV
16 NEWMV
17 NEAREST_NEARESTMV
18 NEAR_NEARMV
19 NEAREST_NEWMV
20 NEW_NEARESTMV
21 NEAR_NEWMV
22 NEW_NEARMV
23 GLOBAL_GLOBALMV
24 NEW_NEWMV

Note: The intra modes take values 0..12 so these YMode values start at 13.

new_mv equal to 0 means that a motion vector difference should be read.

zero_mv equal to 0 means that the motion vector should be set equal to default motion for the frame.

ref_mv equal to 0 means that the most likely motion vector should be used (called NEAREST), ref_mv equal to 1 means that the second most likely motion vector should be used (called NEAR).

interp_filter specifies the type of filter used in inter prediction. Values 0..3 are allowed with the same interpretation as for interpolation_filter. One filter type is specified for the vertical filter direction and one for the horizontal filter direction.

Note: The syntax element interpolation_filter from the uncompressed header can specify the type of filter to be used for the whole frame. If it is set to SWITCHABLE then the interp_filter syntax element is read from the bitstream for every inter block.

RefMvIdx specifies which candidate in the RefStackMv should be used. If there are not enough entries in the stack, a candidate from the RefListMv will be used instead.

drl_mode is a bit sent for candidates in the motion vector stack to indicate if they should be used. drl_mode equal to 0 means to use the current value of idx. drl_mode equal to 1 says to continue searching. DRL stands for “Dynamic Reference List”.

Ref Frames Semantics

comp_mode specifies whether single or compound prediction is used. Values 0 and 1 are used with the same interpretation as for ReferenceMode.

comp_ref_type is used for compound prediction to specify whether both reference frames come from the same direction or not:

comp_ref_type Name of comp_ref_type Description
0 UNIDIR_COMP_REFERENCE Both reference frames from the same direction
1 BIDIR_COMP_REFERENCE One forward and one backward reference frame

uni_comp_ref, uni_comp_ref_p1, and uni_comp_ref_p2 specify which reference frames are in use when both come from the same direction.

comp_ref, comp_ref_p1, and comp_ref_p2 specify the first reference frame when the two reference frames come from different directions.

comp_bwdref and comp_bwdref_p1 specify the second reference frame when the two reference frames come from different directions.

single_ref_p1, single_ref_p2, single_ref_p3, single_ref_p4, single_ref_p5, and single_ref_p6 specify the reference frame when only a single reference frame is in use.

RefFrame[ 0 ] specifies which frame is used to compute the predicted samples for this block:

RefFrame[ 0 ] Name of ref_frame
0 INTRA_FRAME
1 LAST_FRAME
2 LAST2_FRAME
3 LAST3_FRAME
4 GOLDEN_FRAME
5 BWDREF_FRAME
6 ALTREF2_FRAME
7 ALTREF_FRAME

RefFrame[ 1 ] specifies which additional frame is used in compound prediction:

RefFrame[ 1 ] Name of ref_frame
-1 NONE (this block uses single prediction)
0 INTRA_FRAME (this block uses interintra prediction)
1 LAST_FRAME
2 LAST2_FRAME
3 LAST3_FRAME
4 GOLDEN_FRAME
5 BWDREF_FRAME
6 ALTREF2_FRAME
7 ALTREF_FRAME

Note: Not all combinations of RefFrame[0] and RefFrame[1] can be coded.

Read Motion Mode Semantics

use_obmc equal to 1 means that OBMC should be used. use_obmc equal to 0 means that simple translation should be used.

motion_mode specifies the type of motion compensation to perform:

motion_mode Name of motion_mode
0 SIMPLE
1 OBMC
2 LOCALWARP

Note: A motion_mode equal to SIMPLE is used for blocks requiring global motion.

Read Inter Intra Semantics

interintra equal to 1 specifies that an inter prediction should be blended with an intra prediction.

interintra_mode specifies the type of intra prediction to be used:

interintra_mode Name of interintra_mode
0 II_DC_PRED
1 II_V_PRED
2 II_H_PRED
3 II_SMOOTH_PRED

wedge_interintra equal to 1 specifies that wedge blending should be used. wedge_interintra equal to 0 specifies that intra blending should be used.

wedge_index specifies the angle to be used during wedge blending.

Read Compound Type Semantics

compound_avg equal to 1 means COMPOUND_AVERAGE blending should be used. compound_avg equal to 0 means COMPOUND_SEG should be used.

compound_type specifies how the two predictions should be blended together:

compound_type Name of compound_type
0 COMPOUND_AVERAGE
1 COMPOUND_WEDGE
2 COMPOUND_SEG
3 COMPOUND_INTRA

Note: COMPOUND_INTRA cannot be directly signalled in the compound_type syntax element. It is only used in interintra modes.

wedge_index specifies the angle to be used during wedge blending:

wedge_index Name of wedge_index
0 WEDGE_HORIZONTAL
1 WEDGE_VERTICAL
2 WEDGE_OBLIQUE27
3 WEDGE_OBLIQUE63
4 WEDGE_OBLIQUE117
5 WEDGE_OBLIQUE153

wedge_sign specifies the sign of the wedge blend.

mask_type specifies the type of mask to be used during blending:

mask_type Name of mask_type
0 UNIFORM_45
1 UNIFORM_45_INV

MV Semantics

MvCtx is used to determine which CDFs to use for the motion vector syntax elements.

mv_joint specifies which components of the motion vector difference are non-zero:

mv_joint Name of mv_joint Changes row Changes col
0 MV_JOINT_ZERO No No
1 MV_JOINT_HNZVZ No Yes
2 MV_JOINT_HZVNZ Yes No
3 MV_JOINT_HNZVNZ Yes Yes

The motion vector difference is added to the PredMv to compute the final motion vector in Mv. It is a requirement of bitstream conformance that the resulting motion vector satisfies -(1 << 14) < Mv[ ref ][ comp ] < (1 << 14) - 1 for comp=0..1.

MV Component Semantics

mv_sign equal to 0 means that the motion vector difference is positive; mv_sign equal to 1 means that the motion vector difference is negative.

mv_class specifies the class of the motion vector difference. A higher class means that the motion vector difference represents a larger update:

mv_class Name of mv_class
0 MV_CLASS_0
1 MV_CLASS_1
2 MV_CLASS_2
3 MV_CLASS_3
4 MV_CLASS_4
5 MV_CLASS_5
6 MV_CLASS_6
7 MV_CLASS_7
8 MV_CLASS_8
9 MV_CLASS_9
10 MV_CLASS_10

mv_class0_bit specifies the integer part of the motion vector difference. This is only present in the bitstream for class 0 motion vector differences.

mv_class0_fr specifies the first 2 fractional bits of the motion vector difference. This is only present in the bitstream for class 0 motion vector differences.

mv_class0_hp specifies the third fraction bit of the motion vector difference. This is only present in the bitstream for class 0 motion vector differences.

mv_bit specifies bit i of the integer part of the motion vector difference.

mv_fr specifies the first 2 fractional bits of the motion vector difference.

mv_hp specifies the third fractional bit of the motion vector difference.

Residual Semantics

predict_intra is a function call that indicates the conceptual point where intra prediction happens. When this function is called, the intra prediction process specified in section 7.6.1 is invoked.

predict_inter is a function call that indicates the conceptual point where inter prediction happens. When this function is called, the inter prediction process specified in section 7.6.2 is invoked.

predW and predH are variables containing the smallest size that can be used for inter prediction. (This size may be increased for chroma blocks if not all blocks use inter prediction.)

someUseIntra is a variable that indicates if some of the blocks corresponding to this residual require intra prediction.

Note: The chroma residual block size is always at least 4 in width and height. This means that no transform width or height smaller than 4 is required. As such, a chroma residual may actually cover several luma blocks. Normally, a single prediction is performed for the entire chroma residual block based on the mode info of the bottom right luma block. However, if all the constituent blocks are inter blocks, a special case is triggered and inter prediction is done using a smaller block size for each of the corresponding luma blocks.

predict_palette is a function call that indicates the conceptual point where palette prediction happens. When this function is called, the palette prediction process specified in section 7.6.3 is invoked.

Note: The predict_inter, predict_intra, predict_palette, and predict_chroma_from_luma functions do not affect the syntax decode process.

Transform Block Semantics

AboveNonzeroContext and LeftNonzeroContext are arrays that store at a 4 sample granularity which blocks contained coded coefficients.

reconstruct is a function call that indicates the conceptual point where inverse transform and reconstruction happens. When this function is called, the reconstruction process specified in section 7.7.2 is invoked.

predict_chroma_from_luma is a function call that indicates the conceptual point where predicting chroma from luma happens. When this function is called, the predict chroma from luma process specified in section 7.6.4 is invoked.

MaxLumaW and MaxLumaH are needed for chroma from luma prediction and store the extent of luma pixels that can be used for prediction.

LoopfilterTxSizes is an array that stores the transform size for each plane and position for use in loop filtering. LoopfilterTxSizes[ plane ][ row ][ col ] stores the transform size where row and col are in units of 4x4 samples.

Note: The transform size is always equal for planes 1 and 2.

Transform Tree Semantics

isLumaSquare is a variable that indicates if the luma samples used a square transform for this location.

becomingRect is a variable that indicates we are forced to subdivide the transform tree.

Note: When the luma uses a square transform, the chroma samples must also use a square transform. For example, if we have subsampling_y=1, and subsampling_x=0, a 32x32 block in luma will become a 32x16 block in chroma. If a 32x32 transform is used for luma, chroma is forbidden from using a 32x16 transform and will use a pair of 16x16 transforms instead.

Token Semantics

moreCoefs equal to 0 specifies that all the remaining coefficients in this transform block are equal to 0 and that no more coefficients need to be parsed for this transform block. moreCoefs equal to 1 indicates that more coefficients should be read.

dc_head_token is used to compute combToken for the DC coefficient in a transform block.

ac_head_token is used to compute combToken for the AC coefficients in a transform block.

last_head_token is used to compute combToken for the last AC coefficient in a transform block.

Note: dc_head_token can specify any combination of token and moreCoefs. ac_head_token cannot specify the case when both token and moreCoefs are equal to zero. last_head_token cannot specify a zero token, and always specifies moreCoefs equal to zero. These restriction ensure that there are no syntax elements corresponding to trailing zero coefficients.

combToken specifies the size of the coefficient and whether this is the last non-zero coefficient in the block. The least significant bit contains moreCoefs, and the remaining bits specify the base value for token.

tail_token specifies an increment to be applied to compute the final token value.

token specifies the size range of the transform coefficient:

token Name of token
0 ZERO_TOKEN
1 ONE_TOKEN
2 TWO_TOKEN
3 THREE_TOKEN
4 FOUR_TOKEN
5 DCT_VAL_CATEGORY1
6 DCT_VAL_CATEGORY2
7 DCT_VAL_CATEGORY3
8 DCT_VAL_CATEGORY4
9 DCT_VAL_CATEGORY5
10 DCT_VAL_CATEGORY6

sign_bit equal to 0 indicates that the transform coefficient is given by coef; sign_bit equal to 1 indicates that the transform coefficient is given by -coef.

Coef Semantics

coef_extra_bits represents a section of the transform coefficient bitstring.

Intra Angle Info Semantics

angle_delta_y specifies the offset to be applied to the intra prediction angle specified by the prediction mode in the luma plane, biased by MAX_ANGLE_DELTA so as to encode a positive value.

angle_delta_uv specifies the offset to be applied to the intra prediction angle specified by the prediction mode in the chroma plane biased by MAX_ANGLE_DELTA so as to encode a positive value.

AngleDeltaY is computed from angle_delta_y by removing the MAX_ANGLE_DELTA offset to produce the final luma angle offset value, which may be positive or negative.

AngleDeltaUV is computed from angle_delta_uv by removing the MAX_ANGLE_DELTA offset to produce the final chroma angle offset value, which may be positive or negative.

Read CFL Alphas Semantics

cfl_alpha_signs contains the sign of the alpha values for U and V packed together into a single syntax element with 8 possible values. (The combination of two zero signs is unnecessary.)

signU contains the sign of the alpha value for the U component:

signU Name of signU
0 CFL_SIGN_ZERO
1 CFL_SIGN_NEG
2 CFL_SIGN_POS

signV contains the sign of the alpha value for the V component with the same interpretation as for signU.

cfl_alpha_u contains the absolute value of alpha minus one for the U component.

cfl_alpha_v contains the absolute value of alpha minus one for the V component.

CflAlphaU contains the signed value of the alpha component for the U component.

CflAlphaV contains the signed value of the alpha component for the V component.

Palette Mode Info Semantics

has_palette_y is a boolean value specifying whether a palette is encoded for the Y plane.

has_palette_uv is a boolean value specifying whether a palette is encoded for the UV plane.

palette_size_y_minus_2 is used to compute PaletteSizeY.

PaletteSizeY is a variable holding the Y plane palette size.

palette_size_uv_minus_2 is used to compute PaletteSizeUV.

PaletteSizeUV is a variable holding the UV plane palette size.

use_palette_color_cache_y, if equal to 1, indicates that for a particular palette entry in the luma palette, the cached entry should be used.

use_palette_color_cache_u, if equal to 1, indicates that for a particular palette entry in the U chroma palette, the cached entry should be used.

palette_colors_y is an array holding the Y plane palette colors.

palette_colors_u is an array holding the U plane palette colors.

palette_colors_v is an array holding the V plane palette colors.

delta_encode_palette_colors_v, if equal to 1, indicates that the V chroma palette is encoded using delta encoding.

palette_num_extra_bits_y is used to calculate the number of bits used to store each palette delta value for the luma palette.

palette_num_extra_bits_u is used to calculate the number of bits used to store each palette delta value for the U chroma palette.

palette_num_extra_bits_v is used to calculate the number of bits used to store each palette delta value for the V chroma palette.

palette_delta_y is a delta value for the luma palette.

palette_delta_u is a delta value for the U chroma palette.

palette_delta_v is a delta value for the V chroma palette.

Note: Luma and U delta values give a positive offset relative to the previous palette entry in the same plane. V delta values give a signed offset relative to the U palette entries.

palette_delta_sign_bit_v, if equal to 1, indicates that the decoded V chroma palette delta value should be negated.

Palette Tokens Semantics

color_index_map_y holds the index in palette_colors_y for the block’s Y plane top left pixel.

color_index_map_uv holds the index in palette_colors_u and palette_colors_v for the block’s UV plane top left pixel.

palette_color_idx_y holds the index in ColorOrder for a pixel in the block’s Y plane.

palette_color_idx_uv holds the index in ColorOrder for a pixel in the block’s UV plane.

Palette Colors Semantics

ColorOrder is an array holding the mapping from an encoded index to the palette. ColorOrder is ranked in order of frequency of occurrence of each color in the neighbourhood of the current block, weighted by closeness to the current block.

ColorContextHash is a variable derived from the distribution of colors in the neighbourhood of the current block, which is used to determine the probability context used to decode palette_color_idx_y and palette_color_idx_uv.

Decode CDF Semantics

cdef_idx specifies which CDEF filtering parameters should be used for a particular 64 by 64 pixel block.

Decoding Process

General

Decoders shall produce output frames that are identical in all respects and have the same output order as those produced by the decoding process specified herein.

The input to this process is a sequence of open bitstream units (OBUs).

The output from this process is a sequence of decoded frames.

For each OBU in turn the syntax elements are extracted as specified in section 5.1.

The syntax tables include function calls indicating when the remaining block decode processes are triggered.

Decode Frame Process

This process is triggered by a call to decode_frame from within the syntax tables.

If show_existing_frame is equal to 0, the process first performs any post processing filtering by the following ordered steps:

  1. If loop_filter_level[ 0 ] is not equal to 0 or loop_filter_level[ 1 ] is not equal to 0, the loop filter process specified in section 7.10 is invoked once the coded frame has been decoded.

  2. The CDEF process specified in section 7.11 is invoked.

  3. If all of the following conditions are true, PrevSegmentIds[ row ][ col ] is set equal to SegmentIds[ row ][ col ] for row = 0..MiRows-1, for col = 0..MiCols-1:

    • segmentation_enabled is equal to 1,

    • segmentation_update_map is equal to 1.

  4. The reference frame update process as specified in section 7.13 is invoked.

If show_existing_frame is equal to 1 or show_frame is equal to 1, the output process as specified in section 7.12 is invoked.

Frame Order Constraints

This section describes additional constraints on a bitstream that result from the choice of frame types.

If a sequence starts with a key frame, then the additional constraints are automatically satisfied.

Otherwise, the sequence can start with a number of non key frames and extra care has to be taken to ensure that the decoding process is well defined. It is a requirement of bitstream conformance that the following applies:

  • When load_cdfs( ctx ) is invoked, this must load an initialized set of CDFs, i.e. there must have been an earlier invocation of save_cdfs( ctx ).

  • When ref_frame_idx[ i ] is decoded, it must identify an initialized reference frame, i.e. there must have been an earlier decoded frame which had (refresh_frame_flags >> ref_frame_idx[ i ])&1 equal to 1.

Note: This constraint means that the first coded frame cannot be an inter frame.

CDF Update Process

This process is triggered when the function update_cdf is called from the tile group syntax table.

The frame CDF arrays are set equal to the final tile CDF arrays for the largest tile (measured in bytes) as follows.

A copy is made of the saved CDF values for each of the CDF arrays mentioned in the semantics for setup_past_independence. The name of the destination for the copy is the name of the CDF array with no prefix. The name of the source for the copy is the name of the CDF array prefixed with “Saved”. For example, the array YModeCdf will be updated with values equal to the contents of SavedYModeCdf.

Motion Field Estimation Process

This process is triggered during the call to load_previous.

A linear projection model is employed to create a motion field estimation that is able to capture high velocity temporal motion trajectories.

The motion field is estimated based on the saved motion vectors from the reference frames and the relative frame distances.

As the frame distances depend on the frame being referenced, a separate motion field is estimated for each reference frame used by the current frame.

A stack of up to three motion vectors (for each reference frame type) is prepared at each location on an 8x8 pixel grid.

The variable w8 (representing the width of the motion field in units of 8x8 pixels) is set equal to MiCols >> 1.

The variable h8 (representing the height of the motion field in units of 8x8 pixels) is set equal to MiRows >> 1.

As the linear projection can create a field with holes, the motion fields are initialized to an invalid motion vector of -32768, -32768 as follows:

for ( ref = LAST_FRAME; ref <= ALTREF_FRAME; ref++ )
    for ( y = 0; y < h8 ; y++ )
        for ( x = 0; x < w8; x++ )
            for ( i = 0; i < MFMV_STACK_SIZE; i++ )
                for ( j = 0; j < 2; j++ )
                    MotionFieldMvs[ ref ][ y ][ x ][ i ][ j ] = -1 << 15.

The variable curAltDecodeOrder (representing the decode order for ALTREF_FRAME of the current frame) is set equal to DecodeOrders[ ALTREF_FRAME ].

If ( curAltDecodeOrder < DecodeOrder ), then this process terminates immediately.

The variable refStamp (representing where in the stack to place projected motion vectors) is set equal to MFMV_STACK_SIZE - 1.

The variable lastIdx (representing which reference frame is used for LAST_FRAME) is set equal to ref_frame_idx[ 0 ].

The variable curGoldDecodeOrder (representing the decode order for GOLD_FRAME of the current frame) is set equal to DecodeOrders[ GOLD_FRAME ].

The variable lastAltDecodeOrder ( representing the decode order for ALTREF_FRAME of LAST_FRAME) is set equal to SavedDecodeOrders[ lastIdx ][ ALTREF_FRAME ].

The variable useLast (representing whether to project the motion vectors from LAST_FRAME) is set equal to ( lastAltDecodeOrder != curGoldDecodeOrder ).

If useLast is equal to 1, the forward projection process in section 7.5.1 is invoked with src equal to LAST_FRAME, and refStamp as inputs.

The variable refStamp is set equal to MFMV_STACK_SIZE - 2.

Note: refStamp is decreased even if the forward projection process is not invoked.

The variable useBwd is set equal to ( DecodeOrders[ BWDREF_FRAME ] > DecodeOrder ).

If useBwd is equal to 1, the backward projection process in section 7.5.2 is invoked with src equal to BWDREF_FRAME, and refStamp as inputs.

If useBwd is equal to 1, refStamp is set equal to refStamp - 1.

The variable useAlt2 is set equal to ( DecodeOrders[ ALTREF2_FRAME ] > DecodeOrder ).

If useAlt2 is equal to 1, the backward projection process in section 7.5.2 is invoked with src equal to ALTREF2_FRAME, and refStamp as inputs.

If useAlt2 is equal to 1, refStamp is set equal to refStamp - 1.

The variable useAlt is set equal to ( DecodeOrders[ ALTREF_FRAME ] > DecodeOrder ).

If useAlt is equal to 1 and (refStamp >= 0), the backward projection process in section 7.5.2 is invoked with src equal to ALTREF_FRAME, and refStamp as inputs.

Forward Projection Process

The inputs to this process are:

  • a variable src specifying which reference frame’s motion vectors should be projected,

  • a variable refStamp specifying which entry in the stack to store the motion vectors.

The process projects the motion vectors from a whole reference frame (which will always be LAST_FRAME) and stores the results in MotionFieldMvs.

The variable srcIdx (representing which reference frame is used) is set equal to ref_frame_idx[ src - LAST_FRAME ].

The variable w8 (representing the width of the motion field in units of 8x8 pixels) is set equal to MiCols >> 1.

The variable h8 (representing the height of the motion field in units of 8x8 pixels) is set equal to MiRows >> 1.

The process is specified as follows:

for ( y8 = 0; y8 < h8; y8++ ) {
    for ( x8 = 0; x8 < w8; x8++ ) {
        row = 2 * y8 + 1
        col = 2 * x8 + 1
        srcRef = SavedRefFrames[ srcIdx ][ row ][ col ][ 0 ]
        if ( check_forward( srcRef ) ) {
            mv = SavedMvs[ srcIdx ][ row ][ col ][ 0 ]
            projMv = get_mv_projection( mv, srcRef, src, src ) 
            posValid = get_block_position( row, col, projMv, 1 )
            if ( posValid ) {
                for ( dst = LAST_FRAME; dst <= GOLDEN_FRAME; dst++ ) {
                    projMv = get_mv_projection( mv, srcRef, src, dst )
                    MotionFieldMvs[ dst ][ PosY8 ][ PosX8 ][ refStamp ] = projMv
                }
            }
        }
        for ( idx = 0; idx < 2; idx++ ) {
            srcRef = SavedRefFrames[ srcIdx ][ row ][ col ][ idx ]
            if ( check_backward( srcRef ) ) {
                mv = SavedMvs[ srcIdx ][ row ][ col ][ idx ]
                projMv = get_mv_projection( mv, srcRef, src, src ) 
                posValid = get_block_position( row, col, projMv, 0 )
                if ( posValid ) {
                    for ( dst = BWDREF_FRAME; dst <= ALTREF_FRAME; dst++ ) {
                        projMv = get_mv_projection( mv, srcRef, src, dst )
                        MotionFieldMvs[ dst ][ PosY8 ][ PosX8 ][ refStamp ] = projMv
                    }
                }
            }
        }
    }
}

When the function get_mv_projection is called, the get mv position process specified in section 7.5.3 is invoked with mv, src, dst as inputs and the output assigned to projMv.

When the function get_block_position is called, the get block position process specified in section 7.5.4 is invoked and the output assigned to posValid. This process also sets up the variables PosY8 and PosX8 representing the projected location in the motion field.

Note: The forward projections from LAST_FRAME can use both list0 and list1 motion vectors. The backward projections only use list0 motion vectors.

Backward Projection Process

The inputs to this process are:

  • a variable src specifying which reference frame’s motion vectors should be projected,

  • a variable refStamp specifying which entry in the stack to store the motion vectors.

The process projects the motion vectors from a whole reference frame (which will always be one of the backward reference types) and stores the results in MotionFieldMvs.

The variable srcIdx (representing which reference frame is used) is set equal to ref_frame_idx[ src - LAST_FRAME ].

The variable w8 (representing the width of the motion field in units of 8x8 pixels) is set equal to MiCols >> 1.

The variable h8 (representing the height of the motion field in units of 8x8 pixels) is set equal to MiRows >> 1.

It is a requirement of bitstream conformance that srcIdx refers to a frame of the same width and height as the current frame. In other words, when this process is invoked, both of the following must be true:

  • RefFrameWidth[ srcIdx ] is equal to FrameWidth.

  • RefFrameHeight[ srcIdx ] is equal to FrameHeight.

The process is specified as follows:

for ( y8 = 0; y8 < h8; y8++ ) {
    for ( x8 = 0; x8 < w8; x8++ ) {
        row = 2 * y8 + 1
        col = 2 * x8 + 1
        srcRef = SavedRefFrames[ srcIdx ][ row ][ col ][ 0 ]
        if ( check_forward( srcRef ) ) {
            mv = SavedMvs[ srcIdx ][ row ][ col ][ 0 ]
            projMv = get_mv_projection( mv, srcRef, src, src )
            posValid = get_block_position( row, col, projMv, 0 )
            if ( posValid ) {
                for ( dst = LAST_FRAME; dst <= ALTREF_FRAME; dst++ ) {
                    if ( dst == ALTREF_FRAME ) {
                        useDst = src == ALTREF_FRAME
                    } else if (dst == ALTREF2_FRAME ) {
                        useDst = src >= ALTREF2_FRAME
                    } else if (dst == BWDREF_FRAME ) {
                        useDst = 1
                    } else {
                        useDst = srcRef >= dst
                    }
                    if ( useDst ) {
                        projMv = get_mv_projection( mv, srcRef, src, dst )
                        if ( check_backward( dst ) ) {
                            projMv[ 0 ] = -projMv[ 0 ]
                            projMv[ 1 ] = -projMv[ 1 ]
                        }
                        MotionFieldMvs[ dst ][ PosY8 ][ PosX8 ][ refStamp ] = projMv
                    }
                }
            }
        }
    }
}

When the function get_mv_projection is called, the get mv position process specified in section 7.5.3 is invoked with mv, src, dst as inputs and the output assigned to projMv.

When the function get_block_position is called, the get block position process specified in section 7.5.4 is invoked and the output assigned to posValid. This process also sets up the variables PosY8 and PosX8 representing the projected location in the motion field.

Get MV Position Process

The inputs to this process are:

  • a length two array mv specifying a motion vector,

  • a variable ref specifying the reference frame associated with the motion vector,

  • a variable src specifying which reference frame’s motion vectors should be projected,

  • a variable dst specifying which reference frame to target when adjusting the motion vector.

The outputs of this process are:

  • a length 2 array projMv containing a projected motion vector

This process starts with a motion vector mv from a previous frame (src). This motion vector gives the displacement expected when moving a certain number of frames (between src and ref). We wish to use the motion vector for predictions using a different reference frame (dst), so we need to scale the length of the motion vector.

The variable srcIdx (representing the reference frame where we obtained the motion vector) is set equal to ref_frame_idx[ src - LAST_FRAME ].

The variable srcDecodeOrder (representing the decode order of the reference frame where we obtained the motion vector) is set equal to DecodeOrders[ src ].

The variable refDecodeOrder (representing the decode order of the frame referenced by the motion vector) is set equal to SavedDecodeOrders[ srcIdx ][ ref ].

The variable refSign is set equal to ( check_backward( ref ) ? -1 : 1 ).

The variable mvOffset (representing the number of frames covered by the motion vector) is set equal to Max( 1, refSign * (srcDecodeOrder - refDecodeOrder) ).

The variable dstDecodeOrder (representing the decode order of the reference frame we wish to use) is set equal to DecodeOrders[ dst ].

The variable dstSign is set equal to ( check_backward( dst ) ? -1 : 1 ).

The variable dstOffset (representing the number of frames that we wish the motion vector to cover) is set equal to dstSign * (DecodeOrder - dstDecodeOrder).

It is a requirement of bitstream conformance that mvOffset and dstOffset are in the range -31 to 31.

The projected motion vector is specified as follows:

for ( i = 0; i < 2; i++ )
    projMv[ i ] = Round2( mv[ i ] * dstOffset * Div_Mult[ mvOffset ], 14 )

where Div_Mult is a constant lookup table specified as:

Div_Mult[32] = {
  0,    16384, 8192, 5461, 4096, 3276, 2730, 2340, 2048, 1820, 1638,
  1489, 1365,  1260, 1170, 1092, 1024, 963,  910,  862,  819,  780,
  744,  712,   682,  655,  630,  606,  585,  564,  546,  528
}

Get Block Position Process

The inputs to this process are:

  • variables x8 and y8 specifying a location in units of 8x8 pixels,

  • a length two array projMv specifying a projected motion vector,

  • a flag signBias specifying if we should project the block in the direction of the motion vector (signBias equal to 0), or in the reverse direction (signBias equal to 1).

The process generates global variables PosX8 and PosY8 representing the projected location in units of 8x8 pixels.

The process returns a flag posValid that indicates if the position should be used.

Note: posValid is specified such that only blocks within a certain distance of the current location need to be projected.

The variable posValid is set equal to 1.

The variable PosY8 is set equal to project(y8, projMv[ 0 ], MiRows >> 1, MAX_OFFSET_HEIGHT).

The variable PosX8 is set equal to project(x8, projMv[ 1 ], MiCols >> 1, MAX_OFFSET_WIDTH).

where the function project is specified as follows:

project( v8, delta, max8, maxOff8 ) {
    base8 = (v8 >> 3) << 3
    if (delta >= 0) {
        offset8 = delta >> ( 3 + 1 + MI_SIZE_LOG2 )
    } else {
        offset8 = -( -delta ) >> ( 3 + 1 + MI_SIZE_LOG2 )
    }
    if ( signBias )
        v8 -= offset8
    else
        v8 += offset8
    if ( v8 < 0 || 
         v8 >= max8 || 
         v8 <= base8 - maxOff8 ||
         v8 >= base8 + 8 + maxOff8 ) {
        posValid = 0
    }
    return v8
}

The project function clears posValid if the resulting position is offset too far.

Motion Vector Prediction Processes

The following sections define the processes used for predicting the motion vectors.

These processes are triggered at points defined by function calls to find_mv_list, compound_context, and find_mv_stack in the inter block mode info syntax described in section 5.8.20.

Find MV List Process

The input to this process is a variable refList specifying which set of motion vectors to predict.

This process is triggered by a function call to find_mv_list and constructs an array RefListMv[ refList ] containing 2 motion vector candidates.

The setup zero mv process specified in section 7.6.1.1 is invoked with the input refList and the output is assigned to ZeroMvs[ refList ].

The array RefListMv[ refList ] is first initialized to have both entries equal to ZeroMvs[ refList ].

The variable NumMvFound (repesenting the number of candidates found during this process) is set equal to 0.

The variable bw8 (representing the width of the block in units of 8 pixels) is set equal to Num_8x8_Blocks_Wide[ MiSize ].

The variable bh8 (representing the height of the block in units of 8 pixels) is set equal to Num_8x8_Blocks_High[ MiSize ].

An array offMvs8 (representing offsets in units of 8 pixels to search locations) is defined as:

offMvs8[ 9 ][ 2 ] = {
  { bh8 - 1, -1 },
  { -1, bw8 - 1 },
  { -1, (bw8 - 1) >> 1 },
  { (bh8 - 1) >> 1, -1 },
  { -1, -1 },
  { -1, ( bw8 == bh8 ) ? 0 : bw8 },
  { ( bw8 == bh8 ) ? 0 : bh8, -1 },
  { -1, -3 },
  { bh8 - 1, -3 }
}

The motion vector candidates are constructed by the following ordered steps :

  1. For i = 0..8 the spatial motion vector candidate process in section 7.6.1.1 is invoked with mv8 equal to offMvs8[ i ], same equal to 1, and refList as inputs.

  2. For i = 0..8 the spatial motion vector candidate process in section 7.6.1.1 is invoked with mv8 equal to offMvs8[ i ], same equal to 0, and refList as inputs.

Setup Zero MV Process

The input to this process is a variable refList specifying which set of motion vectors to predict.

The output is a motion vector mv representing global motion for this block.

The variable ref (specifying the reference frame) is set equal to RefFrame[ refList ].

The variable typ (specifying the type of global motion) is set equal to gm_type[ ref ].

The variable bw (representing the width of the block in units of pixels) is set equal to Block_Width[ MiSize ].

The variable bh (representing the height of the block in units of pixels) is set equal to Block_Height[ MiSize ].

The output motion vector mv is specified by projecting the central pixel of the block as follows:

if (typ == IDENTITY) {
    mv[0] = 0
    mv[1] = 0
} else if (typ == TRANSLATION) {
    mv[0] = gm_params[ref][0] >> (WARPEDMODEL_PREC_BITS - 3)
    mv[1] = gm_params[ref][1] >> (WARPEDMODEL_PREC_BITS - 3)
} else {
    x = MiCol * MI_SIZE + bw / 2 - 1
    y = MiRow * MI_SIZE + bh / 2 - 1
    xc = (gm_params[ref][2] - (1 << WARPEDMODEL_PREC_BITS)) * x +
          gm_params[ref][3] * y +
          gm_params[ref][0]
    yc =  gm_params[ref][4] * x +
         (gm_params[ref][5] - (1 << WARPEDMODEL_PREC_BITS)) * y +
          gm_params[ref][1]
    if (allow_high_precision_mv) {
      mv[0] = Round2Signed(xc, WARPEDMODEL_PREC_BITS - 3)
      mv[1] = Round2Signed(yc, WARPEDMODEL_PREC_BITS - 3)
    } else {
      mv[0] = Round2Signed(xc, WARPEDMODEL_PREC_BITS - 2) * 2
      mv[1] = Round2Signed(yc, WARPEDMODEL_PREC_BITS - 2) * 2
    }
}
Spatial Motion Vector Candidate Process

The inputs to this process are:

  • a 2 element array mv8 specifying the offset in 8 pixel units to the candidate location,

  • a variable same specifying whether to only look for candidates with matching reference frame,

  • a variable refList specifying which set of motion vectors to predict.

This process examines the motion vector at a position in the current frame and adds it to the candidate list if certain conditions are met.

The candidate location in 4x4 pixel units is derived as:

  • the variable mvRow is set equal to MiRow + 2 * mv8[0]

  • the variable mvCol is set equal to MiCol + 2 * mv8[1]

The variable size (representing the size of the superblock in units of 4x4 pixels) is set as follows:

  • If use_128x128_superblock is equal to 1, size is set equal to (Num_4x4_Blocks_Wide[ BLOCK_128X128 ].

  • Otherwise (use_128x128_superblock is equal to 0), size is set equal to (Num_4x4_Blocks_Wide[ BLOCK_64X64 ].

This process terminates immediately if any of the following are true:

  • the function is_inside( mvRow, mvCol ) is equal to 0 (this tests if the candidate is in a different tile from which we are not allowed to retrieve motion vectors)

  • (MiRow % size) + 2 * mv8[0] is greater than or equal to size (this tests if the candidate comes from the superblock row below)

  • (MiCol % size) + 2 * mv8[1] is greater than or equal to size (this tests if the candidate comes from the superblock column to the right)

  • RefFrames[ mvRow ][ mvCol ][ 0 ] has not yet been written for this frame (this tests if the candidate location has not been decoded yet)

For list=0..1 the following ordered steps apply:

  1. The variable candRef is set equal to RefFrames[ mvRow ][ mvCol ][ list ]
  2. The 2 element array candMv is set to a copy of Mvs[ mvRow ][ mvCol ][ list ]
  3. Invoke the candidate add process in section 7.6.1.3 with candRef, candMv, same, refList as inputs.
Candidate Add Process

The inputs to this process are:

  • a 2 element array candMv specifying the candidate motion vector,

  • a variable candRef specifying the candidate reference frame,

  • a variable same specifying whether to only look for candidates with matching reference frame,

  • a variable refList specifying which set of motion vectors to predict.

This process terminates immediately if same is equal to 1 and candRef is not equal to RefFrame[refList].

This process terminates immediately if NumMvFound is equal to 2 (this means we have already found enough motion vector candidates).

If ref_frame_sign_bias[ candRef ] is not equal to ref_frame_sign_bias[ RefFrame[refList] ], then the candidate motion vector is inverted as follows:

  • candMv[ 0 ] *= -1
  • candMv[ 1 ] *= -1

The variable bw (representing the width of the block rounded up to be a multiple of 8) is set equal to 8 * Num_8x8_Blocks_Wide[ MiSize ].

The variable bh (representing the height of the block rounded up to be a multiple of 8) is set equal to 8 * Num_8x8_Blocks_High[ MiSize ].

The motion vector is clamped to a legal range as follows:

  • candMv[ 0 ] is set equal to clamp_mv_row( candMv[ 0 ], MV_BORDER + bh * 8)
  • candMv[ 1 ] is set equal to clamp_mv_col( candMv[ 1 ], MV_BORDER + bw * 8)

If NumMvFound is equal to 0 or candMv is not equal to RefListMv[ refList ][ 0 ], then the following ordered steps apply:

  1. RefListMv[ refList ][ NumMvFound ] is set equal to candMv
  2. NumMvFound is set equal to NumMvFound + 1

Compound Context Process

This process is triggered by a function call to compound_context and constructs a variable CompoundModeContext that is used for decoding the inter_mode syntax element.

The variable bw4 (representing the width of the block in units of 4 pixels) is set equal to Num_4x4_Blocks_Wide[ MiSize ].

The variable bh4 (representing the height of the block in units of 4 pixels) is set equal to Num_4x4_Blocks_High[ MiSize ].

An array offMvs4 (representing offsets in units of 4 pixels to search locations) is defined as:

offMvs4[ 2 ][ 2 ] = {
  {bh4 - 1, -1},
  {-1, bw4 - 1}
}

The CompoundModeContext is constructed by testing the mode of the neighbouring blocks at the top-right and bottom-left corners as follows:

counter = 0
for (i = 0; i < 2; i++) {
    mvRow = MiRow + offMvs4[i][0]
    mvCol = MiCol + offMvs4[i][1]
    if (is_inside(mvcol, mvrow)) {
      counter += Mode_To_Counter[YModes[ mvRow ][ mvCol ]
    }
  }
  CompoundModeContext = Counter_To_Context[counter]

The Mode_To_Counter table is defined as:

Mode_To_Counter[ MB_MODE_COUNT ] = {
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 3, 1
}

The Counter_To_Context table is defined as:

Counter_To_Context[ 19 ] = {
    BOTH_PREDICTED,
    NEW_PLUS_NON_INTRA,
    BOTH_NEW,
    ZERO_PLUS_PREDICTED,
    NEW_PLUS_NON_INTRA,
    INVALID_CASE,
    BOTH_ZERO,
    INVALID_CASE,
    INVALID_CASE,
    INTRA_PLUS_NON_INTRA,
    INTRA_PLUS_NON_INTRA,
    INVALID_CASE,
    INTRA_PLUS_NON_INTRA,
    INVALID_CASE,
    INVALID_CASE,
    INVALID_CASE,
    INVALID_CASE,
    INVALID_CASE,
    BOTH_INTRA
}

Find MV Stack Process

This process is triggered by a function call to find_mv_stack.

The input to this process is a variable refList specifying which set of motion vectors to predict, or -1 to signal compound prediction.

This process constructs an array RefStackMv containing motion vector candidates. This is similar to the RefListMv list of motion vectors, except that the stack only contains candidates that exactly match in their use of reference frames, while RefListMv can also include partial matches. For single prediction, the candidates in the stack are used to overwrite entries in RefListMv.

The process also prepares the value of the contexts used when decoding inter prediction syntax elements.

The variable bw4 specifying the width of the block in 4x4 pixels is set equal to Num_4x4_Blocks_Wide[ MiSize ].

The following ordered steps apply:

  1. The variable NumMvFound (representing the number of motion vector candidates in RefStackMv) is set equal to 0.

  2. The variable NumNewMvFound (representing the number of candidates in RefStackMv that used NEWMV encoding) is set equal to 0.

  3. The scan row process in section 7.6.3.1 is invoked with deltaRow equal to -1 and refList as inputs.

  4. The scan col process in section 7.6.3.2 is invoked with deltaCol equal to -1 and refList as inputs.

  5. The scan point process in section 7.6.3.3 is invoked with deltaRow equal to -1, deltaCol equal to bw4, and refList as inputs.

  6. The variable numNearest (representing the number of motion vectors found in the immediate neighbourhood) is set equal to NumMvFound

  7. The variable numNew (representing the number of NEWMV candidates found in the immediate neighbourhood) is set equal to NumNewMvFound

  8. If numNearest is greater than 0, WeightStack[ idx ] is incremented by REF_CAT_LEVEL for idx = 0..(numNearest-1).

  9. The variable ZeroMvContext is set equal to 0.

  10. If refList is greater than or equal to 0 and can_use_previous is equal to 1, the temporal scan process in section 7.6.3.4 is invoked with refList as input (the temporal scan process affects ZeroMvContext).

  11. The scan point process in section 7.6.3.3 is invoked with deltaRow equal to -1, deltaCol equal to -1, and refList as inputs.

  12. The scan row process in section 7.6.3.1 is invoked with deltaRow equal to -3 and refList as inputs.

  13. The scan col process in section 7.6.3.2 is invoked with deltaCol equal to -3 and refList as inputs.

  14. The scan row process in section 7.6.3.1 is invoked with deltaRow equal to -5 and refList as inputs.

  15. The scan col process in section 7.6.3.2 is invoked with deltaCol equal to -5 and refList as inputs.

  16. The scan col process in section 7.6.3.2 is invoked with deltaCol equal to -7 and refList as inputs.

  17. The sorting process in section 7.6.3.10 is invoked with start equal to 0 and end equal to numNearest.

  18. The sorting process in section 7.6.3.10 is invoked with start equal to numNearest and end equal to NumMvFound.

  19. The context and clamping process in section 7.6.3.11 is invoked with refList, numNearest, and numNew as input.

Scan Row Process

The inputs to this process are:

  • a variable deltaRow specifying (in units of 4x4 pixels) how far above to look for motion vectors,

  • a variable refList specifying which set of motion vectors to predict, or -1 to signal compound prediction.

The variable bw4 specifying the width of the block in 4x4 pixels is set equal to Num_4x4_Blocks_Wide[ MiSize ].

The variable deltaCol is set equal to 0.

The variable useStep16 is set equal to (bw4 >= 16).

Note: useStep16 is equal to 1 when the block is 64 pixels wide. This means only 4 locations will be searched in this case. However, a 32 pixel wide block may still search 8 locations.

If Abs(deltaRow) is greater than 1, the offset is adjusted as follows:

deltaRow += MiRow & 1
deltaCol = 1 - (MiCol & 1)

Note: These adjustments reduce the number of motion vectors that need to be kept in memory

A series of motion vector locations is scanned as follows:

i = 0
while ( i < bw4 && NumMvFound < MAX_REF_MV_STACK_SIZE) {
    mvRow = miRow + deltaRow
    mvCol = miCol + deltaCol + i
    if (!is_inside(mvRow,mvCol))
        break
    len = Min(bw4, Num_4x4_Blocks_Wide[ MiSizes[ mvRow ][ mvCol ] ])
    if (Abs(deltaRow) > 1)
        len = Max(2, len)
    if (useStep16)
        len = Max(4, len)
    add_ref_mv_candidate( mvRow, mvCol, refList, len)
    i += len
}

where the call to add_ref_mv_candidate invokes the process in section 7.6.3.6.

Scan Col Process

The inputs to this process are:

  • a variable deltaCol specifying (in units of 4x4 pixels) how far left to look for motion vectors,

  • a variable refList specifying which set of motion vectors to predict, or -1 to signal compound prediction.

The variable bh4 specifying the height of the block in 4x4 pixels is set equal to Num_4x4_Blocks_High[ MiSize ].

The variable deltaRow is set equal to 0.

The variable useStep16 is set equal to (bh4 >= 16).

If Abs(deltaCol) is greater than 1, the offset is adjusted as follows:

deltaRow = 1 - (MiRow & 1)
deltaCol += MiCol & 1

A series of motion vector locations is scanned as follows:

i = 0
while ( i < bh4 && NumMvFound < MAX_REF_MV_STACK_SIZE) {
    mvRow = miRow + deltaRow + i
    mvCol = miCol + deltaCol
    if (!is_inside(mvRow,mvCol))
        break
    len = Min(bh4, Num_4x4_Blocks_High[ MiSizes[ mvRow ][ mvCol ] ])
    if (Abs(deltaCol) > 1)
        len = Max(2, len)
    if (useStep16)
        len = Max(4, len)
    add_ref_mv_candidate( mvRow, mvCol, refList, len)
    i += len
}

where the call to add_ref_mv_candidate invokes the process in section 7.6.3.6.

Scan Point Process

The inputs to this process are:

  • a variable deltaRow specifying (in units of 4x4 pixels) how far above to look for a motion vector,

  • a variable deltaCol specifying (in units of 4x4 pixels) how far left to look for a motion vector,

  • a variable refList specifying which set of motion vectors to predict, or -1 to signal compound prediction.

The variable mvRow is set equal to MiRow + deltaRow.

The variable mvCol is set equal to MiCol + deltaCol.

The variable len is set equal to 8.

If is_inside( mvRow, mvCol ) is equal to 1 and RefFrames[ mvRow ][ mvCol ][ 0 ] has been written for this frame (this checks that the candidate location has been decoded), the add reference motion vector process in section 7.6.3.6 is invoked with mvRow, mvCol, refList, len as inputs.

Temporal Scan Process

The input to this process is a variable refList specifying which set of motion vectors to predict.

This process scans the motion vectors in a previous frame looking for candidates which use the same reference frame.

The variable bw4 specifying the width of the block in 4x4 pixels is set equal to Num_4x4_Blocks_Wide[ MiSize ].

The variable bh4 specifying the height of the block in 4x4 pixels is set equal to Num_4x4_Blocks_High[ MiSize ].

The process scans the locations within the block as follows:

for ( deltaRow = 0; deltaRow < bh4 ; deltaRow += 2 ) {
    for ( deltaCol = 0; deltaCol < bw4 ; deltaCol += 2 ) {
        add_tpl_ref_mv( deltaRow, deltaCol, refList)
    }
}

where the call to add_tpl_ref_mv invokes the temporal sample process in section 7.6.3.5.

The process then scans positions around the block (but still within the same superblock) as follows:

for ( i = 0; i < 9; i++ ) {
    deltaRow = tplSamplePos[ i ][ 0 ]
    deltaCol = tplSamplePos[ i ][ 1 ]
    if ( check_sb_border( deltaRow, deltaCol ) ) { 
        add_tpl_ref_mv( deltaRow, deltaCol, refList)
    }
}

where tplSamplePos contains the offsets to search (in units of 4x4 pixels) and is specified as:

voffset = Max(2, h4)
hoffset = Max(2, w4)
tplSamplePos[9][2] = {
    { -2, hoffset }, { 0, hoffset },  { voffset, hoffset },
    { voffset, 0 },  { voffset, -2 }, { voffset, -4 },
    { -4, hoffset }, { voffset, 4 },  { 2, hoffset + 4 },
}

and check_sb_border checks that the position is within the same superblock as follows:

check_sb_border( deltaRow, deltaCol ) {
    sbSize = use_128x128_superblock ? BLOCK_128X128 : BLOCK_64X64
    sbSize4 = Num_4x4_Blocks_Wide[ sbSize ]
    row = (MiRow % sbSize4) + deltaRow 
    col = (MiCol % sbSize4) + deltaCol
    
    return ( row >= 0 && row < sbSize4 && col >= 0 && col < sbSize4 )
}
Temporal Sample Process

The inputs to this process are:

  • variables deltaRow and deltaCol specifying (in units of 4x4 pixels) the offset to the candidate location,

  • a variable refList specifying which set of motion vectors to predict, or -1 to signal compound prediction.

This process looks up a motion vector from the motion field and adds it into the stack.

The variable mvRow is set equal to (MiRow + deltaRow) 1.
The variable mvCol is set equal to (MiCol + deltaCol) 1.

If is_inside( mvRow, mvCol ) is equal to 0, this process terminates immediately.

The variable x8 is set equal to mvCol » 1.

The variable y8 is set equal to mvRow » 1.

(x8 and y8 represent the position of the candidate in units of 8x8 pixels.)

The process is specified as follows:

if ( refList >= 0 ) {
    for ( i = 0; i < MFMV_STACK_SIZE; i++ ) {
        candMv = MotionFieldMvs[ RefFrame[ refList ] ][ y8 ][ x8 ][ i ] 
        if ( candMv[ 0 ] == -1 << 15 )
            continue
        lower_mv_precision( candMv )
        if ( deltaRow == 0 && deltaCol == 0 ) {
            if ( Abs( candMv[ 0 ] ) >= 16 || Abs( candMv[ 1 ] ) >= 16 )
                ZeroMvContext = 1
        }
        for ( idx = 0; idx < NumMvFound; idx++ ) {
            if ( Abs( candMv[ 0 ] - RefStackMv[ idx ][ 0 ][ 0 ] ) < 4 &&
                 Abs( candMv[ 1 ] - RefStackMv[ idx ][ 0 ][ 1 ] ) < 4 )
                 break
        }
        if ( idx < NumMvFound ) {
            WeightStack[ idx ] += 2
        } else if ( NumMvFound < MAX_REF_MV_STACK_SIZE ) {
            RefStackMv[ NumMvFound ][ 0 ] = candMv
            PredStackMv[ NumMvFound ][ 0 ] = candMv
            PredStackMv[ NumMvFound ][ 0 ][ 0 ] += 4
            WeightStack[ NumMvFound ] = 2
            NumMvFound += 1
        }
    }
} else {
    for ( i = 0; i < MFMV_STACK_SIZE; i++ ) {
        candMv0 = MotionFieldMvs[ RefFrame[ 0 ] ][ y8 ][ x8 ][ i ] 
        if ( candMv0[ 0 ] == -1 << 15 )
            continue
        candMv1 = MotionFieldMvs[ RefFrame[ 1 ] ][ y8 ][ x8 ][ i ] 
        if ( candMv1[ 0 ] == -1 << 15 )
            continue
        lower_mv_precision( candMv0 )
        lower_mv_precision( candMv1 )
        if ( deltaRow == 0 && deltaCol == 0 ) {
            if ( Abs( candMv0[ 0 ] ) >= 16 || Abs( candMv0[ 1 ] ) >= 16 ) ||
                 Abs( candMv1[ 0 ] ) >= 16 || Abs( candMv1[ 1 ] ) >= 16 )
                ZeroMvContext = 1
        }
        for ( idx = 0; idx < NumMvFound; idx++ ) {
            if ( Abs( candMv0[ 0 ] - RefStackMv[ idx ][ 0 ][ 0 ] ) < 4 &&
                 Abs( candMv0[ 1 ] - RefStackMv[ idx ][ 0 ][ 1 ] ) < 4 &&
                 Abs( candMv1[ 0 ] - RefStackMv[ idx ][ 1 ][ 0 ] ) < 4 &&
                 Abs( candMv1[ 1 ] - RefStackMv[ idx ][ 1 ][ 1 ] ) < 4)
                 break
        }
        if ( idx < NumMvFound ) {
            WeightStack[ idx ] += 2
        } else if ( NumMvFound < MAX_REF_MV_STACK_SIZE ) {
            RefStackMv[ NumMvFound ][ 0 ] = candMv0
            PredStackMv[ NumMvFound ][ 0 ] = candMv0
            PredStackMv[ NumMvFound ][ 0 ][ 0 ] += 4
            RefStackMv[ NumMvFound ][ 1 ] = candMv1
            PredStackMv[ NumMvFound ][ 1 ] = candMv1
            PredStackMv[ NumMvFound ][ 1 ][ 0 ] += 4
            WeightStack[ NumMvFound ] = 2
            NumMvFound += 1
        }
    }
}

where the call to lower_mv_precision invokes the lower precision process specified in section 7.6.3.9.

Note: The motion field does not store values for PredMv, so the PredStackMv values are constructed as a simple offset of the candidate motion vectors.

Add Reference Motion Vector Process

The inputs to this process are:

  • variables mvRow and mvCol specifying (in units of 4x4 pixels) the candidate location,

  • a variable refList specifying which set of motion vectors to predict, or -1 to signal compound prediction,

  • a variable len specifying the weight attached to this motion vector.

This process examines the candidate to find matching reference frames.

If refList is greater than or equal to 0, the following applies for candList = 0..1:

  1. if RefFrames[ mvRow ][ mvCol ][ candList ] is equal to RefFrame[ refList ], the search stack process in section 7.6.3.7 is invoked with mvRow, mvCol, len, candList, refList as inputs

Otherwise (refList is equal to -1), the following applies:

  1. if RefFrames[ mvRow ][ mvCol ][ 0 ] is equal to RefFrame[ 0 ] and RefFrames[ mvRow ][ mvCol ][ 1 ] is equal to RefFrame[ 1 ], the compound search stack process in section 7.6.3.8 is invoked with mvRow, mvCol, refList, len as inputs
Search Stack Process

The inputs to this process are:

  • variables mvRow and mvCol specifying (in units of 4x4 pixels) the candidate location,

  • a variable candList specifying which list in the candidate matches our reference frame,

  • a variable len specifying the weight attached to this motion vector,

  • a variable refList specifying which set of motion vectors to predict.

This process adds motion vectors to the stack if they are not already present.

The variable candMode is set equal to YModes[ mvRow ][ mvCol ].

The candidate motion vector candMv is set as follows:

  • If ( candMode == GLOBALMV || candMode == GLOBAL_GLOBALMV) and gm_type[ RefFrame[ refList ] ] > TRANSLATION, candMv is set equal to ZeroMvs[ refList ].

  • Otherwise, candMv is set equal to Mvs[ mvRow ][ mvCol ][ candList ].

The lower precision process specified in section 7.6.3.9 is invoked with candMv.

The variable weight is set equal to len * 2.

The process depends on whether the candidate motion vector is already in the stack as follows:

  • If candMv is already equal to RefStackMv[ idx ][ 0 ] for some idx less than NumMvFound, then WeightStack[ idx ] is increased by weight

  • Otherwise, if NumMvFound is less than MAX_REF_MV_STACK_SIZE, the following ordered steps apply:

    a. RefStackMv[ NumMvFound ][ 0 ] is set equal to candMv

    b. PredStackMv[ NumMvFound ][ 0 ] is set equal to PredMvs[ mvRow ][ mvCol ][ 0 ]

    c. WeightStack[ NumMvFound ] is set equal to weight

    d. NumMvFound is set equal to NumMvFound + 1.

    e. If candMode is equal to NEWMV, NumNewMvFound is set equal to NumNewMvFound + 1.

  • Otherwise, (NumMvFound is greater than or equal to MAX_REF_MV_STACK_SIZE), the process has no effect.

Compound Search Stack Process

The inputs to this process are:

  • variables mvRow and mvCol specifying (in units of 4x4 pixels) the candidate location,

  • a variable candList specifying which list in the candidate matches our reference frame,

  • a variable len specifying the weight attached to this motion vector,

This process adds motion vectors to the stack if they are not already present.

The array candMvs (containing two motion vectors) is set equal to Mvs[ mvRow ][ mvCol ].

The variable candMode is set equal to YModes[ mvRow ][ mvCol ].

If candMode is equal to GLOBAL_GLOBALMV, for refList = 0..1 the following applies:

  • If gm_type[ RefFrame[ refList ] ] > TRANSLATION, candMvs[ refList ] is set equal to ZeroMvs[ refList ].

For i = 0..1, the lower precision process specified in section 7.6.3.9 is invoked with candMvs[ i ].

The variable weight is set equal to len * 2.

The process depends on whether the candidate motion vector is already in the stack as follows:

  • If candMvs[ 0 ] is equal to RefStackMv[ idx ][ 0 ] and candMvs[ 1 ] is equal to RefStackMv[ idx ][ 1 ] for some idx less than NumMvFound, then WeightStack[ idx ] is increased by weight

  • Otherwise, if NumMvFound is less than MAX_REF_MV_STACK_SIZE, the following ordered steps apply:

    a. RefStackMv[ NumMvFound ][ i ] is set equal to candMvs[ i ] for i = 0..1

    b. PredStackMv[ NumMvFound ][ i ] is set equal to PredMvs[ mvRow ][ mvCol ][ i ] for i = 0..1

    b. WeightStack[ NumMvFound ] is set equal to weight

    c. NumMvFound is set equal to NumMvFound + 1.

  • Otherwise, (NumMvFound is greater than or equal to MAX_REF_MV_STACK_SIZE), the process has no effect.

NumNewMvFound is incremented by 1 if all of the following are true:

  • NumMvFound is increased during this process

  • YModes[ mvRow ][ mvCol ] is equal to NEW_NEWMV

Lower Precision Process

The input to this process is a reference candMv to a motion vector array.

This process modifies the contents of the input motion vector to remove the least significant bit when high precision is not allowed.

If allow_high_precision_mv is equal to 1, this process terminates immediately.

For i = 0..1, the following applies:

if (candMv[ i ] & 1) {
    if (candMv[ i ] > 0)
        candMv[ i ]--
    else
        candMv[ i ]++
}
Sorting Process

The inputs to this process are:

  • a variable start representing the first position to be sorted,

  • a variable end representing the length of the array.

This process performs a stable sort of part of the stack of motion vectors according to the corresponding weight.

Entries in RefStackMv from start (inclusive) to end (exclusive) are sorted.

The sorting process is specified as:

while ( end > start ) {
    newEnd = start
    for ( idx = start + 1; idx < end; idx++ ) {
        if ( WeightStack[ idx - 1 ] < WeightStack[ idx ] ) {
            swap(idx - 1, idx)
            newEnd = idx
        }
    }
}

When the function swap is invoked, the entries at locations idx and idx - 1 should be swapped in each of the following arrays:

  • WeightStack
  • RefStackMv
  • PredStackMv
Context and Clamping Process

The inputs to this process are:

  • a variable refList specifying which set of motion vectors to predict, or -1 to signal compound prediction,

  • a variable numNearest specifying the number of candidates found in the immediate neighbourhood,

  • a variable numNew specifying the number of NEWMV candidates found in the immediate neighbourhood.

This process computes contexts to be used when decoding syntax elements, and overwrites the entries in RefListMv with clamped candidates from RefStackMv.

The variable bw (representing the width of the block in units of pixels) is set equal to Block_Width[ MiSize ].

The variable bh (representing the height of the block in units of pixels) is set equal to Block_Height[ MiSize ].

The variable numLists specifying the number of reference frames used for this block is set equal to ( (refList < 0) ? 2 : 1 ).

The arrays DrlCtxStack and MvCtxStack contain one or two contexts (depending on whether we are doing single or compound prediction) for each entry in the stack.

The array MvCtxStack is set as follows:

for ( list = 0; list < numLists; list++ ) {
    for ( idx = 0; idx < NumMvFound ; idx++ ) {
        refMv = RefStackMv[ idx ][ list ]
        predMv = PredStackMv[ idx ][ list ]
        v = 0
        if ( WeightStack[ idx ] >= REF_CAT_LEVEL )
            v = 2
            for ( j = 0; j < 2; j++ ) {
                if ( Abs( refMv[ j ] - predMv[ j ] ) > 4 )
                    v = 1
            }
        }
        MvCtxStack[ idx ][ list] = v
    }
}

The array DrlCtxStack is set as follows:

for ( list = 0; list < numLists; list++ ) {
    for ( idx = 0; idx < NumMvFound ; idx++ ) {
        z = 0
        if ( idx + 1 < NumMvFound ) {
            w0 = WeightStack[ idx ]
            w1 = WeightStack[ idx + 1 ]
            if (w0 >= REF_CAT_LEVEL) {
                if (w1 < REF_CAT_LEVEL) {
                    z = 2
                }
            } else {
                if (w1 < REF_CAT_LEVEL) {
                    z = 3
                }
            }
        }      
        DrlCtxStack[ idx ][ list ] = z
    }
}

Note: It is impossible for DrlCtxStack to contain the value 1.

The motion vectors are clamped and the variable AllZero is set as follows:

AllZero = 1
for ( list = 0; list < numLists; list++ ) {
    for ( idx = 0; idx < NumMvFound ; idx++ ) {
        refMv = RefStackMv[ idx ][ list ]
        refMv[ 0 ] = clamp_mv_row( refMv[ 0 ], MV_BORDER + bh * 8)
        refMv[ 1 ] = clamp_mv_col( refMv[ 1 ], MV_BORDER + bw * 8)
        if ( refList < 0 ) {
            RefStackMv[ idx ][ list ] = refMv
        } else if (idx < 2) {
            RefListMv[ refList ][ idx ] = refMv
        }
        if (idx < 3 && RefStackMv[ idx ][ list ] != ZeroMvs[ list ])
            AllZero = 0
    }
}
if ( NumMvFound < 2 ) {
    for ( list = 0; list < numLists; list++ ) {
        for ( idx = 0; idx < 2; i++ ) {
            if ( RefListMv[ list ][ idx ] != ZeroMvs[ list ] ) {
                AllZero = 0
            }
        }
    }
}

Note: The AllZero checks are done against unclamped motion vectors in the RefStackMv for single prediction, but against clamped motion vectors for compound prediction.

The variables RefMvContext and NewMvContext are set as follows:

if ( numNearest == 0 ) {
    NewMvContext = Min( NumMvFound, 1 )  // 0,1
    RefMvContext = Min( NumMvFound, 2 )  // 0,1,2
} else if ( numNearest == 1 ) {
    NewMvContext = 3 - Min( numNew, 1 ) // 2,3
    RefMvContext = Min( 3 * NumMvFound, 4)  // 0,3,4
} else {
    NewMvContext = 6 - Min( numNew, 2 ) // 4,5,6
    RefMvContext = 5
}

Note: It is impossible for RefMvContext to be equal to 6 or 7 or 8+6 or 8+7.

Has Overlappable Candidates Process

This process is triggered by a call to has_overlappable_candidates.

It returns 1 to indicate that the block has neighbours suitable for use by overlapped motion compensation, or 0 otherwise.

The process looks to see if there are any inter blocks to the left or above.

The check is only made at 8x8 granularity.

The process is specified as:

has_overlappable_candidates( ) {
  if ( AvailU ) {
    w4 = Num_4x4_Blocks_Wide[ MiSize ]
    for ( x4 = MiCol; x4 < Min( MiCols, MiCol + w4 ); x4 += 2 ) {
        if ( RefFrames[ MiRow - 1 ][ x4 | 1 ][ 0 ] > INTRA_FRAME )
            return 1
    }
  }
  if ( AvailL ) {
    h4 = Num_4x4_Blocks_High[ MiSize ]
    for ( y4 = MiRow; y4 < Min( MiRows, MiRow + h4 ); y4 += 2 ) {
        if ( RefFrames[ y4 | 1 ][ MiCol - 1 ][ 0 ] > INTRA_FRAME )
            return 1
    }
  }
  return 0
}

Find Warp Samples Process

This process is triggered when the find_warp_samples function is invoked.

The process examines the neighbouring inter predicted blocks and estimates a local warp transformation based on the motion vectors.

The process produces a variable NumSamples containing the number of valid candidates found, and an array CandList containing sorted candidates.

The variable NumSamples is set equal to 0.

The variable w4 specifying the width of the block in 4x4 pixels is set equal to Num_4x4_Blocks_Wide[ MiSize ].

The variable h4 specifying the height of the block in 4x4 pixels is set equal to Num_4x4_Blocks_High[ MiSize ].

The following ordered steps apply:

  1. The add sample process in section 7.6.5.1 is invoked with deltaRow equal to -1, and deltaCol equal to 0..(w4 - 1) (this adds candidates above the current block).

  2. The add sample process in section 7.6.5.1 is invoked with deltaCol equal to -1, and deltaRow equal to 0..(h4 - 1) (this adds candidates to the left of the current block).

  3. The add sample process in section 7.6.5.1 is invoked with deltaRow equal to -1, and deltaCol equal to -1 (this adds a candidate to the top left).

  4. The add sample process in section 7.6.5.1 is invoked with deltaRow equal to -1, and deltaCol equal to w4 (this adds a candidate to the top right).

  5. The sort sample process in section 7.6.5.2 is invoked.

Add Sample Process

The inputs to this process are:

  • a variable deltaRow specifying (in units of 4x4 pixels) how far above to look for a motion vector,

  • a variable deltaCol specifying (in units of 4x4 pixels) how far left to look for a motion vector.

The output of this process is to add a new sample to the list of candidates if it is a valid candidate and has not been seen before.

The variable mvRow is set equal to MiRow + deltaRow.

The variable mvCol is set equal to MiCol + deltaCol.

If is_inside( mvRow, mvCol ) is equal to 0, then this process immediately returns.

If RefFrames[ mvRow ][ mvCol ][ 0 ] has not been written for this frame, then this process immediately returns.

If RefFrames[ mvRow ][ mvCol ][ 0 ] is not equal to RefFrames[ 0 ], then this process immediately returns.

If RefFrames[ mvRow ][ mvCol ][ 1 ] is not equal to NONE, then this process immediately returns.

The variable candSz is set equal to MiSizes[ mvRow ][ mvCol ].

The variable candW4 is set equal to Num_4x4_Blocks_Wide[ candSz ].

The variable candH4 is set equal to Num_4x4_Blocks_High[ candSz ].

The variable candRow is set equal to mvRow & (candH4 - 1).

The variable candCol is set equal to mvCol & (candW4 - 1).

The variable midY is set equal to candRow * 4 + candH4 * 2 - 1.

The variable midX is set equal to candCol * 4 + candW4 * 2 - 1.

Note: candRow and candCol give the top-left position of the candidate block in units of 4x4 blocks. midX and midY give the central position of the candidate block in units of pixels.

A candidate array (representing source and destination locations in units of 1/8 pixels, plus a closeness measure) is specified as:

cand[ 0 ] = midY * 8
cand[ 1 ] = midX * 8
cand[ 2 ] = midY * 8 + Mvs[ candRow ][ candCol ][ 0 ][ 0 ]
cand[ 3 ] = midY * 8 + Mvs[ candRow ][ candCol ][ 0 ][ 1 ]
cand[ 4 ] = Abs( Mvs[ candRow ][ candCol ][ 0 ][ 0 ] - Mvs[ 0 ][ 0 ] ) + 
            Abs( Mvs[ candRow ][ candCol ][ 0 ][ 1 ] - Mvs[ 0 ][ 1 ] )

If this array cand is equal (in all 4 locations) to CandList[ i ] for any i < NumSamples, then this process immediately returns.

Otherwise, the following ordered steps apply:

  1. CandList[ NumSamples ][ j ] is set equal to cand[ j ] for j=0..4

  2. NumSamples is increased by 1.

Sort Sample Process

This process performs a stable sort of NumSamples candidates in CandList in order of how close the motion vectors are to the current blocks motion vector.

The number of active samples is also reduced if the difference between motion vector closenesses is too large.

The sorting process is specified as:

for (i = 1; i < NumSamples; i++) {
    for (j = 0; j < i; j++) {
        if (CandList[j][4] > CandList[i][4]) {
            for ( p = 0; p <= 4; p++ )
                temp[p] = CandList[i][p]
            for (k = i; k > j; k--) {
                for ( p = 0; p <= 4; p++ )
                    CandList[k][p] = CandList[k-1][p]
            }
            for ( p = 0; p <= 4; p++ )
                CandList[j][p] = temp[p]
            break
        }
    }
}
ret = NumSamples
for (i = NumSamples - 1; i >= 1; i--) {
    low = (i == 1) ? 1 : Max((CandList[i - 1][4] - CandList[0][4]) / (i - 1), 1)
    if ((CandList[i][4] - CandList[i - 1][4]) >= TRIM_THR * low) ret = i
}
NumSamples = Min( LEAST_SQUARES_SAMPLES_MAX, ret )

Prediction Processes

The following sections define the processes used for predicting the sample values.

These processes are triggered at points defined by function calls to predict_intra, predict_inter, predict_chroma_from_luma, and predict_palette in the residual syntax table described in section 5.8.29.

Intra Prediction Process

The intra prediction process is invoked for intra coded blocks to predict a part of the block corresponding to a transform block. When the transform size is smaller than the block size, this process can be invoked multiple times within a single block for the same plane, and the invocations are in raster order within the block.

The inputs to this process are:

  • the already reconstructed samples in the current frame CurrFrame,

  • a variable plane specifying which plane is being predicted,

  • variables x and y specifying the location of the top left sample in the CurrFrame[ plane ] array of the current transform block,

  • a variable haveLeft that is equal to 1 if there are valid samples to the left of this transform block,

  • a variable haveAbove that is equal to 1 if there are valid samples above this transform block,

  • a variable haveAboveRight that is equal to 1 if there are valid samples above the transform block to the right of this transform block,

  • a variable haveBelowLeft that is equal to 1 if there are valid samples to the left of the transform block below this transform block,

  • a variable mode specifying the type of intra prediction to apply,

  • variable log2W specifying the base 2 logarithm of the width of the region to be predicted,

  • variable log2H specifying the base 2 logarithm of the height of the region to be predicted.

The outputs of this process are intra predicted samples in the current frame CurrFrame.

The variable w is set equal to 1 << log2W.

The variable h is set equal to 1 << log2H.

The variable maxX is set equal to (MiCols * MI_SIZE) - 1.

The variable maxY is set equal to (MiRows * MI_SIZE) - 1.

If plane is greater than 0, then:

  • maxX is set equal to ((MiCols * MI_SIZE) >> subsampling_x) - 1.

  • maxY is set equal to ( (MiRows * MI_SIZE) >> subsampling_y) - 1.

The array AboveRow[ i ] for i = 0..w + h - 1 is derived as follows:

  • If haveAbove is equal to 0 and haveLeft is equal to 1, AboveRow[ i ] is set equal to CurrFrame[ plane ][ y ][ x - 1 ].

  • Otherwise, if haveAbove is equal to 0 and haveLeft is equal to 0, AboveRow[ i ] is set equal to ( 1 << ( BitDepth - 1 ) ) - 1.

  • Otherwise, the following applies:

    • The variable aboveLimit is set equal to Min( maxX, x + ( haveAboveRight ? 2 * txw : txw ) - 1 ).

    • AboveRow[ i ] is set equal to CurrFrame[ plane ][ y-1 ][ Min(aboveLimit, x+i) ].

The array LeftCol[ i ] for i = 0..w + h - 1 is derived as follows:

  • If haveLeft is equal to 0 and haveAbove is equal to 1, LeftCol[ i ] is set equal to CurrFrame[ plane ][ y - 1 ][ x ].

  • Otherwise, if haveLeft is equal to 0 and haveAbove is equal to 0, LeftCol[ i ] is set equal to ( 1 << ( BitDepth - 1 ) ) + 1.

  • Otherwise, the following applies:

    • The variable leftLimit is set equal to Min( maxY, y + ( haveBelowLeft ? 2 * txh : txh ) - 1 ).

    • LeftCol[ i ] is set equal to CurrFrame[ plane ][ Min(leftLimit, y+i) ][ x-1 ].

The array AboveRow[ i ] for i = -1 is specified by:

  • If haveAbove is equal to 1 and haveLeft is equal to 1, AboveRow[ -1 ] is set equal to CurrFrame[ plane ][ y-1 ][ x-1 ].

  • Otherwise if haveAbove is equal to 1, AboveRow[ -1 ] is set equal to CurrFrame [ plane ][ y - 1 ][ x ].

  • Otherwise if haveLeft is equal to 1, AboveRow[ -1 ] is set equal to CurrFrame [ plane ][ y ][ x - 1 ].

  • Otherwise, AboveRow[ -1 ] is set equal to 1 << ( BitDepth - 1 ).

The array LeftCol[ i ] for i = -1 is set equal to AboveRow[ -1 ].

A 2D array named pred containing the intra predicted samples is constructed as follows:

  • If is_directional_mode( mode ) is true, the following ordered steps apply:

    1. The variable angleDelta is derived as follows:

      • If plane is equal to 0, angleDelta is set equal to AngleDeltaY.

      • Otherwise (plane is not equal to 0), angleDelta is set equal to AngleDeltaUV.

    2. The variable pAngle is set equal to ( Mode_To_Angle[ mode ] + angleDelta * ANGLE_STEP ).

    3. If pAngle is not equal to 90 and pAngle is not equal to 180, the following applies:

      • If haveAbove is equal to 1, the following steps apply:

        • The intra edge filter strength selection process specified in section 7.7.1.1 is invoked with the parameters w and pAngle - 90, and the result stored in the variable strength.

        • The variable numPx is set equal to Min( ( ( pAngle < 90 ) && haveAboveRight ) ? 2 * w : w, maxX - x + 1 ) + 1.

        • The intra edge filter process specified in section 7.7.1.2 is invoked with the parameters numPx, strength and 0.

      • If haveLeft is equal to 1, the following steps apply:

        • The intra edge filter strength selection process specified in section 7.7.1.1 is invoked with the parameters h and pAngle - 180, and the result stored in the variable strength.

        • The variable numPx is set equal to Min( ( ( pAngle > 180 ) && haveBelowLeft ) ? 2 * h : h, maxY - y + 1 ) + 1.

        • The intra edge filter process specified in section 7.7.1.2 is invoked with the parameters numPx, strength and 1.

    4. The variable dx is derived as follows:

      • If pAngle is greater than 0 and less than 90, dx is set equal to Dr_Intra_Derivative[ pAngle ].

      • Otherwise, if pAngle is greater than 90 and less than 180, dx is set equal to Dr_Intra_Derivative[ 180 - pAngle ].

      • Otherwise, dx is undefined.

    5. The variable dy is derived as follows:

      • If pAngle is greater than 90 and less than 180, dy is set equal to Dr_Intra_Derivative[ pAngle - 90 ].

      • Otherwise, if pAngle is greater than 180 and less than 270, dy is set equal to Dr_Intra_Derivative[ 270 - pAngle ].

      • Otherwise, dy is undefined.

    6. If pAngle is greater than 0 and less than 90, the following steps apply for i = 0..h-1, for j = 0..w-1:

      • The variable idx is set equal to ( i + 1 ) * dx.

      • The variable base is set equal to idx >> 8.

      • The variable shift is set equal to idx & 0xFF.

      • The variable max_base_x is set equal to w + h - 1.

      • If base is less than max_base_x, pred[ i ][ j ] is set equal to Clip1( Round2( AboveRow[ base ] * ( 256 - shift ) + AboveRow[ base + 1 ] * shift, 8 ) ).

      • Otherwise (base is greater than or equal to max_base_x), pred[ i ][ j ] is set equal to AboveRow[ max_base_x ].

    7. Otherwise, if pAngle is greater than 90 and pAngle is less than 180, the following steps apply for i = 0..h-1, for j = 0..w-1:

      • The variable idx is set equal to ( j << 8 ) - ( i + 1 ) * dx.

      • The variable base is set equal to idx >> 8.

      • If base is greater than or equal to -1, the following steps apply:

        • The variable shift is set equal to idx & 0xFF.

        • pred[ i ][ j ] is set equal to Clip1( Round2( AboveRow[ base ] * ( 256 - shift ) + AboveRow[ base + 1 ] * shift, 8 ) ).

      • Otherwise (base is less than -1), the following steps apply:

        • The variable idx is set equal to ( i << 8 ) - ( j + 1 ) * dy.

        • The variable base is set equal to idx >> 8.

        • The variable shift is set equal to idx & 0xFF.

        • pred[ i ][ j ] is set equal to Clip1( Round2( LeftCol[ base ] * ( 256 - shift ) + LeftCol[ base + 1 ] * shift, 8 ) ).

    8. Otherwise, if pAngle is greater than 180 and pAngle is less than 270, the following steps apply for i = 0..h-1, for j = 0..w-1:

      • The variable idx is set equal to ( j + 1 ) * dy.

      • The variable base is set equal to idx >> 8.

      • The variable shift is set equal to idx & 0xFF.

      • The variable max_base_y is set equal to w + h - 1.

      • If base is less than max_base_y, pred[ i ][ j ] is set equal to Clip1( Round2( LeftCol[ base ] * ( 256 - shift ) + LeftCol[ base + 1 ] * shift, 8 ) ).

      • Otherwise (base is greater than or equal to max_base_y), pred[ i ][ j ] is set equal to LeftCol[ max_base_y ].

    9. Otherwise, if pAngle is equal to 90, pred[ i ][ j ] is set equal to AboveRow[ j ] with j = 0..w-1 and i = 0..h-1 (each row of the block is filled with a copy of AboveRow).

    10. Otherwise, if pAngle is equal to 180, pred[ i ][ j ] is set equal to LeftCol[ i ] with j = 0..w-1 and i = 0..h-1 (each column of the block is filled with a copy of LeftCol).

  • Otherwise if mode is equal to V_PRED, pred[ i ][ j ] is set equal to AboveRow[ j ] with j = 0..w-1 and i = 0..h-1 (each row of the block is filled with a copy of AboveRow).

  • Otherwise if mode is equal to H_PRED, pred[ i ][ j ] is set equal to LeftCol[ i ] with j = 0..w-1 and i = 0..h-1 (each column of the block is filled with a copy of LeftCol).

  • Otherwise if mode is equal to D207_PRED, the following applies for i = 0..h-1:

    1. pred[ i ][ j ] = Round2( LeftCol[ i + j/2 ] + LeftCol[ i + 1 + j/2 ], 1 ) for even values of j in the range 0..w-2

    2. pred[ i ][ j ] = Round2( LeftCol[ i + j/2 ] + 2 * LeftCol[ i + 1 + j/2 ] + LeftCol[ i + 2 + j/2 ], 2 ) for odd values of j in the range 0..w-1

  • Otherwise if mode is equal to D45_PRED, the following applies for i = 0..h-1, for j = 0..w-1:

    1. pred[ i ][ j ] = Round2( AboveRow[ i + j ] + 2 * AboveRow[ i + j + 1 ] + AboveRow[ i + j + 1 ], 2 ) if (i + j + 2 >= w + h)

    2. pred[ i ][ j ] = Round2( AboveRow[ i + j ] + 2 * AboveRow[ i + j + 1 ] + AboveRow[ i + j + 2 ], 2 ) if (i + j + 2 < w + h)

  • Otherwise if mode is equal to D63_PRED, the following applies for i = 0..h-1, for j = 0..w-1:

    1. pred[ i ][ j ] = Round2( AboveRow[ i/2 + j ] + AboveRow[ i/2 + j + 1 ], 1 ) for even values of j in the range 0..h-2

    2. pred[ i ][ j ] = Round2( AboveRow[ i/2 + j ] + 2 * AboveRow[ i/2 + j + 1 ] + AboveRow[ i/2 + j + 2 ], 2 ) for odd values of j in the range 0..h-1.

  • Otherwise if mode is equal to D117_PRED, the following applies:

    1. pred[ 0 ][ j ] = Round2( AboveRow[ j - 1 ] + AboveRow[ j ], 1 ) for j = 0..w-1

    2. pred[ 1 ][ 0 ] = Round2( LeftCol[ 0 ] + 2 * AboveRow[ -1 ] + AboveRow[ 0 ], 2 )

    3. pred[ 1 ][ j ] = Round2( AboveRow[ j - 2 ] + 2 * AboveRow[ j - 1 ] + AboveRow[ j ], 2 ) for j = 1..w-1

    4. pred[ 2 ][ 0 ] = Round2( AboveRow[ -1 ] + 2 * LeftCol[ 0 ] + LeftCol[ 1 ], 2 )

    5. pred[ i ][ 0 ] = Round2( LeftCol[ i - 3 ] + 2 * LeftCol[ i - 2 ] + LeftCol[ i - 1 ], 2 ) for i = 3..h-1

    6. pred[ i ][ j ] = pred[ i - 2 ][ j - 1 ] for i = 2..h-1, for j = 1..w-1

  • Otherwise if mode is equal to D135_PRED, the following applies:

    1. pred[ 0 ][ 0 ] = Round2( LeftCol[ 0 ] + 2 * AboveRow[ -1 ] + AboveRow[ 0 ], 2 )

    2. pred[ 0 ][ j ] = Round2( AboveRow[ j - 2 ] + 2 * AboveRow[ j - 1 ] + AboveRow[ j ], 2 ) for j = 1..w-1

    3. pred[ 1 ][ 0 ] = Round2( AboveRow[ -1 ] + 2 * LeftCol[ 0 ] + LeftCol[ 1 ], 2 )

    4. pred[ i ][ 0 ] = Round2( LeftCol[ i - 2 ] + 2 * LeftCol[ i - 1 ] + LeftCol[ i ], 2 ) for i = 2..h-1

    5. pred[ i ][ j ] = pred[ i - 1 ][ j - 1 ] for i = 1..h-1, for j = 1..w-1

  • Otherwise if mode is equal to D153_PRED, the following applies:

    1. pred[ 0 ][ 0 ] = Round2( LeftCol[ 0 ] + AboveRow[ -1 ], 1 )

    2. pred[ i ][ 0 ] = Round2( LeftCol[ i - 1 ] + LeftCol[ i ], 1 ) for i = 1..h-1

    3. pred[ 0 ][ 1 ] = Round2( LeftCol[ 0 ] + 2 * AboveRow[ -1 ] + AboveRow[ 0 ], 2 )

    4. pred[ 1 ][ 1 ] = Round2( AboveRow[ -1 ] + 2 * LeftCol[ 0 ] + LeftCol[ 1 ], 2 )

    5. pred[ i ][ 1 ] = Round2( LeftCol[ i - 2 ] + 2 * LeftCol[ i - 1 ] + LeftCol[ i ], 2 ) for i = 2..h-1

    6. pred[ 0 ][ j ] = Round2( AboveRow[ j - 3 ] + 2 * AboveRow[ j - 2 ] + AboveRow[ j - 1 ], 2 ) for j = 2..w-1

    7. pred[ i ][ j ] = pred[ i - 1 ][ j - 2 ] for i = 1..h-1, for j = 2..w-1

  • Otherwise if mode is equal to TM_PRED, the following ordered steps apply for i = 0..h-1, for j = 0..w-1:

    1. The variable base is set equal to AboveRow[ j ] + LeftCol[ i ] - AboveRow[ -1 ].

    2. The variable pLeft is set equal to Abs( base - LeftCol[ i ]).

    3. The variable pTop is set equal to Abs( base - AboveRow[ j ]).

    4. The variable pTopLeft is set equal to Abs( base - AboveRow[ -1 ] ).

    5. If pLeft <= pTop and pLeft <= pTopLeft, pred[ i ][ j ] is set equal to LeftCol[ i ].

    6. Otherwise, if pTop <= pTopLeft, pred[ i ][ j ] is set equal to AboveRow[ j ].

    7. Otherwise, pred[ i ][ j ] is set equal to AboveRow[ -1 ].

  • Otherwise if mode is equal to SMOOTH_PRED, the following ordered steps apply for i = 0..h-1, for j = 0..w-1:

    1. The array smWeightsX is set dependent on the value of log2W according to the following table:

      log2W smWeightsX
      2 Sm_Weights_Tx_4x4
      3 Sm_Weights_Tx_8x8
      4 Sm_Weights_Tx_16x16
      5 Sm_Weights_Tx_32x32
    2. The array smWeightsY is set dependent on the value of log2H according to the following table:

      log2H smWeightsY
      2 Sm_Weights_Tx_4x4
      3 Sm_Weights_Tx_8x8
      4 Sm_Weights_Tx_16x16
      5 Sm_Weights_Tx_32x32
    3. The variable smoothPred is set as follows:

      smoothPred =   smWeightsY[ i ] * AboveRow[ j ] +
                  ( 256 - smWeightsY[ i ] ) * LeftCol[ h - 1 ] +
                    smWeightsX[ j ] * LeftCol[ i ] +
                  ( 256 - smWeightsX[ j ] ) * AboveRow[ w - 1 ]
      
    4. pred[ i ][ j ] is set equal to Clip1( Round2( smoothPred, 9 ) ).

  • Otherwise if mode is equal to SMOOTH_V_PRED, the following ordered steps apply for i = 0..h-1, for j = 0..w-1:

    1. The array smWeights is set dependent on the value of log2H according to the following table:

      log2H smWeights
      2 Sm_Weights_Tx_4x4
      3 Sm_Weights_Tx_8x8
      4 Sm_Weights_Tx_16x16
      5 Sm_Weights_Tx_32x32
    2. The variable smoothPred is set as follows:

      smoothPred =   smWeights[ i ] * AboveRow[ j ] +
                  ( 256 - smWeights[ i ] ) * LeftCol[ h - 1 ]
      
    3. pred[ i ][ j ] is set equal to Clip1( Round2( smoothPred, 8 ) ).

  • Otherwise if mode is equal to SMOOTH_H_PRED, the following ordered steps apply for i = 0..h-1, for j = 0..w-1:

    1. The array smWeights is set dependent on the value of log2W according to the following table:

      log2W smWeights
      2 Sm_Weights_Tx_4x4
      3 Sm_Weights_Tx_8x8
      4 Sm_Weights_Tx_16x16
      5 Sm_Weights_Tx_32x32
    2. The variable smoothPred is set as follows:

      smoothPred =   smWeights[ j ] * LeftCol[ i ] +
                  ( 256 - smWeights[ j ] ) * AboveRow[ w - 1 ]
      
    3. pred[ i ][ j ] is set equal to Clip1( Round2( smoothPred, 8 ) ).

  • Otherwise if mode is equal to DC_PRED and haveLeft is equal to 1 and haveAbove is equal to 1, pred[ i ][ j ] is set equal to avg with i = 0..h-1 and j = 0..w-1. The variable avg (the average of the samples in union of AboveRow and LeftCol) is specified as follows:

    sum = 0
    for ( k = 0; k < h; k++ )
        sum += LeftCol[ k ]
    for ( k = 0; k < w; k++ )
        sum += AboveRow[ k ]
    avg = (sum + ( ( w + h ) >> 1 ) ) / ( w + h )
    
  • Otherwise if mode is equal to DC_PRED and haveLeft is equal to 1 and haveAbove is equal to 0, pred[ i ][ j ] is set equal to leftAvg with i = 0..h-1 and j = 0..w-1. The variable leftAvg is specified as follows:

    sum = 0
    for ( k = 0; k < h; k++ ) {
        sum += LeftCol[ k ]
    }
    leftAvg = (sum + (1 << (log2H - 1) ) ) >> log2H
    
  • Otherwise if mode is equal to DC_PRED and haveLeft is equal to 0 and haveAbove is equal to 1, pred[ i ][ j ] is set equal to aboveAvg with i = 0..h-1 and j = 0..w-1. The variable aboveAvg is specified as follows:

    sum = 0
    for ( k = 0; k < w; k++ ) {
        sum += AboveRow[ k ]
    }
    aboveAvg = (sum + (1 << (log2W - 1) ) ) >> log2W
    
  • Otherwise (mode is DC_PRED), pred[ i ][ j ] is set equal to 1 << ( BitDepth - 1 ) with i = 0..h-1 and j = 0..w-1.

The current frame is updated as follows:

  • CurrFrame[ plane ][ y + i ][ x + j ] is set equal to pred[ i ][ j ] for i = 0..h-1 and j = 0..w-1.
Intra Edge Filter Strength Selection Process

The inputs to this process are:

  • a transform size sz,

  • an angle delta

The output is an intra edge filter strength from 0 to 3 inclusive.

The variable d is set equal to Abs( delta ).

The output is generated by the following procedure:

  1. If sz is equal to 4, return ( d >= 56 && d < 90 ) ? 1 : 0.

  2. If sz is equal to 8, return ( d < 8 || d >= 90 ) ? 0 : ( d < 32 ) ? 1 : 3.

  3. If sz is equal to 16, return ( d < 4 || d >= 90 ) ? 0 : ( d < 16 ) ? 1 : 3.

  4. Otherwise ( sz is equal to 32 ), return ( d < 16 ) ? 2 : ( d < 90 ) ? 3 : 0.

Intra Edge Filter Process

The inputs to this process are:

  • A size sz,

  • A filter strength strength between 0 and 3 inclusive,

  • An edge direction left (when equal to 1, it specifies a vertical edge; when equal to 0, it specifies a horizontal edge.

The process filters the LeftCol (if left is equal to 1) or AboveRow (if left is equal to 0) arrays.

If strength is equal to 0, the process returns without doing anything.

Otherwise (strength is not equal to 0), the following ordered steps apply for i = 1..sz-2:

  1. The variable s is set equal to 0.

  2. The following steps now apply for j = 0..INTRA_EDGE_TAPS-1.

    a. The variable k is set equal to Clip3( 0, sz - 1, i - 2 + j ).

    b. The variable s is incremented by Intra_Edge_Kernel[ strength - 1 ][ j ] * ( left ? LeftCol[ k - 1 ] : AboveRow[ k - 1 ] ).

  3. If left is equal to 1, LeftCol[ i - 1 ] is set equal to ( s + 8 ) >> 4.

  4. If left is equal to 0, AboveRow[ i - 1 ] is set equal to ( s + 8 ) >> 4.

The array Intra_Edge_Kernel is specified as follows:

Intra_Edge_Kernel[INTRA_EDGE_KERNELS][INTRA_EDGE_TAPS] = {
  { 0, 4, 8, 4, 0 },
  { 0, 5, 6, 5, 0 },
  { 2, 4, 4, 4, 2 }
}

Inter Prediction Process

The inter prediction process is invoked for inter coded blocks and interintra blocks. The inputs to this process are:

  • a variable plane specifying which plane is being predicted,

  • variables x and y specifying the location of the top left sample in the CurrFrame[ plane ] array of the region to be predicted,

  • variables w and h specifying the width and height of the region to be predicted,

  • variables candRow and candCol specifying the location (in units of 4x4 blocks) of the motion vector information to be used.

The outputs of this process are predicted samples in the current frame CurrFrame.

This process is triggered by a function call to predict_inter.

The variable isInterInter is set equal to RefFrames[ candRow ][ candCol ][ 1 ] > INTRA_FRAME.

The variable isCompound is set equal to RefFrames[ candRow ][ candCol ][ 1 ] >= INTRA_FRAME.

The prediction arrays are formed by the following ordered steps:

  1. The variable refList is set equal to 0.

  2. The variable useWarp is derived as follows:

    • If w < 8 or h < 8, useWarp is set equal to 0.

    • Otherwise, if motion_mode is equal to LOCALWARP, useWarp is set equal to 1.

    • Otherwise, if (YMode == GLOBALMV || YMode == GLOBAL_GLOBALMV) and gm_type[ RefFrame[ refList ] ] > TRANSLATION, useWarp is set equal to 1.

    • Otherwise, useWarp is set equal to 0.

  3. If plane is equal to 0 and motion_mode is equal to LOCALWARP, the warp estimation process in section 7.7.2.6 is invoked.

  4. The motion vector array mv is set equal to Mvs[ candRow ][ candCol ][ refList ].

  5. The variable refIdx specifying which reference frame is being used is set equal to ref_frame_idx[ RefFrame[ refList ] - LAST_FRAME ].

  6. The motion vector scaling process in section 7.7.2.1 is invoked with plane, refIdx, x, y, mv as inputs and the output being the initial location startX, startY, and the step sizes stepX, stepY.

  7. If useWarp is equal to 1, the block warp process in section 7.7.2.3 is invoked with plane, refList, x, y, i8, j8, w, h as inputs and the output is assigned to the 2D array preds[ refList ] for i8 = 0..((h-1) >> 3) and for j8 = 0..((w-1) >> 3).

  8. If useWarp is equal to 0, the block inter prediction process in section 7.7.2.2 is invoked with plane, refIdx, startX, startY, stepX, stepY, w, h, candRow, candCol as inputs and the output is assigned to the 2D array preds[ refList ].

  9. If isInterInter is equal to 1, then the variable refList is set equal to 1 and steps 4 to 9 are repeated to form the prediction for the second reference.

If isInterIntra is equal to 1, the following ordered steps apply:

  1. The variable mode is set as follows:

    • If interintra_mode is equal to II_DC_PRED, mode is set equal to DC_PRED.

    • Otherwise if interintra_mode is equal to II_V_PRED, mode is set equal to V_PRED,

    • Otherwise if interintra_mode is equal to II_H_PRED, mode is set equal to H_PRED,

    • Otherwise (interintra_mode is equal to II_SMOOTH_PRED), mode is set equal to SMOOTH_PRED.

  2. The variable haveLeft is set equal to AvailL

  3. The variable haveAbove is set equal to AvailU

  4. The variable haveAboveRight is set equal to 0

  5. The variable haveBelowLeft is set equal to 0

  6. The variable log2W is set equal to log2( w )

  7. The variable log2H is set equal to log2( h )

  8. The intra prediction process specified in section 7.7.1 is invoked with plane, x, y, haveLeft, haveAbove, haveAboveRight, haveBelowLeft, mode, log2W, log2H as inputs. (This will write intra predicted samples into CurrFrame.)

An array named Mask is prepared as follows:

  • If compound_type is equal to COMPOUND_WEDGE and plane is equal to 0, the wedge mask process in section 7.7.2.9 is invoked with w, h as inputs.

  • Otherwise if compound_type is equal to COMPOUND_INTRA, the inter intra mask process in section 7.7.2.11 is invoked with preds, plane, x, y, w, h as inputs.

  • Otherwise if compound_type is equal to COMPOUND_SEG and plane is equal to 0, the segment mask process in section 7.7.2.10 is invoked with preds, w, h as inputs.

  • Otherwise, no mask array is needed.

The inter predicted samples are then derived as follows:

  • If isCompound is equal to 0, CurrFrame[ plane ][ y + i ][ x + j ] is set equal to Clip1( Round2( preds[ 0 ][ i ][ j ], 9) ) for i = 0..h-1 and j = 0..w-1.

  • Otherwise if compound_type is equal to COMPOUND_AVERAGE, CurrFrame[ plane ][ y + i ][ x + j ] is set equal to Clip1( Round2( preds[ 0 ][ i ][ j ] + preds[ 1 ][ i ][ j ], 10 ) ) for i = 0..h-1 and j = 0..w-1.

  • Otherwise, the mask blend process in section 7.7.2.12 is invoked with preds, plane, x, y, w, h as inputs.

If motion_mode is equal to OBMC, the overlapped motion compensation in section 7.7.2.7 is invoked with plane, x, y, w, h as inputs.

Motion Vector Scaling Process

The inputs to this process are:

  • a variable plane specifying which plane is being predicted,

  • a variable refIdx specifying which reference frame is being used,

  • variables x and y specifying the location of the top left sample in the CurrFrame[ plane ] array of the region to be predicted,

  • a variable mv specifying the clamped motion vector (in units of 1/8 th of a luma pixel, i.e. with 3 fractional bits).

The outputs of this process are the variables startX and startY giving the reference block location in units of 1/1024 th of a sample, and variables xStep and yStep giving the step size in units of 1/1024 th of a sample.

This process is responsible for computing the sampling locations in the reference frame based on the motion vector. The sampling locations are also adjusted to compensate for any difference in the size of the reference frame compared to the current frame.

It is a requirement of bitstream conformance that all the following conditions are satisfied:

  • 2 * FrameWidth >= RefFrameWidth[ refIdx ]

  • 2 * FrameHeight >= RefFrameHeight[ refIdx ]

  • FrameWidth <= 16 * RefFrameWidth[ refIdx ]

  • FrameHeight <= 16 * RefFrameHeight[ refIdx ]

A variable xScale is set equal to (RefFrameWidth[ refIdx ] << REF_SCALE_SHIFT + ( FrameWidth / 2 ) ) / FrameWidth.

A variable yScale is set equal to (RefFrameHeight[ refIdx ] << REF_SCALE_SHIFT + ( FrameHeight / 2 ) ) / FrameHeight.

(xScale and yScale specify the size of the reference frame relative to the current frame in units where (1 << 14) is equivalent to both frames having the same size.)

The variables subX and subY are set equal to the subsampling for the current plane as follows:

  • If plane is equal to 0, subX is set equal to 0 and subY is set equal to 0.

  • Otherwise, subX is set equal to subsampling_x and subY is set equal to subsampling_y.

The variable halfSample (representing half the size of a sample in units of 1/16 th of a sample) is set equal to ( 1 « ( SUBPEL_BITS - 1 ) ).

The variable origY is set equal to ( (y « SUBPEL_BITS) + ( ( 2 * mv[0] ) » subY ) + halfSample ).

The variable origX is set equal to ( (x « SUBPEL_BITS) + ( ( 2 * mv[1] ) » subX ) + halfSample ).

(origX and origY specify the location of the centre of the sample at the top-left corner of the reference block in the current frame’s coordinate system in units of 1/16 th of a sample, i.e. with SUBPEL_BITS=4 fractional bits.)

The variable baseX is set equal to (x * xScale - ( halfSample « REF_SCALE_SHIFT ) ).

The variable baseY is set equal to (y * yScale - ( halfSample « REF_SCALE_SHIFT ) ).

(baseX and baseY specify the location of the top-left corner of the block in the reference frame in the reference frame’s coordinate system with 18 fractional bits.)

The variable off (containing a rounding offset for the filter tap selection) is set equal to ( ( 1 « (SCALE_SUBPEL_BITS - SUBPEL_BITS) ) / 2 ).

The output variable startX is set equal to (Round2Signed( baseX, REF_SCALE_SHIFT + SUBPEL_BITS - SCALE_SUBPEL_BITS) + off).

The output variable startY is set equal to (Round2Signed( baseY, REF_SCALE_SHIFT + SUBPEL_BITS - SCALE_SUBPEL_BITS) + off).

(startX and startY specify the location of the top-left corner of the block in the reference frame in the reference frame’s coordinate system with SCALE_SUBPEL_BITS=10 fractional bits.)

The output variable stepX is set equal to Round2Signed( xScale, REF_SCALE_SHIFT - SCALE_SUBPEL_BITS).

The output variable stepY is set equal to Round2Signed( yScale, REF_SCALE_SHIFT - SCALE_SUBPEL_BITS).

(stepX and stepY are the size of one current frame sample in the reference frame’s coordinate system with 10 fractional bits.)

Block Inter Prediction Process

The inputs to this process are:

  • a variable plane,

  • a variable refIdx specifying which reference frame is being used,

  • variables x and y giving the block location with in units of 1/1024 th of a sample,

  • variables xStep and yStep giving the step size in units of 1/1024 th of a sample,

  • variables w and h giving the width and height of the block in units of samples,

  • variables candRow and candCol specifying the location (in units of 4x4 blocks) of the motion vector information to be used.

The output from this process is the 2D array named pred containing inter predicted samples.

A variable ref specifying the reference frame contents is set equal to FrameStore[ refIdx ].

The variables subX and subY are set equal to the subsampling for the current plane as follows:

  • If plane is equal to 0, subX is set equal to 0 and subY is set equal to 0.

  • Otherwise, subX is set equal to subsampling_x and subY is set equal to subsampling_y.

The variable lastX is set equal to ( (RefFrameWidth[ refIdx ] + subX) >> subX) - 1.

The variable lastY is set equal to ( (RefFrameHeight[ refIdx ] + subY) >> subY) - 1.

(lastX and lastY specify the coordinates of the bottom right sample of the reference plane.)

The variable intermediateHeight specifying the height required for the intermediate array is set equal to (((h - 1) * yStep + (1 « SCALE_SUBPEL_BITS) - 1) >> SCALE_SUBPEL_BITS) + 8.

The sub-sample interpolation is effected via two one-dimensional convolutions. First a horizontal filter is used to build up a temporary array, and then this array is vertically filtered to obtain the final prediction. The fractional parts of the motion vectors determine the filtering process. If the fractional part is zero, then the filtering is equivalent to a straight sample copy.

The filtering is applied as follows:

  • The array intermediate is specified as follows:

    interpFilter = InterpFilters[ candRow ][ candCol ][ 1 ]
    if ( w <= 4 ) {
        if (interpFilter == EIGHTTAP || interpFilter == EIGHTTAP_SHARP) {
            interpFilter = 4
        } else if (interpFilter == EIGHTTAP_SMOOTH) {
            interpFilter = 5
        }
    }
    for ( r = 0; r < intermediateHeight; r++ ) {
        for ( c = 0; c < w; c++ ) {
            s = 0
            p = x + xStep * c
            for ( t = 0; t < 8; t++ )
                s += Subpel_Filters[ interpFilter ][ (p >> 6) & 15 ][ t ] *
                  ref[ plane ] [ Clip3( 0, lastY, (y >> 10) + r - 3 ) ]
                               [ Clip3( 0, lastX, (p >> 10) + t - 3 ) ]
            intermediate[ r ][ c ] = Round2(s, 5)
        }
    }
    
  • The array pred is specified as follows:

    interpFilter = InterpFilters[ candRow ][ candCol ][ 0 ]
    if ( h <= 4 ) {
        if (interpFilter == EIGHTTAP || interpFilter == EIGHTTAP_SHARP) {
            interpFilter = 4
        } else if (interpFilter == EIGHTTAP_SMOOTH) {
            interpFilter = 5
        }
    }
    for ( r = 0; r < h; r++ ) {
        for ( c = 0; c < w; c++ ) {
            s = 0
            p = (y & 1023) + yStep * r
            for ( t = 0; t < 8; t++ )
                s += Subpel_Filters[ interpFilter ][ (p >> 6) & 15 ][ t ] *
                  intermediate[ (p >> 10) + t ][ c ]
            pred[ r ][ c ] = s
        }
    }
    

    where the constant array Subpel_Filters is specified as:

    Subpel_Filters[ 6 ][ 16 ][ 8 ] = {
      {
        { 0, 0, 0, 128, 0, 0, 0, 0 },
        { 0, 2, -6, 126, 8, -2, 0, 0 },
        { 0, 2, -10, 122, 18, -4, 0, 0 },
        { 0, 2, -12, 116, 28, -8, 2, 0 },
        { 0, 2, -14, 110, 38, -10, 2, 0 },
        { 0, 2, -14, 102, 48, -12, 2, 0 },
        { 0, 2, -16, 94, 58, -12, 2, 0 },
        { 0, 2, -14, 84, 66, -12, 2, 0 },
        { 0, 2, -14, 76, 76, -14, 2, 0 },
        { 0, 2, -12, 66, 84, -14, 2, 0 },
        { 0, 2, -12, 58, 94, -16, 2, 0 },
        { 0, 2, -12, 48, 102, -14, 2, 0 },
        { 0, 2, -10, 38, 110, -14, 2, 0 },
        { 0, 2, -8, 28, 116, -12, 2, 0 },
        { 0, 0, -4, 18, 122, -10, 2, 0 },
        { 0, 0, -2, 8, 126, -6, 2, 0 }
      },
      {
        { 0, 0, 0, 128, 0, 0, 0, 0 },
        { 0, 2, 28, 62, 34, 2, 0, 0 },
        { 0, 0, 26, 62, 36, 4, 0, 0 },
        { 0, 0, 22, 62, 40, 4, 0, 0 },
        { 0, 0, 20, 60, 42, 6, 0, 0 },
        { 0, 0, 18, 58, 44, 8, 0, 0 },
        { 0, 0, 16, 56, 46, 10, 0, 0 },
        { 0, -2, 16, 54, 48, 12, 0, 0 },
        { 0, -2, 14, 52, 52, 14, -2, 0 },
        { 0, 0, 12, 48, 54, 16, -2, 0 },
        { 0, 0, 10, 46, 56, 16, 0, 0 },
        { 0, 0, 8, 44, 58, 18, 0, 0 },
        { 0, 0, 6, 42, 60, 20, 0, 0 },
        { 0, 0, 4, 40, 62, 22, 0, 0 },
        { 0, 0, 4, 36, 62, 26, 0, 0 },
        { 0, 0, 2, 34, 62, 28, 2, 0 }
      },
      {
        { 0, 0, 0, 128, 0, 0, 0, 0 },
        { -2, 2, -6, 126, 8, -2, 2, 0 },
        { -2, 6, -12, 124, 16, -6, 4, -2 },
        { -2, 8, -18, 120, 26, -10, 6, -2 },
        { -4, 10, -22, 116, 38, -14, 6, -2 },
        { -4, 10, -22, 108, 48, -18, 8, -2 },
        { -4, 10, -24, 100, 60, -20, 8, -2 },
        { -4, 10, -24, 90, 70, -22, 10, -2 },
        { -4, 12, -24, 80, 80, -24, 12, -4 },
        { -2, 10, -22, 70, 90, -24, 10, -4 },
        { -2, 8, -20, 60, 100, -24, 10, -4 },
        { -2, 8, -18, 48, 108, -22, 10, -4 },
        { -2, 6, -14, 38, 116, -22, 10, -4 },
        { -2, 6, -10, 26, 120, -18, 8, -2 },
        { -2, 4, -6, 16, 124, -12, 6, -2 },
        { 0, 2, -2, 8, 126, -6, 2, -2 }
      },
      {
        { 0, 0, 0, 128, 0, 0, 0, 0 },
        { 0, 0, 0, 120, 8, 0, 0, 0 },
        { 0, 0, 0, 112, 16, 0, 0, 0 },
        { 0, 0, 0, 104, 24, 0, 0, 0 },
        { 0, 0, 0, 96, 32, 0, 0, 0 },
        { 0, 0, 0, 88, 40, 0, 0, 0 },
        { 0, 0, 0, 80, 48, 0, 0, 0 },
        { 0, 0, 0, 72, 56, 0, 0, 0 },
        { 0, 0, 0, 64, 64, 0, 0, 0 },
        { 0, 0, 0, 56, 72, 0, 0, 0 },
        { 0, 0, 0, 48, 80, 0, 0, 0 },
        { 0, 0, 0, 40, 88, 0, 0, 0 },
        { 0, 0, 0, 32, 96, 0, 0, 0 },
        { 0, 0, 0, 24, 104, 0, 0, 0 },
        { 0, 0, 0, 16, 112, 0, 0, 0 },
        { 0, 0, 0, 8, 120, 0, 0, 0 }
      },
      {
        { 0, 0, 0, 128, 0, 0, 0, 0 },
        { 0, 0, -4, 126, 8, -2, 0, 0 },
        { 0, 0, -8, 122, 18, -4, 0, 0 },
        { 0, 0, -10, 116, 28, -6, 0, 0 },
        { 0, 0, -12, 110, 38, -8, 0, 0 },
        { 0, 0, -12, 102, 48, -10, 0, 0 },
        { 0, 0, -14, 94, 58, -10, 0, 0 },
        { 0, 0, -12, 84, 66, -10, 0, 0 },
        { 0, 0, -12, 76, 76, -12, 0, 0 },
        { 0, 0, -10, 66, 84, -12, 0, 0 },
        { 0, 0, -10, 58, 94, -14, 0, 0 },
        { 0, 0, -10, 48, 102, -12, 0, 0 },
        { 0, 0, -8, 38, 110, -12, 0, 0 },
        { 0, 0, -6, 28, 116, -10, 0, 0 },
        { 0, 0, -4, 18, 122, -8, 0, 0 },
        { 0, 0, -2, 8, 126, -4, 0, 0 }
      },
      {
        { 0, 0, 0, 128, 0, 0, 0, 0 },
        { 0, 0, 30, 62, 34, 2, 0, 0 },
        { 0, 0, 26, 62, 36, 4, 0, 0 },
        { 0, 0, 22, 62, 40, 4, 0, 0 },
        { 0, 0, 20, 60, 42, 6, 0, 0 },
        { 0, 0, 18, 58, 44, 8, 0, 0 },
        { 0, 0, 16, 56, 46, 10, 0, 0 },
        { 0, 0, 14, 54, 48, 12, 0, 0 },
        { 0, 0, 12, 52, 52, 12, 0, 0 },
        { 0, 0, 12, 48, 54, 14, 0, 0 },
        { 0, 0, 10, 46, 56, 16, 0, 0 },
        { 0, 0, 8, 44, 58, 18, 0, 0 },
        { 0, 0, 6, 42, 60, 20, 0, 0 },
        { 0, 0, 4, 40, 62, 22, 0, 0 },
        { 0, 0, 4, 36, 62, 26, 0, 0 },
        { 0, 0, 2, 34, 62, 30, 0, 0 }
      }
    }
    

Note: All the values in Subpel_Filters are even. The last two filter types are used for small blocks and only have four filter taps. The filter at index 4 has a four tap version of the EIGHTTAP filter. The filter at index 5 has a four tap version of the EIGHTAP_SMOOTH filter.

Block Warp Process

The inputs to this process are:

  • a variable plane,

  • a variable refList specifying that we should predict from RefFrame[ refList ],

  • variables x and y specifying the location of the top left sample in the CurrFrame[ plane ] array of the region to be predicted,

  • variables i8 and j8 specifying the offset (in units of 8 samples) relative to the top left sample,

  • variables w and h giving the width and height of the block in units of samples.

The output from this process is the 2D array named pred containing warped inter predicted samples.

The process only updates a section of the pred array. The size of the updated section is 8x8 samples, clipped to the size of the block. Variables i8 and j8 give the location of the section to update.

A variable refIdx specifying which reference frame is being used is set equal to ref_frame_idx[ RefFrame[ refList ] - LAST_FRAME ].

A variable ref specifying the reference frame contents is set equal to FrameStore[ refIdx ].

The variables subX and subY are set equal to the subsampling for the current plane as follows:

  • If plane is equal to 0, subX is set equal to 0 and subY is set equal to 0.

  • Otherwise, subX is set equal to subsampling_x and subY is set equal to subsampling_y.

The variable lastX is set equal to ( (RefFrameWidth[ refIdx ] + subX) >> subX) - 1.

The variable lastY is set equal to ( (RefFrameHeight[ refIdx ] + subY) >> subY) - 1.

(lastX and lastY specify the coordinates of the bottom right sample of the reference plane.)

The variable srcX is set equal to (j8 * 8 + 4) << subX.

The variable srcY is set equal to (i8 * 8 + 4) << subY.

(srcX and srcY specify a location in the luma plane that will be projected using the warp parameters.)

The array warpParams is specified as follows:

  • If motion_mode is equal to LOCALWARP, warpParams is set equal to LocalWarpParams.

  • Otherwise (motion_mode is not equal to LOCALWARP), warpParams is set equal to gm_params[ RefFrame[ refList ] ].

The variable dstX is set equal to warpParams[2] * srcX + warpParams[3] * srcY + warpParams[0].

The variable dstY is set equal to warpParams[4] * srcX + warpParams[5] * srcY + warpParams[1].

(dstX and dstY specify the destination location in the luma plane using WARPEDMODEL_PREC_BITS bits of precision).

The setup shear process specified in section 7.7.2.4 is invoked with warpParams as input, and the outputs are assigned to alpha, beta, gamma, and delta.

The sub-sample interpolation is effected via two one-dimensional convolutions. First a horizontal filter is used to build up a temporary array, and then this array is vertically filtered to obtain the final prediction.

The filtering is applied as follows:

  • The array intermediate is specified as follows:

    x4 = dstX >> subX
    y4 = dstY >> subY
    ix4 = x4 >> WARPEDMODEL_PREC_BITS
    sx4 = x4 & ((1 << WARPEDMODEL_PREC_BITS) - 1)
    iy4 = y4 >> WARPEDMODEL_PREC_BITS
    sy4 = y4 & ((1 << WARPEDMODEL_PREC_BITS) - 1)
        
    for (k = -7; k < 8; k++) {
        for (l = -4; l < 4; l++) {
            sx = sx4 + alpha * l + beta * k
            offs = Round2(sx, WARPEDDIFF_PREC_BITS) + WARPEDPIXEL_PREC_SHIFTS
            s = 0
            for (m = 0; m < 8; m++) {
                s += Warped_Filters[ offs ][ m ] * 
                  ref[ plane ][ Clip3( 0, lastY, iy4 + k ) ]
                              [ Clip3( 0, lastX, ix4 + l - 3 + m ) ]
            }
            intermediate[(k + 7)][(l + 4)] = Round2(s, 7)
        }
    }
    
  • The array pred is specified as follows:

    for (k = -4; k < Min(4, h - i8 * 8 - 4); k++) {
        for (l = -4; l < Min(4, w - j8 * 8 - 4); l++) {
            sy = sy4 + gamma * l + delta * k
            offs = Round2(sy, WARPEDDIFF_PREC_BITS) + WARPEDPIXEL_PREC_SHIFTS
            s = 0
            for (m = 0; m < 8; m++) {
                s += Warped_Filters[offs][m] * 
                     intermediate[(k + m + 4)][(l + 4)]
            }
            pred[ i8 * 8 + k + 4 ][ j8 * 8 + l + 4 ] = s
        }
    }
    

    where the constant array Warped_Filters is specified as:

    Warped_Filters[WARPEDPIXEL_PREC_SHIFTS * 3 + 1][8] = {
        { 0,   0, 127,   1,   0, 0, 0, 0 }, { 0, - 1, 127,   2,   0, 0, 0, 0 },
        { 1, - 3, 127,   4, - 1, 0, 0, 0 }, { 1, - 4, 126,   6, - 2, 1, 0, 0 },
        { 1, - 5, 126,   8, - 3, 1, 0, 0 }, { 1, - 6, 125,  11, - 4, 1, 0, 0 },
        { 1, - 7, 124,  13, - 4, 1, 0, 0 }, { 2, - 8, 123,  15, - 5, 1, 0, 0 },
        { 2, - 9, 122,  18, - 6, 1, 0, 0 }, { 2, -10, 121,  20, - 6, 1, 0, 0 },
        { 2, -11, 120,  22, - 7, 2, 0, 0 }, { 2, -12, 119,  25, - 8, 2, 0, 0 },
        { 3, -13, 117,  27, - 8, 2, 0, 0 }, { 3, -13, 116,  29, - 9, 2, 0, 0 },
        { 3, -14, 114,  32, -10, 3, 0, 0 }, { 3, -15, 113,  35, -10, 2, 0, 0 },
        { 3, -15, 111,  37, -11, 3, 0, 0 }, { 3, -16, 109,  40, -11, 3, 0, 0 },
        { 3, -16, 108,  42, -12, 3, 0, 0 }, { 4, -17, 106,  45, -13, 3, 0, 0 },
        { 4, -17, 104,  47, -13, 3, 0, 0 }, { 4, -17, 102,  50, -14, 3, 0, 0 },
        { 4, -17, 100,  52, -14, 3, 0, 0 }, { 4, -18,  98,  55, -15, 4, 0, 0 },
        { 4, -18,  96,  58, -15, 3, 0, 0 }, { 4, -18,  94,  60, -16, 4, 0, 0 },
        { 4, -18,  91,  63, -16, 4, 0, 0 }, { 4, -18,  89,  65, -16, 4, 0, 0 },
        { 4, -18,  87,  68, -17, 4, 0, 0 }, { 4, -18,  85,  70, -17, 4, 0, 0 },
        { 4, -18,  82,  73, -17, 4, 0, 0 }, { 4, -18,  80,  75, -17, 4, 0, 0 },
        { 4, -18,  78,  78, -18, 4, 0, 0 }, { 4, -17,  75,  80, -18, 4, 0, 0 },
        { 4, -17,  73,  82, -18, 4, 0, 0 }, { 4, -17,  70,  85, -18, 4, 0, 0 },
        { 4, -17,  68,  87, -18, 4, 0, 0 }, { 4, -16,  65,  89, -18, 4, 0, 0 },
        { 4, -16,  63,  91, -18, 4, 0, 0 }, { 4, -16,  60,  94, -18, 4, 0, 0 },
        { 3, -15,  58,  96, -18, 4, 0, 0 }, { 4, -15,  55,  98, -18, 4, 0, 0 },
        { 3, -14,  52, 100, -17, 4, 0, 0 }, { 3, -14,  50, 102, -17, 4, 0, 0 },
        { 3, -13,  47, 104, -17, 4, 0, 0 }, { 3, -13,  45, 106, -17, 4, 0, 0 },
        { 3, -12,  42, 108, -16, 3, 0, 0 }, { 3, -11,  40, 109, -16, 3, 0, 0 },
        { 3, -11,  37, 111, -15, 3, 0, 0 }, { 2, -10,  35, 113, -15, 3, 0, 0 },
        { 3, -10,  32, 114, -14, 3, 0, 0 }, { 2, - 9,  29, 116, -13, 3, 0, 0 },
        { 2, - 8,  27, 117, -13, 3, 0, 0 }, { 2, - 8,  25, 119, -12, 2, 0, 0 },
        { 2, - 7,  22, 120, -11, 2, 0, 0 }, { 1, - 6,  20, 121, -10, 2, 0, 0 },
        { 1, - 6,  18, 122, - 9, 2, 0, 0 }, { 1, - 5,  15, 123, - 8, 2, 0, 0 },
        { 1, - 4,  13, 124, - 7, 1, 0, 0 }, { 1, - 4,  11, 125, - 6, 1, 0, 0 },
        { 1, - 3,   8, 126, - 5, 1, 0, 0 }, { 1, - 2,   6, 126, - 4, 1, 0, 0 },
        { 0, - 1,   4, 127, - 3, 1, 0, 0 }, { 0,   0,   2, 127, - 1, 0, 0, 0 },
    
        { 0,  0,   0, 127,   1,   0,  0,  0}, { 0,  0,  -1, 127,   2,   0,  0,  0},
        { 0,  1,  -3, 127,   4,  -2,  1,  0}, { 0,  1,  -5, 127,   6,  -2,  1,  0},
        { 0,  2,  -6, 126,   8,  -3,  1,  0}, {-1,  2,  -7, 126,  11,  -4,  2, -1},
        {-1,  3,  -8, 125,  13,  -5,  2, -1}, {-1,  3, -10, 124,  16,  -6,  3, -1},
        {-1,  4, -11, 123,  18,  -7,  3, -1}, {-1,  4, -12, 122,  20,  -7,  3, -1},
        {-1,  4, -13, 121,  23,  -8,  3, -1}, {-2,  5, -14, 120,  25,  -9,  4, -1},
        {-1,  5, -15, 119,  27, -10,  4, -1}, {-1,  5, -16, 118,  30, -11,  4, -1},
        {-2,  6, -17, 116,  33, -12,  5, -1}, {-2,  6, -17, 114,  35, -12,  5, -1},
        {-2,  6, -18, 113,  38, -13,  5, -1}, {-2,  7, -19, 111,  41, -14,  6, -2},
        {-2,  7, -19, 110,  43, -15,  6, -2}, {-2,  7, -20, 108,  46, -15,  6, -2},
        {-2,  7, -20, 106,  49, -16,  6, -2}, {-2,  7, -21, 104,  51, -16,  7, -2},
        {-2,  7, -21, 102,  54, -17,  7, -2}, {-2,  8, -21, 100,  56, -18,  7, -2},
        {-2,  8, -22,  98,  59, -18,  7, -2}, {-2,  8, -22,  96,  62, -19,  7, -2},
        {-2,  8, -22,  94,  64, -19,  7, -2}, {-2,  8, -22,  91,  67, -20,  8, -2},
        {-2,  8, -22,  89,  69, -20,  8, -2}, {-2,  8, -22,  87,  72, -21,  8, -2},
        {-2,  8, -21,  84,  74, -21,  8, -2}, {-2,  8, -22,  82,  77, -21,  8, -2},
        {-2,  8, -21,  79,  79, -21,  8, -2}, {-2,  8, -21,  77,  82, -22,  8, -2},
        {-2,  8, -21,  74,  84, -21,  8, -2}, {-2,  8, -21,  72,  87, -22,  8, -2},
        {-2,  8, -20,  69,  89, -22,  8, -2}, {-2,  8, -20,  67,  91, -22,  8, -2},
        {-2,  7, -19,  64,  94, -22,  8, -2}, {-2,  7, -19,  62,  96, -22,  8, -2},
        {-2,  7, -18,  59,  98, -22,  8, -2}, {-2,  7, -18,  56, 100, -21,  8, -2},
        {-2,  7, -17,  54, 102, -21,  7, -2}, {-2,  7, -16,  51, 104, -21,  7, -2},
        {-2,  6, -16,  49, 106, -20,  7, -2}, {-2,  6, -15,  46, 108, -20,  7, -2},
        {-2,  6, -15,  43, 110, -19,  7, -2}, {-2,  6, -14,  41, 111, -19,  7, -2},
        {-1,  5, -13,  38, 113, -18,  6, -2}, {-1,  5, -12,  35, 114, -17,  6, -2},
        {-1,  5, -12,  33, 116, -17,  6, -2}, {-1,  4, -11,  30, 118, -16,  5, -1},
        {-1,  4, -10,  27, 119, -15,  5, -1}, {-1,  4,  -9,  25, 120, -14,  5, -2},
        {-1,  3,  -8,  23, 121, -13,  4, -1}, {-1,  3,  -7,  20, 122, -12,  4, -1},
        {-1,  3,  -7,  18, 123, -11,  4, -1}, {-1,  3,  -6,  16, 124, -10,  3, -1},
        {-1,  2,  -5,  13, 125,  -8,  3, -1}, {-1,  2,  -4,  11, 126,  -7,  2, -1},
        { 0,  1,  -3,   8, 126,  -6,  2,  0}, { 0,  1,  -2,   6, 127,  -5,  1,  0},
        { 0,  1,  -2,   4, 127,  -3,  1,  0}, { 0,  0,   0,   2, 127,  -1,  0,  0},
    
        { 0, 0, 0,   1, 127,   0,   0, 0 }, { 0, 0, 0, - 1, 127,   2,   0, 0 },
        { 0, 0, 1, - 3, 127,   4, - 1, 0 }, { 0, 0, 1, - 4, 126,   6, - 2, 1 },
        { 0, 0, 1, - 5, 126,   8, - 3, 1 }, { 0, 0, 1, - 6, 125,  11, - 4, 1 },
        { 0, 0, 1, - 7, 124,  13, - 4, 1 }, { 0, 0, 2, - 8, 123,  15, - 5, 1 },
        { 0, 0, 2, - 9, 122,  18, - 6, 1 }, { 0, 0, 2, -10, 121,  20, - 6, 1 },
        { 0, 0, 2, -11, 120,  22, - 7, 2 }, { 0, 0, 2, -12, 119,  25, - 8, 2 },
        { 0, 0, 3, -13, 117,  27, - 8, 2 }, { 0, 0, 3, -13, 116,  29, - 9, 2 },
        { 0, 0, 3, -14, 114,  32, -10, 3 }, { 0, 0, 3, -15, 113,  35, -10, 2 },
        { 0, 0, 3, -15, 111,  37, -11, 3 }, { 0, 0, 3, -16, 109,  40, -11, 3 },
        { 0, 0, 3, -16, 108,  42, -12, 3 }, { 0, 0, 4, -17, 106,  45, -13, 3 },
        { 0, 0, 4, -17, 104,  47, -13, 3 }, { 0, 0, 4, -17, 102,  50, -14, 3 },
        { 0, 0, 4, -17, 100,  52, -14, 3 }, { 0, 0, 4, -18,  98,  55, -15, 4 },
        { 0, 0, 4, -18,  96,  58, -15, 3 }, { 0, 0, 4, -18,  94,  60, -16, 4 },
        { 0, 0, 4, -18,  91,  63, -16, 4 }, { 0, 0, 4, -18,  89,  65, -16, 4 },
        { 0, 0, 4, -18,  87,  68, -17, 4 }, { 0, 0, 4, -18,  85,  70, -17, 4 },
        { 0, 0, 4, -18,  82,  73, -17, 4 }, { 0, 0, 4, -18,  80,  75, -17, 4 },
        { 0, 0, 4, -18,  78,  78, -18, 4 }, { 0, 0, 4, -17,  75,  80, -18, 4 },
        { 0, 0, 4, -17,  73,  82, -18, 4 }, { 0, 0, 4, -17,  70,  85, -18, 4 },
        { 0, 0, 4, -17,  68,  87, -18, 4 }, { 0, 0, 4, -16,  65,  89, -18, 4 },
        { 0, 0, 4, -16,  63,  91, -18, 4 }, { 0, 0, 4, -16,  60,  94, -18, 4 },
        { 0, 0, 3, -15,  58,  96, -18, 4 }, { 0, 0, 4, -15,  55,  98, -18, 4 },
        { 0, 0, 3, -14,  52, 100, -17, 4 }, { 0, 0, 3, -14,  50, 102, -17, 4 },
        { 0, 0, 3, -13,  47, 104, -17, 4 }, { 0, 0, 3, -13,  45, 106, -17, 4 },
        { 0, 0, 3, -12,  42, 108, -16, 3 }, { 0, 0, 3, -11,  40, 109, -16, 3 },
        { 0, 0, 3, -11,  37, 111, -15, 3 }, { 0, 0, 2, -10,  35, 113, -15, 3 },
        { 0, 0, 3, -10,  32, 114, -14, 3 }, { 0, 0, 2, - 9,  29, 116, -13, 3 },
        { 0, 0, 2, - 8,  27, 117, -13, 3 }, { 0, 0, 2, - 8,  25, 119, -12, 2 },
        { 0, 0, 2, - 7,  22, 120, -11, 2 }, { 0, 0, 1, - 6,  20, 121, -10, 2 },
        { 0, 0, 1, - 6,  18, 122, - 9, 2 }, { 0, 0, 1, - 5,  15, 123, - 8, 2 },
        { 0, 0, 1, - 4,  13, 124, - 7, 1 }, { 0, 0, 1, - 4,  11, 125, - 6, 1 },
        { 0, 0, 1, - 3,   8, 126, - 5, 1 }, { 0, 0, 1, - 2,   6, 126, - 4, 1 },
        { 0, 0, 0, - 1,   4, 127, - 3, 1 }, { 0, 0, 0,   0,   2, 127, - 1, 0 },
            
        { 0, 0, 0,   0,   2, 127, - 1, 0 }
    }
    
Setup Shear Process

The input for this process is an array warpParams representing an affine transformation.

The outputs from this process are variables alpha, beta, gamma, delta representing two shearing operations that combine to make the full affine transformation.

The variable alpha0 is set equal to Clip3( -32768, 32767, warpParams[ 2 ] - (1 << WARPEDMODEL_PREC_BITS) ).

The variable beta0 is set equal to Clip3( -32768, 32767, warpParams[ 3 ] ).

The resolve divisor process specified in section 7.7.2.5 is invoked with warpParams[ 2 ] as input, and the outputs assigned to divShift and divFactor.

The variable v is set equal to ( warpParams[ 4 ] << WARPEDMODEL_PREC_BITS ).

The variable gamma0 is set equal to Clip3( -32768, 32767, Round2Signed( v * divFactor, divShift ) ).

The variable w is set equal to ( warpParams[ 3 ] * warpParams[ 4 ] ).

The variable delta0 is set equal to Clip3( -32768, 32767, warpParams[ 5 ] - Round2Signed( w * divFactor, divShift ) - (1 « WARPEDMODEL_PREC_BITS) ).

It is a requirement of bitstream conformance that 4 * Abs( alpha0 ) + 7 * Abs( beta0 ) is less than (1 « WARPEDMODEL_PREC_BITS).

It is a requirement of bitstream conformance that 4 * Abs( gamma0 ) + 4 * Abs( delta0 ) is less than (1 « WARPEDMODEL_PREC_BITS).

The output variables are set as follows:

alpha = Round2Signed( alpha0, WARP_PARAM_REDUCE_BITS) << WARP_PARAM_REDUCE_BITS
beta = Round2Signed( beta0, WARP_PARAM_REDUCE_BITS) << WARP_PARAM_REDUCE_BITS
gamma = Round2Signed( gamma0, WARP_PARAM_REDUCE_BITS) << WARP_PARAM_REDUCE_BITS
delta = Round2Signed( delta0, WARP_PARAM_REDUCE_BITS) << WARP_PARAM_REDUCE_BITS
Resolve Divisor Process

The input for this process is a variable d.

The outputs for this process are variables divShift and divFactor that can be used to perform an approximate division by d via multiplying by divFactor and shifting right by divShift.

The variable n (representing the location of the most signficant bit in Abs(d) ) is set equal to floor( log2( Abs(d) ) ).

The variable e is set equal to Abs( d ) - ( 1 « n ).

The variable f is set as follows:

  • If n > DUT_LUT_BITS, f is set equal to Round2( e, n - DIV_LUT_BITS ).

  • Otherwise, f is set equal to e « (DIV_LUT_BITS - n ).

The output variable divShift is set equal to (n + DIV_LUT_PREC_BITS).

The output variable divFactor is set as follows:

  • If d is less than 0, divFactor is set equal to -Div_Lut[ f ].

  • Otherwise, divFactors is set equal to Div_Lut[ f ].

The lookup table Div_Lut is specified as:

Div_Lut[DIV_LUT_NUM] = {
  16384, 16320, 16257, 16194, 16132, 16070, 16009, 15948, 15888, 15828, 15768,
  15709, 15650, 15592, 15534, 15477, 15420, 15364, 15308, 15252, 15197, 15142,
  15087, 15033, 14980, 14926, 14873, 14821, 14769, 14717, 14665, 14614, 14564,
  14513, 14463, 14413, 14364, 14315, 14266, 14218, 14170, 14122, 14075, 14028,
  13981, 13935, 13888, 13843, 13797, 13752, 13707, 13662, 13618, 13574, 13530,
  13487, 13443, 13400, 13358, 13315, 13273, 13231, 13190, 13148, 13107, 13066,
  13026, 12985, 12945, 12906, 12866, 12827, 12788, 12749, 12710, 12672, 12633,
  12596, 12558, 12520, 12483, 12446, 12409, 12373, 12336, 12300, 12264, 12228,
  12193, 12157, 12122, 12087, 12053, 12018, 11984, 11950, 11916, 11882, 11848,
  11815, 11782, 11749, 11716, 11683, 11651, 11619, 11586, 11555, 11523, 11491,
  11460, 11429, 11398, 11367, 11336, 11305, 11275, 11245, 11215, 11185, 11155,
  11125, 11096, 11067, 11038, 11009, 10980, 10951, 10923, 10894, 10866, 10838,
  10810, 10782, 10755, 10727, 10700, 10673, 10645, 10618, 10592, 10565, 10538,
  10512, 10486, 10460, 10434, 10408, 10382, 10356, 10331, 10305, 10280, 10255,
  10230, 10205, 10180, 10156, 10131, 10107, 10082, 10058, 10034, 10010, 9986,
  9963,  9939,  9916,  9892,  9869,  9846,  9823,  9800,  9777,  9754,  9732,
  9709,  9687,  9664,  9642,  9620,  9598,  9576,  9554,  9533,  9511,  9489,
  9468,  9447,  9425,  9404,  9383,  9362,  9341,  9321,  9300,  9279,  9259,
  9239,  9218,  9198,  9178,  9158,  9138,  9118,  9098,  9079,  9059,  9039,
  9020,  9001,  8981,  8962,  8943,  8924,  8905,  8886,  8867,  8849,  8830,
  8812,  8793,  8775,  8756,  8738,  8720,  8702,  8684,  8666,  8648,  8630,
  8613,  8595,  8577,  8560,  8542,  8525,  8508,  8490,  8473,  8456,  8439,
  8422,  8405,  8389,  8372,  8355,  8339,  8322,  8306,  8289,  8273,  8257,
  8240,  8224,  8208,  8192
}
Warp Estimation Process

This process produces the array LocalWarpParams based on NumSamples candidates in CandList by performing a least squares fit.

A 2x2 matrix A, and two length 2 arrays Bx and By are constructed as follows:

for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
        A[i][j] = 0
    }
    Bx[i] = 0
    By[i] = 0
}
w4 = Num_4x4_Blocks_Wide[MiSize]
h4 = Num_4x4_Blocks_High[MiSize]
midY = MiRow * 4 + bh * 2 - 1
midX = MiCol * 4 + bw * 2 - 1
suy = midY * 8
sux = midX * 8
duy = suy + Mv[0][0]
dux = sux + Mv[0][1]
n = 0
for (i = 0; i < NumSamples; i++) {
    sy = CandList[i][0] - suy + 1
    sx = CandList[i][1] - sux + 1
    dy = CandList[i][2] - duy + 1
    dx = CandList[i][3] - dux + 1
    if (Abs(sx - dx) < LS_MV_MAX && Abs(sy - dy) < LS_MV_MAX) {
        A[0][0] += sx * sx + 1
        A[0][1] += sx * sy
        A[1][1] += sy * sy + 1
        Bx[0] += sx * dx + 1
        Bx[1] += sy * dx
        By[0] += sx * dy
        By[1] += sy * dy + 1
        n += 1
    }
}
if (n >= 4)
    downshift = LS_MAT_DOWN_BITS
else if (n >= 2)
    downshift = LS_MAT_DOWN_BITS - 1
else
    downshift = LS_MAT_DOWN_BITS - 2
for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
        A[i][j] = Clip3(LS_MAT_MIN, LS_MAT_MAX, Round2Signed(A[i][j], downshift))
    }
    Bx[i] = Clip3(LS_MAT_MIN, LS_MAT_MAX, Round2Signed(Bx[i], downshift))
    By[i] = Clip3(LS_MAT_MIN, LS_MAT_MAX, Round2Signed(By[i], downshift))
}

Note: The matrix A is symmetric so entry A[1][0] is omitted.

Note: The addition of 1 in certain places in this code has the effect of treating each candidate as providing four closely samples. This helps to regularize the solution.

The variable det (containing the determinant of the matrix A) is set equal to A[0][0] * A[1][1] - A[0][1] * A[0][1].

It is a requirement of bitstream conformance that det is not equal to 0.

The resolve divisor process specified in section 7.7.2.5 is invoked with det as input, and the outputs assigned to divShift and divFactor.

The local warp parameters in LocalWarpParams are derived as follows:

    divShift -= WARPEDMODEL_PREC_BITS
    if (divShift < 0) {
        divFactor = divFactor << (-divShift)
        divShift = 0
    }
    LocalWarpParams[2] = diag(     A[1][1] * Bx[0] - A[0][1] * Bx[1])
    LocalWarpParams[3] = nondiag( -A[0][1] * Bx[0] + A[0][0] * Bx[1])
    LocalWarpParams[4] = nondiag(  A[1][1] * By[0] - A[0][1] * By[1])
    LocalWarpParams[5] = diag(    -A[0][1] * By[0] + A[0][0] * By[1])

    vx = mvx * (1 << (WARPEDMODEL_PREC_BITS - 3)) -
         (midX * (LocalWarpParams[2] - (1 << WARPEDMODEL_PREC_BITS)) + midY * LocalWarpParams[3])
    vy = mvy * (1 << (WARPEDMODEL_PREC_BITS - 3)) -
         (midX * LocalWarpParams[4] + midY * (LocalWarpParams[5] - (1 << WARPEDMODEL_PREC_BITS)))
    LocalWarpParams[0] = Clip3(-WARPEDMODEL_TRANS_CLAMP, WARPEDMODEL_TRANS_CLAMP - 1, vx)
    LocalWarpParams[1] = Clip3(-WARPEDMODEL_TRANS_CLAMP, WARPEDMODEL_TRANS_CLAMP - 1, vy)

where diag and nondiag are specified to divide and clamp using divFactor and divShift as follows:

nondiag(v) {
    return Clip3(-WARPEDMODEL_NONDIAGAFFINE_CLAMP + 1,
                  WARPEDMODEL_NONDIAGAFFINE_CLAMP - 1,
                  Round2Signed(v * divFactor, divShift))
}

diag(v) {
    return Clip3((1 << WARPEDMODEL_PREC_BITS) - WARPEDMODEL_NONDIAGAFFINE_CLAMP + 1,
                 (1 << WARPEDMODEL_PREC_BITS) + WARPEDMODEL_NONDIAGAFFINE_CLAMP - 1,
                 Round2Signed(v * divFactor, divShift))
}
Overlapped Motion Compensation Process

The inputs to this process are:

  • a variable plane specifying which plane is being predicted,

  • variables x and y specifying the location of the top left sample in the CurrFrame[ plane ] array of the region to be predicted,

  • variables w and h specifying the width and height of the region to be predicted.

The outputs of this process are modified inter predicted samples in the current frame CurrFrame.

This process blends the inter predicted samples for the current block with inter predicted samples based on motion vectors from the above and left blocks.

The maximum number of overlapped predictions is limited based on the size of the block.

For small blocks, only the left neighbour will be used to form the prediction.

The variables subX and subY describing the subsampling of the current plane are derived as follows:

  • If plane is equal to 0, subX and subY are set equal to 0.

  • Otherwise (plane is not equal to 0), subX is set equal to subsampling_x and subY is set equal to subsampling_y.

The process is specified as:

if ( AvailU ) {
    if ( get_plane_residual_size( MiSize, plane ) >= BLOCK_8X8 ) {
        pass = 0
        w4 = Num_4x4_Blocks_Wide[ MiSize ]
        x4 = MiCol
        y4 = MiRow
        nCount = 0
        nLimit = Min(4, Mi_Width_Log2[ MiSize ])
        while ( nCount < nLimit && x4 < Min( MiCols, MiCol + w4 ) ) {
            candRow = MiRow - 1
            candCol = x4 | 1
            candSz = MiSizes[ candRow ][ candCol ]
            step4 = Max(2, Num_4x4_Blocks_Wide[ candSz ])
            if ( RefFrames[ candRow ][ candCol ][ 0 ] > INTRA_FRAME ) {
                nCount += 1
                predW = Min( w, ( step4 * MI_SIZE ) >> subX )
                predH = Min( h >> 1, 32 >> subY )
                mask = get_obmc_mask( predH )
                predict_overlap( )
            }
            x4 += step4
        }
    }
}
if ( AvailL ) {
    pass = 1
    h4 = Num_4x4_Blocks_High[ MiSize ]
    x4 = MiCol
    y4 = MiRow
    nCount = 0
    nLimit = Min(4, Mi_Height_Log2[ MiSize ])
    while ( nCount < nLimit && y4 < Min( MiRows, MiRow + h4 ) ) {
        candCol = MiCol - 1
        candRow = y4 | 1
        candSz = MiSizes[ candRow ][ candCol ]
        step4 = Max(2, Num_4x4_Blocks_High[ candSz ])
        if ( RefFrames[ candRow ][ candCol ][ 0 ] > INTRA_FRAME ) {
            nCount += 1
            predW = Min( w >> 1, 32 >> subX )
            predH = Min( h, ( step4 * MI_SIZE ) >> subY )
            mask = get_obmc_mask( predW )
            predict_overlap( )
        }
        y4 += step4
    }
}

When the function predict_overlap is invoked, the following ordered steps apply to form the overlap prediction for a region of size predW by predH based on the candidate motion vector:

  1. The motion vector mv is set equal to Mvs[ candRow ][ candCol ][ 0 ].

  2. The variable refIdx is set equal to ref_frame_idx[ RefFrames[ candRow ][ candCol ][ 0 ] - LAST_FRAME ].

  3. The variable predX is set equal to (x4 * 4) >> subX.

  4. The variable predY is set equal to (y4 * 4) >> subY.

  5. The motion vector scaling process in section 7.7.2.1 is invoked with plane, refIdx, predX, predY, mv as inputs and the output being the initial location startX, startY, and the step sizes stepX, stepY.

  6. The block inter prediction process in section 7.7.2.2 is invoked with plane, refIdx, startX, startY, stepX, stepY, predW, predH, candRow, candCol as inputs and the output is assigned to the 2D array obmcPred.

  7. obmcPred[ i ][ j ] is set equal to Clip1( Round2( obmcPred[ i ][ j ], 9) ) for i = 0..predH-1 and j = 0..predW-1.

  8. The blending process in section 7.7.2.8 is invoked with plane, predX, predY, predW, predH, pass, obmcPred, and mask as inputs.

The function get_obmc_mask returns a blending mask as follows:

get_obmc_mask( length ) {
    if (length == 1) {
        return Obmc_Mask_1
    } else if (length == 2) {
        return Obmc_Mask_2
    } else if (length == 4) {
        return Obmc_Mask_4
    } else if (length == 8) {
        return Obmc_Mask_8
    } else if (length == 16) {
        return Obmc_Mask_16
    } else if (length == 32) {
        return Obmc_Mask_32
    }
}

The blending masks are defined as follows:

Obmc_Mask_1[1] = { 64 };

Obmc_Mask_2[2] = { 45, 64 };

Obmc_Mask_4[4] = { 39, 50, 59, 64 };

Obmc_Mask_8[8] = { 36, 42, 48, 53, 57, 61, 64, 64 };

Obmc_Mask_16[16] = { 34, 37, 40, 43, 46, 49, 52, 54,
                     56, 58, 60, 61, 64, 64, 64, 64 };

Obmc_Mask_32[32] = { 33, 35, 36, 38, 40, 41, 43, 44,
                     45, 47, 48, 50, 51, 52, 53, 55,
                     56, 57, 58, 59, 60, 60, 61, 62,
                     64, 64, 64, 64, 64, 64, 64, 64 };
Overlap Blending Process

The inputs to this process are:

  • a variable plane specifying which plane is being predicted,

  • variables predX and predY specifying the location of the top left sample in the CurrFrame[ plane ] array of the region to be predicted,

  • variables predW and predH specifying the width and height of the region to be predicted,

  • a variable pass equal to 0 if blending above samples, or equal to 1 if blending left samples,

  • a 2d array obmcPred containing the samples predicted from a neighbouring motion vector,

  • an array mask containing the blending weights.

The outputs of this process are modified inter predicted samples in the current frame CurrFrame.

For i = 0..(predH - 1) and j = 0..(predW - 1), the following ordered steps apply:

  1. The variable m specifying the blending factor is specifed as follows:

    • If pass is equal to 0 (blend from above), m is set equal to mask[ i ].

    • Otherwise (pass is equal to 0 meaning blend from left), m is set equal to mask[ j ].

  2. CurrFrame[ plane ][ predY + i ][ predX + j ] is set equal to Round2( m * CurrFrame[ plane ][ predY + i ][ predX + j ] + (64 - m) * obmcPred[ i ][ j ], 6)

Wedge Mask Process

The input to this process is:

  • variables w and h specifying the width and height of the region to be predicted.

This process sets up a mask array for the luma samples.

The mask is specified as:

for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
        Mask[ i ][ j ] = WedgeMasks[ MiSize ][ wedge_sign ][ wedge_index ][ i ][ j ]
    }
}

where WedgeMasks is a fixed lookup table that is specified as:

w = MASK_MASTER_SIZE
h = MASK_MASTER_SIZE
for (j = 0; j < w; j ++) {
    shift = MASK_MASTER_SIZE / 4
    for (i = 0; i < h; i += 2) {
        MasterMask[ WEDGE_OBLIQUE63 ][ i ][ j ] = Wedge_Master_oblique_even[ Clip3( 0, MASK_MASTER_SIZE - 1, j - shift ) ]
        shift -= 1
        MasterMask[ WEDGE_OBLIQUE63 ][ i + 1][ j ] = Wedge_Master_Oblique_Even[ Clip3( 0, MASK_MASTER_SIZE - 1, j - shift ) ]
        MasterMask[ WEDGE_VERTICAL ][ i ][ j ] = Wedge_Master_Vertical[ j ]
        MasterMask[ WEDGE_VERTICAL ][ i + 1 ][ j ] = Wedge_Master_Vertical[ j ]
    }
}
for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      msk = MasterMask[WEDGE_OBLIQUE63][ i ][ j ]
      MasterMask[WEDGE_OBLIQUE27][j  ][ i ] = msk
      MasterMask[WEDGE_OBLIQUE117][ i ][ w - 1 - j ] = 64 - msk
      MasterMask[WEDGE_OBLIQUE153][ w - 1 - j ][ i ] = 64 - msk
      MasterMask[WEDGE_HORIZONTAL][ j ][ i ] = MasterMask[WEDGE_VERTICAL][ i ][ j ]
    }
}
for (bsize = BLOCK_8X8; bsize < BLOCK_SIZES; bsize++) {
    if ( Wedge_Bits[ bsize ] > 0 ) {
        w = Block_Width[ MiSize ]
        h = Block_Height[ MiSize ]
        for (wedge = 0; wedge < WEDGE_TYPES; wedge++) {
            dir = get_wedge_direction(bsize, wedge)
            xoff = MASK_MASTER_SIZE / 2 - ((get_wedge_xoff(bsize, wedge) * w) >> 3)
            yoff = MASK_MASTER_SIZE / 2 - ((get_wedge_yoff(bsize, wedge) * h) >> 3)
            sum = 0
            for (i = 0; i < w; i++)
              sum += MasterMask[dir][ yoff ][ xoff+i ]
            for (i = 1; i < h; i++)
              sum += MasterMask[dir][ yoff+i ][ xoff ]
            avg = (sum + (w + h - 1) / 2) / (w + h - 1)
            flipSign = (avg < 32)
            for (i = 0; i < h; i++) {
                for (j = 0; j < w; j++) {
                  WedgeMasks[bsize][flipSign][wedge][ i ][ j ] = MasterMask[ dir ][ yoff+i ][ xoff+j ]
                  WedgeMasks[bsize][!flipSign][wedge][ i ][ j ] = 64 - MasterMask[ dir ][ yoff+i ][ xoff+j ]
                }
            }
        }
    }
}

The 1d lookup tables are defined as:

Wedge_Master_Oblique_Odd[MASK_MASTER_SIZE] = {
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  2,  6,  18,
  37, 53, 60, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
}

Wedge_Master_Oblique_Even[MASK_MASTER_SIZE] = {
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  4,  11, 27,
  46, 58, 62, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
}

Wedge_Master_Vertical[MASK_MASTER_SIZE] = {
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  2,  7,  21,
  43, 57, 62, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
}

The get_wedge functions are defined as:

int block_shape(bsize) {
  w4 = Num_4x4_Blocks_Wide[bsize]
  h4 = Num_4x4_Blocks_High[bsize]
  if (h4 > w4)
      return 0
  else if (h4 < w4)
      return 1
  else
      return 2
}

get_wedge_direction(bsize, index) {
  return Wedge_Codebook[block_shape(bsize)][index][0]
}

get_wedge_xoff(bsize, index) {
  return Wedge_Codebook[block_shape(bsize)][index][1]
}

get_wedge_yoff(bsize, index) {
  return Wedge_Codebook[block_shape(bsize)][index][2]
}

Wedge_Codebook[3][16][3] = {
    {
        { WEDGE_OBLIQUE27, 4, 4 },  { WEDGE_OBLIQUE63, 4, 4 },
        { WEDGE_OBLIQUE117, 4, 4 }, { WEDGE_OBLIQUE153, 4, 4 },
        { WEDGE_HORIZONTAL, 4, 2 }, { WEDGE_HORIZONTAL, 4, 4 },
        { WEDGE_HORIZONTAL, 4, 6 }, { WEDGE_VERTICAL, 4, 4 },
        { WEDGE_OBLIQUE27, 4, 2 },  { WEDGE_OBLIQUE27, 4, 6 },
        { WEDGE_OBLIQUE153, 4, 2 }, { WEDGE_OBLIQUE153, 4, 6 },
        { WEDGE_OBLIQUE63, 2, 4 },  { WEDGE_OBLIQUE63, 6, 4 },
        { WEDGE_OBLIQUE117, 2, 4 }, { WEDGE_OBLIQUE117, 6, 4 },
    },
    {
        { WEDGE_OBLIQUE27, 4, 4 },  { WEDGE_OBLIQUE63, 4, 4 },
        { WEDGE_OBLIQUE117, 4, 4 }, { WEDGE_OBLIQUE153, 4, 4 },
        { WEDGE_VERTICAL, 2, 4 },   { WEDGE_VERTICAL, 4, 4 },
        { WEDGE_VERTICAL, 6, 4 },   { WEDGE_HORIZONTAL, 4, 4 },
        { WEDGE_OBLIQUE27, 4, 2 },  { WEDGE_OBLIQUE27, 4, 6 },
        { WEDGE_OBLIQUE153, 4, 2 }, { WEDGE_OBLIQUE153, 4, 6 },
        { WEDGE_OBLIQUE63, 2, 4 },  { WEDGE_OBLIQUE63, 6, 4 },
        { WEDGE_OBLIQUE117, 2, 4 }, { WEDGE_OBLIQUE117, 6, 4 },
    },
    {
        { WEDGE_OBLIQUE27, 4, 4 },  { WEDGE_OBLIQUE63, 4, 4 },
        { WEDGE_OBLIQUE117, 4, 4 }, { WEDGE_OBLIQUE153, 4, 4 },
        { WEDGE_HORIZONTAL, 4, 2 }, { WEDGE_HORIZONTAL, 4, 6 },
        { WEDGE_VERTICAL, 2, 4 },   { WEDGE_VERTICAL, 6, 4 },
        { WEDGE_OBLIQUE27, 4, 2 },  { WEDGE_OBLIQUE27, 4, 6 },
        { WEDGE_OBLIQUE153, 4, 2 }, { WEDGE_OBLIQUE153, 4, 6 },
        { WEDGE_OBLIQUE63, 2, 4 },  { WEDGE_OBLIQUE63, 6, 4 },
        { WEDGE_OBLIQUE117, 2, 4 }, { WEDGE_OBLIQUE117, 6, 4 },
    }
}
Segment Mask Process

The input to this process is:

  • an array preds containing the predicted samples,

  • variables w and h specifying the width and height of the region to be predicted.

This process prepares an array Mask containing the blending weights for the luma samples.

The process sets the array based on the difference between the two predictions as follows:

for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
        diff = Abs(preds[ 0 ][ i ][ j ] - preds[ 1 ][ i ][ j ])
        diff = Round2(diff, (BitDepth - 8) + 9)
        m = Clip3(0, 64, 38 + diff / 16)
        if (mask_type)
            Mask[ i ][ j ] = 64 - m
        else
            Mask[ i ][ j ] = m

    }
}
Inter Intra Mask Process

The input to this process is:

  • an array preds containing the predicted samples,

  • a variable plane specifying which plane is being predicted,

  • variables x and y specifying the location of the top left sample in the CurrFrame[ plane ] array of the region to be predicted,

  • variables w and h specifying the width and height of the region to be predicted.

This process prepares an array Mask containing the blending weights for the luma samples.

The process sets the array based on the mode used for intra prediction as follows:

sizeScale = MAX_SB_SIZE / Max( h, w )
for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
    if (interintra_mode == II_V_PRED) {
        Mask[ i ][ j ] = Ii_Weights_1d[ i * sizeScale ]
    } else if (interintra_mode == II_H_PRED) {
        Mask[ i ][ j ] = Ii_Weights_1d[ j * sizeScale ]
    } else if (interintra_mode == II_SMOOTH_PRED) {
        Mask[ i ][ j ] = Ii_Weights_1d[ Min(i, j) * sizeScale ]
    } else {
        Mask[ i ][ j ] = 32
    }
}

where the table Ii_Weights_1d is defined as:

Ii_Weights_1d[MAX_SB_SIZE] = {
  60, 58, 56, 54, 52, 50, 48, 47, 45, 44, 42, 41, 39, 38, 37, 35, 34, 33, 32,
  31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 22, 21, 20, 19, 19, 18, 18, 17, 16,
  16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10,  9,  9,  9,  8,
  8,  8,  8,  7,  7,  7,  7,  6,  6,  6,  6,  6,  5,  5,  5,  5,  5,  4,  4,
  4,  4,  4,  4,  4,  4,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,
  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  1,  1,  1,  1,  1,  1,  1,  1,
  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
}
Mask Blend Process

The inputs to this process are

  • an array preds containing the predicted samples,

  • a variable plane specifying which plane is being predicted,

  • variables dstX and dstY specifying the location of the top left sample in the CurrFrame[ plane ] array of the region to be predicted,

  • variables w and h specifying the width and height of the region to be predicted.

The process combines two predictions according to the mask.
It makes use of an array Mask containing the blending weights to apply (the weights are defined for the current plane samples if compound_type is equal to COMPOUND_INTRA, or the luma plane otherwise).

The variables subX and subY describing the subsampling of the current plane are derived as follows:

  • If plane is equal to 0, subX and subY are set equal to 0.

  • Otherwise (plane is not equal to 0), subX is set equal to subsampling_x and subY is set equal to subsampling_y.

The process is specified as follows:

for (y = 0; y < h; y++) {
    for (x = 0; x < w; x++) {
        if (!subX && !subY) {
            m = Mask[ y ][ x ]
        } else if (subX && !subY) {
            m = Round2(Mask[ y ][ 2*x ] + Mask[ y ][ 2*x+1 ], 1)
        } else if (!subX && subY) {
            m = Round2(Mask[ 2*y ][ x ] + Mask[ 2*y+1 ][ x ], 1)
        } else {
            m = Round2(Mask[ 2*y ][ 2*x ] + Mask[ 2*y ][ 2*x+1 ] +
                       Mask[ 2*y+1 ][ 2*x ] + Mask[ 2*y+1 ][ 2*x+1 ], 2)
        }
        if (interintra) {
            pred0 = Clip1(Round2(preds[ 0 ][ y ][ x ], 9))
            pred1 = CurrFrame[plane][x+dstX][y+dstY]
            CurrFrame[plane][x+dstX][y+dstY] = Round2( m * pred1 + (64 - m) * pred0, 6 )
        } else {
            pred0 = preds[ 0 ][ y ][ x ]
            pred1 = preds[ 1 ][ y ][ x ]
            CurrFrame[plane][x+dstX][y+dstY] = Clip1( Round2( Round2(m * pred0 + (64 - m) * pred1, 6), 9 ) )
        }
    }
}

Palette Prediction Process

The palette prediction process is invoked for palette coded intra blocks to predict a part of the block using the limited palette.

The inputs to this process are:

  • a variable plane specifying which plane is being predicted,
  • variables startX and startY specifying the location of the top left sample in the CurrFrame[ plane ] array of the current transform block,
  • variables x and y specifying the location in 4x4 units relative to the top left sample of the current transform block,
  • a variable txSz, specifying the size of the current transform block.

The outputs of this process are palette predicted samples in the current frame CurrFrame.

The variable w specifying the width of the transform block is set equal to Tx_Width[ txSz ].

The variable h specifying the height of the transform block is set equal to Tx_Height[ txSz ].

The variable palette is specified as follows:

  • If plane is 0, palette is set to palette_colors_y.
  • Otherwise, if plane is 1, palette is set to palette_colors_u.
  • Otherwise (plane is 2), palette is set to palette_colors_v.

The variable map is specified as follows:

  • If plane is 0, map is set to ColorMapY.
  • Otherwise (plane is not 0), map is set to ColorMapUV.

The current frame is updated as follows:

  • CurrFrame[ plane ][ startY + i ][ startX + j ] is set equal to palette[ map[ y * 4 + i ][ x * 4 + j ] ] for i = 0..h-1 and j = 0..w-1.

Predict Chroma From Luma Process

The chroma from luma process uses luma predicted samples to form a prediction for the chroma samples. The high frequencies are taken from the luma prediction and combined with DC predicted chroma samples.

The inputs to this process are:

  • a variable plane (greater than zero) specifying which plane is being predicted,

  • variables startX and startY specifying the location of the top left sample in the CurrFrame[ plane ] array of the current transform block,

  • a variable txSz, specifying the size of the current transform block.

The outputs of this process are modified chroma predicted samples in the current frame CurrFrame.

The variable w specifying the width of the transform block is set equal to Tx_Width[ txSz ].

The variable h specifying the height of the transform block is set equal to Tx_Height[ txSz ].

The variable subX is set equal to subsampling_x.

The variable subY is set equal to subsampling_y.

The variable alpha depends on the plane as follows:

  • If plane is equal to 1, alpha is set equal to CflAlphaU.

  • Otherwise (plane is equal to 2), alpha is set equal to CflAlphaV.

An array L (containing subsampled luma pixels with 3 fractional bits of precision) and lumaAvg (representing the average luma intensity with 3 fractional bits of precision) is specified as:

lumaAvg = 0
for ( i = 0; i < h; i++ ) {
    for ( j = 0; j < w; j++ ) {
        lumaX = (startX + j) << subX  
        lumaY = (startY + i) << subY
        t = 0
        for ( dy = 0; dy <= subY; dy += 1 ) 
            for ( dx = 0; dx <= subY; dx += 1 ) 
                t += CurrFrame[ 0 ][ Min( MaxLumaH - 1, lumaY + dy ) ]
                                   [ Min( MaxLumaW - 1, lumaX + dx ) ]
        v = t << ( 3 - subX - subY )
        L[ i ][ j ] = v
        lumaAvg += v
    }
}
lumaAvg >>= Tx_Width_Log2[ txSz ] + Tx_Height_Log2[ txSz ]

The predicted chroma pixels are specified as:

for ( i = 0; i < h; i++ ) {
    for ( j = 0; j < w; j++ ) {
        dc = CurrFrame[ plane ][ startY + i ][ startX + j ]
        scaledLuma = Round2Signed( alpha * ( L[ i ][ j ] - lumaAvg ), 6 )
        CurrFrame[ plane ][ startY + i ][ startX + j ] = Clip1( dc + scaledLuma )
    }
}

Reconstruction and Dequantization

This section details the process of reconstructing a block of coefficients using dequantization and inverse transforms.

Dequantization Functions

This section defines the functions get_dc_quant and get_ac_quant that are needed by the dequantization process.

The quantization parameters are derived from lookup tables.

The function dc_q( b ) is specified as Dc_Qlookup[ (BitDepth-8) >> 1 ][ Clip3( 0, 255, b ) ] where Dc_Qlookup is defined as follows:

Dc_Qlookup[ 3 ][ 256 ] = {
  {
    4, 8, 8, 9, 10, 11, 12, 12, 13, 14, 15, 16,
    17, 18, 19, 19, 20, 21, 22, 23, 24, 25, 26, 26,
    27, 28, 29, 30, 31, 32, 32, 33, 34, 35, 36, 37,
    38, 38, 39, 40, 41, 42, 43, 43, 44, 45, 46, 47,
    48, 48, 49, 50, 51, 52, 53, 53, 54, 55, 56, 57,
    57, 58, 59, 60, 61, 62, 62, 63, 64, 65, 66, 66,
    67, 68, 69, 70, 70, 71, 72, 73, 74, 74, 75, 76,
    77, 78, 78, 79, 80, 81, 81, 82, 83, 84, 85, 85,
    87, 88, 90, 92, 93, 95, 96, 98, 99, 101, 102, 104,
    105, 107, 108, 110, 111, 113, 114, 116, 117, 118, 120, 121,
    123, 125, 127, 129, 131, 134, 136, 138, 140, 142, 144, 146,
    148, 150, 152, 154, 156, 158, 161, 164, 166, 169, 172, 174,
    177, 180, 182, 185, 187, 190, 192, 195, 199, 202, 205, 208,
    211, 214, 217, 220, 223, 226, 230, 233, 237, 240, 243, 247,
    250, 253, 257, 261, 265, 269, 272, 276, 280, 284, 288, 292,
    296, 300, 304, 309, 313, 317, 322, 326, 330, 335, 340, 344,
    349, 354, 359, 364, 369, 374, 379, 384, 389, 395, 400, 406,
    411, 417, 423, 429, 435, 441, 447, 454, 461, 467, 475, 482,
    489, 497, 505, 513, 522, 530, 539, 549, 559, 569, 579, 590,
    602, 614, 626, 640, 654, 668, 684, 700, 717, 736, 755, 775,
    796, 819, 843, 869, 896, 925, 955, 988, 1022, 1058, 1098, 1139,
    1184, 1232, 1282, 1336
  },
  {
    4, 9, 10, 13, 15, 17, 20, 22, 25, 28, 31, 34,
    37, 40, 43, 47, 50, 53, 57, 60, 64, 68, 71, 75,
    78, 82, 86, 90, 93, 97, 101, 105, 109, 113, 116, 120,
    124, 128, 132, 136, 140, 143, 147, 151, 155, 159, 163, 166,
    170, 174, 178, 182, 185, 189, 193, 197, 200, 204, 208, 212,
    215, 219, 223, 226, 230, 233, 237, 241, 244, 248, 251, 255,
    259, 262, 266, 269, 273, 276, 280, 283, 287, 290, 293, 297,
    300, 304, 307, 310, 314, 317, 321, 324, 327, 331, 334, 337,
    343, 350, 356, 362, 369, 375, 381, 387, 394, 400, 406, 412,
    418, 424, 430, 436, 442, 448, 454, 460, 466, 472, 478, 484,
    490, 499, 507, 516, 525, 533, 542, 550, 559, 567, 576, 584,
    592, 601, 609, 617, 625, 634, 644, 655, 666, 676, 687, 698,
    708, 718, 729, 739, 749, 759, 770, 782, 795, 807, 819, 831,
    844, 856, 868, 880, 891, 906, 920, 933, 947, 961, 975, 988,
    1001, 1015, 1030, 1045, 1061, 1076, 1090, 1105, 1120, 1137, 1153, 1170,
    1186, 1202, 1218, 1236, 1253, 1271, 1288, 1306, 1323, 1342, 1361, 1379,
    1398, 1416, 1436, 1456, 1476, 1496, 1516, 1537, 1559, 1580, 1601, 1624,
    1647, 1670, 1692, 1717, 1741, 1766, 1791, 1817, 1844, 1871, 1900, 1929,
    1958, 1990, 2021, 2054, 2088, 2123, 2159, 2197, 2236, 2276, 2319, 2363,
    2410, 2458, 2508, 2561, 2616, 2675, 2737, 2802, 2871, 2944, 3020, 3102,
    3188, 3280, 3375, 3478, 3586, 3702, 3823, 3953, 4089, 4236, 4394, 4559,
    4737, 4929, 5130, 5347
  },
  {
    4, 12, 18, 25, 33, 41, 50, 60,
    70, 80, 91, 103, 115, 127, 140, 153,
    166, 180, 194, 208, 222, 237, 251, 266,
    281, 296, 312, 327, 343, 358, 374, 390,
    405, 421, 437, 453, 469, 484, 500, 516,
    532, 548, 564, 580, 596, 611, 627, 643,
    659, 674, 690, 706, 721, 737, 752, 768,
    783, 798, 814, 829, 844, 859, 874, 889,
    904, 919, 934, 949, 964, 978, 993, 1008,
    1022, 1037, 1051, 1065, 1080, 1094, 1108, 1122,
    1136, 1151, 1165, 1179, 1192, 1206, 1220, 1234,
    1248, 1261, 1275, 1288, 1302, 1315, 1329, 1342,
    1368, 1393, 1419, 1444, 1469, 1494, 1519, 1544,
    1569, 1594, 1618, 1643, 1668, 1692, 1717, 1741,
    1765, 1789, 1814, 1838, 1862, 1885, 1909, 1933,
    1957, 1992, 2027, 2061, 2096, 2130, 2165, 2199,
    2233, 2267, 2300, 2334, 2367, 2400, 2434, 2467,
    2499, 2532, 2575, 2618, 2661, 2704, 2746, 2788,
    2830, 2872, 2913, 2954, 2995, 3036, 3076, 3127,
    3177, 3226, 3275, 3324, 3373, 3421, 3469, 3517,
    3565, 3621, 3677, 3733, 3788, 3843, 3897, 3951,
    4005, 4058, 4119, 4181, 4241, 4301, 4361, 4420,
    4479, 4546, 4612, 4677, 4742, 4807, 4871, 4942,
    5013, 5083, 5153, 5222, 5291, 5367, 5442, 5517,
    5591, 5665, 5745, 5825, 5905, 5984, 6063, 6149,
    6234, 6319, 6404, 6495, 6587, 6678, 6769, 6867,
    6966, 7064, 7163, 7269, 7376, 7483, 7599, 7715,
    7832, 7958, 8085, 8214, 8352, 8492, 8635, 8788,
    8945, 9104, 9275, 9450, 9639, 9832, 10031, 10245,
    10465, 10702, 10946, 11210, 11482, 11776, 12081, 12409,
    12750, 13118, 13501, 13913, 14343, 14807, 15290, 15812,
    16356, 16943, 17575, 18237, 18949, 19718, 20521, 21387
  }
}

The function ac_q( b ) is specified as Ac_Qlookup[ (BitDepth-8) >> 1 ][ Clip3( 0, 255, b ) ] where Ac_Qlookup is defined as follows:

Ac_Qlookup[ 3 ][ 256 ] = {
  {
    4, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
    19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
    31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
    43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
    55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
    67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
    79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
    91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
    104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126,
    128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150,
    152, 155, 158, 161, 164, 167, 170, 173, 176, 179, 182, 185,
    188, 191, 194, 197, 200, 203, 207, 211, 215, 219, 223, 227,
    231, 235, 239, 243, 247, 251, 255, 260, 265, 270, 275, 280,
    285, 290, 295, 300, 305, 311, 317, 323, 329, 335, 341, 347,
    353, 359, 366, 373, 380, 387, 394, 401, 408, 416, 424, 432,
    440, 448, 456, 465, 474, 483, 492, 501, 510, 520, 530, 540,
    550, 560, 571, 582, 593, 604, 615, 627, 639, 651, 663, 676,
    689, 702, 715, 729, 743, 757, 771, 786, 801, 816, 832, 848,
    864, 881, 898, 915, 933, 951, 969, 988, 1007, 1026, 1046, 1066,
    1087, 1108, 1129, 1151, 1173, 1196, 1219, 1243, 1267, 1292, 1317, 1343,
    1369, 1396, 1423, 1451, 1479, 1508, 1537, 1567, 1597, 1628, 1660, 1692,
    1725, 1759, 1793, 1828
  },
  {
    4, 9, 11, 13, 16, 18, 21, 24, 27, 30, 33, 37,
    40, 44, 48, 51, 55, 59, 63, 67, 71, 75, 79, 83,
    88, 92, 96, 100, 105, 109, 114, 118, 122, 127, 131, 136,
    140, 145, 149, 154, 158, 163, 168, 172, 177, 181, 186, 190,
    195, 199, 204, 208, 213, 217, 222, 226, 231, 235, 240, 244,
    249, 253, 258, 262, 267, 271, 275, 280, 284, 289, 293, 297,
    302, 306, 311, 315, 319, 324, 328, 332, 337, 341, 345, 349,
    354, 358, 362, 367, 371, 375, 379, 384, 388, 392, 396, 401,
    409, 417, 425, 433, 441, 449, 458, 466, 474, 482, 490, 498,
    506, 514, 523, 531, 539, 547, 555, 563, 571, 579, 588, 596,
    604, 616, 628, 640, 652, 664, 676, 688, 700, 713, 725, 737,
    749, 761, 773, 785, 797, 809, 825, 841, 857, 873, 889, 905,
    922, 938, 954, 970, 986, 1002, 1018, 1038, 1058, 1078, 1098, 1118,
    1138, 1158, 1178, 1198, 1218, 1242, 1266, 1290, 1314, 1338, 1362, 1386,
    1411, 1435, 1463, 1491, 1519, 1547, 1575, 1603, 1631, 1663, 1695, 1727,
    1759, 1791, 1823, 1859, 1895, 1931, 1967, 2003, 2039, 2079, 2119, 2159,
    2199, 2239, 2283, 2327, 2371, 2415, 2459, 2507, 2555, 2603, 2651, 2703,
    2755, 2807, 2859, 2915, 2971, 3027, 3083, 3143, 3203, 3263, 3327, 3391,
    3455, 3523, 3591, 3659, 3731, 3803, 3876, 3952, 4028, 4104, 4184, 4264,
    4348, 4432, 4516, 4604, 4692, 4784, 4876, 4972, 5068, 5168, 5268, 5372,
    5476, 5584, 5692, 5804, 5916, 6032, 6148, 6268, 6388, 6512, 6640, 6768,
    6900, 7036, 7172, 7312
  },
  {
    4, 13, 19, 27, 35, 44, 54, 64,
    75, 87, 99, 112, 126, 139, 154, 168,
    183, 199, 214, 230, 247, 263, 280, 297,
    314, 331, 349, 366, 384, 402, 420, 438,
    456, 475, 493, 511, 530, 548, 567, 586,
    604, 623, 642, 660, 679, 698, 716, 735,
    753, 772, 791, 809, 828, 846, 865, 884,
    902, 920, 939, 957, 976, 994, 1012, 1030,
    1049, 1067, 1085, 1103, 1121, 1139, 1157, 1175,
    1193, 1211, 1229, 1246, 1264, 1282, 1299, 1317,
    1335, 1352, 1370, 1387, 1405, 1422, 1440, 1457,
    1474, 1491, 1509, 1526, 1543, 1560, 1577, 1595,
    1627, 1660, 1693, 1725, 1758, 1791, 1824, 1856,
    1889, 1922, 1954, 1987, 2020, 2052, 2085, 2118,
    2150, 2183, 2216, 2248, 2281, 2313, 2346, 2378,
    2411, 2459, 2508, 2556, 2605, 2653, 2701, 2750,
    2798, 2847, 2895, 2943, 2992, 3040, 3088, 3137,
    3185, 3234, 3298, 3362, 3426, 3491, 3555, 3619,
    3684, 3748, 3812, 3876, 3941, 4005, 4069, 4149,
    4230, 4310, 4390, 4470, 4550, 4631, 4711, 4791,
    4871, 4967, 5064, 5160, 5256, 5352, 5448, 5544,
    5641, 5737, 5849, 5961, 6073, 6185, 6297, 6410,
    6522, 6650, 6778, 6906, 7034, 7162, 7290, 7435,
    7579, 7723, 7867, 8011, 8155, 8315, 8475, 8635,
    8795, 8956, 9132, 9308, 9484, 9660, 9836, 10028,
    10220, 10412, 10604, 10812, 11020, 11228, 11437, 11661,
    11885, 12109, 12333, 12573, 12813, 13053, 13309, 13565,
    13821, 14093, 14365, 14637, 14925, 15213, 15502, 15806,
    16110, 16414, 16734, 17054, 17390, 17726, 18062, 18414,
    18766, 19134, 19502, 19886, 20270, 20670, 21070, 21486,
    21902, 22334, 22766, 23214, 23662, 24126, 24590, 25070,
    25551, 26047, 26559, 27071, 27599, 28143, 28687, 29247
  }
}

The function get_qindex( ignoreDeltaQ ) returns the quantizer index for the current block and is specified by the following:

  • If seg_feature_active( SEG_LVL_ALT_Q ) is equal to 1 the following ordered steps apply:

    1. Set the variable data equal to FeatureData[ segment_id ][ SEG_LVL_ALT_Q ].

    2. If segmentation_abs_or_delta_update is equal to 0, set data equal to base_q_idx + data

    3. Return Clip3( 0, 255, data ).

  • Otherwise, if ignoreDeltaQ is equal to 0 and delta_q_present is equal to 1, return CurrentQIndex.

  • Otherwise, return base_q_idx.

The function get_dc_quant( plane ) returns the quantizer value for the dc coefficient for a particular plane and is derived as follows:

  • If plane is equal to 0, return dc_q( get_qindex( 0 ) + deltaQYDc ).

  • Otherwise, return dc_q( get_qindex( 0 ) + deltaQUVDc ).

The function get_ac_quant( plane ) returns the quantizer value for the ac coefficient for a particular plane and is derived as follows:

  • If plane is equal to 0, return ac_q( get_qindex( 0 ) ).

  • Otherwise, return ac_q( get_qindex( 0 ) + deltaQUVAc ).

Reconstruct Process

The reconstruct process is invoked to perform dequantization, inverse transform and reconstruction. This process is triggered at a point defined by a function call to reconstruct in the residual syntax table described in section 5.8.29.

The inputs to this process are:

  • a variable plane specifying which plane is being reconstructed,

  • variables x and y specifying the location of the top left sample in the CurrFrame[ plane ] array of the current transform block,

  • a variable txSz, specifying the size of the transform block.

The outputs of this process are reconstructed samples in the current frame CurrFrame.

The reconstruction and dequantization process is defined as follows:

The variable dqDenom is set equal to 2 if txSz is equal to TX_32X32, otherwise dqDenom is set equal to 1.

The variable log2W (specifying the base 2 logarithm of the width of the transform block) is set equal to Tx_Width_Log2[ txSz ].

The variable log2H (specifying the base 2 logarithm of the height of the transform block) is set equal to Tx_Height_Log2[ txSz ].

The variable w (specifying the width of the transform block) is set equal to 1 << log2W.

The variable h (specifying the height of the transform block) is set equal to 1 << log2H.

The variable flipUD is derived as follows. If PlaneTxType is equal to one of FLIPADST_DCT, FLIPADST_ADST, V_FLIPADST, or FLIPADST_FLIPADST, flipUD is set equal to 1. Otherwise, flipUD is set equal to 0.

The variable flipLR is derived as follows. If PlaneTxType is equal to one of DCT_FLIPADST, ADST_FLIPADST, H_FLIPADST, or FLIPADST_FLIPADST, flipLR is set equal to 1. Otherwise, flipLR is set equal to 0.

The following ordered steps apply:

  1. For i = 0..(h-1), for j = 0..(w-1), the following ordered steps apply:

    a. The variable q is derived as follows:

    • If i is equal to 0 and j is equal to 0, the variable q is set equal to get_dc_quant( plane ).

    • Otherwise (i, j or both are not equal to 0), the variable q is set equal to get_ac_quant( plane ).

    b. The variable q2 is derived as follows:

    • If using_qmatrix is equal to 1, PlaneTxType is less than IDTX, and SegQMLevel[ segment_id ] is less than 15, q2 is set equal to Round2( q * Quantizer_Matrix[ SegQMLevel[ segment_id ] ][ plane > 0 ][ Qm_Offset[ txSz ] + i * w + j ], 4 ).

    • Otherwise, q2 is set equal to q.

    c. Dequant[ i ][ j ] is set equal to ( Tokens[ i * w + j ] * q2 ) / dqDenom.

  2. Invoke the 2D inverse transform block process defined in section 7.9.2 with the variable txSz as input. The inverse transform outputs are stored back to the Dequant buffer.

  3. For i = 0..(h-1), for j = 0..(w-1), the following applies:

    • The variable xx is set equal to flipLR ? ( w - j - 1 ) : j.

    • The variable yy is set equal to flipUD ? ( h - i - 1 ) : i.

    • CurrFrame[ plane ][ y + yy ][ x + xx ] is set equal to Clip1( CurrFrame[ plane ][ y + yy ][ x + xx ] + Dequant[ i ][ j ] ).

It is a requirement of bitstream conformance that the values written into the Dequant array in steps 1 and 2 are representable by a signed integer with 8 + BitDepth bits.

Inverse Transform Process

This section details the inverse transforms used during the reconstruction processes detailed in section 7.8.

1D Transforms

Butterfly Functions

This section defines the butterfly functions B, H, SB, SH used by the 1D transform processes.

The inverse transform process works by writing values into an array T. It is a requirement of bitstream conformance that the values saved into the array T are representable by a signed integer using 8 + BitDepth bits of precision.

Note: The inverse asymmetric discrete sine transforms also make use of an intermediate array named S. The values in this array require higher precision to avoid overflow. Using signed integers with 24 + BitDepth bits of precision is enough to avoid overflow.

The function brev(numBits, x) returns the bit-reversal of numBits of x and is specified as follows:

brev( numBits, x ) {
    t = 0
    for ( i = 0; i < numBits; i++ ) {
        bit = (x >> i) & 1
        t += bit << (numBits - 1 - i)
    }
    return t
}

The function B( a, b, angle, 0 ) performs a butterfly rotation specified by the following ordered steps:

  1. The variable x is set equal to T[ a ] * cos64( angle ) - T[ b ] * sin64( angle ).

  2. The variable y is set equal to T[ a ] * sin64( angle ) + T[ b ] * cos64( angle ).

  3. T[ a ] is set equal to Round2( x, 14 ).

  4. T[ b ] is set equal to Round2( y, 14 ).

It is a requirement of bitstream conformance that the values saved into the array T by this function are representable by a signed integer using 8 + BitDepth bits of precision.

The function cos64( angle ) is specified for integer values of the input angle by the following ordered steps:

  1. Set a variable angle2 equal to angle & 127.

  2. If angle2 is greater than or equal to 0 and less than or equal to 32, return cos64_lookup[ angle2 ].

  3. If angle2 is greater than 32 and less than or equal to 64, return cos64_lookup[ 64 - angle2 ] * -1.

  4. If angle2 is greater than 64 and less than or equal to 96, return cos64_lookup[ angle2 - 64 ] * -1.

  5. Otherwise (if angle2 is greater than 96 and less than 128), return cos64_lookup[ 128 - angle2 ].

Where cos64_lookup is a constant lookup table defined as:

cos64_lookup[ 33 ] = {
    16384, 16364, 16305, 16207, 16069, 15893, 15679, 15426,
    15137, 14811, 14449, 14053, 13623, 13160, 12665, 12140,
    11585, 11003, 10394, 9760, 9102, 8423, 7723, 7005,
    6270, 5520, 4756, 3981, 3196, 2404, 1606, 804,
    0
}

The function sin64( angle ) is defined to be cos64( angle - 32 ).

Note: The cos64 function implements the expression round( 16384 * cos( angle * pi / 64 ) ). The sin64 function implements the expression round( 16384 * sin( angle * pi / 64 ) ).

When the angle is equal to 16 + 32 * k for integer k the butterfly rotation can be equivalently performed with two fewer multiplications (because the magnitude of cos64(16 + 32 * k) is always equal to that of sin64(16 + 32 * k)) by the following process:

  1. The variable v is set equal to (angle & 32) ? T[ a ] + T[ b ] : T[ a ] - T[ b ].

  2. The variable w is set equal to (angle & 32) ? -T[ a ] + T[ b ] : T[ a ] + T[ b ].

  3. The variable x is set equal to v * cos64( angle ).

  4. The variable y is set equal to w * cos64( angle ).

  5. T[ a ] is set equal to Round2( x, 14 ).

  6. T[ b ] is set equal to Round2( y, 14 ).

It is a requirement of bitstream conformance that the angle is equal to 16 + 32 * k for integer k, the variables v and w are representable by a signed integer using 8 + BitDepth bits of precision.

The function B( a ,b, angle, 1 ) performs a butterfly rotation and flip specified by the following ordered steps:

  1. The function B( a, b, angle, 0 ) is invoked.

  2. The contents of T[ a ] and T[ b ] are exchanged.

The function H( a, b, 0 ) performs a Hadamard rotation specified by the following ordered steps:

  1. The variable x is set equal to T[ a ].

  2. The variable y is set equal to T[ b ].

  3. T[ a ] is set equal to x + y.

  4. T[ b ] is set equal to x - y.

It is a requirement of bitstream conformance that the values saved into the array T by this function are representable by a signed integer using 8 + BitDepth bits of precision.

The function H( a, b, 1 ) performs a Hadamard rotation with flipped indices and is specified as follows:

  1. The function H( b, a, 0 ) is invoked.

The function SB( a, b, angle, 0 ) performs a butterfly rotation according to the following ordered steps:

  1. S[ a ] is set equal to T[ a ] * cos64( angle ) - T[ b ] * sin64( angle ).

  2. S[ b ] is set equal to T[ a ] * sin64( angle ) + T[ b ] * cos64( angle ).

The function SB( a, b, angle, 1 ) performs a butterfly rotation and flip according to the following ordered steps:

  1. The function SB( a, b, angle, 0 ) is invoked.

  2. The contents of S[ a ] and S[ b ] are exchanged.

The function SH( a, b ) performs a Hadamard rotation and rounding specified by the following ordered steps:

  1. T[ a ] is set equal to Round2( S[ a ] + S[ b ], 14 ).

  2. T[ b ] is set equal to Round2( S[ a ] - S[ b ], 14 ).

Inverse DCT Array Permutation Process

This process performs an in-place permutation of the array T of length 2n for 2 ≤ n ≤ 5 which is required before execution of the inverse DCT process.

The input to this process is a variable n that specifies the base 2 logarithm of the length of the input array.

A temporary array named copyT is set equal to T.

T[ i ] is set equal to copyT[ brev( n, i ) ] for i = 0..((1 << n) - 1).

Inverse DCT Process

This process performs an in-place inverse discrete cosine transform of the permuted array T which is of length 2n for 2 ≤ n ≤ 5.

The input to this process is a variable n that specifies the base 2 logarithm of the length of the input array.

The variable n0 is set equal to 1 << n.

The variable n1 is set equal to 1 << (n - 1).

The variable n2 is set equal to 1 << (n - 2).

The variable n3 is set equal to 1 << (n - 3).

The following ordered steps apply:

  1. If n is equal to 2, invoke B( 0, 1, 16, 1 ), otherwise recursively invoke the inverse DCT defined in this section with the variable n set equal to n - 1.

  2. Invoke B( n1+i, n0-1-i, 32-brev( 5, n1+i), 0 ) for i = 0..(n2-1).

  3. If n is greater than or equal to 3:

    a. Invoke H( n1 + 4 * i + 2 * j, n1 + 1 + 4 * i + 2 * j, j ) for i = 0..(n3-1), j = 0..1.

  4. If n is equal to 5:

    a. Invoke B( n0 - n + 3 - n2 * j - 4 * i, n1 + n - 4 + n2 * j + 4 * i, 28 - 16 * i + 56 * j, 1 ) for i = 0..1, j = 0..1.

    b. Invoke H( n1 + n3 * j + i, n1 + n2 - 5 + n3 * j - i, j & 1 ) for i = 0..1, j = 0..3.

  5. If n is greater than or equal to 4:

    a. Invoke B( n0 - n + 2 - i - n2 * j, n1 + n - 3 + i + n2 * j, 24 + 48 * j, 1 ) for i = 0..(n == 5), j = 0..1.

    b. Invoke H( n1 + n2 * j + i, n1 + n2 - 1 + n2 * j - i, j & 1 ) for i = 0..(2n - 7), j = 0..1.

  6. If n is greater than or equal to 3:

    a. Invoke B( n0 - n3 - 1 - i, n1 + n3 + i, 16, 1 ) for i = 0..(n3-1).

  7. Invoke H( i, n0 - 1 - i, 0 ) for i = 0..(n1 - 1).

Inverse ADST Input Array Permutation Process

This process performs the in-place permutation of the array T of length 2n which is required as the first step of the inverse ADST.

The input to this process is a variable n that specifies the base 2 logarithm of the length of the input array.

The variable n0 is set equal to 1 << n.

The variable n1 is set equal to 1 << (n - 1).

A temporary array named copyT is set equal to T.

The values at even locations T[ 2 * i ] are set equal to copyT[ n0 - 1 - 2 * i ] for i = 0..(n1-1).

The values at odd locations T[ 2 * i + 1 ] are set equal to copyT[ 2 * i ] for i = 0..(n1-1).

Inverse ADST Output Array Permutation Process

This process performs the in-place permutation of the array T of length 2n which is required before the final step of the inverse ADST.

The input to this process is a variable n that specifies the base 2 logarithm of the length of the input array.

A temporary array named copyT is set equal to T.

The permutation depends on n as follows:

  • If n is equal to 4, T[ 8 * a + 4 * b + 2 * c + d ] is set equal to copyT[ 8 * (d^c) + 4 * (c^b) + 2 * (b^a) + a ] for a = 0..1 and b = 0..1 and c = 0..1 and d = 0..1.

  • Otherwise (n is equal to 3), T[ 4 * a + 2 * b + c ] is set equal to copyT[ 4 * (c^b) + 2 * (b^a) + a ] for a = 0..1 and b = 0..1 and c = 0..1.

Inverse ADST4 Process

This process does an in-place transform of the array T to perform an inverse ADST.

The following ordered steps apply:

s0 = SINPI_1_9 * T[ 0 ]
s1 = SINPI_2_9 * T[ 0 ]
s2 = SINPI_3_9 * T[ 1 ]
s3 = SINPI_4_9 * T[ 2 ]
s4 = SINPI_1_9 * T[ 2 ]
s5 = SINPI_2_9 * T[ 3 ]
s6 = SINPI_4_9 * T[ 3 ]
v = T[ 0 ] - T[ 2 ] + T[ 3 ]
s7 = SINPI_3_9 * v
x0 = s0 + s3 + s5
x1 = s1 - s4 - s6
x2 = s7
x3 = s2
s0 = x0 + x3
s1 = x1 + x3
s2 = x2
s3 = x0 + x1 - x3
T[ 0 ] = Round2( s0, 14 )
T[ 1 ] = Round2( s1, 14 )
T[ 2 ] = Round2( s2, 14 )
T[ 3 ] = Round2( s3, 14 )

It is a requirement of bitstream conformance that the values saved into the variable v and into the array T by this function are representable by a signed integer using 8 + BitDepth bits of precision.

The constants used in this function are defined as:

Name of constant Value of constant
SINPI_1_9 5283
SINPI_2_9 9929
SINPI_3_9 13377
SINPI_4_9 15212
Inverse ADST8 Process

This process does an in-place transform of the array T using a higher precision array S for intermediate results. The following ordered steps apply:

  1. Invoke the ADST input array permutation process specified in section 7.9.1.4 with the input variable n set equal to 3.

  2. Invoke SB( 2 * i, 1 + 2 * i, 30 - 8 * i, 1 ) for i = 0..3.

  3. Invoke SH( i, 4 + i ) for i = 0..3.

  4. Invoke SB( 4 + 3 * i, 5 + i, 24 - 16 * i, 1 ) for i = 0..1.

  5. Invoke SH( 4 + i, 6 + i ) for i = 0..1.

  6. Invoke H( i, 2 + i, 0 ) for i = 0..1.

  7. Invoke B( 2 + 4 * i, 3 + 4 * i, 16, 1 ) for i = 0..1.

  8. Invoke the ADST output array permutation process specified in section 7.9.1.5 with the input variable n set equal to 3.

  9. Set T[ 1 + 2 * i ] equal to -T[ 1 + 2 * i ] for i = 0..3.

Inverse ADST16 Process

This process does an in-place transform of the array T using a higher precision array S for intermediate results. The following ordered steps apply:

  1. Invoke the ADST input array permutation process specified in section 7.9.1.4 with the input variable n set equal to 4.

  2. Invoke SB( 2 * i, 1 + 2 * i, 31 - 4 * i, 1 ) for i = 0..7.

  3. Invoke SH( i, 8 + i ) for i = 0..7.

  4. Invoke SB( 8 + 2 * i, 9 + 2 * i, 28 - 16 * i, 1 ) for i = 0..3.

  5. Invoke SH( 8 + i, 12 + i ) for i = 0..3.

  6. Invoke H( i, 4 + i, 0 ) for i = 0..3.

  7. Invoke SB( 4 + 8 * i + 3 * j, 5 + 8 * i + j, 24 - 16 * j, 1 ) for i = 0..1, for j = 0..1.

  8. Invoke SH( 4 + 8 * j + i, 6 + 8 * j + i ) for i = 0..1, j = 0..1.

  9. Invoke H( 8 * j + i, 2 + 8 * j + i, 0 ) for i = 0..1, for j = 0..1.

  10. Invoke B( 2 + 4 * j + 8 * i, 3 + 4 * j + 8 * i, 48 + 64 * (i ^ j), 0 ) for i = 0..1, for j = 0..1.

  11. Invoke the ADST output array permutation process specified in section 7.9.1.5 with the input variable n set equal to 4.

  12. Set T[ 1 + 12 * j + 2 * i ] equal to - T[ 1 + 12 * j + 2 * i ] for i = 0..1, for j = 0..1.

Inverse ADST Process

This process performs an in-place inverse ADST process on the array T of size 2n for 2 ≤ n ≤ 4.

The input to this process is a variable n that specifies the base 2 logarithm of the length of the input array.

The process to invoke depends on n as follows:

  • If n is equal to 2, invoke the Inverse ADST4 process specified in section 7.9.1.6.

  • Otherwise if n is equal to 3, invoke the Inverse ADST8 process specified in section 7.9.1.7.

  • Otherwise (n is equal to 4), invoke the Inverse ADST16 process specified in section 7.9.1.8.

Inverse Walsh-Hadamard Transform Process

The input to this process is a variable shift that specifies the amount of pre-scaling.

This process does an in-place transform of the array T (of length 4) by the following ordered steps:

a = T[ 0 ] >> shift
c = T[ 1 ] >> shift
d = T[ 2 ] >> shift
b = T[ 3 ] >> shift
a += c
d -= b
e = (a - d) >> 1
b = e - b
c = e - c
a -= b
d += c
T[ 0 ] = a
T[ 1 ] = b
T[ 2 ] = c
T[ 3 ] = d
Inverse Identity Transform 4 Process

The process does an in-place transform of the array T (of length 4) by the following calculation for i = 0..3:

T[ i ] = Round2( T[ i ] * 23170, 14 )
Inverse Identity Transform 8 Process

The process does an in-place transform of the array T (of length 8) by the following calculation for i = 0..7:

T[ i ] = T[ i ] * 2
Inverse Identity Transform 16 Process

The process does an in-place transform of the array T (of length 16) by the following calculation for i = 0..15:

T[ i ] = Round2( T[ i ] * 46340, 14 )
Inverse Identity Transform 32 Process

The process does an in-place transform of the array T (of length 32) by the following calculation for i = 0..31:

T[ i ] = T[ i ] * 4
Inverse Identity Transform Process

This process performs an in-place identity transform process (with a size-dependent scaling factor) on the array T of size 2n for 2 ≤ n ≤ 5.

The input to this process is a variable n that specifies the base 2 logarithm of the length of the input array.

The process to invoke depends on n as follows:

  • If n is equal to 2, invoke the inverse identity transform 4 process in section 7.9.1.11.

  • Otherwise, if n is equal to 3, invoke the inverse identity transform 8 process in section 7.9.1.12.

  • Otherwise, if n is equal to 4, invoke the inverse identity transform 16 process in section 7.9.1.13.

  • Otherwise (n is equal to 5), invoke the inverse identity transform 32 process in section 7.9.1.14.

2D Inverse Transform

This process performs a 2D inverse transform for an array stored in the 2D array Dequant.

The input to this process is a variable txSz that specifies the transform size.

Set the variable log2W equal to Tx_Width_Log2[ txSz ].

Set the variable log2H equal to Tx_Height_Log2[ txSz ].

Set the variable w equal to 1 << log2W.

Set the variable h equal to 1 << log2H.

The row transforms with i = 0..(h-1) are applied as follows:

  • Set T[ j ] equal to Dequant[ i ][ j ] for j = 0..(w-1).

  • If Lossless is equal to 1, invoke the Inverse WHT process as specified in section 7.9.1.10 with shift equal to 2.

  • Otherwise, if PlaneTxType is equal to one of DCT_DCT, ADST_DCT, FLIPADST_DCT or H_DCT, apply an inverse DCT as follows:

    1. Invoke the inverse DCT permutation process as specified in section 7.9.1.2 with the input variable n equal to log2W.

    2. Invoke the inverse DCT process as specified in section 7.9.1.3 with the input variable n equal to log2W.

  • Otherwise if PlaneTxType is equal to one of DCT_ADST, ADST_ADST, DCT_FLIPADST, FLIPADST_FLIPADST, ADST_FLIPADST, FLIPADST_ADST, H_ADST, or H_FLIPADST, invoke the inverse ADST process as specified in section 7.9.1.9 with input variable n equal to log2W.

  • Otherwise, invoke the inverse identity transform process specified in section 7.9.1.15 with the input variable n equal to log2W.

  • The array Dequant is then updated as follows:

    • If Abs( log2W - log2H ) is equal to 1, set Dequant[ i ][ j ] equal to Round2( T[ j ] * 23170, 14 ) for j = 0..(w-1).

    • Otherwise (Abs( log2W - log2H ) is not equal to 1), set Dequant[ i ][ j ] equal to T[ j ] for j = 0..(w-1).

The column transforms with j = 0..(w-1) are applied as follows:

  • Set T[ i ] equal to Dequant[ i ][ j ] for i = 0..(h-1).

  • If Lossless is equal to 1, invoke the Inverse WHT process as specified in section 7.9.1.10 with shift equal to 0.

  • Otherwise, if PlaneTxType is equal to one of DCT_DCT, DCT_ADST, DCT_FLIPADST or V_DCT, apply an inverse DCT as follows:

    1. Invoke the inverse DCT permutation process as specified in section 7.9.1.2 with the input variable n equal to log2H.

    2. Invoke the inverse DCT process as specified in section 7.9.1.3 with the input variable n equal to log2H.

  • Otherwise, if PlaneTxType is equal to one of ADST_DCT, ADST_ADST, FLIPADST_DCT, FLIPADST_FLIPADST, ADST_FLIPADST, FLIPADST_ADST, V_ADST, or V_FLIPADST, invoke the inverse ADST process as specified in section 7.9.1.9 with input variable n equal to log2H.

  • Otherwise, invoke the inverse identity transform process specified in section 7.9.1.15 with the input variable n equal to log2H.

  • Dequant[ i ][ j ] is set equal to T[ i ] for i = 0..(h-1).

Loop Filter Process

Input to this process is the array CurrFrame of reconstructed samples.

Output from this process is a modified array CurrFrame containing deblocked samples.

The purpose of the loop filter is to eliminate (or at least reduce) visually objectionable artifacts associated with the semi-independence of the coding of super blocks and their constituent sub-blocks.

The loop filter is applied on all vertical boundaries followed by all horizontal boundaries as follows:

for ( plane = 0; plane < 3; plane++ ) {
    if ( ( plane == 0 && ( loop_filter_level[ 0 ] || loop_filter_level[ 1 ] ) ) ||
         ( plane > 0 && loop_filter_level[ 1 + plane ] ) ) {
        for ( pass = 0; pass < 2; pass++ ) {
            rowStep = ( plane > 0 ) ? 1 : ( 1 << subsampling_y )
            colStep = ( plane > 0 ) ? 1 : ( 1 << subsampling_x )
            for ( row = 0; row < MiRows; row += rowStep )
                for ( col = 0; col < MiCols; col += colStep )
                    loop_filter_edge( plane, pass, row, col )
        }
    }
}

When the function loop_filter_edge is called, the edge loop filter process specified in section 7.10.1 is invoked with the variables plane, pass, row, and col as inputs.

Note: The loop filter is an integral part of the decoding process, in that the results of loop filtering are used in the prediction of subsequent frames.

Note: The loop filtering is designed so that any order of filtering for the edges will give identical results, provided that the vertical boundaries are filtered before the horizontal boundaries.

Note: The loop filter applies after the macroblocks have been “reconstructed” (i.e., had their prediction summed with their residual); correct decoding is predicated on the fact that already-constructed portions of the current frame referenced via intra prediction are not yet filtered.

Edge Loop Filter Process

The inputs to this process are:

  • a variable plane specifying whether we are filtering Y, U, or V samples,

  • a variable pass specifying the direction of the edges. pass equal to 0 means we are filtering vertical block boundaries, and pass equal to 1 means we are filtering horizontal block boundaries,

  • variables row and col specifying the location of the edge in units of 4x4 blocks in the luma plane.

The outputs of this process are modified values in the array CurrFrame.

The variables subX and subY describing the subsampling of the current plane are derived as follows:

  • If plane is equal to 0, subX and subY are set equal to 0.

  • Otherwise (plane is not equal to 0), subX is set equal to subsampling_x and subY is set equal to subsampling_y.

The variables dx and dy are derived as follows:

  • If pass is equal to 0, then dx is set equal to 1, dy is set equal to 0.

  • Otherwise (pass is equal to 1), dy is set equal to 1, dx is set equal to 0.

dx and dy specify the offset between the samples to be filtered.

The variable x is set equal to col * MI_SIZE.

The variable y is set equal to row * MI_SIZE.

x and y contain the location in luma coordinates.

The variable onScreen (equal to 1 if the samples on both sides of the boundary lie in the visible area) is derived as follows:

  • If x is greater than or equal to FrameWidth, onScreen is set equal to 0.

  • Otherwise, if y is greater than or equal to FrameHeight, onScreen is set equal to 0.

  • Otherwise, if pass is equal to 0 and x is equal to 0, onScreen is set equal to 0.

  • Otherwise, if pass is equal to 1 and y is equal to 0, onScreen is set equal to 0.

  • Otherwise, onScreen is set equal to 1.

If onScreen is equal to 0 and i is equal to 0, then this process immediately returns and no filtering is applied to this edge.

The variables xP and yP (containing the location in the current plane) are derived as follows:

  • Set xP equal to x >> subX

  • Set yP equal to y >> subY

The variables prevRow and prevCol (containing the location of the mode info block on the other side of the boundary) are derived as follows:

  • Set prevRow equal to row - ( dy << subY )

  • Set prevCol equal to col - ( dx << subX )

Set the variable MiSize equal to MiSizes[ row ][ col ].

Set the variable txSz equal to LoopfilterTxSizes[ plane ][ row ][ col ].

Set the variable planeSize equal to get_plane_residual_size( MiSize, plane )

Set the variable skip equal to Skips[ row ][ col ].

Set the variable isIntra equal to RefFrames[ row ][ col ][ 0 ] <= INTRA_FRAME.

Set the variable prevTxSz equal to get_tx_size( plane, TxSizes[ prevRow ][ prevCol ] ).

Set the variable prevSkip equal to Skips[ prevRow ][ prevCol ].

Set the variable prevIsIntra equal to RefFrames[ prevRow ][ prevCol ][ 0 ] <= INTRA_FRAME.

The variable isBlockEdge (equal to 1 if the samples cross a prediction block edge) is derived as follows:

  • If pass is equal to 0 and xP is an exact multiple of Block_Width[ planeSize ], isBlockEdge is set equal to 1.

  • Otherwise, if pass is equal to 1 and yP is an exact multiple of Block_Height[ planeSize ], isBlockEdge is set equal to 1.

  • Otherwise, isBlockEdge is set equal to 0.

The variable isTxEdge (equal to 1 if the samples cross a transform block edge) is derived as follows:

  • If pass is equal to 0 and xP is an exact multiple of Tx_Width[ txSz ], isTxEdge is set equal to 1.

  • Otherwise, if pass is equal to 1 and yP is an exact multiple of Tx_Height[ txSz ], isTxEdge is set equal to 1.

  • Otherwise, isTxEdge is set equal to 0.

The variable isTileEdge (equal to 1 if the samples come from different tiles is derived as follows:

  • If TileNums[ prevRow ][ prevCol ] is equal to TileNums[ row ][ col ], isTileEdge is set equal to 0.

  • Otherwise, isTileEdge is set equal to 1

The variable isTileGroupEdge (equal to 1 if the samples come from different tile groups is derived as follows:

  • If TileStarts[ prevRow ][ prevCol ] is equal to TileStarts[ row ][ col ], isTileGroupEdge is set equal to 0.

  • Otherwise, isTileGroupEdge is set equal to 1

The variable applyFilter (equal to 1 if the samples are filtered) is derived as follows:

  • If isTxEdge is equal to 0, applyFilter is set equal to 0.

  • Otherwise, if pass is equal to 0 and loop_filter_across_tiles is equal to 0 and isTileEdge is equal to 1, applyFilter is set equal to 0

  • Otherwise, if pass is equal to 1 and loop_filter_across_tiles is equal to 0 and dependent_tiles is equal to 0 and isTileEdge is equal to 1, applyFilter is set equal to 0

  • Otherwise, if pass is equal to 1 and loop_filter_across_tiles is equal to 0 and dependent_tiles is equal to 1 and isTileGroupEdge is equal to 1, applyFilter is set equal to 0

  • Otherwise, if isBlockEdge is equal to 1 or skip is equal to 0 or isIntra is equal to 1 or prevSkip is equal to 0 or prevIsIntra is equal to 1, applyFilter is set equal to 1.

  • Otherwise applyFilter is set equal to 0.

The filter size process specified in section 7.10.2 is invoked with the inputs txSz, prevTxSz, pass, subX, and subY, plane and the output assigned to the variable filterSize (containing the maximum filter size that can be used).

The adaptive filter strength process specified in section 7.10.3 is invoked with the inputs row, col, plane, and pass, and the output assigned to the variables lvl, limit, blimit, and thresh.

If lvl is equal to 0, the adaptive filter strength process specified in section 7.10.3 is invoked with the inputs prevRow, prevCol, plane, and pass, and the output assigned to the variables lvl, limit, blimit, and thresh.

For the variable i taking values from 0 to MI_SIZE - 1, the following applies:

  • If applyFilter is equal to 1 and lvl is greater than zero, the sample filtering process specified in section 7.10.5 is invoked with the input variable x set equal to xP + dy * i, the input variable y set equal to yP + dx * i, and the variables plane, limit, blimit, thresh, plane, dx, dy, filterSize.

Note: the vector (dx,dy) represents the direction of the filter, while (dy,dx) represents the direction of the boundary.

Filter Size Process

The inputs to this process are:

  • a variable txSz specifying the size of the transform block,

  • a variable prevTxSz specifying the size of the transform block on the other side of the boundary,

  • a variable pass specifying the direction of the edges,

  • variables subX and subY describing the subsampling of the current plane,

  • a variable plane specifying whether we are filtering Y, U, or V samples.

The output of this process is the variable filterSize containing the maximum filter size that can be used.

The purpose of this process is to reduce the width of the chroma filters and to ensure that different boundaries can be filtered in parallel.

The variable baseSize is set equal to Min(prevTxSz, txSz).

The output variable filterSize is derived as follows:

  • If plane is equal to 0, filterSize is set equal to Min( TX_16X16, baseSize ),

  • Otherwise, (plane is greater than 0), filterSize is set equal to Min( TX_8X8, baseSize ).

Adaptive Filter Strength Process

The inputs to this process are:

  • the variables row and col specifying the luma location in units of 4x4 blocks,

  • the variable plane specifying whether we are filtering Y, U or V samples,

  • the variable pass specifying the direction of the edge being filtered. pass equal to 0 means we are filtering vertical block boundaries, and pass equal to 1 means we are filtering horizontal block boundaries.

The outputs of this process are the variables lvl, limit, blimit, and thresh.

The output variable lvl is derived as follows:

  • The variable segment is set equal to SegmentIds[ row ][ col ].

  • The variable ref is set equal to RefFrames[ row ][ col ][ 0 ].

  • The variable mode is set equal to YModes[ row ][ col ].

  • The variable modeType is derived as follows:

    1. If mode is equal to NEARESTMV or NEARMV or NEWMV, modeType is set equal to 1.

    2. Otherwise (if mode is an intra type or GLOBALMV or GLOBAL_GLOBALMV), modeType is set equal to 0.

  • The variable deltaLF is derived as follows:

    1. If delta_lf_multi is equal to 0, deltaLF is set equal to DeltaLFs[ row ][ col ][ 0 ].

    2. Otherwise (delta_lf_multi is equal to 1), deltaLF is set equal to DeltaLFs[ row ][ col ][ ( plane == 0 ) ? pass : ( plane + 1 ) ].

  • The adaptive filter strength selection process specified in section 7.10.4 is invoked, with segment, ref, modeType, deltaLF, plane, and pass as inputs, and the output being the output variable lvl.

The variable shift is derived as follows:

  • If loop_filter_sharpness is greater than 4, shift is set equal to 2.

  • Otherwise, if loop_filter_sharpness is greater than 0, shift is set equal to 1.

  • Otherwise, shift is set equal to 0.

The output variable limit is derived as follows:

  • If loop_filter_sharpness is greater than 0, limit is set equal to Clip3( 1, 9 - loop_filter_sharpness, lvl >> shift ).

  • Otherwise, limit is set equal to Max( 1, lvl >> shift ).

The output variable blimit is set equal to 2 * (lvl + 2) + limit.

The output variable thresh is set equal to lvl >> 4.

Adaptive Filter Strength Selection Process

The inputs to this process are:

  • The variable segment, specifying the current segment id,

  • The variable ref, specifying the reference frame type (INTRA_FRAME, LAST_FRAME, etc.),

  • The variable modeType, specifying the loop filter mode type,

  • The variable deltaLF, specifying the loop filter delta value,

  • The variable plane, specifying whether we are filtering Y, U or V samples,

  • The variable pass, specifying the direction of the edge being filtered. pass equal to 0 means we are filtering vertical block boundaries, and pass equal to 1 means we are filtering horizontal block boundaries.

The output of this process is a filter strength level.

This process is invoked to select a loop filter strength level.

The variable i is set equal ( plane == 0 ) ? pass : ( plane + 1 ).

The variable baseFilterLevel is set equal to Clip3( 0, MAX_LOOP_FILTER, deltaLF + loop_filter_level[ i ] ).

The following ordered steps apply:

  1. The variable nShift is set equal to baseFilterLevel >> 5.

  2. lvlSeg is set equal to baseFilterLevel.

  3. The variable feature is set equal to SEG_LVL_ALT_LF_Y_V + i.

  4. If seg_feature_active_idx( segment, feature ) is equal to 1 the following ordered steps apply:

    a. If segmentation_abs_or_delta_update is equal to 1, lvlSeg is set equal to FeatureData[ segment ][ feature ].

    b. If segmentation_abs_or_delta_update is equal to 0, lvlSeg is set equal to FeatureData[ segment ][ feature ] + lvlSeg.

    c. lvlSeg is set equal to Clip3( 0, MAX_LOOP_FILTER, lvlSeg ).

  5. If loop_filter_delta_enabled is equal to 1, then the following ordered steps apply:

    a. If ref is equal to INTRA_FRAME, then lvlSeg is set equal to lvlSeg + ( loop_filter_ref_deltas[ INTRA_FRAME ] << nShift ).

    b. Otherwise, if ref is not equal to INTRA_FRAME, then lvlSeg is set equal to lvlSeg + ( loop_filter_ref_deltas[ ref ] << nShift ) + ( loop_filter_mode_deltas[ modeType ] << nShift ).

    c. lvlSeg is set equal to Clip3(0, MAX_LOOP_FILTER, lvlSeg).

  6. Return lvlSeg.

Sample Filtering Process

The inputs to this process are:

  • variables x and y specifying the location within CurrFrame[ plane ],

  • a variable plane specifying whether the block is the Y, U or V plane,

  • variables limit, blimit, thresh that specify the strength of the filtering operation,

  • variables dx and dy specifying the direction perpendicular to the edge being filtered,

  • a variable filterSize of specifying the maximum size of filter allowed.

The outputs of this process are modified values in the array CurrFrame.

First the filter mask process specified in section 7.10.5.1 is invoked with the inputs x, y, plane, limit, blimit, thresh, dx, dy, and filterSize, and the output is assigned to the variables hevMask, filterMask, flatMask, and flatMask2.

Then the appropriate filter process is invoked with the inputs x, y, plane, dx, dy as follows:

  • If filterMask is equal to 0, no filter is invoked.

  • Otherwise, if filterSize is equal to TX_4X4 or flatMask is equal to 0, the narrow filter process specified in section 7.10.5.2 is invoked with the additional input variable hevMask.

  • Otherwise, if filterSize is equal to TX_8X8 or flatMask2 is equal to 0, the wide filter process specified in section 7.10.5.3 is invoked with the additional input variable log2Size set to 3.

  • Otherwise, the wide filter process specified in section 7.10.5.3 is invoked with the additional input variable log2Size set to 4.

Filter Mask Process

The inputs to this process are:

  • variables x and y specifying the location within CurrFrame[ plane ],

  • a variable plane specifying whether the block is the Y, U or V plane,

  • variables limit, blimit, thresh that specify the strength of the filtering operation,

  • variables dx and dy specifying the direction perpendicular to the edge being filtered,

  • a variable filterSize of specifying the maximum size of filter allowed.

The outputs from this process are the variables:

  • hevMask,

  • filterMask,

  • flatMask, (only used if filterSize >= TX_8X8),

  • flatMask2 (only used if filterSize >= TX_16X16).

The values output for these masks depend on the differences between samples on either side of the specified boundary. These samples are specified as follows:

q0 = CurrFrame[ plane ][ y ][ x ]
q1 = CurrFrame[ plane ][ y + dy     ][ x + dx     ]
q2 = CurrFrame[ plane ][ y + dy * 2 ][ x + dx * 2 ]
q3 = CurrFrame[ plane ][ y + dy * 3 ][ x + dx * 3 ]
q4 = CurrFrame[ plane ][ y + dy * 4 ][ x + dx * 4 ]
q5 = CurrFrame[ plane ][ y + dy * 5 ][ x + dx * 5 ]
q6 = CurrFrame[ plane ][ y + dy * 6 ][ x + dx * 6 ]
p0 = CurrFrame[ plane ][ y - dy     ][ x - dx     ]
p1 = CurrFrame[ plane ][ y - dy * 2 ][ x - dx * 2 ]
p2 = CurrFrame[ plane ][ y - dy * 3 ][ x - dx * 3 ]
p3 = CurrFrame[ plane ][ y - dy * 4 ][ x - dx * 4 ]
p4 = CurrFrame[ plane ][ y - dy * 5 ][ x - dx * 5 ]
p5 = CurrFrame[ plane ][ y - dy * 6 ][ x - dx * 6 ]
p6 = CurrFrame[ plane ][ y - dy * 7 ][ x - dx * 7 ]

Note: Samples q4, q5, q6, p4, p5, and p6 are only used if filterSize is equal to TX_16X16.

The value of hevMask indicates whether the sample has high edge variance. It is calculated as follows:

hevMask = 0
threshBd = thresh << (BitDepth - 8)
hevMask |= (Abs( p1 - p0 ) > threshBd)
hevMask |= (Abs( q1 - q0 ) > threshBd)

The value of filterMask indicates whether adjacent samples close to the edge (within four samples either side of the specified boundary) vary by less than the limits given by limit and blimit. It is used to determine if any filtering should occur and is calculated as follows:

limitBd = limit << (BitDepth - 8)
blimitBd = blimit << (BitDepth - 8)
mask = 0
mask |= (Abs( p3 - p2 ) > limitBd)
mask |= (Abs( p2 - p1 ) > limitBd)
mask |= (Abs( p1 - p0 ) > limitBd)
mask |= (Abs( q1 - q0 ) > limitBd)
mask |= (Abs( q2 - q1 ) > limitBd)
mask |= (Abs( q3 - q2 ) > limitBd)
mask |= (Abs( p0 - q0 ) * 2 + Abs( p1 - q1 ) / 2 > blimitBd)
filterMask = (mask == 0)

The value of flatMask is only required when filterSize >= TX_8X8. It measures whether samples from each side of the specified boundary are in a flat region. That is whether those samples are at most (1 << (BitDepth - 8)) different from the sample on the boundary. It is calculated as follows:

thresholdBd = 1 << (BitDepth - 8)
if ( filterSize >= TX_8X8 ) {
    mask = 0
    mask |= (Abs( p1 - p0 ) > thresholdBd)
    mask |= (Abs( q1 - q0 ) > thresholdBd)
    mask |= (Abs( p2 - p0 ) > thresholdBd)
    mask |= (Abs( q2 - q0 ) > thresholdBd)
    if ( plane == 0 ) {
        mask |= (Abs( p3 - p0 ) > thresholdBd)
        mask |= (Abs( q3 - q0 ) > thresholdBd)
    }
    flatMask = (mask == 0)
}

The value of flatMask2 is only required when filterSize >= TX_16X16. It measures whether at least seven samples from each side of the specified boundary are in a flat region assuming the first four on each side are (so the full region is flat if flatMask & flatMask2 == 0). The value of flatMask2 is calculated as follows:

thresholdBd = 1 << (BitDepth - 8)
if ( filterSize >= TX_16X16 ) {
    mask = 0
    mask |= (Abs( p6 - p0 ) > thresholdBd)
    mask |= (Abs( q6 - q0 ) > thresholdBd)
    mask |= (Abs( p5 - p0 ) > thresholdBd)
    mask |= (Abs( q5 - q0 ) > thresholdBd)
    mask |= (Abs( p4 - p0 ) > thresholdBd)
    mask |= (Abs( q4 - q0 ) > thresholdBd)
    flatMask2 = (mask == 0)
}
Narrow Filter Process

The inputs to this filter are:

  • a variable hevMask specifying whether this is a high edge variance case,

  • variables x, y specifying the the location within CurrFrame[ plane ],

  • a variable plane specifying whether the block is the Y, U or V plane,

  • variables limit, blimit, thresh that specify the strength of the filtering operation,

  • variables dx and dy specifying the direction perpendicular to the edge being filtered.

This process modifies up to two samples on each side of the specified boundary depending on the value of hevMask as follows:

  • If hevMask is equal to 0 (i.e. the samples do not have high edge variance), this process modifies two samples on each side of the specified boundary, using a filter constructed from just the inner two (one from each side of the specified boundary).

  • Otherwise (the samples do have high edge variance), this process only modifies the one value on each side of the specified boundary, using a filter constructed from four input samples (two from each side of the specified boundary).

The process subtracts 0x80 << (BitDepth - 8) from the input sample values so that they are in the range -(1 << (BitDepth - 1)) to (1 << (BitDepth - 1)) - 1 inclusive. Intermediate values are made to be in this range by the following function:

filter4_clamp( value ) {
    return Clip3( -(1 << (BitDepth - 1)), (1 << (BitDepth - 1)) - 1, value )
}

The process is specified as follows:

q0 = CurrFrame[ plane ][ y ][ x ]
q1 = CurrFrame[ plane ][ y + dy ][ x + dx ]
p0 = CurrFrame[ plane ][ y - dy ][ x - dx ]
p1 = CurrFrame[ plane ][ y - dy * 2 ][ x - dx * 2 ]
ps1 = p1 - (0x80 << (BitDepth - 8))
ps0 = p0 - (0x80 << (BitDepth - 8))
qs0 = q0 - (0x80 << (BitDepth - 8))
qs1 = q1 - (0x80 << (BitDepth - 8))
filter = hevMask ? filter4_clamp( ps1 - qs1 ) : 0
filter = filter4_clamp( filter + 3 * (qs0 - ps0) )
filter1 = filter4_clamp( filter + 4 ) >> 3
filter2 = filter4_clamp( filter + 3 ) >> 3
oq0 = filter4_clamp( qs0 - filter1 ) + (0x80 << (BitDepth - 8))
op0 = filter4_clamp( ps0 + filter2 ) + (0x80 << (BitDepth - 8))
CurrFrame[ plane ][ y ][ x ] = oq0
CurrFrame[ plane ][ y - dy ][ x - dx ] = op0
if ( !hevMask ) {
    filter = Round2( filter1, 1 )
    oq1 = filter4_clamp( qs1 - filter ) + (0x80 << (BitDepth - 8))
    op1 = filter4_clamp( ps1 + filter ) + (0x80 << (BitDepth - 8))
    CurrFrame[ plane ][ y + dy ][ x + dx ] = oq1
    CurrFrame[ plane ][ y - dy * 2 ][ x - dx * 2 ] = op1
}
Wide Filter Process

The inputs to this filter are:

  • variables x, y specifying the the location within CurrFrame[ plane ],

  • a variable plane specifying whether the block is the Y, U or V plane,

  • variables dx and dy specifying the direction perpendicular to the edge being filtered,

  • a variable log2Size specifying the base 2 logarithm of the number of taps.

This filter is only applied when samples from each side of the boundary are detected to be in a flat region.

The variable n (specifying the number of filter taps on each side of the central sample) is set as follows:

  • If log2Size is equal to 4, n is set equal to 6.

  • Otherwise if plane is equal to 0, n is set equal to 3.

  • Otherwise (log2size is equal to 3 and plane is greater than 0), n is set equal to 2.

The variable n2 (specifying the number of filter taps equal to 2 on each side of the central sample needed to give a unity DC gain) is set as follows:

  • If log2Size is equal to 3 and plane is equal to 0, n2 is set equal to 0.

  • Otherwise (log2size is equal to 4 or plane is greater than 0), n2 is set equal to 1.

This process modifies the samples on each side of the specified boundary by applying a low pass filter as follows:

for( i = -n; i < n; i++ ) {
    t = 0
    for( j = -n; j <= n; j++ ) {
        p = Clip3( -( n + 1 ), n, i + j )
        tap = ( Abs( j ) <= n2 ) ? 2 : 1
        t += CurrFrame[ plane ][ y + p * dy ][ x + p * dx ] * tap
    }
    F[ i ] = Round2( t, log2Size )
}
for( i = -n; i < n; i++ )
    CurrFrame[ plane ][ y+i * dy ][ x+i * dx ] = F[ i ]

where F is an array with indices from -n to n - 1 used to store the filtered results.

CDEF Process

Input to this process is the array CurrFrame of reconstructed samples.

Output from this process is the array CdefFrame containing deringed samples.

The purpose of CDEF is to perform deringing based on the detected direction of blocks.

CDEF parameters are stored for each 64 by 64 block of pixels.

The CDEF filter is applied on each 8 by 8 block of pixels as follows:

cdefSize4 = Num_4x4_Blocks_Wide[ BLOCK_8X8 ]
for (r = 0; r < MiRows; r += step4) {
    for (c = 0; c < MiCols; c += step4) {
          baseR = r & (cdefSize4 - 1)
          baseC = c & (cdefSize4 - 1)
          idx = AllLossless ? -1 : cdef_idx[ baseR ][ baseC ]
          cdef_block(r, c, idx)
    }
}

When the cdef_block function is called, the CDEF block process specified in section 7.11.1 is invoked with r, c, and idx as inputs.

Note Skipped blocks can be filtered (if the filter_skip syntax elements are equal to 1), unless the entire 64 by 64 block is skipped in which case filtering is never applied.

CDEF Block Process

The inputs to this process are:

  • variables r and c specifying the location of an 8x8 block in units of 4x4 blocks in the luma plane,

  • a variable idx specifying which set of CDEF parameters to use, or -1 to signal that no filtering should be applied.

The block is first copied to the CdefFrame as follows:

startY = r * MI_SIZE
endY = startY + MI_SIZE * 2
startX = c * MI_SIZE
endX = startX + MI_SIZE * 2
for( y = startY; y < endY; y++ ) {
    for( x = startX; x < endX; x++ ) {
        CdefFrame[ 0 ][ y ][ x ] = CurrFrame[ 0 ][ y ][ x ]
    }
}
startY >>= subsampling_y
endY >>= subsampling_y
startX >>= subsampling_x
endX >>= subsampling_x
for( y = startY; y < endY; y++ ) {
    for( x = startX; x < endX; x++ ) {
        CdefFrame[ 1 ][ y ][ x ] = CurrFrame[ 1 ][ y ][ x ]
        CdefFrame[ 2 ][ y ][ x ] = CurrFrame[ 2 ][ y ][ x ]
    }
}

Note If CDEF filtering turns out to be needed, then the contents of CdefFrame will be overwritten later in this process.

If idx is equal to -1, then the process returns immediately after performing this copy.

The variable coeffShift is set equal to BitDepth - 8.

The variable skip is set equal to SkipCoeffs[ r ][ c ].

The variable filterY (that says if the filter should be applied to the luma samples) is set equal to ( !skip || cdef_y_filter_skip[ idx ] ).

The variable filterUV (that says if the filter should be applied to the chroma samples) is set equal to ( CdefFilterChroma && (!skip || cdef_uv_filter_skip[ idx ] ) ).

If filterY is equal to 1 or filterUV is equal to 1, the CDEF direction process specified in section 7.11.2 is invoked with r and c as inputs, and the outputs assigned to variables yDir and var.

If filterY is equal to 1, the following ordered steps apply:

  1. The variable priStr is set equal to cdef_y_pri_strength[ idx ] << coeffShift.

  2. The variable secStr is set equal to cdef_y_sec_strength[ idx ] << coeffShift.

  3. If priStr is equal to 0 and secStr is equal to 0 and cdef_y_filter_skip[ idx ] is equal to 1, the following applies:

    • priStr is set equal to 19 << coeffShift.

    • secStr is set equal to 7 << coeffShift. Note: Shift is applied to the secondary strength in this case.

  4. The variable dir is set equal to ( priStr == 0 ) ? 0 : yDir.

  5. The variable varStr is set equal to ( var >> 6 ) ? Min( floor( log2( var >> 6 ) ), 12) : 0.

  6. The variable priStr is set equal to ( var ? ( priStr * ( 4 + varStr ) + 8 ) >> 4 : 0 ).

  7. The variable damping is set equal to CdefDamping + coeffShift.

  8. The CDEF filter process specified in section 7.11.3 is invoked with plane equal to 0, r, c, priStr, secStr, damping, and dir as input.

If filterUV is equal to 1, the following ordered steps apply:

  1. The variable priStr is set equal to cdef_uv_pri_strength[ idx ] << coeffShift.

  2. The variable secStr is set equal to cdef_uv_sec_strength[ idx ] << coeffShift.

  3. If priStr is equal to 0 and secStr is equal to 0 and cdef_uv_filter_skip[ idx ] is equal to 1, the following applies:

    • priStr is set equal to 19 << coeffShift.

    • secStr is set equal to 7 << coeffShift. Note: Shift is applied to the secondary strength in this case.

  4. The variable dir is set equal to ( priStr == 0 ) ? 0 : yDir.

  5. The variable damping is set equal to CdefDamping + coeffShift.

  6. The CDEF filter process specified in section 7.11.3 is invoked with plane equal to 1, r, c, priStr, secStr, damping, and dir as input.

  7. The CDEF filter process specified in section 7.11.3 is invoked with plane equal to 2, r, c, priStr, secStr, damping, and dir as input.

CDEF Direction Process

The inputs to this process are variables r and c specifying the location of an 8x8 block in units of 4x4 blocks in the luma plane.

The outputs of this process are:

  • a variable yDir containing the direction of this block,

  • a variable var containing the variance for this block.

This block uses luma samples to measure the direction and variance of a block.

The process is specified as:

for (i = 0; i < 8; i++) {
    cost[i] = 0
    for (j = 0; j < 15; j++)
        partial[i][j] = 0
}
bestCost = 0
yDir = 0
x0 = c << MI_SIZE_LOG2
y0 = r << MI_SIZE_LOG2
for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
        x = (CurrFrame[ 0 ][y0 + i][x0 + j] >> (BitDepth - 8)) - 128
        partial[0][i + j] += x
        partial[1][i + j / 2] += x
        partial[2][i] += x
        partial[3][3 + i - j / 2] += x
        partial[4][7 + i - j] += x
        partial[5][3 - i / 2 + j] += x
        partial[6][j] += x
        partial[7][i / 2 + j] += x
    }
}
for (i = 0; i < 8; i++) {
    cost[2] += partial[2][i] * partial[2][i]
    cost[6] += partial[6][i] * partial[6][i]
}
cost[2] *= Div_Table[8]
cost[6] *= Div_Table[8]
for (i = 0; i < 7; i++) {
    cost[0] += (partial[0][i] * partial[0][i] +
                partial[0][14 - i] * partial[0][14 - i]) *
               Div_Table[i + 1]
    cost[4] += (partial[4][i] * partial[4][i] +
                partial[4][14 - i] * partial[4][14 - i]) *
               Div_Table[i + 1]
}
cost[0] += partial[0][7] * partial[0][7] * Div_Table[8]
cost[4] += partial[4][7] * partial[4][7] * Div_Table[8]
for (i = 1; i < 8; i += 2) {
    for (j = 0; j < 4 + 1; j++) {
      cost[i] += partial[i][3 + j] * partial[i][3 + j]
    }
    cost[i] *= Div_Table[8]
    for (j = 0; j < 4 - 1; j++) {
        cost[i] += (partial[i][j] * partial[i][j] +
                  partial[i][10 - j] * partial[i][10 - j]) *
                  Div_Table[2 * j + 2]
    }
}
for (i = 0; i < 8; i++) {
    if (cost[i] > bestCost) {
      bestCost = cost[i]
      yDir = i
    }
}
var = (bestCost - cost[(yDir + 4) & 7]) >> 10

where the Div_Table is a constant lookup table specified as:

uint16 Div_Table[9] = { 
    0, 840, 420, 280, 210, 168, 140, 120, 105
}

CDEF Filter Process

The inputs to this process are:

  • a variable plane specifying which plane is being predicted,

  • variables r and c specifying the location of an 8x8 block in units of 4x4 blocks in the luma plane,

  • a variable priStr specifying the primary filter strength,

  • a variable secStr specifying the secondary filter strength,

  • a variable damping specifying a shift used for damping,

  • a variable dir specifying the detected direction of the block.

The process modifies samples in CdefFrame based on filtering samples from CurrFrame.

The variable sub (representing the amount of subsampling for the block) is set depending on the subsampling for the plane as follows:

  • If plane is equal to 0, sub is set equal to 0.

  • Otherwise, sub is set equal to subsampling_x. Note: CDEF is only used on square chroma blocks.

The extent of the space allowed for filtering is configured depending on loop_filter_across_tiles as follows:

  • If loop_filter_across_tiles is equal to 1, the following applies:

    • MiColStart is set equal to 0

    • MiRowStart is set equal to 0

    • MiColEnd is set equal to MiCols

    • MiRowEnd is set equal to MiRows

    • AboveSameTileGroup is set equal to 1

  • Otherwise, MiColStart, MiRowStart, MiColEnd, MiRowEnd, AboveSameTileGroup are set equal to the values they had when the syntax element MiSizes[ r ][ c ] was written.

Note: These variables are used by the is_inside function to determine which samples are available for use in filtering. If loop_filter_across_tiles is equal to 1, the variables are set to indicate the whole frame is available. If loop_filter_across_tiles is equal to 0, the variables are set according to the tile that includes the current block.

The filtering is applied as follows:

startX = (c * MI_SIZE ) >> sub
startY = (r * MI_SIZE ) >> sub
size = 8 >> sub
for ( i = 0; i < size; i++ )
    for (j = 0; j < size; j++) {
        sum = 0
        x = CurrFrame[plane][y0 + i][x0 + j]
        max = x
        min = x
        for (k = 0; k < 2; k++) {
            for (sign = -1; sign <= 1; sign += 2) {
                p = cdef_get_at(plane, x0, y0, i, j, dir, k,  sign)
                sum += Cdef_Pri_Taps[priStr & 1][k] * constrain(p - x, priStr, damping)
                if (p != CDEF_VERY_LARGE) {
                    max = Max(p, max)
                    min = Min(p, min)
                }
                for ( dirOff = -2; dirOff <= 2; dirOff += 4) {
                    s = cdef_get_at(plane, x0, y0, i, j, (dir + dirOff) & 7, k,  sign)
                    sum += Cdef_Sec_Taps[priStr & 1][k] * constrain(s - x, secStr, damping)
                    if (s != CDEF_VERY_LARGE) {
                        max = Max(s, max)
                        min = Min(s, min)
                    }
                }
            } 
        }
        CdefFrame[plane][y0 + i][x0 + j] = Clip3(min, max, x + ((8 + sum - (sum < 0)) >> 4) )
    }
}

where Cdef_Pri_Taps and Cdef_Sec_Taps are constant lookup tables specified as:

uint8 Cdef_Pri_Taps[2][2] = { 
    { 4, 2 }, { 3, 3 } 
}

uint8 Cdef_Sec_Taps[2][2] = { 
    { 2, 1 }, { 2, 1 } 
}

constrain is specified as:

constrain(diff, threshold, damping) {
    if ( !threshold )
      return 0
    dampingAdj = Max(0, damping - floor( log2( threshold ) ) )
    sign = (diff < 0) ? -1 : 1
    return sign * Clip3(0, Abs(diff), threshold - (Abs(diff) >> dampingAdj) )
}

and cdef_get_at fetches a pixel from CurrFrame if it is available, or returns CDEF_VERY_LARGE otherwise, and is defined as:

uint16 cdef_get_at(plane, x0, y0, i, j, dir, k, sign) {
    y = y0 + i + sign * cdef_directions[dir][k][0]
    x = x0 + j + sign * cdef_directions[dir][k][1]
    candidateR = (y << sub) >> MI_SIZE_LOG2
    candidateC = (x << sub) >> MI_SIZE_LOG2
    if ( is_inside( candidateR, candidateC ) )
        return CurrFrame[ plane ][ y ][ x ]
    else
        return CDEF_VERY_LARGE
}

where cdef_directions is defined as:

cdef_directions[8][2][2] = {
  { { -1, 1 }, { -2,  2 } },
  { {  0, 1 }, { -1,  2 } },
  { {  0, 1 }, {  0,  2 } },
  { {  0, 1 }, {  1,  2 } },
  { {  1, 1 }, {  2,  2 } },
  { {  1, 0 }, {  2,  1 } },
  { {  1, 0 }, {  2,  0 } },
  { {  1, 0 }, {  2, -1 } }
}

Output Process

This process is invoked to optionally display a frame.

If show_existing_frame is equal to 1, then the decoder should output a previously decoded frame as follows:

  • The variable w is set equal to RefFrameWidth[ frame_to_show_map_idx ].

  • The variable h is set equal to RefFrameHeight[ frame_to_show_map_idx ].

  • The variable subX is set equal to RefSubsamplingX[ frame_to_show_map_idx ].

  • The variable subY is set equal to RefSubsamplingY[ frame_to_show_map_idx ].

  • The Y plane is w samples across by h samples down and the sample at location x samples across and y samples down is given by FrameStore[ frame_to_show_map_idx ][ 0 ][ y ][ x ] with x = 0..w - 1 and y = 0..h - 1.

  • The U plane is (w + subX) >> subX samples across by (h + subY) >> subY samples down and the sample at location x samples across and y samples down is given by FrameStore[ frame_to_show_map_idx ][ 1 ][ y ][ x ] with x = 0..((w + subX) >> subX) - 1 and y = 0..((h + subY) >> subY) - 1.

  • The V plane is (w + subX) >> subX samples across by (h + subY) >> subY samples down and the sample at location x samples across and y samples down is given by FrameStore[ frame_to_show_map_idx ][ 2 ][ x ][ y ] with x = 0..((w + subX) >> subX) - 1 and y = 0..((h + subY) >> subY) - 1.

  • The bit depth for each sample is RefBitDepth[ frame_to_show_map_idx ].

Otherwise, if show_frame is equal to 1, then the decoder should output the current frame as follows:

  • The variable w is set equal to FrameWidth.

  • The variable h is set equal to FrameHeight.

  • The variable subX is set equal to subsampling_x.

  • The variable subY is set equal to subsampling_y.

  • The Y plane is w samples across by h samples down and the sample at location x samples across and y samples down is given by CdefFrame[ 0 ][ y ][ x ] with x = 0..w - 1 and y = 0..h - 1.

  • The U plane is (w + subX) >> subX samples across by (h + subY) >> subY samples down and the sample at location x samples across and y samples down is given by CdefFrame[ 1 ][ y ][ x ] with x = 0..((w + subX) >> subX) - 1 and y = 0..((h + subY) >> subY) - 1.

  • The V plane is (w + subX) >> subX samples across by (h + subY) >> subY samples down and the sample at location x samples across and y samples down is given by CdefFrame[ 2 ][ x ][ y ] with x = 0..((w + subX) >> subX) - 1 and y = 0..((h + subY) >> subY) - 1.

  • The bit depth for each sample is BitDepth.

Reference Frame Update Process

This process is invoked as the final step in decoding a frame.

The inputs to this process are the samples in the current frame CdefFrame[ plane ][ x ][ y ].

The output from this process is an updated set of reference frames and previous motion vectors.

For each value of i from 0 to NUM_REF_FRAMES - 1, the following applies if bit i of refresh_frame_flags is equal to 1 (i.e. if (refresh_frame_flags >> i) & 1 is equal to 1):

 * RefFrameWidth[ i ] is set equal to FrameWidth.

 * RefFrameHeight[ i ] is set equal to FrameHeight.

 * RefSubsamplingX[ i ] is set equal to subsampling_x.

 * RefSubsamplingY[ i ] is set equal to subsampling_y.

 * RefBitDepth[ i ] is set equal to BitDepth.
 
 * RefDecodeOrder[ i ] is set equal to DecodeOrder.

 * FrameStore[ i ][ 0 ][ y ][ x ] is set equal to CdefFrame[ 0 ][ y ][ x ]
   for x = 0..FrameWidth-1, for y = 0..FrameHeight-1.

 * FrameStore[ i ][ plane ][ y ][ x ] is set equal to
   CdefFrame[ plane ][ y ][ x ] for plane = 1..2,
   for x = 0..((FrameWidth + subsampling_x) \>\> subsampling_x) - 1,
   for y = 0..((FrameHeight + subsampling_y) \>\> subsampling_y) - 1.
   
 * SavedFrameType[ i ] is set equal to frame_type.
 
 * SavedDecodeOrders[ i ][ j] is set equal to DecodeOrders[ j ] for j = LAST_FRAME..ALTREF_FRAME.

 * SavedRefFrames[ i ][ row ][ col ][ list ] is set equal to
   RefFrames[ row ][ col ][ list ] for row = 0..MiRows-1,
   for col = 0..MiCols-1, for list = 0..1.

 * SavedMvs[ i ][ row ][ col ][ list ][ comp ] is set equal to
   Mvs[ row ][ col ][ list ][ comp ] for row = 0..MiRows-1,
   for col = 0..MiCols-1, for list = 0..1, for comp = 0..1.
   
 * SavedGmParams[ i ][ ref ][ j ] is set equal to gm_params[ ref ][ j ]
   for ref = LAST_FRAME..ALTREF_FRAME,
   for j = 0..5.

Note: Although this process stores all the motion vectors, only the values where row and col are both odd will be used again.

Parsing Process

Parsing Process for f(n)

This process is invoked when the descriptor of a syntax element in the syntax tables is equal to f(n).

The next n bits are read from the bit stream.

This process is specified as follows:

x = 0
for ( i = 0; i < n; i++ ) {
    x = 2 * x + read_bit( )
}

read_bit( ) reads the next bit from the bitstream and advances the bitstream pointer by 1. If the bitstream is provided as a series of bytes, then the first bit is given by the most significant bit of the first byte.

The value for the syntax element is given by x.

Parsing Process for Boolean Decoder

Aside from the uncompressed header and the partition sizes, the entire bitstream is entropy coded. The entropy decoder is referred to as the “Boolean decoder” and the function init_bool( sz ), exit_bool( ), and read_bool( p ) are used in this Specification to indicate the entropy decoding operation.

Initialization Process for Boolean Decoder

The input to this process is a variable sz specifying the number of bytes to be read by the Boolean decoder.

This process is invoked when the function init_bool( sz ) is called from the syntax structure.

Note: The bit position will always be byte aligned when init_bool is invoked because the uncompressed header and the data partitions are always a whole number of bytes long.

The variable UpdateCdfs (representing if this is the biggest tile seen so far) is set equal to (sz > MaxTileSize).

The variable MaxTileSize (that tracks the largest tile size seen so far) is set equal to Max( MaxTileSize, sz ).

The variable buf is read using the f(15) parsing process.

The variable BoolValue is set to ((1 << 15) - 1) ^ buf.

The variable BoolRange is set to 1 << 15.

The variable BoolMaxBits is set to 8 * sz - 15.

A copy is made of each of the CDF arrays mentioned in the semantics for setup_past_independence. The name of the copy is the name of the CDF array prefixed with “Tile”. This copying produces the following arrays:

  • TileYModeCdf

  • TileUVModeCdf

  • TilePartitionW8Cdf

  • TilePartitionCdf

  • TileSegmentIdCdf

  • TileSegmentIdPredictedCdf

  • TileTx8x8Cdf

  • TileTx16x16Cdf

  • TileTx32x32Cdf

  • TileTxfmSplitCdf

  • TileInterpFilterCdf

  • TileMotionModeCdf

  • TileNewMvCdf

  • TileZeroMvCdf

  • TileRefMvCdf

  • TileCompoundModeCdf

  • TileDrlModeCdf

  • TileIsInterCdf

  • TileCompModeCdf

  • TileSkipCdf

  • TileCompRefCdf

  • TileCompBwdRefCdf

  • TileSingleRefCdf

  • TileMvJointCdf

  • TileMvClassCdf

  • TileMvClass0BitCdf

  • TileMvFrCdf

  • TileMvClass0FrCdf

  • TileMvClass0HpCdf

  • TileMvBitCdf

  • TileMvHpCdf

  • TileTailTokenCdf

  • TileAcHeadTokenCdf

  • TileDcHeadTokenCdf

  • TilePaletteYModeCdf

  • TilePaletteUVModeCdf

  • TilePaletteYSizeCdf

  • TilePaletteUVSizeCdf

  • TilePaletteSize2YColorCdf

  • TilePaletteSize2UVColorCdf

  • TilePaletteSize3YColorCdf

  • TilePaletteSize3UVColorCdf

  • TilePaletteSize4YColorCdf

  • TilePaletteSize4UVColorCdf

  • TilePaletteSize5YColorCdf

  • TilePaletteSize5UVColorCdf

  • TilePaletteSize6YColorCdf

  • TilePaletteSize6UVColorCdf

  • TilePaletteSize7YColorCdf

  • TilePaletteSize7UVColorCdf

  • TilePaletteSize8YColorCdf

  • TilePaletteSize8UVColorCdf

  • TileDeltaQCdf

  • TileDeltaLFCdf

  • TileDeltaLFMultiCdf[ i ] for i = 0..FRAME_LF_COUNT-1

  • TileIntraTxTypeSet1Cdf

  • TileIntraTxTypeSet2Cdf

  • TileInterTxTypeSet1Cdf

  • TileInterTxTypeSet2Cdf

  • TileInterTxTypeSet3Cdf

  • TileUseObmcCdf

  • TileInterIntraCdf

  • TileCompRefTypeCdf

  • TileCflSignCdf

  • TileUniCompRefCdf

  • TileWedgeInterIntraCdf

  • TileCompoundTypeCdf

  • TileInterIntraModeCdf

  • TileCflAlphaCdf

Boolean Decoding Process

The input to this process is a variable p which specifies the probability (in the range 0 to 255) to use during bool decode.

The output of this process is the variable bool, containing a decoded bool.

This process is invoked when the function read_bool( p ) is called from the syntax structure.

An array cdf of length 3 is constructed as follows:

cdf[ 0 ] = ( ( p << 15 ) + 256 – p ) >> 8
cdf[ 1 ] = 1 << 15
cdf[ 2 ] = 0

The return value for the function is given by read_symbol( cdf ).

Exit Process for Boolean Decoder

This process is invoked when the function exit_bool( ) is called from the syntax structure.

The padding syntax element is read using the f(BoolMaxBits) parsing process.

It is a requirement of bitstream conformance that BoolMaxBits is greater than or equal to 0 whenever this process is invoked.

It is a requirement of bitstream conformance that padding is equal to 0.

Note: The padding is required to make the bit position byte aligned. It is legal for frames to end with more than one byte of padding.

If UpdateCdfs is equal to 1, a copy is made of the final CDF values for each of the CDF arrays mentioned in the semantics for setup_past_independence. The name of the destination for the copy is the name of the CDF array prefixed with “Saved”. The name of the source for the copy is the name of the CDF array prefixed with “Tile”. For example, an array SavedYModeCdf will be created with values equal to TileYModeCdf.

Parsing Process for read_literal

This process is invoked when the function read_literal( n ) is invoked.

This process is specified as follows:

x = 0
for ( i = 0 ; i < n; i++ ) {
    x = 2 * x + read_bool( 128 )
}

The return value for the function is given by x.

Symbol Decoding Process

The input to this process is an array cdf of length N + 1 which specifies the cumulative distribution for a symbol with N possible values.

The output of this process is the variable symbol, containing a decoded syntax element. The process also modifies the input array cdf to adapt the probabilities to the content of the stream.

This process is invoked when the function read_symbol( cdf ) is called.

Note: When this process is invoked, N will be greater than 1 and cdf[ N-1 ] will be equal to 1 << 15.

The variables cur, prev, and symbol are calculated as follows:

cur = BoolRange
symbol = -1
do {
  symbol++
  prev = cur
  f = ( 1 << 15 ) - cdf[ symbol ]
  cur = ( ( BoolRange >> 8 ) * f ) >> 7
} while ( BoolValue < cur )

Note: Implementations may prefer to store the inverse cdf to move the subtraction out of this loop.

The variable BoolRange is set to prev - cur.

The variable BoolValue is set equal to BoolValue - cur.

The range and value are renormalized by the following ordered steps:

  1. The variable bits is set to 15 – floor( log2( BoolRange ) ). This represents the number of new bits to be read from the bitstream.

  2. The variable BoolRange is set to BoolRange << bits.

  3. The variable newData is read using the f(bits) parsing process.

  4. The variable BoolValue is set to newData ^ ( ( ( BoolValue + 1 ) << bits ) - 1 ).

  5. The variable BoolMaxBits is set to BoolMaxBits - bits.

Note: bits may be equal to 0, in which case these ordered steps have no effect.

The cumulative distribution is updated as follows:

rate = 4 + ( cdf[N] > 31 ) + floor ( log2 ( N ) )
rate2 = 5
tmp0 = 1 << rate2
tmp = tmp0
diff = (((1<<15) - (N << rate2)) >> rate) << rate
for (i = 0; i < N - 1; i++) {
  tmp += (i == symbol ? diff : 0)
  cdf[i] -= ((cdf[i] - tmp) >> rate)
  tmp += tmp0
}
cdf[N] += (cdf[N] < 32)

Note: The last entry of the cdf array is used to keep a count of the number of times the symbol has been decoded (up to a maximum of 32). This allows the cdf to change faster for the first 32 times the symbol is decoded.

The return value from the function is given by symbol.

Parsing process for CDF encoded syntax elements

This process is invoked when the descriptor of a syntax element in the syntax tables is equal to S.

The input to this process is the name of a syntax element.

Section 8.3.1 specifies how a CDF array is chosen for the syntax element. The variable cdf is set equal to a reference to this CDF array.

Note: The array must be passed by reference because read_symbol will adjust the array contents.

The output of this process is the result of calling the function read_symbol( cdf ).

CDF Selection Process

The input to this process is the name of a syntax element.

The output of this process is a reference to a CDF array.

When the description in this section uses variables, these variables are taken to have the values defined by the syntax tables at the point that the syntax element is being decoded.

The probabilities depend on the syntax element as follows:

intra_frame_y_mode: The cdf for intra_frame_y_mode is given by Default_Intra_Frame_Y_Mode_Cdf[ abovemode ][ leftmode ] where abovemode and leftmode are the intra modes used for the blocks immediately above and to the left of this block and are computed as:

abovemode = Intra_Mode_Context[ AvailU ? YModes[ MiRow - 1 ][ MiCol ] : DC_PRED ]
leftmode = Intra_Mode_Context[ AvailL ? YModes[ MiRow ][ MiCol - 1] : DC_PRED ]

where Intra_Mode_Context is defined as follows:

Intra_Mode_Context[ INTRA_MODES ] = {
  0, 1, 2, 3, 4, 4, 4, 4, 3, 0, 1, 2, 0
}

Note: We are using a 2D array to store the YModes for clarity. It is possible to reduce memory consumption by only storing one intra mode for each 4x4 horizontal and vertical position, i.e. to use two 1D arrays instead.

y_mode: The cdf for y_mode is given by TileYModeCdf[ ctx ] where the variable ctx is computed as Size_Group[ MiSize ].

uv_mode: The cdf for uv_mode is given by TileUVModeCdf[ ctx ] where the variable ctx is set equal to YMode.

partition: The variable ctx is computed as follows:

bsl = Mi_Width_Log2[ bSize ]
above = AvailU && ( Mi_Width_Log2[ MiSizes[ r - 1 ][ c ] ] < bsl )
left = AvailL && ( Mi_Height_Log2[ MiSizes[ r ][ c - 1 ] ] < bsl )
ctx = bsl * 4 + left * 2 + above

The cdf is derived as follows:

  • If ctx is less than PARTITION_CONTEXTS_W8, the cdf is given by TilePartitionW8Cdf[ ctx ].

  • Otherwise (ctx is greater than or equal to PARTITION_CONTEXTS_W8), the cdf is given by TilePartitionCdf[ ctx - PARTITION_CONTEXTS_W8 ].

split_or_horz: split_or_horz uses the same derivation for the variable ctx as for the syntax element partition.

The cdf to return is given by an array of length 3 which is constructed as follows:

partitionCdf = TilePartitionCdf[ ctx - PARTITION_CONTEXTS_W8 ]
psum = ( partitionCdf[ PARTITION_VERT ] - partitionCdf[ PARTITION_VERT - 1 ] +
         partitionCdf[ PARTITION_SPLIT ] - partitionCdf[ PARTITION_SPLIT - 1 ] +
         partitionCdf[ PARTITION_HORZ_A ] - partitionCdf[ PARTITION_HORZ_A - 1 ] +
         partitionCdf[ PARTITION_VERT_A ] - partitionCdf[ PARTITION_VERT_A - 1 ] +
         partitionCdf[ PARTITION_VERT_B ] - partitionCdf[ PARTITION_VERT_B - 1 ] +
         partitionCdf[ PARTITION_VERT_4 ] - partitionCdf[ PARTITION_VERT_4 - 1 ] )
cdf[0] = ( 1 << 15 ) - psum
cdf[1] = 1 << 15
cdf[2] = 0

Note: The syntax element split_or_horz is not allowed to return a PARTITION_VERT, so the probability for a vertical partition is assigned to the probability for the split partition.

split_or_vert: split_or_vert uses the same derivation for the variable ctx as for the syntax element partition.

The cdf to return is given by an array of length 3 which is constructed as follows:

partitionCdf = TilePartitionCdf[ ctx - PARTITION_CONTEXTS_W8 ]
psum = ( partitionCdf[ PARTITION_HORZ ] - partitionCdf[ PARTITION_HORZ - 1 ] +
         partitionCdf[ PARTITION_SPLIT ] - partitionCdf[ PARTITION_SPLIT - 1 ] +
         partitionCdf[ PARTITION_HORZ_A ] - partitionCdf[ PARTITION_HORZ_A - 1 ] +
         partitionCdf[ PARTITION_HORZ_B ] - partitionCdf[ PARTITION_HORZ_B - 1 ] +
         partitionCdf[ PARTITION_VERT_A ] - partitionCdf[ PARTITION_VERT_A - 1 ] +
         partitionCdf[ PARTITION_HORZ_4 ] - partitionCdf[ PARTITION_HORZ_4 - 1 ] )
cdf[0] = ( 1 << 15 ) - psum
cdf[1] = 1 << 15
cdf[2] = 0

tx_size: the cdf depends on the value of maxTxSize and ctx, where ctx is computed by:

    above = maxTxSize
    left = maxTxSize
    if ( AvailU && !Skips[ MiRow - 1 ][ MiCol ] )
        above = TxSizes[ MiRow - 1][ MiCol ]
    if ( AvailL && !Skips[ MiRow ][ MiCol - 1 ] )
        left = TxSizes[ MiRow ][ MiCol - 1 ]
    if ( !AvailL )
        left = above
    if ( !AvailU )
        above = left
    ctx = (above+left) > maxTxSize

The cdf to return is given by:

  • TileTx32x32Cdf[ ctx ] if maxTxSize is equal to TX_32X32.

  • TileTx16x16Cdf[ ctx ] if maxTxSize is equal to TX_16X16.

  • TileTx8x8Cdf[ ctx ] otherwise.

txfm_split: the cdf is given by TileTxfmSplitCdf[ ctx ], where ctx is computed by:

if ( !AvailU ) {
    aboveW = 4
} else {
    if ( Skips[ row - 1][ col ] )
        aboveW = Block_Width[ MiSizes[ row - 1 ][ col ] ]
    else
        aboveW = Tx_Width[ InterTxSizes[ row - 1 ][ col ] ]
}
if ( !AvailL ) {
    leftH = 4
} else {
    if ( Skips[ row - 1][ col ] )
        leftH = Block_Height[ MiSizes[ row  ][ col - 1 ] ]
    else
        leftH = Tx_Height[ InterTxSizes[ row  ][ col - 1] ]
}
txW = Tx_Width[txSz]
txh = Tx_Height[txSz]
above = aboveW < txW
left = leftH < txH
ctx = TXFM_PARTITION_CONTEXTS - 1
size = Max( Block_Width[ MiSize ], Block_Height[ MiSize ] )
size = Min( 32, size )
maxTxSz = find_tx_size( size, size )
if (maxTxSz >= TX_8X8) {
    ctx = (txSz != maxTxSz && maxTxSz > TX_8X8) +
               (TX_SIZES - 1 - maxTxSz) * 2
}
if (ctx != TXFM_PARTITION_CONTEXTS - 1)
    ctx = ctx * 3 + above + left
}

segment_id: the cdf is given by TileSegmentIdCdf.

seg_id_predicted: the cdf is given by TileSegmentIdPredictedCdf[ ctx ], where ctx is computed by:

ctx = LeftSegPredContext[ MiRow ] + AboveSegPredContext[ MiCol ]

new_mv: the cdf is given by TileNewMvCdf[ NewMvContext ].

zero_mv: the cdf is given by TileZeroMvCdf[ ZeroMvContext ].

ref_mv: the cdf is given by TileRefMvCdf[ RefMvContext ].

drl_mode: the cdf is given by TileDrlModeCdf[ DrlCtxStack[ idx ] ].

is_inter: the cdf is given by TileIsInterCdf[ ctx ] where ctx is computed by:

if ( AvailU && AvailL )
    ctx = (LeftIntra && AboveIntra) ? 3 : LeftIntra || AboveIntra
    else if ( AvailU || AvailL )
    ctx = 2 * (AvailU ? AboveIntra : LeftIntra)
else
    ctx = 0

comp_mode: the cdf is given by TileCompModeCdf[ ctx ] where ctx is computed by:

if ( AvailU && AvailL ) {
    if ( AboveSingle && LeftSingle )
    ctx = (AboveRefFrame[ 0 ] == CompFixedRef)
        ^ (LeftRefFrame[ 0 ] == CompFixedRef)
    else if ( AboveSingle )
        ctx = 2 + (AboveRefFrame[ 0 ] == CompFixedRef || AboveIntra)
    else if ( LeftSingle )
        ctx = 2 + (LeftRefFrame[ 0 ] == CompFixedRef || LeftIntra)
    else
        ctx = 4
} else if ( AvailU ) {
    if ( AboveSingle )
        ctx = AboveRefFrame[ 0 ] == CompFixedRef
    else
        ctx = 3
} else if ( AvailL ) {
    if ( LeftSingle )
        ctx= LeftRefFrame[ 0 ] == CompFixedRef
    else
        ctx = 3
} else {
    ctx = 1
}

skip: the cdf is given by TileSkipCdf[ ctx ] where ctx is computed by:

    ctx = 0
    if ( AvailU )
        ctx += Skips[ MiRow - 1 ][ MiCol ]
    if ( AvailL )
        ctx += Skips[ MiRow ][ MiCol - 1 ]

comp_ref: the cdf is given by TileCompRefCdf[ ctx ][ 0 ] where ctx is computed by:

above0 = AboveRefFrame[ 0 ]
left0 = LeftRefFrame[ 0 ]
if ( AvailU && AvailL ) {
    if ( AboveIntra && LeftIntra ) {
        ctx = 2
    } else if ( LeftIntra ) {
        ctx = 1 + 2 * (!check_golden_or_last3(above0))
    } else if ( AboveIntra ) {
        ctx = 1 + 2 * (!check_golden_or_last3(left0))
    } else {
        frfa = above0
        frfl = left0
        if ( frfa == frfl && check_golden_or_last3(frfa) ) {
            ctx = 0
        } else if ( LeftSingle && AboveSingle ) {
            if ((check_backward(frfa) && check_last_or_last2(frfl)) ||
                (check_backward(frfl) && check_last_or_last2(frfa)))
                ctx = 4
            else if ( check_golden_or_last3(frfa) || check_golden_or_last3(frfl) )
                ctx = 1
            else
                ctx = 3
        } else if ( LeftSingle || AboveSingle ) {
            frfc = LeftSingle ? frfa : frfl
            rfs = AboveSingle ? frfa : frfl
            if ( check_golden_or_last3(frfc) && !check_golden_or_last3(rfs) )
                ctx = 1
            else if ( check_golden_or_last3(rfs) && !check_golden_or_last3(frfc) )
                ctx = 2
            else
                ctx = 4
        } else if ( check_last_or_last2(frfa) && check_last_or_last2(frfl) ) {
            ctx = 4
        } else {
            ctx = 2
        }
    }
} else if ( AvailU ) {
    if ( AboveIntra ) {
        ctx = 2
    } else {
        if ( AboveSingle )
            ctx = 3 * ( !check_golden_or_last3(above0) )
        else
            ctx = 4 * ( !check_golden_or_last3(above0) )
    }
} else if ( AvailL ) {
    if ( LeftIntra ) {
        ctx = 2
    } else {
        if ( LeftSingle )
            ctx = 3 * ( !check_golden_or_last3(left0) )
        else
            ctx = 4 * ( !check_golden_or_last3(left0) )
    }
} else {
    ctx = 2
}

comp_ref_p1: the cdf is given by TileCompRefCdf[ ctx ][ 1 ] where ctx is computed by:

above0 = AboveRefFrame[ 0 ]
left0 = LeftRefFrame[ 0 ]
if ( AvailU && AvailL ) {
    if ( AboveIntra && LeftIntra ) {
        ctx = 2
    } else if ( LeftIntra ) {
        ctx = 1 + 2 * (!check_last(above0))
    } else if ( AboveIntra ) {
        ctx = 1 + 2 * (!check_last(left0))
    } else {
        frfa = above0
        frfl = left0
        if ( frfa == frfl && check_last(frfa) ) {
            ctx = 0
        } else if ( LeftSingle && AboveSingle ) {
            if ( check_last(frfa) || check_last(frfl) )
                ctx = 1
            else if ( check_golden_or_last3(frfa) || check_golden_or_last3(frfl) )
                ctx = 2 + (frfa != frfl)
            else if ( frfa==frfl ||
                     (check_backward(frfa) && check_backward(frfl))) {
                ctx = 3
            else
                ctx = 4
        } else if ( LeftSingle || AboveSingle ) {
            frfc = LeftSingle ? frfa : frfl
            rfs = AboveSingle ? frfa : frfl
            if (check_last(frfc) && !check_last(rfs))
                ctx= 1
            else if (check_last(rfs) && !check_last(frfc))
                ctx = 2
              else
                ctx = 3 + (frfc == LAST2_FRAME || check_golden_or_last3(rfs))
        } else if ( check_last(frfa) && check_last(frfl) ) {
            ctx = 2
        } else {
            ctx = 3 + (check_golden_or_last3(frfa) || check_golden_or_last3(frfl))
        }
    }
} else if ( AvailU ) {
    if ( AboveIntra ) {
        ctx = 2
    } else {
        if ( !AboveSingle )
            ctx = 4 * (!check_last(above0))
        else if (check_last(above0))
            ctx = 0
        else
            ctx = 2 + check_golden_or_last3(above0)
    }
} else if ( AvailL ) {
    if ( LeftIntra ) {
        ctx = 2
    } else {
        if ( !LeftSingle )
            ctx = 4 * (!check_last(left_ref_frame[fwd_ref_sign_idx]))
        else if (check_last(left0))
            ctx = 0
        else
            ctx = 2 + check_golden_or_last3(left0)
    }
} else {
    ctx = 2
}

comp_ref_p2: the cdf is given by TileCompRefCdf[ ctx ][ 2 ] where ctx is computed by:

above0 = AboveRefFrame[ 0 ]
left0 = LeftRefFrame[ 0 ]
if ( AvailU && AvailL ) {
    if ( AboveIntra && LeftIntra ) {
        ctx = 2
    } else if ( LeftIntra ) {
        ctx = 1 + 2 * (!check_golden(above0))
    } else if ( AboveIntra ) {
        ctx = 1 + 2 * (!check_golden(left0))
    } else {
        frfa = above0
        frfl = left0
        if ( frfa == frfl && check_golden(frfa) ) {
            ctx = 0
        } else if ( LeftSingle && AboveSingle ) {
            if ( check_golden(frfa) || check_golden(frfl) )
                ctx = 1
            else if ( check_last_or_last2(frfa) || check_last_or_last2(frfl) )
                ctx = 2 + (frfa != frfl)
            else if ( frfa==frfl ||
                     (check_backward(frfa) && check_backward(frfl))) {
                ctx = 3
            else
                ctx = 4
        } else if ( LeftSingle || AboveSingle ) {
            frfc = LeftSingle ? frfa : frfl
            rfs = AboveSingle ? frfa : frfl
            if (check_golden(frfc) && !check_golden(rfs))
                ctx= 1
            else if (check_golden(rfs) && !check_golden(frfc))
                ctx = 2
              else
                ctx = 3 + (frfc == LAST3_FRAME || check_last_or_last2(rfs))
        } else if ( check_golden(frfa) && check_golden(frfl) ) {
            ctx = 2
        } else {
            ctx = 3 + (check_last_or_last2(frfa) || check_last_or_last2(frfl))
        }
    }
} else if ( AvailU ) {
    if ( AboveIntra ) {
        ctx = 2
    } else {
        if ( !AboveSingle )
            ctx = 4 * (!check_golden(above0))
        else if (check_golden(above0))
            ctx = 0
        else
            ctx = 2 + check_last_or_last2(above0)
    }
} else if ( AvailL ) {
    if ( LeftIntra ) {
        ctx = 2
    } else {
        if ( !LeftSingle )
            ctx = 4 * (!check_golden(left_ref_frame[fwd_ref_sign_idx]))
        else if (check_golden(left0))
            ctx = 0
        else
            ctx = 2 + check_last_or_last2(left0)
    }
} else {
    ctx = 2
}

comp_bwdref: the cdf is given by TileCompBwdRefCdf[ ctx ][ 0 ] where ctx is computed by:

brfarf2Count = count_refs( BWDREF_FRAME ) + count_refs( ALTREF2_FRAME )
arfCount = count_refs( ALTREF_FRAME )
ctx = ref_count_ctx( brfarf2Count, arfCount )

comp_bwdref_p1: the cdf is given by TileCompBwdRefCdf[ ctx ][ 1 ] where ctx is computed by:

brfCount = count_refs( BWDREF_FRAME )
arf2Count = count_refs( ALTREF2_FRAME )
ctx = ref_count_ctx( brfCount, arf2Count )

single_ref_p1: the cdf is given by TileSingleRefCdf[ ctx ][ 0 ] where ctx is computed by:

above0 = AboveRefFrame[ 0 ]
left0 = LeftRefFrame[ 0 ]
if ( AvailU && AvailL ) {
    if ( AboveIntra && LeftIntra ) {
        ctx = 2
    } else if ( LeftIntra ) {
        if ( AboveSingle )
            ctx = 4 * (!check_backward(above0))
        else
            ctx = 2
    } else if ( AboveIntra ) {
        if ( LeftSingle )
            ctx = 4 * (!check_backward(left0))
        else
            ctx = 2
    } else {
        if ( AboveSingle && LeftSingle ) {
            ctx = 2 * (!check_backward(above0)) +
                  2 * (!check_backward(left0))
        } else if ( !AboveSingle && !LeftSingle ) {
            ctx = 2
        } else {
            rfs = AboveSingle ? above0 : left0
            ctx = (!check_backward(rfs)) ? 4 : 1
        }
    }
} else if ( AvailU ) {
    if ( AboveIntra ) {
        ctx = 2
    } else {
        if ( AboveSingle )
            ctx = 4 * (!check_backward(above0))
        else
            ctx = 2
    }
} else if ( AvailL ) {
    if ( LeftIntra ) {
        ctx = 2
    } else {
        if ( LeftSingle )
            ctx = 4 * (!check_backward(left0))
        else
            ctx = 2
    }
} else {
    ctx = 2
}

single_ref_p2: the cdf is given by TileSingleRefCdf[ ctx ][ 1 ] where ctx is computed by:

brfarf2Count = count_refs( BWDREF_FRAME ) + count_refs( ALTREF2_FRAME )
arfCount = count_refs( ALTREF_FRAME )
ctx = ref_count_ctx( brfarf2Count, arfCount )

Note: The context calculation for single_ref_p2 is the same as for comp_bwdref. ctx can only equal 0, 1, or 2 for single_ref_p2.

single_ref_p3: the cdf is given by TileSingleRefCdf[ ctx ][ 2 ] where ctx is computed by:

above0 = AboveRefFrame[ 0 ]
above1 = AboveRefFrame[ 1 ]
left0 = LeftRefFrame[ 0 ]
left1 = LeftRefFrame[ 1 ]
if ( AvailU && AvailL ) {
    if ( AboveIntra && LeftIntra ) {
        ctx = 2
    } else if ( LeftIntra ) {
        if ( AboveSingle ) {
            if ( check_backward(above0) )
                ctx = 3
            else
                ctx = 4 * check_last_or_last2(above0)
        } else {
            ctx = 1 + 2 * (check_last_or_last2(above0) ||
                           check_last_or_last2(above1))
        }
    } else if ( AboveIntra ) {
        if ( LeftSingle ) {
            if ( check_backward(left0) )
                ctx = 3
            else
                ctx = 4 * check_last_or_last2(left0)
        } else {
                ctx = 1 + 2 * (check_last_or_last2(left0) ||
                               check_last_or_last2(left1))
        }
    } else {
        if ( AboveSingle && LeftSingle ) {
            if (check_backward(above0) && check_backward(left0)) {
                ctx = 2 + (above0 == left0)
            } else if (check_backward(above0) ||
                       check_backward(left0)) {
                edge0 = check_backward(above0) ? left0 : above0
                ctx = 4 * check_last_or_last2(edge0)
            } else {
                ctx = 2 * check_last_or_last2(above0) + 2 * check_last_or_last2(left0)
            }
        } else if ( !AboveSingle && !LeftSingle ) {
            if (above0 == left0 && above1 == left1)
                ctx = 3 * (check_last_or_last2(above0) ||
                           check_last_or_last2(above1) ||
                           check_last_or_last2(left0) ||
                           check_last_or_last2(left1))
            else
                ctx = 2
        } else {
            rfs = AboveSingle ? above0 : left0
            crf1 = AboveSingle ? left0 : above0
            crf2 = AboveSingle ? left1 : above1
            if (check_last_or_last2(rfs))
                ctx = 3 + (check_last_or_last2(crf1) || check_last_or_last2(crf2))
            else if (check_golden_or_last3(rfs))
                ctx = (check_last_or_last2(crf1) || check_last_or_last2(crf2))
            else
                ctx = 1 + 2 * (check_last_or_last2(crf1) || check_last_or_last2(crf2))
        }
    } else if ( AvailU ) {
        if ( AboveIntra || (check_backward(above0) && AboveSingle) )
            ctx= 2
        else if ( AboveSingle )
            ctx= 4 * check_last_or_last2(above0)
        else
            ctx= 3 * ( check_last_or_last2(above0) ||
                       check_last_or_last2(above1) )
    } else if ( AvailL ) {
        if ( LeftIntra || (check_backward(left0) && LeftSingle) )
            ctx = 2
        else if ( LeftSingle )
            ctx = 4 * check_last_or_last2(left0)
        else
            ctx = 3 * ( check_last_or_last2(left0) ||
                        check_last_or_last2(left1) )
    } else {
        ctx = 2
}

single_ref_p4: the cdf is given by TileSingleRefCdf[ ctx ][ 3 ] where ctx is computed by:

above0 = AboveRefFrame[ 0 ]
above1 = AboveRefFrame[ 1 ]
left0 = LeftRefFrame[ 0 ]
left1 = LeftRefFrame[ 1 ]
if ( AvailU && AvailL ) {
    if ( AboveIntra && LeftIntra ) {
        ctx = 2
    } else if ( LeftIntra ) {
        if ( AboveSingle ) {
            if ( !check_last_or_last2(above0) )
                ctx = 3
            else
                ctx = 4 * check_last(above0)
        } else {
            ctx = 1 + 2 * (check_last(above0) ||
                           check_last(above1))
        }
    } else if ( AboveIntra ) {
        if ( LeftSingle ) {
            if ( !check_last_or_last2(left0) )
                ctx = 3
            else
                ctx = 4 * check_last(left0)
        } else {
                ctx = 1 + 2 * (check_last(left0) ||
                               check_last(left1))
        }
    } else {
        if ( AboveSingle && LeftSingle ) {
            if (!check_last_or_last2(above0) && !check_last_or_last2(left0)) {
                ctx = 2 + (above0 == left0)
            } else if (!check_last_or_last2(above0) ||
                       !check_last_or_last2(left0)) {
                edge0 = !check_last_or_last2(above0) ? left0 : above0
                ctx = 4 * check_last(edge0)
            } else {
                ctx = 2 * check_last(above0) + 2 * check_last(left0)
            }
        } else if ( !AboveSingle && !LeftSingle ) {
            if (above0 == left0 && above1 == left1)
                ctx = 3 * (check_last(above0) ||
                           check_last(above1) ||
                           check_last(left0) ||
                           check_last(left1))
            else
                ctx = 2
        } else {
            rfs = AboveSingle ? above0 : left0
            crf1 = AboveSingle ? left0 : above0
            crf2 = AboveSingle ? left1 : above1
            if (check_last(rfs))
                ctx = 3 + (check_last(crf1) || check_last(crf2))
            else if (check_last2(rfs))
                ctx = (check_last(crf1) || check_last(crf2))
            else
                ctx = 1 + 2 * (check_last(crf1) || check_last(crf2))
        }
    } else if ( AvailU ) {
        if ( AboveIntra || (!check_last_or_last2(above0) && AboveSingle) )
            ctx= 2
        else if ( AboveSingle )
            ctx= 4 * check_last(above0)
        else
            ctx= 3 * ( check_last(above0) ||
                       check_last(above1) )
    } else if ( AvailL ) {
        if ( LeftIntra || (!check_last_or_last2(left0) && LeftSingle) )
            ctx = 2
        else if ( LeftSingle )
            ctx = 4 * check_last(left0)
        else
            ctx = 3 * ( check_last(left0) ||
                        check_last(left1) )
    } else {
        ctx = 2
}

single_ref_p5: the cdf is given by TileSingleRefCdf[ ctx ][ 4 ] where ctx is computed by:

above0 = AboveRefFrame[ 0 ]
above1 = AboveRefFrame[ 1 ]
left0 = LeftRefFrame[ 0 ]
left1 = LeftRefFrame[ 1 ]
if ( AvailU && AvailL ) {
    if ( AboveIntra && LeftIntra ) {
        ctx = 2
    } else if ( LeftIntra ) {
        if ( AboveSingle ) {
            if ( !check_golden_or_last3(above0) )
                ctx = 3
            else
                ctx = 4 * check_last3(above0)
        } else {
            ctx = 1 + 2 * (check_last3(above0) ||
                           check_last3(above1))
        }
    } else if ( AboveIntra ) {
        if ( LeftSingle ) {
            if ( !check_golden_or_last3(left0) )
                ctx = 3
            else
                ctx = 4 * check_last3(left0)
        } else {
                ctx = 1 + 2 * (check_last3(left0) ||
                               check_last3(left1))
        }
    } else {
        if ( AboveSingle && LeftSingle ) {
            if (!check_golden_or_last3(above0) && !check_golden_or_last3(left0)) {
                ctx = 2 + (above0 == left0)
            } else if (!check_golden_or_last3(above0) ||
                       !check_golden_or_last3(left0)) {
                edge0 = !check_golden_or_last3(above0) ? left0 : above0
                ctx = 4 * check_last3(edge0)
            } else {
                ctx = 2 * check_last3(above0) + 2 * check_last3(left0)
            }
        } else if ( !AboveSingle && !LeftSingle ) {
            if (above0 == left0 && above1 == left1)
                ctx = 3 * (check_last3(above0) ||
                           check_last3(above1) ||
                           check_last3(left0) ||
                           check_last3(left1))
            else
                ctx = 2
        } else {
            rfs = AboveSingle ? above0 : left0
            crf1 = AboveSingle ? left0 : above0
            crf2 = AboveSingle ? left1 : above1
            if (check_last3(rfs))
                ctx = 3 + (check_last3(crf1) || check_last3(crf2))
            else if (check_golden(rfs))
                ctx = (check_last3(crf1) || check_last3(crf2))
            else
                ctx = 1 + 2 * (check_last3(crf1) || check_last3(crf2))
        }
    } else if ( AvailU ) {
        if ( AboveIntra || (!check_golden_or_last3(above0) && AboveSingle) )
            ctx= 2
        else if ( AboveSingle )
            ctx= 4 * check_last3(above0)
        else
            ctx= 3 * ( check_last3(above0) ||
                       check_last3(above1) )
    } else if ( AvailL ) {
        if ( LeftIntra || (!check_golden_or_last3(left0) && LeftSingle) )
            ctx = 2
        else if ( LeftSingle )
            ctx = 4 * check_last3(left0)
        else
            ctx = 3 * ( check_last3(left0) ||
                        check_last3(left1) )
    } else {
        ctx = 2
}

single_ref_p6: the cdf is given by TileSingleRefCdf[ ctx ][ 5 ] where ctx is computed by:

brfCount = count_refs( BWDREF_FRAME )
arf2Count = count_refs( ALTREF2_FRAME )
ctx = ref_count_ctx( brfCount, arf2Count )

Note: The context calculation for single_ref_p6 is the same as for comp_bwdref_p1. ctx can only equal 0, 1, or 2 for single_ref_p6.

coef_extra_bits: the cdf depends on the variables cat and cdfIndex as follows:

cat cdfIndex cdf
1 0 Default_Coef_Extra_Bits_Cat1_Cdf
2 0 Default_Coef_Extra_Bits_Cat2_Cdf
3 0 Default_Coef_Extra_Bits_Cat3_Cdf
4 0 Default_Coef_Extra_Bits_Cat4_Cdf
5 0 Default_Coef_Extra_Bits_Cat5_S1_Cdf
5 1 Default_Coef_Extra_Bits_Cat5_S2_Cdf
6 0 Default_Coef_Extra_Bits_Cat6_S1_Cdf
6 1 Default_Coef_Extra_Bits_Cat6_S2_Cdf
6 2 Default_Coef_Extra_Bits_Cat6_S3_Cdf
6 3 Default_Coef_Extra_Bits_Cat6_S4_Cdf
6 4 Default_Coef_Extra_Bits_Cat6_S5_Cdf

compound_mode: the cdf is given by TileCompoundModeCdf[ CompoundContext ].

interp_filter: the cdf is given by TileInterpFilterCdf[ ctx ] where ctx is computed by:

    ctx = ( ( dir & 1 ) * 2 + ( RefFrame[ 1 ] > INTRA_FRAME ) ) * 4
    leftType = 3
    aboveType = 3

    if ( AvailL ) {
        if ( RefFrames[ MiRow ][ MiCol - 1 ][ 0 ] == RefFrame[ 0 ] ||
             RefFrames[ MiRow ][ MiCol - 1 ][ 1 ] == RefFrame[ 0 ] )
            leftType = InterpFilters[ MiRow ] [ MiCol - 1 ][ dir ]
    }

    if ( AvailU ) {
        if ( RefFrames[ MiRow - 1 ][ MiCol ][ 0 ] == RefFrame[ 0 ] ||
             RefFrames[ MiRow - 1 ][ MiCol ][ 1 ] == RefFrame[ 0 ] )
            aboveType = InterpFilters[ MiRow - 1 ] [ MiCol ][ dir ]
    }

    if ( leftType == aboveType )
        ctx += leftType
    else if ( leftType == 3 )
        ctx += aboveType
    else if ( aboveType == 3 )
        ctx += leftType
    else
        ctx += 3

motion_mode: the cdf is given by TileMotionModeCdf[ MiSize ].

mv_joint: the cdf is given by TileMvJointCdf[ MvCtx ].

mv_class: the cdf is given by TileMvClassCdf[ MvCtx ][ comp ].

mv_class0_bit: the cdf is given by TileMvClass0BitCdf[ MvCtx ][ comp ].

mv_class0_fr: the cdf is given by TileMvClass0FrCdf[ MvCtx ][ comp ][ mv_class0_bit ].

mv_class0_hp: the cdf

mv_fr: the cdf is given by TileMvFrCdf[ MvCtx ][ comp ].

tail_token: the cdf is given by TileTailTokenCdf[txSz][plane>0][is_inter][band][ctx] where ctx is computed by:

if ( c == 0 ) {
    sx = plane > 0 ? subsampling_x : 0
    sy = plane > 0 ? subsampling_y : 0
    maxX4 = MiCols >> sx
    maxY4 = MiRows >> sy
    w4 = Tx_Width[ txSz ] >> 2
    h4 = Tx_Height[ txSz ] >> 2
    x4 = startX >> 2
    y4 = startY >> 2
    above = 0
    left = 0
    for ( i = 0 ; i < w4; i++ ) {
        if ( x4 + i < maxX4 )
            above |= AboveNonzeroContext[ plane ][ x4 + i ]
    }
    for ( i = 0 ; i < h4; i++ ) {
        if ( y4 + i < maxY4 )
            left |= LeftNonzeroContext[ plane ][ y4 + i ]
    }
    ctx = above + left
} else {
    ctx = ( 1 + TokenCache[ nb[ 0 ] ] + TokenCache[ nb[ 1 ] ] ) >> 1
}

The neighbors of each coefficient are calculated as follows:

    if ( c == 0 ) {
        nb[ 0 ] = 0
        nb[ 1 ] = 0
    } else {
        w = Tx_Width[ txSz ]
        i = pos / w
        j = pos % w
        if ( i > 0 && j > 0 ) {
            a = (i - 1) * w + j
            a2 = i * w + j - 1
            if ( PlaneTxType == DCT_ADST ) {
                nb[ 0 ] = a
                nb[ 1 ] = a
            } else if ( PlaneTxType == ADST_DCT ) {
                nb[ 0 ] = a2
                nb[ 1 ] = a2
            } else {
                nb[ 0 ] = a
                nb[ 1 ] = a2
            }
        } else if ( i > 0 ) {
            nb[ 0 ] = (i - 1) * w + j
            nb[ 1 ] = (i - 1) * w + j
        } else {
            nb[ 0 ] = i * w + j - 1
            nb[ 1 ] = i * w + j - 1
        }
    }

dc_head_token: dc_head_token uses the same derivation for the variable ctx as for the syntax element tail_token. The cdf for dc_head_token is given by TileDcHeadTokenCdf[txSz][plane>0][is_inter][ctx].

ac_head_token: ac_head_token uses the same derivation for the variable ctx as for the syntax element tail_token. The cdf for ac_head_token is given by TileAcHeadTokenCdf[txSz][plane>0][is_inter][band-1][ctx].

has_palette_y: the cdf is given by TilePaletteYModeCdf[ MiSize - BLOCK_8X8 ][ ctx ] where ctx is computed as follows:

ctx = 0
if ( AvailU && PaletteSizes[ 0 ][ MiRow - 1 ][ MiCol ] > 0 )
    ctx += 1
if ( AvailL && PaletteSizes[ 0 ][ MiRow ][ MiCol - 1 ] > 0 )
    ctx += 1

has_palette_uv: the cdf is given by TilePaletteUVModeCdf[ MiSize - BLOCK_8X8 ][ ctx ] where ctx is computed as follows:

ctx = ( PaletteSizeY > 0 ) ? 1 : 0

palette_size_y_minus_2: the cdf is given by TilePaletteYSizeCdf[ MiSize - BLOCK_8X8 ].

palette_size_uv_minus_2: the cdf is given by TilePaletteUVSizeCdf[ MiSize - BLOCK_8X8 ].

palette_color_idx_y: the cdf depends on PaletteSizeY, as follows:

PaletteSizeY cdf
2 TilePaletteSize2YColorCdf[ ctx ]
3 TilePaletteSize3YColorCdf[ ctx ]
4 TilePaletteSize4YColorCdf[ ctx ]
5 TilePaletteSize5YColorCdf[ ctx ]
6 TilePaletteSize6YColorCdf[ ctx ]
7 TilePaletteSize7YColorCdf[ ctx ]
8 TilePaletteSize8YColorCdf[ ctx ]

where ctx is computed as follows:

ctx = Palette_Color_Context[ ColorContextHash ]

palette_color_idx_uv: the cdf depends on PaletteSizeUV, as follows:

PaletteSizeUV cdf
2 TilePaletteSize2UVColorCdf[ ctx ]
3 TilePaletteSize3UVColorCdf[ ctx ]
4 TilePaletteSize4UVColorCdf[ ctx ]
5 TilePaletteSize5UVColorCdf[ ctx ]
6 TilePaletteSize6UVColorCdf[ ctx ]
7 TilePaletteSize7UVColorCdf[ ctx ]
8 TilePaletteSize8UVColorCdf[ ctx ]

where ctx is computed as follows:

ctx = Palette_Color_Context[ ColorContextHash ]

delta_q_abs: the cdf is given by TileDeltaQCdf.

delta_lf_abs: the cdf is derived as follows:

* If delta_lf_multi is equal to 0, the cdf is given by TileDeltaLFCdf.

* Otherwise (delta_lf_multi is equal to 1), the cdf is given by TileDeltaLFMultiCdf[ i ].

intra_tx_type: the cdf depends on the variable set, as follows:

set cdf
1 TileIntraTxTypeSet1Cdf[ Tx_Size_Sqr[ txSz ] ][ YMode ]
2 TileIntraTxTypeSet2Cdf[ Tx_Size_Sqr[ txSz ] ][ YMode ]

inter_tx_type: the cdf depends on the variable set, as follows:

set cdf
1 TileInterTxTypeSet1Cdf[ Tx_Size_Sqr[ txSz ] ]
2 TileInterTxTypeSet2Cdf[ Tx_Size_Sqr[ txSz ] ]
3 TileInterTxTypeSet3Cdf[ Tx_Size_Sqr[ txSz ] ]

comp_ref_type: The cdf is given by TileCompRefTypeCdf[ ctx ], where ctx is computed as follows:

above0 = AboveRefFrame[ 0 ]
above1 = AboveRefFrame[ 1 ]
left0 = LeftRefFrame[ 0 ]
left1 = LeftRefFrame[ 1 ]
aboveCompInter = AvailU && !AboveIntra && !AboveSingle
leftCompInter = AvailL && !LeftIntra && !LeftSingle
aboveUniComp = aboveCompInter && is_samedir_ref_pair(above0, above1)
leftUniComp = leftCompInter && is_samedir_ref_pair(left0, left1)

if (AvailU && !AboveIntra && AvailL && !LeftIntra) {
    samedir = is_samedir_ref_pair(above0, left0)

    if (!aboveCompInter && !leftCompInter) {
        ctx = 1 + 2 * samedir
    } else if (!aboveCompInter) {
        if (!leftUniComp)
            ctx = 1
        else
            ctx = 3 + samedir
    } else if (!leftCompInter) {
        if (!aboveUniComp)
            ctx = 1
        else
            ctx = 3 + samedir
    } else {
        if (!aboveUniComp && !leftUniComp)
            ctx = 0
        else if (!aboveUniComp || !leftUniComp)
            ctx = 2
        else
            ctx = 3 + ((above0 == BWDREF_FRAME) == (left0 == BWDREF_FRAME))
    }
} else if (AvailU && AvailL) {
    if (aboveCompInter)
        ctx = 1 + 2 * aboveUniComp
    else if (leftCompInter)
        ctx = 1 + 2 * leftUniComp
    else
        ctx = 2
} else if (aboveCompInter) {
    ctx = 4 * aboveUniComp
} else if (leftCompInter) {
    ctx = 4 * leftUniComp
} else {
    ctx = 2
}

uni_comp_ref: The cdf is given by TileUniCompRefCdf[ ctx ][ 0 ], where ctx is computed as follows:

fwdCount = count_refs( LAST_FRAME )
fwdCount += count_refs( LAST2_FRAME )
fwdCount += count_refs( LAST3_FRAME )
fwdCount += count_refs( GOLDEN_FRAME )
bwdCount = count_refs( BWDREF_FRAME )
bwdCount += count_refs( ALTREF2_FRAME )
bwdCount += count_refs( ALTREF_FRAME )
ctx = ref_count_ctx( fwdCount, bwdCount )

uni_comp_ref_p1: The cdf is given by TileUniCompRefCdf[ ctx ][ 1 ], where ctx is computed as follows:

last2Count = count_refs( LAST2_FRAME )
last3GoldCount = count_refs( LAST3_FRAME ) + count_refs( GOLDEN_FRAME )
ctx = ref_count_ctx( last2Count, last3GoldCount )

uni_comp_ref_p2: The cdf is given by TileUniCompRefCdf[ ctx ][ 2 ], where ctx is computed as follows:

last3Count = count_refs( LAST3_FRAME )
goldCount = count_refs( GOLDEN_FRAME )
ctx = ref_count_ctx( last3Count, goldCount )

compound_type: The cdf is given by TileCompoundTypeCdf[ MiSize ].

interintra: The cdf is given by TileInterIntraCdf[ ctx ], where ctx is computed as follows:

ctx = Size_Group[ MiSize ]

interintra_mode: The cdf is given by TileInterIntraModeCdf[ ctx ], where ctx is computed as follows:

ctx = Size_Group[ MiSize ]

wedge_interintra: The cdf is given by TileWedgeInterIntraCdf[ MiSize ].

use_obmc: The cdf is given by TileUseObmcCdf[ MiSize ].

cfl_alpha_signs: The cdf is given by TileCflSignCdf.

cfl_alpha_u: The cdf is given by TileCflAlphaCdf[ ctx ] where ctx is computed as follows:

ctx = (signU - 1) * 3 + signV

Note: The variable ctx produced by this calculation will be equal to cfl_alpha_signs - 2.

cfl_alpha_v: The cdf is given by TileCflAlphaCdf[ ctx ] where ctx is computed as follows:

ctx = (signV - 1) * 3 + signU

Additional Tables

This section contains tables that do not naturally fit in the main sections of the Specification.

Scan Tables

This section defines the scan order for different types of transform.

Default_Scan_4x4[ 16 ] = {
    0, 4, 1, 5,
    8, 2, 12, 9,
    3, 6, 13, 10,
    7, 14, 11, 15,
}
Col_Scan_4x4[ 16 ] = {
    0, 4, 8, 1,
    12, 5, 9, 2,
    13, 6, 10, 3,
    7, 14, 11, 15,
}
Row_Scan_4x4[ 16 ] = {
    0, 1, 4, 2,
    5, 3, 6, 8,
    9, 7, 12, 10,
    13, 11, 14, 15,
}
Mcol_Scan_4x4[ 16 ] = {
    0, 4, 8, 12,
    1, 5, 9, 13,
    2, 6, 10, 14,
    3, 7, 11, 15,
}
Mrow_Scan_4x4[ 16 ] = {
    0, 1, 2, 3,
    4, 5, 6, 7,
    8, 9, 10, 11,
    12, 13, 14, 15,
}
Default_Scan_4x8[32] = {
  0,  1,  4,  5,  2,  8,  6,  9,  10, 3,  12, 7,  13, 11, 14, 16,
  17, 15, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
}
Mcol_Scan_4x8[32] = {
  0, 4, 8,  12, 16, 20, 24, 28, 1, 5, 9,  13, 17, 21, 25, 29,
  2, 6, 10, 14, 18, 22, 26, 30, 3, 7, 11, 15, 19, 23, 27, 31,
}
Mrow_Scan_4x8[32] = {
  0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15,
  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
}
Default_Scan_8x4[32] = {
  0,  1,  8,  9, 2,  16, 10, 17, 18, 3,  24, 11, 25, 19, 26, 4,
  12, 27, 20, 5, 28, 13, 21, 29, 6,  14, 22, 30, 7,  15, 23, 31,
}
Mcol_Scan_8x4[32] = {
  0, 8,  16, 24, 1, 9,  17, 25, 2, 10, 18, 26, 3, 11, 19, 27,
  4, 12, 20, 28, 5, 13, 21, 29, 6, 14, 22, 30, 7, 15, 23, 31,
}
Mrow_Scan_8x4[32] = {
  0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15,
  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
}
Default_Scan_8x8[ 64 ] = {
    0, 8, 1, 16, 9, 2, 17, 24,
    10, 3, 18, 25, 32, 11, 4, 26,
    33, 19, 40, 12, 34, 27, 5, 41,
    20, 48, 13, 35, 42, 28, 21, 6,
    49, 56, 36, 43, 29, 7, 14, 50,
    57, 44, 22, 37, 15, 51, 58, 30,
    45, 23, 52, 59, 38, 31, 60, 53,
    46, 39, 61, 54, 47, 62, 55, 63,
}
Mcol_Scan_8x8[ 64 ] = {
  0, 8,  16, 24, 32, 40, 48, 56,
  1, 9,  17, 25, 33, 41, 49, 57,
  2, 10, 18, 26, 34, 42, 50, 58,
  3, 11, 19, 27, 35, 43, 51, 59,
  4, 12, 20, 28, 36, 44, 52, 60,
  5, 13, 21, 29, 37, 45, 53, 61,
  6, 14, 22, 30, 38, 46, 54, 62,
  7, 15, 23, 31, 39, 47, 55, 63,
}
Mrow_Scan_8x8[ 64 ] = {
  0,  1,  2,  3,  4,  5,  6,  7,
  8,  9,  10, 11, 12, 13, 14, 15,
  16, 17, 18, 19, 20, 21, 22, 23,
  24, 25, 26, 27, 28, 29, 30, 31,
  32, 33, 34, 35, 36, 37, 38, 39,
  40, 41, 42, 43, 44, 45, 46, 47,
  48, 49, 50, 51, 52, 53, 54, 55,
  56, 57, 58, 59, 60, 61, 62, 63,
}
Col_Scan_8x8[ 64 ] = {
    0, 8, 16, 1, 24, 9, 32, 17,
    2, 40, 25, 10, 33, 18, 48, 3,
    26, 41, 11, 56, 19, 34, 4, 49,
    27, 42, 12, 35, 20, 57, 50, 28,
    5, 43, 13, 36, 58, 51, 21, 44,
    6, 29, 59, 37, 14, 52, 22, 7,
    45, 60, 30, 15, 38, 53, 23, 46,
    31, 61, 39, 54, 47, 62, 55, 63,
}
Row_Scan_8x8[ 64 ] = {
    0, 1, 2, 8, 9, 3, 16, 10,
    4, 17, 11, 24, 5, 18, 25, 12,
    19, 26, 32, 6, 13, 20, 33, 27,
    7, 34, 40, 21, 28, 41, 14, 35,
    48, 42, 29, 36, 49, 22, 43, 15,
    56, 37, 50, 44, 30, 57, 23, 51,
    58, 45, 38, 52, 31, 59, 53, 46,
    60, 39, 61, 47, 54, 55, 62, 63,
}
Default_Scan_8x16[128] = {
  0,   1,   8,   2,   9,   16,  3,   10,  17,  24,  4,   11,  18,  25,  32,
  5,   12,  19,  26,  33,  40,  6,   13,  20,  27,  34,  41,  48,  7,   14,
  21,  28,  35,  42,  49,  56,  15,  22,  29,  36,  43,  50,  57,  64,  23,
  30,  37,  44,  51,  58,  65,  72,  31,  38,  45,  52,  59,  66,  73,  80,
  39,  46,  53,  60,  67,  74,  81,  88,  47,  54,  61,  68,  75,  82,  89,
  96,  55,  62,  69,  76,  83,  90,  97,  104, 63,  70,  77,  84,  91,  98,
  105, 112, 71,  78,  85,  92,  99,  106, 113, 120, 79,  86,  93,  100, 107,
  114, 121, 87,  94,  101, 108, 115, 122, 95,  102, 109, 116, 123, 103, 110,
  117, 124, 111, 118, 125, 119, 126, 127,
}
Mcol_Scan_8x16[128] = {
  0, 8,  16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96,  104, 112, 120,
  1, 9,  17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97,  105, 113, 121,
  2, 10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98,  106, 114, 122,
  3, 11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 91, 99,  107, 115, 123,
  4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92, 100, 108, 116, 124,
  5, 13, 21, 29, 37, 45, 53, 61, 69, 77, 85, 93, 101, 109, 117, 125,
  6, 14, 22, 30, 38, 46, 54, 62, 70, 78, 86, 94, 102, 110, 118, 126,
  7, 15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95, 103, 111, 119, 127,
}
Mrow_Scan_8x16[128] = {
  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,
  75,  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
  90,  91,  92,  93,  94,  95,  96,  97,  98,  99,  100, 101, 102, 103, 104,
  105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
  120, 121, 122, 123, 124, 125, 126, 127,
}
Default_Scan_16x8[128] = {
  0,   1,  16,  2,   17,  32,  3,  18, 33,  48,  4,   19,  34,  49,  64,  5,
  20,  35, 50,  65,  80,  6,   21, 36, 51,  66,  81,  96,  7,   22,  37,  52,
  67,  82, 97,  112, 8,   23,  38, 53, 68,  83,  98,  113, 9,   24,  39,  54,
  69,  84, 99,  114, 10,  25,  40, 55, 70,  85,  100, 115, 11,  26,  41,  56,
  71,  86, 101, 116, 12,  27,  42, 57, 72,  87,  102, 117, 13,  28,  43,  58,
  73,  88, 103, 118, 14,  29,  44, 59, 74,  89,  104, 119, 15,  30,  45,  60,
  75,  90, 105, 120, 31,  46,  61, 76, 91,  106, 121, 47,  62,  77,  92,  107,
  122, 63, 78,  93,  108, 123, 79, 94, 109, 124, 95,  110, 125, 111, 126, 127,
}
Mcol_Scan_16x8[128] = {
  0,  16, 32, 48, 64, 80, 96,  112, 1,  17, 33, 49, 65, 81, 97,  113,
  2,  18, 34, 50, 66, 82, 98,  114, 3,  19, 35, 51, 67, 83, 99,  115,
  4,  20, 36, 52, 68, 84, 100, 116, 5,  21, 37, 53, 69, 85, 101, 117,
  6,  22, 38, 54, 70, 86, 102, 118, 7,  23, 39, 55, 71, 87, 103, 119,
  8,  24, 40, 56, 72, 88, 104, 120, 9,  25, 41, 57, 73, 89, 105, 121,
  10, 26, 42, 58, 74, 90, 106, 122, 11, 27, 43, 59, 75, 91, 107, 123,
  12, 28, 44, 60, 76, 92, 108, 124, 13, 29, 45, 61, 77, 93, 109, 125,
  14, 30, 46, 62, 78, 94, 110, 126, 15, 31, 47, 63, 79, 95, 111, 127,
}
Mrow_Scan_16x8[128] = {
  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,
  75,  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
  90,  91,  92,  93,  94,  95,  96,  97,  98,  99,  100, 101, 102, 103, 104,
  105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
  120, 121, 122, 123, 124, 125, 126, 127,
}
Default_Scan_16x16[ 256 ] = {
    0, 16, 1, 32, 17, 2, 48, 33, 18, 3, 64, 34, 49, 19, 65, 80,
    50, 4, 35, 66, 20, 81, 96, 51, 5, 36, 82, 97, 67, 112, 21, 52,
    98, 37, 83, 113, 6, 68, 128, 53, 22, 99, 114, 84, 7, 129, 38, 69,
    100, 115, 144, 130, 85, 54, 23, 8, 145, 39, 70, 116, 101, 131, 160, 146,
    55, 86, 24, 71, 132, 117, 161, 40, 9, 102, 147, 176, 162, 87, 56, 25,
    133, 118, 177, 148, 72, 103, 41, 163, 10, 192, 178, 88, 57, 134, 149, 119,
    26, 164, 73, 104, 193, 42, 179, 208, 11, 135, 89, 165, 120, 150, 58, 194,
    180, 27, 74, 209, 105, 151, 136, 43, 90, 224, 166, 195, 181, 121, 210, 59,
    12, 152, 106, 167, 196, 75, 137, 225, 211, 240, 182, 122, 91, 28, 197, 13,
    226, 168, 183, 153, 44, 212, 138, 107, 241, 60, 29, 123, 198, 184, 227, 169,
    242, 76, 213, 154, 45, 92, 14, 199, 139, 61, 228, 214, 170, 185, 243, 108,
    77, 155, 30, 15, 200, 229, 124, 215, 244, 93, 46, 186, 171, 201, 109, 140,
    230, 62, 216, 245, 31, 125, 78, 156, 231, 47, 187, 202, 217, 94, 246, 141,
    63, 232, 172, 110, 247, 157, 79, 218, 203, 126, 233, 188, 248, 95, 173, 142,
    219, 111, 249, 234, 158, 127, 189, 204, 250, 235, 143, 174, 220, 205, 159, 251,
    190, 221, 175, 236, 237, 191, 206, 252, 222, 253, 207, 238, 223, 254, 239, 255
}
Mcol_Scan_16x16[ 256 ] = {
  0,  16, 32, 48, 64, 80, 96,  112, 128, 144, 160, 176, 192, 208, 224, 240,
  1,  17, 33, 49, 65, 81, 97,  113, 129, 145, 161, 177, 193, 209, 225, 241,
  2,  18, 34, 50, 66, 82, 98,  114, 130, 146, 162, 178, 194, 210, 226, 242,
  3,  19, 35, 51, 67, 83, 99,  115, 131, 147, 163, 179, 195, 211, 227, 243,
  4,  20, 36, 52, 68, 84, 100, 116, 132, 148, 164, 180, 196, 212, 228, 244,
  5,  21, 37, 53, 69, 85, 101, 117, 133, 149, 165, 181, 197, 213, 229, 245,
  6,  22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182, 198, 214, 230, 246,
  7,  23, 39, 55, 71, 87, 103, 119, 135, 151, 167, 183, 199, 215, 231, 247,
  8,  24, 40, 56, 72, 88, 104, 120, 136, 152, 168, 184, 200, 216, 232, 248,
  9,  25, 41, 57, 73, 89, 105, 121, 137, 153, 169, 185, 201, 217, 233, 249,
  10, 26, 42, 58, 74, 90, 106, 122, 138, 154, 170, 186, 202, 218, 234, 250,
  11, 27, 43, 59, 75, 91, 107, 123, 139, 155, 171, 187, 203, 219, 235, 251,
  12, 28, 44, 60, 76, 92, 108, 124, 140, 156, 172, 188, 204, 220, 236, 252,
  13, 29, 45, 61, 77, 93, 109, 125, 141, 157, 173, 189, 205, 221, 237, 253,
  14, 30, 46, 62, 78, 94, 110, 126, 142, 158, 174, 190, 206, 222, 238, 254,
  15, 31, 47, 63, 79, 95, 111, 127, 143, 159, 175, 191, 207, 223, 239, 255,
}
Mrow_Scan_16x16[ 256 ] = {
  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,
  75,  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
  90,  91,  92,  93,  94,  95,  96,  97,  98,  99,  100, 101, 102, 103, 104,
  105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
  120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
  135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
  150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
  165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
  180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
  195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
  210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
  225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
  255,
}
Col_Scan_16x16[ 256 ] = {
    0, 16, 32, 48, 1, 64, 17, 80, 33, 96, 49, 2, 65, 112, 18, 81,
    34, 128, 50, 97, 3, 66, 144, 19, 113, 35, 82, 160, 98, 51, 129, 4,
    67, 176, 20, 114, 145, 83, 36, 99, 130, 52, 192, 5, 161, 68, 115, 21,
    146, 84, 208, 177, 37, 131, 100, 53, 162, 224, 69, 6, 116, 193, 147, 85,
    22, 240, 132, 38, 178, 101, 163, 54, 209, 117, 70, 7, 148, 194, 86, 179,
    225, 23, 133, 39, 164, 8, 102, 210, 241, 55, 195, 118, 149, 71, 180, 24,
    87, 226, 134, 165, 211, 40, 103, 56, 72, 150, 196, 242, 119, 9, 181, 227,
    88, 166, 25, 135, 41, 104, 212, 57, 151, 197, 120, 73, 243, 182, 136, 167,
    213, 89, 10, 228, 105, 152, 198, 26, 42, 121, 183, 244, 168, 58, 137, 229,
    74, 214, 90, 153, 199, 184, 11, 106, 245, 27, 122, 230, 169, 43, 215, 59,
    200, 138, 185, 246, 75, 12, 91, 154, 216, 231, 107, 28, 44, 201, 123, 170,
    60, 247, 232, 76, 139, 13, 92, 217, 186, 248, 155, 108, 29, 124, 45, 202,
    233, 171, 61, 14, 77, 140, 15, 249, 93, 30, 187, 156, 218, 46, 109, 125,
    62, 172, 78, 203, 31, 141, 234, 94, 47, 188, 63, 157, 110, 250, 219, 79,
    126, 204, 173, 142, 95, 189, 111, 235, 158, 220, 251, 127, 174, 143, 205, 236,
    159, 190, 221, 252, 175, 206, 237, 191, 253, 222, 238, 207, 254, 223, 239, 255,
}
Row_Scan_16x16[ 256 ] = {
    0, 1, 2, 16, 3, 17, 4, 18, 32, 5, 33, 19, 6, 34, 48, 20,
    49, 7, 35, 21, 50, 64, 8, 36, 65, 22, 51, 37, 80, 9, 66, 52,
    23, 38, 81, 67, 10, 53, 24, 82, 68, 96, 39, 11, 54, 83, 97, 69,
    25, 98, 84, 40, 112, 55, 12, 70, 99, 113, 85, 26, 41, 56, 114, 100,
    13, 71, 128, 86, 27, 115, 101, 129, 42, 57, 72, 116, 14, 87, 130, 102,
    144, 73, 131, 117, 28, 58, 15, 88, 43, 145, 103, 132, 146, 118, 74, 160,
    89, 133, 104, 29, 59, 147, 119, 44, 161, 148, 90, 105, 134, 162, 120, 176,
    75, 135, 149, 30, 60, 163, 177, 45, 121, 91, 106, 164, 178, 150, 192, 136,
    165, 179, 31, 151, 193, 76, 122, 61, 137, 194, 107, 152, 180, 208, 46, 166,
    167, 195, 92, 181, 138, 209, 123, 153, 224, 196, 77, 168, 210, 182, 240, 108,
    197, 62, 154, 225, 183, 169, 211, 47, 139, 93, 184, 226, 212, 241, 198, 170,
    124, 155, 199, 78, 213, 185, 109, 227, 200, 63, 228, 242, 140, 214, 171, 186,
    156, 229, 243, 125, 94, 201, 244, 215, 216, 230, 141, 187, 202, 79, 172, 110,
    157, 245, 217, 231, 95, 246, 232, 126, 203, 247, 233, 173, 218, 142, 111, 158,
    188, 248, 127, 234, 219, 249, 189, 204, 143, 174, 159, 250, 235, 205, 220, 175,
    190, 251, 221, 191, 206, 236, 207, 237, 252, 222, 253, 223, 238, 239, 254, 255,
}
Default_Scan_16x32[512] = {
  0,   1,   16,  2,   17,  32,  3,   18,  33,  48,  4,   19,  34,  49,  64,
  5,   20,  35,  50,  65,  80,  6,   21,  36,  51,  66,  81,  96,  7,   22,
  37,  52,  67,  82,  97,  112, 8,   23,  38,  53,  68,  83,  98,  113, 128,
  9,   24,  39,  54,  69,  84,  99,  114, 129, 144, 10,  25,  40,  55,  70,
  85,  100, 115, 130, 145, 160, 11,  26,  41,  56,  71,  86,  101, 116, 131,
  146, 161, 176, 12,  27,  42,  57,  72,  87,  102, 117, 132, 147, 162, 177,
  192, 13,  28,  43,  58,  73,  88,  103, 118, 133, 148, 163, 178, 193, 208,
  14,  29,  44,  59,  74,  89,  104, 119, 134, 149, 164, 179, 194, 209, 224,
  15,  30,  45,  60,  75,  90,  105, 120, 135, 150, 165, 180, 195, 210, 225,
  240, 31,  46,  61,  76,  91,  106, 121, 136, 151, 166, 181, 196, 211, 226,
  241, 256, 47,  62,  77,  92,  107, 122, 137, 152, 167, 182, 197, 212, 227,
  242, 257, 272, 63,  78,  93,  108, 123, 138, 153, 168, 183, 198, 213, 228,
  243, 258, 273, 288, 79,  94,  109, 124, 139, 154, 169, 184, 199, 214, 229,
  244, 259, 274, 289, 304, 95,  110, 125, 140, 155, 170, 185, 200, 215, 230,
  245, 260, 275, 290, 305, 320, 111, 126, 141, 156, 171, 186, 201, 216, 231,
  246, 261, 276, 291, 306, 321, 336, 127, 142, 157, 172, 187, 202, 217, 232,
  247, 262, 277, 292, 307, 322, 337, 352, 143, 158, 173, 188, 203, 218, 233,
  248, 263, 278, 293, 308, 323, 338, 353, 368, 159, 174, 189, 204, 219, 234,
  249, 264, 279, 294, 309, 324, 339, 354, 369, 384, 175, 190, 205, 220, 235,
  250, 265, 280, 295, 310, 325, 340, 355, 370, 385, 400, 191, 206, 221, 236,
  251, 266, 281, 296, 311, 326, 341, 356, 371, 386, 401, 416, 207, 222, 237,
  252, 267, 282, 297, 312, 327, 342, 357, 372, 387, 402, 417, 432, 223, 238,
  253, 268, 283, 298, 313, 328, 343, 358, 373, 388, 403, 418, 433, 448, 239,
  254, 269, 284, 299, 314, 329, 344, 359, 374, 389, 404, 419, 434, 449, 464,
  255, 270, 285, 300, 315, 330, 345, 360, 375, 390, 405, 420, 435, 450, 465,
  480, 271, 286, 301, 316, 331, 346, 361, 376, 391, 406, 421, 436, 451, 466,
  481, 496, 287, 302, 317, 332, 347, 362, 377, 392, 407, 422, 437, 452, 467,
  482, 497, 303, 318, 333, 348, 363, 378, 393, 408, 423, 438, 453, 468, 483,
  498, 319, 334, 349, 364, 379, 394, 409, 424, 439, 454, 469, 484, 499, 335,
  350, 365, 380, 395, 410, 425, 440, 455, 470, 485, 500, 351, 366, 381, 396,
  411, 426, 441, 456, 471, 486, 501, 367, 382, 397, 412, 427, 442, 457, 472,
  487, 502, 383, 398, 413, 428, 443, 458, 473, 488, 503, 399, 414, 429, 444,
  459, 474, 489, 504, 415, 430, 445, 460, 475, 490, 505, 431, 446, 461, 476,
  491, 506, 447, 462, 477, 492, 507, 463, 478, 493, 508, 479, 494, 509, 495,
  510, 511,
}
Mcol_Scan_16x32[512] = {
  0,   16,  32,  48,  64,  80,  96,  112, 128, 144, 160, 176, 192, 208, 224,
  240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400, 416, 432, 448, 464,
  480, 496, 1,   17,  33,  49,  65,  81,  97,  113, 129, 145, 161, 177, 193,
  209, 225, 241, 257, 273, 289, 305, 321, 337, 353, 369, 385, 401, 417, 433,
  449, 465, 481, 497, 2,   18,  34,  50,  66,  82,  98,  114, 130, 146, 162,
  178, 194, 210, 226, 242, 258, 274, 290, 306, 322, 338, 354, 370, 386, 402,
  418, 434, 450, 466, 482, 498, 3,   19,  35,  51,  67,  83,  99,  115, 131,
  147, 163, 179, 195, 211, 227, 243, 259, 275, 291, 307, 323, 339, 355, 371,
  387, 403, 419, 435, 451, 467, 483, 499, 4,   20,  36,  52,  68,  84,  100,
  116, 132, 148, 164, 180, 196, 212, 228, 244, 260, 276, 292, 308, 324, 340,
  356, 372, 388, 404, 420, 436, 452, 468, 484, 500, 5,   21,  37,  53,  69,
  85,  101, 117, 133, 149, 165, 181, 197, 213, 229, 245, 261, 277, 293, 309,
  325, 341, 357, 373, 389, 405, 421, 437, 453, 469, 485, 501, 6,   22,  38,
  54,  70,  86,  102, 118, 134, 150, 166, 182, 198, 214, 230, 246, 262, 278,
  294, 310, 326, 342, 358, 374, 390, 406, 422, 438, 454, 470, 486, 502, 7,
  23,  39,  55,  71,  87,  103, 119, 135, 151, 167, 183, 199, 215, 231, 247,
  263, 279, 295, 311, 327, 343, 359, 375, 391, 407, 423, 439, 455, 471, 487,
  503, 8,   24,  40,  56,  72,  88,  104, 120, 136, 152, 168, 184, 200, 216,
  232, 248, 264, 280, 296, 312, 328, 344, 360, 376, 392, 408, 424, 440, 456,
  472, 488, 504, 9,   25,  41,  57,  73,  89,  105, 121, 137, 153, 169, 185,
  201, 217, 233, 249, 265, 281, 297, 313, 329, 345, 361, 377, 393, 409, 425,
  441, 457, 473, 489, 505, 10,  26,  42,  58,  74,  90,  106, 122, 138, 154,
  170, 186, 202, 218, 234, 250, 266, 282, 298, 314, 330, 346, 362, 378, 394,
  410, 426, 442, 458, 474, 490, 506, 11,  27,  43,  59,  75,  91,  107, 123,
  139, 155, 171, 187, 203, 219, 235, 251, 267, 283, 299, 315, 331, 347, 363,
  379, 395, 411, 427, 443, 459, 475, 491, 507, 12,  28,  44,  60,  76,  92,
  108, 124, 140, 156, 172, 188, 204, 220, 236, 252, 268, 284, 300, 316, 332,
  348, 364, 380, 396, 412, 428, 444, 460, 476, 492, 508, 13,  29,  45,  61,
  77,  93,  109, 125, 141, 157, 173, 189, 205, 221, 237, 253, 269, 285, 301,
  317, 333, 349, 365, 381, 397, 413, 429, 445, 461, 477, 493, 509, 14,  30,
  46,  62,  78,  94,  110, 126, 142, 158, 174, 190, 206, 222, 238, 254, 270,
  286, 302, 318, 334, 350, 366, 382, 398, 414, 430, 446, 462, 478, 494, 510,
  15,  31,  47,  63,  79,  95,  111, 127, 143, 159, 175, 191, 207, 223, 239,
  255, 271, 287, 303, 319, 335, 351, 367, 383, 399, 415, 431, 447, 463, 479,
  495, 511,
}
Mrow_Scan_16x32[512] = {
  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,
  75,  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
  90,  91,  92,  93,  94,  95,  96,  97,  98,  99,  100, 101, 102, 103, 104,
  105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
  120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
  135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
  150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
  165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
  180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
  195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
  210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
  225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
  255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
  270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
  285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
  300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
  315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329,
  330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
  345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359,
  360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
  375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389,
  390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
  405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419,
  420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434,
  435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449,
  450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464,
  465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479,
  480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494,
  495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509,
  510, 511,
}
Default_Scan_32x16[512] = {
  0,   1,   32,  2,   33,  64,  3,   34,  65,  96,  4,   35,  66,  97,  128,
  5,   36,  67,  98,  129, 160, 6,   37,  68,  99,  130, 161, 192, 7,   38,
  69,  100, 131, 162, 193, 224, 8,   39,  70,  101, 132, 163, 194, 225, 256,
  9,   40,  71,  102, 133, 164, 195, 226, 257, 288, 10,  41,  72,  103, 134,
  165, 196, 227, 258, 289, 320, 11,  42,  73,  104, 135, 166, 197, 228, 259,
  290, 321, 352, 12,  43,  74,  105, 136, 167, 198, 229, 260, 291, 322, 353,
  384, 13,  44,  75,  106, 137, 168, 199, 230, 261, 292, 323, 354, 385, 416,
  14,  45,  76,  107, 138, 169, 200, 231, 262, 293, 324, 355, 386, 417, 448,
  15,  46,  77,  108, 139, 170, 201, 232, 263, 294, 325, 356, 387, 418, 449,
  480, 16,  47,  78,  109, 140, 171, 202, 233, 264, 295, 326, 357, 388, 419,
  450, 481, 17,  48,  79,  110, 141, 172, 203, 234, 265, 296, 327, 358, 389,
  420, 451, 482, 18,  49,  80,  111, 142, 173, 204, 235, 266, 297, 328, 359,
  390, 421, 452, 483, 19,  50,  81,  112, 143, 174, 205, 236, 267, 298, 329,
  360, 391, 422, 453, 484, 20,  51,  82,  113, 144, 175, 206, 237, 268, 299,
  330, 361, 392, 423, 454, 485, 21,  52,  83,  114, 145, 176, 207, 238, 269,
  300, 331, 362, 393, 424, 455, 486, 22,  53,  84,  115, 146, 177, 208, 239,
  270, 301, 332, 363, 394, 425, 456, 487, 23,  54,  85,  116, 147, 178, 209,
  240, 271, 302, 333, 364, 395, 426, 457, 488, 24,  55,  86,  117, 148, 179,
  210, 241, 272, 303, 334, 365, 396, 427, 458, 489, 25,  56,  87,  118, 149,
  180, 211, 242, 273, 304, 335, 366, 397, 428, 459, 490, 26,  57,  88,  119,
  150, 181, 212, 243, 274, 305, 336, 367, 398, 429, 460, 491, 27,  58,  89,
  120, 151, 182, 213, 244, 275, 306, 337, 368, 399, 430, 461, 492, 28,  59,
  90,  121, 152, 183, 214, 245, 276, 307, 338, 369, 400, 431, 462, 493, 29,
  60,  91,  122, 153, 184, 215, 246, 277, 308, 339, 370, 401, 432, 463, 494,
  30,  61,  92,  123, 154, 185, 216, 247, 278, 309, 340, 371, 402, 433, 464,
  495, 31,  62,  93,  124, 155, 186, 217, 248, 279, 310, 341, 372, 403, 434,
  465, 496, 63,  94,  125, 156, 187, 218, 249, 280, 311, 342, 373, 404, 435,
  466, 497, 95,  126, 157, 188, 219, 250, 281, 312, 343, 374, 405, 436, 467,
  498, 127, 158, 189, 220, 251, 282, 313, 344, 375, 406, 437, 468, 499, 159,
  190, 221, 252, 283, 314, 345, 376, 407, 438, 469, 500, 191, 222, 253, 284,
  315, 346, 377, 408, 439, 470, 501, 223, 254, 285, 316, 347, 378, 409, 440,
  471, 502, 255, 286, 317, 348, 379, 410, 441, 472, 503, 287, 318, 349, 380,
  411, 442, 473, 504, 319, 350, 381, 412, 443, 474, 505, 351, 382, 413, 444,
  475, 506, 383, 414, 445, 476, 507, 415, 446, 477, 508, 447, 478, 509, 479,
  510, 511,
}
Mcol_Scan_32x16[512] = {
  0,  32, 64, 96,  128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480,
  1,  33, 65, 97,  129, 161, 193, 225, 257, 289, 321, 353, 385, 417, 449, 481,
  2,  34, 66, 98,  130, 162, 194, 226, 258, 290, 322, 354, 386, 418, 450, 482,
  3,  35, 67, 99,  131, 163, 195, 227, 259, 291, 323, 355, 387, 419, 451, 483,
  4,  36, 68, 100, 132, 164, 196, 228, 260, 292, 324, 356, 388, 420, 452, 484,
  5,  37, 69, 101, 133, 165, 197, 229, 261, 293, 325, 357, 389, 421, 453, 485,
  6,  38, 70, 102, 134, 166, 198, 230, 262, 294, 326, 358, 390, 422, 454, 486,
  7,  39, 71, 103, 135, 167, 199, 231, 263, 295, 327, 359, 391, 423, 455, 487,
  8,  40, 72, 104, 136, 168, 200, 232, 264, 296, 328, 360, 392, 424, 456, 488,
  9,  41, 73, 105, 137, 169, 201, 233, 265, 297, 329, 361, 393, 425, 457, 489,
  10, 42, 74, 106, 138, 170, 202, 234, 266, 298, 330, 362, 394, 426, 458, 490,
  11, 43, 75, 107, 139, 171, 203, 235, 267, 299, 331, 363, 395, 427, 459, 491,
  12, 44, 76, 108, 140, 172, 204, 236, 268, 300, 332, 364, 396, 428, 460, 492,
  13, 45, 77, 109, 141, 173, 205, 237, 269, 301, 333, 365, 397, 429, 461, 493,
  14, 46, 78, 110, 142, 174, 206, 238, 270, 302, 334, 366, 398, 430, 462, 494,
  15, 47, 79, 111, 143, 175, 207, 239, 271, 303, 335, 367, 399, 431, 463, 495,
  16, 48, 80, 112, 144, 176, 208, 240, 272, 304, 336, 368, 400, 432, 464, 496,
  17, 49, 81, 113, 145, 177, 209, 241, 273, 305, 337, 369, 401, 433, 465, 497,
  18, 50, 82, 114, 146, 178, 210, 242, 274, 306, 338, 370, 402, 434, 466, 498,
  19, 51, 83, 115, 147, 179, 211, 243, 275, 307, 339, 371, 403, 435, 467, 499,
  20, 52, 84, 116, 148, 180, 212, 244, 276, 308, 340, 372, 404, 436, 468, 500,
  21, 53, 85, 117, 149, 181, 213, 245, 277, 309, 341, 373, 405, 437, 469, 501,
  22, 54, 86, 118, 150, 182, 214, 246, 278, 310, 342, 374, 406, 438, 470, 502,
  23, 55, 87, 119, 151, 183, 215, 247, 279, 311, 343, 375, 407, 439, 471, 503,
  24, 56, 88, 120, 152, 184, 216, 248, 280, 312, 344, 376, 408, 440, 472, 504,
  25, 57, 89, 121, 153, 185, 217, 249, 281, 313, 345, 377, 409, 441, 473, 505,
  26, 58, 90, 122, 154, 186, 218, 250, 282, 314, 346, 378, 410, 442, 474, 506,
  27, 59, 91, 123, 155, 187, 219, 251, 283, 315, 347, 379, 411, 443, 475, 507,
  28, 60, 92, 124, 156, 188, 220, 252, 284, 316, 348, 380, 412, 444, 476, 508,
  29, 61, 93, 125, 157, 189, 221, 253, 285, 317, 349, 381, 413, 445, 477, 509,
  30, 62, 94, 126, 158, 190, 222, 254, 286, 318, 350, 382, 414, 446, 478, 510,
  31, 63, 95, 127, 159, 191, 223, 255, 287, 319, 351, 383, 415, 447, 479, 511,
}
Mrow_Scan_32x16[512] = {
  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,
  75,  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
  90,  91,  92,  93,  94,  95,  96,  97,  98,  99,  100, 101, 102, 103, 104,
  105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
  120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
  135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
  150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
  165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
  180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
  195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
  210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
  225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
  255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
  270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
  285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
  300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
  315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329,
  330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
  345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359,
  360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
  375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389,
  390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
  405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419,
  420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434,
  435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449,
  450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464,
  465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479,
  480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494,
  495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509,
  510, 511,
}
Default_Scan_32x32[ 1024 ] = {
    0, 32, 1, 64, 33, 2, 96, 65, 34, 128, 3, 97, 66, 160,
    129, 35, 98, 4, 67, 130, 161, 192, 36, 99, 224, 5, 162, 193,
    68, 131, 37, 100,
    225, 194, 256, 163, 69, 132, 6, 226, 257, 288, 195, 101, 164, 38,
    258, 7, 227, 289, 133, 320, 70, 196, 165, 290, 259, 228, 39, 321,
    102, 352, 8, 197,
    71, 134, 322, 291, 260, 353, 384, 229, 166, 103, 40, 354, 323, 292,
    135, 385, 198, 261, 72, 9, 416, 167, 386, 355, 230, 324, 104, 293,
    41, 417, 199, 136,
    262, 387, 448, 325, 356, 10, 73, 418, 231, 168, 449, 294, 388, 105,
    419, 263, 42, 200, 357, 450, 137, 480, 74, 326, 232, 11, 389, 169,
    295, 420, 106, 451,
    481, 358, 264, 327, 201, 43, 138, 512, 482, 390, 296, 233, 170, 421,
    75, 452, 359, 12, 513, 265, 483, 328, 107, 202, 514, 544, 422, 391,
    453, 139, 44, 234,
    484, 297, 360, 171, 76, 515, 545, 266, 329, 454, 13, 423, 203, 108,
    546, 485, 576, 298, 235, 140, 361, 330, 172, 547, 45, 455, 267, 577,
    486, 77, 204, 362,
    608, 14, 299, 578, 109, 236, 487, 609, 331, 141, 579, 46, 15, 173,
    610, 363, 78, 205, 16, 110, 237, 611, 142, 47, 174, 79, 206, 17,
    111, 238, 48, 143,
    80, 175, 112, 207, 49, 18, 239, 81, 113, 19, 50, 82, 114, 51,
    83, 115, 640, 516, 392, 268, 144, 20, 672, 641, 548, 517, 424,
    393, 300, 269, 176, 145,
    52, 21, 704, 673, 642, 580, 549, 518, 456, 425, 394, 332, 301,
    270, 208, 177, 146, 84, 53, 22, 736, 705, 674, 643, 612, 581,
    550, 519, 488, 457, 426, 395,
    364, 333, 302, 271, 240, 209, 178, 147, 116, 85, 54, 23, 737,
    706, 675, 613, 582, 551, 489, 458, 427, 365, 334, 303, 241,
    210, 179, 117, 86, 55, 738, 707,
    614, 583, 490, 459, 366, 335, 242, 211, 118, 87, 739, 615, 491,
    367, 243, 119, 768, 644, 520, 396, 272, 148, 24, 800, 769, 676,
    645, 552, 521, 428, 397, 304,
    273, 180, 149, 56, 25, 832, 801, 770, 708, 677, 646, 584, 553,
    522, 460, 429, 398, 336, 305, 274, 212, 181, 150, 88, 57, 26,
    864, 833, 802, 771, 740, 709,
    678, 647, 616, 585, 554, 523, 492, 461, 430, 399, 368, 337, 306,
    275, 244, 213, 182, 151, 120, 89, 58, 27, 865, 834, 803, 741,
    710, 679, 617, 586, 555, 493,
    462, 431, 369, 338, 307, 245, 214, 183, 121, 90, 59, 866, 835,
    742, 711, 618, 587, 494, 463, 370, 339, 246, 215, 122, 91, 867,
    743, 619, 495, 371, 247, 123,
    896, 772, 648, 524, 400, 276, 152, 28, 928, 897, 804, 773, 680,
    649, 556, 525, 432, 401, 308, 277, 184, 153, 60, 29, 960, 929,
    898, 836, 805, 774, 712, 681,
    650, 588, 557, 526, 464, 433, 402, 340, 309, 278, 216, 185, 154,
    92, 61, 30, 992, 961, 930, 899, 868, 837, 806, 775, 744, 713, 682,
    651, 620, 589, 558, 527,
    496, 465, 434, 403, 372, 341, 310, 279, 248, 217, 186, 155, 124,
    93, 62, 31, 993, 962, 931, 869, 838, 807, 745, 714, 683, 621, 590,
    559, 497, 466, 435, 373,
    342, 311, 249, 218, 187, 125, 94, 63, 994, 963, 870, 839, 746, 715,
    622, 591, 498, 467, 374, 343, 250, 219, 126, 95, 995, 871, 747, 623,
    499, 375, 251, 127,
    900, 776, 652, 528, 404, 280, 156, 932, 901, 808, 777, 684, 653, 560,
    529, 436, 405, 312, 281, 188, 157, 964, 933, 902, 840, 809, 778, 716,
    685, 654, 592, 561,
    530, 468, 437, 406, 344, 313, 282, 220, 189, 158, 996, 965, 934, 903,
    872, 841, 810, 779, 748, 717, 686, 655, 624, 593, 562, 531, 500, 469,
    438, 407, 376, 345,
    314, 283, 252, 221, 190, 159, 997, 966, 935, 873, 842, 811, 749, 718,
    687, 625, 594, 563, 501, 470, 439, 377, 346, 315, 253, 222, 191, 998,
    967, 874, 843, 750,
    719, 626, 595, 502, 471, 378, 347, 254, 223, 999, 875, 751, 627, 503,
    379, 255, 904, 780, 656, 532, 408, 284, 936, 905, 812, 781, 688, 657,
    564, 533, 440, 409,
    316, 285, 968, 937, 906, 844, 813, 782, 720, 689, 658, 596, 565, 534,
    472, 441, 410, 348, 317, 286, 1000, 969, 938, 907, 876, 845, 814, 783,
    752, 721, 690, 659,
    628, 597, 566, 535, 504, 473, 442, 411, 380, 349, 318, 287, 1001, 970,
    939, 877, 846, 815, 753, 722, 691, 629, 598, 567, 505, 474, 443, 381,
    350, 319, 1002, 971,
    878, 847, 754, 723, 630, 599, 506, 475, 382, 351, 1003, 879, 755, 631,
    507, 383, 908, 784, 660, 536, 412, 940, 909, 816, 785, 692, 661, 568,
    537, 444, 413, 972,
    941, 910, 848, 817, 786, 724, 693, 662, 600, 569, 538, 476, 445, 414,
    1004, 973, 942, 911, 880, 849, 818, 787, 756, 725, 694, 663, 632, 601,
    570, 539, 508, 477,
    446, 415, 1005, 974, 943, 881, 850, 819, 757, 726, 695, 633, 602, 571,
    509, 478, 447, 1006, 975, 882, 851, 758, 727, 634, 603, 510, 479,
    1007, 883, 759, 635, 511,
    912, 788, 664, 540, 944, 913, 820, 789, 696, 665, 572, 541, 976, 945,
    914, 852, 821, 790, 728, 697, 666, 604, 573, 542, 1008, 977, 946, 915,
    884, 853, 822, 791,
    760, 729, 698, 667, 636, 605, 574, 543, 1009, 978, 947, 885, 854, 823,
    761, 730, 699, 637, 606, 575, 1010, 979, 886, 855, 762, 731, 638, 607,
    1011, 887, 763, 639,
    916, 792, 668, 948, 917, 824, 793, 700, 669, 980, 949, 918, 856, 825,
    794, 732, 701, 670, 1012, 981, 950, 919, 888, 857, 826, 795, 764, 733,
    702, 671, 1013, 982,
    951, 889, 858, 827, 765, 734, 703, 1014, 983, 890, 859, 766, 735, 1015,
    891, 767, 920, 796, 952, 921, 828, 797, 984, 953, 922, 860, 829, 798,
    1016, 985, 954, 923,
    892, 861, 830, 799, 1017, 986, 955, 893, 862, 831, 1018, 987, 894, 863,
    1019, 895, 924, 956, 925, 988, 957, 926, 1020, 989, 958, 927, 1021,
    990, 959, 1022, 991, 1023,
}
Mcol_Scan_32x32[ 1024 ] = {
  0,   32,   64,  96,   128, 160,  192, 224,  256, 288,  320, 352,  384, 416,
  448, 480,  512, 544,  576, 608,  640, 672,  704, 736,  768, 800,  832, 864,
  896, 928,  960, 992,  1,   33,   65,  97,   129, 161,  193, 225,  257, 289,
  321, 353,  385, 417,  449, 481,  513, 545,  577, 609,  641, 673,  705, 737,
  769, 801,  833, 865,  897, 929,  961, 993,  2,   34,   66,  98,   130, 162,
  194, 226,  258, 290,  322, 354,  386, 418,  450, 482,  514, 546,  578, 610,
  642, 674,  706, 738,  770, 802,  834, 866,  898, 930,  962, 994,  3,   35,
  67,  99,   131, 163,  195, 227,  259, 291,  323, 355,  387, 419,  451, 483,
  515, 547,  579, 611,  643, 675,  707, 739,  771, 803,  835, 867,  899, 931,
  963, 995,  4,   36,   68,  100,  132, 164,  196, 228,  260, 292,  324, 356,
  388, 420,  452, 484,  516, 548,  580, 612,  644, 676,  708, 740,  772, 804,
  836, 868,  900, 932,  964, 996,  5,   37,   69,  101,  133, 165,  197, 229,
  261, 293,  325, 357,  389, 421,  453, 485,  517, 549,  581, 613,  645, 677,
  709, 741,  773, 805,  837, 869,  901, 933,  965, 997,  6,   38,   70,  102,
  134, 166,  198, 230,  262, 294,  326, 358,  390, 422,  454, 486,  518, 550,
  582, 614,  646, 678,  710, 742,  774, 806,  838, 870,  902, 934,  966, 998,
  7,   39,   71,  103,  135, 167,  199, 231,  263, 295,  327, 359,  391, 423,
  455, 487,  519, 551,  583, 615,  647, 679,  711, 743,  775, 807,  839, 871,
  903, 935,  967, 999,  8,   40,   72,  104,  136, 168,  200, 232,  264, 296,
  328, 360,  392, 424,  456, 488,  520, 552,  584, 616,  648, 680,  712, 744,
  776, 808,  840, 872,  904, 936,  968, 1000, 9,   41,   73,  105,  137, 169,
  201, 233,  265, 297,  329, 361,  393, 425,  457, 489,  521, 553,  585, 617,
  649, 681,  713, 745,  777, 809,  841, 873,  905, 937,  969, 1001, 10,  42,
  74,  106,  138, 170,  202, 234,  266, 298,  330, 362,  394, 426,  458, 490,
  522, 554,  586, 618,  650, 682,  714, 746,  778, 810,  842, 874,  906, 938,
  970, 1002, 11,  43,   75,  107,  139, 171,  203, 235,  267, 299,  331, 363,
  395, 427,  459, 491,  523, 555,  587, 619,  651, 683,  715, 747,  779, 811,
  843, 875,  907, 939,  971, 1003, 12,  44,   76,  108,  140, 172,  204, 236,
  268, 300,  332, 364,  396, 428,  460, 492,  524, 556,  588, 620,  652, 684,
  716, 748,  780, 812,  844, 876,  908, 940,  972, 1004, 13,  45,   77,  109,
  141, 173,  205, 237,  269, 301,  333, 365,  397, 429,  461, 493,  525, 557,
  589, 621,  653, 685,  717, 749,  781, 813,  845, 877,  909, 941,  973, 1005,
  14,  46,   78,  110,  142, 174,  206, 238,  270, 302,  334, 366,  398, 430,
  462, 494,  526, 558,  590, 622,  654, 686,  718, 750,  782, 814,  846, 878,
  910, 942,  974, 1006, 15,  47,   79,  111,  143, 175,  207, 239,  271, 303,
  335, 367,  399, 431,  463, 495,  527, 559,  591, 623,  655, 687,  719, 751,
  783, 815,  847, 879,  911, 943,  975, 1007, 16,  48,   80,  112,  144, 176,
  208, 240,  272, 304,  336, 368,  400, 432,  464, 496,  528, 560,  592, 624,
  656, 688,  720, 752,  784, 816,  848, 880,  912, 944,  976, 1008, 17,  49,
  81,  113,  145, 177,  209, 241,  273, 305,  337, 369,  401, 433,  465, 497,
  529, 561,  593, 625,  657, 689,  721, 753,  785, 817,  849, 881,  913, 945,
  977, 1009, 18,  50,   82,  114,  146, 178,  210, 242,  274, 306,  338, 370,
  402, 434,  466, 498,  530, 562,  594, 626,  658, 690,  722, 754,  786, 818,
  850, 882,  914, 946,  978, 1010, 19,  51,   83,  115,  147, 179,  211, 243,
  275, 307,  339, 371,  403, 435,  467, 499,  531, 563,  595, 627,  659, 691,
  723, 755,  787, 819,  851, 883,  915, 947,  979, 1011, 20,  52,   84,  116,
  148, 180,  212, 244,  276, 308,  340, 372,  404, 436,  468, 500,  532, 564,
  596, 628,  660, 692,  724, 756,  788, 820,  852, 884,  916, 948,  980, 1012,
  21,  53,   85,  117,  149, 181,  213, 245,  277, 309,  341, 373,  405, 437,
  469, 501,  533, 565,  597, 629,  661, 693,  725, 757,  789, 821,  853, 885,
  917, 949,  981, 1013, 22,  54,   86,  118,  150, 182,  214, 246,  278, 310,
  342, 374,  406, 438,  470, 502,  534, 566,  598, 630,  662, 694,  726, 758,
  790, 822,  854, 886,  918, 950,  982, 1014, 23,  55,   87,  119,  151, 183,
  215, 247,  279, 311,  343, 375,  407, 439,  471, 503,  535, 567,  599, 631,
  663, 695,  727, 759,  791, 823,  855, 887,  919, 951,  983, 1015, 24,  56,
  88,  120,  152, 184,  216, 248,  280, 312,  344, 376,  408, 440,  472, 504,
  536, 568,  600, 632,  664, 696,  728, 760,  792, 824,  856, 888,  920, 952,
  984, 1016, 25,  57,   89,  121,  153, 185,  217, 249,  281, 313,  345, 377,
  409, 441,  473, 505,  537, 569,  601, 633,  665, 697,  729, 761,  793, 825,
  857, 889,  921, 953,  985, 1017, 26,  58,   90,  122,  154, 186,  218, 250,
  282, 314,  346, 378,  410, 442,  474, 506,  538, 570,  602, 634,  666, 698,
  730, 762,  794, 826,  858, 890,  922, 954,  986, 1018, 27,  59,   91,  123,
  155, 187,  219, 251,  283, 315,  347, 379,  411, 443,  475, 507,  539, 571,
  603, 635,  667, 699,  731, 763,  795, 827,  859, 891,  923, 955,  987, 1019,
  28,  60,   92,  124,  156, 188,  220, 252,  284, 316,  348, 380,  412, 444,
  476, 508,  540, 572,  604, 636,  668, 700,  732, 764,  796, 828,  860, 892,
  924, 956,  988, 1020, 29,  61,   93,  125,  157, 189,  221, 253,  285, 317,
  349, 381,  413, 445,  477, 509,  541, 573,  605, 637,  669, 701,  733, 765,
  797, 829,  861, 893,  925, 957,  989, 1021, 30,  62,   94,  126,  158, 190,
  222, 254,  286, 318,  350, 382,  414, 446,  478, 510,  542, 574,  606, 638,
  670, 702,  734, 766,  798, 830,  862, 894,  926, 958,  990, 1022, 31,  63,
  95,  127,  159, 191,  223, 255,  287, 319,  351, 383,  415, 447,  479, 511,
  543, 575,  607, 639,  671, 703,  735, 767,  799, 831,  863, 895,  927, 959,
  991, 1023,
}
Mrow_Scan_32x32[ 1024 ] = {
  0,    1,    2,    3,    4,    5,    6,    7,    8,    9,    10,   11,   12,
  13,   14,   15,   16,   17,   18,   19,   20,   21,   22,   23,   24,   25,
  26,   27,   28,   29,   30,   31,   32,   33,   34,   35,   36,   37,   38,
  39,   40,   41,   42,   43,   44,   45,   46,   47,   48,   49,   50,   51,
  52,   53,   54,   55,   56,   57,   58,   59,   60,   61,   62,   63,   64,
  65,   66,   67,   68,   69,   70,   71,   72,   73,   74,   75,   76,   77,
  78,   79,   80,   81,   82,   83,   84,   85,   86,   87,   88,   89,   90,
  91,   92,   93,   94,   95,   96,   97,   98,   99,   100,  101,  102,  103,
  104,  105,  106,  107,  108,  109,  110,  111,  112,  113,  114,  115,  116,
  117,  118,  119,  120,  121,  122,  123,  124,  125,  126,  127,  128,  129,
  130,  131,  132,  133,  134,  135,  136,  137,  138,  139,  140,  141,  142,
  143,  144,  145,  146,  147,  148,  149,  150,  151,  152,  153,  154,  155,
  156,  157,  158,  159,  160,  161,  162,  163,  164,  165,  166,  167,  168,
  169,  170,  171,  172,  173,  174,  175,  176,  177,  178,  179,  180,  181,
  182,  183,  184,  185,  186,  187,  188,  189,  190,  191,  192,  193,  194,
  195,  196,  197,  198,  199,  200,  201,  202,  203,  204,  205,  206,  207,
  208,  209,  210,  211,  212,  213,  214,  215,  216,  217,  218,  219,  220,
  221,  222,  223,  224,  225,  226,  227,  228,  229,  230,  231,  232,  233,
  234,  235,  236,  237,  238,  239,  240,  241,  242,  243,  244,  245,  246,
  247,  248,  249,  250,  251,  252,  253,  254,  255,  256,  257,  258,  259,
  260,  261,  262,  263,  264,  265,  266,  267,  268,  269,  270,  271,  272,
  273,  274,  275,  276,  277,  278,  279,  280,  281,  282,  283,  284,  285,
  286,  287,  288,  289,  290,  291,  292,  293,  294,  295,  296,  297,  298,
  299,  300,  301,  302,  303,  304,  305,  306,  307,  308,  309,  310,  311,
  312,  313,  314,  315,  316,  317,  318,  319,  320,  321,  322,  323,  324,
  325,  326,  327,  328,  329,  330,  331,  332,  333,  334,  335,  336,  337,
  338,  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
  351,  352,  353,  354,  355,  356,  357,  358,  359,  360,  361,  362,  363,
  364,  365,  366,  367,  368,  369,  370,  371,  372,  373,  374,  375,  376,
  377,  378,  379,  380,  381,  382,  383,  384,  385,  386,  387,  388,  389,
  390,  391,  392,  393,  394,  395,  396,  397,  398,  399,  400,  401,  402,
  403,  404,  405,  406,  407,  408,  409,  410,  411,  412,  413,  414,  415,
  416,  417,  418,  419,  420,  421,  422,  423,  424,  425,  426,  427,  428,
  429,  430,  431,  432,  433,  434,  435,  436,  437,  438,  439,  440,  441,
  442,  443,  444,  445,  446,  447,  448,  449,  450,  451,  452,  453,  454,
  455,  456,  457,  458,  459,  460,  461,  462,  463,  464,  465,  466,  467,
  468,  469,  470,  471,  472,  473,  474,  475,  476,  477,  478,  479,  480,
  481,  482,  483,  484,  485,  486,  487,  488,  489,  490,  491,  492,  493,
  494,  495,  496,  497,  498,  499,  500,  501,  502,  503,  504,  505,  506,
  507,  508,  509,  510,  511,  512,  513,  514,  515,  516,  517,  518,  519,
  520,  521,  522,  523,  524,  525,  526,  527,  528,  529,  530,  531,  532,
  533,  534,  535,  536,  537,  538,  539,  540,  541,  542,  543,  544,  545,
  546,  547,  548,  549,  550,  551,  552,  553,  554,  555,  556,  557,  558,
  559,  560,  561,  562,  563,  564,  565,  566,  567,  568,  569,  570,  571,
  572,  573,  574,  575,  576,  577,  578,  579,  580,  581,  582,  583,  584,
  585,  586,  587,  588,  589,  590,  591,  592,  593,  594,  595,  596,  597,
  598,  599,  600,  601,  602,  603,  604,  605,  606,  607,  608,  609,  610,
  611,  612,  613,  614,  615,  616,  617,  618,  619,  620,  621,  622,  623,
  624,  625,  626,  627,  628,  629,  630,  631,  632,  633,  634,  635,  636,
  637,  638,  639,  640,  641,  642,  643,  644,  645,  646,  647,  648,  649,
  650,  651,  652,  653,  654,  655,  656,  657,  658,  659,  660,  661,  662,
  663,  664,  665,  666,  667,  668,  669,  670,  671,  672,  673,  674,  675,
  676,  677,  678,  679,  680,  681,  682,  683,  684,  685,  686,  687,  688,
  689,  690,  691,  692,  693,  694,  695,  696,  697,  698,  699,  700,  701,
  702,  703,  704,  705,  706,  707,  708,  709,  710,  711,  712,  713,  714,
  715,  716,  717,  718,  719,  720,  721,  722,  723,  724,  725,  726,  727,
  728,  729,  730,  731,  732,  733,  734,  735,  736,  737,  738,  739,  740,
  741,  742,  743,  744,  745,  746,  747,  748,  749,  750,  751,  752,  753,
  754,  755,  756,  757,  758,  759,  760,  761,  762,  763,  764,  765,  766,
  767,  768,  769,  770,  771,  772,  773,  774,  775,  776,  777,  778,  779,
  780,  781,  782,  783,  784,  785,  786,  787,  788,  789,  790,  791,  792,
  793,  794,  795,  796,  797,  798,  799,  800,  801,  802,  803,  804,  805,
  806,  807,  808,  809,  810,  811,  812,  813,  814,  815,  816,  817,  818,
  819,  820,  821,  822,  823,  824,  825,  826,  827,  828,  829,  830,  831,
  832,  833,  834,  835,  836,  837,  838,  839,  840,  841,  842,  843,  844,
  845,  846,  847,  848,  849,  850,  851,  852,  853,  854,  855,  856,  857,
  858,  859,  860,  861,  862,  863,  864,  865,  866,  867,  868,  869,  870,
  871,  872,  873,  874,  875,  876,  877,  878,  879,  880,  881,  882,  883,
  884,  885,  886,  887,  888,  889,  890,  891,  892,  893,  894,  895,  896,
  897,  898,  899,  900,  901,  902,  903,  904,  905,  906,  907,  908,  909,
  910,  911,  912,  913,  914,  915,  916,  917,  918,  919,  920,  921,  922,
  923,  924,  925,  926,  927,  928,  929,  930,  931,  932,  933,  934,  935,
  936,  937,  938,  939,  940,  941,  942,  943,  944,  945,  946,  947,  948,
  949,  950,  951,  952,  953,  954,  955,  956,  957,  958,  959,  960,  961,
  962,  963,  964,  965,  966,  967,  968,  969,  970,  971,  972,  973,  974,
  975,  976,  977,  978,  979,  980,  981,  982,  983,  984,  985,  986,  987,
  988,  989,  990,  991,  992,  993,  994,  995,  996,  997,  998,  999,  1000,
  1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013,
  1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023,
}
V2_Scan_32x32[ 1024 ] = {
  0,    1,    32,   33,   2,    64,   34,   65,   66,   3,    96,   35,   97,
  67,   98,   4,    128,  36,   129,  99,   68,   130,  5,    100,  131,  160,
  37,   161,  69,   162,  132,  101,  163,  6,    192,  38,   193,  70,   194,
  133,  164,  102,  195,  7,    224,  39,   165,  225,  134,  196,  71,   226,
  103,  227,  166,  197,  8,    256,  40,   135,  228,  257,  72,   258,  198,
  104,  259,  167,  229,  136,  260,  9,    288,  41,   289,  73,   199,  230,
  290,  168,  261,  105,  291,  137,  292,  231,  10,   200,  262,  320,  42,
  321,  74,   322,  169,  293,  106,  323,  232,  263,  138,  324,  201,  294,
  11,   352,  43,   353,  75,   170,  325,  354,  264,  107,  233,  295,  355,
  202,  326,  139,  356,  12,   384,  44,   265,  296,  385,  171,  357,  76,
  386,  234,  327,  108,  387,  203,  358,  140,  388,  297,  266,  328,  13,
  172,  389,  416,  45,   235,  359,  417,  77,   418,  109,  419,  204,  390,
  298,  329,  141,  267,  360,  420,  236,  391,  173,  421,  14,   448,  46,
  449,  78,   330,  450,  299,  361,  110,  205,  422,  451,  268,  392,  142,
  452,  237,  423,  174,  331,  362,  453,  15,   300,  393,  480,  47,   481,
  79,   482,  206,  454,  269,  424,  111,  483,  143,  484,  363,  332,  394,
  238,  455,  175,  301,  425,  485,  512,  513,  270,  456,  514,  207,  486,
  364,  395,  515,  333,  426,  516,  239,  487,  302,  457,  517,  396,  271,
  488,  544,  365,  427,  545,  518,  546,  334,  458,  547,  519,  548,  303,
  489,  397,  428,  549,  366,  459,  520,  576,  335,  490,  550,  577,  578,
  579,  521,  429,  551,  398,  460,  580,  367,  491,  581,  552,  522,  582,
  608,  609,  430,  461,  610,  399,  492,  553,  611,  583,  523,  612,  613,
  584,  554,  462,  431,  493,  614,  524,  640,  641,  642,  585,  643,  555,
  615,  644,  463,  494,  586,  525,  616,  645,  556,  646,  672,  617,  673,
  587,  674,  647,  495,  675,  526,  676,  557,  618,  648,  677,  588,  678,
  527,  649,  619,  704,  558,  705,  706,  679,  589,  707,  650,  708,  620,
  680,  709,  559,  590,  710,  651,  681,  736,  621,  737,  711,  738,  739,
  682,  652,  740,  712,  591,  741,  622,  683,  713,  742,  653,  768,  769,
  743,  770,  714,  684,  771,  623,  772,  744,  654,  773,  715,  685,  745,
  774,  655,  775,  800,  801,  716,  746,  802,  803,  686,  776,  804,  747,
  805,  717,  777,  806,  687,  748,  807,  778,  832,  833,  718,  834,  835,
  808,  836,  779,  749,  837,  809,  719,  838,  780,  750,  810,  839,  864,
  865,  866,  867,  840,  781,  868,  811,  751,  869,  841,  870,  812,  782,
  842,  871,  896,  897,  898,  872,  899,  813,  843,  900,  783,  901,  873,
  844,  902,  814,  874,  903,  928,  929,  845,  930,  904,  815,  875,  931,
  932,  905,  933,  846,  876,  934,  906,  935,  877,  960,  847,  961,  962,
  907,  936,  963,  964,  937,  878,  965,  908,  966,  938,  967,  909,  879,
  992,  939,  993,  968,  994,  995,  996,  910,  969,  940,  997,  998,  970,
  911,  941,  999,  971,  1000, 942,  1001, 972,  1002, 943,  973,  1003, 974,
  1004, 975,  1005, 1006, 1007, 16,   48,   80,   112,  144,  176,  17,   49,
  208,  81,   113,  145,  240,  177,  272,  18,   50,   209,  82,   114,  304,
  241,  146,  178,  273,  336,  210,  19,   51,   83,   115,  305,  242,  147,
  368,  179,  274,  337,  211,  20,   400,  52,   84,   306,  116,  243,  369,
  148,  338,  180,  275,  432,  401,  212,  21,   53,   307,  85,   370,  244,
  117,  464,  149,  433,  339,  276,  181,  402,  213,  308,  496,  371,  22,
  54,   465,  86,   245,  118,  434,  150,  340,  277,  403,  182,  528,  497,
  214,  466,  372,  309,  23,   55,   435,  87,   246,  119,  341,  404,  151,
  529,  560,  278,  498,  183,  467,  373,  215,  310,  436,  24,   56,   247,
  561,  88,   530,  592,  342,  120,  405,  499,  152,  279,  468,  184,  374,
  311,  437,  216,  562,  593,  531,  624,  25,   248,  500,  57,   406,  89,
  343,  121,  469,  280,  153,  594,  185,  375,  563,  625,  438,  532,  656,
  312,  217,  501,  407,  249,  26,   344,  58,   90,   470,  122,  595,  626,
  281,  564,  657,  154,  376,  533,  688,  439,  186,  313,  502,  218,  408,
  627,  596,  658,  250,  345,  471,  27,   59,   565,  689,  91,   123,  282,
  534,  720,  155,  440,  377,  187,  503,  314,  628,  659,  219,  597,  690,
  409,  472,  566,  721,  346,  251,  28,   60,   535,  752,  92,   124,  283,
  441,  378,  156,  660,  504,  629,  691,  598,  722,  188,  315,  567,  753,
  220,  410,  473,  347,  536,  784,  252,  29,   661,  692,  61,   93,   442,
  630,  723,  284,  125,  379,  505,  599,  754,  157,  316,  568,  785,  189,
  474,  411,  221,  537,  816,  693,  348,  662,  724,  253,  631,  755,  443,
  30,   600,  786,  62,   506,  94,   285,  380,  126,  569,  817,  158,  317,
  190,  475,  694,  725,  412,  663,  756,  538,  848,  222,  632,  787,  349,
  254,  601,  818,  444,  507,  31,   63,   381,  286,  95,   570,  849,  726,
  127,  695,  757,  664,  788,  159,  476,  318,  413,  539,  880,  191,  633,
  819,  223,  350,  602,  850,  508,  255,  445,  727,  758,  696,  789,  571,
  881,  382,  287,  665,  820,  477,  634,  851,  540,  912,  319,  414,  603,
  882,  759,  728,  790,  351,  509,  697,  821,  446,  572,  913,  666,  852,
  383,  635,  883,  478,  541,  944,  415,  760,  791,  604,  914,  729,  822,
  698,  853,  510,  667,  884,  447,  573,  945,  636,  915,  792,  761,  823,
  542,  976,  479,  730,  854,  605,  946,  699,  885,  668,  916,  511,  574,
  977,  793,  824,  637,  947,  762,  855,  731,  886,  543,  1008, 606,  978,
  700,  917,  669,  948,  575,  825,  1009, 794,  856,  763,  887,  638,  979,
  732,  918,  701,  949,  607,  1010, 670,  980,  826,  857,  795,  888,  764,
  919,  639,  1011, 733,  950,  702,  981,  858,  827,  889,  796,  920,  671,
  1012, 765,  951,  734,  982,  703,  1013, 859,  890,  828,  921,  797,  952,
  766,  983,  735,  1014, 891,  860,  922,  829,  953,  798,  984,  767,  1015,
  892,  923,  861,  954,  830,  985,  799,  1016, 924,  893,  955,  862,  986,
  831,  1017, 925,  956,  894,  987,  863,  1018, 957,  926,  988,  895,  1019,
  958,  989,  927,  1020, 990,  959,  1021, 991,  1022, 1023,
}
H2_Scan_32x32[ 1024 ] = {
  0,    1,    32,   33,   2,    64,   34,   65,   66,   3,    96,   35,   97,
  67,   98,   4,    128,  36,   129,  99,   68,   130,  5,    100,  131,  160,
  37,   161,  69,   162,  132,  101,  163,  6,    192,  38,   193,  70,   194,
  133,  164,  102,  195,  7,    224,  39,   165,  225,  134,  196,  71,   226,
  103,  227,  166,  197,  8,    256,  40,   135,  228,  257,  72,   258,  198,
  104,  259,  167,  229,  136,  260,  9,    288,  41,   289,  73,   199,  230,
  290,  168,  261,  105,  291,  137,  292,  231,  10,   200,  262,  320,  42,
  321,  74,   322,  169,  293,  106,  323,  232,  263,  138,  324,  201,  294,
  11,   352,  43,   353,  75,   170,  325,  354,  264,  107,  233,  295,  355,
  202,  326,  139,  356,  12,   384,  44,   265,  296,  385,  171,  357,  76,
  386,  234,  327,  108,  387,  203,  358,  140,  388,  297,  266,  328,  13,
  172,  389,  416,  45,   235,  359,  417,  77,   418,  109,  419,  204,  390,
  298,  329,  141,  267,  360,  420,  236,  391,  173,  421,  14,   448,  46,
  449,  78,   330,  450,  299,  361,  110,  205,  422,  451,  268,  392,  142,
  452,  237,  423,  174,  331,  362,  453,  15,   300,  393,  480,  47,   481,
  79,   482,  206,  454,  269,  424,  111,  483,  143,  484,  363,  332,  394,
  238,  455,  175,  301,  425,  485,  16,   48,   80,   270,  456,  207,  486,
  112,  364,  395,  333,  426,  144,  239,  487,  302,  457,  176,  396,  17,
  271,  488,  49,   365,  427,  208,  81,   334,  458,  113,  145,  240,  303,
  489,  397,  428,  177,  366,  459,  272,  18,   50,   209,  335,  490,  82,
  114,  304,  241,  429,  146,  398,  460,  367,  491,  178,  273,  336,  210,
  19,   51,   83,   430,  461,  399,  492,  115,  305,  242,  147,  368,  179,
  274,  337,  462,  431,  493,  211,  20,   400,  52,   84,   306,  116,  243,
  369,  148,  463,  494,  338,  180,  275,  432,  401,  212,  21,   53,   307,
  85,   370,  244,  117,  495,  464,  149,  433,  339,  276,  181,  402,  213,
  308,  496,  371,  22,   54,   465,  86,   245,  118,  434,  150,  340,  277,
  403,  182,  497,  214,  466,  372,  309,  23,   55,   435,  87,   246,  119,
  341,  404,  151,  278,  498,  183,  467,  373,  215,  310,  436,  24,   56,
  247,  88,   342,  120,  405,  499,  152,  279,  468,  184,  374,  311,  437,
  216,  25,   248,  500,  57,   406,  89,   343,  121,  469,  280,  153,  185,
  375,  438,  312,  217,  501,  407,  249,  26,   344,  58,   90,   470,  122,
  281,  154,  376,  439,  186,  313,  502,  218,  408,  250,  345,  471,  27,
  59,   91,   123,  282,  155,  440,  377,  187,  503,  314,  219,  409,  472,
  346,  251,  28,   60,   92,   124,  283,  441,  378,  156,  504,  188,  315,
  220,  410,  473,  347,  252,  29,   61,   93,   442,  284,  125,  379,  505,
  157,  316,  189,  474,  411,  221,  348,  253,  443,  30,   62,   506,  94,
  285,  380,  126,  158,  317,  190,  475,  412,  222,  349,  254,  444,  507,
  31,   63,   381,  286,  95,   127,  159,  476,  318,  413,  191,  223,  350,
  508,  255,  445,  382,  287,  477,  319,  414,  351,  509,  446,  383,  478,
  415,  510,  447,  479,  511,  512,  513,  514,  515,  516,  517,  544,  545,
  518,  546,  547,  519,  548,  549,  520,  576,  550,  577,  578,  579,  521,
  551,  580,  581,  552,  522,  582,  608,  609,  610,  553,  611,  583,  523,
  612,  613,  584,  554,  614,  524,  640,  641,  642,  585,  643,  555,  615,
  644,  586,  525,  616,  645,  556,  646,  672,  617,  673,  587,  674,  647,
  675,  526,  676,  557,  618,  648,  677,  588,  678,  527,  649,  619,  704,
  558,  705,  706,  679,  589,  707,  650,  708,  620,  680,  709,  528,  559,
  590,  710,  651,  681,  736,  621,  737,  711,  738,  739,  682,  652,  529,
  560,  740,  712,  591,  741,  622,  683,  713,  742,  653,  768,  769,  561,
  743,  530,  592,  770,  714,  684,  771,  623,  772,  744,  654,  773,  715,
  685,  745,  774,  562,  593,  531,  624,  655,  775,  800,  801,  716,  746,
  802,  803,  686,  776,  804,  594,  563,  625,  747,  805,  717,  532,  656,
  777,  806,  687,  748,  807,  778,  832,  833,  718,  834,  595,  626,  835,
  564,  657,  808,  836,  533,  688,  779,  749,  837,  809,  719,  838,  780,
  627,  596,  658,  750,  810,  839,  864,  565,  689,  865,  866,  867,  534,
  720,  840,  781,  868,  811,  751,  869,  841,  628,  659,  597,  690,  870,
  812,  782,  566,  721,  842,  871,  896,  535,  752,  897,  898,  872,  899,
  813,  843,  660,  900,  783,  629,  691,  598,  722,  901,  873,  567,  753,
  844,  902,  814,  874,  536,  784,  903,  661,  692,  928,  929,  630,  723,
  845,  930,  904,  815,  875,  931,  599,  754,  932,  568,  785,  905,  933,
  846,  876,  934,  537,  816,  693,  662,  724,  906,  631,  755,  935,  877,
  600,  786,  960,  847,  961,  962,  907,  936,  963,  569,  817,  964,  937,
  694,  725,  878,  965,  908,  663,  756,  538,  848,  966,  632,  787,  938,
  601,  818,  967,  909,  879,  992,  939,  993,  968,  570,  849,  994,  726,
  695,  757,  995,  664,  788,  996,  910,  969,  539,  880,  940,  633,  819,
  997,  998,  602,  850,  970,  911,  941,  999,  727,  758,  696,  789,  571,
  881,  971,  665,  820,  1000, 634,  851,  942,  540,  912,  1001, 972,  603,
  882,  759,  728,  790,  1002, 697,  821,  943,  973,  572,  913,  666,  852,
  1003, 635,  883,  974,  541,  944,  760,  791,  1004, 604,  914,  729,  822,
  698,  853,  975,  667,  884,  573,  945,  1005, 636,  915,  792,  761,  823,
  542,  976,  1006, 730,  854,  605,  946,  699,  885,  668,  916,  1007, 574,
  977,  793,  824,  637,  947,  762,  855,  731,  886,  543,  1008, 606,  978,
  700,  917,  669,  948,  575,  825,  1009, 794,  856,  763,  887,  638,  979,
  732,  918,  701,  949,  607,  1010, 670,  980,  826,  857,  795,  888,  764,
  919,  639,  1011, 733,  950,  702,  981,  858,  827,  889,  796,  920,  671,
  1012, 765,  951,  734,  982,  703,  1013, 859,  890,  828,  921,  797,  952,
  766,  983,  735,  1014, 891,  860,  922,  829,  953,  798,  984,  767,  1015,
  892,  923,  861,  954,  830,  985,  799,  1016, 924,  893,  955,  862,  986,
  831,  1017, 925,  956,  894,  987,  863,  1018, 957,  926,  988,  895,  1019,
  958,  989,  927,  1020, 990,  959,  1021, 991,  1022, 1023,
}
Qtr_Scan_32x32[ 1024 ] = {
  0,    1,    32,   33,   2,    64,   34,   65,   66,   3,    96,   35,   97,
  67,   98,   4,    128,  36,   129,  99,   68,   130,  5,    100,  131,  160,
  37,   161,  69,   162,  132,  101,  163,  6,    192,  38,   193,  70,   194,
  133,  164,  102,  195,  7,    224,  39,   165,  225,  134,  196,  71,   226,
  103,  227,  166,  197,  8,    256,  40,   135,  228,  257,  72,   258,  198,
  104,  259,  167,  229,  136,  260,  9,    288,  41,   289,  73,   199,  230,
  290,  168,  261,  105,  291,  137,  292,  231,  10,   200,  262,  320,  42,
  321,  74,   322,  169,  293,  106,  323,  232,  263,  138,  324,  201,  294,
  11,   352,  43,   353,  75,   170,  325,  354,  264,  107,  233,  295,  355,
  202,  326,  139,  356,  12,   384,  44,   265,  296,  385,  171,  357,  76,
  386,  234,  327,  108,  387,  203,  358,  140,  388,  297,  266,  328,  13,
  172,  389,  416,  45,   235,  359,  417,  77,   418,  109,  419,  204,  390,
  298,  329,  141,  267,  360,  420,  236,  391,  173,  421,  14,   448,  46,
  449,  78,   330,  450,  299,  361,  110,  205,  422,  451,  268,  392,  142,
  452,  237,  423,  174,  331,  362,  453,  15,   300,  393,  480,  47,   481,
  79,   482,  206,  454,  269,  424,  111,  483,  143,  484,  363,  332,  394,
  238,  455,  175,  301,  425,  485,  270,  456,  207,  486,  364,  395,  333,
  426,  239,  487,  302,  457,  396,  271,  488,  365,  427,  334,  458,  303,
  489,  397,  428,  366,  459,  335,  490,  429,  398,  460,  367,  491,  430,
  461,  399,  492,  462,  431,  493,  463,  494,  495,  16,   512,  48,   513,
  80,   514,  112,  515,  144,  516,  176,  517,  17,   544,  49,   545,  208,
  518,  81,   546,  113,  547,  145,  240,  519,  548,  177,  549,  272,  520,
  18,   576,  50,   209,  550,  577,  82,   578,  114,  579,  304,  521,  241,
  551,  146,  580,  178,  581,  273,  552,  336,  522,  210,  582,  19,   608,
  51,   609,  83,   610,  115,  305,  553,  611,  242,  583,  147,  368,  523,
  612,  179,  613,  274,  584,  337,  554,  211,  614,  20,   400,  524,  640,
  52,   641,  84,   642,  306,  585,  116,  643,  243,  369,  555,  615,  148,
  644,  338,  586,  180,  275,  432,  525,  616,  645,  401,  556,  212,  646,
  21,   672,  53,   307,  617,  673,  85,   370,  587,  674,  244,  647,  117,
  675,  464,  526,  149,  676,  433,  557,  339,  618,  276,  648,  181,  677,
  402,  588,  213,  678,  308,  496,  527,  649,  371,  619,  22,   704,  54,
  465,  558,  705,  86,   706,  245,  679,  118,  434,  589,  707,  150,  340,
  650,  708,  277,  403,  620,  680,  182,  709,  528,  497,  559,  214,  466,
  590,  710,  372,  651,  309,  681,  23,   736,  55,   435,  621,  737,  87,
  246,  711,  738,  119,  739,  341,  682,  404,  652,  151,  529,  560,  740,
  278,  712,  498,  591,  183,  741,  467,  622,  373,  683,  215,  310,  713,
  742,  436,  653,  24,   768,  56,   769,  247,  561,  743,  88,   530,  592,
  770,  342,  714,  120,  405,  684,  771,  499,  623,  152,  772,  279,  744,
  468,  654,  184,  773,  374,  715,  311,  437,  685,  745,  216,  774,  562,
  593,  531,  624,  25,   248,  500,  655,  775,  800,  57,   801,  406,  716,
  89,   343,  746,  802,  121,  803,  469,  686,  280,  776,  153,  804,  594,
  185,  375,  563,  625,  747,  805,  438,  717,  532,  656,  312,  777,  217,
  806,  501,  687,  407,  748,  249,  807,  26,   344,  778,  832,  58,   833,
  90,   470,  718,  834,  122,  595,  626,  835,  281,  564,  657,  808,  154,
  836,  376,  533,  688,  779,  439,  749,  186,  837,  313,  809,  502,  719,
  218,  838,  408,  780,  627,  596,  658,  250,  345,  471,  750,  810,  839,
  27,   864,  59,   565,  689,  865,  91,   866,  123,  867,  282,  534,  720,
  840,  155,  440,  781,  868,  377,  811,  187,  503,  751,  869,  314,  841,
  628,  659,  219,  597,  690,  870,  409,  812,  472,  782,  566,  721,  346,
  842,  251,  871,  28,   896,  60,   535,  752,  897,  92,   898,  124,  283,
  872,  899,  441,  813,  378,  843,  156,  660,  900,  504,  783,  629,  691,
  598,  722,  188,  901,  315,  873,  567,  753,  220,  410,  844,  902,  473,
  814,  347,  874,  536,  784,  252,  903,  29,   661,  692,  928,  61,   929,
  93,   442,  630,  723,  845,  930,  284,  904,  125,  379,  505,  815,  875,
  931,  599,  754,  157,  932,  316,  568,  785,  905,  189,  933,  474,  846,
  411,  876,  221,  934,  537,  816,  693,  348,  662,  724,  906,  253,  631,
  755,  935,  443,  877,  30,   600,  786,  960,  62,   506,  847,  961,  94,
  962,  285,  380,  907,  936,  126,  963,  569,  817,  158,  964,  317,  937,
  190,  475,  694,  725,  878,  965,  412,  908,  663,  756,  538,  848,  222,
  966,  632,  787,  349,  938,  254,  601,  818,  967,  444,  909,  507,  879,
  31,   992,  63,   381,  939,  993,  286,  968,  95,   570,  849,  994,  726,
  127,  695,  757,  995,  664,  788,  159,  996,  476,  910,  318,  969,  413,
  539,  880,  940,  191,  633,  819,  997,  223,  998,  350,  602,  850,  970,
  508,  911,  255,  445,  941,  999,  727,  758,  696,  789,  571,  881,  382,
  971,  287,  665,  820,  1000, 477,  634,  851,  942,  540,  912,  319,  1001,
  414,  972,  603,  882,  759,  728,  790,  351,  1002, 509,  697,  821,  943,
  446,  973,  572,  913,  666,  852,  383,  1003, 635,  883,  478,  974,  541,
  944,  415,  760,  791,  1004, 604,  914,  729,  822,  698,  853,  510,  975,
  667,  884,  447,  573,  945,  1005, 636,  915,  792,  761,  823,  542,  976,
  479,  1006, 730,  854,  605,  946,  699,  885,  668,  916,  511,  1007, 574,
  977,  793,  824,  637,  947,  762,  855,  731,  886,  543,  1008, 606,  978,
  700,  917,  669,  948,  575,  825,  1009, 794,  856,  763,  887,  638,  979,
  732,  918,  701,  949,  607,  1010, 670,  980,  826,  857,  795,  888,  764,
  919,  639,  1011, 733,  950,  702,  981,  858,  827,  889,  796,  920,  671,
  1012, 765,  951,  734,  982,  703,  1013, 859,  890,  828,  921,  797,  952,
  766,  983,  735,  1014, 891,  860,  922,  829,  953,  798,  984,  767,  1015,
  892,  923,  861,  954,  830,  985,  799,  1016, 924,  893,  955,  862,  986,
  831,  1017, 925,  956,  894,  987,  863,  1018, 957,  926,  988,  895,  1019,
  958,  989,  927,  1020, 990,  959,  1021, 991,  1022, 1023,
}

Conversion Tables

This section defines the constant lookup tables used to convert between different representations.

For a block size x (with values having the same interpretation as for the variable subSize), Mi_Width_Log2[ x ] gives the base 2 logarithm of the width of the block in units of 4 samples.

Mi_Width_Log2[ BLOCK_SIZES ] = {
    0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4,
    4, 4, 5, 5, 0, 2, 1, 3, 2, 4, 3, 5
}

For a block size x, Mi_Height_Log2[ x ] gives the base 2 logarithm of the height of the block in units of 4 samples.

Mi_Height_Log2[ BLOCK_SIZES ] = {
    0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3,
    4, 5, 4, 5, 2, 0, 3, 1, 4, 2, 5, 3,
}

For a block size x, Num_4x4_Blocks_Wide[ x ] gives the width of the block in units of 4 samples.

Num_4x4_Blocks_Wide[ BLOCK_SIZES ] = {
    1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16,
    16, 16, 32, 32, 1, 4, 2, 8, 4, 16, 8, 32,
}

For a block size x, Block_Width[ x ] gives the width of the block in units of samples. Block_Width[ x ] is defined to be equal to 4 * Num_4x4_Blocks_Wide[ x ].

For a block size x, Num_4x4_Blocks_High[ x ] gives the the height of the block in units of 4 samples.

Num_4x4_Blocks_High[ BLOCK_SIZES ] = {
    1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8,
    16, 32, 16, 32, 4, 1, 8, 2, 16, 4, 32, 8,
}

For a block size x, Block_Height[ x ] gives the width of the block in units of samples. Block_Height[ x ] is defined to be equal to 4 * Num_4x4_Blocks_High[ x ].

For a block size x, Num_8x8_Blocks_Wide[ x ] gives the width of the block in units of 8 samples (rounded up).

Num_8x8_Blocks_Wide[ BLOCK_SIZES ] = { 
    1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 8,
    8, 8, 16, 16, 1, 2, 1, 4, 2, 8, 4, 16,
 }

For a block size x, Num_8x8_Blocks_High[ x ] gives the height of the block in units of 8 samples (rounded up).

Num_8x8_Blocks_High[ BLOCK_SIZES ] =
{
    1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 
    16, 8, 16, 2, 1, 4, 1, 8, 2, 16, 4
}

Size_Group is used to map a block size into a context for intra syntax elements.

Size_Group[ BLOCK_SIZES ] = { 
  0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3,
  3, 3, 3, 3, 0, 0, 1, 1, 2, 2, 3, 3,
}

For a luma block size x, Max_Tx_Size[ x ] returns the largest square transform size that can be used for blocks of size x.

Max_Tx_Size[ BLOCK_SIZES ] = {
  TX_4X4, TX_4X4, TX_4X4, TX_8X8,
  TX_8X8, TX_8X8, TX_16X16, TX_16X16,
  TX_16X16, TX_32X32, TX_32X32, TX_32X32,
  TX_32X32, TX_32X32, TX_32X32, TX_32X32,
  TX_4X4, TX_4X4, TX_8X8, TX_8X8,
  TX_16X16, TX_16X16, TX_32X32, TX_32X32
}

For a luma block size x, Max_Tx_Size[ x ] returns the largest transform size that can be used for blocks of size x (this can be either square or rectangular).

Max_Tx_Size_Rect[ BLOCK_SIZES ] = {
  TX_4X4, TX_4X8, TX_8X4, TX_8X8,
  TX_8X16, TX_16X8, TX_16X16, TX_16X32,
  TX_32X16, TX_32X32, TX_32X32, TX_32X32,
  TX_32X32, TX_32X32, TX_32X32, TX_32X32,
  TX_4X8, TX_8X4, TX_8X16, TX_16X8,
  TX_16X32, TX_32X16, TX_32X32, TX_32X32
}

For a square block size x, and a partition type p, Partition_Subsize[ p ][ x ] returns the size of the sub-blocks used by this partition. (If the partition produces blocks of different sizes, then the table contains the largest sub-block size.)

The table will never get accessed for rectangular block sizes, or for a 4x4 block size.

Partition_Subsize[ PARTITION_TYPES ][ BLOCK_SIZES ] = {
  {
                                  BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X8,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X16,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X32,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X64,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X128,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID
  }, {  
                                  BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID
  }, {  
                                  BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID
  }, {  
                                  BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X4,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X8,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X16,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X32,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X64,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID
  }, {  
                                  BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID
  }, {  
                                  BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID
  }, {  
                                  BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID
  }, {  
                                  BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID
  }, {  
                                  BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X4,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X8,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X16,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X32,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID
  }, {  
                                  BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X16,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X32,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X64,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X128,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_INVALID, BLOCK_INVALID
  }
}
Coefband_4x4[ 16 ] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5}
Coefband_4x8_8x4[32] = {
  0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4,
  4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
}
Coefband_8x8_Plus[ 1024 ] = {
    0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4,
    4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
}
Energy_Class[ 12 ] = {0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 5}
Mode_To_Txfm[ MB_MODE_COUNT ] = {
    DCT_DCT, // DC
    ADST_DCT, // V
    DCT_ADST, // H
    DCT_DCT, // D45
    ADST_ADST, // D135
    ADST_DCT, // D117
    DCT_ADST, // D153
    DCT_ADST, // D207
    ADST_DCT, // D63
    ADST_ADST, // SMOOTH
    ADST_DCT,  // SMOOTH_V
    DCT_ADST,  // SMOOTH_H
    ADST_ADST, // TM
    DCT_DCT, // NEARESTMV
    DCT_DCT, // NEARMV
    DCT_DCT, // GLOBALMV
    DCT_DCT // NEWMV
}
Palette_Color_Context[ PALETTE_MAX_COLOR_CONTEXT_HASH + 1 ] =
  { -1, -1, 0, -1, -1, 4,  3,  2, 1 }

Note: The negative numbers in the array Palette_Color_Context indicate values that will never be accessed.

Palette_Color_Hash_Multipliers[ PALETTE_NUM_NEIGHBORS ] = { 1, 2, 2 }
Sm_Weights_Tx_4x4  [  4 ] = { 255, 149,  85,  64 }
Sm_Weights_Tx_8x8  [  8 ] = { 255, 197, 146, 105,  73,  50,  37,  32 }
Sm_Weights_Tx_16x16[ 16 ] = { 255, 225, 196, 170, 145, 123, 102,  84,  68,  54,  43,  33,  26, 20, 17, 16 }
Sm_Weights_Tx_32x32[ 32 ] = { 255, 240, 225, 210, 196, 182, 169, 157, 145, 133, 122, 111, 101, 92, 83, 74,
                              66,  59,  52,  45,  39,  34,  29,  25,  21,  17,  14,  12,  10,  9,  8,  8 }
Mode_To_Angle[ INTRA_MODES ] = { 0, 90, 180, 45, 135, 111, 157, 203, 67, 0, 0, 0, 0 }
Dr_Intra_Derivative[ 90 ] = {
  1, 14666, 7330, 4884, 3660, 2926, 2435, 2084, 1821, 1616, 1451, 1317, 1204,
  1108, 1026, 955, 892, 837, 787, 743, 703, 666, 633, 603, 574, 548,
  524, 502, 481, 461, 443, 426, 409, 394, 379, 365, 352, 339, 327,
  316, 305, 294, 284, 274, 265, 256, 247, 238, 230, 222, 214, 207,
  200, 192, 185, 179, 172, 166, 159, 153, 147, 141, 136, 130, 124,
  119, 113, 108, 103, 98, 93, 88, 83, 78, 73, 68, 63, 59,
  54, 49, 45, 40, 35, 31, 26, 22, 17, 13, 8, 4,
}
Num_Tx_Set[ TX_SET_TYPES ] = { 1, 2, 5, 7, 12, 16 }
Tx_Set_Index_Intra[ TX_SET_TYPES ] = { 0, -1, 2, 1, -1, -1 }
Tx_Set_Index_Inter[ TX_SET_TYPES ] = { 0, 3, -1, -1, 2, 1 }
Uv_Tx_Size[ BLOCK_SIZES ][ TX_SIZES_ALL ][ 2 ][ 2 ] = {
  {
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },  
    { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },  
    { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X8, TX_4X4 } },
    { { TX_8X4, TX_8X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X4 }, { TX_4X8, TX_4X4 } },
    { { TX_8X8, TX_8X4 }, { TX_4X8, TX_4X4 } },
    { { TX_8X8, TX_8X4 }, { TX_4X8, TX_4X4 } },
    { { TX_8X8, TX_8X4 }, { TX_4X8, TX_4X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X16, TX_8X8 }, { TX_4X8, TX_4X8 } },  
    { { TX_8X16, TX_8X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X16, TX_8X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X16, TX_8X8 }, { TX_4X8, TX_4X8 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
    { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
    { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X8, TX_4X4 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_16X8, TX_8X4 }, { TX_8X8, TX_8X4 } },
    { { TX_16X8, TX_8X4 }, { TX_8X8, TX_8X4 } },  
    { { TX_16X8, TX_8X4 }, { TX_8X8, TX_8X4 } },
    { { TX_16X8, TX_8X4 }, { TX_8X8, TX_8X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
    { { TX_16X8, TX_16X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X8 }, { TX_8X16, TX_8X8 } },
    { { TX_16X16, TX_16X8 }, { TX_8X16, TX_8X8 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X32, TX_16X16 }, { TX_8X16, TX_8X16 } },  
    { { TX_16X32, TX_16X16 }, { TX_8X16, TX_8X16 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
    { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
    { { TX_32X16, TX_16X8 }, { TX_16X16, TX_16X8 } },
    { { TX_32X16, TX_16X8 }, { TX_16X16, TX_16X8 } },  
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
    { { TX_32X32, TX_16X16 }, { TX_16X16, TX_16X16 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
    { { TX_16X32, TX_16X16 }, { TX_16X32, TX_16X16 } },
    { { TX_32X16, TX_32X16 }, { TX_16X16, TX_16X16 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
    { { TX_32X32, TX_32X32 }, { TX_16X16, TX_16X16 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
    { { TX_16X32, TX_16X32 }, { TX_16X16, TX_16X16 } },
    { { TX_32X16, TX_32X16 }, { TX_16X16, TX_16X16 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
    { { TX_32X32, TX_16X16 }, { TX_32X32, TX_16X16 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
    { { TX_16X32, TX_16X16 }, { TX_16X32, TX_16X16 } },
    { { TX_32X16, TX_16X16 }, { TX_32X16, TX_16X16 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
    { { TX_32X32, TX_32X32 }, { TX_32X32, TX_32X32 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
    { { TX_16X32, TX_16X32 }, { TX_16X32, TX_16X32 } },
    { { TX_32X16, TX_32X16 }, { TX_32X16, TX_16X16 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
    { { TX_32X32, TX_32X32 }, { TX_32X32, TX_32X32 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
    { { TX_16X32, TX_16X32 }, { TX_16X32, TX_16X32 } },
    { { TX_32X16, TX_32X16 }, { TX_32X16, TX_32X16 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
    { { TX_32X32, TX_32X32 }, { TX_32X32, TX_32X32 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
    { { TX_16X32, TX_16X32 }, { TX_16X32, TX_16X32 } },
    { { TX_32X16, TX_32X16 }, { TX_32X16, TX_32X16 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
    { { TX_32X32, TX_32X32 }, { TX_32X32, TX_32X32 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
    { { TX_16X32, TX_16X32 }, { TX_16X32, TX_16X32 } },
    { { TX_32X16, TX_32X16 }, { TX_32X16, TX_32X16 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X8 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X8 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X8 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X8 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X8 }, { TX_4X4, TX_4X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_8X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_8X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_8X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_8X4, TX_4X4 } },
    { { TX_8X4, TX_4X4 }, { TX_8X4, TX_4X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X16, TX_8X16 }, { TX_4X8, TX_4X8 } },
    { { TX_8X8, TX_8X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X16, TX_8X16 }, { TX_4X8, TX_4X8 } },
    { { TX_8X16, TX_8X16 }, { TX_4X8, TX_4X8 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
    { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
    { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
    { { TX_4X8, TX_4X4 }, { TX_4X8, TX_4X4 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X8, TX_8X4 }, { TX_8X8, TX_8X4 } },
    { { TX_16X8, TX_8X4 }, { TX_16X8, TX_8X4 } },
    { { TX_16X8, TX_8X4 }, { TX_16X8, TX_8X4 } },
    { { TX_16X8, TX_8X4 }, { TX_16X8, TX_8X4 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X32, TX_16X32 }, { TX_8X16, TX_8X16 } },
    { { TX_16X16, TX_16X16 }, { TX_8X16, TX_8X16 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
    { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
    { { TX_16X16, TX_16X8 }, { TX_16X16, TX_16X8 } },
    { { TX_32X16, TX_16X8 }, { TX_32X16, TX_16X8 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
    { { TX_32X32, TX_32X32 }, { TX_16X16, TX_16X16 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
  },
  {
    
    { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
    { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
    { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
    { { TX_32X32, TX_16X16 }, { TX_32X32, TX_16X16 } },
    { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
    { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
    { { TX_8X16, TX_8X16 }, { TX_8X16, TX_8X16 } },
    { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
  },
}

For a transform size t (of width w and height h) (with the same interpretation as for the tx_size syntax element), Tx_Size_Sqr[ t ] returns a square tx size with side length Min( w, h ).

Tx_Size_Sqr[ TX_SIZES_ALL ] = {
    TX_4X4,
    TX_8X8,
    TX_16X16,
    TX_32X32,
    TX_4X4,
    TX_4X4,
    TX_8X8,
    TX_8X8,
    TX_16X16,
    TX_16X16,
}

For a transform size t (of width w and height h), Tx_Size_Sqr_Up[ t ] returns a square tx size with side length Max( w, h ).

Tx_Size_Sqr_Up[ TX_SIZES_ALL ] = {
    TX_4X4,
    TX_8X8,
    TX_16X16,
    TX_32X32,
    TX_8X8,
    TX_8X8,
    TX_16X16,
    TX_16X16,
    TX_32X32,
    TX_32X32,
}

For a transform size t (of width w and height h), Tx_Width[ t ] returns w.

Tx_Width[ TX_SIZES_ALL ] = {
    4,  8, 16, 32, 4,  8, 8,  16, 16, 32
}

For a transform size t (of width w and height h), Tx_Height[ t ] returns h.

Tx_Height[ TX_SIZES_ALL ] = {
    4,  8, 16, 32, 8,  4, 16, 8,  32, 16
}

For a transform size t (of width w and height h), Tx_Width_Log2[ t ] returns the base 2 logarithm of w.

Tx_Width_Log2[ TX_SIZES_ALL ] = {
    2, 3, 4, 5, 2, 3, 3, 4, 4, 5
}

For a transform size t (of width w and height h), Tx_Height_Log2[ t ] returns the base 2 logarithm of h.

Tx_Height_Log2[ TX_SIZES_ALL ] = {
    2, 3, 4, 5, 3, 2, 4, 3, 5, 4
}
Wedge_Bits[ BLOCK_SIZES ] = { 
  0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 0, 0,
  0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0,
 }

Default CDF Tables

This section contains the default values for the cumulative distributions.

Default_Intra_Frame_Y_Mode_Cdf[ INTRA_MODE_CONTEXTS ][ INTRA_MODE_CONTEXTS ][ INTRA_MODES + 1 ] = {
  {
    {
      14208, 17049, 20482,
      21400, 22520, 23261,
      23963, 25010, 25828,
      28398, 29394, 30738,
      32768, 0,
    },
    {
      10496, 18295, 19872,
      20945, 21933, 22818,
      23334, 24033, 24996,
      27652, 29060, 30071,
      32768, 0,
    },
    {
      5120, 6461, 19840, 20310,
      21151, 21506, 22535,
      23900, 24281, 26958,
      27680, 29636, 32768, 0,
    },
    {
      12544, 15177, 17666,
      19855, 21147, 22017,
      22797, 24514, 25779,
      28716, 29772, 31267,
      32768, 0,
    },
    {
      7552, 9909, 11908, 13141,
      18765, 22029, 23872,
      24920, 25674, 29031,
      30244, 31684, 32768, 0,
    },
  },
  {
    {
      3968, 17613, 19125, 19550,
      20305, 21908, 22274,
      22719, 23959, 26970,
      29013, 29843, 32768, 0,
    },
    {
      3072, 21231, 21863, 22306,
      22674, 23414, 23517,
      23798, 24770, 27032,
      29016, 29636, 32768, 0,
    },
    {
      2560, 9825, 15681, 16370,
      17054, 17687, 18236,
      19273, 20311, 24863,
      26825, 28756, 32768, 0,
    },
    {
      6912, 15140, 16485, 18364,
      19181, 20394, 20663,
      22098, 23936, 27555,
      29704, 30849, 32768, 0,
    },
    {
      2944, 13101, 14006, 14974,
      17818, 21093, 21930,
      22566, 24137, 27732,
      29814, 30904, 32768, 0,
    },
  },
  {
    {
      11392, 12961, 20901,
      21544, 22490, 22928,
      23888, 25214, 25777,
      28256, 29102, 30513,
      32768, 0,
    },
    {
      8064, 13595, 18888, 19616,
      20765, 21454, 21990,
      23103, 23980, 26772,
      28070, 29197, 32768, 0,
    },
    {
      4352, 5059, 21705, 22099,
      22703, 22846, 23679,
      25469, 25728, 27919,
      28484, 30215, 32768, 0,
    },
    {
      10752, 12277, 16471,
      18276, 19443, 19917,
      21158, 23881, 24892,
      27709, 28771, 30274,
      32768, 0,
    },
    {
      8320, 10000, 14147, 15330,
      19197, 20923, 22954,
      24541, 25285, 28407,
      29431, 30953, 32768, 0,
    },
  },
  {
    {
      10240, 12819, 15545,
      18248, 19779, 20932,
      21899, 23377, 25448,
      28730, 29936, 31536,
      32768, 0,
  },
    {
      7552, 15309, 16645, 19760,
      20653, 21650, 22221,
      23273, 25509, 28683,
      30153, 31192, 32768, 0,
  },
    {
      5248, 6840, 16129, 17940,
      19069, 19660, 20588,
      22760, 23927, 27538,
      28397, 30725, 32768, 0,
  },
    {
      11008, 11903, 13794,
      21320, 21931, 22310,
      22546, 25375, 27347,
      29800, 30761, 31833,
      32768, 0,
    },
    {
      6272, 8678, 10313, 13073,
      16823, 19980, 21520,
      23242, 25344, 28797,
      30405, 31940, 32768, 0,
    },
  },
  {
    {
      7296, 9304, 11772, 12529,
      18014, 20418, 23076,
      24662, 25549, 29074,
      30392, 31773, 32768, 0,
    },
    {
      7168, 11687, 13541, 14431,
      18214, 20761, 22269,
      23320, 24633, 28339,
      30193, 31268, 32768, 0,
    },
    {
      3584, 4428, 13496, 14189,
      17372, 18617, 20609,
      22615, 23270, 27280,
      28305, 30602, 32768, 0,
    },
    {
      7424, 8834, 10499, 14357,
      17671, 19150, 20460,
      23235, 24391, 28351,
      29843, 31481, 32768, 0,
    },
    {
      4480, 5888, 7093, 7902,
      18290, 22123, 24511,
      25532, 26360, 29653,
      30954, 32215, 32768, 0,
    },
  },
}
Default_Y_Mode_Cdf[ BLOCK_SIZE_GROUPS ][ INTRA_MODES + 1 ] = {
  { 7168, 10680, 13913, 16928,
    20294, 22790, 24706, 26275,
    28139, 29751, 30563, 31468,
    32768, 0, },
  { 11776, 13823, 15307, 15725,
    16638, 17406, 17994, 18814,
    19634, 21513, 22198, 22928,
    32768, 0, },
  { 14720, 16459, 18091, 18299,
    18757, 19125, 19423, 19924,
    20504, 22922, 24063, 25577,
    32768, 0, },
  { 18944, 19925, 20908, 20998,
    21017, 21072, 21084, 21121,
    21159, 22064, 22820, 24290,
    32768, 0, },
}
Default_Uv_Mode_Cdf[ INTRA_MODES ][ INTRA_MODES + 1 ] = {
  { 18377, 18815, 19743, 20178, 20560, 20889, 21359, 22098,
    22481, 24563, 25781, 26662, 28396, 32768, 0 },
  { 5350, 16837, 17066, 17360, 17692, 18778, 18969, 19206,
    20291, 22367, 23212, 24670, 27912, 32768, 0 },
  { 6671, 6759, 17812, 17998, 18260, 18384, 19408, 20667,
    20806, 22760, 24142, 24875, 28072, 32768, 0 },
  { 7461, 8082, 8515, 15013, 15583, 16098, 16522, 18519,
    20348, 22954, 24130, 25342, 26548, 32768, 0 },
  { 3694, 4403, 5370, 5854, 17841, 19639, 21625, 22224,
    22651, 24613, 25399, 26143, 26599, 32768, 0 },
  { 3700, 5651, 6112, 6541, 8929, 20623, 21213, 21640,
    22214, 24306, 25412, 26406, 27249, 32768, 0 },
  { 4649, 4947, 7128, 7432, 9439, 9903, 21163, 21774,
    22056, 24426, 25403, 26324, 27128, 32768, 0 },
  { 7208, 7375, 8779, 9683, 10072, 10284, 10796, 19786,
    20152, 22955, 24246, 25165, 26589, 32768, 0 },
  { 5897, 7283, 7555, 8910, 9391, 9937, 10276, 11044,
    19841, 22620, 23784, 25060, 26418, 32768, 0 },
  { 12171, 12718, 13885, 14348, 14925, 15394, 16108, 17075,
    17583, 21996, 23614, 25048, 27011, 32768, 0 },
  { 10192, 11222, 12318, 12877, 13533, 14184, 14866, 15879,
    16650, 20419, 23265, 24295, 26596, 32768, 0 },
  { 10776, 11387, 12899, 13471, 14088, 14575, 15366, 16456,
    17040, 20815, 22009, 24448, 26492, 32768, 0 },
  { 4015, 6473, 9853, 10285, 10655, 11032, 11431, 12199,
    12738, 14760, 16121, 17263, 28612, 32768, 0 },
}
Default_Partition_W8_Cdf[ PARTITION_CONTEXTS_W8 ][ PARTITION_TYPES_W8 + 1 ] = {
  { 25472, 28949, 31052, 32768, 0 },
  { 18816, 22250, 28783, 32768, 0 },
  { 18944, 26126, 29188, 32768, 0 },
  { 15488, 22508, 27077, 32768, 0 },
}
Default_Partition_Cdf[ PARTITION_CONTEXTS - PARTITION_CONTEXTS_W8 ][ PARTITION_TYPES + 1 ] = {
  { 22272, 23768, 25043, 29996, 30495, 30994, 31419, 31844, 32343, 32768, 0 },
  { 11776, 13457, 16315, 28229, 28789, 29349, 30302, 31255, 31816, 32768, 0 },
  { 10496, 14802, 16136, 27127, 28563, 29999, 30444, 30889, 32324, 32768, 0 },
  { 6784, 8763, 10440, 29110, 29770, 30430, 30989, 31548, 32208, 32768, 0 },
  { 22656, 23801, 24702, 30721, 31103, 31485, 31785, 32085, 32467, 32768, 0 },
  { 8704, 9926, 12586, 28885, 29292, 29699, 30586, 31473, 31881, 32768, 0 },
  { 6656, 10685, 11566, 27857, 29200, 30543, 30837, 31131, 32474, 32768, 0 },
  { 2176, 3012, 3690, 31253, 31532, 31811, 32037, 32263, 32542, 32768, 0 },
  { 28416, 28705, 28926, 32258, 32354, 32450, 32523, 32596, 32693, 32768, 0 },
  { 9216, 9952, 11849, 30134, 30379, 30624, 31256, 31888, 32134, 32768, 0 },
  { 7424, 9008, 9528, 30664, 31192, 31720, 31893, 32066, 32594, 32768, 0 },
  { 1280, 1710, 2069, 31978, 32121, 32264, 32383, 32502, 32647, 32768, 0 },
  { 28416, 28705, 28926, 32258, 32354, 32450, 32523, 32596, 32693, 32768, 0 },
  { 9216, 9952, 11849, 30134, 30379, 30624, 31256, 31888, 32134, 32768, 0 },
  { 7424, 9008, 9528, 30664, 31192, 31720, 31893, 32066, 32594, 32768, 0 },
  { 1280, 1710, 2069, 31978, 32121, 32264, 32383, 32502, 32647, 32768, 0 },
}
Default_Tx_32x32_Cdf[ TX_SIZE_CONTEXTS ][ MAX_TX_DEPTH + 2 ] = {
  { 384, 17588, 19782, 32768, 0 },
  { 640, 7166, 8466, 32768, 0 }
}
Default_Tx_16x16_Cdf[ TX_SIZE_CONTEXTS ][ MAX_TX_DEPTH + 1 ] = {
  { 2560, 20496, 32768, 0 },
  { 1920, 14091, 32768, 0 }
}
Default_Tx_8x8_Cdf[ TX_SIZE_CONTEXTS ][ MAX_TX_DEPTH ] = {
  { 12800, 32768, 0 },
  { 8448, 32768, 0 }
}
Default_Txfm_Split_Cdf[TXFM_PARTITION_CONTEXTS][3] = {
  { 250*128, 32768, 0 }, { 231*128, 32768, 0 },
  { 212*128, 32768, 0 }, { 241*128, 32768, 0 },
  { 166*128, 32768, 0 }, { 66*128, 32768, 0 },
  { 241*128, 32768, 0 }, { 230*128, 32768, 0 },
  { 135*128, 32768, 0 }, { 243*128, 32768, 0 },
  { 154*128, 32768, 0 }, { 64*128, 32768, 0 },
  { 248*128, 32768, 0 }, { 161*128, 32768, 0 },
  {  63*128, 32768, 0 }, { 128*128, 32768, 0 },
}
Default_Segment_Id_Cdf[ MAX_SEGMENTS + 1 ] = {
  4096,  8192,  12288,
  16384, 20480, 24576,
  28672, 32768, 0
}
Default_Segment_Id_Predicted_Cdf[ SEGMENT_ID_PREDICTED_CONTEXTS ][ 3 ] = {
  { 128 * 128, 32768, 0 },
  { 128 * 128, 32768, 0 },
  { 128 * 128, 32768, 0 }
}
Default_Mv_Class0_Hp_Cdf[ 3 ] = {
  160*128, 32768, 0
}
Default_Mv_Hp_Cdf[ 3 ] = {
  128*128, 32768, 0
}
Default_Mv_Bit_Cdf[ MV_BIT_CONTEXTS ][ 3 ] = {
  { 196*128, 32768, 0 },
  { 198*128, 32768, 0 },
  { 208*128, 32768, 0 },
  { 224*128, 32768, 0 },
  { 245*128, 32768, 0 },
  { 240*128, 32768, 0 }
}
Default_Mv_Class0_Bit_Cdf[ 3 ] = {
  216*128, 32768, 0
}
Default_New_Mv_Cdf[ NEW_MV_CONTEXTS ][ 3 ] = {
  { 128 * 155, 32768, 0 },
  { 128 * 116, 32768, 0 },
  { 128 * 94, 32768, 0 },
  { 128 * 32, 32768, 0 },
  { 128 * 96, 32768, 0 },
  { 128 * 56, 32768, 0 },
  { 128 * 30, 32768, 0 }
}
Default_Zero_Mv_Cdf[ ZERO_MV_CONTEXTS ][ 3 ] = {
  {128 * 45, 32768, 0},
  {128 * 13, 32768, 0}
}
Default_Ref_Mv_Cdf[ REF_MV_CONTEXTS ][ 3 ] = {
  {128 * 178, 32768, 0},
  {128 * 212, 32768, 0},
  {128 * 135, 32768, 0},
  {128 * 244, 32768, 0},
  {128 * 203, 32768, 0},
  {128 * 122, 32768, 0},
  {128 * 128, 32768, 0},
  {128 * 128, 32768, 0},
  {128 * 128, 32768, 0}
}
Default_Drl_Mode_Cdf[ DRL_MODE_CONTEXTS ][ 3 ] = {
  {128 * 119, 32768, 0},
  {128 * 128, 32768, 0},
  {128 * 189, 32768, 0},
  {128 * 134, 32768, 0},
  {128 * 128, 32768, 0},
}
Default_Is_Inter_Cdf[ IS_INTER_CONTEXTS ][ 3 ] = {
  { 768, 32768, 0 },
  { 12416, 32768, 0 },
  { 19328, 32768, 0 },
  { 26240, 32768, 0 }
}
Default_Comp_Mode_Cdf[ COMP_INTER_CONTEXTS ][ 3 ] = {
  { 24290, 32768, 0 },
  { 19956, 32768, 0 },
  { 11641, 32768, 0 },
  {  9804, 32768, 0 },
  {  2842, 32768, 0 }
}
Default_Skip_Cdf[ SKIP_CONTEXTS ][ 3 ] = {
  {24576, 32768, 0},
  {16384, 32768, 0},
  {8192, 32768, 0}
}
Default_Comp_Ref_Cdf[ REF_CONTEXTS ][ FWD_REFS - 1 ][ 3 ] = {
  { {  3556, 32768, 0 },
    {  1217, 32768, 0 },
    {   988, 32768, 0 } },
  { {  9857, 32768, 0 },
    {  3394, 32768, 0 },
    {  3303, 32768, 0 } },
  { { 16237, 32768, 0 },
    {  7946, 32768, 0 },
    {  7195, 32768, 0 } },
  { { 23826, 32768, 0 },
    { 16124, 32768, 0 },
    { 20536, 32768, 0 } },
  { { 30195, 32768, 0 },
    { 18344, 32768, 0 },
    { 21980, 32768, 0 } }
}
Default_Comp_Bwd_Ref_Cdf[ REF_CONTEXTS ][ BWD_REFS - 1 ][ 3 ] = {
  { {  2762, 32768, 0 }, {  1614, 32768, 0 } },
  { { 17976, 32768, 0 }, { 15912, 32768, 0 } },
  { { 30894, 32768, 0 }, { 30639, 32768, 0 } },
  { { 32768, 32768, 0 }, { 32768, 32768, 0 } },
  { { 32768, 32768, 0 }, { 32768, 32768, 0 } }
}
Default_Single_Ref_Cdf[ REF_CONTEXTS ][ SINGLE_REFS - 1 ][ 3 ] = {
  { {  4623, 32768, 0 }, {  2110, 32768, 0 }, {  4132, 32768, 0 },
    {  7309, 32768, 0 }, {  1392, 32768, 0 }, {  1781, 32768, 0 } },
  { {  8659, 32768, 0 }, { 16372, 32768, 0 }, {  9371, 32768, 0 },
    { 16322, 32768, 0 }, {  6216, 32768, 0 }, { 15834, 32768, 0 } },
  { { 17353, 32768, 0 }, { 30182, 32768, 0 }, { 16300, 32768, 0 },
    { 21702, 32768, 0 }, { 10365, 32768, 0 }, { 30486, 32768, 0 } },
  { { 32768, 32768, 0 }, { 32768, 32768, 0 }, { 24426, 32768, 0 },
    { 26972, 32768, 0 }, { 14760, 32768, 0 }, { 32768, 32768, 0 } },
  { { 28634, 32768, 0 }, { 32768, 32768, 0 }, { 29425, 32768, 0 },
    { 30969, 32768, 0 }, { 26676, 32768, 0 }, { 32768, 32768, 0 } }
}
Default_Compound_Mode_Cdf[ COMPOUND_MODE_CONTEXTS ][ COMPOUND_MODES + 1 ] = {
  { 19712, 28229, 30892, 31437,
    31712, 32135, 32360, 32768, 0 },
  { 9600, 24804, 29268, 30323,
    30802, 31726, 32177, 32768, 0 },
  { 896, 22434, 27015, 29026,
    29753, 31114, 31597, 32768, 0 },
  { 1024, 15904, 22127, 25421,
    26864, 28996, 30001, 32768, 0 },
  { 512, 11222, 17217, 21445,
    23473, 26133, 27550, 32768, 0 },
  { 2944, 13313, 17214, 20751,
    23211, 25500, 26992, 32768, 0 },
  { 3456, 9067, 14069, 16907,
    18817, 21214, 23139, 32768, 0 }
}
Default_Interp_Filter_Cdf[ INTERP_FILTER_CONTEXTS ][ INTERP_FILTERS + 1 ] = {
  { 32256, 32654, 32768, 0 },
  { 2816, 32651, 32768, 0 },
  { 512, 764, 32768, 0 },
  { 30464, 31778, 32768, 0 },
  { 32384, 32483, 32768, 0 },
  { 3072, 32652, 32768, 0 },
  { 256, 383, 32768, 0 },
  { 25344, 26533, 32768, 0 },
  { 32000, 32531, 32768, 0 },
  { 2048, 32648, 32768, 0 },
  { 384, 890, 32768, 0 },
  { 28928, 31358, 32768, 0 },
  { 31616, 31787, 32768, 0 },
  { 4224, 32433, 32768, 0 },
  { 128, 256, 32768, 0 },
  { 17408, 18248, 32768, 0 }
}
Default_Motion_Mode_Cdf[ BLOCK_SIZES ][ MOTION_MODES + 1 ] = {
  { 16384, 24576, 32768, 0 },
  { 16384, 24576, 32768, 0 },
  { 16384, 24576, 32768, 0 },
  {  7936, 19091, 32768, 0 },
  {  4991, 19205, 32768, 0 },
  {  4992, 19314, 32768, 0 },
  { 15104, 21590, 32768, 0 },
  {  9855, 21043, 32768, 0 },
  { 12800, 22238, 32768, 0 },
  { 24320, 26498, 32768, 0 },
  { 26496, 28995, 32768, 0 },
  { 25216, 28166, 32768, 0 },
  { 30592, 31238, 32768, 0 },
  { 32256, 32656, 32768, 0 },
  { 32256, 32656, 32768, 0 },
  { 32256, 32656, 32768, 0 },
  { 32640, 32740, 32768, 0 },
  { 32640, 32740, 32768, 0 },
  { 32640, 32740, 32768, 0 },
  { 32640, 32740, 32768, 0 },
  { 32640, 32740, 32768, 0 },
  { 32640, 32740, 32768, 0 },
  { 32256, 32656, 32768, 0 },
  { 32256, 32656, 32768, 0 },
}
Default_Mv_Joint_Cdf[ MV_JOINTS + 1 ] = {
  4096, 11264, 19328, 32768, 0
}
Default_Mv_Class_Cdf[ 2 ][ MV_CLASSES + 1 ] = {
  { 28672, 30976, 31858, 32320,
    32551, 32656, 32740, 32757,
    32762, 32767, 32768, 0 },
  { 28672, 30976, 31858, 32320,
    32551, 32656, 32740, 32757,
    32762, 32767, 32768, 0 },
}
Default_Mv_Class0_Fr_Cdf[ 2 ][ CLASS0_SIZE ][ MV_JOINTS + 1 ] = {
  { { 16384, 24576, 26624, 32768, 0 },
    { 12288, 21248, 24128, 32768, 0 } },
  { { 16384, 24576, 26624, 32768, 0 },
    { 12288, 21248, 24128, 32768, 0 } },
}
Default_Mv_Fr_Cdf[ 2 ][ MV_JOINTS + 1 ] = {
  { 8192, 17408, 21248, 32768, 0 },
  { 8192, 17408, 21248, 32768, 0 },
}
Default_Tail_Token_Cdf[ TX_SIZES ][ BLOCK_TYPES ][ REF_TYPES ][ COEF_BANDS ]
                      [ PREV_COEF_CONTEXTS ][ TAIL_TOKENS + 1 ] = {
  {
    {
      {
        {
          { 17389, 25062, 28688, 31459, 32567, 32754, 32766, 32767, 32768, 0 },
          { 15452, 23176, 27234, 30728, 32389, 32738, 32766, 32767, 32768, 0 },
          { 12097, 19397, 23922, 28661, 31696, 32643, 32761, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 24087, 29987, 31740, 32575, 32751, 32765, 32766, 32767, 32768, 0 },
          { 23510, 29658, 31576, 32533, 32747, 32765, 32766, 32767, 32768, 0 },
          { 20556, 27694, 30468, 32188, 32702, 32763, 32766, 32767, 32768, 0 },
          { 16024, 23755, 27695, 30972, 32453, 32744, 32766, 32767, 32768, 0 },
          { 10570, 17456, 22030, 27250, 31081, 32527, 32754, 32767, 32768, 0 },
          { 4899, 8989, 12416, 17728, 24285, 29755, 32238, 32730, 32768, 0 },
        },
        {
          { 26220, 31051, 32221, 32683, 32760, 32765, 32766, 32767, 32768, 0 },
          { 25376, 30659, 32053, 32648, 32757, 32765, 32766, 32767, 32768, 0 },
          { 21234, 28187, 30765, 32290, 32717, 32764, 32766, 32767, 32768, 0 },
          { 15567, 23294, 27329, 30779, 32403, 32740, 32766, 32767, 32768, 0 },
          { 9978, 16666, 21225, 26601, 30762, 32456, 32748, 32767, 32768, 0 },
          { 4652, 8574, 11891, 17100, 23682, 29391, 32135, 32719, 32768, 0 },
        },
        {
          { 27610, 31616, 32440, 32723, 32763, 32765, 32766, 32767, 32768, 0 },
          { 26466, 31159, 32265, 32692, 32761, 32765, 32766, 32767, 32768, 0 },
          { 20783, 27862, 30571, 32225, 32708, 32764, 32766, 32767, 32768, 0 },
          { 13841, 21443, 25778, 29885, 32138, 32709, 32765, 32767, 32768, 0 },
          { 6614, 11763, 15800, 21512, 27518, 31389, 32607, 32761, 32768, 0 },
          { 11980, 19253, 23786, 28565, 31658, 32637, 32761, 32767, 32768, 0 },
        },
        {
          { 29010, 32081, 32597, 32747, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26966, 31367, 32347, 32707, 32762, 32765, 32766, 32767, 32768, 0 },
          { 18069, 25674, 29129, 31658, 32608, 32757, 32766, 32767, 32768, 0 },
          { 11864, 19109, 23649, 28467, 31618, 32630, 32761, 32767, 32768, 0 },
          { 2410, 4622, 6654, 10242, 15874, 22983, 29138, 32089, 32768, 0 },
          { 2410, 4622, 6654, 10242, 15874, 22983, 29138, 32089, 32768, 0 },
        },
        {
          { 28714, 31992, 32569, 32743, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26713, 31263, 32306, 32699, 32761, 32765, 32766, 32767, 32768, 0 },
          { 18296, 25872, 29268, 31718, 32620, 32758, 32766, 32767, 32768, 0 },
          { 14072, 21701, 26002, 30021, 32182, 32714, 32765, 32767, 32768, 0 },
          { 5759, 10404, 14170, 19747, 26096, 30738, 32480, 32752, 32768, 0 },
          { 3785, 7085, 9968, 14706, 21211, 27701, 31556, 32642, 32768, 0 },
        },
      },
      {
        {
          { 25977, 30943, 32176, 32675, 32760, 32765, 32766, 32767, 32768, 0 },
          { 25021, 30483, 31974, 32631, 32756, 32765, 32766, 32767, 32768, 0 },
          { 24552, 30240, 31862, 32605, 32754, 32765, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 30192, 32390, 32685, 32757, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29650, 32258, 32649, 32753, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26098, 30997, 32199, 32679, 32760, 32765, 32766, 32767, 32768, 0 },
          { 19766, 27089, 30086, 32049, 32680, 32762, 32766, 32767, 32768, 0 },
          { 12448, 19823, 24320, 28937, 31803, 32660, 32762, 32767, 32768, 0 },
          { 6614, 11763, 15800, 21512, 27518, 31389, 32607, 32761, 32768, 0 },
        },
        {
          { 30393, 32434, 32696, 32758, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29483, 32214, 32637, 32752, 32764, 32765, 32766, 32767, 32768, 0 },
          { 24087, 29987, 31740, 32575, 32751, 32765, 32766, 32767, 32768, 0 },
          { 16822, 24532, 28294, 31273, 32526, 32751, 32766, 32767, 32768, 0 },
          { 10333, 17142, 21713, 26998, 30960, 32501, 32752, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
        },
        {
          { 30612, 32481, 32708, 32760, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29320, 32169, 32623, 32750, 32764, 32765, 32766, 32767, 32768, 0 },
          { 22255, 28881, 31163, 32416, 32734, 32765, 32766, 32767, 32768, 0 },
          { 12681, 20102, 24578, 29112, 31869, 32671, 32763, 32767, 32768, 0 },
          { 9383, 15850, 20374, 25885, 30385, 32364, 32740, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
        },
        {
          { 30393, 32434, 32696, 32758, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29010, 32081, 32597, 32747, 32764, 32765, 32766, 32767, 32768, 0 },
          { 21573, 28423, 30903, 32335, 32723, 32764, 32766, 32767, 32768, 0 },
          { 15452, 23176, 27234, 30728, 32389, 32738, 32766, 32767, 32768, 0 },
          { 6978, 12329, 16463, 22200, 28032, 31598, 32642, 32763, 32768, 0 },
          { 4281, 7943, 11084, 16113, 22697, 28755, 31936, 32696, 32768, 0 },
        },
        {
          { 30393, 32434, 32696, 32758, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28714, 31992, 32569, 32743, 32764, 32765, 32766, 32767, 32768, 0 },
          { 17617, 25270, 28840, 31529, 32582, 32755, 32766, 32767, 32768, 0 },
          { 9025, 15348, 19839, 25419, 30125, 32295, 32733, 32767, 32768, 0 },
          { 14302, 21954, 26219, 30151, 32222, 32719, 32765, 32767, 32768, 0 },
          { 5268, 9602, 13183, 18626, 25115, 30227, 32362, 32742, 32768, 0 },
        },
      },
    },
    {
      {
        {
          { 27480, 31568, 32423, 32721, 32763, 32765, 32766, 32767, 32768, 0 },
          { 24318, 30114, 31801, 32590, 32752, 32765, 32766, 32767, 32768, 0 },
          { 20443, 27610, 30416, 32170, 32699, 32763, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 28860, 32036, 32583, 32745, 32764, 32765, 32766, 32767, 32768, 0 },
          { 27876, 31713, 32475, 32729, 32763, 32765, 32766, 32767, 32768, 0 },
          { 23625, 29725, 31610, 32542, 32748, 32765, 32766, 32767, 32768, 0 },
          { 19314, 26728, 29851, 31958, 32665, 32761, 32766, 32767, 32768, 0 },
          { 10333, 17142, 21713, 26998, 30960, 32501, 32752, 32767, 32768, 0 },
          { 8547, 14666, 19100, 24755, 29736, 32185, 32722, 32767, 32768, 0 },
        },
        {
          { 29163, 32125, 32610, 32748, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28569, 31946, 32554, 32741, 32764, 32765, 32766, 32767, 32768, 0 },
          { 24087, 29987, 31740, 32575, 32751, 32765, 32766, 32767, 32768, 0 },
          { 15909, 23640, 27605, 30925, 32441, 32743, 32766, 32767, 32768, 0 },
          { 11394, 18521, 23084, 28056, 31446, 32599, 32759, 32767, 32768, 0 },
          { 3286, 6206, 8805, 13189, 19504, 26352, 30985, 32544, 32768, 0 },
        },
        {
          { 29483, 32214, 32637, 32752, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28714, 31992, 32569, 32743, 32764, 32765, 32766, 32767, 32768, 0 },
          { 25021, 30483, 31974, 32631, 32756, 32765, 32766, 32767, 32768, 0 },
          { 19766, 27089, 30086, 32049, 32680, 32762, 32766, 32767, 32768, 0 },
          { 11277, 18372, 22938, 27947, 31398, 32590, 32758, 32767, 32768, 0 },
          { 4775, 8782, 12155, 17417, 23989, 29579, 32189, 32725, 32768, 0 },
        },
        {
          { 30393, 32434, 32696, 32758, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29320, 32169, 32623, 32750, 32764, 32765, 32766, 32767, 32768, 0 },
          { 25735, 30831, 32129, 32665, 32759, 32765, 32766, 32767, 32768, 0 },
          { 18862, 26355, 29601, 31858, 32647, 32760, 32766, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
          { 4652, 8574, 11891, 17100, 23682, 29391, 32135, 32719, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 30002, 32345, 32673, 32756, 32764, 32765, 32766, 32767, 32768, 0 },
          { 24786, 30362, 31919, 32618, 32755, 32765, 32766, 32767, 32768, 0 },
          { 25139, 30542, 32001, 32637, 32757, 32765, 32766, 32767, 32768, 0 },
          { 11746, 18963, 23510, 28367, 31577, 32622, 32760, 32767, 32768, 0 },
          { 5881, 10601, 14409, 20013, 26320, 30848, 32504, 32754, 32768, 0 },
        },
      },
      {
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 30192, 32390, 32685, 32757, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29483, 32214, 32637, 32752, 32764, 32765, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 27350, 31519, 32405, 32718, 32763, 32765, 32766, 32767, 32768, 0 },
          { 19201, 26636, 29790, 31934, 32661, 32761, 32766, 32767, 32768, 0 },
          { 16822, 24532, 28294, 31273, 32526, 32751, 32766, 32767, 32768, 0 },
          { 7099, 12514, 16678, 22419, 28190, 31659, 32651, 32763, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 27876, 31713, 32475, 32729, 32763, 32765, 32766, 32767, 32768, 0 },
          { 24435, 30177, 31832, 32598, 32753, 32765, 32766, 32767, 32768, 0 },
          { 9740, 16342, 20890, 26323, 30619, 32422, 32745, 32767, 32768, 0 },
          { 4899, 8989, 12416, 17728, 24285, 29755, 32238, 32730, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29163, 32125, 32610, 32748, 32764, 32765, 32766, 32767, 32768, 0 },
          { 16594, 24314, 28128, 31191, 32506, 32749, 32766, 32767, 32768, 0 },
          { 10452, 17300, 21873, 27126, 31022, 32514, 32753, 32767, 32768, 0 },
          { 5881, 10601, 14409, 20013, 26320, 30848, 32504, 32754, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 14993, 22698, 26844, 30513, 32330, 32732, 32766, 32767, 32768, 0 },
          { 10333, 17142, 21713, 26998, 30960, 32501, 32752, 32767, 32768, 0 },
          { 6492, 11572, 15574, 21274, 27335, 31311, 32593, 32760, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 21801, 28579, 30993, 32364, 32727, 32765, 32766, 32767, 32768, 0 },
          { 16480, 24203, 28043, 31149, 32496, 32748, 32766, 32767, 32768, 0 },
          { 12797, 20240, 24704, 29196, 31900, 32675, 32763, 32767, 32768, 0 },
          { 7584, 13249, 17521, 23260, 28778, 31875, 32683, 32765, 32768, 0 },
        },
      },
    },
  },
  {
    {
      {
        {
          { 19088, 26543, 29728, 31910, 32657, 32761, 32766, 32767, 32768, 0 },
          { 14418, 22081, 26327, 30215, 32242, 32722, 32766, 32767, 32768, 0 },
          { 8426, 14492, 18910, 24581, 29630, 32153, 32718, 32766, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 20670, 27779, 30520, 32207, 32705, 32763, 32766, 32767, 32768, 0 },
          { 20443, 27610, 30416, 32170, 32699, 32763, 32766, 32767, 32768, 0 },
          { 17843, 25473, 28986, 31594, 32595, 32756, 32766, 32767, 32768, 0 },
          { 14418, 22081, 26327, 30215, 32242, 32722, 32766, 32767, 32768, 0 },
          { 9383, 15850, 20374, 25885, 30385, 32364, 32740, 32767, 32768, 0 },
          { 3909, 7301, 10251, 15068, 21602, 27989, 31666, 32659, 32768, 0 },
        },
        {
          { 23855, 29857, 31676, 32559, 32749, 32765, 32766, 32767, 32768, 0 },
          { 22595, 29100, 31283, 32452, 32738, 32765, 32766, 32767, 32768, 0 },
          { 19088, 26543, 29728, 31910, 32657, 32761, 32766, 32767, 32768, 0 },
          { 14763, 22453, 26640, 30397, 32296, 32728, 32766, 32767, 32768, 0 },
          { 10096, 16825, 21389, 26736, 30830, 32471, 32749, 32767, 32768, 0 },
          { 4899, 8989, 12416, 17728, 24285, 29755, 32238, 32730, 32768, 0 },
        },
        {
          { 25376, 30659, 32053, 32648, 32757, 32765, 32766, 32767, 32768, 0 },
          { 23625, 29725, 31610, 32542, 32748, 32765, 32766, 32767, 32768, 0 },
          { 18636, 26165, 29471, 31804, 32637, 32759, 32766, 32767, 32768, 0 },
          { 13262, 20784, 25196, 29518, 32015, 32692, 32764, 32767, 32768, 0 },
          { 7945, 13788, 18129, 23848, 29168, 32008, 32701, 32766, 32768, 0 },
          { 3286, 6206, 8805, 13189, 19504, 26352, 30985, 32544, 32768, 0 },
        },
        {
          { 27220, 31468, 32386, 32714, 32762, 32765, 32766, 32767, 32768, 0 },
          { 25021, 30483, 31974, 32631, 32756, 32765, 32766, 32767, 32768, 0 },
          { 19088, 26543, 29728, 31910, 32657, 32761, 32766, 32767, 32768, 0 },
          { 13262, 20784, 25196, 29518, 32015, 32692, 32764, 32767, 32768, 0 },
          { 7221, 12700, 16892, 22635, 28344, 31717, 32660, 32764, 32768, 0 },
          { 2535, 4852, 6971, 10688, 16449, 23562, 29498, 32193, 32768, 0 },
        },
        {
          { 28860, 32036, 32583, 32745, 32764, 32765, 32766, 32767, 32768, 0 },
          { 25977, 30943, 32176, 32675, 32760, 32765, 32766, 32767, 32768, 0 },
          { 18296, 25872, 29268, 31718, 32620, 32758, 32766, 32767, 32768, 0 },
          { 11864, 19109, 23649, 28467, 31618, 32630, 32761, 32767, 32768, 0 },
          { 6857, 12141, 16244, 21975, 27866, 31532, 32631, 32762, 32768, 0 },
          { 2284, 4390, 6334, 9789, 15279, 22366, 28736, 31965, 32768, 0 },
        },
      },
      {
        {
          { 26466, 31159, 32265, 32692, 32761, 32765, 32766, 32767, 32768, 0 },
          { 24203, 30051, 31771, 32583, 32752, 32765, 32766, 32767, 32768, 0 },
          { 21914, 28655, 31036, 32377, 32729, 32765, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 29483, 32214, 32637, 32752, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28860, 32036, 32583, 32745, 32764, 32765, 32766, 32767, 32768, 0 },
          { 25977, 30943, 32176, 32675, 32760, 32765, 32766, 32767, 32768, 0 },
          { 21460, 28345, 30858, 32320, 32721, 32764, 32766, 32767, 32768, 0 },
          { 15223, 22938, 27041, 30622, 32360, 32735, 32766, 32767, 32768, 0 },
          { 10452, 17300, 21873, 27126, 31022, 32514, 32753, 32767, 32768, 0 },
        },
        {
          { 30192, 32390, 32685, 32757, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29010, 32081, 32597, 32747, 32764, 32765, 32766, 32767, 32768, 0 },
          { 25258, 30601, 32028, 32643, 32757, 32765, 32766, 32767, 32768, 0 },
          { 20331, 27526, 30364, 32152, 32697, 32763, 32766, 32767, 32768, 0 },
          { 13957, 21573, 25891, 29954, 32161, 32712, 32765, 32767, 32768, 0 },
          { 9383, 15850, 20374, 25885, 30385, 32364, 32740, 32767, 32768, 0 },
        },
        {
          { 30612, 32481, 32708, 32760, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29650, 32258, 32649, 32753, 32764, 32765, 32766, 32767, 32768, 0 },
          { 25614, 30773, 32103, 32659, 32758, 32765, 32766, 32767, 32768, 0 },
          { 19201, 26636, 29790, 31934, 32661, 32761, 32766, 32767, 32768, 0 },
          { 12215, 19541, 24057, 28755, 31733, 32649, 32762, 32767, 32768, 0 },
          { 4281, 7943, 11084, 16113, 22697, 28755, 31936, 32696, 32768, 0 },
        },
        {
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 30393, 32434, 32696, 32758, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26966, 31367, 32347, 32707, 32762, 32765, 32766, 32767, 32768, 0 },
          { 19991, 27265, 30199, 32091, 32687, 32762, 32766, 32767, 32768, 0 },
          { 12448, 19823, 24320, 28937, 31803, 32660, 32762, 32767, 32768, 0 },
          { 4281, 7943, 11084, 16113, 22697, 28755, 31936, 32696, 32768, 0 },
        },
        {
          { 30853, 32529, 32720, 32761, 32764, 32765, 32766, 32767, 32768, 0 },
          { 30192, 32390, 32685, 32757, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28147, 31806, 32507, 32734, 32764, 32765, 32766, 32767, 32768, 0 },
          { 16024, 23755, 27695, 30972, 32453, 32744, 32766, 32767, 32768, 0 },
          { 10452, 17300, 21873, 27126, 31022, 32514, 32753, 32767, 32768, 0 },
          { 5268, 9602, 13183, 18626, 25115, 30227, 32362, 32742, 32768, 0 },
        },
      },
    },
    {
      {
        {
          { 28286, 31854, 32524, 32737, 32764, 32765, 32766, 32767, 32768, 0 },
          { 23855, 29857, 31676, 32559, 32749, 32765, 32766, 32767, 32768, 0 },
          { 17389, 25062, 28688, 31459, 32567, 32754, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 27610, 31616, 32440, 32723, 32763, 32765, 32766, 32767, 32768, 0 },
          { 26840, 31316, 32328, 32704, 32762, 32765, 32766, 32767, 32768, 0 },
          { 23510, 29658, 31576, 32533, 32747, 32765, 32766, 32767, 32768, 0 },
          { 18636, 26165, 29471, 31804, 32637, 32759, 32766, 32767, 32768, 0 },
          { 11041, 18070, 22642, 27724, 31300, 32571, 32757, 32767, 32768, 0 },
          { 4157, 7730, 10809, 15771, 22344, 28514, 31854, 32685, 32768, 0 },
        },
        {
          { 27610, 31616, 32440, 32723, 32763, 32765, 32766, 32767, 32768, 0 },
          { 26466, 31159, 32265, 32692, 32761, 32765, 32766, 32767, 32768, 0 },
          { 22141, 28806, 31121, 32403, 32732, 32765, 32766, 32767, 32768, 0 },
          { 16594, 24314, 28128, 31191, 32506, 32749, 32766, 32767, 32768, 0 },
          { 10688, 17611, 22186, 27372, 31139, 32539, 32755, 32767, 32768, 0 },
          { 5759, 10404, 14170, 19747, 26096, 30738, 32480, 32752, 32768, 0 },
        },
        {
          { 28426, 31900, 32539, 32739, 32764, 32765, 32766, 32767, 32768, 0 },
          { 27092, 31417, 32366, 32710, 32762, 32765, 32766, 32767, 32768, 0 },
          { 21687, 28502, 30949, 32350, 32725, 32764, 32766, 32767, 32768, 0 },
          { 16252, 23980, 27871, 31062, 32475, 32746, 32766, 32767, 32768, 0 },
          { 17050, 24747, 28455, 31350, 32543, 32752, 32766, 32767, 32768, 0 },
          { 12448, 19823, 24320, 28937, 31803, 32660, 32762, 32767, 32768, 0 },
        },
        {
          { 29010, 32081, 32597, 32747, 32764, 32765, 32766, 32767, 32768, 0 },
          { 27610, 31616, 32440, 32723, 32763, 32765, 32766, 32767, 32768, 0 },
          { 22595, 29100, 31283, 32452, 32738, 32765, 32766, 32767, 32768, 0 },
          { 13957, 21573, 25891, 29954, 32161, 32712, 32765, 32767, 32768, 0 },
          { 11980, 19253, 23786, 28565, 31658, 32637, 32761, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
        },
        {
          { 30002, 32345, 32673, 32756, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28286, 31854, 32524, 32737, 32764, 32765, 32766, 32767, 32768, 0 },
          { 22141, 28806, 31121, 32403, 32732, 32765, 32766, 32767, 32768, 0 },
          { 15795, 23525, 27514, 30878, 32429, 32742, 32766, 32767, 32768, 0 },
          { 18410, 25972, 29338, 31749, 32627, 32759, 32766, 32767, 32768, 0 },
          { 5881, 10601, 14409, 20013, 26320, 30848, 32504, 32754, 32768, 0 },
        },
      },
      {
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 30853, 32529, 32720, 32761, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29823, 32302, 32662, 32755, 32764, 32765, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 30002, 32345, 32673, 32756, 32764, 32765, 32766, 32767, 32768, 0 },
          { 22028, 28732, 31080, 32391, 32731, 32765, 32766, 32767, 32768, 0 },
          { 17050, 24747, 28455, 31350, 32543, 32752, 32766, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 27350, 31519, 32405, 32718, 32763, 32765, 32766, 32767, 32768, 0 },
          { 24203, 30051, 31771, 32583, 32752, 32765, 32766, 32767, 32768, 0 },
          { 15452, 23176, 27234, 30728, 32389, 32738, 32766, 32767, 32768, 0 },
          { 4899, 8989, 12416, 17728, 24285, 29755, 32238, 32730, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28714, 31992, 32569, 32743, 32764, 32765, 32766, 32767, 32768, 0 },
          { 15452, 23176, 27234, 30728, 32389, 32738, 32766, 32767, 32768, 0 },
          { 10452, 17300, 21873, 27126, 31022, 32514, 32753, 32767, 32768, 0 },
          { 5881, 10601, 14409, 20013, 26320, 30848, 32504, 32754, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 30192, 32390, 32685, 32757, 32764, 32765, 32766, 32767, 32768, 0 },
          { 15681, 23410, 27422, 30829, 32416, 32741, 32766, 32767, 32768, 0 },
          { 10333, 17142, 21713, 26998, 30960, 32501, 32752, 32767, 32768, 0 },
          { 6492, 11572, 15574, 21274, 27335, 31311, 32593, 32760, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 24203, 30051, 31771, 32583, 32752, 32765, 32766, 32767, 32768, 0 },
          { 16480, 24203, 28043, 31149, 32496, 32748, 32766, 32767, 32768, 0 },
          { 12797, 20240, 24704, 29196, 31900, 32675, 32763, 32767, 32768, 0 },
          { 7584, 13249, 17521, 23260, 28778, 31875, 32683, 32765, 32768, 0 },
        },
      },
    },
  },
  {
    {
      {
        {
          { 14188, 21829, 26112, 30088, 32203, 32717, 32765, 32767, 32768, 0 },
          { 10924, 17918, 22492, 27609, 31248, 32561, 32756, 32767, 32768, 0 },
          { 6004, 10798, 14647, 20275, 26537, 30951, 32524, 32755, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 18069, 25674, 29129, 31658, 32608, 32757, 32766, 32767, 32768, 0 },
          { 17730, 25372, 28913, 31562, 32589, 32756, 32766, 32767, 32768, 0 },
          { 16024, 23755, 27695, 30972, 32453, 32744, 32766, 32767, 32768, 0 },
          { 12914, 20378, 24830, 29280, 31931, 32680, 32764, 32767, 32768, 0 },
          { 8906, 15180, 19658, 25258, 30033, 32270, 32731, 32767, 32768, 0 },
          { 4033, 7516, 10531, 15422, 21979, 28260, 31765, 32673, 32768, 0 },
        },
        {
          { 21573, 28423, 30903, 32335, 32723, 32764, 32766, 32767, 32768, 0 },
          { 20670, 27779, 30520, 32207, 32705, 32763, 32766, 32767, 32768, 0 },
          { 17504, 25167, 28765, 31495, 32575, 32755, 32766, 32767, 32768, 0 },
          { 14072, 21701, 26002, 30021, 32182, 32714, 32765, 32767, 32768, 0 },
          { 10096, 16825, 21389, 26736, 30830, 32471, 32749, 32767, 32768, 0 },
          { 4652, 8574, 11891, 17100, 23682, 29391, 32135, 32719, 32768, 0 },
        },
        {
          { 23971, 29922, 31708, 32567, 32750, 32765, 32766, 32767, 32768, 0 },
          { 22141, 28806, 31121, 32403, 32732, 32765, 32766, 32767, 32768, 0 },
          { 17389, 25062, 28688, 31459, 32567, 32754, 32766, 32767, 32768, 0 },
          { 12215, 19541, 24057, 28755, 31733, 32649, 32762, 32767, 32768, 0 },
          { 6978, 12329, 16463, 22200, 28032, 31598, 32642, 32763, 32768, 0 },
          { 3162, 5984, 8507, 12791, 19038, 25957, 30799, 32507, 32768, 0 },
        },
        {
          { 25977, 30943, 32176, 32675, 32760, 32765, 32766, 32767, 32768, 0 },
          { 23280, 29522, 31506, 32514, 32745, 32765, 32766, 32767, 32768, 0 },
          { 17050, 24747, 28455, 31350, 32543, 32752, 32766, 32767, 32768, 0 },
          { 11629, 18817, 23370, 28266, 31535, 32615, 32760, 32767, 32768, 0 },
          { 6978, 12329, 16463, 22200, 28032, 31598, 32642, 32763, 32768, 0 },
          { 3286, 6206, 8805, 13189, 19504, 26352, 30985, 32544, 32768, 0 },
        },
        {
          { 28569, 31946, 32554, 32741, 32764, 32765, 32766, 32767, 32768, 0 },
          { 25376, 30659, 32053, 32648, 32757, 32765, 32766, 32767, 32768, 0 },
          { 17843, 25473, 28986, 31594, 32595, 32756, 32766, 32767, 32768, 0 },
          { 12215, 19541, 24057, 28755, 31733, 32649, 32762, 32767, 32768, 0 },
          { 7584, 13249, 17521, 23260, 28778, 31875, 32683, 32765, 32768, 0 },
          { 3536, 6648, 9393, 13962, 20388, 27069, 31301, 32601, 32768, 0 },
        },
      },
      {
        {
          { 25376, 30659, 32053, 32648, 32757, 32765, 32766, 32767, 32768, 0 },
          { 22141, 28806, 31121, 32403, 32732, 32765, 32766, 32767, 32768, 0 },
          { 19201, 26636, 29790, 31934, 32661, 32761, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 28011, 31760, 32491, 32731, 32763, 32765, 32766, 32767, 32768, 0 },
          { 27610, 31616, 32440, 32723, 32763, 32765, 32766, 32767, 32768, 0 },
          { 25258, 30601, 32028, 32643, 32757, 32765, 32766, 32767, 32768, 0 },
          { 21573, 28423, 30903, 32335, 32723, 32764, 32766, 32767, 32768, 0 },
          { 15223, 22938, 27041, 30622, 32360, 32735, 32766, 32767, 32768, 0 },
          { 8186, 14142, 18523, 24221, 29406, 32084, 32710, 32766, 32768, 0 },
        },
        {
          { 28860, 32036, 32583, 32745, 32764, 32765, 32766, 32767, 32768, 0 },
          { 27743, 31665, 32458, 32726, 32763, 32765, 32766, 32767, 32768, 0 },
          { 24087, 29987, 31740, 32575, 32751, 32765, 32766, 32767, 32768, 0 },
          { 19654, 27001, 30030, 32028, 32677, 32762, 32766, 32767, 32768, 0 },
          { 13610, 21183, 25551, 29744, 32092, 32703, 32765, 32767, 32768, 0 },
          { 6857, 12141, 16244, 21975, 27866, 31532, 32631, 32762, 32768, 0 },
        },
        {
          { 29823, 32302, 32662, 32755, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28426, 31900, 32539, 32739, 32764, 32765, 32766, 32767, 32768, 0 },
          { 24087, 29987, 31740, 32575, 32751, 32765, 32766, 32767, 32768, 0 },
          { 18975, 26449, 29664, 31883, 32651, 32760, 32766, 32767, 32768, 0 },
          { 12448, 19823, 24320, 28937, 31803, 32660, 32762, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
        },
        {
          { 30612, 32481, 32708, 32760, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29320, 32169, 32623, 32750, 32764, 32765, 32766, 32767, 32768, 0 },
          { 25258, 30601, 32028, 32643, 32757, 32765, 32766, 32767, 32768, 0 },
          { 20218, 27440, 30310, 32132, 32694, 32763, 32766, 32767, 32768, 0 },
          { 15681, 23410, 27422, 30829, 32416, 32741, 32766, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
        },
        {
          { 30853, 32529, 32720, 32761, 32764, 32765, 32766, 32767, 32768, 0 },
          { 30192, 32390, 32685, 32757, 32764, 32765, 32766, 32767, 32768, 0 },
          { 25496, 30717, 32079, 32654, 32758, 32765, 32766, 32767, 32768, 0 },
          { 19766, 27089, 30086, 32049, 32680, 32762, 32766, 32767, 32768, 0 },
          { 13494, 21050, 25433, 29670, 32067, 32699, 32764, 32767, 32768, 0 },
          { 5268, 9602, 13183, 18626, 25115, 30227, 32362, 32742, 32768, 0 },
        },
      },
    },
    {
      {
        {
          { 28011, 31760, 32491, 32731, 32763, 32765, 32766, 32767, 32768, 0 },
          { 22823, 29243, 31359, 32473, 32740, 32765, 32766, 32767, 32768, 0 },
          { 14993, 22698, 26844, 30513, 32330, 32732, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 26098, 30997, 32199, 32679, 32760, 32765, 32766, 32767, 32768, 0 },
          { 25376, 30659, 32053, 32648, 32757, 32765, 32766, 32767, 32768, 0 },
          { 22141, 28806, 31121, 32403, 32732, 32765, 32766, 32767, 32768, 0 },
          { 18862, 26355, 29601, 31858, 32647, 32760, 32766, 32767, 32768, 0 },
          { 13610, 21183, 25551, 29744, 32092, 32703, 32765, 32767, 32768, 0 },
          { 8666, 14837, 19287, 24925, 29837, 32214, 32725, 32767, 32768, 0 },
        },
        {
          { 26343, 31106, 32244, 32688, 32761, 32765, 32766, 32767, 32768, 0 },
          { 24087, 29987, 31740, 32575, 32751, 32765, 32766, 32767, 32768, 0 },
          { 20556, 27694, 30468, 32188, 32702, 32763, 32766, 32767, 32768, 0 },
          { 15795, 23525, 27514, 30878, 32429, 32742, 32766, 32767, 32768, 0 },
          { 10096, 16825, 21389, 26736, 30830, 32471, 32749, 32767, 32768, 0 },
          { 11159, 18221, 22791, 27837, 31350, 32581, 32758, 32767, 32768, 0 },
        },
        {
          { 26966, 31367, 32347, 32707, 32762, 32765, 32766, 32767, 32768, 0 },
          { 24318, 30114, 31801, 32590, 32752, 32765, 32766, 32767, 32768, 0 },
          { 19878, 27177, 30143, 32070, 32683, 32762, 32766, 32767, 32768, 0 },
          { 14763, 22453, 26640, 30397, 32296, 32728, 32766, 32767, 32768, 0 },
          { 10688, 17611, 22186, 27372, 31139, 32539, 32755, 32767, 32768, 0 },
          { 6370, 11380, 15346, 21032, 27146, 31229, 32578, 32759, 32768, 0 },
        },
        {
          { 27743, 31665, 32458, 32726, 32763, 32765, 32766, 32767, 32768, 0 },
          { 25496, 30717, 32079, 32654, 32758, 32765, 32766, 32767, 32768, 0 },
          { 19427, 26819, 29911, 31982, 32669, 32761, 32766, 32767, 32768, 0 },
          { 15567, 23294, 27329, 30779, 32403, 32740, 32766, 32767, 32768, 0 },
          { 6248, 11187, 15115, 20784, 26950, 31142, 32562, 32758, 32768, 0 },
          { 3536, 6648, 9393, 13962, 20388, 27069, 31301, 32601, 32768, 0 },
        },
        {
          { 28860, 32036, 32583, 32745, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26466, 31159, 32265, 32692, 32761, 32765, 32766, 32767, 32768, 0 },
          { 20443, 27610, 30416, 32170, 32699, 32763, 32766, 32767, 32768, 0 },
          { 16936, 24640, 28375, 31312, 32535, 32752, 32766, 32767, 32768, 0 },
          { 9740, 16342, 20890, 26323, 30619, 32422, 32745, 32767, 32768, 0 },
          { 7945, 13788, 18129, 23848, 29168, 32008, 32701, 32766, 32768, 0 },
        },
      },
      {
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28714, 31992, 32569, 32743, 32764, 32765, 32766, 32767, 32768, 0 },
          { 27092, 31417, 32366, 32710, 32762, 32765, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29650, 32258, 32649, 32753, 32764, 32765, 32766, 32767, 32768, 0 },
          { 22141, 28806, 31121, 32403, 32732, 32765, 32766, 32767, 32768, 0 },
          { 14993, 22698, 26844, 30513, 32330, 32732, 32766, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
        },
        {
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26098, 30997, 32199, 32679, 32760, 32765, 32766, 32767, 32768, 0 },
          { 15452, 23176, 27234, 30728, 32389, 32738, 32766, 32767, 32768, 0 },
          { 13378, 20917, 25315, 29595, 32042, 32696, 32764, 32767, 32768, 0 },
          { 4899, 8989, 12416, 17728, 24285, 29755, 32238, 32730, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 23971, 29922, 31708, 32567, 32750, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 10452, 17300, 21873, 27126, 31022, 32514, 32753, 32767, 32768, 0 },
          { 5881, 10601, 14409, 20013, 26320, 30848, 32504, 32754, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26589, 31211, 32286, 32696, 32761, 32765, 32766, 32767, 32768, 0 },
          { 14993, 22698, 26844, 30513, 32330, 32732, 32766, 32767, 32768, 0 },
          { 10333, 17142, 21713, 26998, 30960, 32501, 32752, 32767, 32768, 0 },
          { 6492, 11572, 15574, 21274, 27335, 31311, 32593, 32760, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28286, 31854, 32524, 32737, 32764, 32765, 32766, 32767, 32768, 0 },
          { 16594, 24314, 28128, 31191, 32506, 32749, 32766, 32767, 32768, 0 },
          { 12797, 20240, 24704, 29196, 31900, 32675, 32763, 32767, 32768, 0 },
          { 7584, 13249, 17521, 23260, 28778, 31875, 32683, 32765, 32768, 0 },
        },
      },
    },
  },
  {
    {
      {
        {
          { 22255, 28881, 31163, 32416, 32734, 32765, 32766, 32767, 32768, 0 },
          { 12797, 20240, 24704, 29196, 31900, 32675, 32763, 32767, 32768, 0 },
          { 6004, 10798, 14647, 20275, 26537, 30951, 32524, 32755, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 19991, 27265, 30199, 32091, 32687, 32762, 32766, 32767, 32768, 0 },
          { 20218, 27440, 30310, 32132, 32694, 32763, 32766, 32767, 32768, 0 },
          { 18069, 25674, 29129, 31658, 32608, 32757, 32766, 32767, 32768, 0 },
          { 13610, 21183, 25551, 29744, 32092, 32703, 32765, 32767, 32768, 0 },
          { 7825, 13609, 17927, 23654, 29040, 31964, 32694, 32765, 32768, 0 },
          { 2911, 5535, 7902, 11974, 18057, 25090, 30363, 32413, 32768, 0 },
        },
        {
          { 21573, 28423, 30903, 32335, 32723, 32764, 32766, 32767, 32768, 0 },
          { 21008, 28025, 30669, 32258, 32713, 32764, 32766, 32767, 32768, 0 },
          { 18296, 25872, 29268, 31718, 32620, 32758, 32766, 32767, 32768, 0 },
          { 13841, 21443, 25778, 29885, 32138, 32709, 32765, 32767, 32768, 0 },
          { 8786, 15009, 19474, 25094, 29937, 32243, 32728, 32767, 32768, 0 },
          { 3411, 6428, 9100, 13578, 19952, 26720, 31150, 32574, 32768, 0 },
        },
        {
          { 25139, 30542, 32001, 32637, 32757, 32765, 32766, 32767, 32768, 0 },
          { 22823, 29243, 31359, 32473, 32740, 32765, 32766, 32767, 32768, 0 },
          { 16936, 24640, 28375, 31312, 32535, 32752, 32766, 32767, 32768, 0 },
          { 11394, 18521, 23084, 28056, 31446, 32599, 32759, 32767, 32768, 0 },
          { 6004, 10798, 14647, 20275, 26537, 30951, 32524, 32755, 32768, 0 },
          { 2410, 4622, 6654, 10242, 15874, 22983, 29138, 32089, 32768, 0 },
        },
        {
          { 25977, 30943, 32176, 32675, 32760, 32765, 32766, 32767, 32768, 0 },
          { 23510, 29658, 31576, 32533, 32747, 32765, 32766, 32767, 32768, 0 },
          { 16366, 24092, 27958, 31106, 32486, 32747, 32766, 32767, 32768, 0 },
          { 10570, 17456, 22030, 27250, 31081, 32527, 32754, 32767, 32768, 0 },
          { 5881, 10601, 14409, 20013, 26320, 30848, 32504, 32754, 32768, 0 },
          { 3037, 5761, 8207, 12387, 18557, 25538, 30593, 32464, 32768, 0 },
        },
        {
          { 28147, 31806, 32507, 32734, 32764, 32765, 32766, 32767, 32768, 0 },
          { 23625, 29725, 31610, 32542, 32748, 32765, 32766, 32767, 32768, 0 },
          { 15223, 22938, 27041, 30622, 32360, 32735, 32766, 32767, 32768, 0 },
          { 9740, 16342, 20890, 26323, 30619, 32422, 32745, 32767, 32768, 0 },
          { 5881, 10601, 14409, 20013, 26320, 30848, 32504, 32754, 32768, 0 },
          { 3162, 5984, 8507, 12791, 19038, 25957, 30799, 32507, 32768, 0 },
        },
      },
      {
        {
          { 26840, 31316, 32328, 32704, 32762, 32765, 32766, 32767, 32768, 0 },
          { 22141, 28806, 31121, 32403, 32732, 32765, 32766, 32767, 32768, 0 },
          { 17276, 24958, 28612, 31424, 32560, 32754, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 26840, 31316, 32328, 32704, 32762, 32765, 32766, 32767, 32768, 0 },
          { 27480, 31568, 32423, 32721, 32763, 32765, 32766, 32767, 32768, 0 },
          { 26220, 31051, 32221, 32683, 32760, 32765, 32766, 32767, 32768, 0 },
          { 23741, 29792, 31644, 32551, 32749, 32765, 32766, 32767, 32768, 0 },
          { 17957, 25575, 29059, 31628, 32603, 32757, 32766, 32767, 32768, 0 },
          { 11980, 19253, 23786, 28565, 31658, 32637, 32761, 32767, 32768, 0 },
        },
        {
          { 28147, 31806, 32507, 32734, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26840, 31316, 32328, 32704, 32762, 32765, 32766, 32767, 32768, 0 },
          { 22482, 29028, 31244, 32440, 32737, 32765, 32766, 32767, 32768, 0 },
          { 16822, 24532, 28294, 31273, 32526, 32751, 32766, 32767, 32768, 0 },
          { 11041, 18070, 22642, 27724, 31300, 32571, 32757, 32767, 32768, 0 },
          { 5022, 9195, 12675, 18034, 24572, 29923, 32284, 32735, 32768, 0 },
        },
        {
          { 28286, 31854, 32524, 32737, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26589, 31211, 32286, 32696, 32761, 32765, 32766, 32767, 32768, 0 },
          { 21347, 28266, 30811, 32305, 32719, 32764, 32766, 32767, 32768, 0 },
          { 15109, 22820, 26944, 30569, 32346, 32734, 32766, 32767, 32768, 0 },
          { 11512, 18670, 23228, 28162, 31491, 32607, 32759, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
        },
        {
          { 29823, 32302, 32662, 32755, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28147, 31806, 32507, 32734, 32764, 32765, 32766, 32767, 32768, 0 },
          { 23396, 29591, 31542, 32524, 32746, 32765, 32766, 32767, 32768, 0 },
          { 17276, 24958, 28612, 31424, 32560, 32754, 32766, 32767, 32768, 0 },
          { 11041, 18070, 22642, 27724, 31300, 32571, 32757, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
        },
        {
          { 30393, 32434, 32696, 32758, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28860, 32036, 32583, 32745, 32764, 32765, 32766, 32767, 32768, 0 },
          { 23625, 29725, 31610, 32542, 32748, 32765, 32766, 32767, 32768, 0 },
          { 18296, 25872, 29268, 31718, 32620, 32758, 32766, 32767, 32768, 0 },
          { 14993, 22698, 26844, 30513, 32330, 32732, 32766, 32767, 32768, 0 },
          { 5268, 9602, 13183, 18626, 25115, 30227, 32362, 32742, 32768, 0 },
        },
      },
    },
    {
      {
        {
          { 25977, 30943, 32176, 32675, 32760, 32765, 32766, 32767, 32768, 0 },
          { 22368, 28954, 31203, 32428, 32735, 32765, 32766, 32767, 32768, 0 },
          { 22368, 28954, 31203, 32428, 32735, 32765, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 29650, 32258, 32649, 32753, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28569, 31946, 32554, 32741, 32764, 32765, 32766, 32767, 32768, 0 },
          { 27610, 31616, 32440, 32723, 32763, 32765, 32766, 32767, 32768, 0 },
          { 25021, 30483, 31974, 32631, 32756, 32765, 32766, 32767, 32768, 0 },
          { 7342, 12884, 17104, 22847, 28493, 31772, 32668, 32764, 32768, 0 },
          { 4775, 8782, 12155, 17417, 23989, 29579, 32189, 32725, 32768, 0 },
        },
        {
          { 30192, 32390, 32685, 32757, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26713, 31263, 32306, 32699, 32761, 32765, 32766, 32767, 32768, 0 },
          { 15452, 23176, 27234, 30728, 32389, 32738, 32766, 32767, 32768, 0 },
          { 15452, 23176, 27234, 30728, 32389, 32738, 32766, 32767, 32768, 0 },
          { 14763, 22453, 26640, 30397, 32296, 32728, 32766, 32767, 32768, 0 },
          { 11041, 18070, 22642, 27724, 31300, 32571, 32757, 32767, 32768, 0 },
        },
        {
          { 30002, 32345, 32673, 32756, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26840, 31316, 32328, 32704, 32762, 32765, 32766, 32767, 32768, 0 },
          { 20331, 27526, 30364, 32152, 32697, 32763, 32766, 32767, 32768, 0 },
          { 13841, 21443, 25778, 29885, 32138, 32709, 32765, 32767, 32768, 0 },
          { 9025, 15348, 19839, 25419, 30125, 32295, 32733, 32767, 32768, 0 },
          { 4775, 8782, 12155, 17417, 23989, 29579, 32189, 32725, 32768, 0 },
        },
        {
          { 29483, 32214, 32637, 32752, 32764, 32765, 32766, 32767, 32768, 0 },
          { 27876, 31713, 32475, 32729, 32763, 32765, 32766, 32767, 32768, 0 },
          { 16594, 24314, 28128, 31191, 32506, 32749, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
          { 4652, 8574, 11891, 17100, 23682, 29391, 32135, 32719, 32768, 0 },
        },
        {
          { 29650, 32258, 32649, 32753, 32764, 32765, 32766, 32767, 32768, 0 },
          { 28714, 31992, 32569, 32743, 32764, 32765, 32766, 32767, 32768, 0 },
          { 20331, 27526, 30364, 32152, 32697, 32763, 32766, 32767, 32768, 0 },
          { 16366, 24092, 27958, 31106, 32486, 32747, 32766, 32767, 32768, 0 },
          { 11746, 18963, 23510, 28367, 31577, 32622, 32760, 32767, 32768, 0 },
          { 5881, 10601, 14409, 20013, 26320, 30848, 32504, 32754, 32768, 0 },
        },
      },
      {
        {
          { 30192, 32390, 32685, 32757, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26098, 30997, 32199, 32679, 32760, 32765, 32766, 32767, 32768, 0 },
          { 20670, 27779, 30520, 32207, 32705, 32763, 32766, 32767, 32768, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
          { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        },
        {
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 30853, 32529, 32720, 32761, 32764, 32765, 32766, 32767, 32768, 0 },
          { 29823, 32302, 32662, 32755, 32764, 32765, 32766, 32767, 32768, 0 },
          { 26343, 31106, 32244, 32688, 32761, 32765, 32766, 32767, 32768, 0 },
          { 22709, 29172, 31321, 32462, 32739, 32765, 32766, 32767, 32768, 0 },
          { 15452, 23176, 27234, 30728, 32389, 32738, 32766, 32767, 32768, 0 },
        },
        {
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 22028, 28732, 31080, 32391, 32731, 32765, 32766, 32767, 32768, 0 },
          { 20331, 27526, 30364, 32152, 32697, 32763, 32766, 32767, 32768, 0 },
          { 9740, 16342, 20890, 26323, 30619, 32422, 32745, 32767, 32768, 0 },
          { 4899, 8989, 12416, 17728, 24285, 29755, 32238, 32730, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 16024, 23755, 27695, 30972, 32453, 32744, 32766, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
          { 5881, 10601, 14409, 20013, 26320, 30848, 32504, 32754, 32768, 0 },
        },
        {
          { 31131, 32579, 32731, 32762, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 20331, 27526, 30364, 32152, 32697, 32763, 32766, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
          { 6492, 11572, 15574, 21274, 27335, 31311, 32593, 32760, 32768, 0 },
        },
        {
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 31486, 32636, 32743, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
          { 128, 255, 382, 634, 1131, 2100, 3939, 7257, 32768, 0 },
          { 16480, 24203, 28043, 31149, 32496, 32748, 32766, 32767, 32768, 0 },
          { 12797, 20240, 24704, 29196, 31900, 32675, 32763, 32767, 32768, 0 },
          { 7584, 13249, 17521, 23260, 28778, 31875, 32683, 32765, 32768, 0 },
        },
      },
    },
  },
}
Default_Dc_Head_Token_Cdf[ TX_SIZES ][ BLOCK_TYPES ][ REF_TYPES ]
                         [ DC_COEF_CONTEXTS ][ DC_HEAD_TOKENS + 1 ] = {
  {
    {
      {
        { 25024, 25863, 27361, 29796, 30374, 32768, 0 },
        { 10816, 14127, 17116, 23516, 24999, 32768, 0 },
        { 1088, 6358, 8428, 16648, 18276, 32768, 0 },
      },
      {
        { 24512, 26673, 28962, 31929, 32126, 32768, 0 },
        { 15936, 21711, 25569, 30899, 31305, 32768, 0 },
        { 3264, 14756, 20107, 29407, 30032, 32768, 0 },
      },
    },
    {
      {
        { 27456, 28244, 31289, 32358, 32534, 32768, 0 },
        { 16960, 21207, 26511, 30539, 31190, 32768, 0 },
        { 5440, 13412, 18469, 26423, 27669, 32768, 0 },
      },
      {
        { 29376, 30098, 32421, 32766, 32767, 32768, 0 },
        { 18368, 22916, 30116, 32541, 32650, 32768, 0 },
        { 5952, 16505, 25955, 32163, 32365, 32768, 0 },
      },
    },
  },
  {
    {
      {
        { 16064, 18127, 22153, 27289, 28507, 32768, 0 },
        { 6720, 10545, 13491, 20948, 22631, 32768, 0 },
        { 832, 5270, 5918, 12645, 13532, 32768, 0 },
      },
      {
        { 25920, 27743, 29455, 32147, 32280, 32768, 0 },
        { 13888, 19845, 23350, 30219, 30660, 32768, 0 },
        { 2368, 12781, 16196, 27232, 27894, 32768, 0 },
      },
    },
    {
      {
        { 27200, 27981, 31389, 32444, 32592, 32768, 0 },
        { 14528, 19068, 24887, 29901, 30688, 32768, 0 },
        { 3776, 11778, 14700, 23745, 24854, 32768, 0 },
      },
      {
        { 28864, 29988, 32423, 32766, 32767, 32768, 0 },
        { 18496, 24572, 30167, 32687, 32737, 32768, 0 },
        { 5440, 19618, 25332, 32393, 32491, 32768, 0 },
      },
    },
  },
  {
    {
      {
        { 960, 4882, 9467, 17710, 20412, 32768, 0 },
        { 704, 4657, 6561, 14507, 16279, 32768, 0 },
        { 192, 3443, 3759, 9011, 9685, 32768, 0 },
      },
      {
        { 2496, 8717, 17280, 28922, 29751, 32768, 0 },
        { 2496, 9665, 15235, 26542, 27580, 32768, 0 },
        { 448, 9240, 11886, 24124, 24898, 32768, 0 },
      },
    },
    {
      {
        { 27072, 27916, 31095, 32400, 32553, 32768, 0 },
        { 12352, 16792, 22516, 28853, 29797, 32768, 0 },
        { 2880, 9023, 11126, 20602, 21713, 32768, 0 },
      },
      {
        { 29888, 30492, 32500, 32766, 32767, 32768, 0 },
        { 18752, 23235, 29846, 32214, 32442, 32768, 0 },
        { 5568, 17762, 25039, 31213, 31651, 32768, 0 },
      },
    },
  },
  {
    {
      {
        { 2240, 5407, 18304, 25601, 27911, 32768, 0 },
        { 960, 4633, 8197, 16254, 18796, 32768, 0 },
        { 192, 3061, 3557, 8701, 9762, 32768, 0 },
      },
      {
        { 4672, 6927, 23534, 29846, 30928, 32768, 0 },
        { 3776, 6784, 18075, 25863, 27926, 32768, 0 },
        { 1344, 5588, 12166, 20966, 23504, 32768, 0 },
      },
    },
    {
      {
        { 23232, 24301, 30231, 31582, 32091, 32768, 0 },
        { 7872, 11041, 22542, 27086, 29145, 32768, 0 },
        { 1344, 3989, 18125, 25340, 27820, 32768, 0 },
      },
      {
        { 25280, 25678, 32446, 32622, 32724, 32768, 0 },
        { 10560, 11822, 28682, 29919, 31276, 32768, 0 },
        { 3264, 5170, 21779, 24026, 27905, 32768, 0 },
      },
    },
  },
}
Default_Ac_Head_Token_Cdf[ TX_SIZES ][ BLOCK_TYPES ]
                         [ REF_TYPES ][ COEF_BANDS - 1 ]
                         [ PREV_COEF_CONTEXTS ][ AC_HEAD_TOKENS + 1 ] = {
  {
    {
      {
        {
          { 14529, 18769, 29100, 29634, 32768, 0 },
          { 12993, 17117, 28404, 28988, 32768, 0 },
          { 11201, 14084, 25818, 26504, 32768, 0 },
          { 9793, 11267, 21775, 22451, 32768, 0 },
          { 7105, 7562, 15777, 16225, 32768, 0 },
          { 3905, 3966, 8359, 8526, 32768, 0 },
        },
        {
          { 20033, 23643, 31102, 31374, 32768, 0 },
          { 16321, 20350, 30167, 30546, 32768, 0 },
          { 12993, 15512, 26859, 27396, 32768, 0 },
          { 10305, 11659, 21669, 22330, 32768, 0 },
          { 7361, 7819, 15450, 15940, 32768, 0 },
          { 3521, 3580, 7805, 7976, 32768, 0 },
        },
        {
          { 21057, 25460, 31740, 31952, 32768, 0 },
          { 16449, 21173, 30761, 31092, 32768, 0 },
          { 11841, 14615, 26188, 26824, 32768, 0 },
          { 7745, 8991, 18937, 19707, 32768, 0 },
          { 4417, 4706, 10342, 10890, 32768, 0 },
          { 7617, 8392, 17295, 17915, 32768, 0 },
        },
        {
          { 20417, 26452, 32166, 32321, 32768, 0 },
          { 15809, 21634, 30947, 31298, 32768, 0 },
          { 10049, 12176, 23495, 24229, 32768, 0 },
          { 5953, 6731, 16166, 16798, 32768, 0 },
          { 6081, 6188, 8114, 8764, 32768, 0 },
          { 2113, 2291, 4448, 5527, 32768, 0 },
        },
        {
          { 9153, 25905, 31431, 31934, 32768, 0 },
          { 9025, 23345, 30033, 30965, 32768, 0 },
          { 5953, 13835, 22032, 24664, 32768, 0 },
          { 6337, 11435, 18366, 21418, 32768, 0 },
          { 3137, 4871, 8519, 12426, 32768, 0 },
          { 1857, 2727, 5540, 8757, 32768, 0 },
        },
      },
      {
        {
          { 21313, 26020, 32523, 32575, 32768, 0 },
          { 18369, 24215, 32291, 32391, 32768, 0 },
          { 15297, 19637, 30414, 30752, 32768, 0 },
          { 11713, 14040, 25408, 26033, 32768, 0 },
          { 9537, 10173, 18839, 19315, 32768, 0 },
          { 9025, 9093, 13987, 14115, 32768, 0 },
        },
        {
          { 22721, 27599, 32592, 32636, 32768, 0 },
          { 19009, 24676, 32258, 32367, 32768, 0 },
          { 12737, 16769, 28739, 29247, 32768, 0 },
          { 8769, 10956, 21941, 22840, 32768, 0 },
          { 6721, 7678, 15319, 16290, 32768, 0 },
          { 4417, 4430, 4583, 5712, 32768, 0 },
        },
        {
          { 22849, 28333, 32633, 32671, 32768, 0 },
          { 18497, 24619, 32184, 32315, 32768, 0 },
          { 11841, 14640, 27251, 27752, 32768, 0 },
          { 8385, 10154, 18339, 19621, 32768, 0 },
          { 5697, 6977, 13787, 15289, 32768, 0 },
          { 193, 194, 384, 479, 32768, 0 },
        },
        {
          { 20417, 28167, 32552, 32621, 32768, 0 },
          { 16833, 23968, 31991, 32174, 32768, 0 },
          { 10433, 13387, 26356, 26951, 32768, 0 },
          { 5057, 6823, 18967, 19843, 32768, 0 },
          { 5697, 6479, 11672, 13052, 32768, 0 },
          { 2241, 2265, 6355, 6432, 32768, 0 },
        },
        {
          { 12097, 28717, 32406, 32555, 32768, 0 },
          { 10433, 26113, 31504, 31975, 32768, 0 },
          { 5825, 14284, 21349, 24461, 32768, 0 },
          { 4545, 8454, 12648, 17501, 32768, 0 },
          { 193, 7173, 15272, 19322, 32768, 0 },
          { 2113, 2183, 7202, 7377, 32768, 0 },
        },
      },
    },
    {
      {
        {
          { 17857, 26327, 31983, 32219, 32768, 0 },
          { 16065, 24198, 31431, 31785, 32768, 0 },
          { 12865, 18011, 28454, 29166, 32768, 0 },
          { 9665, 12501, 24331, 25147, 32768, 0 },
          { 2753, 3121, 12661, 13034, 32768, 0 },
          { 4033, 4140, 11834, 11977, 32768, 0 },
        },
        {
          { 21185, 28338, 32249, 32417, 32768, 0 },
          { 18497, 25227, 31905, 32122, 32768, 0 },
          { 12097, 16516, 28610, 29166, 32768, 0 },
          { 9281, 11157, 21438, 22312, 32768, 0 },
          { 5697, 6566, 15585, 16340, 32768, 0 },
          { 9409, 9659, 11827, 12911, 32768, 0 },
        },
        {
          { 22337, 29459, 32382, 32519, 32768, 0 },
          { 16961, 25262, 31874, 32123, 32768, 0 },
          { 12353, 17748, 29300, 29852, 32768, 0 },
          { 9025, 11528, 24468, 25141, 32768, 0 },
          { 6209, 6565, 15806, 16121, 32768, 0 },
          { 2497, 2524, 7050, 7125, 32768, 0 },
        },
        {
          { 20417, 29779, 32552, 32636, 32768, 0 },
          { 15553, 26420, 32063, 32295, 32768, 0 },
          { 9665, 17946, 29385, 30096, 32768, 0 },
          { 5569, 10207, 22410, 23836, 32768, 0 },
          { 16449, 16450, 16545, 16593, 32768, 0 },
          { 2369, 2395, 6822, 6898, 32768, 0 },
        },
        {
          { 10177, 30567, 32725, 32745, 32768, 0 },
          { 9537, 28243, 32179, 32423, 32768, 0 },
          { 13377, 23187, 29322, 30382, 32768, 0 },
          { 13121, 21346, 29507, 30326, 32768, 0 },
          { 4417, 4939, 15104, 15535, 32768, 0 },
          { 2625, 2680, 8218, 8338, 32768, 0 },
        },
      },
      {
        {
          { 19649, 30160, 32743, 32753, 32768, 0 },
          { 18881, 28724, 32688, 32717, 32768, 0 },
          { 16833, 23053, 31244, 31573, 32768, 0 },
          { 14657, 17714, 26083, 26978, 32768, 0 },
          { 14657, 16618, 24597, 25403, 32768, 0 },
          { 4289, 4326, 10686, 10751, 32768, 0 },
        },
        {
          { 21953, 30956, 32748, 32757, 32768, 0 },
          { 20929, 29412, 32700, 32725, 32768, 0 },
          { 13377, 21495, 31216, 31569, 32768, 0 },
          { 9153, 15097, 28295, 28990, 32768, 0 },
          { 5313, 5363, 13839, 13894, 32768, 0 },
          { 2625, 2652, 7276, 7351, 32768, 0 },
        },
        {
          { 20289, 31164, 32745, 32755, 32768, 0 },
          { 17601, 29635, 32739, 32751, 32768, 0 },
          { 18241, 24284, 32116, 32258, 32768, 0 },
          { 32705, 32706, 32739, 32740, 32768, 0 },
          { 5697, 5750, 14739, 14792, 32768, 0 },
          { 2881, 2913, 8427, 8498, 32768, 0 },
        },
        {
          { 19009, 31481, 32742, 32754, 32768, 0 },
          { 15809, 30521, 32736, 32750, 32768, 0 },
          { 16449, 32705, 32737, 32753, 32768, 0 },
          { 7873, 8039, 19981, 20068, 32768, 0 },
          { 5313, 5366, 14376, 14430, 32768, 0 },
          { 2753, 2789, 8909, 8979, 32768, 0 },
        },
        {
          { 11841, 32116, 32728, 32748, 32768, 0 },
          { 12353, 32132, 32729, 32748, 32768, 0 },
          { 7489, 12435, 25708, 26666, 32768, 0 },
          { 5697, 7486, 20238, 21009, 32768, 0 },
          { 4929, 5579, 16402, 16866, 32768, 0 },
          { 3009, 3246, 10158, 10533, 32768, 0 },
        },
      },
    },
  },
  {
    {
      {
        {
          { 14017, 16139, 26799, 27295, 32768, 0 },
          { 12737, 15136, 26235, 26816, 32768, 0 },
          { 10817, 12445, 23637, 24217, 32768, 0 },
          { 8897, 9702, 20040, 20500, 32768, 0 },
          { 5953, 6156, 13966, 14205, 32768, 0 },
          { 2497, 2519, 6222, 6300, 32768, 0 },
        },
        {
          { 19777, 21403, 30054, 30269, 32768, 0 },
          { 16193, 17913, 28593, 28883, 32768, 0 },
          { 12609, 13572, 25248, 25534, 32768, 0 },
          { 9665, 10118, 20721, 20968, 32768, 0 },
          { 6849, 7028, 15202, 15391, 32768, 0 },
          { 3009, 3036, 7601, 7675, 32768, 0 },
        },
        {
          { 22593, 23915, 31159, 31283, 32768, 0 },
          { 17345, 18690, 29425, 29611, 32768, 0 },
          { 11969, 12540, 24685, 24867, 32768, 0 },
          { 8129, 8355, 18668, 18819, 32768, 0 },
          { 4673, 4714, 11752, 11814, 32768, 0 },
          { 1857, 1876, 5057, 5138, 32768, 0 },
        },
        {
          { 24513, 25718, 31947, 32014, 32768, 0 },
          { 18881, 20029, 30409, 30527, 32768, 0 },
          { 12481, 12953, 25201, 25341, 32768, 0 },
          { 8385, 8528, 18815, 18910, 32768, 0 },
          { 4289, 4327, 10797, 10861, 32768, 0 },
          { 1857, 1872, 4332, 4415, 32768, 0 },
        },
        {
          { 26049, 27752, 32415, 32462, 32768, 0 },
          { 20417, 22100, 31056, 31192, 32768, 0 },
          { 12481, 13075, 24646, 24844, 32768, 0 },
          { 7489, 7696, 17117, 17285, 32768, 0 },
          { 3777, 3814, 10062, 10129, 32768, 0 },
          { 1473, 1486, 3735, 3820, 32768, 0 },
        },
      },
      {
        {
          { 21697, 24758, 32358, 32417, 32768, 0 },
          { 20289, 23960, 32111, 32213, 32768, 0 },
          { 17345, 19966, 30630, 30841, 32768, 0 },
          { 14529, 16070, 27461, 27777, 32768, 0 },
          { 9793, 10613, 21146, 21566, 32768, 0 },
          { 6977, 7162, 15591, 15776, 32768, 0 },
        },
        {
          { 23617, 26783, 32572, 32607, 32768, 0 },
          { 20801, 24292, 32185, 32275, 32768, 0 },
          { 15169, 17905, 29916, 30181, 32768, 0 },
          { 10945, 12972, 25565, 26064, 32768, 0 },
          { 6849, 8334, 18543, 19446, 32768, 0 },
          { 3649, 4346, 12351, 13169, 32768, 0 },
        },
        {
          { 25281, 28440, 32667, 32689, 32768, 0 },
          { 22081, 25694, 32414, 32476, 32768, 0 },
          { 15297, 18341, 30141, 30410, 32768, 0 },
          { 10305, 12381, 24477, 25084, 32768, 0 },
          { 5697, 6673, 16325, 17080, 32768, 0 },
          { 2369, 2393, 6466, 6543, 32768, 0 },
        },
        {
          { 25921, 29445, 32729, 32739, 32768, 0 },
          { 22465, 26834, 32588, 32627, 32768, 0 },
          { 16449, 20062, 31016, 31233, 32768, 0 },
          { 11073, 13165, 25353, 25896, 32768, 0 },
          { 11713, 13837, 20144, 21734, 32768, 0 },
          { 2241, 2265, 6355, 6432, 32768, 0 },
        },
        {
          { 26177, 29403, 32705, 32721, 32768, 0 },
          { 22337, 26344, 32545, 32589, 32768, 0 },
          { 19009, 21527, 31775, 31873, 32768, 0 },
          { 11585, 12685, 22632, 23137, 32768, 0 },
          { 8257, 8305, 16444, 16492, 32768, 0 },
          { 2113, 2183, 7202, 7377, 32768, 0 },
        },
      },
    },
    {
      {
        {
          { 20289, 25202, 31672, 31909, 32768, 0 },
          { 18369, 23493, 31166, 31487, 32768, 0 },
          { 15425, 18619, 28941, 29393, 32768, 0 },
          { 10945, 12535, 24287, 24792, 32768, 0 },
          { 6465, 6810, 15764, 16080, 32768, 0 },
          { 2113, 2137, 6125, 6203, 32768, 0 },
        },
        {
          { 23745, 27041, 31976, 32135, 32768, 0 },
          { 19521, 22766, 31139, 31367, 32768, 0 },
          { 14273, 15834, 27820, 28105, 32768, 0 },
          { 9537, 10445, 22106, 22491, 32768, 0 },
          { 7233, 7386, 15961, 16109, 32768, 0 },
          { 2369, 2401, 7891, 7964, 32768, 0 },
        },
        {
          { 26305, 28703, 32352, 32435, 32768, 0 },
          { 20673, 23490, 31517, 31680, 32768, 0 },
          { 14017, 15251, 27458, 27702, 32768, 0 },
          { 10945, 11374, 22496, 22687, 32768, 0 },
          { 9153, 9435, 22299, 22411, 32768, 0 },
          { 193, 269, 13236, 13293, 32768, 0 },
        },
        {
          { 27713, 29770, 32522, 32575, 32768, 0 },
          { 21569, 24342, 31785, 31919, 32768, 0 },
          { 15297, 16497, 28367, 28569, 32768, 0 },
          { 17601, 17828, 24444, 24582, 32768, 0 },
          { 6977, 7035, 16901, 16947, 32768, 0 },
          { 193, 384, 32706, 32707, 32768, 0 },
        },
        {
          { 28737, 30879, 32667, 32695, 32768, 0 },
          { 22593, 26241, 32073, 32207, 32768, 0 },
          { 16577, 19148, 28436, 28906, 32768, 0 },
          { 12993, 14005, 23151, 23630, 32768, 0 },
          { 7617, 9188, 22797, 23313, 32768, 0 },
          { 2625, 2680, 8218, 8338, 32768, 0 },
        },
      },
      {
        {
          { 23745, 29427, 32751, 32757, 32768, 0 },
          { 23745, 28704, 32716, 32731, 32768, 0 },
          { 23105, 27943, 32524, 32587, 32768, 0 },
          { 21057, 24773, 29589, 30282, 32768, 0 },
          { 12609, 14823, 23831, 24713, 32768, 0 },
          { 16449, 16450, 16545, 16593, 32768, 0 },
        },
        {
          { 25025, 30203, 32754, 32759, 32768, 0 },
          { 23617, 28361, 32715, 32729, 32768, 0 },
          { 17985, 21562, 31354, 31543, 32768, 0 },
          { 12353, 18915, 28742, 29548, 32768, 0 },
          { 193, 289, 16545, 16593, 32768, 0 },
          { 2625, 2652, 7276, 7351, 32768, 0 },
        },
        {
          { 26433, 30892, 32757, 32761, 32768, 0 },
          { 24513, 29274, 32721, 32735, 32768, 0 },
          { 20161, 24040, 32055, 32171, 32768, 0 },
          { 21953, 24678, 27382, 28734, 32768, 0 },
          { 5697, 5750, 14739, 14792, 32768, 0 },
          { 2881, 2913, 8427, 8498, 32768, 0 },
        },
        {
          { 27457, 31485, 32759, 32763, 32768, 0 },
          { 24129, 29502, 32752, 32757, 32768, 0 },
          { 19009, 25452, 32473, 32544, 32768, 0 },
          { 32705, 32706, 32737, 32738, 32768, 0 },
          { 5313, 5366, 14376, 14430, 32768, 0 },
          { 2753, 2789, 8909, 8979, 32768, 0 },
        },
        {
          { 27841, 32288, 32759, 32764, 32768, 0 },
          { 19137, 30271, 32742, 32753, 32768, 0 },
          { 18625, 27739, 29979, 31099, 32768, 0 },
          { 5697, 7486, 20238, 21009, 32768, 0 },
          { 4929, 5579, 16402, 16866, 32768, 0 },
          { 3009, 3246, 10158, 10533, 32768, 0 },
        },
      },
    },
  },
  {
    {
      {
        {
          { 12481, 13958, 24487, 24997, 32768, 0 },
          { 11457, 13075, 23820, 24406, 32768, 0 },
          { 9793, 11127, 21775, 22387, 32768, 0 },
          { 7745, 8457, 18155, 18655, 32768, 0 },
          { 5441, 5668, 13180, 13467, 32768, 0 },
          { 2497, 2520, 6340, 6417, 32768, 0 },
        },
        {
          { 19521, 20572, 28965, 29177, 32768, 0 },
          { 15425, 16741, 27247, 27554, 32768, 0 },
          { 11969, 12690, 23872, 24141, 32768, 0 },
          { 9281, 9678, 19970, 20207, 32768, 0 },
          { 6081, 6266, 14682, 14876, 32768, 0 },
          { 2753, 2779, 7150, 7225, 32768, 0 },
        },
        {
          { 22337, 23293, 30630, 30753, 32768, 0 },
          { 16321, 17427, 28368, 28570, 32768, 0 },
          { 11457, 11907, 23570, 23741, 32768, 0 },
          { 7233, 7331, 17258, 17334, 32768, 0 },
          { 4033, 4070, 10375, 10441, 32768, 0 },
          { 1601, 1619, 4706, 4788, 32768, 0 },
        },
        {
          { 24769, 25536, 31660, 31722, 32768, 0 },
          { 18113, 18886, 29420, 29534, 32768, 0 },
          { 11201, 11412, 23207, 23291, 32768, 0 },
          { 6977, 7033, 16599, 16646, 32768, 0 },
          { 4033, 4070, 10375, 10441, 32768, 0 },
          { 1601, 1620, 4827, 4909, 32768, 0 },
        },
        {
          { 28353, 28831, 32502, 32517, 32768, 0 },
          { 21441, 21869, 30977, 31017, 32768, 0 },
          { 11969, 12088, 24116, 24158, 32768, 0 },
          { 7489, 7547, 17413, 17458, 32768, 0 },
          { 4545, 4585, 11325, 11388, 32768, 0 },
          { 2113, 2133, 5526, 5606, 32768, 0 },
        },
      },
      {
        {
          { 21057, 22896, 31877, 31953, 32768, 0 },
          { 20673, 23151, 31706, 31825, 32768, 0 },
          { 18753, 20519, 30497, 30668, 32768, 0 },
          { 15425, 16608, 27789, 28027, 32768, 0 },
          { 10305, 10977, 21405, 21749, 32768, 0 },
          { 3649, 3812, 11213, 11445, 32768, 0 },
        },
        {
          { 24001, 25899, 32307, 32360, 32768, 0 },
          { 20929, 22941, 31775, 31867, 32768, 0 },
          { 15169, 16734, 29228, 29425, 32768, 0 },
          { 10561, 12047, 24918, 25324, 32768, 0 },
          { 6977, 7929, 18311, 18918, 32768, 0 },
          { 3649, 3760, 9962, 10162, 32768, 0 },
        },
        {
          { 25793, 27526, 32565, 32591, 32768, 0 },
          { 21825, 23885, 32064, 32135, 32768, 0 },
          { 15041, 16286, 29203, 29360, 32768, 0 },
          { 10433, 11058, 24349, 24538, 32768, 0 },
          { 5569, 6016, 16460, 16794, 32768, 0 },
          { 193, 194, 384, 479, 32768, 0 },
        },
        {
          { 26433, 28398, 32682, 32696, 32768, 0 },
          { 22977, 25086, 32367, 32412, 32768, 0 },
          { 16577, 17928, 30144, 30275, 32768, 0 },
          { 12481, 13352, 25993, 26211, 32768, 0 },
          { 7745, 8069, 20501, 20657, 32768, 0 },
          { 16449, 16450, 16545, 16593, 32768, 0 },
        },
        {
          { 27841, 29700, 32721, 32730, 32768, 0 },
          { 23873, 26202, 32578, 32604, 32768, 0 },
          { 17729, 19046, 30448, 30568, 32768, 0 },
          { 13505, 14508, 26034, 26304, 32768, 0 },
          { 10049, 10494, 19945, 20233, 32768, 0 },
          { 2113, 2183, 7202, 7377, 32768, 0 },
        },
      },
    },
    {
      {
        {
          { 20161, 24785, 31070, 31430, 32768, 0 },
          { 17985, 22773, 30430, 30880, 32768, 0 },
          { 15937, 18802, 28265, 28788, 32768, 0 },
          { 11841, 13587, 24798, 25335, 32768, 0 },
          { 8769, 9160, 19316, 19566, 32768, 0 },
          { 5313, 5357, 12874, 12932, 32768, 0 },
        },
        {
          { 24129, 26501, 31672, 31844, 32768, 0 },
          { 19649, 21553, 30130, 30370, 32768, 0 },
          { 11713, 13134, 25983, 26321, 32768, 0 },
          { 9409, 9948, 21408, 21663, 32768, 0 },
          { 5569, 5757, 14335, 14533, 32768, 0 },
          { 2241, 2305, 13152, 13209, 32768, 0 },
        },
        {
          { 26817, 28135, 32130, 32209, 32768, 0 },
          { 20161, 21412, 30331, 30481, 32768, 0 },
          { 13377, 13798, 26065, 26176, 32768, 0 },
          { 8129, 8290, 19920, 20008, 32768, 0 },
          { 5697, 5751, 14950, 15002, 32768, 0 },
          { 5569, 5601, 11041, 11105, 32768, 0 },
        },
        {
          { 28225, 29079, 32387, 32426, 32768, 0 },
          { 21185, 22046, 30982, 31061, 32768, 0 },
          { 13377, 13595, 25762, 25824, 32768, 0 },
          { 8001, 8123, 20530, 20590, 32768, 0 },
          { 4289, 4322, 9907, 9974, 32768, 0 },
          { 3393, 3412, 6663, 6739, 32768, 0 },
        },
        {
          { 30529, 31014, 32651, 32664, 32768, 0 },
          { 23489, 24268, 31627, 31682, 32768, 0 },
          { 14017, 14239, 26653, 26707, 32768, 0 },
          { 11201, 11317, 23122, 23169, 32768, 0 },
          { 6721, 6768, 14810, 14863, 32768, 0 },
          { 6593, 6632, 13188, 13245, 32768, 0 },
        },
      },
      {
        {
          { 26433, 29681, 32757, 32760, 32768, 0 },
          { 24769, 28761, 32722, 32734, 32768, 0 },
          { 22209, 26975, 32418, 32500, 32768, 0 },
          { 16321, 21333, 28368, 29283, 32768, 0 },
          { 12865, 14775, 22545, 23553, 32768, 0 },
          { 12353, 12354, 12473, 12532, 32768, 0 },
        },
        {
          { 27457, 30005, 32738, 32745, 32768, 0 },
          { 24897, 27541, 32723, 32731, 32768, 0 },
          { 15297, 19106, 30414, 30711, 32768, 0 },
          { 6593, 8826, 19732, 20840, 32768, 0 },
          { 4161, 4233, 16509, 16557, 32768, 0 },
          { 2625, 2652, 7276, 7351, 32768, 0 },
        },
        {
          { 28609, 30482, 32761, 32763, 32768, 0 },
          { 25665, 27830, 32727, 32733, 32768, 0 },
          { 21057, 23803, 30367, 30721, 32768, 0 },
          { 10945, 21878, 32726, 32737, 32768, 0 },
          { 5697, 5750, 14739, 14792, 32768, 0 },
          { 2881, 2913, 8427, 8498, 32768, 0 },
        },
        {
          { 28993, 30944, 32762, 32764, 32768, 0 },
          { 26561, 28695, 32733, 32739, 32768, 0 },
          { 17985, 19028, 31008, 31079, 32768, 0 },
          { 7873, 8039, 19981, 20068, 32768, 0 },
          { 5313, 5366, 14376, 14430, 32768, 0 },
          { 2753, 2789, 8909, 8979, 32768, 0 },
        },
        {
          { 30273, 32029, 32764, 32766, 32768, 0 },
          { 28609, 30847, 32745, 32751, 32768, 0 },
          { 21313, 24377, 31986, 32098, 32768, 0 },
          { 32705, 32709, 32739, 32741, 32768, 0 },
          { 4929, 5579, 16402, 16866, 32768, 0 },
          { 3009, 3246, 10158, 10533, 32768, 0 },
        },
      },
    },
  },
  {
    {
      {
        {
          { 11969, 15846, 25660, 26667, 32768, 0 },
          { 11713, 15794, 25737, 26760, 32768, 0 },
          { 9281, 12675, 23181, 24351, 32768, 0 },
          { 7105, 8757, 18383, 19437, 32768, 0 },
          { 4289, 4579, 11353, 11792, 32768, 0 },
          { 1857, 1874, 4695, 4777, 32768, 0 },
        },
        {
          { 20929, 22297, 29370, 29646, 32768, 0 },
          { 17473, 18985, 28079, 28413, 32768, 0 },
          { 13121, 14064, 24902, 25217, 32768, 0 },
          { 9793, 10214, 20069, 20329, 32768, 0 },
          { 5825, 5987, 13350, 13559, 32768, 0 },
          { 2241, 2260, 5520, 5600, 32768, 0 },
        },
        {
          { 25921, 26891, 31632, 31729, 32768, 0 },
          { 18241, 19463, 29222, 29419, 32768, 0 },
          { 11585, 12065, 23294, 23488, 32768, 0 },
          { 6593, 6686, 16153, 16234, 32768, 0 },
          { 3137, 3170, 8751, 8821, 32768, 0 },
          { 1345, 1359, 3739, 3824, 32768, 0 },
        },
        {
          { 27713, 28504, 32068, 32132, 32768, 0 },
          { 19265, 20354, 29789, 29943, 32768, 0 },
          { 11201, 11538, 22701, 22848, 32768, 0 },
          { 6337, 6424, 15268, 15353, 32768, 0 },
          { 3649, 3681, 9052, 9121, 32768, 0 },
          { 1601, 1618, 4584, 4667, 32768, 0 },
        },
        {
          { 30913, 31044, 32635, 32640, 32768, 0 },
          { 22081, 22261, 30452, 30477, 32768, 0 },
          { 10561, 10625, 21535, 21568, 32768, 0 },
          { 6081, 6130, 14369, 14423, 32768, 0 },
          { 3777, 3809, 9156, 9225, 32768, 0 },
          { 1857, 1875, 4936, 5018, 32768, 0 },
        },
      },
      {
        {
          { 19393, 22016, 31280, 31444, 32768, 0 },
          { 21185, 24329, 31706, 31865, 32768, 0 },
          { 20673, 23240, 31186, 31379, 32768, 0 },
          { 17857, 20035, 29594, 29889, 32768, 0 },
          { 13633, 14929, 24883, 25337, 32768, 0 },
          { 7873, 8416, 17452, 17886, 32768, 0 },
        },
        {
          { 25665, 27145, 32256, 32314, 32768, 0 },
          { 21057, 22826, 31465, 31576, 32768, 0 },
          { 13633, 14885, 27873, 28088, 32768, 0 },
          { 8769, 9515, 21941, 22248, 32768, 0 },
          { 6209, 6594, 15598, 15950, 32768, 0 },
          { 1985, 2014, 6855, 6931, 32768, 0 },
        },
        {
          { 26817, 27824, 32362, 32399, 32768, 0 },
          { 21185, 22321, 31389, 31466, 32768, 0 },
          { 13761, 14154, 27163, 27245, 32768, 0 },
          { 8897, 9011, 20600, 20659, 32768, 0 },
          { 4673, 4774, 15044, 15131, 32768, 0 },
          { 193, 194, 384, 479, 32768, 0 },
        },
        {
          { 28865, 29687, 32655, 32667, 32768, 0 },
          { 23233, 24218, 32080, 32118, 32768, 0 },
          { 15041, 15444, 28787, 28845, 32768, 0 },
          { 9921, 10248, 22818, 22944, 32768, 0 },
          { 7745, 7866, 16591, 16702, 32768, 0 },
          { 193, 194, 384, 479, 32768, 0 },
        },
        {
          { 31169, 31559, 32741, 32744, 32768, 0 },
          { 24769, 25583, 32347, 32370, 32768, 0 },
          { 15937, 16169, 29120, 29152, 32768, 0 },
          { 7489, 7578, 22647, 22677, 32768, 0 },
          { 7617, 7689, 19849, 19887, 32768, 0 },
          { 2113, 2183, 7202, 7377, 32768, 0 },
        },
      },
    },
    {
      {
        {
          { 15937, 29000, 32210, 32434, 32768, 0 },
          { 12353, 26626, 31533, 31993, 32768, 0 },
          { 11457, 29187, 30896, 31750, 32768, 0 },
          { 5697, 21278, 28169, 29764, 32768, 0 },
          { 7489, 8855, 13365, 15620, 32768, 0 },
          { 4289, 4833, 8572, 10108, 32768, 0 },
        },
        {
          { 25025, 30783, 32603, 32666, 32768, 0 },
          { 24385, 29586, 31803, 32142, 32768, 0 },
          { 22337, 23002, 27573, 27903, 32768, 0 },
          { 10945, 12336, 21900, 22590, 32768, 0 },
          { 8257, 8830, 19986, 20298, 32768, 0 },
          { 10945, 10990, 18660, 18701, 32768, 0 },
        },
        {
          { 29761, 31473, 32693, 32715, 32768, 0 },
          { 20417, 24512, 31394, 31650, 32768, 0 },
          { 11713, 13283, 25819, 26206, 32768, 0 },
          { 13121, 14099, 21909, 22514, 32768, 0 },
          { 193, 248, 9546, 9614, 32768, 0 },
          { 2497, 2524, 7050, 7125, 32768, 0 },
        },
        {
          { 30657, 31885, 32691, 32715, 32768, 0 },
          { 19393, 26050, 31698, 31988, 32768, 0 },
          { 15809, 15863, 24985, 25008, 32768, 0 },
          { 23489, 28138, 32751, 32756, 32768, 0 },
          { 16449, 16450, 16545, 16593, 32768, 0 },
          { 2369, 2395, 6822, 6898, 32768, 0 },
        },
        {
          { 32705, 32744, 32766, 32767, 32768, 0 },
          { 21953, 24962, 32156, 32246, 32768, 0 },
          { 13121, 15358, 26284, 26835, 32768, 0 },
          { 5697, 7417, 20132, 20885, 32768, 0 },
          { 4417, 4939, 15104, 15535, 32768, 0 },
          { 2625, 2680, 8218, 8338, 32768, 0 },
        },
      },
      {
        {
          { 24257, 30554, 32719, 32738, 32768, 0 },
          { 17217, 27413, 32617, 32667, 32768, 0 },
          { 22977, 27600, 32482, 32552, 32768, 0 },
          { 16833, 24360, 30746, 31293, 32768, 0 },
          { 17089, 20060, 28880, 29370, 32768, 0 },
          { 10945, 11009, 21900, 21932, 32768, 0 },
        },
        {
          { 27201, 30217, 32736, 32745, 32768, 0 },
          { 22721, 27676, 32749, 32754, 32768, 0 },
          { 5057, 12431, 25246, 26620, 32768, 0 },
          { 193, 321, 22016, 22048, 32768, 0 },
          { 5313, 5363, 13839, 13894, 32768, 0 },
          { 2625, 2652, 7276, 7351, 32768, 0 },
        },
        {
          { 27713, 30739, 32759, 32762, 32768, 0 },
          { 26177, 30430, 32756, 32760, 32768, 0 },
          { 193, 384, 32706, 32707, 32768, 0 },
          { 9409, 9528, 21591, 21646, 32768, 0 },
          { 193, 194, 384, 479, 32768, 0 },
          { 2881, 2913, 8427, 8498, 32768, 0 },
        },
        {
          { 28993, 31156, 32747, 32753, 32768, 0 },
          { 25153, 28701, 32754, 32758, 32768, 0 },
          { 16449, 16544, 32737, 32738, 32768, 0 },
          { 193, 321, 22016, 22048, 32768, 0 },
          { 193, 194, 384, 479, 32768, 0 },
          { 2753, 2789, 8909, 8979, 32768, 0 },
        },
        {
          { 30785, 32088, 32765, 32766, 32768, 0 },
          { 22977, 26623, 32750, 32754, 32768, 0 },
          { 21953, 21954, 22017, 22049, 32768, 0 },
          { 5697, 7486, 20238, 21009, 32768, 0 },
          { 4929, 5579, 16402, 16866, 32768, 0 },
          { 3009, 3246, 10158, 10533, 32768, 0 },
        },
      },
    },
  },
}
Default_Palette_Y_Size_Cdf[ PALETTE_BLOCK_SIZES ][ PALETTE_SIZES + 1 ] = {
  { 12288, 19408, 24627, 26662, 28499, 30667, 32768, 0 },
  { 2815, 4570, 9416, 10875, 13782, 19863, 32768, 0 },
  { 3839, 5986, 11949, 13413, 16286, 21823, 32768, 0 },
  { 12032, 14948, 22187, 23138, 24756, 27635, 32768, 0 },
  { 14847, 20167, 25433, 26751, 28278, 30119, 32768, 0 },
  { 14336, 20240, 24840, 26079, 27908, 30034, 32768, 0 },
  { 18816, 25574, 29030, 29877, 30656, 31506, 32768, 0 },
  { 23039, 27333, 30220, 30708, 31070, 31826, 32768, 0 },
  { 13696, 18911, 23620, 25371, 29821, 31617, 32768, 0 },
  { 12543, 20838, 27455, 28762, 29763, 31546, 32768, 0 }
  { 12543, 20838, 27455, 28762, 29763, 31546, 32768, 0 },
  { 12543, 20838, 27455, 28762, 29763, 31546, 32768, 0 },
  { 12543, 20838, 27455, 28762, 29763, 31546, 32768, 0 },
}
Default_Palette_Uv_Size_Cdf[ PALETTE_BLOCK_SIZES ][ PALETTE_SIZES + 1 ] = {
  { 20480, 29888, 32453, 32715, 32751, 32766, 32768, 0 },
  { 11135, 23641, 31056, 31998, 32496, 32668, 32768, 0 },
  { 9216, 23108, 30806, 31871, 32414, 32637, 32768, 0 },
  { 9984, 21999, 29192, 30645, 31640, 32402, 32768, 0 },
  { 7552, 16614, 24880, 27283, 29254, 31203, 32768, 0 },
  { 9600, 20279, 27548, 29261, 30494, 31631, 32768, 0 },
  { 11391, 18656, 23727, 26058, 27788, 30278, 32768, 0 },
  { 8576, 13585, 17632, 20884, 23948, 27152, 32768, 0 },
  { 15360, 24200, 26978, 30846, 31409, 32545, 32768, 0 },
  { 9216, 14276, 19043, 22689, 25799, 28712, 32768, 0 }
  { 9216, 14276, 19043, 22689, 25799, 28712, 32768, 0 },
  { 9216, 14276, 19043, 22689, 25799, 28712, 32768, 0 },
  { 9216, 14276, 19043, 22689, 25799, 28712, 32768, 0 },
}
Default_Palette_Size_2_Y_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 3 ] = {
  { 29568, 32768, 0 },
  { 16384, 32768, 0 },
  { 8832, 32768, 0 },
  { 28672, 32768, 0 },
  { 31872, 32768, 0 },
}

Default_Palette_Size_3_Y_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 4 ] = {
  { 28032, 30326, 32768, 0 },
  { 11647, 27405, 32768, 0 },
  { 4352, 30659, 32768, 0 },
  { 23552, 27800, 32768, 0 },
  { 32256, 32504, 32768, 0 }
}

Default_Palette_Size_4_Y_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 5 ] = {
  { 26112, 28374, 30039, 32768, 0 },
  { 9472, 22576, 27712, 32768, 0 },
  { 6656, 26138, 29608, 32768, 0 },
  { 19328, 23791, 28946, 32768, 0 },
  { 31744, 31984, 32336, 32768, 0 }
}

Default_Palette_Size_5_Y_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 6 ] = {
  { 27904, 29215, 30075, 31190, 32768, 0 },
  { 9728, 22598, 26134, 29425, 32768, 0 },
  { 2688, 30066, 31058, 31933, 32768, 0 },
  { 22015, 25039, 27726, 29932, 32768, 0 },
  { 32383, 32482, 32554, 32660, 32768, 0 }
}

Default_Palette_Size_6_Y_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 7 ] = {
  { 24319, 26299, 27486, 28600, 29804, 32768, 0 },
  { 7935, 18217, 21116, 25440, 28589, 32768, 0 },
  { 6656, 25016, 27105, 28698, 30399, 32768, 0 },
  { 19967, 24117, 26550, 28566, 30224, 32768, 0 },
  { 31359, 31607, 31775, 31977, 32258, 32768, 0 },
}

Default_Palette_Size_7_Y_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 8 ] = {
  { 26368, 27768, 28588, 29274, 29997, 30917, 32768, 0 },
  { 8960, 18260, 20810, 23986, 26627, 28882, 32768, 0 },
  { 7295, 24111, 25836, 27515, 29033, 30769, 32768, 0 },
  { 22016, 25208, 27305, 28159, 29221, 30274, 32768, 0 },
  { 31744, 31932, 32050, 32199, 32335, 32521, 32768, 0 },
}

Default_Palette_Size_8_Y_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 9 ] = {
  { 26624, 27872, 28599, 29153, 29633, 30172, 30841, 32768, 0 },
  { 6655, 17569, 19587, 23345, 25884, 28088, 29678, 32768, 0 },
  { 3584, 27296, 28429, 29158, 30032, 30780, 31572, 32768, 0 },
  { 23551, 25855, 27070, 27893, 28597, 29721, 30970, 32768, 0 },
  { 32128, 32173, 32245, 32337, 32416, 32500, 32609, 32768, 0 }
}
Default_Palette_Size_2_Uv_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 3 ] = {
  { 29824, 32768, 0 },
  { 16384, 32768, 0 },
  { 8832, 32768, 0 },
  { 30720, 32768, 0 },
  { 31744, 32768, 0 }
}

Default_Palette_Size_3_Uv_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 4 ] = {
  { 27648, 30208, 32768, 0 },
  { 14080, 26563, 32768, 0 },
  { 5120, 30932, 32768, 0 },
  { 24448, 27828, 32768, 0 },
  { 31616, 32219, 32768, 0 }
}

Default_Palette_Size_4_Uv_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 5 ] = {
  { 25856, 28259, 30584, 32768, 0 },
  { 11520, 22476, 27944, 32768, 0 },
  { 8064, 26882, 30308, 32768, 0 },
  { 19455, 23823, 29134, 32768, 0 },
  { 30848, 31501, 32174, 32768, 0 },
}

Default_Palette_Size_5_Uv_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 6 ] = {
  { 26751, 28020, 29541, 31230, 32768, 0 },
  { 12032, 26045, 30772, 31497, 32768, 0 },
  { 1280, 32153, 32458, 32560, 32768, 0 },
  { 23424, 24154, 29201, 29856, 32768, 0 },
  { 32256, 32402, 32561, 32682, 32768, 0 }
}

Default_Palette_Size_6_Uv_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 7 ] = {
  { 24576, 26720, 28114, 28950, 31694, 32768, 0 },
  { 7551, 16613, 20462, 25269, 29077, 32768, 0 },
  { 6272, 23039, 25623, 28163, 30861, 32768, 0 },
  { 17024, 18808, 20771, 27941, 29845, 32768, 0 },
  { 31616, 31936, 32079, 32321, 32546, 32768, 0 }
}

Default_Palette_Size_7_Uv_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 8 ] = {
  { 23296, 25590, 27833, 29337, 29954, 31229, 32768, 0 },
  { 7552, 13659, 16570, 21695, 24506, 27701, 32768, 0 },
  { 6911, 24788, 26284, 27753, 29575, 30872, 32768, 0 },
  { 17535, 22236, 24457, 26242, 27363, 30191, 32768, 0 },
  { 30592, 31289, 31745, 31921, 32149, 32321, 32768, 0 }
}

Default_Palette_Size_8_Uv_Color_Cdf[ PALETTE_COLOR_CONTEXTS ][ 9 ] = {
  { 22016, 24242, 25141, 27137, 27797, 29331, 30848, 32768, 0 },
  { 8063, 13564, 16940, 21948, 24568, 25689, 26989, 32768, 0 },
  { 6528, 27028, 27835, 28741, 30031, 31795, 32285, 32768, 0 },
  { 18047, 23797, 25444, 26274, 27111, 27929, 30367, 32768, 0 },
  { 30208, 30628, 31046, 31658, 31762, 32367, 32469, 32768, 0 }
}
Default_Palette_Y_Mode_Cdf[ PALETTE_BLOCK_SIZES ][ PALETTE_Y_MODE_CONTEXTS ][ 3 ] = {
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
  { { 128*240, 32768, 0 }, { 128*180, 32768, 0 }, { 128*100, 32768, 0 } },
}
Default_Palette_Uv_Mode_Cdf[ PALETTE_UV_MODE_CONTEXTS ][ 3 ] = {
  { 128*253, 32768, 0 }, { 128*229, 32768, 0 }
}
Default_Delta_Q_Cdf[ DELTA_Q_SMALL + 2 ] = {
  28160, 32120, 32677, 32768, 0
}
Default_Delta_Lf_Cdf[ DELTA_LF_SMALL + 2 ] = {
  28160, 32120, 32677, 32768, 0
}
Default_Coef_Extra_Bits_Cat1_Cdf[ 3 ] = {
  20352, 32768, 0
}

Default_Coef_Extra_Bits_Cat2_Cdf[ 5 ] = {
  11963, 21121, 27719, 32768, 0
}

Default_Coef_Extra_Bits_Cat3_Cdf[ 9 ] = {
  7001, 12802, 17911, 22144, 25503, 28286, 30737, 32768, 0
}

Default_Coef_Extra_Bits_Cat4_Cdf[ 17 ] = {
  3934,  7460, 10719, 13640, 16203, 18500, 20624, 22528,
  24316, 25919, 27401, 28729, 29894, 30938, 31903, 32768, 0
}

Default_Coef_Extra_Bits_Cat5_S1_Cdf[ 17 ] = {
  2942,  5794,  8473, 11069, 13469, 15795, 17980, 20097,
  21952, 23750, 25439, 27076, 28589, 30056, 31434, 32768, 0
}

Default_Coef_Extra_Bits_Cat5_S2_Cdf[ 3 ] = { 23040, 32768, 0 }

Default_Coef_Extra_Bits_Cat6_S1_Cdf[ 17 ] = {
  2382,  4727,  7036,  9309, 11512, 13681, 15816, 17918,
  19892, 21835, 23748, 25632, 27458, 29255, 31024, 32768, 0
}

Default_Coef_Extra_Bits_Cat6_S2_Cdf[ 17 ] = {
  9314, 15584, 19741, 22540, 25391, 27310, 28583, 29440,
  30493, 31202, 31672, 31988, 32310, 32527, 32671, 32768, 0
}

Default_Coef_Extra_Bits_Cat6_S3_Cdf[ 17 ] = {
  29548, 31129, 31960, 32004, 32473, 32498, 32511, 32512,
  32745, 32757, 32763, 32764, 32765, 32766, 32767, 32768, 0
}

Default_Coef_Extra_Bits_Cat6_S4_Cdf[ 17 ] = {
  32006, 32258, 32510, 32512, 32638, 32639, 32640, 32641,
  32761, 32762, 32763, 32764, 32765, 32766, 32767, 32768, 0
}

Default_Coef_Extra_Bits_Cat6_S5_Cdf[ 5 ] = { 32513, 32641, 32767, 32768, 0 }
Default_Intra_Tx_Type_Set1_Cdf[ TX_SIZES ][ INTRA_MODES ][ 7 ] = {
    {
      { 1024, 28800, 29048, 29296,
        30164, 31466, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 27118, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1152, 25852, 26284, 26717,
        28230, 30499, 32768 },
      { 1024, 2016, 3938, 5860,
        29404, 31086, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 27118, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 4109, 5900, 7691,
        15528, 27380, 32768 },
      { 1280, 4109, 5900, 7691,
        15528, 27380, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
    },
    {
      { 1024, 28800, 29048, 29296,
        30164, 31466, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 27118, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1152, 25852, 26284, 26717,
        28230, 30499, 32768 },
      { 1024, 2016, 3938, 5860,
        29404, 31086, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 27118, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 4109, 5900, 7691,
        15528, 27380, 32768 },
      { 1280, 4109, 5900, 7691,
        15528, 27380, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
    },
    {
      { 1024, 28800, 29048, 29296,
        30164, 31466, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 27118, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1152, 25852, 26284, 26717,
        28230, 30499, 32768 },
      { 1024, 2016, 3938, 5860,
        29404, 31086, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 27118, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 4109, 5900, 7691,
        15528, 27380, 32768 },
      { 1280, 4109, 5900, 7691,
        15528, 27380, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
    },
    {
      { 1024, 28800, 29048, 29296,
        30164, 31466, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 27118, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1152, 25852, 26284, 26717,
        28230, 30499, 32768 },
      { 1024, 2016, 3938, 5860,
        29404, 31086, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 27118, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 4109, 5900, 7691,
        15528, 27380, 32768 },
      { 1280, 4109, 5900, 7691,
        15528, 27380, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
      { 1280, 5216, 6938, 8660,
        10167, 15817, 32768 },
    }
}
Default_Intra_Tx_Type_Set2_Cdf[ TX_SIZES ][ INTRA_MODES ][ 5 ] = {
    {
      { 1024, 28800, 29792, 31280, 32768 },
      { 1280, 5216, 6938, 26310, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1152, 25852, 27581, 30174, 32768 },
      { 1024, 2016, 28924, 30846, 32768 },
      { 1280, 5216, 6938, 26310, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 4109, 13065, 26611, 32768 },
      { 1280, 4109, 13065, 26611, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
    },
    {
      { 1024, 28800, 29792, 31280, 32768 },
      { 1280, 5216, 6938, 26310, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1152, 25852, 27581, 30174, 32768 },
      { 1024, 2016, 28924, 30846, 32768 },
      { 1280, 5216, 6938, 26310, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 4109, 13065, 26611, 32768 },
      { 1280, 4109, 13065, 26611, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
    },
    {
      { 1024, 28800, 29792, 31280, 32768 },
      { 1280, 5216, 6938, 26310, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1152, 25852, 27581, 30174, 32768 },
      { 1024, 2016, 28924, 30846, 32768 },
      { 1280, 5216, 6938, 26310, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 4109, 13065, 26611, 32768 },
      { 1280, 4109, 13065, 26611, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
    },
    {
      { 1024, 28800, 29792, 31280, 32768 },
      { 1280, 5216, 6938, 26310, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1152, 25852, 27581, 30174, 32768 },
      { 1024, 2016, 28924, 30846, 32768 },
      { 1280, 5216, 6938, 26310, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 4109, 13065, 26611, 32768 },
      { 1280, 4109, 13065, 26611, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
      { 1280, 5216, 6938, 13396, 32768 },
    },
}
Default_Inter_Tx_Type_Set1_Cdf[ TX_SIZES ][ 16 ] = {
    { 1280, 1453, 1626, 2277,
      2929, 3580, 4232, 16717,
      19225, 21733, 24241, 26749,
      28253, 29758, 31263, 32768 },
    { 1280, 1453, 1626, 2277,
      2929, 3580, 4232, 16717,
      19225, 21733, 24241, 26749,
      28253, 29758, 31263, 32768 },
    { 1280, 1453, 1626, 2277,
      2929, 3580, 4232, 16717,
      19225, 21733, 24241, 26749,
      28253, 29758, 31263, 32768 },
    { 1280, 1453, 1626, 2277,
      2929, 3580, 4232, 16717,
      19225, 21733, 24241, 26749,
      28253, 29758, 31263, 32768 }
}
Default_Inter_Tx_Type_Set2_Cdf[ TX_SIZES ][ 12 ] = {
    { 1280, 3125, 4970, 17132,
      19575, 22018, 24461, 26904,
      28370, 29836, 31302, 32768 },
    { 1280, 3125, 4970, 17132,
      19575, 22018, 24461, 26904,
      28370, 29836, 31302, 32768 },
    { 1280, 3125, 4970, 17132,
      19575, 22018, 24461, 26904,
      28370, 29836, 31302, 32768 },
    { 1280, 3125, 4970, 17132,
      19575, 22018, 24461, 26904,
      28370, 29836, 31302, 32768 }
}
Default_Inter_Tx_Type_Set3_Cdf[ TX_SIZES ][ 2 ] = {
    { 1536, 32768 },
    { 1536, 32768 },
    { 1536, 32768 },
    { 1536, 32768 }
}
Default_Compound_Type_Cdf[ BLOCK_SIZES ][ COMPOUND_TYPES + 1 ] = {
  { 16384, 24576, 32768, 0 },
  { 32640, 32704, 32768, 0 },
  { 32640, 32704, 32768, 0 },
  { 8448, 13293, 32768, 0 },
  { 9216, 12436, 32768, 0 },
  { 10112, 12679, 32768, 0 },
  { 9088, 10753, 32768, 0 },
  { 10368, 12906, 32768, 0 },
  { 10368, 12643, 32768, 0 },
  { 8832, 10609, 32768, 0 },
  { 13312, 13388, 32768, 0 },
  { 12672, 12751, 32768, 0 },
  { 9600, 9691, 32768, 0 },
  { 32640, 32641, 32768, 0 },
  { 32640, 32641, 32768, 0 },
  { 32640, 32641, 32768, 0 },
  { 16384, 24576, 32768, 0 },
  { 16384, 24576, 32768, 0 },
  { 16384, 24576, 32768, 0 },
  { 16384, 24576, 32768, 0 },
  { 26624, 26648, 32768, 0 },
  { 26624, 26648, 32768, 0 },
  { 26624, 26648, 32768, 0 },
  { 26624, 26648, 32768, 0 },
}
Default_Inter_Intra_Cdf[ BLOCK_SIZE_GROUPS ][ 3 ] = {
  {128*128, 32768, 0},
  {226*128, 32768, 0},
  {244*128, 32768, 0},
  {254*128, 32768, 0}
}
Default_Inter_Intra_Mode_Cdf[ BLOCK_SIZE_GROUPS ][ INTERINTRA_MODES + 1 ] = {
  { 16384, 24576, 28672, 32768, 0 },
  { 3072, 7016, 18987, 32768, 0 },
  { 4864, 8461, 17481, 32768, 0 },
  { 6528, 8681, 19031, 32768, 0 }
}
Default_Wedge_Inter_Intra_Cdf[ BLOCK_SIZES ][ 3 ] = {
  { 128*128, 32768, 0 },
  { 128*128, 32768, 0 },
  { 128*128, 32768, 0 },
  { 194*128, 32768, 0 },
  { 213*128, 32768, 0 },
  { 217*128, 32768, 0 },
  { 222*128, 32768, 0 },
  { 224*128, 32768, 0 },
  { 226*128, 32768, 0 },
  { 220*128, 32768, 0 },
  { 128*128, 32768, 0 },
  { 128*128, 32768, 0 },
  { 128*128, 32768, 0 },
  { 208*128, 32768, 0 },
  { 208*128, 32768, 0 },
  { 208*128, 32768, 0 },
  { 208*128, 32768, 0 },
  { 208*128, 32768, 0 },
  { 208*128, 32768, 0 },
  { 208*128, 32768, 0 },
  { 255*128, 32768, 0 },
  { 255*128, 32768, 0 },
  { 255*128, 32768, 0 },
  { 255*128, 32768, 0 },
}
Default_Use_Obmc_Cdf[ BLOCK_SIZES ][ 3 ] = {
  { 128*128, 32768, 0 },
  { 128*128, 32768, 0 },
  { 128*128, 32768, 0 },
  { 45*128, 32768, 0 },
  { 79*128, 32768, 0 },
  { 75*128, 32768, 0 },
  { 130*128, 32768, 0 },
  { 141*128, 32768, 0 },
  { 144*128, 32768, 0 },
  { 208*128, 32768, 0 },
  { 201*128, 32768, 0 },
  { 186*128, 32768, 0 },
  { 231*128, 32768, 0 },
  { 252*128, 32768, 0 },
  { 252*128, 32768, 0 },
  { 252*128, 32768, 0 },
  { 208 * 128, 32768, 0 },
  { 208 * 128, 32768, 0 },
  { 208 * 128, 32768, 0 },
  { 208 * 128, 32768, 0 },
  { 208 * 128, 32768, 0 },
  { 208 * 128, 32768, 0 },
  { 252 * 128, 32768, 0 },
  { 252 * 128, 32768, 0 },
};
Default_Comp_Ref_Type_Cdf[ COMP_REF_TYPE_CONTEXTS ][ 3 ] = {
  { 8*128, 32768, 0 }, { 20*128, 32768, 0 }, { 78*128, 32768, 0 },
  { 91*128, 32768, 0 }, { 194*128, 32768, 0 }
}
Default_Uni_Comp_Ref_Cdf[ UNI_COMP_REF_CONTEXTS ][ UNIDIR_COMP_REFS - 1 ][ 3 ] = {
  { { 88*128, 32768, 0 }, { 30*128, 32768, 0 }, { 28*128, 32768, 0 } },
  { { 218*128, 32768, 0 }, { 97*128, 32768, 0 }, { 105*128, 32768, 0 } },
  { { 254*128, 32768, 0 }, { 180*128, 32768, 0 }, { 196*128, 32768, 0 } }
}
Default_Cfl_Sign_Cdf[ CFL_JOINT_SIGNS + 1 ] = {
  1892, 2229, 11464, 14116, 25661, 26409, 32508, 32768, 0
}
Default_Cfl_Alpha_Cdf[ CFL_ALPHA_CONTEXTS ][ CFL_ALPHABET_SIZE + 1 ] = {
  { 16215, 27740, 31726, 32606, 32736, 32751, 32757, 32759,
    32761, 32762, 32763, 32764, 32765, 32766, 32767, 32768, 0 },
  { 15213, 24615, 29704, 31974, 32545, 32673, 32713, 32746,
    32753, 32756, 32758, 32761, 32763, 32764, 32766, 32768, 0 },
  { 13250, 24677, 29113, 31666, 32408, 32578, 32628, 32711,
    32730, 32738, 32744, 32749, 32752, 32756, 32759, 32768, 0 },
  { 24593, 30787, 32062, 32495, 32656, 32707, 32735, 32747,
    32752, 32757, 32760, 32763, 32764, 32765, 32767, 32768, 0 },
  { 19883, 27419, 30100, 31392, 31896, 32184, 32299, 32511,
    32568, 32602, 32628, 32664, 32680, 32691, 32708, 32768, 0 },
  { 15939, 24151, 27754, 29680, 30651, 31267, 31527, 31868,
    32001, 32090, 32181, 32284, 32314, 32366, 32486, 32768, 0 }
}

Quantizer Matrix Tables

Qm_Offset[ TX_SIZES_ALL ] = { 0, 16, 80, 336, 1360, 1392, 1424, 1552, 1680, 2192 }
Quantizer_Matrix[ 15 ][ 2 ][ QM_TOTAL_SIZE ] = {
  {
      { /* Luma */
        /* Size 4x4 */
        32, 43, 73, 97, 43, 67, 94, 110, 73, 94, 137, 150, 97, 110, 150, 200,
        /* Size 8x8 */
        32, 32, 38, 51, 68, 84, 95, 109, 32, 35, 40, 49, 63, 76, 89, 102, 38,
        40, 54, 65, 78, 91, 98, 106, 51, 49, 65, 82, 97, 111, 113, 121, 68, 63,
        78, 97, 117, 134, 138, 142, 84, 76, 91, 111, 134, 152, 159, 168, 95, 89,
        98, 113, 138, 159, 183, 199, 109, 102, 106, 121, 142, 168, 199, 220,
        /* Size 16x16 */
        32, 31, 31, 34, 36, 44, 48, 59, 65, 80, 83, 91, 97, 104, 111, 119, 31,
        32, 32, 33, 34, 41, 44, 54, 59, 72, 75, 83, 90, 97, 104, 112, 31, 32,
        33, 35, 36, 42, 45, 54, 59, 71, 74, 81, 86, 93, 100, 107, 34, 33, 35,
        39, 42, 47, 51, 58, 63, 74, 76, 81, 84, 90, 97, 105, 36, 34, 36, 42, 48,
        54, 57, 64, 68, 79, 81, 88, 91, 96, 102, 105, 44, 41, 42, 47, 54, 63,
        67, 75, 79, 90, 92, 95, 100, 102, 109, 112, 48, 44, 45, 51, 57, 67, 71,
        80, 85, 96, 99, 107, 108, 111, 117, 120, 59, 54, 54, 58, 64, 75, 80, 92,
        98, 110, 113, 115, 116, 122, 125, 130, 65, 59, 59, 63, 68, 79, 85, 98,
        105, 118, 121, 127, 130, 134, 135, 140, 80, 72, 71, 74, 79, 90, 96, 110,
        118, 134, 137, 140, 143, 144, 146, 152, 83, 75, 74, 76, 81, 92, 99, 113,
        121, 137, 140, 151, 152, 155, 158, 165, 91, 83, 81, 81, 88, 95, 107,
        115, 127, 140, 151, 159, 166, 169, 173, 179, 97, 90, 86, 84, 91, 100,
        108, 116, 130, 143, 152, 166, 174, 182, 189, 193, 104, 97, 93, 90, 96,
        102, 111, 122, 134, 144, 155, 169, 182, 191, 200, 210, 111, 104, 100,
        97, 102, 109, 117, 125, 135, 146, 158, 173, 189, 200, 210, 220, 119,
        112, 107, 105, 105, 112, 120, 130, 140, 152, 165, 179, 193, 210, 220,
        231,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 32, 34, 35, 36, 39, 44, 46, 48, 54, 59, 62, 65, 71,
        80, 81, 83, 88, 91, 94, 97, 101, 104, 107, 111, 115, 119, 123, 31, 32,
        32, 32, 32, 32, 34, 34, 35, 38, 42, 44, 46, 51, 56, 59, 62, 68, 76, 77,
        78, 84, 86, 89, 92, 95, 99, 102, 105, 109, 113, 116, 31, 32, 32, 32, 32,
        32, 33, 34, 34, 37, 41, 42, 44, 49, 54, 56, 59, 65, 72, 73, 75, 80, 83,
        86, 90, 93, 97, 101, 104, 108, 112, 116, 31, 32, 32, 32, 33, 33, 34, 35,
        35, 38, 41, 43, 45, 49, 54, 56, 59, 64, 72, 73, 74, 79, 82, 85, 88, 91,
        94, 97, 101, 104, 107, 111, 31, 32, 32, 33, 33, 34, 35, 36, 36, 39, 42,
        44, 45, 50, 54, 56, 59, 64, 71, 72, 74, 78, 81, 84, 86, 89, 93, 96, 100,
        104, 107, 111, 32, 32, 32, 33, 34, 35, 37, 37, 38, 40, 42, 44, 46, 49,
        53, 55, 58, 63, 69, 70, 72, 76, 79, 82, 85, 89, 93, 96, 99, 102, 106,
        109, 34, 34, 33, 34, 35, 37, 39, 41, 42, 45, 47, 49, 51, 54, 58, 60, 63,
        68, 74, 75, 76, 80, 81, 82, 84, 87, 90, 93, 97, 101, 105, 110, 35, 34,
        34, 35, 36, 37, 41, 43, 45, 47, 50, 52, 53, 57, 61, 63, 65, 70, 76, 77,
        79, 82, 84, 86, 89, 91, 92, 93, 96, 100, 103, 107, 36, 35, 34, 35, 36,
        38, 42, 45, 48, 50, 54, 55, 57, 60, 64, 66, 68, 73, 79, 80, 81, 85, 88,
        90, 91, 93, 96, 99, 102, 103, 105, 107, 39, 38, 37, 38, 39, 40, 45, 47,
        50, 54, 58, 59, 61, 65, 69, 71, 73, 78, 84, 85, 86, 91, 92, 92, 95, 98,
        100, 101, 103, 106, 110, 114, 44, 42, 41, 41, 42, 42, 47, 50, 54, 58,
        63, 65, 67, 71, 75, 77, 79, 84, 90, 91, 92, 95, 95, 97, 100, 101, 102,
        105, 109, 111, 112, 114, 46, 44, 42, 43, 44, 44, 49, 52, 55, 59, 65, 67,
        69, 74, 78, 80, 82, 87, 93, 94, 95, 98, 100, 103, 102, 105, 108, 110,
        111, 113, 117, 121, 48, 46, 44, 45, 45, 46, 51, 53, 57, 61, 67, 69, 71,
        76, 80, 83, 85, 90, 96, 97, 99, 103, 107, 105, 108, 111, 111, 113, 117,
        119, 120, 122, 54, 51, 49, 49, 50, 49, 54, 57, 60, 65, 71, 74, 76, 82,
        87, 89, 92, 97, 104, 105, 106, 111, 110, 111, 114, 113, 116, 120, 120,
        121, 125, 130, 59, 56, 54, 54, 54, 53, 58, 61, 64, 69, 75, 78, 80, 87,
        92, 95, 98, 103, 110, 111, 113, 115, 115, 119, 116, 120, 122, 122, 125,
        129, 130, 130, 62, 59, 56, 56, 56, 55, 60, 63, 66, 71, 77, 80, 83, 89,
        95, 98, 101, 107, 114, 115, 117, 119, 123, 121, 125, 126, 125, 129, 131,
        131, 135, 140, 65, 62, 59, 59, 59, 58, 63, 65, 68, 73, 79, 82, 85, 92,
        98, 101, 105, 111, 118, 119, 121, 126, 127, 128, 130, 130, 134, 133,
        135, 140, 140, 140, 71, 68, 65, 64, 64, 63, 68, 70, 73, 78, 84, 87, 90,
        97, 103, 107, 111, 117, 125, 126, 128, 134, 132, 136, 133, 138, 137,
        140, 143, 142, 145, 150, 80, 76, 72, 72, 71, 69, 74, 76, 79, 84, 90, 93,
        96, 104, 110, 114, 118, 125, 134, 135, 137, 139, 140, 139, 143, 142,
        144, 146, 146, 151, 152, 151, 81, 77, 73, 73, 72, 70, 75, 77, 80, 85,
        91, 94, 97, 105, 111, 115, 119, 126, 135, 137, 138, 144, 147, 146, 148,
        149, 151, 150, 156, 155, 157, 163, 83, 78, 75, 74, 74, 72, 76, 79, 81,
        86, 92, 95, 99, 106, 113, 117, 121, 128, 137, 138, 140, 147, 151, 156,
        152, 157, 155, 161, 158, 162, 165, 164, 88, 84, 80, 79, 78, 76, 80, 82,
        85, 91, 95, 98, 103, 111, 115, 119, 126, 134, 139, 144, 147, 152, 154,
        158, 163, 159, 165, 163, 168, 168, 169, 176, 91, 86, 83, 82, 81, 79, 81,
        84, 88, 92, 95, 100, 107, 110, 115, 123, 127, 132, 140, 147, 151, 154,
        159, 161, 166, 171, 169, 173, 173, 176, 179, 177, 94, 89, 86, 85, 84,
        82, 82, 86, 90, 92, 97, 103, 105, 111, 119, 121, 128, 136, 139, 146,
        156, 158, 161, 166, 168, 174, 179, 178, 180, 183, 183, 190, 97, 92, 90,
        88, 86, 85, 84, 89, 91, 95, 100, 102, 108, 114, 116, 125, 130, 133, 143,
        148, 152, 163, 166, 168, 174, 176, 182, 187, 189, 188, 193, 191, 101,
        95, 93, 91, 89, 89, 87, 91, 93, 98, 101, 105, 111, 113, 120, 126, 130,
        138, 142, 149, 157, 159, 171, 174, 176, 183, 184, 191, 195, 199, 197,
        204, 104, 99, 97, 94, 93, 93, 90, 92, 96, 100, 102, 108, 111, 116, 122,
        125, 134, 137, 144, 151, 155, 165, 169, 179, 182, 184, 191, 193, 200,
        204, 210, 206, 107, 102, 101, 97, 96, 96, 93, 93, 99, 101, 105, 110,
        113, 120, 122, 129, 133, 140, 146, 150, 161, 163, 173, 178, 187, 191,
        193, 200, 202, 210, 214, 222, 111, 105, 104, 101, 100, 99, 97, 96, 102,
        103, 109, 111, 117, 120, 125, 131, 135, 143, 146, 156, 158, 168, 173,
        180, 189, 195, 200, 202, 210, 212, 220, 224, 115, 109, 108, 104, 104,
        102, 101, 100, 103, 106, 111, 113, 119, 121, 129, 131, 140, 142, 151,
        155, 162, 168, 176, 183, 188, 199, 204, 210, 212, 220, 222, 230, 119,
        113, 112, 107, 107, 106, 105, 103, 105, 110, 112, 117, 120, 125, 130,
        135, 140, 145, 152, 157, 165, 169, 179, 183, 193, 197, 210, 214, 220,
        222, 231, 232, 123, 116, 116, 111, 111, 109, 110, 107, 107, 114, 114,
        121, 122, 130, 130, 140, 140, 150, 151, 163, 164, 176, 177, 190, 191,
        204, 206, 222, 224, 230, 232, 242,
        /* Size 4x8 */
        32, 42, 75, 91, 33, 42, 69, 86, 37, 58, 84, 91, 49, 71, 103, 110, 65,
        84, 125, 128, 80, 97, 142, 152, 91, 100, 145, 178, 104, 112, 146, 190,
        /* Size 8x4 */
        32, 33, 37, 49, 65, 80, 91, 104, 42, 42, 58, 71, 84, 97, 100, 112, 75,
        69, 84, 103, 125, 142, 145, 146, 91, 86, 91, 110, 128, 152, 178, 190,
        /* Size 8x16 */
        32, 32, 36, 53, 65, 87, 93, 99, 31, 33, 34, 49, 59, 78, 86, 93, 32, 34,
        36, 50, 59, 77, 82, 89, 34, 37, 42, 54, 63, 79, 80, 88, 36, 38, 48, 60,
        68, 84, 86, 90, 44, 43, 53, 71, 79, 95, 94, 97, 48, 46, 56, 76, 85, 102,
        105, 105, 58, 54, 63, 87, 98, 116, 112, 115, 65, 58, 68, 92, 105, 124,
        122, 124, 79, 70, 79, 104, 118, 141, 135, 135, 82, 72, 81, 106, 121,
        144, 149, 146, 91, 80, 88, 106, 130, 148, 162, 159, 97, 86, 94, 107,
        128, 157, 167, 171, 103, 93, 98, 114, 131, 150, 174, 186, 110, 100, 101,
        117, 138, 161, 183, 193, 118, 107, 105, 118, 136, 157, 182, 203,
        /* Size 16x8 */
        32, 31, 32, 34, 36, 44, 48, 58, 65, 79, 82, 91, 97, 103, 110, 118, 32,
        33, 34, 37, 38, 43, 46, 54, 58, 70, 72, 80, 86, 93, 100, 107, 36, 34,
        36, 42, 48, 53, 56, 63, 68, 79, 81, 88, 94, 98, 101, 105, 53, 49, 50,
        54, 60, 71, 76, 87, 92, 104, 106, 106, 107, 114, 117, 118, 65, 59, 59,
        63, 68, 79, 85, 98, 105, 118, 121, 130, 128, 131, 138, 136, 87, 78, 77,
        79, 84, 95, 102, 116, 124, 141, 144, 148, 157, 150, 161, 157, 93, 86,
        82, 80, 86, 94, 105, 112, 122, 135, 149, 162, 167, 174, 183, 182, 99,
        93, 89, 88, 90, 97, 105, 115, 124, 135, 146, 159, 171, 186, 193, 203,
        /* Size 16x32 */
        32, 31, 32, 34, 36, 44, 53, 59, 65, 79, 87, 90, 93, 96, 99, 102, 31, 32,
        32, 34, 35, 42, 51, 56, 62, 75, 82, 85, 88, 91, 94, 97, 31, 32, 33, 33,
        34, 41, 49, 54, 59, 72, 78, 82, 86, 90, 93, 97, 31, 32, 33, 34, 35, 41,
        49, 54, 59, 71, 78, 81, 84, 87, 90, 93, 32, 32, 34, 35, 36, 42, 50, 54,
        59, 71, 77, 80, 82, 86, 89, 93, 32, 33, 35, 37, 38, 42, 49, 53, 58, 69,
        75, 78, 82, 86, 89, 92, 34, 34, 37, 39, 42, 48, 54, 58, 63, 73, 79, 78,
        80, 83, 88, 92, 35, 34, 37, 41, 45, 50, 57, 61, 65, 76, 82, 83, 84, 84,
        87, 90, 36, 34, 38, 43, 48, 54, 60, 64, 68, 78, 84, 87, 86, 89, 90, 90,
        39, 37, 40, 45, 50, 58, 65, 69, 73, 84, 89, 89, 91, 91, 93, 96, 44, 41,
        43, 48, 53, 63, 71, 75, 79, 90, 95, 93, 94, 95, 97, 97, 46, 43, 44, 49,
        55, 65, 73, 78, 82, 93, 98, 100, 98, 100, 99, 103, 48, 45, 46, 51, 56,
        67, 76, 80, 85, 96, 102, 102, 105, 102, 105, 104, 53, 49, 50, 54, 60,
        71, 82, 87, 92, 103, 109, 107, 107, 110, 107, 111, 58, 54, 54, 58, 63,
        75, 87, 92, 98, 110, 116, 115, 112, 111, 115, 112, 61, 57, 56, 60, 66,
        77, 89, 95, 101, 114, 120, 118, 119, 118, 116, 120, 65, 60, 58, 63, 68,
        79, 92, 98, 105, 118, 124, 123, 122, 123, 124, 121, 71, 65, 63, 68, 73,
        84, 97, 103, 111, 125, 132, 132, 130, 128, 127, 130, 79, 72, 70, 74, 79,
        90, 104, 110, 118, 133, 141, 136, 135, 135, 135, 131, 81, 74, 71, 75,
        80, 91, 105, 112, 119, 135, 142, 140, 140, 138, 139, 142, 82, 75, 72,
        76, 81, 92, 106, 113, 121, 136, 144, 151, 149, 149, 146, 143, 88, 80,
        77, 80, 85, 97, 108, 115, 126, 142, 149, 153, 153, 152, 152, 154, 91,
        83, 80, 81, 88, 100, 106, 114, 130, 142, 148, 155, 162, 160, 159, 155,
        94, 85, 83, 82, 91, 100, 105, 118, 131, 137, 153, 160, 165, 167, 166,
        168, 97, 88, 86, 85, 94, 100, 107, 123, 128, 140, 157, 161, 167, 173,
        171, 169, 100, 91, 89, 87, 97, 100, 111, 121, 127, 145, 152, 164, 173,
        178, 182, 181, 103, 94, 93, 90, 98, 101, 114, 120, 131, 144, 150, 170,
        174, 180, 186, 183, 107, 97, 96, 93, 100, 104, 117, 119, 136, 142, 155,
        168, 177, 187, 191, 198, 110, 101, 100, 97, 101, 108, 117, 123, 138,
        141, 161, 165, 183, 188, 193, 200, 114, 104, 104, 100, 103, 112, 117,
        127, 137, 146, 159, 167, 185, 190, 201, 206, 118, 108, 107, 103, 105,
        115, 118, 131, 136, 151, 157, 172, 182, 197, 203, 208, 122, 111, 111,
        107, 107, 119, 119, 136, 136, 156, 156, 178, 179, 203, 204, 217,
        /* Size 32x16 */
        32, 31, 31, 31, 32, 32, 34, 35, 36, 39, 44, 46, 48, 53, 58, 61, 65, 71,
        79, 81, 82, 88, 91, 94, 97, 100, 103, 107, 110, 114, 118, 122, 31, 32,
        32, 32, 32, 33, 34, 34, 34, 37, 41, 43, 45, 49, 54, 57, 60, 65, 72, 74,
        75, 80, 83, 85, 88, 91, 94, 97, 101, 104, 108, 111, 32, 32, 33, 33, 34,
        35, 37, 37, 38, 40, 43, 44, 46, 50, 54, 56, 58, 63, 70, 71, 72, 77, 80,
        83, 86, 89, 93, 96, 100, 104, 107, 111, 34, 34, 33, 34, 35, 37, 39, 41,
        43, 45, 48, 49, 51, 54, 58, 60, 63, 68, 74, 75, 76, 80, 81, 82, 85, 87,
        90, 93, 97, 100, 103, 107, 36, 35, 34, 35, 36, 38, 42, 45, 48, 50, 53,
        55, 56, 60, 63, 66, 68, 73, 79, 80, 81, 85, 88, 91, 94, 97, 98, 100,
        101, 103, 105, 107, 44, 42, 41, 41, 42, 42, 48, 50, 54, 58, 63, 65, 67,
        71, 75, 77, 79, 84, 90, 91, 92, 97, 100, 100, 100, 100, 101, 104, 108,
        112, 115, 119, 53, 51, 49, 49, 50, 49, 54, 57, 60, 65, 71, 73, 76, 82,
        87, 89, 92, 97, 104, 105, 106, 108, 106, 105, 107, 111, 114, 117, 117,
        117, 118, 119, 59, 56, 54, 54, 54, 53, 58, 61, 64, 69, 75, 78, 80, 87,
        92, 95, 98, 103, 110, 112, 113, 115, 114, 118, 123, 121, 120, 119, 123,
        127, 131, 136, 65, 62, 59, 59, 59, 58, 63, 65, 68, 73, 79, 82, 85, 92,
        98, 101, 105, 111, 118, 119, 121, 126, 130, 131, 128, 127, 131, 136,
        138, 137, 136, 136, 79, 75, 72, 71, 71, 69, 73, 76, 78, 84, 90, 93, 96,
        103, 110, 114, 118, 125, 133, 135, 136, 142, 142, 137, 140, 145, 144,
        142, 141, 146, 151, 156, 87, 82, 78, 78, 77, 75, 79, 82, 84, 89, 95, 98,
        102, 109, 116, 120, 124, 132, 141, 142, 144, 149, 148, 153, 157, 152,
        150, 155, 161, 159, 157, 156, 90, 85, 82, 81, 80, 78, 78, 83, 87, 89,
        93, 100, 102, 107, 115, 118, 123, 132, 136, 140, 151, 153, 155, 160,
        161, 164, 170, 168, 165, 167, 172, 178, 93, 88, 86, 84, 82, 82, 80, 84,
        86, 91, 94, 98, 105, 107, 112, 119, 122, 130, 135, 140, 149, 153, 162,
        165, 167, 173, 174, 177, 183, 185, 182, 179, 96, 91, 90, 87, 86, 86, 83,
        84, 89, 91, 95, 100, 102, 110, 111, 118, 123, 128, 135, 138, 149, 152,
        160, 167, 173, 178, 180, 187, 188, 190, 197, 203, 99, 94, 93, 90, 89,
        89, 88, 87, 90, 93, 97, 99, 105, 107, 115, 116, 124, 127, 135, 139, 146,
        152, 159, 166, 171, 182, 186, 191, 193, 201, 203, 204, 102, 97, 97, 93,
        93, 92, 92, 90, 90, 96, 97, 103, 104, 111, 112, 120, 121, 130, 131, 142,
        143, 154, 155, 168, 169, 181, 183, 198, 200, 206, 208, 217 },
      { /* Chroma */
        /* Size 4x4 */
        35, 46, 57, 66, 46, 60, 69, 71, 57, 69, 90, 90, 66, 71, 90, 109,
        /* Size 8x8 */
        31, 38, 47, 50, 57, 63, 67, 71, 38, 47, 46, 47, 52, 57, 62, 67, 47, 46,
        54, 57, 61, 66, 67, 68, 50, 47, 57, 66, 72, 77, 75, 75, 57, 52, 61, 72,
        82, 88, 86, 84, 63, 57, 66, 77, 88, 96, 95, 95, 67, 62, 67, 75, 86, 95,
        104, 107, 71, 67, 68, 75, 84, 95, 107, 113,
        /* Size 16x16 */
        32, 30, 33, 41, 49, 49, 50, 54, 57, 63, 65, 68, 70, 72, 74, 76, 30, 32,
        35, 42, 46, 45, 46, 49, 52, 57, 58, 62, 64, 67, 70, 72, 33, 35, 39, 45,
        47, 45, 46, 49, 51, 56, 57, 60, 62, 64, 66, 69, 41, 42, 45, 48, 50, 49,
        50, 52, 53, 57, 58, 59, 60, 61, 64, 67, 49, 46, 47, 50, 53, 53, 54, 55,
        56, 60, 61, 64, 64, 65, 66, 66, 49, 45, 45, 49, 53, 58, 60, 62, 63, 67,
        68, 67, 69, 68, 70, 70, 50, 46, 46, 50, 54, 60, 61, 65, 67, 71, 71, 74,
        73, 73, 74, 74, 54, 49, 49, 52, 55, 62, 65, 71, 73, 78, 79, 78, 77, 78,
        78, 78, 57, 52, 51, 53, 56, 63, 67, 73, 76, 82, 83, 84, 84, 84, 82, 83,
        63, 57, 56, 57, 60, 67, 71, 78, 82, 89, 90, 90, 89, 88, 87, 88, 65, 58,
        57, 58, 61, 68, 71, 79, 83, 90, 91, 94, 93, 93, 92, 93, 68, 62, 60, 59,
        64, 67, 74, 78, 84, 90, 94, 98, 99, 98, 98, 98, 70, 64, 62, 60, 64, 69,
        73, 77, 84, 89, 93, 99, 102, 103, 104, 104, 72, 67, 64, 61, 65, 68, 73,
        78, 84, 88, 93, 98, 103, 106, 108, 109, 74, 70, 66, 64, 66, 70, 74, 78,
        82, 87, 92, 98, 104, 108, 111, 112, 76, 72, 69, 67, 66, 70, 74, 78, 83,
        88, 93, 98, 104, 109, 112, 116,
        /* Size 32x32 */
        32, 31, 30, 32, 33, 36, 41, 45, 49, 48, 49, 50, 50, 52, 54, 56, 57, 60,
        63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 31, 31, 31, 33,
        34, 38, 42, 45, 47, 47, 47, 47, 48, 50, 52, 53, 54, 57, 60, 61, 61, 63,
        64, 65, 66, 67, 68, 69, 70, 71, 72, 74, 30, 31, 32, 33, 35, 40, 42, 44,
        46, 45, 45, 45, 46, 47, 49, 51, 52, 54, 57, 58, 58, 61, 62, 63, 64, 66,
        67, 68, 70, 71, 72, 74, 32, 33, 33, 35, 37, 41, 43, 45, 47, 46, 45, 46,
        46, 47, 49, 50, 51, 54, 57, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68,
        69, 70, 33, 34, 35, 37, 39, 43, 45, 46, 47, 46, 45, 46, 46, 47, 49, 50,
        51, 53, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 36, 38,
        40, 41, 43, 47, 47, 47, 48, 46, 45, 46, 46, 47, 48, 49, 50, 52, 54, 55,
        55, 57, 58, 59, 61, 62, 64, 65, 66, 67, 68, 69, 41, 42, 42, 43, 45, 47,
        48, 49, 50, 49, 49, 49, 50, 50, 52, 52, 53, 55, 57, 58, 58, 60, 59, 59,
        60, 61, 61, 63, 64, 66, 67, 69, 45, 45, 44, 45, 46, 47, 49, 50, 51, 51,
        51, 51, 52, 52, 53, 54, 55, 57, 59, 59, 60, 61, 61, 62, 63, 63, 63, 63,
        63, 64, 65, 66, 49, 47, 46, 47, 47, 48, 50, 51, 53, 53, 53, 54, 54, 54,
        55, 56, 56, 58, 60, 61, 61, 63, 64, 64, 64, 64, 65, 66, 66, 66, 66, 66,
        48, 47, 45, 46, 46, 46, 49, 51, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61,
        63, 64, 64, 66, 66, 65, 66, 67, 67, 67, 67, 68, 69, 70, 49, 47, 45, 45,
        45, 45, 49, 51, 53, 55, 58, 59, 60, 61, 62, 63, 63, 65, 67, 67, 68, 69,
        67, 68, 69, 68, 68, 69, 70, 70, 70, 70, 50, 47, 45, 46, 46, 46, 49, 51,
        54, 56, 59, 60, 60, 62, 64, 64, 65, 67, 69, 69, 70, 70, 71, 71, 70, 70,
        71, 71, 71, 71, 72, 74, 50, 48, 46, 46, 46, 46, 50, 52, 54, 56, 60, 60,
        61, 63, 65, 66, 67, 68, 71, 71, 71, 73, 74, 72, 73, 74, 73, 73, 74, 74,
        74, 74, 52, 50, 47, 47, 47, 47, 50, 52, 54, 57, 61, 62, 63, 66, 68, 69,
        70, 72, 75, 75, 75, 77, 75, 75, 76, 75, 75, 76, 75, 75, 76, 77, 54, 52,
        49, 49, 49, 48, 52, 53, 55, 58, 62, 64, 65, 68, 71, 72, 73, 75, 78, 78,
        79, 79, 78, 79, 77, 78, 78, 77, 78, 79, 78, 78, 56, 53, 51, 50, 50, 49,
        52, 54, 56, 59, 63, 64, 66, 69, 72, 73, 75, 77, 80, 80, 81, 81, 82, 80,
        81, 81, 79, 81, 80, 79, 81, 82, 57, 54, 52, 51, 51, 50, 53, 55, 56, 60,
        63, 65, 67, 70, 73, 75, 76, 79, 82, 82, 83, 85, 84, 83, 84, 83, 84, 82,
        82, 84, 83, 82, 60, 57, 54, 54, 53, 52, 55, 57, 58, 61, 65, 67, 68, 72,
        75, 77, 79, 82, 85, 85, 86, 88, 86, 87, 85, 86, 85, 85, 86, 84, 85, 86,
        63, 60, 57, 57, 56, 54, 57, 59, 60, 63, 67, 69, 71, 75, 78, 80, 82, 85,
        89, 89, 90, 90, 90, 89, 89, 88, 88, 88, 87, 88, 88, 87, 64, 61, 58, 57,
        57, 55, 58, 59, 61, 64, 67, 69, 71, 75, 78, 80, 82, 85, 89, 90, 91, 92,
        93, 92, 92, 91, 91, 90, 91, 90, 90, 92, 65, 61, 58, 58, 57, 55, 58, 60,
        61, 64, 68, 70, 71, 75, 79, 81, 83, 86, 90, 91, 91, 94, 94, 96, 93, 94,
        93, 94, 92, 93, 93, 92, 67, 63, 61, 60, 59, 57, 60, 61, 63, 66, 69, 70,
        73, 77, 79, 81, 85, 88, 90, 92, 94, 96, 96, 97, 98, 95, 97, 95, 96, 95,
        95, 96, 68, 64, 62, 61, 60, 58, 59, 61, 64, 66, 67, 71, 74, 75, 78, 82,
        84, 86, 90, 93, 94, 96, 98, 98, 99, 100, 98, 99, 98, 98, 98, 97, 69, 65,
        63, 62, 61, 59, 59, 62, 64, 65, 68, 71, 72, 75, 79, 80, 83, 87, 89, 92,
        96, 97, 98, 100, 100, 101, 102, 101, 101, 101, 100, 102, 70, 66, 64, 63,
        62, 61, 60, 63, 64, 66, 69, 70, 73, 76, 77, 81, 84, 85, 89, 92, 93, 98,
        99, 100, 102, 102, 103, 104, 104, 103, 104, 102, 71, 67, 66, 64, 63, 62,
        61, 63, 64, 67, 68, 70, 74, 75, 78, 81, 83, 86, 88, 91, 94, 95, 100,
        101, 102, 104, 104, 105, 106, 107, 105, 107, 72, 68, 67, 65, 64, 64, 61,
        63, 65, 67, 68, 71, 73, 75, 78, 79, 84, 85, 88, 91, 93, 97, 98, 102,
        103, 104, 106, 106, 108, 108, 109, 107, 73, 69, 68, 66, 65, 65, 63, 63,
        66, 67, 69, 71, 73, 76, 77, 81, 82, 85, 88, 90, 94, 95, 99, 101, 104,
        105, 106, 109, 108, 110, 111, 112, 74, 70, 70, 67, 66, 66, 64, 63, 66,
        67, 70, 71, 74, 75, 78, 80, 82, 86, 87, 91, 92, 96, 98, 101, 104, 106,
        108, 108, 111, 111, 112, 113, 75, 71, 71, 68, 68, 67, 66, 64, 66, 68,
        70, 71, 74, 75, 79, 79, 84, 84, 88, 90, 93, 95, 98, 101, 103, 107, 108,
        110, 111, 113, 113, 115, 76, 72, 72, 69, 69, 68, 67, 65, 66, 69, 70, 72,
        74, 76, 78, 81, 83, 85, 88, 90, 93, 95, 98, 100, 104, 105, 109, 111,
        112, 113, 116, 115, 78, 74, 74, 70, 70, 69, 69, 66, 66, 70, 70, 74, 74,
        77, 78, 82, 82, 86, 87, 92, 92, 96, 97, 102, 102, 107, 107, 112, 113,
        115, 115, 118,
        /* Size 4x8 */
        31, 47, 60, 66, 40, 45, 54, 61, 46, 56, 64, 64, 48, 61, 75, 73, 54, 65,
        85, 82, 61, 69, 92, 92, 64, 68, 90, 102, 68, 71, 87, 105,
        /* Size 8x4 */
        31, 40, 46, 48, 54, 61, 64, 68, 47, 45, 56, 61, 65, 69, 68, 71, 60, 54,
        64, 75, 85, 92, 90, 87, 66, 61, 64, 73, 82, 92, 102, 105,
        /* Size 8x16 */
        32, 37, 48, 52, 57, 66, 68, 71, 30, 40, 46, 48, 52, 60, 63, 66, 33, 43,
        47, 47, 51, 59, 60, 63, 42, 47, 50, 50, 53, 60, 59, 62, 49, 48, 53, 54,
        57, 62, 62, 62, 49, 46, 53, 61, 64, 69, 66, 66, 50, 46, 54, 64, 67, 73,
        72, 70, 54, 49, 55, 68, 73, 80, 76, 75, 57, 50, 56, 70, 76, 84, 80, 79,
        63, 55, 60, 75, 82, 92, 87, 84, 64, 56, 61, 75, 83, 93, 93, 89, 68, 59,
        64, 74, 86, 94, 98, 94, 70, 62, 66, 73, 83, 96, 99, 98, 72, 64, 66, 75,
        83, 92, 101, 104, 74, 67, 66, 74, 84, 94, 103, 106, 76, 69, 67, 73, 82,
        91, 101, 109,
        /* Size 16x8 */
        32, 30, 33, 42, 49, 49, 50, 54, 57, 63, 64, 68, 70, 72, 74, 76, 37, 40,
        43, 47, 48, 46, 46, 49, 50, 55, 56, 59, 62, 64, 67, 69, 48, 46, 47, 50,
        53, 53, 54, 55, 56, 60, 61, 64, 66, 66, 66, 67, 52, 48, 47, 50, 54, 61,
        64, 68, 70, 75, 75, 74, 73, 75, 74, 73, 57, 52, 51, 53, 57, 64, 67, 73,
        76, 82, 83, 86, 83, 83, 84, 82, 66, 60, 59, 60, 62, 69, 73, 80, 84, 92,
        93, 94, 96, 92, 94, 91, 68, 63, 60, 59, 62, 66, 72, 76, 80, 87, 93, 98,
        99, 101, 103, 101, 71, 66, 63, 62, 62, 66, 70, 75, 79, 84, 89, 94, 98,
        104, 106, 109,
        /* Size 16x32 */
        32, 31, 37, 42, 48, 49, 52, 54, 57, 63, 66, 67, 68, 69, 71, 72, 31, 31,
        38, 42, 47, 47, 50, 52, 54, 60, 63, 64, 65, 66, 67, 68, 30, 32, 40, 42,
        46, 45, 48, 50, 52, 57, 60, 62, 63, 65, 66, 68, 32, 34, 41, 44, 46, 45,
        48, 49, 51, 57, 59, 61, 62, 63, 64, 65, 33, 36, 43, 45, 47, 46, 47, 49,
        51, 56, 59, 60, 60, 62, 63, 65, 37, 40, 47, 47, 47, 45, 47, 48, 50, 54,
        57, 58, 60, 61, 62, 63, 42, 43, 47, 48, 50, 49, 50, 52, 53, 57, 60, 58,
        59, 60, 62, 63, 45, 44, 47, 49, 51, 51, 52, 54, 55, 59, 61, 61, 61, 60,
        61, 61, 49, 46, 48, 50, 53, 53, 54, 55, 57, 60, 62, 63, 62, 63, 62, 62,
        48, 46, 47, 50, 53, 56, 57, 59, 60, 64, 66, 65, 65, 64, 64, 65, 49, 45,
        46, 49, 53, 58, 61, 62, 64, 67, 69, 67, 66, 66, 66, 65, 49, 46, 46, 49,
        53, 59, 62, 64, 65, 69, 71, 70, 68, 68, 67, 68, 50, 46, 46, 50, 54, 59,
        64, 65, 67, 71, 73, 72, 72, 70, 70, 69, 52, 48, 47, 50, 54, 61, 66, 68,
        71, 75, 77, 74, 73, 73, 71, 72, 54, 50, 49, 52, 55, 62, 68, 71, 73, 78,
        80, 78, 76, 74, 75, 73, 55, 51, 49, 52, 56, 63, 69, 72, 75, 80, 82, 80,
        79, 78, 76, 77, 57, 52, 50, 53, 56, 64, 70, 73, 76, 82, 84, 82, 80, 80,
        79, 77, 60, 54, 52, 55, 58, 65, 72, 75, 79, 85, 88, 86, 84, 82, 81, 81,
        63, 57, 55, 58, 60, 67, 75, 78, 82, 89, 92, 88, 87, 85, 84, 81, 64, 58,
        55, 58, 61, 68, 75, 78, 82, 89, 92, 90, 89, 87, 86, 86, 64, 59, 56, 58,
        61, 68, 75, 79, 83, 90, 93, 95, 93, 91, 89, 87, 67, 61, 58, 60, 63, 69,
        76, 79, 85, 92, 95, 96, 94, 92, 91, 91, 68, 62, 59, 60, 64, 71, 74, 78,
        86, 91, 94, 96, 98, 96, 94, 91, 69, 62, 60, 60, 65, 70, 72, 79, 85, 88,
        95, 98, 99, 98, 97, 96, 70, 63, 62, 60, 66, 69, 73, 81, 83, 89, 96, 97,
        99, 101, 98, 97, 71, 64, 63, 61, 67, 68, 74, 79, 82, 90, 93, 98, 102,
        102, 102, 101, 72, 65, 64, 62, 66, 68, 75, 78, 83, 89, 92, 100, 101,
        103, 104, 102, 73, 66, 65, 63, 66, 69, 75, 76, 84, 87, 93, 98, 102, 105,
        106, 107, 74, 67, 67, 64, 66, 70, 74, 77, 84, 86, 94, 96, 103, 105, 106,
        107, 75, 68, 68, 65, 66, 71, 74, 78, 83, 87, 93, 96, 103, 105, 109, 109,
        76, 69, 69, 66, 67, 72, 73, 80, 82, 88, 91, 97, 101, 107, 109, 110, 77,
        70, 70, 67, 67, 73, 73, 81, 81, 90, 90, 99, 99, 108, 108, 113,
        /* Size 32x16 */
        32, 31, 30, 32, 33, 37, 42, 45, 49, 48, 49, 49, 50, 52, 54, 55, 57, 60,
        63, 64, 64, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 31, 31, 32, 34,
        36, 40, 43, 44, 46, 46, 45, 46, 46, 48, 50, 51, 52, 54, 57, 58, 59, 61,
        62, 62, 63, 64, 65, 66, 67, 68, 69, 70, 37, 38, 40, 41, 43, 47, 47, 47,
        48, 47, 46, 46, 46, 47, 49, 49, 50, 52, 55, 55, 56, 58, 59, 60, 62, 63,
        64, 65, 67, 68, 69, 70, 42, 42, 42, 44, 45, 47, 48, 49, 50, 50, 49, 49,
        50, 50, 52, 52, 53, 55, 58, 58, 58, 60, 60, 60, 60, 61, 62, 63, 64, 65,
        66, 67, 48, 47, 46, 46, 47, 47, 50, 51, 53, 53, 53, 53, 54, 54, 55, 56,
        56, 58, 60, 61, 61, 63, 64, 65, 66, 67, 66, 66, 66, 66, 67, 67, 49, 47,
        45, 45, 46, 45, 49, 51, 53, 56, 58, 59, 59, 61, 62, 63, 64, 65, 67, 68,
        68, 69, 71, 70, 69, 68, 68, 69, 70, 71, 72, 73, 52, 50, 48, 48, 47, 47,
        50, 52, 54, 57, 61, 62, 64, 66, 68, 69, 70, 72, 75, 75, 75, 76, 74, 72,
        73, 74, 75, 75, 74, 74, 73, 73, 54, 52, 50, 49, 49, 48, 52, 54, 55, 59,
        62, 64, 65, 68, 71, 72, 73, 75, 78, 78, 79, 79, 78, 79, 81, 79, 78, 76,
        77, 78, 80, 81, 57, 54, 52, 51, 51, 50, 53, 55, 57, 60, 64, 65, 67, 71,
        73, 75, 76, 79, 82, 82, 83, 85, 86, 85, 83, 82, 83, 84, 84, 83, 82, 81,
        63, 60, 57, 57, 56, 54, 57, 59, 60, 64, 67, 69, 71, 75, 78, 80, 82, 85,
        89, 89, 90, 92, 91, 88, 89, 90, 89, 87, 86, 87, 88, 90, 66, 63, 60, 59,
        59, 57, 60, 61, 62, 66, 69, 71, 73, 77, 80, 82, 84, 88, 92, 92, 93, 95,
        94, 95, 96, 93, 92, 93, 94, 93, 91, 90, 67, 64, 62, 61, 60, 58, 58, 61,
        63, 65, 67, 70, 72, 74, 78, 80, 82, 86, 88, 90, 95, 96, 96, 98, 97, 98,
        100, 98, 96, 96, 97, 99, 68, 65, 63, 62, 60, 60, 59, 61, 62, 65, 66, 68,
        72, 73, 76, 79, 80, 84, 87, 89, 93, 94, 98, 99, 99, 102, 101, 102, 103,
        103, 101, 99, 69, 66, 65, 63, 62, 61, 60, 60, 63, 64, 66, 68, 70, 73,
        74, 78, 80, 82, 85, 87, 91, 92, 96, 98, 101, 102, 103, 105, 105, 105,
        107, 108, 71, 67, 66, 64, 63, 62, 62, 61, 62, 64, 66, 67, 70, 71, 75,
        76, 79, 81, 84, 86, 89, 91, 94, 97, 98, 102, 104, 106, 106, 109, 109,
        108, 72, 68, 68, 65, 65, 63, 63, 61, 62, 65, 65, 68, 69, 72, 73, 77, 77,
        81, 81, 86, 87, 91, 91, 96, 97, 101, 102, 107, 107, 109, 110, 113 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 41, 69, 92, 41, 63, 88, 103, 69, 88, 127, 140, 92, 103, 140, 184,
        /* Size 8x8 */
        32, 32, 37, 47, 62, 78, 90, 102, 32, 35, 39, 46, 58, 72, 84, 96, 37, 39,
        51, 60, 71, 84, 93, 100, 47, 46, 60, 73, 87, 100, 106, 113, 62, 58, 71,
        87, 105, 121, 129, 132, 78, 72, 84, 100, 121, 140, 148, 155, 90, 84, 93,
        106, 129, 148, 169, 183, 102, 96, 100, 113, 132, 155, 183, 201,
        /* Size 16x16 */
        32, 31, 31, 32, 36, 39, 47, 54, 61, 71, 80, 86, 92, 98, 104, 111, 31,
        32, 32, 33, 34, 37, 44, 50, 56, 65, 73, 79, 85, 91, 98, 105, 31, 32, 33,
        34, 36, 39, 45, 50, 56, 64, 71, 77, 82, 88, 94, 100, 32, 33, 34, 36, 40,
        42, 47, 51, 57, 65, 71, 76, 80, 85, 91, 98, 36, 34, 36, 40, 48, 50, 56,
        60, 65, 73, 79, 84, 86, 90, 95, 98, 39, 37, 39, 42, 50, 54, 60, 65, 70,
        78, 84, 89, 95, 96, 102, 105, 47, 44, 45, 47, 56, 60, 69, 75, 81, 89,
        95, 100, 102, 104, 109, 112, 54, 50, 50, 51, 60, 65, 75, 82, 89, 97,
        104, 109, 110, 114, 117, 121, 61, 56, 56, 57, 65, 70, 81, 89, 97, 106,
        113, 119, 122, 126, 125, 130, 71, 65, 64, 65, 73, 78, 89, 97, 106, 117,
        125, 131, 134, 134, 136, 141, 80, 73, 71, 71, 79, 84, 95, 104, 113, 125,
        134, 140, 142, 145, 146, 152, 86, 79, 77, 76, 84, 89, 100, 109, 119,
        131, 140, 147, 154, 157, 160, 165, 92, 85, 82, 80, 86, 95, 102, 110,
        122, 134, 142, 154, 162, 168, 174, 178, 98, 91, 88, 85, 90, 96, 104,
        114, 126, 134, 145, 157, 168, 176, 184, 193, 104, 98, 94, 91, 95, 102,
        109, 117, 125, 136, 146, 160, 174, 184, 193, 201, 111, 105, 100, 98, 98,
        105, 112, 121, 130, 141, 152, 165, 178, 193, 201, 210,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 32, 32, 34, 36, 38, 39, 44, 47, 49, 54, 59, 61, 65,
        71, 76, 80, 83, 86, 89, 92, 95, 98, 101, 104, 108, 111, 114, 31, 32, 32,
        32, 32, 32, 33, 34, 35, 37, 38, 42, 45, 47, 51, 56, 58, 62, 68, 72, 76,
        78, 82, 85, 88, 90, 93, 96, 99, 102, 105, 109, 31, 32, 32, 32, 32, 32,
        33, 33, 34, 36, 37, 41, 44, 46, 50, 54, 56, 60, 65, 70, 73, 76, 79, 82,
        85, 88, 91, 95, 98, 101, 105, 109, 31, 32, 32, 32, 32, 33, 33, 34, 35,
        36, 38, 41, 44, 45, 49, 54, 56, 59, 65, 69, 72, 75, 78, 81, 84, 86, 89,
        92, 95, 98, 101, 104, 31, 32, 32, 32, 33, 34, 34, 35, 36, 38, 39, 42,
        45, 46, 50, 54, 56, 59, 64, 68, 71, 74, 77, 79, 82, 85, 88, 91, 94, 97,
        100, 104, 32, 32, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 45, 46, 49,
        53, 55, 58, 63, 66, 69, 72, 74, 78, 81, 84, 87, 90, 93, 96, 99, 102, 32,
        33, 33, 33, 34, 36, 36, 38, 40, 41, 42, 44, 47, 48, 51, 55, 57, 60, 65,
        68, 71, 73, 76, 78, 80, 82, 85, 88, 91, 95, 98, 102, 34, 34, 33, 34, 35,
        37, 38, 39, 42, 44, 45, 47, 50, 51, 54, 58, 60, 63, 68, 71, 74, 76, 79,
        82, 85, 86, 87, 88, 90, 93, 96, 99, 36, 35, 34, 35, 36, 38, 40, 42, 48,
        50, 50, 54, 56, 57, 60, 64, 65, 68, 73, 76, 79, 81, 84, 86, 86, 88, 90,
        93, 95, 97, 98, 100, 38, 37, 36, 36, 38, 39, 41, 44, 50, 51, 52, 56, 58,
        60, 63, 67, 68, 71, 76, 79, 82, 84, 87, 87, 90, 93, 94, 95, 96, 100,
        103, 106, 39, 38, 37, 38, 39, 40, 42, 45, 50, 52, 54, 58, 60, 62, 65,
        69, 70, 73, 78, 81, 84, 86, 89, 92, 95, 95, 96, 99, 102, 104, 105, 106,
        44, 42, 41, 41, 42, 42, 44, 47, 54, 56, 58, 63, 66, 68, 71, 75, 77, 79,
        84, 88, 90, 92, 95, 97, 97, 99, 102, 103, 103, 106, 109, 113, 47, 45,
        44, 44, 45, 45, 47, 50, 56, 58, 60, 66, 69, 71, 75, 79, 81, 84, 89, 92,
        95, 97, 100, 100, 102, 105, 104, 106, 109, 111, 112, 113, 49, 47, 46,
        45, 46, 46, 48, 51, 57, 60, 62, 68, 71, 73, 77, 81, 83, 87, 92, 95, 98,
        100, 103, 105, 107, 106, 109, 112, 112, 113, 117, 120, 54, 51, 50, 49,
        50, 49, 51, 54, 60, 63, 65, 71, 75, 77, 82, 87, 89, 92, 97, 101, 104,
        106, 109, 112, 110, 113, 114, 114, 117, 121, 121, 121, 59, 56, 54, 54,
        54, 53, 55, 58, 64, 67, 69, 75, 79, 81, 87, 92, 94, 98, 103, 107, 110,
        113, 116, 114, 117, 118, 117, 121, 122, 122, 125, 129, 61, 58, 56, 56,
        56, 55, 57, 60, 65, 68, 70, 77, 81, 83, 89, 94, 97, 101, 106, 110, 113,
        116, 119, 120, 122, 121, 126, 124, 125, 130, 130, 130, 65, 62, 60, 59,
        59, 58, 60, 63, 68, 71, 73, 79, 84, 87, 92, 98, 101, 105, 111, 115, 118,
        121, 124, 128, 125, 129, 128, 131, 133, 132, 135, 139, 71, 68, 65, 65,
        64, 63, 65, 68, 73, 76, 78, 84, 89, 92, 97, 103, 106, 111, 117, 122,
        125, 128, 131, 131, 134, 132, 134, 136, 136, 140, 141, 140, 76, 72, 70,
        69, 68, 66, 68, 71, 76, 79, 81, 88, 92, 95, 101, 107, 110, 115, 122,
        127, 130, 133, 136, 136, 138, 139, 141, 140, 145, 143, 146, 151, 80, 76,
        73, 72, 71, 69, 71, 74, 79, 82, 84, 90, 95, 98, 104, 110, 113, 118, 125,
        130, 134, 137, 140, 146, 142, 146, 145, 149, 146, 150, 152, 151, 83, 78,
        76, 75, 74, 72, 73, 76, 81, 84, 86, 92, 97, 100, 106, 113, 116, 121,
        128, 133, 137, 140, 144, 147, 152, 148, 154, 151, 156, 155, 156, 162,
        86, 82, 79, 78, 77, 74, 76, 79, 84, 87, 89, 95, 100, 103, 109, 116, 119,
        124, 131, 136, 140, 144, 147, 150, 154, 159, 157, 160, 160, 162, 165,
        162, 89, 85, 82, 81, 79, 78, 78, 82, 86, 87, 92, 97, 100, 105, 112, 114,
        120, 128, 131, 136, 146, 147, 150, 155, 156, 161, 166, 165, 167, 169,
        169, 175, 92, 88, 85, 84, 82, 81, 80, 85, 86, 90, 95, 97, 102, 107, 110,
        117, 122, 125, 134, 138, 142, 152, 154, 156, 162, 163, 168, 173, 174,
        174, 178, 176, 95, 90, 88, 86, 85, 84, 82, 86, 88, 93, 95, 99, 105, 106,
        113, 118, 121, 129, 132, 139, 146, 148, 159, 161, 163, 169, 170, 176,
        180, 183, 181, 187, 98, 93, 91, 89, 88, 87, 85, 87, 90, 94, 96, 102,
        104, 109, 114, 117, 126, 128, 134, 141, 145, 154, 157, 166, 168, 170,
        176, 178, 184, 188, 193, 188, 101, 96, 95, 92, 91, 90, 88, 88, 93, 95,
        99, 103, 106, 112, 114, 121, 124, 131, 136, 140, 149, 151, 160, 165,
        173, 176, 178, 184, 186, 192, 196, 203, 104, 99, 98, 95, 94, 93, 91, 90,
        95, 96, 102, 103, 109, 112, 117, 122, 125, 133, 136, 145, 146, 156, 160,
        167, 174, 180, 184, 186, 193, 194, 201, 204, 108, 102, 101, 98, 97, 96,
        95, 93, 97, 100, 104, 106, 111, 113, 121, 122, 130, 132, 140, 143, 150,
        155, 162, 169, 174, 183, 188, 192, 194, 201, 202, 210, 111, 105, 105,
        101, 100, 99, 98, 96, 98, 103, 105, 109, 112, 117, 121, 125, 130, 135,
        141, 146, 152, 156, 165, 169, 178, 181, 193, 196, 201, 202, 210, 211,
        114, 109, 109, 104, 104, 102, 102, 99, 100, 106, 106, 113, 113, 120,
        121, 129, 130, 139, 140, 151, 151, 162, 162, 175, 176, 187, 188, 203,
        204, 210, 211, 219,
        /* Size 4x8 */
        32, 42, 69, 88, 33, 42, 64, 83, 36, 56, 77, 88, 46, 67, 93, 105, 60, 79,
        112, 122, 75, 92, 130, 144, 86, 95, 136, 167, 98, 105, 136, 177,
        /* Size 8x4 */
        32, 33, 36, 46, 60, 75, 86, 98, 42, 42, 56, 67, 79, 92, 95, 105, 69, 64,
        77, 93, 112, 130, 136, 136, 88, 83, 88, 105, 122, 144, 167, 177,
        /* Size 8x16 */
        32, 32, 36, 47, 65, 79, 90, 96, 31, 32, 35, 44, 60, 72, 84, 90, 32, 34,
        36, 45, 59, 71, 80, 87, 32, 35, 40, 47, 60, 71, 78, 85, 36, 37, 48, 56,
        68, 78, 83, 87, 39, 40, 50, 60, 73, 84, 91, 94, 47, 45, 56, 69, 84, 95,
        101, 101, 53, 50, 60, 75, 92, 103, 108, 110, 61, 56, 65, 81, 100, 113,
        116, 118, 71, 64, 73, 89, 111, 125, 129, 129, 79, 70, 79, 95, 118, 133,
        142, 138, 86, 76, 84, 100, 124, 140, 153, 150, 92, 82, 89, 101, 121,
        148, 157, 161, 98, 88, 93, 108, 124, 141, 163, 174, 104, 94, 95, 110,
        129, 151, 171, 181, 110, 100, 98, 111, 127, 147, 169, 188,
        /* Size 16x8 */
        32, 31, 32, 32, 36, 39, 47, 53, 61, 71, 79, 86, 92, 98, 104, 110, 32,
        32, 34, 35, 37, 40, 45, 50, 56, 64, 70, 76, 82, 88, 94, 100, 36, 35, 36,
        40, 48, 50, 56, 60, 65, 73, 79, 84, 89, 93, 95, 98, 47, 44, 45, 47, 56,
        60, 69, 75, 81, 89, 95, 100, 101, 108, 110, 111, 65, 60, 59, 60, 68, 73,
        84, 92, 100, 111, 118, 124, 121, 124, 129, 127, 79, 72, 71, 71, 78, 84,
        95, 103, 113, 125, 133, 140, 148, 141, 151, 147, 90, 84, 80, 78, 83, 91,
        101, 108, 116, 129, 142, 153, 157, 163, 171, 169, 96, 90, 87, 85, 87,
        94, 101, 110, 118, 129, 138, 150, 161, 174, 181, 188,
        /* Size 16x32 */
        32, 31, 32, 32, 36, 44, 47, 53, 65, 73, 79, 87, 90, 93, 96, 99, 31, 32,
        32, 33, 35, 42, 45, 51, 62, 69, 75, 83, 86, 88, 91, 94, 31, 32, 32, 33,
        35, 41, 44, 49, 60, 67, 72, 80, 84, 87, 90, 94, 31, 32, 33, 33, 35, 41,
        44, 49, 59, 66, 71, 79, 82, 84, 87, 90, 32, 32, 34, 34, 36, 42, 45, 50,
        59, 65, 71, 78, 80, 83, 87, 90, 32, 33, 35, 36, 38, 42, 45, 49, 58, 64,
        69, 76, 80, 83, 86, 88, 32, 33, 35, 36, 40, 44, 47, 51, 60, 66, 71, 76,
        78, 81, 85, 89, 34, 34, 36, 38, 42, 48, 50, 54, 63, 69, 73, 80, 82, 81,
        84, 86, 36, 34, 37, 40, 48, 54, 56, 60, 68, 74, 78, 84, 83, 86, 87, 87,
        38, 36, 39, 41, 49, 56, 58, 63, 71, 77, 81, 86, 88, 88, 90, 93, 39, 37,
        40, 42, 50, 58, 60, 65, 73, 79, 84, 90, 91, 92, 94, 93, 44, 41, 42, 45,
        53, 63, 66, 71, 79, 85, 90, 96, 94, 96, 96, 99, 47, 44, 45, 47, 56, 66,
        69, 75, 84, 90, 95, 99, 101, 98, 101, 99, 49, 46, 47, 48, 57, 67, 71,
        77, 86, 93, 97, 103, 103, 105, 102, 106, 53, 49, 50, 51, 60, 71, 75, 82,
        92, 99, 103, 111, 108, 107, 110, 107, 58, 54, 54, 55, 63, 75, 79, 87,
        98, 105, 110, 114, 114, 113, 111, 115, 61, 56, 56, 57, 65, 77, 81, 89,
        100, 107, 113, 118, 116, 117, 118, 116, 65, 60, 59, 60, 68, 79, 84, 92,
        105, 112, 118, 126, 124, 122, 121, 124, 71, 65, 64, 65, 73, 84, 89, 97,
        111, 119, 125, 130, 129, 129, 129, 125, 76, 69, 68, 69, 76, 88, 92, 101,
        115, 123, 130, 134, 134, 131, 132, 135, 79, 72, 70, 71, 79, 90, 95, 104,
        118, 127, 133, 143, 142, 141, 138, 136, 82, 75, 73, 74, 81, 92, 97, 106,
        121, 130, 136, 146, 145, 144, 144, 145, 86, 78, 76, 77, 84, 95, 100,
        109, 124, 133, 140, 147, 153, 151, 150, 146, 89, 81, 79, 78, 87, 95, 99,
        112, 124, 130, 145, 152, 156, 157, 156, 158, 92, 84, 82, 80, 89, 95,
        101, 116, 121, 132, 148, 151, 157, 163, 161, 159, 95, 86, 85, 83, 92,
        95, 105, 114, 120, 136, 143, 155, 163, 167, 171, 170, 98, 89, 88, 85,
        93, 95, 108, 113, 124, 136, 141, 160, 163, 169, 174, 171, 101, 92, 91,
        88, 94, 98, 110, 112, 128, 133, 146, 158, 166, 175, 179, 185, 104, 95,
        94, 91, 95, 101, 110, 115, 129, 132, 151, 154, 171, 175, 181, 186, 107,
        98, 97, 94, 96, 105, 110, 119, 128, 136, 149, 156, 173, 177, 188, 192,
        110, 101, 100, 97, 98, 108, 111, 123, 127, 141, 147, 161, 169, 183, 188,
        193, 114, 104, 104, 100, 100, 111, 111, 126, 127, 145, 145, 166, 166,
        189, 190, 201,
        /* Size 32x16 */
        32, 31, 31, 31, 32, 32, 32, 34, 36, 38, 39, 44, 47, 49, 53, 58, 61, 65,
        71, 76, 79, 82, 86, 89, 92, 95, 98, 101, 104, 107, 110, 114, 31, 32, 32,
        32, 32, 33, 33, 34, 34, 36, 37, 41, 44, 46, 49, 54, 56, 60, 65, 69, 72,
        75, 78, 81, 84, 86, 89, 92, 95, 98, 101, 104, 32, 32, 32, 33, 34, 35,
        35, 36, 37, 39, 40, 42, 45, 47, 50, 54, 56, 59, 64, 68, 70, 73, 76, 79,
        82, 85, 88, 91, 94, 97, 100, 104, 32, 33, 33, 33, 34, 36, 36, 38, 40,
        41, 42, 45, 47, 48, 51, 55, 57, 60, 65, 69, 71, 74, 77, 78, 80, 83, 85,
        88, 91, 94, 97, 100, 36, 35, 35, 35, 36, 38, 40, 42, 48, 49, 50, 53, 56,
        57, 60, 63, 65, 68, 73, 76, 79, 81, 84, 87, 89, 92, 93, 94, 95, 96, 98,
        100, 44, 42, 41, 41, 42, 42, 44, 48, 54, 56, 58, 63, 66, 67, 71, 75, 77,
        79, 84, 88, 90, 92, 95, 95, 95, 95, 95, 98, 101, 105, 108, 111, 47, 45,
        44, 44, 45, 45, 47, 50, 56, 58, 60, 66, 69, 71, 75, 79, 81, 84, 89, 92,
        95, 97, 100, 99, 101, 105, 108, 110, 110, 110, 111, 111, 53, 51, 49, 49,
        50, 49, 51, 54, 60, 63, 65, 71, 75, 77, 82, 87, 89, 92, 97, 101, 104,
        106, 109, 112, 116, 114, 113, 112, 115, 119, 123, 126, 65, 62, 60, 59,
        59, 58, 60, 63, 68, 71, 73, 79, 84, 86, 92, 98, 100, 105, 111, 115, 118,
        121, 124, 124, 121, 120, 124, 128, 129, 128, 127, 127, 73, 69, 67, 66,
        65, 64, 66, 69, 74, 77, 79, 85, 90, 93, 99, 105, 107, 112, 119, 123,
        127, 130, 133, 130, 132, 136, 136, 133, 132, 136, 141, 145, 79, 75, 72,
        71, 71, 69, 71, 73, 78, 81, 84, 90, 95, 97, 103, 110, 113, 118, 125,
        130, 133, 136, 140, 145, 148, 143, 141, 146, 151, 149, 147, 145, 87, 83,
        80, 79, 78, 76, 76, 80, 84, 86, 90, 96, 99, 103, 111, 114, 118, 126,
        130, 134, 143, 146, 147, 152, 151, 155, 160, 158, 154, 156, 161, 166,
        90, 86, 84, 82, 80, 80, 78, 82, 83, 88, 91, 94, 101, 103, 108, 114, 116,
        124, 129, 134, 142, 145, 153, 156, 157, 163, 163, 166, 171, 173, 169,
        166, 93, 88, 87, 84, 83, 83, 81, 81, 86, 88, 92, 96, 98, 105, 107, 113,
        117, 122, 129, 131, 141, 144, 151, 157, 163, 167, 169, 175, 175, 177,
        183, 189, 96, 91, 90, 87, 87, 86, 85, 84, 87, 90, 94, 96, 101, 102, 110,
        111, 118, 121, 129, 132, 138, 144, 150, 156, 161, 171, 174, 179, 181,
        188, 188, 190, 99, 94, 94, 90, 90, 88, 89, 86, 87, 93, 93, 99, 99, 106,
        107, 115, 116, 124, 125, 135, 136, 145, 146, 158, 159, 170, 171, 185,
        186, 192, 193, 201 },
      { /* Chroma */
        /* Size 4x4 */
        33, 45, 56, 64, 45, 58, 66, 69, 56, 66, 86, 87, 64, 69, 87, 105,
        /* Size 8x8 */
        31, 38, 47, 48, 54, 61, 66, 69, 38, 47, 47, 46, 50, 55, 61, 65, 47, 47,
        53, 55, 58, 63, 65, 66, 48, 46, 55, 62, 67, 72, 73, 73, 54, 50, 58, 67,
        76, 83, 84, 82, 61, 55, 63, 72, 83, 91, 92, 92, 66, 61, 65, 73, 84, 92,
        101, 103, 69, 65, 66, 73, 82, 92, 103, 109,
        /* Size 16x16 */
        32, 30, 33, 38, 49, 48, 50, 52, 55, 60, 63, 66, 68, 70, 72, 74, 30, 31,
        35, 41, 46, 46, 46, 48, 51, 55, 58, 60, 63, 65, 68, 70, 33, 35, 39, 44,
        47, 46, 46, 47, 50, 53, 56, 58, 60, 62, 65, 67, 38, 41, 44, 47, 49, 48,
        47, 48, 50, 53, 55, 58, 58, 60, 62, 65, 49, 46, 47, 49, 53, 53, 54, 54,
        56, 58, 60, 62, 62, 63, 64, 64, 48, 46, 46, 48, 53, 54, 56, 57, 59, 61,
        63, 65, 67, 66, 68, 68, 50, 46, 46, 47, 54, 56, 61, 63, 65, 68, 70, 72,
        71, 71, 72, 72, 52, 48, 47, 48, 54, 57, 63, 66, 69, 72, 75, 76, 75, 76,
        76, 76, 55, 51, 50, 50, 56, 59, 65, 69, 73, 77, 79, 81, 81, 81, 80, 80,
        60, 55, 53, 53, 58, 61, 68, 72, 77, 82, 85, 87, 87, 85, 84, 85, 63, 58,
        56, 55, 60, 63, 70, 75, 79, 85, 89, 91, 91, 90, 89, 90, 66, 60, 58, 58,
        62, 65, 72, 76, 81, 87, 91, 94, 96, 95, 95, 95, 68, 63, 60, 58, 62, 67,
        71, 75, 81, 87, 91, 96, 99, 100, 100, 100, 70, 65, 62, 60, 63, 66, 71,
        76, 81, 85, 90, 95, 100, 103, 104, 105, 72, 68, 65, 62, 64, 68, 72, 76,
        80, 84, 89, 95, 100, 104, 107, 108, 74, 70, 67, 65, 64, 68, 72, 76, 80,
        85, 90, 95, 100, 105, 108, 111,
        /* Size 32x32 */
        32, 31, 30, 31, 33, 36, 38, 41, 49, 49, 48, 49, 50, 51, 52, 54, 55, 57,
        60, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 31, 31, 31, 32,
        34, 38, 40, 42, 47, 47, 47, 47, 48, 48, 50, 52, 53, 54, 57, 59, 60, 61,
        63, 64, 65, 66, 67, 67, 68, 69, 70, 71, 30, 31, 31, 32, 35, 39, 41, 42,
        46, 46, 46, 45, 46, 47, 48, 50, 51, 52, 55, 57, 58, 59, 60, 62, 63, 64,
        65, 67, 68, 69, 70, 71, 31, 32, 32, 33, 36, 40, 41, 43, 46, 46, 45, 45,
        46, 46, 47, 49, 50, 51, 54, 56, 57, 58, 59, 61, 62, 63, 63, 64, 65, 66,
        67, 68, 33, 34, 35, 36, 39, 43, 44, 45, 47, 46, 46, 45, 46, 47, 47, 49,
        50, 51, 53, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 36, 38,
        39, 40, 43, 47, 47, 47, 48, 47, 46, 45, 46, 46, 47, 48, 49, 50, 52, 53,
        54, 55, 56, 58, 59, 61, 62, 63, 64, 65, 66, 66, 38, 40, 41, 41, 44, 47,
        47, 48, 49, 48, 48, 47, 47, 47, 48, 49, 50, 51, 53, 54, 55, 56, 58, 58,
        58, 59, 60, 61, 62, 64, 65, 66, 41, 42, 42, 43, 45, 47, 48, 48, 50, 50,
        49, 49, 50, 50, 50, 52, 52, 53, 55, 56, 57, 58, 59, 60, 61, 61, 61, 61,
        62, 63, 63, 64, 49, 47, 46, 46, 47, 48, 49, 50, 53, 53, 53, 53, 54, 54,
        54, 55, 56, 56, 58, 59, 60, 61, 62, 63, 62, 62, 63, 64, 64, 64, 64, 64,
        49, 47, 46, 46, 46, 47, 48, 50, 53, 53, 54, 55, 55, 55, 56, 57, 58, 58,
        60, 61, 62, 63, 64, 64, 64, 65, 65, 65, 65, 66, 67, 68, 48, 47, 46, 45,
        46, 46, 48, 49, 53, 54, 54, 55, 56, 56, 57, 58, 59, 60, 61, 63, 63, 64,
        65, 66, 67, 66, 66, 67, 68, 68, 68, 68, 49, 47, 45, 45, 45, 45, 47, 49,
        53, 55, 55, 58, 59, 60, 61, 62, 63, 63, 65, 66, 67, 68, 69, 69, 68, 68,
        69, 69, 69, 69, 70, 71, 50, 48, 46, 46, 46, 46, 47, 50, 54, 55, 56, 59,
        61, 61, 63, 64, 65, 66, 68, 69, 70, 71, 72, 71, 71, 72, 71, 71, 72, 72,
        72, 71, 51, 48, 47, 46, 47, 46, 47, 50, 54, 55, 56, 60, 61, 62, 64, 66,
        66, 67, 69, 70, 71, 72, 73, 73, 74, 73, 73, 74, 73, 73, 74, 75, 52, 50,
        48, 47, 47, 47, 48, 50, 54, 56, 57, 61, 63, 64, 66, 68, 69, 70, 72, 74,
        75, 75, 76, 77, 75, 76, 76, 75, 76, 77, 76, 75, 54, 52, 50, 49, 49, 48,
        49, 52, 55, 57, 58, 62, 64, 66, 68, 71, 72, 73, 75, 77, 78, 79, 80, 78,
        79, 78, 77, 78, 78, 77, 78, 79, 55, 53, 51, 50, 50, 49, 50, 52, 56, 58,
        59, 63, 65, 66, 69, 72, 73, 74, 77, 78, 79, 80, 81, 81, 81, 80, 81, 80,
        80, 81, 80, 79, 57, 54, 52, 51, 51, 50, 51, 53, 56, 58, 60, 63, 66, 67,
        70, 73, 74, 76, 79, 80, 82, 83, 84, 85, 83, 84, 83, 83, 83, 82, 82, 83,
        60, 57, 55, 54, 53, 52, 53, 55, 58, 60, 61, 65, 68, 69, 72, 75, 77, 79,
        82, 84, 85, 86, 87, 86, 87, 85, 85, 85, 84, 86, 85, 84, 62, 59, 57, 56,
        55, 53, 54, 56, 59, 61, 63, 66, 69, 70, 74, 77, 78, 80, 84, 86, 87, 88,
        90, 89, 89, 88, 88, 87, 88, 87, 87, 88, 63, 60, 58, 57, 56, 54, 55, 57,
        60, 62, 63, 67, 70, 71, 75, 78, 79, 82, 85, 87, 89, 90, 91, 93, 91, 91,
        90, 91, 89, 90, 90, 89, 65, 61, 59, 58, 57, 55, 56, 58, 61, 63, 64, 68,
        71, 72, 75, 79, 80, 83, 86, 88, 90, 91, 93, 94, 95, 92, 94, 92, 93, 92,
        91, 93, 66, 63, 60, 59, 58, 56, 58, 59, 62, 64, 65, 69, 72, 73, 76, 80,
        81, 84, 87, 90, 91, 93, 94, 95, 96, 97, 95, 95, 95, 95, 95, 93, 67, 64,
        62, 61, 59, 58, 58, 60, 63, 64, 66, 69, 71, 73, 77, 78, 81, 85, 86, 89,
        93, 94, 95, 97, 97, 98, 99, 97, 97, 97, 96, 98, 68, 65, 63, 62, 60, 59,
        58, 61, 62, 64, 67, 68, 71, 74, 75, 79, 81, 83, 87, 89, 91, 95, 96, 97,
        99, 98, 100, 100, 100, 99, 100, 98, 69, 66, 64, 63, 61, 61, 59, 61, 62,
        65, 66, 68, 72, 73, 76, 78, 80, 84, 85, 88, 91, 92, 97, 98, 98, 101,
        100, 102, 102, 103, 101, 102, 70, 67, 65, 63, 62, 62, 60, 61, 63, 65,
        66, 69, 71, 73, 76, 77, 81, 83, 85, 88, 90, 94, 95, 99, 100, 100, 103,
        102, 104, 104, 105, 103, 71, 67, 67, 64, 63, 63, 61, 61, 64, 65, 67, 69,
        71, 74, 75, 78, 80, 83, 85, 87, 91, 92, 95, 97, 100, 102, 102, 105, 104,
        106, 106, 108, 72, 68, 68, 65, 65, 64, 62, 62, 64, 65, 68, 69, 72, 73,
        76, 78, 80, 83, 84, 88, 89, 93, 95, 97, 100, 102, 104, 104, 107, 106,
        108, 108, 73, 69, 69, 66, 66, 65, 64, 63, 64, 66, 68, 69, 72, 73, 77,
        77, 81, 82, 86, 87, 90, 92, 95, 97, 99, 103, 104, 106, 106, 109, 108,
        110, 74, 70, 70, 67, 67, 66, 65, 63, 64, 67, 68, 70, 72, 74, 76, 78, 80,
        82, 85, 87, 90, 91, 95, 96, 100, 101, 105, 106, 108, 108, 111, 110, 75,
        71, 71, 68, 68, 66, 66, 64, 64, 68, 68, 71, 71, 75, 75, 79, 79, 83, 84,
        88, 89, 93, 93, 98, 98, 102, 103, 108, 108, 110, 110, 113,
        /* Size 4x8 */
        31, 47, 57, 65, 40, 45, 52, 61, 46, 55, 61, 63, 47, 60, 70, 72, 52, 64,
        79, 81, 59, 68, 87, 90, 63, 66, 88, 99, 66, 69, 85, 102,
        /* Size 8x4 */
        31, 40, 46, 47, 52, 59, 63, 66, 47, 45, 55, 60, 64, 68, 66, 69, 57, 52,
        61, 70, 79, 87, 88, 85, 65, 61, 63, 72, 81, 90, 99, 102,
        /* Size 8x16 */
        32, 35, 48, 50, 57, 63, 68, 70, 30, 38, 46, 46, 52, 58, 63, 65, 33, 41,
        47, 46, 51, 56, 60, 63, 39, 46, 48, 47, 51, 55, 58, 61, 49, 48, 53, 54,
        57, 60, 61, 61, 48, 46, 53, 56, 60, 64, 65, 65, 50, 46, 54, 61, 66, 70,
        71, 69, 52, 47, 54, 63, 71, 75, 75, 74, 55, 49, 56, 65, 74, 79, 79, 78,
        60, 53, 58, 68, 79, 85, 85, 82, 63, 55, 60, 70, 82, 89, 91, 87, 66, 58,
        62, 72, 84, 91, 95, 91, 68, 60, 64, 71, 81, 94, 97, 96, 70, 62, 65, 73,
        81, 89, 98, 101, 72, 65, 65, 72, 82, 92, 100, 103, 74, 67, 65, 71, 79,
        89, 98, 105,
        /* Size 16x8 */
        32, 30, 33, 39, 49, 48, 50, 52, 55, 60, 63, 66, 68, 70, 72, 74, 35, 38,
        41, 46, 48, 46, 46, 47, 49, 53, 55, 58, 60, 62, 65, 67, 48, 46, 47, 48,
        53, 53, 54, 54, 56, 58, 60, 62, 64, 65, 65, 65, 50, 46, 46, 47, 54, 56,
        61, 63, 65, 68, 70, 72, 71, 73, 72, 71, 57, 52, 51, 51, 57, 60, 66, 71,
        74, 79, 82, 84, 81, 81, 82, 79, 63, 58, 56, 55, 60, 64, 70, 75, 79, 85,
        89, 91, 94, 89, 92, 89, 68, 63, 60, 58, 61, 65, 71, 75, 79, 85, 91, 95,
        97, 98, 100, 98, 70, 65, 63, 61, 61, 65, 69, 74, 78, 82, 87, 91, 96,
        101, 103, 105,
        /* Size 16x32 */
        32, 31, 35, 38, 48, 49, 50, 52, 57, 61, 63, 67, 68, 69, 70, 71, 31, 31,
        37, 40, 47, 47, 48, 50, 54, 57, 60, 63, 64, 65, 66, 67, 30, 32, 38, 40,
        46, 45, 46, 48, 52, 55, 58, 61, 63, 64, 65, 67, 31, 33, 38, 41, 46, 45,
        46, 48, 52, 55, 57, 60, 61, 62, 63, 64, 33, 36, 41, 44, 47, 46, 46, 47,
        51, 54, 56, 59, 60, 61, 63, 64, 37, 40, 45, 47, 47, 45, 46, 47, 50, 52,
        54, 57, 59, 61, 62, 62, 39, 41, 46, 47, 48, 47, 47, 48, 51, 54, 55, 57,
        58, 59, 61, 62, 42, 43, 46, 48, 50, 49, 50, 50, 53, 56, 57, 60, 60, 59,
        60, 60, 49, 46, 48, 49, 53, 53, 54, 54, 57, 59, 60, 63, 61, 62, 61, 61,
        48, 46, 47, 48, 53, 55, 55, 56, 58, 61, 62, 64, 64, 63, 63, 64, 48, 46,
        46, 48, 53, 56, 56, 57, 60, 62, 64, 66, 65, 65, 65, 64, 49, 45, 45, 47,
        53, 58, 59, 61, 64, 66, 67, 69, 67, 67, 66, 67, 50, 46, 46, 48, 54, 59,
        61, 63, 66, 68, 70, 71, 71, 68, 69, 67, 51, 47, 47, 48, 54, 60, 61, 64,
        68, 70, 71, 73, 72, 72, 70, 71, 52, 48, 47, 48, 54, 61, 63, 66, 71, 73,
        75, 77, 75, 73, 74, 71, 54, 50, 49, 50, 55, 62, 65, 68, 73, 76, 78, 79,
        78, 76, 74, 75, 55, 51, 49, 50, 56, 63, 65, 69, 74, 77, 79, 81, 79, 78,
        78, 75, 57, 52, 50, 51, 56, 64, 66, 70, 76, 79, 82, 85, 83, 81, 79, 79,
        60, 54, 53, 53, 58, 65, 68, 72, 79, 82, 85, 87, 85, 84, 82, 80, 62, 56,
        54, 55, 60, 66, 69, 74, 81, 84, 87, 88, 87, 85, 84, 84, 63, 57, 55, 56,
        60, 67, 70, 75, 82, 86, 89, 92, 91, 89, 87, 84, 64, 59, 56, 57, 61, 68,
        71, 75, 83, 87, 90, 93, 92, 90, 89, 89, 66, 60, 58, 58, 62, 69, 72, 76,
        84, 88, 91, 94, 95, 93, 91, 89, 67, 61, 59, 58, 63, 68, 71, 78, 83, 86,
        93, 96, 96, 96, 94, 94, 68, 62, 60, 59, 64, 67, 71, 79, 81, 86, 94, 95,
        97, 98, 96, 94, 69, 63, 61, 60, 65, 66, 72, 77, 80, 88, 91, 96, 99, 99,
        100, 98, 70, 64, 62, 60, 65, 66, 73, 76, 81, 87, 89, 97, 98, 100, 101,
        99, 71, 65, 64, 61, 65, 67, 73, 74, 82, 85, 90, 95, 99, 102, 103, 104,
        72, 65, 65, 62, 65, 68, 72, 75, 82, 83, 92, 93, 100, 102, 103, 104, 73,
        66, 66, 63, 65, 69, 72, 76, 81, 85, 90, 93, 100, 102, 105, 106, 74, 67,
        67, 64, 65, 70, 71, 77, 79, 86, 89, 94, 98, 103, 105, 106, 75, 68, 68,
        65, 65, 71, 71, 78, 78, 87, 87, 96, 96, 105, 105, 109,
        /* Size 32x16 */
        32, 31, 30, 31, 33, 37, 39, 42, 49, 48, 48, 49, 50, 51, 52, 54, 55, 57,
        60, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 31, 31, 32, 33,
        36, 40, 41, 43, 46, 46, 46, 45, 46, 47, 48, 50, 51, 52, 54, 56, 57, 59,
        60, 61, 62, 63, 64, 65, 65, 66, 67, 68, 35, 37, 38, 38, 41, 45, 46, 46,
        48, 47, 46, 45, 46, 47, 47, 49, 49, 50, 53, 54, 55, 56, 58, 59, 60, 61,
        62, 64, 65, 66, 67, 68, 38, 40, 40, 41, 44, 47, 47, 48, 49, 48, 48, 47,
        48, 48, 48, 50, 50, 51, 53, 55, 56, 57, 58, 58, 59, 60, 60, 61, 62, 63,
        64, 65, 48, 47, 46, 46, 47, 47, 48, 50, 53, 53, 53, 53, 54, 54, 54, 55,
        56, 56, 58, 60, 60, 61, 62, 63, 64, 65, 65, 65, 65, 65, 65, 65, 49, 47,
        45, 45, 46, 45, 47, 49, 53, 55, 56, 58, 59, 60, 61, 62, 63, 64, 65, 66,
        67, 68, 69, 68, 67, 66, 66, 67, 68, 69, 70, 71, 50, 48, 46, 46, 46, 46,
        47, 50, 54, 55, 56, 59, 61, 61, 63, 65, 65, 66, 68, 69, 70, 71, 72, 71,
        71, 72, 73, 73, 72, 72, 71, 71, 52, 50, 48, 48, 47, 47, 48, 50, 54, 56,
        57, 61, 63, 64, 66, 68, 69, 70, 72, 74, 75, 75, 76, 78, 79, 77, 76, 74,
        75, 76, 77, 78, 57, 54, 52, 52, 51, 50, 51, 53, 57, 58, 60, 64, 66, 68,
        71, 73, 74, 76, 79, 81, 82, 83, 84, 83, 81, 80, 81, 82, 82, 81, 79, 78,
        61, 57, 55, 55, 54, 52, 54, 56, 59, 61, 62, 66, 68, 70, 73, 76, 77, 79,
        82, 84, 86, 87, 88, 86, 86, 88, 87, 85, 83, 85, 86, 87, 63, 60, 58, 57,
        56, 54, 55, 57, 60, 62, 64, 67, 70, 71, 75, 78, 79, 82, 85, 87, 89, 90,
        91, 93, 94, 91, 89, 90, 92, 90, 89, 87, 67, 63, 61, 60, 59, 57, 57, 60,
        63, 64, 66, 69, 71, 73, 77, 79, 81, 85, 87, 88, 92, 93, 94, 96, 95, 96,
        97, 95, 93, 93, 94, 96, 68, 64, 63, 61, 60, 59, 58, 60, 61, 64, 65, 67,
        71, 72, 75, 78, 79, 83, 85, 87, 91, 92, 95, 96, 97, 99, 98, 99, 100,
        100, 98, 96, 69, 65, 64, 62, 61, 61, 59, 59, 62, 63, 65, 67, 68, 72, 73,
        76, 78, 81, 84, 85, 89, 90, 93, 96, 98, 99, 100, 102, 102, 102, 103,
        105, 70, 66, 65, 63, 63, 62, 61, 60, 61, 63, 65, 66, 69, 70, 74, 74, 78,
        79, 82, 84, 87, 89, 91, 94, 96, 100, 101, 103, 103, 105, 105, 105, 71,
        67, 67, 64, 64, 62, 62, 60, 61, 64, 64, 67, 67, 71, 71, 75, 75, 79, 80,
        84, 84, 89, 89, 94, 94, 98, 99, 104, 104, 106, 106, 109 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 38, 63, 86, 38, 56, 78, 97, 63, 78, 113, 130, 86, 97, 130, 169,
        /* Size 8x8 */
        32, 32, 35, 46, 57, 76, 85, 96, 32, 34, 37, 45, 54, 70, 79, 90, 35, 37,
        48, 56, 64, 79, 87, 93, 46, 45, 56, 70, 80, 96, 100, 105, 57, 54, 64,
        80, 93, 111, 121, 122, 76, 70, 79, 96, 111, 134, 138, 144, 85, 79, 87,
        100, 121, 138, 156, 168, 96, 90, 93, 105, 122, 144, 168, 184,
        /* Size 16x16 */
        32, 31, 31, 32, 34, 39, 44, 49, 58, 65, 71, 81, 87, 93, 98, 104, 31, 32,
        32, 32, 34, 38, 41, 46, 54, 60, 66, 75, 81, 86, 92, 98, 31, 32, 33, 34,
        36, 39, 42, 46, 53, 59, 64, 73, 78, 83, 88, 94, 32, 32, 34, 35, 37, 40,
        42, 46, 52, 58, 63, 71, 75, 80, 86, 92, 34, 34, 36, 37, 42, 47, 50, 53,
        59, 65, 70, 77, 82, 85, 89, 92, 39, 38, 39, 40, 47, 54, 58, 62, 68, 73,
        78, 85, 90, 90, 96, 98, 44, 41, 42, 42, 50, 58, 63, 68, 74, 79, 84, 91,
        96, 98, 102, 104, 49, 46, 46, 46, 53, 62, 68, 73, 81, 87, 92, 99, 103,
        107, 109, 112, 58, 54, 53, 52, 59, 68, 74, 81, 90, 97, 102, 110, 114,
        118, 117, 121, 65, 60, 59, 58, 65, 73, 79, 87, 97, 105, 111, 120, 125,
        125, 126, 130, 71, 66, 64, 63, 70, 78, 84, 92, 102, 111, 117, 127, 133,
        134, 136, 141, 81, 75, 73, 71, 77, 85, 91, 99, 110, 120, 127, 137, 143,
        145, 148, 152, 87, 81, 78, 75, 82, 90, 96, 103, 114, 125, 133, 143, 150,
        156, 160, 163, 93, 86, 83, 80, 85, 90, 98, 107, 118, 125, 134, 145, 156,
        163, 169, 177, 98, 92, 88, 86, 89, 96, 102, 109, 117, 126, 136, 148,
        160, 169, 176, 184, 104, 98, 94, 92, 92, 98, 104, 112, 121, 130, 141,
        152, 163, 177, 184, 191,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 32, 32, 34, 34, 36, 39, 41, 44, 48, 49, 54, 58, 59,
        65, 69, 71, 80, 81, 83, 87, 90, 93, 95, 98, 101, 104, 107, 31, 32, 32,
        32, 32, 32, 32, 34, 34, 35, 38, 39, 42, 46, 47, 51, 55, 57, 62, 66, 68,
        76, 77, 78, 83, 85, 88, 90, 93, 96, 99, 101, 31, 32, 32, 32, 32, 32, 32,
        33, 34, 34, 38, 39, 41, 45, 46, 50, 54, 55, 60, 64, 66, 73, 75, 76, 81,
        83, 86, 89, 92, 95, 98, 101, 31, 32, 32, 32, 32, 32, 32, 33, 34, 34, 37,
        38, 41, 44, 45, 49, 53, 54, 59, 63, 65, 72, 74, 75, 79, 81, 84, 86, 89,
        91, 94, 97, 31, 32, 32, 32, 33, 33, 34, 35, 36, 36, 39, 40, 42, 45, 46,
        50, 53, 54, 59, 63, 64, 71, 73, 74, 78, 80, 83, 85, 88, 91, 94, 97, 32,
        32, 32, 32, 33, 34, 34, 36, 36, 37, 40, 40, 42, 45, 46, 49, 53, 54, 58,
        62, 63, 70, 72, 73, 77, 79, 82, 85, 87, 90, 92, 95, 32, 32, 32, 32, 34,
        34, 35, 37, 37, 38, 40, 41, 42, 45, 46, 49, 52, 54, 58, 61, 63, 69, 71,
        72, 75, 78, 80, 83, 86, 89, 92, 95, 34, 34, 33, 33, 35, 36, 37, 39, 41,
        42, 45, 46, 47, 50, 51, 54, 57, 59, 63, 66, 68, 74, 75, 76, 80, 81, 82,
        83, 85, 87, 90, 93, 34, 34, 34, 34, 36, 36, 37, 41, 42, 45, 47, 48, 50,
        53, 53, 56, 59, 61, 65, 68, 70, 76, 77, 78, 82, 83, 85, 88, 89, 90, 92,
        93, 36, 35, 34, 34, 36, 37, 38, 42, 45, 48, 50, 51, 54, 56, 57, 60, 63,
        64, 68, 71, 73, 79, 80, 81, 85, 87, 89, 89, 90, 93, 96, 99, 39, 38, 38,
        37, 39, 40, 40, 45, 47, 50, 54, 55, 58, 61, 62, 65, 68, 69, 73, 76, 78,
        84, 85, 86, 90, 89, 90, 93, 96, 97, 98, 99, 41, 39, 39, 38, 40, 40, 41,
        46, 48, 51, 55, 56, 59, 62, 63, 67, 70, 71, 75, 78, 80, 86, 87, 88, 91,
        93, 96, 97, 97, 99, 102, 105, 44, 42, 41, 41, 42, 42, 42, 47, 50, 54,
        58, 59, 63, 66, 68, 71, 74, 75, 79, 83, 84, 90, 91, 92, 96, 98, 98, 99,
        102, 104, 104, 105, 48, 46, 45, 44, 45, 45, 45, 50, 53, 56, 61, 62, 66,
        70, 71, 76, 79, 80, 85, 88, 90, 96, 97, 98, 101, 100, 102, 105, 105,
        105, 109, 112, 49, 47, 46, 45, 46, 46, 46, 51, 53, 57, 62, 63, 68, 71,
        73, 77, 81, 82, 87, 90, 92, 98, 99, 100, 103, 106, 107, 106, 109, 112,
        112, 112, 54, 51, 50, 49, 50, 49, 49, 54, 56, 60, 65, 67, 71, 76, 77,
        82, 86, 87, 92, 96, 97, 104, 105, 106, 110, 110, 109, 113, 114, 113,
        116, 120, 58, 55, 54, 53, 53, 53, 52, 57, 59, 63, 68, 70, 74, 79, 81,
        86, 90, 91, 97, 100, 102, 109, 110, 111, 114, 114, 118, 116, 117, 121,
        121, 120, 59, 57, 55, 54, 54, 54, 54, 59, 61, 64, 69, 71, 75, 80, 82,
        87, 91, 93, 99, 102, 104, 111, 112, 113, 117, 121, 120, 122, 124, 122,
        125, 129, 65, 62, 60, 59, 59, 58, 58, 63, 65, 68, 73, 75, 79, 85, 87,
        92, 97, 99, 105, 109, 111, 118, 120, 121, 125, 124, 125, 127, 126, 130,
        130, 129, 69, 66, 64, 63, 63, 62, 61, 66, 68, 71, 76, 78, 83, 88, 90,
        96, 100, 102, 109, 113, 115, 123, 125, 126, 129, 130, 131, 130, 134,
        133, 135, 139, 71, 68, 66, 65, 64, 63, 63, 68, 70, 73, 78, 80, 84, 90,
        92, 97, 102, 104, 111, 115, 117, 125, 127, 128, 133, 136, 134, 139, 136,
        139, 141, 140, 80, 76, 73, 72, 71, 70, 69, 74, 76, 79, 84, 86, 90, 96,
        98, 104, 109, 111, 118, 123, 125, 134, 136, 137, 142, 138, 143, 140,
        144, 144, 144, 149, 81, 77, 75, 74, 73, 72, 71, 75, 77, 80, 85, 87, 91,
        97, 99, 105, 110, 112, 120, 125, 127, 136, 137, 139, 143, 148, 145, 148,
        148, 150, 152, 149, 83, 78, 76, 75, 74, 73, 72, 76, 78, 81, 86, 88, 92,
        98, 100, 106, 111, 113, 121, 126, 128, 137, 139, 140, 145, 149, 153,
        153, 154, 155, 155, 161, 87, 83, 81, 79, 78, 77, 75, 80, 82, 85, 90, 91,
        96, 101, 103, 110, 114, 117, 125, 129, 133, 142, 143, 145, 150, 151,
        156, 159, 160, 160, 163, 161, 90, 85, 83, 81, 80, 79, 78, 81, 83, 87,
        89, 93, 98, 100, 106, 110, 114, 121, 124, 130, 136, 138, 148, 149, 151,
        156, 157, 162, 166, 168, 166, 172, 93, 88, 86, 84, 83, 82, 80, 82, 85,
        89, 90, 96, 98, 102, 107, 109, 118, 120, 125, 131, 134, 143, 145, 153,
        156, 157, 163, 164, 169, 172, 177, 172, 95, 90, 89, 86, 85, 85, 83, 83,
        88, 89, 93, 97, 99, 105, 106, 113, 116, 122, 127, 130, 139, 140, 148,
        153, 159, 162, 164, 169, 170, 176, 179, 185, 98, 93, 92, 89, 88, 87, 86,
        85, 89, 90, 96, 97, 102, 105, 109, 114, 117, 124, 126, 134, 136, 144,
        148, 154, 160, 166, 169, 170, 176, 177, 184, 186, 101, 96, 95, 91, 91,
        90, 89, 87, 90, 93, 97, 99, 104, 105, 112, 113, 121, 122, 130, 133, 139,
        144, 150, 155, 160, 168, 172, 176, 177, 184, 185, 191, 104, 99, 98, 94,
        94, 92, 92, 90, 92, 96, 98, 102, 104, 109, 112, 116, 121, 125, 130, 135,
        141, 144, 152, 155, 163, 166, 177, 179, 184, 185, 191, 192, 107, 101,
        101, 97, 97, 95, 95, 93, 93, 99, 99, 105, 105, 112, 112, 120, 120, 129,
        129, 139, 140, 149, 149, 161, 161, 172, 172, 185, 186, 191, 192, 199,
        /* Size 4x8 */
        32, 38, 62, 86, 32, 40, 58, 80, 34, 51, 68, 85, 44, 61, 85, 101, 54, 69,
        98, 117, 72, 84, 118, 136, 82, 89, 129, 157, 92, 98, 127, 165,
        /* Size 8x4 */
        32, 32, 34, 44, 54, 72, 82, 92, 38, 40, 51, 61, 69, 84, 89, 98, 62, 58,
        68, 85, 98, 118, 129, 127, 86, 80, 85, 101, 117, 136, 157, 165,
        /* Size 8x16 */
        32, 32, 36, 44, 58, 79, 88, 93, 31, 32, 35, 41, 54, 73, 81, 88, 32, 33,
        36, 42, 53, 71, 78, 84, 32, 34, 38, 42, 52, 69, 76, 82, 34, 36, 44, 50,
        59, 75, 81, 84, 39, 39, 50, 58, 68, 84, 88, 90, 44, 42, 53, 63, 74, 90,
        97, 97, 49, 46, 57, 67, 81, 97, 104, 105, 57, 53, 63, 74, 90, 108, 111,
        113, 65, 59, 68, 79, 97, 118, 123, 122, 71, 64, 73, 84, 102, 125, 135,
        131, 81, 72, 80, 91, 110, 135, 145, 141, 87, 77, 85, 96, 114, 140, 148,
        151, 92, 83, 88, 102, 117, 133, 153, 163, 98, 88, 89, 103, 121, 141,
        160, 169, 103, 94, 92, 103, 119, 137, 158, 175,
        /* Size 16x8 */
        32, 31, 32, 32, 34, 39, 44, 49, 57, 65, 71, 81, 87, 92, 98, 103, 32, 32,
        33, 34, 36, 39, 42, 46, 53, 59, 64, 72, 77, 83, 88, 94, 36, 35, 36, 38,
        44, 50, 53, 57, 63, 68, 73, 80, 85, 88, 89, 92, 44, 41, 42, 42, 50, 58,
        63, 67, 74, 79, 84, 91, 96, 102, 103, 103, 58, 54, 53, 52, 59, 68, 74,
        81, 90, 97, 102, 110, 114, 117, 121, 119, 79, 73, 71, 69, 75, 84, 90,
        97, 108, 118, 125, 135, 140, 133, 141, 137, 88, 81, 78, 76, 81, 88, 97,
        104, 111, 123, 135, 145, 148, 153, 160, 158, 93, 88, 84, 82, 84, 90, 97,
        105, 113, 122, 131, 141, 151, 163, 169, 175,
        /* Size 16x32 */
        32, 31, 32, 32, 36, 39, 44, 53, 58, 65, 79, 81, 88, 90, 93, 96, 31, 32,
        32, 32, 35, 38, 42, 51, 55, 62, 75, 77, 83, 86, 88, 91, 31, 32, 32, 32,
        35, 38, 41, 50, 54, 60, 73, 75, 81, 84, 88, 91, 31, 32, 32, 33, 34, 37,
        41, 49, 53, 59, 72, 74, 79, 82, 84, 87, 32, 32, 33, 34, 36, 39, 42, 50,
        53, 59, 71, 72, 78, 81, 84, 87, 32, 32, 34, 34, 37, 40, 42, 49, 53, 58,
        70, 71, 77, 80, 83, 85, 32, 33, 34, 35, 38, 40, 42, 49, 52, 58, 69, 70,
        76, 78, 82, 86, 34, 34, 35, 37, 42, 45, 48, 54, 57, 63, 73, 75, 79, 79,
        81, 83, 34, 34, 36, 37, 44, 47, 50, 56, 59, 65, 75, 77, 81, 83, 84, 84,
        36, 34, 37, 38, 48, 51, 54, 60, 63, 68, 78, 80, 85, 85, 86, 89, 39, 37,
        39, 40, 50, 54, 58, 65, 68, 73, 84, 85, 88, 89, 90, 89, 40, 38, 40, 41,
        51, 55, 59, 67, 70, 75, 85, 87, 91, 92, 92, 95, 44, 41, 42, 43, 53, 58,
        63, 71, 74, 79, 90, 91, 97, 94, 97, 95, 47, 44, 45, 46, 56, 61, 66, 75,
        79, 85, 95, 97, 99, 101, 98, 102, 49, 46, 46, 47, 57, 62, 67, 77, 81,
        86, 97, 99, 104, 102, 105, 102, 53, 49, 50, 50, 60, 65, 71, 82, 86, 92,
        103, 105, 109, 108, 106, 110, 57, 53, 53, 53, 63, 68, 74, 86, 90, 97,
        108, 110, 111, 112, 113, 110, 59, 54, 54, 54, 64, 69, 75, 87, 91, 98,
        111, 112, 119, 117, 115, 118, 65, 60, 59, 58, 68, 73, 79, 92, 97, 105,
        118, 119, 123, 123, 122, 119, 69, 63, 62, 62, 71, 76, 83, 96, 100, 109,
        122, 124, 127, 125, 125, 128, 71, 65, 64, 63, 73, 78, 84, 97, 102, 111,
        125, 127, 135, 134, 131, 129, 79, 72, 71, 70, 79, 84, 90, 104, 109, 118,
        133, 135, 137, 136, 136, 137, 81, 74, 72, 71, 80, 85, 91, 105, 110, 120,
        135, 137, 145, 143, 141, 138, 82, 75, 73, 72, 81, 86, 92, 106, 111, 121,
        136, 139, 147, 148, 147, 149, 87, 79, 77, 76, 85, 90, 96, 110, 114, 125,
        140, 143, 148, 154, 151, 149, 90, 82, 80, 78, 87, 89, 99, 108, 113, 129,
        135, 146, 153, 157, 160, 159, 92, 84, 83, 81, 88, 90, 102, 106, 117,
        128, 133, 150, 153, 158, 163, 160, 95, 87, 85, 83, 88, 92, 103, 105,
        120, 125, 137, 148, 155, 164, 168, 173, 98, 89, 88, 85, 89, 95, 103,
        108, 121, 124, 141, 144, 160, 164, 169, 174, 100, 92, 91, 88, 90, 98,
        103, 111, 120, 127, 139, 146, 161, 165, 175, 179, 103, 94, 94, 90, 92,
        101, 103, 114, 119, 131, 137, 150, 158, 170, 175, 180, 106, 97, 97, 93,
        93, 104, 104, 118, 118, 135, 135, 154, 155, 175, 176, 187,
        /* Size 32x16 */
        32, 31, 31, 31, 32, 32, 32, 34, 34, 36, 39, 40, 44, 47, 49, 53, 57, 59,
        65, 69, 71, 79, 81, 82, 87, 90, 92, 95, 98, 100, 103, 106, 31, 32, 32,
        32, 32, 32, 33, 34, 34, 34, 37, 38, 41, 44, 46, 49, 53, 54, 60, 63, 65,
        72, 74, 75, 79, 82, 84, 87, 89, 92, 94, 97, 32, 32, 32, 32, 33, 34, 34,
        35, 36, 37, 39, 40, 42, 45, 46, 50, 53, 54, 59, 62, 64, 71, 72, 73, 77,
        80, 83, 85, 88, 91, 94, 97, 32, 32, 32, 33, 34, 34, 35, 37, 37, 38, 40,
        41, 43, 46, 47, 50, 53, 54, 58, 62, 63, 70, 71, 72, 76, 78, 81, 83, 85,
        88, 90, 93, 36, 35, 35, 34, 36, 37, 38, 42, 44, 48, 50, 51, 53, 56, 57,
        60, 63, 64, 68, 71, 73, 79, 80, 81, 85, 87, 88, 88, 89, 90, 92, 93, 39,
        38, 38, 37, 39, 40, 40, 45, 47, 51, 54, 55, 58, 61, 62, 65, 68, 69, 73,
        76, 78, 84, 85, 86, 90, 89, 90, 92, 95, 98, 101, 104, 44, 42, 41, 41,
        42, 42, 42, 48, 50, 54, 58, 59, 63, 66, 67, 71, 74, 75, 79, 83, 84, 90,
        91, 92, 96, 99, 102, 103, 103, 103, 103, 104, 53, 51, 50, 49, 50, 49,
        49, 54, 56, 60, 65, 67, 71, 75, 77, 82, 86, 87, 92, 96, 97, 104, 105,
        106, 110, 108, 106, 105, 108, 111, 114, 118, 58, 55, 54, 53, 53, 53, 52,
        57, 59, 63, 68, 70, 74, 79, 81, 86, 90, 91, 97, 100, 102, 109, 110, 111,
        114, 113, 117, 120, 121, 120, 119, 118, 65, 62, 60, 59, 59, 58, 58, 63,
        65, 68, 73, 75, 79, 85, 86, 92, 97, 98, 105, 109, 111, 118, 120, 121,
        125, 129, 128, 125, 124, 127, 131, 135, 79, 75, 73, 72, 71, 70, 69, 73,
        75, 78, 84, 85, 90, 95, 97, 103, 108, 111, 118, 122, 125, 133, 135, 136,
        140, 135, 133, 137, 141, 139, 137, 135, 81, 77, 75, 74, 72, 71, 70, 75,
        77, 80, 85, 87, 91, 97, 99, 105, 110, 112, 119, 124, 127, 135, 137, 139,
        143, 146, 150, 148, 144, 146, 150, 154, 88, 83, 81, 79, 78, 77, 76, 79,
        81, 85, 88, 91, 97, 99, 104, 109, 111, 119, 123, 127, 135, 137, 145,
        147, 148, 153, 153, 155, 160, 161, 158, 155, 90, 86, 84, 82, 81, 80, 78,
        79, 83, 85, 89, 92, 94, 101, 102, 108, 112, 117, 123, 125, 134, 136,
        143, 148, 154, 157, 158, 164, 164, 165, 170, 175, 93, 88, 88, 84, 84,
        83, 82, 81, 84, 86, 90, 92, 97, 98, 105, 106, 113, 115, 122, 125, 131,
        136, 141, 147, 151, 160, 163, 168, 169, 175, 175, 176, 96, 91, 91, 87,
        87, 85, 86, 83, 84, 89, 89, 95, 95, 102, 102, 110, 110, 118, 119, 128,
        129, 137, 138, 149, 149, 159, 160, 173, 174, 179, 180, 187 },
      { /* Chroma */
        /* Size 4x4 */
        32, 45, 53, 63, 45, 55, 62, 67, 53, 62, 80, 84, 63, 67, 84, 101,
        /* Size 8x8 */
        31, 36, 47, 48, 52, 60, 64, 67, 36, 43, 47, 46, 49, 55, 59, 63, 47, 47,
        53, 54, 55, 60, 63, 64, 48, 46, 54, 61, 65, 70, 71, 71, 52, 49, 55, 65,
        71, 78, 81, 79, 60, 55, 60, 70, 78, 89, 89, 89, 64, 59, 63, 71, 81, 89,
        97, 99, 67, 63, 64, 71, 79, 89, 99, 104,
        /* Size 16x16 */
        32, 30, 33, 36, 44, 48, 49, 51, 54, 57, 60, 64, 67, 68, 70, 72, 30, 31,
        35, 39, 44, 46, 46, 47, 50, 53, 55, 59, 61, 64, 66, 68, 33, 35, 39, 43,
        46, 46, 45, 47, 49, 51, 53, 57, 59, 61, 63, 65, 36, 39, 43, 47, 47, 46,
        45, 46, 48, 50, 52, 55, 57, 58, 61, 63, 44, 44, 46, 47, 50, 51, 51, 51,
        53, 54, 56, 59, 61, 61, 63, 62, 48, 46, 46, 46, 51, 54, 55, 56, 58, 60,
        61, 64, 65, 64, 66, 66, 49, 46, 45, 45, 51, 55, 58, 60, 62, 63, 65, 68,
        69, 69, 69, 69, 51, 47, 47, 46, 51, 56, 60, 62, 65, 67, 69, 72, 73, 74,
        73, 73, 54, 50, 49, 48, 53, 58, 62, 65, 70, 73, 75, 78, 79, 79, 77, 77,
        57, 53, 51, 50, 54, 60, 63, 67, 73, 76, 79, 82, 84, 83, 82, 82, 60, 55,
        53, 52, 56, 61, 65, 69, 75, 79, 82, 86, 88, 87, 86, 87, 64, 59, 57, 55,
        59, 64, 68, 72, 78, 82, 86, 90, 93, 92, 91, 92, 67, 61, 59, 57, 61, 65,
        69, 73, 79, 84, 88, 93, 95, 96, 96, 96, 68, 64, 61, 58, 61, 64, 69, 74,
        79, 83, 87, 92, 96, 99, 100, 101, 70, 66, 63, 61, 63, 66, 69, 73, 77,
        82, 86, 91, 96, 100, 103, 104, 72, 68, 65, 63, 62, 66, 69, 73, 77, 82,
        87, 92, 96, 101, 104, 106,
        /* Size 32x32 */
        32, 31, 30, 30, 33, 35, 36, 41, 44, 49, 48, 48, 49, 50, 51, 52, 54, 55,
        57, 59, 60, 63, 64, 65, 67, 68, 68, 69, 70, 71, 72, 73, 31, 31, 31, 31,
        34, 36, 38, 42, 44, 47, 47, 47, 47, 48, 48, 50, 51, 52, 54, 56, 57, 60,
        61, 61, 63, 64, 65, 66, 67, 67, 68, 69, 30, 31, 31, 31, 35, 37, 39, 42,
        44, 47, 46, 46, 46, 47, 47, 48, 50, 51, 53, 54, 55, 58, 59, 60, 61, 63,
        64, 65, 66, 67, 68, 69, 30, 31, 31, 32, 35, 37, 40, 42, 44, 46, 45, 45,
        45, 46, 46, 47, 49, 50, 52, 53, 54, 57, 58, 58, 60, 61, 62, 63, 63, 64,
        65, 66, 33, 34, 35, 35, 39, 41, 43, 45, 46, 47, 46, 46, 45, 46, 47, 47,
        49, 49, 51, 53, 53, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 35, 36,
        37, 37, 41, 43, 45, 46, 46, 47, 46, 46, 45, 46, 46, 47, 48, 49, 50, 52,
        53, 55, 56, 56, 58, 59, 60, 61, 62, 63, 64, 64, 36, 38, 39, 40, 43, 45,
        47, 47, 47, 48, 46, 46, 45, 46, 46, 47, 48, 48, 50, 51, 52, 54, 55, 55,
        57, 58, 58, 59, 61, 62, 63, 64, 41, 42, 42, 42, 45, 46, 47, 48, 49, 50,
        49, 49, 49, 50, 50, 50, 51, 52, 53, 54, 55, 57, 58, 58, 60, 60, 59, 59,
        60, 61, 61, 62, 44, 44, 44, 44, 46, 46, 47, 49, 50, 51, 51, 51, 51, 51,
        51, 52, 53, 53, 54, 56, 56, 59, 59, 59, 61, 61, 61, 62, 63, 62, 62, 62,
        49, 47, 47, 46, 47, 47, 48, 50, 51, 53, 53, 53, 53, 54, 54, 54, 55, 55,
        56, 58, 58, 60, 61, 61, 63, 63, 64, 63, 63, 64, 65, 66, 48, 47, 46, 45,
        46, 46, 46, 49, 51, 53, 54, 54, 55, 56, 56, 57, 58, 59, 60, 61, 61, 63,
        64, 64, 65, 65, 64, 65, 66, 66, 66, 66, 48, 47, 46, 45, 46, 46, 46, 49,
        51, 53, 54, 55, 56, 57, 57, 58, 59, 60, 61, 62, 63, 65, 65, 65, 66, 67,
        68, 67, 67, 67, 68, 69, 49, 47, 46, 45, 45, 45, 45, 49, 51, 53, 55, 56,
        58, 59, 60, 61, 62, 62, 63, 65, 65, 67, 68, 68, 69, 70, 69, 69, 69, 70,
        69, 69, 50, 48, 47, 46, 46, 46, 46, 50, 51, 54, 56, 57, 59, 61, 62, 63,
        64, 65, 66, 68, 68, 70, 71, 71, 72, 71, 71, 72, 71, 71, 71, 72, 51, 48,
        47, 46, 47, 46, 46, 50, 51, 54, 56, 57, 60, 62, 62, 64, 65, 66, 67, 69,
        69, 71, 72, 72, 73, 74, 74, 72, 73, 74, 73, 73, 52, 50, 48, 47, 47, 47,
        47, 50, 52, 54, 57, 58, 61, 63, 64, 66, 68, 68, 70, 72, 72, 75, 75, 75,
        77, 76, 75, 76, 76, 74, 75, 76, 54, 51, 50, 49, 49, 48, 48, 51, 53, 55,
        58, 59, 62, 64, 65, 68, 70, 70, 73, 74, 75, 77, 78, 78, 79, 78, 79, 78,
        77, 78, 77, 77, 55, 52, 51, 50, 49, 49, 48, 52, 53, 55, 59, 60, 62, 65,
        66, 68, 70, 71, 73, 75, 76, 78, 79, 79, 80, 81, 80, 80, 81, 79, 79, 81,
        57, 54, 53, 52, 51, 50, 50, 53, 54, 56, 60, 61, 63, 66, 67, 70, 73, 73,
        76, 78, 79, 82, 82, 83, 84, 83, 83, 83, 82, 83, 82, 81, 59, 56, 54, 53,
        53, 52, 51, 54, 56, 58, 61, 62, 65, 68, 69, 72, 74, 75, 78, 80, 81, 84,
        85, 85, 86, 86, 86, 84, 85, 84, 84, 85, 60, 57, 55, 54, 53, 53, 52, 55,
        56, 58, 61, 63, 65, 68, 69, 72, 75, 76, 79, 81, 82, 85, 86, 86, 88, 88,
        87, 88, 86, 87, 87, 85, 63, 60, 58, 57, 56, 55, 54, 57, 59, 60, 63, 65,
        67, 70, 71, 75, 77, 78, 82, 84, 85, 89, 89, 90, 92, 89, 91, 89, 90, 89,
        88, 89, 64, 61, 59, 58, 57, 56, 55, 58, 59, 61, 64, 65, 68, 71, 72, 75,
        78, 79, 82, 85, 86, 89, 90, 91, 93, 94, 92, 92, 91, 91, 92, 90, 65, 61,
        60, 58, 57, 56, 55, 58, 59, 61, 64, 65, 68, 71, 72, 75, 78, 79, 83, 85,
        86, 90, 91, 91, 93, 94, 95, 94, 94, 94, 93, 94, 67, 63, 61, 60, 59, 58,
        57, 60, 61, 63, 65, 66, 69, 72, 73, 77, 79, 80, 84, 86, 88, 92, 93, 93,
        95, 95, 96, 97, 96, 95, 96, 94, 68, 64, 63, 61, 60, 59, 58, 60, 61, 63,
        65, 67, 70, 71, 74, 76, 78, 81, 83, 86, 88, 89, 94, 94, 95, 97, 97, 98,
        99, 99, 97, 99, 68, 65, 64, 62, 61, 60, 58, 59, 61, 64, 64, 68, 69, 71,
        74, 75, 79, 80, 83, 86, 87, 91, 92, 95, 96, 97, 99, 99, 100, 100, 101,
        99, 69, 66, 65, 63, 62, 61, 59, 59, 62, 63, 65, 67, 69, 72, 72, 76, 78,
        80, 83, 84, 88, 89, 92, 94, 97, 98, 99, 101, 100, 102, 102, 104, 70, 67,
        66, 63, 63, 62, 61, 60, 63, 63, 66, 67, 69, 71, 73, 76, 77, 81, 82, 85,
        86, 90, 91, 94, 96, 99, 100, 100, 103, 102, 104, 104, 71, 67, 67, 64,
        64, 63, 62, 61, 62, 64, 66, 67, 70, 71, 74, 74, 78, 79, 83, 84, 87, 89,
        91, 94, 95, 99, 100, 102, 102, 104, 104, 106, 72, 68, 68, 65, 65, 64,
        63, 61, 62, 65, 66, 68, 69, 71, 73, 75, 77, 79, 82, 84, 87, 88, 92, 93,
        96, 97, 101, 102, 104, 104, 106, 106, 73, 69, 69, 66, 66, 64, 64, 62,
        62, 66, 66, 69, 69, 72, 73, 76, 77, 81, 81, 85, 85, 89, 90, 94, 94, 99,
        99, 104, 104, 106, 106, 108,
        /* Size 4x8 */
        31, 47, 54, 64, 38, 46, 50, 60, 46, 53, 57, 62, 46, 56, 66, 71, 50, 59,
        74, 79, 57, 64, 82, 88, 61, 65, 85, 97, 65, 67, 82, 99,
        /* Size 8x4 */
        31, 38, 46, 46, 50, 57, 61, 65, 47, 46, 53, 56, 59, 64, 65, 67, 54, 50,
        57, 66, 74, 82, 85, 82, 64, 60, 62, 71, 79, 88, 97, 99,
        /* Size 8x16 */
        32, 34, 48, 49, 54, 63, 67, 69, 31, 36, 46, 46, 50, 58, 62, 65, 33, 40,
        47, 46, 49, 56, 59, 62, 37, 44, 47, 45, 48, 54, 57, 60, 44, 46, 51, 51,
        53, 59, 60, 61, 48, 46, 53, 56, 58, 64, 64, 64, 49, 45, 53, 58, 62, 67,
        70, 68, 51, 47, 54, 60, 65, 71, 73, 72, 54, 49, 55, 62, 70, 77, 77, 76,
        57, 51, 56, 64, 73, 82, 83, 81, 60, 53, 58, 65, 75, 85, 89, 85, 64, 57,
        61, 68, 78, 89, 93, 89, 66, 59, 63, 69, 79, 91, 94, 93, 68, 61, 63, 71,
        79, 87, 96, 98, 70, 63, 63, 70, 80, 89, 97, 100, 72, 65, 63, 69, 77, 86,
        95, 102,
        /* Size 16x8 */
        32, 31, 33, 37, 44, 48, 49, 51, 54, 57, 60, 64, 66, 68, 70, 72, 34, 36,
        40, 44, 46, 46, 45, 47, 49, 51, 53, 57, 59, 61, 63, 65, 48, 46, 47, 47,
        51, 53, 53, 54, 55, 56, 58, 61, 63, 63, 63, 63, 49, 46, 46, 45, 51, 56,
        58, 60, 62, 64, 65, 68, 69, 71, 70, 69, 54, 50, 49, 48, 53, 58, 62, 65,
        70, 73, 75, 78, 79, 79, 80, 77, 63, 58, 56, 54, 59, 64, 67, 71, 77, 82,
        85, 89, 91, 87, 89, 86, 67, 62, 59, 57, 60, 64, 70, 73, 77, 83, 89, 93,
        94, 96, 97, 95, 69, 65, 62, 60, 61, 64, 68, 72, 76, 81, 85, 89, 93, 98,
        100, 102,
        /* Size 16x32 */
        32, 31, 34, 37, 48, 48, 49, 52, 54, 57, 63, 64, 67, 68, 69, 69, 31, 31,
        35, 38, 47, 47, 47, 50, 51, 54, 60, 61, 63, 64, 65, 66, 31, 32, 36, 39,
        46, 46, 46, 48, 50, 53, 58, 59, 62, 63, 65, 66, 30, 32, 36, 40, 46, 45,
        45, 48, 49, 52, 57, 58, 60, 61, 62, 63, 33, 36, 40, 43, 47, 46, 46, 47,
        49, 51, 56, 57, 59, 60, 62, 63, 35, 38, 42, 45, 47, 46, 45, 47, 48, 50,
        55, 56, 58, 60, 61, 61, 37, 40, 44, 47, 47, 46, 45, 47, 48, 50, 54, 55,
        57, 58, 60, 61, 42, 43, 45, 47, 50, 50, 49, 50, 51, 53, 57, 58, 59, 58,
        59, 59, 44, 44, 46, 47, 51, 51, 51, 52, 53, 54, 59, 59, 60, 61, 61, 60,
        49, 46, 47, 48, 53, 53, 53, 54, 55, 57, 60, 61, 63, 62, 62, 63, 48, 46,
        46, 47, 53, 54, 56, 57, 58, 60, 64, 64, 64, 64, 64, 63, 48, 45, 46, 46,
        53, 55, 56, 58, 59, 61, 65, 65, 66, 66, 65, 66, 49, 45, 45, 46, 53, 56,
        58, 61, 62, 64, 67, 68, 70, 67, 68, 66, 50, 46, 46, 46, 54, 56, 59, 63,
        65, 66, 70, 71, 70, 71, 68, 70, 51, 47, 47, 47, 54, 57, 60, 64, 65, 68,
        71, 72, 73, 71, 72, 70, 52, 48, 47, 47, 54, 57, 61, 66, 68, 71, 75, 75,
        76, 75, 73, 73, 54, 49, 49, 48, 55, 58, 62, 68, 70, 73, 77, 78, 77, 77,
        76, 74, 54, 50, 49, 49, 55, 59, 62, 68, 70, 74, 78, 79, 81, 79, 77, 78,
        57, 52, 51, 50, 56, 60, 64, 70, 73, 76, 82, 82, 83, 82, 81, 78, 59, 54,
        52, 52, 58, 61, 65, 72, 74, 78, 84, 85, 85, 83, 82, 82, 60, 54, 53, 52,
        58, 62, 65, 72, 75, 79, 85, 86, 89, 87, 85, 82, 63, 57, 56, 55, 60, 64,
        67, 75, 77, 82, 89, 90, 90, 88, 87, 86, 64, 58, 57, 55, 61, 64, 68, 75,
        78, 82, 89, 90, 93, 91, 89, 87, 64, 59, 57, 56, 61, 65, 68, 75, 78, 83,
        90, 91, 94, 93, 92, 91, 66, 60, 59, 57, 63, 66, 69, 77, 79, 84, 91, 93,
        94, 95, 93, 91, 67, 61, 60, 58, 63, 65, 70, 75, 78, 85, 88, 93, 96, 97,
        97, 95, 68, 62, 61, 59, 63, 64, 71, 74, 79, 84, 87, 94, 96, 97, 98, 96,
        69, 63, 62, 60, 63, 65, 71, 72, 80, 82, 88, 93, 96, 99, 100, 101, 70,
        64, 63, 60, 63, 66, 70, 73, 80, 81, 89, 90, 97, 99, 100, 101, 71, 65,
        64, 61, 63, 67, 70, 74, 78, 82, 88, 90, 97, 99, 102, 103, 72, 65, 65,
        62, 63, 68, 69, 75, 77, 83, 86, 92, 95, 100, 102, 103, 73, 66, 66, 63,
        63, 69, 69, 76, 76, 84, 84, 93, 93, 101, 101, 105,
        /* Size 32x16 */
        32, 31, 31, 30, 33, 35, 37, 42, 44, 49, 48, 48, 49, 50, 51, 52, 54, 54,
        57, 59, 60, 63, 64, 64, 66, 67, 68, 69, 70, 71, 72, 73, 31, 31, 32, 32,
        36, 38, 40, 43, 44, 46, 46, 45, 45, 46, 47, 48, 49, 50, 52, 54, 54, 57,
        58, 59, 60, 61, 62, 63, 64, 65, 65, 66, 34, 35, 36, 36, 40, 42, 44, 45,
        46, 47, 46, 46, 45, 46, 47, 47, 49, 49, 51, 52, 53, 56, 57, 57, 59, 60,
        61, 62, 63, 64, 65, 66, 37, 38, 39, 40, 43, 45, 47, 47, 47, 48, 47, 46,
        46, 46, 47, 47, 48, 49, 50, 52, 52, 55, 55, 56, 57, 58, 59, 60, 60, 61,
        62, 63, 48, 47, 46, 46, 47, 47, 47, 50, 51, 53, 53, 53, 53, 54, 54, 54,
        55, 55, 56, 58, 58, 60, 61, 61, 63, 63, 63, 63, 63, 63, 63, 63, 48, 47,
        46, 45, 46, 46, 46, 50, 51, 53, 54, 55, 56, 56, 57, 57, 58, 59, 60, 61,
        62, 64, 64, 65, 66, 65, 64, 65, 66, 67, 68, 69, 49, 47, 46, 45, 46, 45,
        45, 49, 51, 53, 56, 56, 58, 59, 60, 61, 62, 62, 64, 65, 65, 67, 68, 68,
        69, 70, 71, 71, 70, 70, 69, 69, 52, 50, 48, 48, 47, 47, 47, 50, 52, 54,
        57, 58, 61, 63, 64, 66, 68, 68, 70, 72, 72, 75, 75, 75, 77, 75, 74, 72,
        73, 74, 75, 76, 54, 51, 50, 49, 49, 48, 48, 51, 53, 55, 58, 59, 62, 65,
        65, 68, 70, 70, 73, 74, 75, 77, 78, 78, 79, 78, 79, 80, 80, 78, 77, 76,
        57, 54, 53, 52, 51, 50, 50, 53, 54, 57, 60, 61, 64, 66, 68, 71, 73, 74,
        76, 78, 79, 82, 82, 83, 84, 85, 84, 82, 81, 82, 83, 84, 63, 60, 58, 57,
        56, 55, 54, 57, 59, 60, 64, 65, 67, 70, 71, 75, 77, 78, 82, 84, 85, 89,
        89, 90, 91, 88, 87, 88, 89, 88, 86, 84, 64, 61, 59, 58, 57, 56, 55, 58,
        59, 61, 64, 65, 68, 71, 72, 75, 78, 79, 82, 85, 86, 90, 90, 91, 93, 93,
        94, 93, 90, 90, 92, 93, 67, 63, 62, 60, 59, 58, 57, 59, 60, 63, 64, 66,
        70, 70, 73, 76, 77, 81, 83, 85, 89, 90, 93, 94, 94, 96, 96, 96, 97, 97,
        95, 93, 68, 64, 63, 61, 60, 60, 58, 58, 61, 62, 64, 66, 67, 71, 71, 75,
        77, 79, 82, 83, 87, 88, 91, 93, 95, 97, 97, 99, 99, 99, 100, 101, 69,
        65, 65, 62, 62, 61, 60, 59, 61, 62, 64, 65, 68, 68, 72, 73, 76, 77, 81,
        82, 85, 87, 89, 92, 93, 97, 98, 100, 100, 102, 102, 101, 69, 66, 66, 63,
        63, 61, 61, 59, 60, 63, 63, 66, 66, 70, 70, 73, 74, 78, 78, 82, 82, 86,
        87, 91, 91, 95, 96, 101, 101, 103, 103, 105 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 37, 58, 81, 37, 54, 72, 91, 58, 72, 102, 121, 81, 91, 121, 156,
        /* Size 8x8 */
        32, 32, 35, 42, 53, 68, 78, 90, 32, 33, 36, 42, 51, 64, 74, 84, 35, 36,
        46, 52, 60, 72, 80, 87, 42, 42, 52, 63, 73, 84, 92, 98, 53, 51, 60, 73,
        86, 100, 109, 114, 68, 64, 72, 84, 100, 117, 128, 133, 78, 74, 80, 92,
        109, 128, 140, 155, 90, 84, 87, 98, 114, 133, 155, 168,
        /* Size 16x16 */
        32, 31, 31, 32, 34, 36, 41, 47, 54, 59, 65, 74, 82, 87, 92, 97, 31, 32,
        32, 32, 34, 35, 39, 45, 50, 55, 61, 69, 76, 81, 87, 92, 31, 32, 33, 33,
        35, 36, 40, 44, 49, 54, 59, 67, 73, 78, 83, 88, 32, 32, 33, 35, 37, 38,
        41, 45, 49, 53, 58, 65, 71, 75, 80, 86, 34, 34, 35, 37, 39, 42, 46, 50,
        54, 58, 63, 70, 76, 80, 84, 85, 36, 35, 36, 38, 42, 48, 52, 56, 60, 64,
        68, 75, 80, 85, 90, 91, 41, 39, 40, 41, 46, 52, 57, 62, 67, 71, 75, 83,
        88, 92, 95, 97, 47, 45, 44, 45, 50, 56, 62, 69, 75, 79, 84, 91, 97, 100,
        102, 104, 54, 50, 49, 49, 54, 60, 67, 75, 82, 87, 92, 100, 106, 110,
        109, 112, 59, 55, 54, 53, 58, 64, 71, 79, 87, 92, 98, 106, 112, 117,
        117, 121, 65, 61, 59, 58, 63, 68, 75, 84, 92, 98, 105, 114, 120, 125,
        126, 130, 74, 69, 67, 65, 70, 75, 83, 91, 100, 106, 114, 123, 131, 135,
        137, 140, 82, 76, 73, 71, 76, 80, 88, 97, 106, 112, 120, 131, 139, 144,
        148, 150, 87, 81, 78, 75, 80, 85, 92, 100, 110, 117, 125, 135, 144, 150,
        155, 162, 92, 87, 83, 80, 84, 90, 95, 102, 109, 117, 126, 137, 148, 155,
        162, 168, 97, 92, 88, 86, 85, 91, 97, 104, 112, 121, 130, 140, 150, 162,
        168, 174,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 32, 32, 34, 35, 36, 39, 41, 44, 47, 48, 54, 56,
        59, 64, 65, 71, 74, 80, 82, 83, 87, 90, 92, 95, 97, 100, 31, 32, 32, 32,
        32, 32, 32, 33, 34, 35, 35, 38, 40, 42, 45, 46, 51, 53, 56, 61, 62, 68,
        71, 76, 78, 78, 83, 85, 88, 90, 92, 95, 31, 32, 32, 32, 32, 32, 32, 33,
        34, 34, 35, 38, 39, 42, 45, 45, 50, 52, 55, 60, 61, 67, 69, 74, 76, 77,
        81, 84, 87, 89, 92, 95, 31, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 37,
        38, 41, 44, 44, 49, 51, 54, 58, 59, 65, 68, 72, 74, 75, 79, 81, 84, 86,
        88, 90, 31, 32, 32, 32, 33, 33, 33, 34, 35, 36, 36, 39, 40, 42, 44, 45,
        49, 51, 54, 58, 59, 64, 67, 71, 73, 74, 78, 80, 83, 85, 88, 90, 31, 32,
        32, 32, 33, 33, 34, 34, 35, 36, 36, 39, 40, 42, 45, 45, 50, 51, 54, 58,
        59, 64, 67, 71, 73, 74, 78, 80, 82, 84, 86, 89, 32, 32, 32, 32, 33, 34,
        35, 36, 37, 38, 38, 40, 41, 42, 45, 46, 49, 51, 53, 57, 58, 63, 65, 69,
        71, 72, 75, 78, 80, 83, 86, 89, 32, 33, 33, 33, 34, 34, 36, 36, 38, 39,
        40, 42, 43, 44, 47, 47, 51, 53, 55, 59, 60, 65, 67, 71, 73, 73, 77, 78,
        80, 82, 84, 86, 34, 34, 34, 33, 35, 35, 37, 38, 39, 42, 42, 45, 46, 47,
        50, 51, 54, 56, 58, 62, 63, 68, 70, 74, 76, 76, 80, 82, 84, 85, 85, 86,
        35, 35, 34, 34, 36, 36, 38, 39, 42, 46, 47, 49, 50, 52, 55, 55, 59, 60,
        62, 66, 67, 72, 74, 78, 79, 80, 83, 84, 85, 87, 90, 92, 36, 35, 35, 34,
        36, 36, 38, 40, 42, 47, 48, 50, 52, 54, 56, 57, 60, 61, 64, 67, 68, 73,
        75, 79, 80, 81, 85, 87, 90, 91, 91, 92, 39, 38, 38, 37, 39, 39, 40, 42,
        45, 49, 50, 54, 55, 58, 60, 61, 65, 66, 69, 72, 73, 78, 80, 84, 86, 86,
        90, 91, 91, 92, 95, 97, 41, 40, 39, 38, 40, 40, 41, 43, 46, 50, 52, 55,
        57, 60, 62, 63, 67, 69, 71, 75, 75, 80, 83, 86, 88, 89, 92, 93, 95, 97,
        97, 98, 44, 42, 42, 41, 42, 42, 42, 44, 47, 52, 54, 58, 60, 63, 66, 67,
        71, 73, 75, 79, 79, 84, 86, 90, 92, 92, 96, 98, 98, 98, 101, 104, 47,
        45, 45, 44, 44, 45, 45, 47, 50, 55, 56, 60, 62, 66, 69, 70, 75, 77, 79,
        83, 84, 89, 91, 95, 97, 97, 100, 99, 102, 105, 104, 104, 48, 46, 45, 44,
        45, 45, 46, 47, 51, 55, 57, 61, 63, 67, 70, 71, 76, 78, 80, 84, 85, 90,
        93, 96, 98, 99, 102, 106, 106, 105, 108, 111, 54, 51, 50, 49, 49, 50,
        49, 51, 54, 59, 60, 65, 67, 71, 75, 76, 82, 84, 87, 91, 92, 97, 100,
        104, 106, 106, 110, 108, 109, 112, 112, 111, 56, 53, 52, 51, 51, 51, 51,
        53, 56, 60, 61, 66, 69, 73, 77, 78, 84, 86, 89, 93, 94, 100, 102, 106,
        108, 109, 112, 113, 115, 114, 116, 119, 59, 56, 55, 54, 54, 54, 53, 55,
        58, 62, 64, 69, 71, 75, 79, 80, 87, 89, 92, 97, 98, 103, 106, 110, 112,
        113, 117, 118, 117, 121, 121, 119, 64, 61, 60, 58, 58, 58, 57, 59, 62,
        66, 67, 72, 75, 79, 83, 84, 91, 93, 97, 102, 103, 109, 112, 116, 118,
        119, 122, 121, 125, 123, 125, 128, 65, 62, 61, 59, 59, 59, 58, 60, 63,
        67, 68, 73, 75, 79, 84, 85, 92, 94, 98, 103, 105, 111, 114, 118, 120,
        121, 125, 129, 126, 129, 130, 129, 71, 68, 67, 65, 64, 64, 63, 65, 68,
        72, 73, 78, 80, 84, 89, 90, 97, 100, 103, 109, 111, 117, 120, 125, 127,
        128, 133, 130, 134, 133, 133, 137, 74, 71, 69, 68, 67, 67, 65, 67, 70,
        74, 75, 80, 83, 86, 91, 93, 100, 102, 106, 112, 114, 120, 123, 128, 131,
        131, 135, 137, 137, 138, 140, 137, 80, 76, 74, 72, 71, 71, 69, 71, 74,
        78, 79, 84, 86, 90, 95, 96, 104, 106, 110, 116, 118, 125, 128, 134, 136,
        137, 142, 141, 142, 143, 143, 147, 82, 78, 76, 74, 73, 73, 71, 73, 76,
        79, 80, 86, 88, 92, 97, 98, 106, 108, 112, 118, 120, 127, 131, 136, 139,
        139, 144, 147, 148, 147, 150, 148, 83, 78, 77, 75, 74, 74, 72, 73, 76,
        80, 81, 86, 89, 92, 97, 99, 106, 109, 113, 119, 121, 128, 131, 137, 139,
        140, 145, 150, 152, 155, 152, 157, 87, 83, 81, 79, 78, 78, 75, 77, 80,
        83, 85, 90, 92, 96, 100, 102, 110, 112, 117, 122, 125, 133, 135, 142,
        144, 145, 150, 151, 155, 158, 162, 158, 90, 85, 84, 81, 80, 80, 78, 78,
        82, 84, 87, 91, 93, 98, 99, 106, 108, 113, 118, 121, 129, 130, 137, 141,
        147, 150, 151, 156, 156, 161, 164, 169, 92, 88, 87, 84, 83, 82, 80, 80,
        84, 85, 90, 91, 95, 98, 102, 106, 109, 115, 117, 125, 126, 134, 137,
        142, 148, 152, 155, 156, 162, 162, 168, 170, 95, 90, 89, 86, 85, 84, 83,
        82, 85, 87, 91, 92, 97, 98, 105, 105, 112, 114, 121, 123, 129, 133, 138,
        143, 147, 155, 158, 161, 162, 168, 168, 174, 97, 92, 92, 88, 88, 86, 86,
        84, 85, 90, 91, 95, 97, 101, 104, 108, 112, 116, 121, 125, 130, 133,
        140, 143, 150, 152, 162, 164, 168, 168, 174, 175, 100, 95, 95, 90, 90,
        89, 89, 86, 86, 92, 92, 97, 98, 104, 104, 111, 111, 119, 119, 128, 129,
        137, 137, 147, 148, 157, 158, 169, 170, 174, 175, 181,
        /* Size 4x8 */
        32, 35, 59, 83, 32, 36, 57, 78, 34, 47, 65, 82, 41, 53, 78, 97, 51, 61,
        92, 111, 65, 73, 108, 129, 75, 81, 117, 148, 86, 92, 119, 154,
        /* Size 8x4 */
        32, 32, 34, 41, 51, 65, 75, 86, 35, 36, 47, 53, 61, 73, 81, 92, 59, 57,
        65, 78, 92, 108, 117, 119, 83, 78, 82, 97, 111, 129, 148, 154,
        /* Size 8x16 */
        32, 31, 35, 44, 53, 65, 82, 90, 31, 32, 34, 41, 50, 61, 76, 85, 31, 33,
        35, 42, 49, 59, 73, 81, 32, 34, 37, 42, 49, 58, 71, 79, 34, 35, 41, 48,
        54, 63, 76, 81, 36, 36, 46, 54, 60, 68, 80, 87, 41, 40, 49, 60, 67, 76,
        88, 93, 47, 44, 53, 66, 75, 84, 97, 101, 53, 50, 57, 71, 82, 92, 106,
        108, 58, 54, 61, 75, 87, 98, 112, 116, 65, 59, 66, 79, 92, 105, 120,
        124, 74, 67, 73, 86, 100, 113, 131, 134, 82, 73, 79, 92, 105, 120, 139,
        142, 87, 78, 83, 96, 110, 125, 144, 153, 92, 83, 84, 97, 114, 132, 150,
        157, 97, 88, 86, 97, 111, 128, 147, 163,
        /* Size 16x8 */
        32, 31, 31, 32, 34, 36, 41, 47, 53, 58, 65, 74, 82, 87, 92, 97, 31, 32,
        33, 34, 35, 36, 40, 44, 50, 54, 59, 67, 73, 78, 83, 88, 35, 34, 35, 37,
        41, 46, 49, 53, 57, 61, 66, 73, 79, 83, 84, 86, 44, 41, 42, 42, 48, 54,
        60, 66, 71, 75, 79, 86, 92, 96, 97, 97, 53, 50, 49, 49, 54, 60, 67, 75,
        82, 87, 92, 100, 105, 110, 114, 111, 65, 61, 59, 58, 63, 68, 76, 84, 92,
        98, 105, 113, 120, 125, 132, 128, 82, 76, 73, 71, 76, 80, 88, 97, 106,
        112, 120, 131, 139, 144, 150, 147, 90, 85, 81, 79, 81, 87, 93, 101, 108,
        116, 124, 134, 142, 153, 157, 163,
        /* Size 16x32 */
        32, 31, 31, 32, 35, 36, 44, 47, 53, 62, 65, 79, 82, 88, 90, 93, 31, 32,
        32, 32, 35, 35, 42, 45, 51, 59, 62, 75, 78, 83, 86, 88, 31, 32, 32, 32,
        34, 35, 41, 45, 50, 58, 61, 74, 76, 82, 85, 88, 31, 32, 32, 33, 34, 34,
        41, 44, 49, 57, 59, 72, 74, 79, 82, 84, 31, 32, 33, 34, 35, 36, 42, 44,
        49, 57, 59, 71, 73, 79, 81, 84, 32, 32, 33, 34, 36, 36, 42, 45, 50, 57,
        59, 71, 73, 78, 80, 82, 32, 33, 34, 35, 37, 38, 42, 45, 49, 56, 58, 69,
        71, 76, 79, 83, 32, 33, 34, 36, 39, 40, 44, 47, 51, 58, 60, 71, 73, 76,
        78, 80, 34, 34, 35, 37, 41, 42, 48, 50, 54, 61, 63, 73, 76, 81, 81, 80,
        35, 34, 36, 38, 45, 47, 52, 55, 59, 65, 67, 77, 79, 82, 83, 86, 36, 34,
        36, 38, 46, 48, 54, 56, 60, 66, 68, 78, 80, 85, 87, 86, 39, 37, 39, 40,
        48, 50, 58, 60, 65, 71, 73, 84, 86, 89, 88, 91, 41, 39, 40, 41, 49, 51,
        60, 62, 67, 74, 76, 86, 88, 91, 93, 91, 44, 41, 42, 43, 51, 53, 63, 66,
        71, 78, 79, 90, 92, 97, 94, 97, 47, 44, 44, 45, 53, 56, 66, 69, 75, 82,
        84, 95, 97, 98, 101, 98, 48, 45, 45, 46, 54, 56, 67, 70, 76, 83, 85, 96,
        98, 104, 101, 105, 53, 49, 50, 50, 57, 60, 71, 75, 82, 90, 92, 103, 106,
        107, 108, 105, 55, 51, 51, 51, 59, 61, 72, 77, 84, 92, 94, 106, 108,
        111, 110, 112, 58, 54, 54, 54, 61, 63, 75, 79, 87, 95, 98, 110, 112,
        117, 116, 113, 63, 58, 58, 57, 65, 67, 78, 83, 91, 100, 103, 116, 118,
        119, 119, 121, 65, 60, 59, 58, 66, 68, 79, 84, 92, 102, 105, 118, 120,
        127, 124, 122, 71, 65, 64, 63, 71, 73, 84, 89, 97, 108, 111, 125, 127,
        129, 129, 130, 74, 68, 67, 66, 73, 75, 86, 91, 100, 110, 113, 128, 131,
        135, 134, 130, 79, 72, 71, 70, 77, 79, 90, 95, 104, 115, 118, 133, 136,
        140, 139, 140, 82, 75, 73, 72, 79, 81, 92, 97, 105, 117, 120, 136, 139,
        145, 142, 140, 82, 75, 74, 72, 79, 81, 92, 97, 106, 117, 121, 136, 139,
        148, 150, 149, 87, 79, 78, 76, 83, 85, 96, 100, 110, 120, 125, 141, 144,
        148, 153, 150, 89, 82, 81, 78, 83, 87, 97, 99, 113, 118, 128, 139, 145,
        153, 157, 161, 92, 84, 83, 80, 84, 89, 97, 101, 114, 116, 132, 135, 150,
        153, 157, 162, 94, 86, 85, 82, 85, 92, 97, 104, 112, 119, 130, 136, 151,
        154, 163, 166, 97, 88, 88, 85, 86, 94, 97, 107, 111, 123, 128, 140, 147,
        159, 163, 167, 99, 91, 91, 87, 87, 97, 97, 110, 110, 126, 126, 144, 144,
        163, 163, 173,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 32, 32, 32, 34, 35, 36, 39, 41, 44, 47, 48, 53, 55,
        58, 63, 65, 71, 74, 79, 82, 82, 87, 89, 92, 94, 97, 99, 31, 32, 32, 32,
        32, 32, 33, 33, 34, 34, 34, 37, 39, 41, 44, 45, 49, 51, 54, 58, 60, 65,
        68, 72, 75, 75, 79, 82, 84, 86, 88, 91, 31, 32, 32, 32, 33, 33, 34, 34,
        35, 36, 36, 39, 40, 42, 44, 45, 50, 51, 54, 58, 59, 64, 67, 71, 73, 74,
        78, 81, 83, 85, 88, 91, 32, 32, 32, 33, 34, 34, 35, 36, 37, 38, 38, 40,
        41, 43, 45, 46, 50, 51, 54, 57, 58, 63, 66, 70, 72, 72, 76, 78, 80, 82,
        85, 87, 35, 35, 34, 34, 35, 36, 37, 39, 41, 45, 46, 48, 49, 51, 53, 54,
        57, 59, 61, 65, 66, 71, 73, 77, 79, 79, 83, 83, 84, 85, 86, 87, 36, 35,
        35, 34, 36, 36, 38, 40, 42, 47, 48, 50, 51, 53, 56, 56, 60, 61, 63, 67,
        68, 73, 75, 79, 81, 81, 85, 87, 89, 92, 94, 97, 44, 42, 41, 41, 42, 42,
        42, 44, 48, 52, 54, 58, 60, 63, 66, 67, 71, 72, 75, 78, 79, 84, 86, 90,
        92, 92, 96, 97, 97, 97, 97, 97, 47, 45, 45, 44, 44, 45, 45, 47, 50, 55,
        56, 60, 62, 66, 69, 70, 75, 77, 79, 83, 84, 89, 91, 95, 97, 97, 100, 99,
        101, 104, 107, 110, 53, 51, 50, 49, 49, 50, 49, 51, 54, 59, 60, 65, 67,
        71, 75, 76, 82, 84, 87, 91, 92, 97, 100, 104, 105, 106, 110, 113, 114,
        112, 111, 110, 62, 59, 58, 57, 57, 57, 56, 58, 61, 65, 66, 71, 74, 78,
        82, 83, 90, 92, 95, 100, 102, 108, 110, 115, 117, 117, 120, 118, 116,
        119, 123, 126, 65, 62, 61, 59, 59, 59, 58, 60, 63, 67, 68, 73, 76, 79,
        84, 85, 92, 94, 98, 103, 105, 111, 113, 118, 120, 121, 125, 128, 132,
        130, 128, 126, 79, 75, 74, 72, 71, 71, 69, 71, 73, 77, 78, 84, 86, 90,
        95, 96, 103, 106, 110, 116, 118, 125, 128, 133, 136, 136, 141, 139, 135,
        136, 140, 144, 82, 78, 76, 74, 73, 73, 71, 73, 76, 79, 80, 86, 88, 92,
        97, 98, 106, 108, 112, 118, 120, 127, 131, 136, 139, 139, 144, 145, 150,
        151, 147, 144, 88, 83, 82, 79, 79, 78, 76, 76, 81, 82, 85, 89, 91, 97,
        98, 104, 107, 111, 117, 119, 127, 129, 135, 140, 145, 148, 148, 153,
        153, 154, 159, 163, 90, 86, 85, 82, 81, 80, 79, 78, 81, 83, 87, 88, 93,
        94, 101, 101, 108, 110, 116, 119, 124, 129, 134, 139, 142, 150, 153,
        157, 157, 163, 163, 163, 93, 88, 88, 84, 84, 82, 83, 80, 80, 86, 86, 91,
        91, 97, 98, 105, 105, 112, 113, 121, 122, 130, 130, 140, 140, 149, 150,
        161, 162, 166, 167, 173 },
      { /* Chroma */
        /* Size 4x4 */
        32, 45, 51, 61, 45, 54, 59, 65, 51, 59, 75, 81, 61, 65, 81, 97,
        /* Size 8x8 */
        31, 34, 46, 47, 50, 57, 61, 65, 34, 39, 47, 45, 48, 53, 57, 61, 46, 47,
        52, 52, 54, 58, 61, 62, 47, 45, 52, 58, 62, 65, 68, 68, 50, 48, 54, 62,
        68, 73, 77, 76, 57, 53, 58, 65, 73, 82, 86, 86, 61, 57, 61, 68, 77, 86,
        91, 95, 65, 61, 62, 68, 76, 86, 95, 100,
        /* Size 16x16 */
        32, 31, 33, 36, 41, 49, 49, 50, 52, 54, 57, 61, 64, 67, 68, 70, 31, 31,
        34, 39, 42, 47, 46, 47, 49, 51, 53, 57, 60, 62, 64, 66, 33, 34, 37, 42,
        44, 47, 46, 46, 47, 49, 51, 55, 57, 59, 61, 63, 36, 39, 42, 47, 47, 48,
        46, 46, 47, 48, 50, 53, 55, 57, 59, 61, 41, 42, 44, 47, 48, 50, 49, 50,
        50, 52, 53, 56, 58, 60, 61, 60, 49, 47, 47, 48, 50, 53, 53, 54, 54, 55,
        56, 59, 61, 63, 64, 64, 49, 46, 46, 46, 49, 53, 55, 57, 59, 60, 61, 64,
        66, 67, 67, 67, 50, 47, 46, 46, 50, 54, 57, 61, 63, 64, 66, 69, 70, 72,
        71, 71, 52, 49, 47, 47, 50, 54, 59, 63, 66, 68, 70, 73, 75, 77, 75, 75,
        54, 51, 49, 48, 52, 55, 60, 64, 68, 71, 73, 76, 79, 80, 79, 79, 57, 53,
        51, 50, 53, 56, 61, 66, 70, 73, 76, 80, 82, 84, 83, 84, 61, 57, 55, 53,
        56, 59, 64, 69, 73, 76, 80, 84, 87, 89, 88, 88, 64, 60, 57, 55, 58, 61,
        66, 70, 75, 79, 82, 87, 91, 93, 93, 93, 67, 62, 59, 57, 60, 63, 67, 72,
        77, 80, 84, 89, 93, 95, 96, 97, 68, 64, 61, 59, 61, 64, 67, 71, 75, 79,
        83, 88, 93, 96, 99, 100, 70, 66, 63, 61, 60, 64, 67, 71, 75, 79, 84, 88,
        93, 97, 100, 102,
        /* Size 32x32 */
        32, 31, 31, 30, 33, 33, 36, 38, 41, 47, 49, 48, 49, 49, 50, 50, 52, 53,
        54, 56, 57, 60, 61, 63, 64, 65, 67, 67, 68, 69, 70, 71, 31, 31, 31, 31,
        34, 34, 38, 40, 42, 46, 47, 47, 47, 47, 48, 48, 50, 50, 52, 54, 54, 57,
        58, 60, 61, 61, 63, 64, 65, 65, 66, 67, 31, 31, 31, 31, 34, 35, 39, 40,
        42, 46, 47, 46, 46, 46, 47, 47, 49, 50, 51, 53, 53, 56, 57, 59, 60, 60,
        62, 63, 64, 65, 66, 67, 30, 31, 31, 32, 34, 35, 40, 41, 42, 45, 46, 45,
        45, 45, 46, 46, 47, 48, 49, 51, 52, 54, 55, 57, 58, 58, 60, 61, 62, 62,
        63, 64, 33, 34, 34, 34, 37, 38, 42, 43, 44, 46, 47, 46, 46, 45, 46, 46,
        47, 48, 49, 51, 51, 53, 55, 56, 57, 57, 59, 60, 61, 62, 63, 64, 33, 34,
        35, 35, 38, 39, 43, 44, 45, 47, 47, 46, 46, 45, 46, 46, 47, 48, 49, 51,
        51, 53, 54, 56, 57, 57, 59, 60, 60, 61, 62, 62, 36, 38, 39, 40, 42, 43,
        47, 47, 47, 47, 48, 46, 46, 45, 46, 46, 47, 47, 48, 49, 50, 52, 53, 54,
        55, 55, 57, 58, 59, 60, 61, 62, 38, 40, 40, 41, 43, 44, 47, 47, 48, 48,
        49, 48, 47, 47, 47, 47, 48, 49, 49, 51, 51, 53, 54, 55, 56, 56, 58, 58,
        58, 59, 60, 60, 41, 42, 42, 42, 44, 45, 47, 48, 48, 50, 50, 49, 49, 49,
        50, 50, 50, 51, 52, 53, 53, 55, 56, 57, 58, 58, 60, 61, 61, 61, 60, 60,
        47, 46, 46, 45, 46, 47, 47, 48, 50, 52, 52, 52, 52, 52, 53, 53, 53, 54,
        55, 55, 56, 58, 58, 60, 60, 61, 62, 61, 61, 62, 63, 64, 49, 47, 47, 46,
        47, 47, 48, 49, 50, 52, 53, 53, 53, 53, 54, 54, 54, 55, 55, 56, 56, 58,
        59, 60, 61, 61, 63, 63, 64, 64, 64, 64, 48, 47, 46, 45, 46, 46, 46, 48,
        49, 52, 53, 54, 55, 55, 56, 56, 57, 58, 58, 59, 60, 61, 62, 63, 64, 64,
        66, 65, 65, 65, 66, 67, 49, 47, 46, 45, 46, 46, 46, 47, 49, 52, 53, 55,
        55, 57, 57, 58, 59, 59, 60, 61, 61, 63, 64, 65, 66, 66, 67, 67, 67, 68,
        67, 67, 49, 47, 46, 45, 45, 45, 45, 47, 49, 52, 53, 55, 57, 58, 59, 60,
        61, 62, 62, 63, 63, 65, 66, 67, 68, 68, 69, 70, 69, 68, 69, 70, 50, 48,
        47, 46, 46, 46, 46, 47, 50, 53, 54, 56, 57, 59, 61, 61, 63, 64, 64, 66,
        66, 68, 69, 70, 70, 71, 72, 70, 71, 72, 71, 70, 50, 48, 47, 46, 46, 46,
        46, 47, 50, 53, 54, 56, 58, 60, 61, 61, 63, 64, 65, 66, 67, 68, 69, 71,
        71, 71, 73, 74, 73, 72, 73, 74, 52, 50, 49, 47, 47, 47, 47, 48, 50, 53,
        54, 57, 59, 61, 63, 63, 66, 67, 68, 70, 70, 72, 73, 75, 75, 75, 77, 75,
        75, 76, 75, 74, 53, 50, 50, 48, 48, 48, 47, 49, 51, 54, 55, 58, 59, 62,
        64, 64, 67, 68, 69, 71, 71, 73, 74, 76, 77, 77, 78, 78, 78, 76, 77, 78,
        54, 52, 51, 49, 49, 49, 48, 49, 52, 55, 55, 58, 60, 62, 64, 65, 68, 69,
        71, 73, 73, 75, 76, 78, 79, 79, 80, 80, 79, 80, 79, 78, 56, 54, 53, 51,
        51, 51, 49, 51, 53, 55, 56, 59, 61, 63, 66, 66, 70, 71, 73, 75, 76, 78,
        79, 81, 82, 82, 83, 81, 83, 81, 81, 82, 57, 54, 53, 52, 51, 51, 50, 51,
        53, 56, 56, 60, 61, 63, 66, 67, 70, 71, 73, 76, 76, 79, 80, 82, 82, 83,
        84, 85, 83, 84, 84, 82, 60, 57, 56, 54, 53, 53, 52, 53, 55, 58, 58, 61,
        63, 65, 68, 68, 72, 73, 75, 78, 79, 82, 83, 85, 86, 86, 88, 86, 87, 86,
        85, 86, 61, 58, 57, 55, 55, 54, 53, 54, 56, 58, 59, 62, 64, 66, 69, 69,
        73, 74, 76, 79, 80, 83, 84, 86, 87, 88, 89, 89, 88, 88, 88, 86, 63, 60,
        59, 57, 56, 56, 54, 55, 57, 60, 60, 63, 65, 67, 70, 71, 75, 76, 78, 81,
        82, 85, 86, 89, 90, 90, 92, 91, 91, 90, 89, 91, 64, 61, 60, 58, 57, 57,
        55, 56, 58, 60, 61, 64, 66, 68, 70, 71, 75, 77, 79, 82, 82, 86, 87, 90,
        91, 91, 93, 93, 93, 92, 93, 91, 65, 61, 60, 58, 57, 57, 55, 56, 58, 61,
        61, 64, 66, 68, 71, 71, 75, 77, 79, 82, 83, 86, 88, 90, 91, 91, 93, 94,
        95, 95, 93, 95, 67, 63, 62, 60, 59, 59, 57, 58, 60, 62, 63, 66, 67, 69,
        72, 73, 77, 78, 80, 83, 84, 88, 89, 92, 93, 93, 95, 95, 96, 96, 97, 95,
        67, 64, 63, 61, 60, 60, 58, 58, 61, 61, 63, 65, 67, 70, 70, 74, 75, 78,
        80, 81, 85, 86, 89, 91, 93, 94, 95, 97, 97, 98, 98, 100, 68, 65, 64, 62,
        61, 60, 59, 58, 61, 61, 64, 65, 67, 69, 71, 73, 75, 78, 79, 83, 83, 87,
        88, 91, 93, 95, 96, 97, 99, 98, 100, 100, 69, 65, 65, 62, 62, 61, 60,
        59, 61, 62, 64, 65, 68, 68, 72, 72, 76, 76, 80, 81, 84, 86, 88, 90, 92,
        95, 96, 98, 98, 100, 100, 101, 70, 66, 66, 63, 63, 62, 61, 60, 60, 63,
        64, 66, 67, 69, 71, 73, 75, 77, 79, 81, 84, 85, 88, 89, 93, 93, 97, 98,
        100, 100, 102, 101, 71, 67, 67, 64, 64, 62, 62, 60, 60, 64, 64, 67, 67,
        70, 70, 74, 74, 78, 78, 82, 82, 86, 86, 91, 91, 95, 95, 100, 100, 101,
        101, 104,
        /* Size 4x8 */
        31, 47, 53, 63, 36, 47, 50, 59, 46, 52, 55, 61, 45, 53, 63, 70, 49, 55,
        71, 77, 54, 58, 77, 86, 59, 61, 81, 94, 63, 65, 80, 95,
        /* Size 8x4 */
        31, 36, 46, 45, 49, 54, 59, 63, 47, 47, 52, 53, 55, 58, 61, 65, 53, 50,
        55, 63, 71, 77, 81, 80, 63, 59, 61, 70, 77, 86, 94, 95,
        /* Size 8x16 */
        32, 33, 45, 49, 52, 57, 64, 68, 31, 34, 45, 46, 49, 53, 60, 64, 33, 37,
        46, 45, 47, 51, 57, 61, 37, 43, 47, 45, 47, 50, 55, 59, 42, 44, 49, 49,
        50, 53, 58, 60, 49, 47, 52, 53, 54, 57, 61, 63, 48, 46, 51, 57, 59, 61,
        66, 67, 50, 46, 52, 59, 63, 66, 71, 71, 52, 47, 53, 61, 66, 71, 75, 74,
        54, 49, 54, 62, 68, 73, 79, 79, 57, 51, 55, 64, 70, 76, 83, 83, 61, 55,
        58, 66, 73, 80, 87, 87, 64, 57, 60, 68, 75, 83, 91, 91, 66, 59, 61, 69,
        77, 84, 93, 95, 68, 61, 61, 68, 77, 86, 94, 97, 70, 63, 61, 67, 75, 83,
        92, 98,
        /* Size 16x8 */
        32, 31, 33, 37, 42, 49, 48, 50, 52, 54, 57, 61, 64, 66, 68, 70, 33, 34,
        37, 43, 44, 47, 46, 46, 47, 49, 51, 55, 57, 59, 61, 63, 45, 45, 46, 47,
        49, 52, 51, 52, 53, 54, 55, 58, 60, 61, 61, 61, 49, 46, 45, 45, 49, 53,
        57, 59, 61, 62, 64, 66, 68, 69, 68, 67, 52, 49, 47, 47, 50, 54, 59, 63,
        66, 68, 70, 73, 75, 77, 77, 75, 57, 53, 51, 50, 53, 57, 61, 66, 71, 73,
        76, 80, 83, 84, 86, 83, 64, 60, 57, 55, 58, 61, 66, 71, 75, 79, 83, 87,
        91, 93, 94, 92, 68, 64, 61, 59, 60, 63, 67, 71, 74, 79, 83, 87, 91, 95,
        97, 98,
        /* Size 16x32 */
        32, 31, 33, 37, 45, 48, 49, 50, 52, 56, 57, 63, 64, 67, 68, 68, 31, 31,
        34, 38, 45, 47, 47, 48, 50, 53, 54, 60, 61, 63, 64, 65, 31, 32, 34, 39,
        45, 46, 46, 47, 49, 52, 53, 59, 60, 62, 64, 65, 30, 32, 35, 40, 44, 46,
        45, 46, 48, 51, 52, 57, 58, 60, 61, 62, 33, 35, 37, 42, 46, 47, 45, 46,
        47, 50, 51, 56, 57, 60, 61, 62, 33, 36, 38, 43, 46, 47, 46, 46, 47, 50,
        51, 56, 57, 59, 60, 60, 37, 40, 43, 47, 47, 47, 45, 46, 47, 49, 50, 54,
        55, 57, 59, 61, 39, 41, 43, 47, 48, 48, 47, 47, 48, 50, 51, 55, 56, 57,
        58, 59, 42, 43, 44, 47, 49, 50, 49, 50, 50, 53, 53, 57, 58, 60, 60, 59,
        47, 46, 46, 48, 51, 52, 53, 53, 53, 55, 56, 60, 61, 61, 61, 62, 49, 46,
        47, 48, 52, 53, 53, 54, 54, 56, 57, 60, 61, 63, 63, 62, 48, 46, 46, 47,
        51, 53, 56, 56, 57, 59, 60, 64, 64, 65, 64, 65, 48, 45, 46, 46, 51, 53,
        57, 57, 59, 61, 61, 65, 66, 66, 67, 65, 49, 45, 45, 46, 51, 53, 58, 59,
        61, 63, 64, 67, 68, 70, 67, 68, 50, 46, 46, 46, 52, 54, 59, 61, 63, 65,
        66, 70, 71, 70, 71, 68, 50, 46, 46, 46, 52, 54, 59, 61, 64, 66, 67, 71,
        71, 73, 71, 72, 52, 48, 47, 47, 53, 54, 61, 63, 66, 70, 71, 75, 75, 75,
        74, 72, 53, 49, 48, 48, 53, 55, 61, 64, 67, 71, 72, 76, 77, 77, 75, 76,
        54, 50, 49, 49, 54, 55, 62, 65, 68, 72, 73, 78, 79, 80, 79, 76, 56, 51,
        51, 50, 55, 56, 63, 66, 70, 74, 76, 81, 82, 81, 80, 80, 57, 52, 51, 50,
        55, 56, 64, 66, 70, 75, 76, 82, 83, 85, 83, 80, 60, 54, 54, 52, 57, 58,
        65, 68, 72, 77, 79, 85, 86, 86, 85, 84, 61, 56, 55, 53, 58, 59, 66, 69,
        73, 79, 80, 86, 87, 89, 87, 84, 63, 57, 56, 55, 59, 60, 67, 70, 75, 80,
        82, 89, 90, 91, 89, 89, 64, 58, 57, 56, 60, 61, 68, 71, 75, 81, 83, 90,
        91, 93, 91, 89, 64, 59, 58, 56, 60, 61, 68, 71, 75, 81, 83, 90, 91, 94,
        94, 93, 66, 60, 59, 57, 61, 63, 69, 72, 77, 82, 84, 92, 93, 94, 95, 93,
        67, 61, 60, 58, 61, 63, 69, 70, 78, 80, 85, 90, 93, 96, 97, 97, 68, 62,
        61, 59, 61, 64, 68, 71, 77, 79, 86, 88, 94, 96, 97, 98, 69, 63, 62, 59,
        61, 65, 68, 72, 76, 80, 85, 88, 94, 95, 99, 99, 70, 63, 63, 60, 61, 66,
        67, 73, 75, 81, 83, 89, 92, 97, 98, 99, 70, 64, 64, 61, 61, 67, 67, 74,
        74, 82, 82, 90, 90, 98, 98, 102,
        /* Size 32x16 */
        32, 31, 31, 30, 33, 33, 37, 39, 42, 47, 49, 48, 48, 49, 50, 50, 52, 53,
        54, 56, 57, 60, 61, 63, 64, 64, 66, 67, 68, 69, 70, 70, 31, 31, 32, 32,
        35, 36, 40, 41, 43, 46, 46, 46, 45, 45, 46, 46, 48, 49, 50, 51, 52, 54,
        56, 57, 58, 59, 60, 61, 62, 63, 63, 64, 33, 34, 34, 35, 37, 38, 43, 43,
        44, 46, 47, 46, 46, 45, 46, 46, 47, 48, 49, 51, 51, 54, 55, 56, 57, 58,
        59, 60, 61, 62, 63, 64, 37, 38, 39, 40, 42, 43, 47, 47, 47, 48, 48, 47,
        46, 46, 46, 46, 47, 48, 49, 50, 50, 52, 53, 55, 56, 56, 57, 58, 59, 59,
        60, 61, 45, 45, 45, 44, 46, 46, 47, 48, 49, 51, 52, 51, 51, 51, 52, 52,
        53, 53, 54, 55, 55, 57, 58, 59, 60, 60, 61, 61, 61, 61, 61, 61, 48, 47,
        46, 46, 47, 47, 47, 48, 50, 52, 53, 53, 53, 53, 54, 54, 54, 55, 55, 56,
        56, 58, 59, 60, 61, 61, 63, 63, 64, 65, 66, 67, 49, 47, 46, 45, 45, 46,
        45, 47, 49, 53, 53, 56, 57, 58, 59, 59, 61, 61, 62, 63, 64, 65, 66, 67,
        68, 68, 69, 69, 68, 68, 67, 67, 50, 48, 47, 46, 46, 46, 46, 47, 50, 53,
        54, 56, 57, 59, 61, 61, 63, 64, 65, 66, 66, 68, 69, 70, 71, 71, 72, 70,
        71, 72, 73, 74, 52, 50, 49, 48, 47, 47, 47, 48, 50, 53, 54, 57, 59, 61,
        63, 64, 66, 67, 68, 70, 70, 72, 73, 75, 75, 75, 77, 78, 77, 76, 75, 74,
        56, 53, 52, 51, 50, 50, 49, 50, 53, 55, 56, 59, 61, 63, 65, 66, 70, 71,
        72, 74, 75, 77, 79, 80, 81, 81, 82, 80, 79, 80, 81, 82, 57, 54, 53, 52,
        51, 51, 50, 51, 53, 56, 57, 60, 61, 64, 66, 67, 71, 72, 73, 76, 76, 79,
        80, 82, 83, 83, 84, 85, 86, 85, 83, 82, 63, 60, 59, 57, 56, 56, 54, 55,
        57, 60, 60, 64, 65, 67, 70, 71, 75, 76, 78, 81, 82, 85, 86, 89, 90, 90,
        92, 90, 88, 88, 89, 90, 64, 61, 60, 58, 57, 57, 55, 56, 58, 61, 61, 64,
        66, 68, 71, 71, 75, 77, 79, 82, 83, 86, 87, 90, 91, 91, 93, 93, 94, 94,
        92, 90, 67, 63, 62, 60, 60, 59, 57, 57, 60, 61, 63, 65, 66, 70, 70, 73,
        75, 77, 80, 81, 85, 86, 89, 91, 93, 94, 94, 96, 96, 95, 97, 98, 68, 64,
        64, 61, 61, 60, 59, 58, 60, 61, 63, 64, 67, 67, 71, 71, 74, 75, 79, 80,
        83, 85, 87, 89, 91, 94, 95, 97, 97, 99, 98, 98, 68, 65, 65, 62, 62, 60,
        61, 59, 59, 62, 62, 65, 65, 68, 68, 72, 72, 76, 76, 80, 80, 84, 84, 89,
        89, 93, 93, 97, 98, 99, 99, 102 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 34, 53, 75, 34, 49, 64, 81, 53, 64, 91, 112, 75, 81, 112, 140,
        /* Size 8x8 */
        32, 32, 34, 39, 50, 62, 76, 84, 32, 33, 35, 40, 48, 59, 71, 79, 34, 35,
        39, 46, 53, 63, 74, 81, 39, 40, 46, 56, 65, 75, 86, 92, 50, 48, 53, 65,
        78, 90, 101, 106, 62, 59, 63, 75, 90, 105, 118, 123, 76, 71, 74, 86,
        101, 118, 134, 142, 84, 79, 81, 92, 106, 123, 142, 153,
        /* Size 16x16 */
        32, 31, 31, 32, 33, 36, 39, 44, 48, 54, 59, 66, 74, 81, 86, 91, 31, 32,
        32, 32, 33, 35, 38, 42, 46, 51, 56, 63, 70, 77, 81, 86, 31, 32, 32, 33,
        34, 35, 38, 41, 45, 49, 54, 60, 67, 73, 77, 82, 32, 32, 33, 34, 36, 37,
        40, 42, 45, 49, 53, 59, 66, 71, 75, 80, 33, 33, 34, 36, 38, 42, 44, 46,
        50, 53, 57, 63, 69, 74, 78, 80, 36, 35, 35, 37, 42, 48, 50, 54, 57, 60,
        64, 69, 75, 80, 84, 85, 39, 38, 38, 40, 44, 50, 54, 58, 61, 65, 69, 74,
        80, 85, 89, 91, 44, 42, 41, 42, 46, 54, 58, 63, 67, 71, 75, 80, 86, 91,
        95, 97, 48, 46, 45, 45, 50, 57, 61, 67, 71, 76, 80, 86, 93, 98, 101,
        104, 54, 51, 49, 49, 53, 60, 65, 71, 76, 82, 87, 93, 100, 105, 109, 112,
        59, 56, 54, 53, 57, 64, 69, 75, 80, 87, 92, 99, 106, 112, 116, 120, 66,
        63, 60, 59, 63, 69, 74, 80, 86, 93, 99, 107, 115, 121, 125, 129, 74, 70,
        67, 66, 69, 75, 80, 86, 93, 100, 106, 115, 123, 130, 135, 138, 81, 77,
        73, 71, 74, 80, 85, 91, 98, 105, 112, 121, 130, 137, 142, 148, 86, 81,
        77, 75, 78, 84, 89, 95, 101, 109, 116, 125, 135, 142, 147, 153, 91, 86,
        82, 80, 80, 85, 91, 97, 104, 112, 120, 129, 138, 148, 153, 159,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 32, 32, 33, 34, 36, 36, 39, 41, 44, 46, 48, 52,
        54, 58, 59, 65, 66, 71, 74, 80, 81, 83, 86, 89, 91, 93, 31, 32, 32, 32,
        32, 32, 32, 32, 33, 34, 35, 35, 38, 39, 42, 44, 46, 50, 51, 56, 56, 62,
        63, 68, 71, 76, 77, 78, 82, 84, 86, 88, 31, 32, 32, 32, 32, 32, 32, 32,
        33, 34, 35, 35, 38, 39, 42, 44, 46, 49, 51, 55, 56, 61, 63, 67, 70, 75,
        77, 78, 81, 84, 86, 88, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34,
        37, 38, 41, 42, 44, 48, 49, 53, 54, 59, 60, 65, 68, 72, 74, 75, 78, 80,
        82, 84, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 35, 35, 38, 39, 41, 43,
        45, 48, 49, 53, 54, 59, 60, 65, 67, 72, 73, 74, 77, 80, 82, 84, 31, 32,
        32, 32, 33, 33, 33, 34, 35, 35, 36, 36, 39, 40, 42, 44, 45, 48, 50, 53,
        54, 59, 60, 64, 67, 71, 73, 74, 77, 79, 81, 83, 32, 32, 32, 32, 33, 33,
        34, 35, 36, 36, 37, 38, 40, 40, 42, 44, 45, 48, 49, 53, 53, 58, 59, 63,
        66, 70, 71, 72, 75, 78, 80, 83, 32, 32, 32, 32, 33, 34, 35, 35, 36, 37,
        38, 38, 40, 41, 42, 44, 46, 48, 49, 53, 53, 58, 59, 63, 65, 69, 71, 72,
        74, 77, 79, 80, 33, 33, 33, 33, 34, 35, 36, 36, 38, 39, 42, 42, 44, 45,
        46, 48, 50, 52, 53, 57, 57, 62, 63, 67, 69, 73, 74, 75, 78, 79, 80, 81,
        34, 34, 34, 33, 34, 35, 36, 37, 39, 39, 42, 43, 45, 46, 47, 49, 51, 53,
        54, 58, 58, 63, 64, 68, 70, 74, 75, 76, 79, 81, 84, 86, 36, 35, 35, 34,
        35, 36, 37, 38, 42, 42, 48, 48, 50, 51, 54, 55, 57, 59, 60, 63, 64, 68,
        69, 73, 75, 79, 80, 81, 84, 85, 85, 86, 36, 35, 35, 34, 35, 36, 38, 38,
        42, 43, 48, 49, 51, 52, 54, 55, 57, 59, 60, 64, 64, 68, 69, 73, 75, 79,
        80, 81, 84, 86, 88, 91, 39, 38, 38, 37, 38, 39, 40, 40, 44, 45, 50, 51,
        54, 55, 58, 59, 61, 64, 65, 68, 69, 73, 74, 78, 80, 84, 85, 86, 89, 91,
        91, 91, 41, 39, 39, 38, 39, 40, 40, 41, 45, 46, 51, 52, 55, 56, 59, 61,
        63, 65, 67, 70, 70, 75, 76, 80, 82, 86, 87, 88, 91, 92, 94, 96, 44, 42,
        42, 41, 41, 42, 42, 42, 46, 47, 54, 54, 58, 59, 63, 65, 67, 70, 71, 75,
        75, 79, 80, 84, 86, 90, 91, 92, 95, 97, 97, 97, 46, 44, 44, 42, 43, 44,
        44, 44, 48, 49, 55, 55, 59, 61, 65, 67, 69, 72, 74, 77, 78, 82, 83, 87,
        89, 93, 94, 95, 98, 98, 100, 103, 48, 46, 46, 44, 45, 45, 45, 46, 50,
        51, 57, 57, 61, 63, 67, 69, 71, 74, 76, 80, 80, 85, 86, 90, 93, 96, 98,
        99, 101, 104, 104, 103, 52, 50, 49, 48, 48, 48, 48, 48, 52, 53, 59, 59,
        64, 65, 70, 72, 74, 78, 80, 84, 85, 90, 91, 95, 97, 101, 103, 104, 106,
        106, 107, 110, 54, 51, 51, 49, 49, 50, 49, 49, 53, 54, 60, 60, 65, 67,
        71, 74, 76, 80, 82, 86, 87, 92, 93, 97, 100, 104, 105, 106, 109, 112,
        112, 110, 58, 56, 55, 53, 53, 53, 53, 53, 57, 58, 63, 64, 68, 70, 75,
        77, 80, 84, 86, 91, 91, 97, 98, 103, 105, 110, 111, 112, 115, 114, 115,
        118, 59, 56, 56, 54, 54, 54, 53, 53, 57, 58, 64, 64, 69, 70, 75, 78, 80,
        85, 87, 91, 92, 98, 99, 103, 106, 110, 112, 113, 116, 119, 120, 119, 65,
        62, 61, 59, 59, 59, 58, 58, 62, 63, 68, 68, 73, 75, 79, 82, 85, 90, 92,
        97, 98, 105, 106, 111, 114, 118, 120, 121, 124, 123, 123, 126, 66, 63,
        63, 60, 60, 60, 59, 59, 63, 64, 69, 69, 74, 76, 80, 83, 86, 91, 93, 98,
        99, 106, 107, 112, 115, 119, 121, 122, 125, 128, 129, 126, 71, 68, 67,
        65, 65, 64, 63, 63, 67, 68, 73, 73, 78, 80, 84, 87, 90, 95, 97, 103,
        103, 111, 112, 117, 120, 125, 127, 128, 131, 132, 132, 135, 74, 71, 70,
        68, 67, 67, 66, 65, 69, 70, 75, 75, 80, 82, 86, 89, 93, 97, 100, 105,
        106, 114, 115, 120, 123, 128, 130, 131, 135, 135, 138, 136, 80, 76, 75,
        72, 72, 71, 70, 69, 73, 74, 79, 79, 84, 86, 90, 93, 96, 101, 104, 110,
        110, 118, 119, 125, 128, 134, 136, 137, 140, 142, 140, 144, 81, 77, 77,
        74, 73, 73, 71, 71, 74, 75, 80, 80, 85, 87, 91, 94, 98, 103, 105, 111,
        112, 120, 121, 127, 130, 136, 137, 139, 142, 145, 148, 144, 83, 78, 78,
        75, 74, 74, 72, 72, 75, 76, 81, 81, 86, 88, 92, 95, 99, 104, 106, 112,
        113, 121, 122, 128, 131, 137, 139, 140, 144, 148, 150, 155, 86, 82, 81,
        78, 77, 77, 75, 74, 78, 79, 84, 84, 89, 91, 95, 98, 101, 106, 109, 115,
        116, 124, 125, 131, 135, 140, 142, 144, 147, 149, 153, 155, 89, 84, 84,
        80, 80, 79, 78, 77, 79, 81, 85, 86, 91, 92, 97, 98, 104, 106, 112, 114,
        119, 123, 128, 132, 135, 142, 145, 148, 149, 153, 154, 159, 91, 86, 86,
        82, 82, 81, 80, 79, 80, 84, 85, 88, 91, 94, 97, 100, 104, 107, 112, 115,
        120, 123, 129, 132, 138, 140, 148, 150, 153, 154, 159, 159, 93, 88, 88,
        84, 84, 83, 83, 80, 81, 86, 86, 91, 91, 96, 97, 103, 103, 110, 110, 118,
        119, 126, 126, 135, 136, 144, 144, 155, 155, 159, 159, 164,
        /* Size 4x8 */
        32, 35, 51, 77, 32, 36, 50, 72, 34, 42, 54, 75, 38, 51, 67, 87, 48, 59,
        80, 103, 60, 68, 92, 119, 72, 79, 104, 135, 81, 86, 112, 144,
        /* Size 8x4 */
        32, 32, 34, 38, 48, 60, 72, 81, 35, 36, 42, 51, 59, 68, 79, 86, 51, 50,
        54, 67, 80, 92, 104, 112, 77, 72, 75, 87, 103, 119, 135, 144,
        /* Size 8x16 */
        32, 31, 33, 40, 51, 65, 79, 87, 31, 32, 33, 39, 49, 61, 74, 82, 31, 32,
        34, 38, 47, 59, 71, 79, 32, 33, 36, 40, 48, 58, 69, 77, 33, 34, 38, 44,
        52, 62, 72, 78, 36, 35, 42, 51, 58, 68, 78, 84, 39, 38, 44, 54, 63, 73,
        84, 89, 44, 41, 46, 59, 69, 79, 90, 96, 48, 45, 50, 62, 74, 85, 96, 103,
        53, 49, 53, 66, 79, 92, 103, 111, 58, 54, 57, 70, 84, 98, 110, 118, 66,
        60, 63, 75, 90, 106, 119, 126, 74, 67, 69, 81, 97, 113, 128, 134, 81,
        73, 75, 86, 102, 120, 135, 143, 86, 78, 78, 90, 106, 124, 140, 147, 91,
        82, 80, 90, 103, 119, 137, 151,
        /* Size 16x8 */
        32, 31, 31, 32, 33, 36, 39, 44, 48, 53, 58, 66, 74, 81, 86, 91, 31, 32,
        32, 33, 34, 35, 38, 41, 45, 49, 54, 60, 67, 73, 78, 82, 33, 33, 34, 36,
        38, 42, 44, 46, 50, 53, 57, 63, 69, 75, 78, 80, 40, 39, 38, 40, 44, 51,
        54, 59, 62, 66, 70, 75, 81, 86, 90, 90, 51, 49, 47, 48, 52, 58, 63, 69,
        74, 79, 84, 90, 97, 102, 106, 103, 65, 61, 59, 58, 62, 68, 73, 79, 85,
        92, 98, 106, 113, 120, 124, 119, 79, 74, 71, 69, 72, 78, 84, 90, 96,
        103, 110, 119, 128, 135, 140, 137, 87, 82, 79, 77, 78, 84, 89, 96, 103,
        111, 118, 126, 134, 143, 147, 151,
        /* Size 16x32 */
        32, 31, 31, 32, 33, 36, 40, 44, 51, 53, 65, 66, 79, 81, 87, 90, 31, 32,
        32, 32, 33, 35, 39, 42, 49, 51, 62, 63, 75, 77, 83, 85, 31, 32, 32, 32,
        33, 35, 39, 42, 49, 51, 61, 62, 74, 76, 82, 85, 31, 32, 32, 33, 33, 34,
        38, 41, 47, 49, 59, 60, 72, 74, 79, 81, 31, 32, 32, 33, 34, 35, 38, 41,
        47, 49, 59, 60, 71, 73, 79, 81, 32, 32, 33, 34, 35, 36, 39, 42, 48, 50,
        59, 60, 71, 72, 78, 80, 32, 32, 33, 35, 36, 37, 40, 42, 48, 49, 58, 59,
        69, 71, 77, 80, 32, 33, 33, 35, 36, 38, 41, 42, 48, 49, 58, 59, 69, 70,
        75, 77, 33, 33, 34, 36, 38, 41, 44, 46, 52, 53, 62, 63, 72, 74, 78, 78,
        34, 34, 34, 37, 39, 42, 45, 48, 53, 54, 63, 64, 73, 75, 80, 83, 36, 34,
        35, 38, 42, 48, 51, 54, 58, 60, 68, 69, 78, 80, 84, 83, 36, 35, 35, 38,
        42, 48, 51, 54, 59, 60, 68, 69, 79, 80, 85, 87, 39, 37, 38, 40, 44, 50,
        54, 58, 63, 65, 73, 74, 84, 85, 89, 88, 40, 38, 39, 41, 45, 51, 56, 59,
        65, 67, 75, 76, 85, 87, 90, 93, 44, 41, 41, 43, 46, 53, 59, 63, 69, 71,
        79, 80, 90, 91, 96, 93, 46, 43, 43, 44, 48, 55, 60, 65, 72, 73, 82, 83,
        93, 94, 97, 100, 48, 45, 45, 46, 50, 56, 62, 67, 74, 76, 85, 86, 96, 98,
        103, 100, 52, 48, 48, 49, 52, 59, 65, 70, 78, 80, 90, 91, 101, 103, 105,
        107, 53, 49, 49, 50, 53, 60, 66, 71, 79, 82, 92, 93, 103, 105, 111, 107,
        58, 53, 53, 53, 57, 63, 69, 74, 83, 86, 97, 98, 109, 111, 113, 115, 58,
        54, 54, 54, 57, 63, 70, 75, 84, 87, 98, 99, 110, 112, 118, 115, 65, 60,
        59, 58, 62, 68, 74, 79, 89, 92, 105, 106, 118, 119, 122, 123, 66, 61,
        60, 59, 63, 69, 75, 80, 90, 93, 106, 107, 119, 121, 126, 123, 71, 65,
        65, 63, 67, 73, 79, 84, 94, 97, 111, 112, 125, 127, 131, 132, 74, 68,
        67, 66, 69, 75, 81, 86, 97, 100, 113, 115, 128, 130, 134, 132, 79, 72,
        72, 70, 73, 79, 85, 90, 101, 104, 118, 119, 133, 135, 141, 140, 81, 74,
        73, 71, 75, 80, 86, 91, 102, 105, 120, 121, 135, 137, 143, 140, 82, 75,
        74, 72, 75, 81, 87, 92, 103, 106, 121, 122, 136, 139, 147, 151, 86, 78,
        78, 75, 78, 84, 90, 95, 106, 109, 124, 125, 140, 142, 147, 151, 88, 81,
        80, 77, 80, 86, 90, 98, 105, 112, 122, 127, 140, 144, 152, 155, 91, 83,
        82, 79, 80, 88, 90, 100, 103, 114, 119, 130, 137, 148, 151, 155, 93, 85,
        85, 81, 81, 90, 90, 102, 103, 117, 117, 134, 134, 151, 152, 160,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 32, 32, 32, 33, 34, 36, 36, 39, 40, 44, 46, 48, 52,
        53, 58, 58, 65, 66, 71, 74, 79, 81, 82, 86, 88, 91, 93, 31, 32, 32, 32,
        32, 32, 32, 33, 33, 34, 34, 35, 37, 38, 41, 43, 45, 48, 49, 53, 54, 60,
        61, 65, 68, 72, 74, 75, 78, 81, 83, 85, 31, 32, 32, 32, 32, 33, 33, 33,
        34, 34, 35, 35, 38, 39, 41, 43, 45, 48, 49, 53, 54, 59, 60, 65, 67, 72,
        73, 74, 78, 80, 82, 85, 32, 32, 32, 33, 33, 34, 35, 35, 36, 37, 38, 38,
        40, 41, 43, 44, 46, 49, 50, 53, 54, 58, 59, 63, 66, 70, 71, 72, 75, 77,
        79, 81, 33, 33, 33, 33, 34, 35, 36, 36, 38, 39, 42, 42, 44, 45, 46, 48,
        50, 52, 53, 57, 57, 62, 63, 67, 69, 73, 75, 75, 78, 80, 80, 81, 36, 35,
        35, 34, 35, 36, 37, 38, 41, 42, 48, 48, 50, 51, 53, 55, 56, 59, 60, 63,
        63, 68, 69, 73, 75, 79, 80, 81, 84, 86, 88, 90, 40, 39, 39, 38, 38, 39,
        40, 41, 44, 45, 51, 51, 54, 56, 59, 60, 62, 65, 66, 69, 70, 74, 75, 79,
        81, 85, 86, 87, 90, 90, 90, 90, 44, 42, 42, 41, 41, 42, 42, 42, 46, 48,
        54, 54, 58, 59, 63, 65, 67, 70, 71, 74, 75, 79, 80, 84, 86, 90, 91, 92,
        95, 98, 100, 102, 51, 49, 49, 47, 47, 48, 48, 48, 52, 53, 58, 59, 63,
        65, 69, 72, 74, 78, 79, 83, 84, 89, 90, 94, 97, 101, 102, 103, 106, 105,
        103, 103, 53, 51, 51, 49, 49, 50, 49, 49, 53, 54, 60, 60, 65, 67, 71,
        73, 76, 80, 82, 86, 87, 92, 93, 97, 100, 104, 105, 106, 109, 112, 114,
        117, 65, 62, 61, 59, 59, 59, 58, 58, 62, 63, 68, 68, 73, 75, 79, 82, 85,
        90, 92, 97, 98, 105, 106, 111, 113, 118, 120, 121, 124, 122, 119, 117,
        66, 63, 62, 60, 60, 60, 59, 59, 63, 64, 69, 69, 74, 76, 80, 83, 86, 91,
        93, 98, 99, 106, 107, 112, 115, 119, 121, 122, 125, 127, 130, 134, 79,
        75, 74, 72, 71, 71, 69, 69, 72, 73, 78, 79, 84, 85, 90, 93, 96, 101,
        103, 109, 110, 118, 119, 125, 128, 133, 135, 136, 140, 140, 137, 134,
        81, 77, 76, 74, 73, 72, 71, 70, 74, 75, 80, 80, 85, 87, 91, 94, 98, 103,
        105, 111, 112, 119, 121, 127, 130, 135, 137, 139, 142, 144, 148, 151,
        87, 83, 82, 79, 79, 78, 77, 75, 78, 80, 84, 85, 89, 90, 96, 97, 103,
        105, 111, 113, 118, 122, 126, 131, 134, 141, 143, 147, 147, 152, 151,
        152, 90, 85, 85, 81, 81, 80, 80, 77, 78, 83, 83, 87, 88, 93, 93, 100,
        100, 107, 107, 115, 115, 123, 123, 132, 132, 140, 140, 151, 151, 155,
        155, 160 },
      { /* Chroma */
        /* Size 4x4 */
        32, 46, 49, 58, 46, 53, 55, 62, 49, 55, 70, 78, 58, 62, 78, 91,
        /* Size 8x8 */
        31, 34, 42, 47, 49, 54, 60, 64, 34, 39, 45, 46, 47, 51, 56, 59, 42, 45,
        48, 49, 50, 53, 57, 60, 47, 46, 49, 55, 58, 61, 65, 66, 49, 47, 50, 58,
        65, 69, 73, 74, 54, 51, 53, 61, 69, 76, 82, 83, 60, 56, 57, 65, 73, 82,
        89, 92, 64, 59, 60, 66, 74, 83, 92, 96,
        /* Size 16x16 */
        32, 31, 31, 35, 40, 49, 48, 49, 50, 52, 54, 57, 61, 64, 66, 68, 31, 31,
        32, 37, 41, 47, 47, 46, 48, 49, 51, 54, 57, 60, 62, 64, 31, 32, 34, 39,
        43, 46, 46, 45, 46, 47, 49, 52, 55, 57, 59, 61, 35, 37, 39, 44, 46, 47,
        46, 45, 46, 47, 48, 51, 53, 56, 57, 59, 40, 41, 43, 46, 48, 50, 49, 48,
        49, 49, 51, 53, 55, 57, 59, 59, 49, 47, 46, 47, 50, 53, 53, 53, 54, 54,
        55, 57, 59, 61, 62, 62, 48, 47, 46, 46, 49, 53, 54, 55, 56, 57, 58, 60,
        62, 64, 65, 65, 49, 46, 45, 45, 48, 53, 55, 58, 60, 61, 62, 64, 66, 68,
        69, 69, 50, 48, 46, 46, 49, 54, 56, 60, 61, 63, 65, 67, 69, 71, 72, 72,
        52, 49, 47, 47, 49, 54, 57, 61, 63, 66, 68, 71, 73, 75, 76, 77, 54, 51,
        49, 48, 51, 55, 58, 62, 65, 68, 71, 74, 76, 78, 80, 81, 57, 54, 52, 51,
        53, 57, 60, 64, 67, 71, 74, 77, 80, 83, 84, 85, 61, 57, 55, 53, 55, 59,
        62, 66, 69, 73, 76, 80, 84, 87, 89, 89, 64, 60, 57, 56, 57, 61, 64, 68,
        71, 75, 78, 83, 87, 90, 92, 94, 66, 62, 59, 57, 59, 62, 65, 69, 72, 76,
        80, 84, 89, 92, 94, 96, 68, 64, 61, 59, 59, 62, 65, 69, 72, 77, 81, 85,
        89, 94, 96, 98,
        /* Size 32x32 */
        32, 31, 31, 30, 31, 33, 35, 36, 40, 41, 49, 49, 48, 48, 49, 50, 50, 52,
        52, 54, 54, 57, 57, 60, 61, 63, 64, 65, 66, 67, 68, 69, 31, 31, 31, 31,
        32, 34, 37, 38, 41, 42, 47, 47, 47, 47, 47, 47, 48, 49, 50, 52, 52, 54,
        55, 57, 58, 60, 61, 61, 63, 64, 64, 65, 31, 31, 31, 31, 32, 35, 37, 39,
        41, 42, 47, 47, 47, 46, 46, 47, 48, 49, 49, 51, 51, 54, 54, 56, 57, 59,
        60, 61, 62, 63, 64, 65, 30, 31, 31, 32, 33, 35, 38, 40, 42, 42, 46, 46,
        45, 45, 45, 45, 46, 47, 47, 49, 49, 52, 52, 54, 55, 57, 58, 58, 60, 61,
        61, 62, 31, 32, 32, 33, 34, 37, 39, 41, 43, 43, 46, 46, 46, 45, 45, 46,
        46, 47, 47, 49, 49, 51, 52, 54, 55, 57, 57, 58, 59, 60, 61, 62, 33, 34,
        35, 35, 37, 39, 41, 43, 44, 45, 47, 47, 46, 46, 45, 46, 46, 47, 47, 49,
        49, 51, 51, 53, 54, 56, 57, 57, 58, 59, 60, 61, 35, 37, 37, 38, 39, 41,
        44, 46, 46, 46, 47, 47, 46, 46, 45, 46, 46, 47, 47, 48, 48, 50, 51, 52,
        53, 55, 56, 56, 57, 58, 59, 61, 36, 38, 39, 40, 41, 43, 46, 47, 47, 47,
        48, 47, 46, 46, 45, 46, 46, 46, 47, 48, 48, 50, 50, 52, 53, 54, 55, 55,
        56, 57, 58, 58, 40, 41, 41, 42, 43, 44, 46, 47, 48, 48, 50, 49, 49, 49,
        48, 49, 49, 49, 49, 51, 51, 52, 53, 54, 55, 57, 57, 58, 59, 59, 59, 59,
        41, 42, 42, 42, 43, 45, 46, 47, 48, 48, 50, 50, 49, 49, 49, 49, 50, 50,
        50, 52, 52, 53, 53, 55, 56, 57, 58, 58, 59, 60, 61, 62, 49, 47, 47, 46,
        46, 47, 47, 48, 50, 50, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56,
        57, 58, 59, 60, 61, 61, 62, 62, 62, 62, 49, 47, 47, 46, 46, 47, 47, 47,
        49, 50, 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 56, 57, 57, 59, 59, 61,
        61, 62, 63, 63, 64, 65, 48, 47, 47, 45, 46, 46, 46, 46, 49, 49, 53, 53,
        54, 54, 55, 56, 56, 57, 57, 58, 58, 60, 60, 61, 62, 63, 64, 64, 65, 66,
        65, 65, 48, 47, 46, 45, 45, 46, 46, 46, 49, 49, 53, 53, 54, 55, 56, 57,
        57, 58, 58, 59, 60, 61, 61, 63, 63, 65, 65, 65, 66, 66, 67, 68, 49, 47,
        46, 45, 45, 45, 45, 45, 48, 49, 53, 54, 55, 56, 58, 59, 60, 61, 61, 62,
        62, 63, 64, 65, 66, 67, 68, 68, 69, 70, 69, 68, 50, 47, 47, 45, 46, 46,
        46, 46, 49, 49, 54, 54, 56, 57, 59, 60, 60, 62, 62, 63, 64, 65, 65, 67,
        68, 69, 69, 70, 70, 70, 71, 71, 50, 48, 48, 46, 46, 46, 46, 46, 49, 50,
        54, 54, 56, 57, 60, 60, 61, 63, 63, 65, 65, 67, 67, 68, 69, 71, 71, 71,
        72, 73, 72, 71, 52, 49, 49, 47, 47, 47, 47, 46, 49, 50, 54, 54, 57, 58,
        61, 62, 63, 65, 65, 67, 67, 69, 70, 71, 72, 73, 74, 74, 75, 74, 74, 75,
        52, 50, 49, 47, 47, 47, 47, 47, 49, 50, 54, 54, 57, 58, 61, 62, 63, 65,
        66, 68, 68, 70, 71, 72, 73, 75, 75, 75, 76, 77, 77, 75, 54, 52, 51, 49,
        49, 49, 48, 48, 51, 52, 55, 55, 58, 59, 62, 63, 65, 67, 68, 70, 70, 73,
        73, 75, 76, 78, 78, 78, 79, 78, 78, 79, 54, 52, 51, 49, 49, 49, 48, 48,
        51, 52, 55, 56, 58, 60, 62, 64, 65, 67, 68, 70, 71, 73, 74, 75, 76, 78,
        78, 79, 80, 81, 81, 79, 57, 54, 54, 52, 51, 51, 50, 50, 52, 53, 56, 57,
        60, 61, 63, 65, 67, 69, 70, 73, 73, 76, 77, 79, 80, 82, 82, 83, 84, 83,
        82, 83, 57, 55, 54, 52, 52, 51, 51, 50, 53, 53, 57, 57, 60, 61, 64, 65,
        67, 70, 71, 73, 74, 77, 77, 79, 80, 82, 83, 83, 84, 85, 85, 83, 60, 57,
        56, 54, 54, 53, 52, 52, 54, 55, 58, 59, 61, 63, 65, 67, 68, 71, 72, 75,
        75, 79, 79, 82, 83, 85, 86, 86, 87, 87, 86, 87, 61, 58, 57, 55, 55, 54,
        53, 53, 55, 56, 59, 59, 62, 63, 66, 68, 69, 72, 73, 76, 76, 80, 80, 83,
        84, 86, 87, 88, 89, 89, 89, 87, 63, 60, 59, 57, 57, 56, 55, 54, 57, 57,
        60, 61, 63, 65, 67, 69, 71, 73, 75, 78, 78, 82, 82, 85, 86, 89, 89, 90,
        91, 92, 90, 91, 64, 61, 60, 58, 57, 57, 56, 55, 57, 58, 61, 61, 64, 65,
        68, 69, 71, 74, 75, 78, 78, 82, 83, 86, 87, 89, 90, 91, 92, 93, 94, 91,
        65, 61, 61, 58, 58, 57, 56, 55, 58, 58, 61, 62, 64, 65, 68, 70, 71, 74,
        75, 78, 79, 83, 83, 86, 88, 90, 91, 91, 93, 94, 94, 96, 66, 63, 62, 60,
        59, 58, 57, 56, 59, 59, 62, 63, 65, 66, 69, 70, 72, 75, 76, 79, 80, 84,
        84, 87, 89, 91, 92, 93, 94, 94, 96, 96, 67, 64, 63, 61, 60, 59, 58, 57,
        59, 60, 62, 63, 66, 66, 70, 70, 73, 74, 77, 78, 81, 83, 85, 87, 89, 92,
        93, 94, 94, 96, 96, 97, 68, 64, 64, 61, 61, 60, 59, 58, 59, 61, 62, 64,
        65, 67, 69, 71, 72, 74, 77, 78, 81, 82, 85, 86, 89, 90, 94, 94, 96, 96,
        98, 97, 69, 65, 65, 62, 62, 61, 61, 58, 59, 62, 62, 65, 65, 68, 68, 71,
        71, 75, 75, 79, 79, 83, 83, 87, 87, 91, 91, 96, 96, 97, 97, 99,
        /* Size 4x8 */
        31, 47, 50, 61, 36, 47, 47, 57, 43, 50, 50, 58, 45, 53, 58, 65, 47, 54,
        66, 74, 52, 56, 70, 82, 57, 60, 75, 90, 61, 63, 77, 93,
        /* Size 8x4 */
        31, 36, 43, 45, 47, 52, 57, 61, 47, 47, 50, 53, 54, 56, 60, 63, 50, 47,
        50, 58, 66, 70, 75, 77, 61, 57, 58, 65, 74, 82, 90, 93,
        /* Size 8x16 */
        32, 32, 40, 49, 51, 57, 63, 67, 31, 33, 41, 47, 49, 54, 59, 63, 31, 35,
        43, 46, 47, 51, 57, 60, 35, 39, 46, 46, 47, 50, 55, 58, 41, 43, 48, 49,
        49, 52, 57, 59, 49, 47, 50, 53, 54, 57, 60, 62, 48, 46, 49, 54, 57, 60,
        64, 65, 49, 45, 48, 56, 61, 64, 67, 69, 50, 46, 49, 57, 63, 67, 71, 73,
        52, 48, 50, 58, 65, 71, 75, 77, 54, 50, 51, 59, 67, 73, 78, 81, 57, 52,
        53, 61, 69, 77, 82, 85, 61, 55, 56, 63, 72, 80, 86, 88, 64, 58, 58, 65,
        73, 82, 89, 92, 66, 59, 59, 66, 75, 84, 91, 94, 68, 61, 59, 65, 72, 81,
        89, 95,
        /* Size 16x8 */
        32, 31, 31, 35, 41, 49, 48, 49, 50, 52, 54, 57, 61, 64, 66, 68, 32, 33,
        35, 39, 43, 47, 46, 45, 46, 48, 50, 52, 55, 58, 59, 61, 40, 41, 43, 46,
        48, 50, 49, 48, 49, 50, 51, 53, 56, 58, 59, 59, 49, 47, 46, 46, 49, 53,
        54, 56, 57, 58, 59, 61, 63, 65, 66, 65, 51, 49, 47, 47, 49, 54, 57, 61,
        63, 65, 67, 69, 72, 73, 75, 72, 57, 54, 51, 50, 52, 57, 60, 64, 67, 71,
        73, 77, 80, 82, 84, 81, 63, 59, 57, 55, 57, 60, 64, 67, 71, 75, 78, 82,
        86, 89, 91, 89, 67, 63, 60, 58, 59, 62, 65, 69, 73, 77, 81, 85, 88, 92,
        94, 95,
        /* Size 16x32 */
        32, 31, 32, 37, 40, 48, 49, 49, 51, 52, 57, 58, 63, 64, 67, 67, 31, 31,
        33, 38, 41, 47, 47, 47, 49, 50, 54, 55, 60, 61, 63, 64, 31, 31, 33, 38,
        41, 47, 47, 47, 49, 49, 54, 54, 59, 60, 63, 64, 30, 32, 33, 40, 42, 46,
        45, 45, 47, 48, 52, 52, 57, 58, 60, 61, 31, 33, 35, 41, 43, 46, 46, 45,
        47, 48, 51, 52, 57, 57, 60, 61, 33, 36, 37, 43, 44, 47, 46, 46, 47, 47,
        51, 52, 56, 57, 59, 60, 35, 38, 39, 45, 46, 47, 46, 45, 47, 47, 50, 51,
        55, 56, 58, 60, 37, 40, 41, 47, 47, 47, 46, 45, 46, 47, 50, 50, 54, 55,
        57, 58, 41, 42, 43, 47, 48, 49, 49, 48, 49, 50, 52, 53, 57, 57, 59, 58,
        42, 43, 43, 47, 48, 50, 49, 49, 50, 50, 53, 54, 57, 58, 60, 61, 49, 46,
        47, 48, 50, 53, 53, 53, 54, 54, 57, 57, 60, 61, 62, 61, 49, 46, 47, 48,
        50, 53, 53, 54, 54, 55, 57, 57, 61, 61, 63, 64, 48, 46, 46, 47, 49, 53,
        54, 56, 57, 57, 60, 60, 64, 64, 65, 64, 48, 45, 46, 46, 49, 53, 55, 56,
        58, 58, 61, 61, 65, 65, 66, 67, 49, 45, 45, 46, 48, 53, 56, 58, 61, 61,
        64, 64, 67, 68, 69, 67, 49, 46, 46, 46, 49, 53, 57, 59, 62, 62, 65, 66,
        69, 69, 70, 70, 50, 46, 46, 46, 49, 54, 57, 59, 63, 64, 67, 67, 71, 71,
        73, 71, 51, 47, 47, 47, 49, 54, 58, 61, 64, 66, 69, 70, 73, 74, 74, 74,
        52, 48, 48, 47, 50, 54, 58, 61, 65, 66, 71, 71, 75, 75, 77, 74, 54, 50,
        49, 48, 51, 55, 59, 62, 67, 68, 73, 73, 77, 78, 78, 78, 54, 50, 50, 49,
        51, 55, 59, 62, 67, 68, 73, 74, 78, 78, 81, 78, 57, 52, 52, 50, 52, 56,
        60, 64, 69, 70, 76, 77, 82, 82, 83, 82, 57, 52, 52, 51, 53, 57, 61, 64,
        69, 71, 77, 77, 82, 83, 85, 82, 60, 54, 54, 52, 55, 58, 62, 65, 71, 72,
        79, 79, 85, 86, 87, 86, 61, 56, 55, 53, 56, 59, 63, 66, 72, 73, 80, 81,
        86, 87, 88, 86, 63, 57, 57, 55, 57, 60, 64, 67, 73, 75, 82, 82, 89, 90,
        92, 90, 64, 58, 58, 55, 58, 61, 65, 68, 73, 75, 82, 83, 89, 90, 92, 90,
        64, 59, 58, 56, 58, 61, 65, 68, 74, 75, 83, 83, 90, 91, 94, 95, 66, 60,
        59, 57, 59, 62, 66, 69, 75, 76, 84, 85, 91, 92, 94, 95, 67, 61, 60, 58,
        59, 63, 66, 70, 74, 77, 82, 85, 91, 93, 96, 96, 68, 62, 61, 58, 59, 64,
        65, 71, 72, 78, 81, 86, 89, 94, 95, 96, 68, 62, 62, 59, 59, 65, 65, 71,
        71, 79, 79, 87, 87, 95, 95, 98,
        /* Size 32x16 */
        32, 31, 31, 30, 31, 33, 35, 37, 41, 42, 49, 49, 48, 48, 49, 49, 50, 51,
        52, 54, 54, 57, 57, 60, 61, 63, 64, 64, 66, 67, 68, 68, 31, 31, 31, 32,
        33, 36, 38, 40, 42, 43, 46, 46, 46, 45, 45, 46, 46, 47, 48, 50, 50, 52,
        52, 54, 56, 57, 58, 59, 60, 61, 62, 62, 32, 33, 33, 33, 35, 37, 39, 41,
        43, 43, 47, 47, 46, 46, 45, 46, 46, 47, 48, 49, 50, 52, 52, 54, 55, 57,
        58, 58, 59, 60, 61, 62, 37, 38, 38, 40, 41, 43, 45, 47, 47, 47, 48, 48,
        47, 46, 46, 46, 46, 47, 47, 48, 49, 50, 51, 52, 53, 55, 55, 56, 57, 58,
        58, 59, 40, 41, 41, 42, 43, 44, 46, 47, 48, 48, 50, 50, 49, 49, 48, 49,
        49, 49, 50, 51, 51, 52, 53, 55, 56, 57, 58, 58, 59, 59, 59, 59, 48, 47,
        47, 46, 46, 47, 47, 47, 49, 50, 53, 53, 53, 53, 53, 53, 54, 54, 54, 55,
        55, 56, 57, 58, 59, 60, 61, 61, 62, 63, 64, 65, 49, 47, 47, 45, 46, 46,
        46, 46, 49, 49, 53, 53, 54, 55, 56, 57, 57, 58, 58, 59, 59, 60, 61, 62,
        63, 64, 65, 65, 66, 66, 65, 65, 49, 47, 47, 45, 45, 46, 45, 45, 48, 49,
        53, 54, 56, 56, 58, 59, 59, 61, 61, 62, 62, 64, 64, 65, 66, 67, 68, 68,
        69, 70, 71, 71, 51, 49, 49, 47, 47, 47, 47, 46, 49, 50, 54, 54, 57, 58,
        61, 62, 63, 64, 65, 67, 67, 69, 69, 71, 72, 73, 73, 74, 75, 74, 72, 71,
        52, 50, 49, 48, 48, 47, 47, 47, 50, 50, 54, 55, 57, 58, 61, 62, 64, 66,
        66, 68, 68, 70, 71, 72, 73, 75, 75, 75, 76, 77, 78, 79, 57, 54, 54, 52,
        51, 51, 50, 50, 52, 53, 57, 57, 60, 61, 64, 65, 67, 69, 71, 73, 73, 76,
        77, 79, 80, 82, 82, 83, 84, 82, 81, 79, 58, 55, 54, 52, 52, 52, 51, 50,
        53, 54, 57, 57, 60, 61, 64, 66, 67, 70, 71, 73, 74, 77, 77, 79, 81, 82,
        83, 83, 85, 85, 86, 87, 63, 60, 59, 57, 57, 56, 55, 54, 57, 57, 60, 61,
        64, 65, 67, 69, 71, 73, 75, 77, 78, 82, 82, 85, 86, 89, 89, 90, 91, 91,
        89, 87, 64, 61, 60, 58, 57, 57, 56, 55, 57, 58, 61, 61, 64, 65, 68, 69,
        71, 74, 75, 78, 78, 82, 83, 86, 87, 90, 90, 91, 92, 93, 94, 95, 67, 63,
        63, 60, 60, 59, 58, 57, 59, 60, 62, 63, 65, 66, 69, 70, 73, 74, 77, 78,
        81, 83, 85, 87, 88, 92, 92, 94, 94, 96, 95, 95, 67, 64, 64, 61, 61, 60,
        60, 58, 58, 61, 61, 64, 64, 67, 67, 70, 71, 74, 74, 78, 78, 82, 82, 86,
        86, 90, 90, 95, 95, 96, 96, 98 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 34, 49, 72, 34, 48, 60, 79, 49, 60, 82, 104, 72, 79, 104, 134,
        /* Size 8x8 */
        32, 32, 34, 38, 46, 56, 68, 78, 32, 33, 35, 39, 45, 54, 64, 74, 34, 35,
        39, 45, 51, 58, 68, 76, 38, 39, 45, 54, 61, 69, 78, 86, 46, 45, 51, 61,
        71, 80, 90, 99, 56, 54, 58, 69, 80, 92, 103, 113, 68, 64, 68, 78, 90,
        103, 117, 128, 78, 74, 76, 86, 99, 113, 128, 140,
        /* Size 16x16 */
        32, 31, 31, 31, 32, 34, 36, 39, 44, 48, 54, 59, 65, 71, 80, 83, 31, 32,
        32, 32, 32, 34, 35, 38, 42, 46, 51, 56, 62, 68, 76, 78, 31, 32, 32, 32,
        32, 33, 34, 37, 41, 44, 49, 54, 59, 65, 72, 75, 31, 32, 32, 33, 34, 35,
        36, 39, 42, 45, 50, 54, 59, 64, 71, 74, 32, 32, 32, 34, 35, 37, 38, 40,
        42, 46, 49, 53, 58, 63, 69, 72, 34, 34, 33, 35, 37, 39, 42, 45, 47, 51,
        54, 58, 63, 68, 74, 76, 36, 35, 34, 36, 38, 42, 48, 50, 54, 57, 60, 64,
        68, 73, 79, 81, 39, 38, 37, 39, 40, 45, 50, 54, 58, 61, 65, 69, 73, 78,
        84, 86, 44, 42, 41, 42, 42, 47, 54, 58, 63, 67, 71, 75, 79, 84, 90, 92,
        48, 46, 44, 45, 46, 51, 57, 61, 67, 71, 76, 80, 85, 90, 96, 99, 54, 51,
        49, 50, 49, 54, 60, 65, 71, 76, 82, 87, 92, 97, 104, 106, 59, 56, 54,
        54, 53, 58, 64, 69, 75, 80, 87, 92, 98, 103, 110, 113, 65, 62, 59, 59,
        58, 63, 68, 73, 79, 85, 92, 98, 105, 111, 118, 121, 71, 68, 65, 64, 63,
        68, 73, 78, 84, 90, 97, 103, 111, 117, 125, 128, 80, 76, 72, 71, 69, 74,
        79, 84, 90, 96, 104, 110, 118, 125, 134, 137, 83, 78, 75, 74, 72, 76,
        81, 86, 92, 99, 106, 113, 121, 128, 137, 140,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 32, 32, 34, 34, 36, 36, 39, 39, 44, 44, 48,
        48, 54, 54, 59, 59, 65, 65, 71, 71, 80, 80, 83, 83, 87, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 34, 34, 35, 35, 38, 38, 42, 42, 46, 46, 51, 51, 56,
        56, 62, 62, 68, 68, 76, 76, 78, 78, 83, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 34, 34, 35, 35, 38, 38, 42, 42, 46, 46, 51, 51, 56, 56, 62, 62, 68,
        68, 76, 76, 78, 78, 83, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34,
        34, 37, 37, 41, 41, 44, 44, 49, 49, 54, 54, 59, 59, 65, 65, 72, 72, 75,
        75, 79, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 37, 37, 41,
        41, 44, 44, 49, 49, 54, 54, 59, 59, 65, 65, 72, 72, 75, 75, 79, 31, 32,
        32, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 39, 39, 42, 42, 45, 45, 50,
        50, 54, 54, 59, 59, 64, 64, 71, 71, 74, 74, 77, 31, 32, 32, 32, 32, 33,
        33, 34, 34, 35, 35, 36, 36, 39, 39, 42, 42, 45, 45, 50, 50, 54, 54, 59,
        59, 64, 64, 71, 71, 74, 74, 77, 32, 32, 32, 32, 32, 34, 34, 35, 35, 37,
        37, 38, 38, 40, 40, 42, 42, 46, 46, 49, 49, 53, 53, 58, 58, 63, 63, 69,
        69, 72, 72, 75, 32, 32, 32, 32, 32, 34, 34, 35, 35, 37, 37, 38, 38, 40,
        40, 42, 42, 46, 46, 49, 49, 53, 53, 58, 58, 63, 63, 69, 69, 72, 72, 75,
        34, 34, 34, 33, 33, 35, 35, 37, 37, 39, 39, 42, 42, 45, 45, 47, 47, 51,
        51, 54, 54, 58, 58, 63, 63, 68, 68, 74, 74, 76, 76, 80, 34, 34, 34, 33,
        33, 35, 35, 37, 37, 39, 39, 42, 42, 45, 45, 47, 47, 51, 51, 54, 54, 58,
        58, 63, 63, 68, 68, 74, 74, 76, 76, 80, 36, 35, 35, 34, 34, 36, 36, 38,
        38, 42, 42, 48, 48, 50, 50, 54, 54, 57, 57, 60, 60, 64, 64, 68, 68, 73,
        73, 79, 79, 81, 81, 84, 36, 35, 35, 34, 34, 36, 36, 38, 38, 42, 42, 48,
        48, 50, 50, 54, 54, 57, 57, 60, 60, 64, 64, 68, 68, 73, 73, 79, 79, 81,
        81, 84, 39, 38, 38, 37, 37, 39, 39, 40, 40, 45, 45, 50, 50, 54, 54, 58,
        58, 61, 61, 65, 65, 69, 69, 73, 73, 78, 78, 84, 84, 86, 86, 90, 39, 38,
        38, 37, 37, 39, 39, 40, 40, 45, 45, 50, 50, 54, 54, 58, 58, 61, 61, 65,
        65, 69, 69, 73, 73, 78, 78, 84, 84, 86, 86, 90, 44, 42, 42, 41, 41, 42,
        42, 42, 42, 47, 47, 54, 54, 58, 58, 63, 63, 67, 67, 71, 71, 75, 75, 79,
        79, 84, 84, 90, 90, 92, 92, 96, 44, 42, 42, 41, 41, 42, 42, 42, 42, 47,
        47, 54, 54, 58, 58, 63, 63, 67, 67, 71, 71, 75, 75, 79, 79, 84, 84, 90,
        90, 92, 92, 96, 48, 46, 46, 44, 44, 45, 45, 46, 46, 51, 51, 57, 57, 61,
        61, 67, 67, 71, 71, 76, 76, 80, 80, 85, 85, 90, 90, 96, 96, 99, 99, 102,
        48, 46, 46, 44, 44, 45, 45, 46, 46, 51, 51, 57, 57, 61, 61, 67, 67, 71,
        71, 76, 76, 80, 80, 85, 85, 90, 90, 96, 96, 99, 99, 102, 54, 51, 51, 49,
        49, 50, 50, 49, 49, 54, 54, 60, 60, 65, 65, 71, 71, 76, 76, 82, 82, 87,
        87, 92, 92, 97, 97, 104, 104, 106, 106, 109, 54, 51, 51, 49, 49, 50, 50,
        49, 49, 54, 54, 60, 60, 65, 65, 71, 71, 76, 76, 82, 82, 87, 87, 92, 92,
        97, 97, 104, 104, 106, 106, 109, 59, 56, 56, 54, 54, 54, 54, 53, 53, 58,
        58, 64, 64, 69, 69, 75, 75, 80, 80, 87, 87, 92, 92, 98, 98, 103, 103,
        110, 110, 113, 113, 116, 59, 56, 56, 54, 54, 54, 54, 53, 53, 58, 58, 64,
        64, 69, 69, 75, 75, 80, 80, 87, 87, 92, 92, 98, 98, 103, 103, 110, 110,
        113, 113, 116, 65, 62, 62, 59, 59, 59, 59, 58, 58, 63, 63, 68, 68, 73,
        73, 79, 79, 85, 85, 92, 92, 98, 98, 105, 105, 111, 111, 118, 118, 121,
        121, 124, 65, 62, 62, 59, 59, 59, 59, 58, 58, 63, 63, 68, 68, 73, 73,
        79, 79, 85, 85, 92, 92, 98, 98, 105, 105, 111, 111, 118, 118, 121, 121,
        124, 71, 68, 68, 65, 65, 64, 64, 63, 63, 68, 68, 73, 73, 78, 78, 84, 84,
        90, 90, 97, 97, 103, 103, 111, 111, 117, 117, 125, 125, 128, 128, 132,
        71, 68, 68, 65, 65, 64, 64, 63, 63, 68, 68, 73, 73, 78, 78, 84, 84, 90,
        90, 97, 97, 103, 103, 111, 111, 117, 117, 125, 125, 128, 128, 132, 80,
        76, 76, 72, 72, 71, 71, 69, 69, 74, 74, 79, 79, 84, 84, 90, 90, 96, 96,
        104, 104, 110, 110, 118, 118, 125, 125, 134, 134, 137, 137, 141, 80, 76,
        76, 72, 72, 71, 71, 69, 69, 74, 74, 79, 79, 84, 84, 90, 90, 96, 96, 104,
        104, 110, 110, 118, 118, 125, 125, 134, 134, 137, 137, 141, 83, 78, 78,
        75, 75, 74, 74, 72, 72, 76, 76, 81, 81, 86, 86, 92, 92, 99, 99, 106,
        106, 113, 113, 121, 121, 128, 128, 137, 137, 140, 140, 144, 83, 78, 78,
        75, 75, 74, 74, 72, 72, 76, 76, 81, 81, 86, 86, 92, 92, 99, 99, 106,
        106, 113, 113, 121, 121, 128, 128, 137, 137, 140, 140, 144, 87, 83, 83,
        79, 79, 77, 77, 75, 75, 80, 80, 84, 84, 90, 90, 96, 96, 102, 102, 109,
        109, 116, 116, 124, 124, 132, 132, 141, 141, 144, 144, 149,
        /* Size 4x8 */
        32, 35, 51, 75, 32, 36, 50, 71, 34, 42, 54, 73, 37, 50, 65, 84, 45, 56,
        76, 96, 54, 63, 87, 110, 65, 73, 97, 125, 75, 81, 106, 136,
        /* Size 8x4 */
        32, 32, 34, 37, 45, 54, 65, 75, 35, 36, 42, 50, 56, 63, 73, 81, 51, 50,
        54, 65, 76, 87, 97, 106, 75, 71, 73, 84, 96, 110, 125, 136,
        /* Size 8x16 */
        32, 31, 32, 36, 44, 53, 65, 79, 31, 32, 32, 35, 42, 51, 62, 75, 31, 32,
        33, 34, 41, 49, 59, 72, 32, 32, 34, 36, 42, 50, 59, 71, 32, 33, 35, 38,
        42, 49, 58, 69, 34, 34, 37, 42, 48, 54, 63, 73, 36, 34, 38, 48, 54, 60,
        68, 78, 39, 37, 40, 50, 58, 65, 73, 84, 44, 41, 43, 53, 63, 71, 79, 90,
        48, 45, 46, 56, 67, 76, 85, 96, 53, 49, 50, 60, 71, 82, 92, 103, 58, 54,
        54, 63, 75, 87, 98, 110, 65, 60, 58, 68, 79, 92, 105, 118, 71, 65, 63,
        73, 84, 97, 111, 125, 79, 72, 70, 79, 90, 104, 118, 133, 82, 75, 72, 81,
        92, 106, 121, 136,
        /* Size 16x8 */
        32, 31, 31, 32, 32, 34, 36, 39, 44, 48, 53, 58, 65, 71, 79, 82, 31, 32,
        32, 32, 33, 34, 34, 37, 41, 45, 49, 54, 60, 65, 72, 75, 32, 32, 33, 34,
        35, 37, 38, 40, 43, 46, 50, 54, 58, 63, 70, 72, 36, 35, 34, 36, 38, 42,
        48, 50, 53, 56, 60, 63, 68, 73, 79, 81, 44, 42, 41, 42, 42, 48, 54, 58,
        63, 67, 71, 75, 79, 84, 90, 92, 53, 51, 49, 50, 49, 54, 60, 65, 71, 76,
        82, 87, 92, 97, 104, 106, 65, 62, 59, 59, 58, 63, 68, 73, 79, 85, 92,
        98, 105, 111, 118, 121, 79, 75, 72, 71, 69, 73, 78, 84, 90, 96, 103,
        110, 118, 125, 133, 136,
        /* Size 16x32 */
        32, 31, 31, 32, 32, 36, 36, 44, 44, 53, 53, 65, 65, 79, 79, 87, 31, 32,
        32, 32, 32, 35, 35, 42, 42, 51, 51, 62, 62, 75, 75, 82, 31, 32, 32, 32,
        32, 35, 35, 42, 42, 51, 51, 62, 62, 75, 75, 82, 31, 32, 32, 33, 33, 34,
        34, 41, 41, 49, 49, 59, 59, 72, 72, 78, 31, 32, 32, 33, 33, 34, 34, 41,
        41, 49, 49, 59, 59, 72, 72, 78, 32, 32, 32, 34, 34, 36, 36, 42, 42, 50,
        50, 59, 59, 71, 71, 77, 32, 32, 32, 34, 34, 36, 36, 42, 42, 50, 50, 59,
        59, 71, 71, 77, 32, 33, 33, 35, 35, 38, 38, 42, 42, 49, 49, 58, 58, 69,
        69, 75, 32, 33, 33, 35, 35, 38, 38, 42, 42, 49, 49, 58, 58, 69, 69, 75,
        34, 34, 34, 37, 37, 42, 42, 48, 48, 54, 54, 63, 63, 73, 73, 79, 34, 34,
        34, 37, 37, 42, 42, 48, 48, 54, 54, 63, 63, 73, 73, 79, 36, 34, 34, 38,
        38, 48, 48, 54, 54, 60, 60, 68, 68, 78, 78, 84, 36, 34, 34, 38, 38, 48,
        48, 54, 54, 60, 60, 68, 68, 78, 78, 84, 39, 37, 37, 40, 40, 50, 50, 58,
        58, 65, 65, 73, 73, 84, 84, 89, 39, 37, 37, 40, 40, 50, 50, 58, 58, 65,
        65, 73, 73, 84, 84, 89, 44, 41, 41, 43, 43, 53, 53, 63, 63, 71, 71, 79,
        79, 90, 90, 95, 44, 41, 41, 43, 43, 53, 53, 63, 63, 71, 71, 79, 79, 90,
        90, 95, 48, 45, 45, 46, 46, 56, 56, 67, 67, 76, 76, 85, 85, 96, 96, 102,
        48, 45, 45, 46, 46, 56, 56, 67, 67, 76, 76, 85, 85, 96, 96, 102, 53, 49,
        49, 50, 50, 60, 60, 71, 71, 82, 82, 92, 92, 103, 103, 109, 53, 49, 49,
        50, 50, 60, 60, 71, 71, 82, 82, 92, 92, 103, 103, 109, 58, 54, 54, 54,
        54, 63, 63, 75, 75, 87, 87, 98, 98, 110, 110, 116, 58, 54, 54, 54, 54,
        63, 63, 75, 75, 87, 87, 98, 98, 110, 110, 116, 65, 60, 60, 58, 58, 68,
        68, 79, 79, 92, 92, 105, 105, 118, 118, 124, 65, 60, 60, 58, 58, 68, 68,
        79, 79, 92, 92, 105, 105, 118, 118, 124, 71, 65, 65, 63, 63, 73, 73, 84,
        84, 97, 97, 111, 111, 125, 125, 132, 71, 65, 65, 63, 63, 73, 73, 84, 84,
        97, 97, 111, 111, 125, 125, 132, 79, 72, 72, 70, 70, 79, 79, 90, 90,
        104, 104, 118, 118, 133, 133, 141, 79, 72, 72, 70, 70, 79, 79, 90, 90,
        104, 104, 118, 118, 133, 133, 141, 82, 75, 75, 72, 72, 81, 81, 92, 92,
        106, 106, 121, 121, 136, 136, 144, 82, 75, 75, 72, 72, 81, 81, 92, 92,
        106, 106, 121, 121, 136, 136, 144, 87, 79, 79, 76, 76, 84, 84, 96, 96,
        109, 109, 124, 124, 141, 141, 149,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 36, 36, 39, 39, 44, 44, 48,
        48, 53, 53, 58, 58, 65, 65, 71, 71, 79, 79, 82, 82, 87, 31, 32, 32, 32,
        32, 32, 32, 33, 33, 34, 34, 34, 34, 37, 37, 41, 41, 45, 45, 49, 49, 54,
        54, 60, 60, 65, 65, 72, 72, 75, 75, 79, 31, 32, 32, 32, 32, 32, 32, 33,
        33, 34, 34, 34, 34, 37, 37, 41, 41, 45, 45, 49, 49, 54, 54, 60, 60, 65,
        65, 72, 72, 75, 75, 79, 32, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38,
        38, 40, 40, 43, 43, 46, 46, 50, 50, 54, 54, 58, 58, 63, 63, 70, 70, 72,
        72, 76, 32, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38, 38, 40, 40, 43,
        43, 46, 46, 50, 50, 54, 54, 58, 58, 63, 63, 70, 70, 72, 72, 76, 36, 35,
        35, 34, 34, 36, 36, 38, 38, 42, 42, 48, 48, 50, 50, 53, 53, 56, 56, 60,
        60, 63, 63, 68, 68, 73, 73, 79, 79, 81, 81, 84, 36, 35, 35, 34, 34, 36,
        36, 38, 38, 42, 42, 48, 48, 50, 50, 53, 53, 56, 56, 60, 60, 63, 63, 68,
        68, 73, 73, 79, 79, 81, 81, 84, 44, 42, 42, 41, 41, 42, 42, 42, 42, 48,
        48, 54, 54, 58, 58, 63, 63, 67, 67, 71, 71, 75, 75, 79, 79, 84, 84, 90,
        90, 92, 92, 96, 44, 42, 42, 41, 41, 42, 42, 42, 42, 48, 48, 54, 54, 58,
        58, 63, 63, 67, 67, 71, 71, 75, 75, 79, 79, 84, 84, 90, 90, 92, 92, 96,
        53, 51, 51, 49, 49, 50, 50, 49, 49, 54, 54, 60, 60, 65, 65, 71, 71, 76,
        76, 82, 82, 87, 87, 92, 92, 97, 97, 104, 104, 106, 106, 109, 53, 51, 51,
        49, 49, 50, 50, 49, 49, 54, 54, 60, 60, 65, 65, 71, 71, 76, 76, 82, 82,
        87, 87, 92, 92, 97, 97, 104, 104, 106, 106, 109, 65, 62, 62, 59, 59, 59,
        59, 58, 58, 63, 63, 68, 68, 73, 73, 79, 79, 85, 85, 92, 92, 98, 98, 105,
        105, 111, 111, 118, 118, 121, 121, 124, 65, 62, 62, 59, 59, 59, 59, 58,
        58, 63, 63, 68, 68, 73, 73, 79, 79, 85, 85, 92, 92, 98, 98, 105, 105,
        111, 111, 118, 118, 121, 121, 124, 79, 75, 75, 72, 72, 71, 71, 69, 69,
        73, 73, 78, 78, 84, 84, 90, 90, 96, 96, 103, 103, 110, 110, 118, 118,
        125, 125, 133, 133, 136, 136, 141, 79, 75, 75, 72, 72, 71, 71, 69, 69,
        73, 73, 78, 78, 84, 84, 90, 90, 96, 96, 103, 103, 110, 110, 118, 118,
        125, 125, 133, 133, 136, 136, 141, 87, 82, 82, 78, 78, 77, 77, 75, 75,
        79, 79, 84, 84, 89, 89, 95, 95, 102, 102, 109, 109, 116, 116, 124, 124,
        132, 132, 141, 141, 144, 144, 149 },
      { /* Chroma */
        /* Size 4x4 */
        32, 46, 47, 57, 46, 53, 54, 60, 47, 54, 66, 75, 57, 60, 75, 89,
        /* Size 8x8 */
        31, 34, 42, 47, 48, 52, 57, 61, 34, 39, 45, 46, 46, 49, 53, 57, 42, 45,
        48, 49, 50, 52, 55, 58, 47, 46, 49, 54, 56, 58, 61, 64, 48, 46, 50, 56,
        61, 65, 68, 71, 52, 49, 52, 58, 65, 71, 75, 79, 57, 53, 55, 61, 68, 75,
        82, 86, 61, 57, 58, 64, 71, 79, 86, 91,
        /* Size 16x16 */
        32, 31, 30, 33, 36, 41, 49, 48, 49, 50, 52, 54, 57, 60, 63, 65, 31, 31,
        31, 34, 38, 42, 47, 47, 47, 48, 50, 52, 54, 57, 60, 61, 30, 31, 32, 35,
        40, 42, 46, 45, 45, 46, 47, 49, 52, 54, 57, 58, 33, 34, 35, 39, 43, 45,
        47, 46, 45, 46, 47, 49, 51, 53, 56, 57, 36, 38, 40, 43, 47, 47, 48, 46,
        45, 46, 47, 48, 50, 52, 54, 55, 41, 42, 42, 45, 47, 48, 50, 49, 49, 50,
        50, 52, 53, 55, 57, 58, 49, 47, 46, 47, 48, 50, 53, 53, 53, 54, 54, 55,
        56, 58, 60, 61, 48, 47, 45, 46, 46, 49, 53, 54, 55, 56, 57, 58, 60, 61,
        63, 64, 49, 47, 45, 45, 45, 49, 53, 55, 58, 60, 61, 62, 63, 65, 67, 68,
        50, 48, 46, 46, 46, 50, 54, 56, 60, 61, 63, 65, 67, 68, 71, 71, 52, 50,
        47, 47, 47, 50, 54, 57, 61, 63, 66, 68, 70, 72, 75, 75, 54, 52, 49, 49,
        48, 52, 55, 58, 62, 65, 68, 71, 73, 75, 78, 79, 57, 54, 52, 51, 50, 53,
        56, 60, 63, 67, 70, 73, 76, 79, 82, 83, 60, 57, 54, 53, 52, 55, 58, 61,
        65, 68, 72, 75, 79, 82, 85, 86, 63, 60, 57, 56, 54, 57, 60, 63, 67, 71,
        75, 78, 82, 85, 89, 90, 65, 61, 58, 57, 55, 58, 61, 64, 68, 71, 75, 79,
        83, 86, 90, 91,
        /* Size 32x32 */
        32, 31, 31, 30, 30, 33, 33, 36, 36, 41, 41, 49, 49, 48, 48, 49, 49, 50,
        50, 52, 52, 54, 54, 57, 57, 60, 60, 63, 63, 65, 65, 67, 31, 31, 31, 31,
        31, 34, 34, 38, 38, 42, 42, 47, 47, 47, 47, 47, 47, 48, 48, 50, 50, 52,
        52, 54, 54, 57, 57, 60, 60, 61, 61, 63, 31, 31, 31, 31, 31, 34, 34, 38,
        38, 42, 42, 47, 47, 47, 47, 47, 47, 48, 48, 50, 50, 52, 52, 54, 54, 57,
        57, 60, 60, 61, 61, 63, 30, 31, 31, 32, 32, 35, 35, 40, 40, 42, 42, 46,
        46, 45, 45, 45, 45, 46, 46, 47, 47, 49, 49, 52, 52, 54, 54, 57, 57, 58,
        58, 60, 30, 31, 31, 32, 32, 35, 35, 40, 40, 42, 42, 46, 46, 45, 45, 45,
        45, 46, 46, 47, 47, 49, 49, 52, 52, 54, 54, 57, 57, 58, 58, 60, 33, 34,
        34, 35, 35, 39, 39, 43, 43, 45, 45, 47, 47, 46, 46, 45, 45, 46, 46, 47,
        47, 49, 49, 51, 51, 53, 53, 56, 56, 57, 57, 59, 33, 34, 34, 35, 35, 39,
        39, 43, 43, 45, 45, 47, 47, 46, 46, 45, 45, 46, 46, 47, 47, 49, 49, 51,
        51, 53, 53, 56, 56, 57, 57, 59, 36, 38, 38, 40, 40, 43, 43, 47, 47, 47,
        47, 48, 48, 46, 46, 45, 45, 46, 46, 47, 47, 48, 48, 50, 50, 52, 52, 54,
        54, 55, 55, 57, 36, 38, 38, 40, 40, 43, 43, 47, 47, 47, 47, 48, 48, 46,
        46, 45, 45, 46, 46, 47, 47, 48, 48, 50, 50, 52, 52, 54, 54, 55, 55, 57,
        41, 42, 42, 42, 42, 45, 45, 47, 47, 48, 48, 50, 50, 49, 49, 49, 49, 50,
        50, 50, 50, 52, 52, 53, 53, 55, 55, 57, 57, 58, 58, 60, 41, 42, 42, 42,
        42, 45, 45, 47, 47, 48, 48, 50, 50, 49, 49, 49, 49, 50, 50, 50, 50, 52,
        52, 53, 53, 55, 55, 57, 57, 58, 58, 60, 49, 47, 47, 46, 46, 47, 47, 48,
        48, 50, 50, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56, 56, 58,
        58, 60, 60, 61, 61, 62, 49, 47, 47, 46, 46, 47, 47, 48, 48, 50, 50, 53,
        53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56, 56, 58, 58, 60, 60, 61,
        61, 62, 48, 47, 47, 45, 45, 46, 46, 46, 46, 49, 49, 53, 53, 54, 54, 55,
        55, 56, 56, 57, 57, 58, 58, 60, 60, 61, 61, 63, 63, 64, 64, 66, 48, 47,
        47, 45, 45, 46, 46, 46, 46, 49, 49, 53, 53, 54, 54, 55, 55, 56, 56, 57,
        57, 58, 58, 60, 60, 61, 61, 63, 63, 64, 64, 66, 49, 47, 47, 45, 45, 45,
        45, 45, 45, 49, 49, 53, 53, 55, 55, 58, 58, 60, 60, 61, 61, 62, 62, 63,
        63, 65, 65, 67, 67, 68, 68, 69, 49, 47, 47, 45, 45, 45, 45, 45, 45, 49,
        49, 53, 53, 55, 55, 58, 58, 60, 60, 61, 61, 62, 62, 63, 63, 65, 65, 67,
        67, 68, 68, 69, 50, 48, 48, 46, 46, 46, 46, 46, 46, 50, 50, 54, 54, 56,
        56, 60, 60, 61, 61, 63, 63, 65, 65, 67, 67, 68, 68, 71, 71, 71, 71, 72,
        50, 48, 48, 46, 46, 46, 46, 46, 46, 50, 50, 54, 54, 56, 56, 60, 60, 61,
        61, 63, 63, 65, 65, 67, 67, 68, 68, 71, 71, 71, 71, 72, 52, 50, 50, 47,
        47, 47, 47, 47, 47, 50, 50, 54, 54, 57, 57, 61, 61, 63, 63, 66, 66, 68,
        68, 70, 70, 72, 72, 75, 75, 75, 75, 76, 52, 50, 50, 47, 47, 47, 47, 47,
        47, 50, 50, 54, 54, 57, 57, 61, 61, 63, 63, 66, 66, 68, 68, 70, 70, 72,
        72, 75, 75, 75, 75, 76, 54, 52, 52, 49, 49, 49, 49, 48, 48, 52, 52, 55,
        55, 58, 58, 62, 62, 65, 65, 68, 68, 71, 71, 73, 73, 75, 75, 78, 78, 79,
        79, 80, 54, 52, 52, 49, 49, 49, 49, 48, 48, 52, 52, 55, 55, 58, 58, 62,
        62, 65, 65, 68, 68, 71, 71, 73, 73, 75, 75, 78, 78, 79, 79, 80, 57, 54,
        54, 52, 52, 51, 51, 50, 50, 53, 53, 56, 56, 60, 60, 63, 63, 67, 67, 70,
        70, 73, 73, 76, 76, 79, 79, 82, 82, 83, 83, 84, 57, 54, 54, 52, 52, 51,
        51, 50, 50, 53, 53, 56, 56, 60, 60, 63, 63, 67, 67, 70, 70, 73, 73, 76,
        76, 79, 79, 82, 82, 83, 83, 84, 60, 57, 57, 54, 54, 53, 53, 52, 52, 55,
        55, 58, 58, 61, 61, 65, 65, 68, 68, 72, 72, 75, 75, 79, 79, 82, 82, 85,
        85, 86, 86, 88, 60, 57, 57, 54, 54, 53, 53, 52, 52, 55, 55, 58, 58, 61,
        61, 65, 65, 68, 68, 72, 72, 75, 75, 79, 79, 82, 82, 85, 85, 86, 86, 88,
        63, 60, 60, 57, 57, 56, 56, 54, 54, 57, 57, 60, 60, 63, 63, 67, 67, 71,
        71, 75, 75, 78, 78, 82, 82, 85, 85, 89, 89, 90, 90, 92, 63, 60, 60, 57,
        57, 56, 56, 54, 54, 57, 57, 60, 60, 63, 63, 67, 67, 71, 71, 75, 75, 78,
        78, 82, 82, 85, 85, 89, 89, 90, 90, 92, 65, 61, 61, 58, 58, 57, 57, 55,
        55, 58, 58, 61, 61, 64, 64, 68, 68, 71, 71, 75, 75, 79, 79, 83, 83, 86,
        86, 90, 90, 91, 91, 93, 65, 61, 61, 58, 58, 57, 57, 55, 55, 58, 58, 61,
        61, 64, 64, 68, 68, 71, 71, 75, 75, 79, 79, 83, 83, 86, 86, 90, 90, 91,
        91, 93, 67, 63, 63, 60, 60, 59, 59, 57, 57, 60, 60, 62, 62, 66, 66, 69,
        69, 72, 72, 76, 76, 80, 80, 84, 84, 88, 88, 92, 92, 93, 93, 95,
        /* Size 4x8 */
        31, 47, 50, 60, 36, 47, 47, 56, 43, 50, 50, 57, 46, 53, 57, 64, 46, 54,
        64, 71, 50, 55, 68, 78, 54, 58, 72, 85, 59, 61, 75, 90,
        /* Size 8x4 */
        31, 36, 43, 46, 46, 50, 54, 59, 47, 47, 50, 53, 54, 55, 58, 61, 50, 47,
        50, 57, 64, 68, 72, 75, 60, 56, 57, 64, 71, 78, 85, 90,
        /* Size 8x16 */
        32, 31, 37, 48, 49, 52, 57, 63, 31, 31, 38, 47, 47, 50, 54, 60, 30, 32,
        40, 46, 45, 48, 52, 57, 33, 36, 43, 47, 46, 47, 51, 56, 37, 40, 47, 47,
        45, 47, 50, 54, 42, 43, 47, 50, 49, 50, 53, 57, 49, 46, 48, 53, 53, 54,
        57, 60, 48, 46, 47, 53, 56, 57, 60, 64, 49, 45, 46, 53, 58, 61, 64, 67,
        50, 46, 46, 54, 59, 64, 67, 71, 52, 48, 47, 54, 61, 66, 71, 75, 54, 50,
        49, 55, 62, 68, 73, 78, 57, 52, 50, 56, 64, 70, 76, 82, 60, 54, 52, 58,
        65, 72, 79, 85, 63, 57, 55, 60, 67, 75, 82, 89, 64, 59, 56, 61, 68, 75,
        83, 90,
        /* Size 16x8 */
        32, 31, 30, 33, 37, 42, 49, 48, 49, 50, 52, 54, 57, 60, 63, 64, 31, 31,
        32, 36, 40, 43, 46, 46, 45, 46, 48, 50, 52, 54, 57, 59, 37, 38, 40, 43,
        47, 47, 48, 47, 46, 46, 47, 49, 50, 52, 55, 56, 48, 47, 46, 47, 47, 50,
        53, 53, 53, 54, 54, 55, 56, 58, 60, 61, 49, 47, 45, 46, 45, 49, 53, 56,
        58, 59, 61, 62, 64, 65, 67, 68, 52, 50, 48, 47, 47, 50, 54, 57, 61, 64,
        66, 68, 70, 72, 75, 75, 57, 54, 52, 51, 50, 53, 57, 60, 64, 67, 71, 73,
        76, 79, 82, 83, 63, 60, 57, 56, 54, 57, 60, 64, 67, 71, 75, 78, 82, 85,
        89, 90,
        /* Size 16x32 */
        32, 31, 31, 37, 37, 48, 48, 49, 49, 52, 52, 57, 57, 63, 63, 66, 31, 31,
        31, 38, 38, 47, 47, 47, 47, 50, 50, 54, 54, 60, 60, 63, 31, 31, 31, 38,
        38, 47, 47, 47, 47, 50, 50, 54, 54, 60, 60, 63, 30, 32, 32, 40, 40, 46,
        46, 45, 45, 48, 48, 52, 52, 57, 57, 60, 30, 32, 32, 40, 40, 46, 46, 45,
        45, 48, 48, 52, 52, 57, 57, 60, 33, 36, 36, 43, 43, 47, 47, 46, 46, 47,
        47, 51, 51, 56, 56, 59, 33, 36, 36, 43, 43, 47, 47, 46, 46, 47, 47, 51,
        51, 56, 56, 59, 37, 40, 40, 47, 47, 47, 47, 45, 45, 47, 47, 50, 50, 54,
        54, 57, 37, 40, 40, 47, 47, 47, 47, 45, 45, 47, 47, 50, 50, 54, 54, 57,
        42, 43, 43, 47, 47, 50, 50, 49, 49, 50, 50, 53, 53, 57, 57, 60, 42, 43,
        43, 47, 47, 50, 50, 49, 49, 50, 50, 53, 53, 57, 57, 60, 49, 46, 46, 48,
        48, 53, 53, 53, 53, 54, 54, 57, 57, 60, 60, 62, 49, 46, 46, 48, 48, 53,
        53, 53, 53, 54, 54, 57, 57, 60, 60, 62, 48, 46, 46, 47, 47, 53, 53, 56,
        56, 57, 57, 60, 60, 64, 64, 66, 48, 46, 46, 47, 47, 53, 53, 56, 56, 57,
        57, 60, 60, 64, 64, 66, 49, 45, 45, 46, 46, 53, 53, 58, 58, 61, 61, 64,
        64, 67, 67, 69, 49, 45, 45, 46, 46, 53, 53, 58, 58, 61, 61, 64, 64, 67,
        67, 69, 50, 46, 46, 46, 46, 54, 54, 59, 59, 64, 64, 67, 67, 71, 71, 73,
        50, 46, 46, 46, 46, 54, 54, 59, 59, 64, 64, 67, 67, 71, 71, 73, 52, 48,
        48, 47, 47, 54, 54, 61, 61, 66, 66, 71, 71, 75, 75, 77, 52, 48, 48, 47,
        47, 54, 54, 61, 61, 66, 66, 71, 71, 75, 75, 77, 54, 50, 50, 49, 49, 55,
        55, 62, 62, 68, 68, 73, 73, 78, 78, 80, 54, 50, 50, 49, 49, 55, 55, 62,
        62, 68, 68, 73, 73, 78, 78, 80, 57, 52, 52, 50, 50, 56, 56, 64, 64, 70,
        70, 76, 76, 82, 82, 84, 57, 52, 52, 50, 50, 56, 56, 64, 64, 70, 70, 76,
        76, 82, 82, 84, 60, 54, 54, 52, 52, 58, 58, 65, 65, 72, 72, 79, 79, 85,
        85, 88, 60, 54, 54, 52, 52, 58, 58, 65, 65, 72, 72, 79, 79, 85, 85, 88,
        63, 57, 57, 55, 55, 60, 60, 67, 67, 75, 75, 82, 82, 89, 89, 92, 63, 57,
        57, 55, 55, 60, 60, 67, 67, 75, 75, 82, 82, 89, 89, 92, 64, 59, 59, 56,
        56, 61, 61, 68, 68, 75, 75, 83, 83, 90, 90, 93, 64, 59, 59, 56, 56, 61,
        61, 68, 68, 75, 75, 83, 83, 90, 90, 93, 66, 60, 60, 57, 57, 63, 63, 69,
        69, 77, 77, 84, 84, 92, 92, 95,
        /* Size 32x16 */
        32, 31, 31, 30, 30, 33, 33, 37, 37, 42, 42, 49, 49, 48, 48, 49, 49, 50,
        50, 52, 52, 54, 54, 57, 57, 60, 60, 63, 63, 64, 64, 66, 31, 31, 31, 32,
        32, 36, 36, 40, 40, 43, 43, 46, 46, 46, 46, 45, 45, 46, 46, 48, 48, 50,
        50, 52, 52, 54, 54, 57, 57, 59, 59, 60, 31, 31, 31, 32, 32, 36, 36, 40,
        40, 43, 43, 46, 46, 46, 46, 45, 45, 46, 46, 48, 48, 50, 50, 52, 52, 54,
        54, 57, 57, 59, 59, 60, 37, 38, 38, 40, 40, 43, 43, 47, 47, 47, 47, 48,
        48, 47, 47, 46, 46, 46, 46, 47, 47, 49, 49, 50, 50, 52, 52, 55, 55, 56,
        56, 57, 37, 38, 38, 40, 40, 43, 43, 47, 47, 47, 47, 48, 48, 47, 47, 46,
        46, 46, 46, 47, 47, 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 57, 48, 47,
        47, 46, 46, 47, 47, 47, 47, 50, 50, 53, 53, 53, 53, 53, 53, 54, 54, 54,
        54, 55, 55, 56, 56, 58, 58, 60, 60, 61, 61, 63, 48, 47, 47, 46, 46, 47,
        47, 47, 47, 50, 50, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56,
        56, 58, 58, 60, 60, 61, 61, 63, 49, 47, 47, 45, 45, 46, 46, 45, 45, 49,
        49, 53, 53, 56, 56, 58, 58, 59, 59, 61, 61, 62, 62, 64, 64, 65, 65, 67,
        67, 68, 68, 69, 49, 47, 47, 45, 45, 46, 46, 45, 45, 49, 49, 53, 53, 56,
        56, 58, 58, 59, 59, 61, 61, 62, 62, 64, 64, 65, 65, 67, 67, 68, 68, 69,
        52, 50, 50, 48, 48, 47, 47, 47, 47, 50, 50, 54, 54, 57, 57, 61, 61, 64,
        64, 66, 66, 68, 68, 70, 70, 72, 72, 75, 75, 75, 75, 77, 52, 50, 50, 48,
        48, 47, 47, 47, 47, 50, 50, 54, 54, 57, 57, 61, 61, 64, 64, 66, 66, 68,
        68, 70, 70, 72, 72, 75, 75, 75, 75, 77, 57, 54, 54, 52, 52, 51, 51, 50,
        50, 53, 53, 57, 57, 60, 60, 64, 64, 67, 67, 71, 71, 73, 73, 76, 76, 79,
        79, 82, 82, 83, 83, 84, 57, 54, 54, 52, 52, 51, 51, 50, 50, 53, 53, 57,
        57, 60, 60, 64, 64, 67, 67, 71, 71, 73, 73, 76, 76, 79, 79, 82, 82, 83,
        83, 84, 63, 60, 60, 57, 57, 56, 56, 54, 54, 57, 57, 60, 60, 64, 64, 67,
        67, 71, 71, 75, 75, 78, 78, 82, 82, 85, 85, 89, 89, 90, 90, 92, 63, 60,
        60, 57, 57, 56, 56, 54, 54, 57, 57, 60, 60, 64, 64, 67, 67, 71, 71, 75,
        75, 78, 78, 82, 82, 85, 85, 89, 89, 90, 90, 92, 66, 63, 63, 60, 60, 59,
        59, 57, 57, 60, 60, 62, 62, 66, 66, 69, 69, 73, 73, 77, 77, 80, 80, 84,
        84, 88, 88, 92, 92, 93, 93, 95 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 33, 45, 62, 33, 39, 51, 64, 45, 51, 71, 87, 62, 64, 87, 108,
        /* Size 8x8 */
        31, 32, 32, 35, 42, 51, 59, 69, 32, 32, 33, 35, 41, 49, 56, 65, 32, 33,
        35, 38, 43, 49, 56, 64, 35, 35, 38, 48, 54, 59, 66, 73, 42, 41, 43, 54,
        63, 71, 77, 85, 51, 49, 49, 59, 71, 81, 89, 97, 59, 56, 56, 66, 77, 89,
        98, 108, 69, 65, 64, 73, 85, 97, 108, 119,
        /* Size 16x16 */
        32, 31, 31, 31, 32, 34, 35, 38, 41, 45, 48, 54, 59, 65, 71, 80, 31, 32,
        32, 32, 32, 34, 35, 37, 40, 43, 46, 51, 56, 62, 68, 76, 31, 32, 32, 32,
        32, 33, 34, 36, 38, 41, 44, 49, 54, 59, 65, 72, 31, 32, 32, 33, 34, 35,
        36, 38, 40, 42, 45, 50, 54, 59, 64, 71, 32, 32, 32, 34, 35, 37, 38, 39,
        41, 43, 46, 49, 53, 58, 63, 69, 34, 34, 33, 35, 37, 39, 42, 44, 46, 48,
        51, 54, 58, 63, 68, 74, 35, 35, 34, 36, 38, 42, 46, 48, 50, 53, 55, 59,
        62, 67, 72, 78, 38, 37, 36, 38, 39, 44, 48, 51, 54, 57, 59, 63, 67, 71,
        76, 82, 41, 40, 38, 40, 41, 46, 50, 54, 57, 60, 63, 67, 71, 75, 80, 86,
        45, 43, 41, 42, 43, 48, 53, 57, 60, 65, 68, 72, 76, 81, 85, 91, 48, 46,
        44, 45, 46, 51, 55, 59, 63, 68, 71, 76, 80, 85, 90, 96, 54, 51, 49, 50,
        49, 54, 59, 63, 67, 72, 76, 82, 87, 92, 97, 104, 59, 56, 54, 54, 53, 58,
        62, 67, 71, 76, 80, 87, 92, 98, 103, 110, 65, 62, 59, 59, 58, 63, 67,
        71, 75, 81, 85, 92, 98, 105, 111, 118, 71, 68, 65, 64, 63, 68, 72, 76,
        80, 85, 90, 97, 103, 111, 117, 125, 80, 76, 72, 71, 69, 74, 78, 82, 86,
        91, 96, 104, 110, 118, 125, 134,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 34, 34, 35, 36, 38, 39, 41, 44,
        45, 48, 48, 53, 54, 57, 59, 62, 65, 67, 71, 72, 80, 80, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 34, 34, 35, 35, 37, 38, 40, 42, 43, 46, 46, 51,
        52, 55, 56, 59, 62, 64, 68, 69, 76, 76, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 34, 34, 35, 35, 37, 38, 40, 42, 43, 46, 46, 51, 51, 55, 56, 59,
        62, 64, 68, 69, 76, 76, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
        34, 34, 36, 38, 39, 41, 42, 45, 45, 49, 50, 53, 54, 57, 60, 62, 66, 66,
        73, 73, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 36, 37,
        38, 41, 41, 44, 44, 49, 49, 52, 54, 56, 59, 61, 65, 65, 72, 72, 31, 32,
        32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 35, 35, 37, 38, 39, 41, 42, 45,
        45, 49, 49, 52, 54, 56, 59, 61, 64, 65, 72, 72, 31, 32, 32, 32, 32, 33,
        33, 33, 34, 34, 35, 35, 36, 36, 38, 39, 40, 42, 42, 45, 45, 49, 50, 52,
        54, 56, 59, 60, 64, 65, 71, 71, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34,
        35, 35, 36, 37, 38, 39, 40, 42, 43, 45, 45, 49, 49, 52, 54, 56, 59, 60,
        64, 64, 70, 70, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 37, 37, 38, 38,
        39, 40, 41, 42, 43, 46, 46, 49, 49, 52, 53, 55, 58, 59, 63, 63, 69, 69,
        32, 32, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38, 38, 40, 41, 41, 43,
        43, 46, 46, 49, 50, 52, 54, 56, 58, 60, 63, 64, 70, 70, 34, 34, 34, 33,
        33, 34, 35, 35, 37, 37, 39, 39, 42, 42, 44, 45, 46, 47, 48, 51, 51, 54,
        54, 57, 58, 60, 63, 64, 68, 68, 74, 74, 34, 34, 34, 33, 33, 34, 35, 35,
        37, 37, 39, 39, 42, 42, 44, 45, 46, 47, 48, 51, 51, 54, 54, 57, 58, 60,
        63, 64, 68, 68, 74, 74, 35, 35, 35, 34, 34, 35, 36, 36, 38, 38, 42, 42,
        46, 47, 48, 49, 50, 52, 53, 55, 55, 58, 59, 61, 62, 64, 67, 68, 72, 72,
        78, 78, 36, 35, 35, 34, 34, 35, 36, 37, 38, 38, 42, 42, 47, 48, 50, 50,
        52, 54, 54, 57, 57, 59, 60, 62, 64, 66, 68, 69, 73, 73, 79, 79, 38, 37,
        37, 36, 36, 37, 38, 38, 39, 40, 44, 44, 48, 50, 51, 52, 54, 56, 57, 59,
        59, 62, 63, 65, 67, 69, 71, 72, 76, 76, 82, 82, 39, 38, 38, 38, 37, 38,
        39, 39, 40, 41, 45, 45, 49, 50, 52, 54, 55, 58, 58, 61, 61, 64, 65, 67,
        69, 71, 73, 74, 78, 78, 84, 84, 41, 40, 40, 39, 38, 39, 40, 40, 41, 41,
        46, 46, 50, 52, 54, 55, 57, 60, 60, 63, 63, 67, 67, 70, 71, 73, 75, 77,
        80, 81, 86, 86, 44, 42, 42, 41, 41, 41, 42, 42, 42, 43, 47, 47, 52, 54,
        56, 58, 60, 63, 64, 67, 67, 71, 71, 74, 75, 77, 79, 81, 84, 85, 90, 90,
        45, 43, 43, 42, 41, 42, 42, 43, 43, 43, 48, 48, 53, 54, 57, 58, 60, 64,
        65, 68, 68, 72, 72, 75, 76, 78, 81, 82, 85, 86, 91, 91, 48, 46, 46, 45,
        44, 45, 45, 45, 46, 46, 51, 51, 55, 57, 59, 61, 63, 67, 68, 71, 71, 75,
        76, 79, 80, 83, 85, 87, 90, 91, 96, 96, 48, 46, 46, 45, 44, 45, 45, 45,
        46, 46, 51, 51, 55, 57, 59, 61, 63, 67, 68, 71, 71, 75, 76, 79, 80, 83,
        85, 87, 90, 91, 96, 96, 53, 51, 51, 49, 49, 49, 49, 49, 49, 49, 54, 54,
        58, 59, 62, 64, 67, 71, 72, 75, 75, 81, 81, 85, 86, 89, 91, 93, 97, 97,
        103, 103, 54, 52, 51, 50, 49, 49, 50, 49, 49, 50, 54, 54, 59, 60, 63,
        65, 67, 71, 72, 76, 76, 81, 82, 85, 87, 89, 92, 94, 97, 98, 104, 104,
        57, 55, 55, 53, 52, 52, 52, 52, 52, 52, 57, 57, 61, 62, 65, 67, 70, 74,
        75, 79, 79, 85, 85, 89, 90, 93, 96, 98, 102, 102, 108, 108, 59, 56, 56,
        54, 54, 54, 54, 54, 53, 54, 58, 58, 62, 64, 67, 69, 71, 75, 76, 80, 80,
        86, 87, 90, 92, 95, 98, 99, 103, 104, 110, 110, 62, 59, 59, 57, 56, 56,
        56, 56, 55, 56, 60, 60, 64, 66, 69, 71, 73, 77, 78, 83, 83, 89, 89, 93,
        95, 98, 101, 103, 107, 108, 114, 114, 65, 62, 62, 60, 59, 59, 59, 59,
        58, 58, 63, 63, 67, 68, 71, 73, 75, 79, 81, 85, 85, 91, 92, 96, 98, 101,
        105, 106, 111, 111, 118, 118, 67, 64, 64, 62, 61, 61, 60, 60, 59, 60,
        64, 64, 68, 69, 72, 74, 77, 81, 82, 87, 87, 93, 94, 98, 99, 103, 106,
        108, 113, 113, 120, 120, 71, 68, 68, 66, 65, 64, 64, 64, 63, 63, 68, 68,
        72, 73, 76, 78, 80, 84, 85, 90, 90, 97, 97, 102, 103, 107, 111, 113,
        117, 118, 125, 125, 72, 69, 69, 66, 65, 65, 65, 64, 63, 64, 68, 68, 72,
        73, 76, 78, 81, 85, 86, 91, 91, 97, 98, 102, 104, 108, 111, 113, 118,
        119, 126, 126, 80, 76, 76, 73, 72, 72, 71, 70, 69, 70, 74, 74, 78, 79,
        82, 84, 86, 90, 91, 96, 96, 103, 104, 108, 110, 114, 118, 120, 125, 126,
        134, 134, 80, 76, 76, 73, 72, 72, 71, 70, 69, 70, 74, 74, 78, 79, 82,
        84, 86, 90, 91, 96, 96, 103, 104, 108, 110, 114, 118, 120, 125, 126,
        134, 134,
        /* Size 4x8 */
        32, 34, 43, 62, 32, 34, 42, 59, 33, 37, 44, 58, 35, 43, 54, 68, 41, 48,
        64, 79, 49, 54, 71, 91, 57, 60, 78, 101, 66, 68, 86, 111,
        /* Size 8x4 */
        32, 32, 33, 35, 41, 49, 57, 66, 34, 34, 37, 43, 48, 54, 60, 68, 43, 42,
        44, 54, 64, 71, 78, 86, 62, 59, 58, 68, 79, 91, 101, 111,
        /* Size 8x16 */
        32, 31, 32, 36, 44, 53, 62, 73, 31, 32, 32, 35, 42, 51, 59, 69, 31, 32,
        33, 34, 41, 49, 57, 66, 32, 32, 34, 36, 42, 50, 57, 65, 32, 33, 35, 38,
        42, 49, 56, 64, 34, 34, 37, 42, 48, 54, 61, 69, 35, 34, 38, 47, 52, 59,
        65, 73, 38, 36, 40, 49, 56, 63, 69, 77, 41, 39, 41, 51, 60, 67, 74, 81,
        44, 42, 43, 54, 64, 72, 79, 86, 48, 45, 46, 56, 67, 76, 83, 91, 53, 49,
        50, 60, 71, 82, 90, 99, 58, 54, 54, 63, 75, 87, 95, 105, 65, 60, 58, 68,
        79, 92, 102, 112, 71, 65, 63, 73, 84, 97, 108, 119, 79, 72, 70, 79, 90,
        104, 115, 127,
        /* Size 16x8 */
        32, 31, 31, 32, 32, 34, 35, 38, 41, 44, 48, 53, 58, 65, 71, 79, 31, 32,
        32, 32, 33, 34, 34, 36, 39, 42, 45, 49, 54, 60, 65, 72, 32, 32, 33, 34,
        35, 37, 38, 40, 41, 43, 46, 50, 54, 58, 63, 70, 36, 35, 34, 36, 38, 42,
        47, 49, 51, 54, 56, 60, 63, 68, 73, 79, 44, 42, 41, 42, 42, 48, 52, 56,
        60, 64, 67, 71, 75, 79, 84, 90, 53, 51, 49, 50, 49, 54, 59, 63, 67, 72,
        76, 82, 87, 92, 97, 104, 62, 59, 57, 57, 56, 61, 65, 69, 74, 79, 83, 90,
        95, 102, 108, 115, 73, 69, 66, 65, 64, 69, 73, 77, 81, 86, 91, 99, 105,
        112, 119, 127,
        /* Size 16x32 */
        32, 31, 31, 32, 32, 34, 36, 38, 44, 44, 53, 53, 62, 65, 73, 79, 31, 32,
        32, 32, 32, 34, 35, 37, 42, 43, 51, 51, 60, 62, 70, 75, 31, 32, 32, 32,
        32, 34, 35, 37, 42, 43, 51, 51, 59, 62, 69, 75, 31, 32, 32, 32, 32, 33,
        35, 36, 41, 42, 50, 50, 58, 60, 67, 73, 31, 32, 32, 32, 33, 33, 34, 36,
        41, 41, 49, 49, 57, 59, 66, 72, 31, 32, 32, 33, 33, 34, 35, 37, 41, 42,
        49, 49, 57, 59, 66, 71, 32, 32, 32, 33, 34, 35, 36, 38, 42, 43, 50, 50,
        57, 59, 65, 71, 32, 32, 32, 34, 34, 35, 37, 38, 42, 43, 49, 49, 56, 59,
        65, 70, 32, 32, 33, 34, 35, 37, 38, 39, 42, 43, 49, 49, 56, 58, 64, 69,
        32, 33, 33, 34, 35, 37, 39, 40, 43, 44, 50, 50, 56, 58, 64, 69, 34, 34,
        34, 36, 37, 39, 42, 44, 48, 48, 54, 54, 61, 63, 69, 73, 34, 34, 34, 36,
        37, 39, 42, 44, 48, 48, 54, 54, 61, 63, 69, 73, 35, 34, 34, 37, 38, 42,
        47, 48, 52, 53, 59, 59, 65, 67, 73, 77, 36, 35, 34, 37, 38, 43, 48, 49,
        54, 54, 60, 60, 66, 68, 74, 78, 38, 36, 36, 38, 40, 44, 49, 51, 56, 57,
        63, 63, 69, 71, 77, 81, 39, 38, 37, 40, 40, 45, 50, 52, 58, 58, 65, 65,
        71, 73, 79, 84, 41, 39, 39, 41, 41, 46, 51, 54, 60, 60, 67, 67, 74, 76,
        81, 86, 44, 41, 41, 42, 43, 48, 53, 56, 63, 64, 71, 71, 78, 79, 85, 90,
        44, 42, 42, 43, 43, 48, 54, 56, 64, 64, 72, 72, 79, 81, 86, 91, 48, 45,
        45, 46, 46, 51, 56, 59, 67, 67, 76, 76, 83, 85, 91, 96, 48, 45, 45, 46,
        46, 51, 56, 59, 67, 67, 76, 76, 83, 85, 91, 96, 53, 49, 49, 49, 49, 54,
        59, 62, 71, 71, 81, 81, 89, 91, 98, 103, 53, 50, 49, 50, 50, 54, 60, 63,
        71, 72, 82, 82, 90, 92, 99, 103, 57, 53, 52, 52, 52, 57, 62, 65, 74, 75,
        85, 85, 94, 96, 103, 108, 58, 54, 54, 54, 54, 58, 63, 67, 75, 76, 87,
        87, 95, 98, 105, 110, 61, 57, 57, 56, 56, 60, 66, 69, 77, 78, 89, 89,
        98, 101, 108, 114, 65, 60, 60, 59, 58, 63, 68, 71, 79, 80, 92, 92, 102,
        105, 112, 118, 67, 62, 61, 60, 60, 64, 69, 72, 81, 82, 94, 94, 103, 106,
        114, 120, 71, 66, 65, 64, 63, 68, 73, 76, 84, 85, 97, 97, 108, 111, 119,
        125, 72, 66, 66, 64, 64, 68, 73, 76, 85, 86, 98, 98, 108, 111, 119, 125,
        79, 73, 72, 71, 70, 74, 79, 82, 90, 91, 104, 104, 115, 118, 127, 133,
        79, 73, 72, 71, 70, 74, 79, 82, 90, 91, 104, 104, 115, 118, 127, 133,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 35, 36, 38, 39, 41, 44,
        44, 48, 48, 53, 53, 57, 58, 61, 65, 67, 71, 72, 79, 79, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 36, 38, 39, 41, 42, 45, 45, 49,
        50, 53, 54, 57, 60, 62, 66, 66, 73, 73, 31, 32, 32, 32, 32, 32, 32, 32,
        33, 33, 34, 34, 34, 34, 36, 37, 39, 41, 42, 45, 45, 49, 49, 52, 54, 57,
        60, 61, 65, 66, 72, 72, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 36, 36,
        37, 37, 38, 40, 41, 42, 43, 46, 46, 49, 50, 52, 54, 56, 59, 60, 64, 64,
        71, 71, 32, 32, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38, 38, 40, 40,
        41, 43, 43, 46, 46, 49, 50, 52, 54, 56, 58, 60, 63, 64, 70, 70, 34, 34,
        34, 33, 33, 34, 35, 35, 37, 37, 39, 39, 42, 43, 44, 45, 46, 48, 48, 51,
        51, 54, 54, 57, 58, 60, 63, 64, 68, 68, 74, 74, 36, 35, 35, 35, 34, 35,
        36, 37, 38, 39, 42, 42, 47, 48, 49, 50, 51, 53, 54, 56, 56, 59, 60, 62,
        63, 66, 68, 69, 73, 73, 79, 79, 38, 37, 37, 36, 36, 37, 38, 38, 39, 40,
        44, 44, 48, 49, 51, 52, 54, 56, 56, 59, 59, 62, 63, 65, 67, 69, 71, 72,
        76, 76, 82, 82, 44, 42, 42, 41, 41, 41, 42, 42, 42, 43, 48, 48, 52, 54,
        56, 58, 60, 63, 64, 67, 67, 71, 71, 74, 75, 77, 79, 81, 84, 85, 90, 90,
        44, 43, 43, 42, 41, 42, 43, 43, 43, 44, 48, 48, 53, 54, 57, 58, 60, 64,
        64, 67, 67, 71, 72, 75, 76, 78, 80, 82, 85, 86, 91, 91, 53, 51, 51, 50,
        49, 49, 50, 49, 49, 50, 54, 54, 59, 60, 63, 65, 67, 71, 72, 76, 76, 81,
        82, 85, 87, 89, 92, 94, 97, 98, 104, 104, 53, 51, 51, 50, 49, 49, 50,
        49, 49, 50, 54, 54, 59, 60, 63, 65, 67, 71, 72, 76, 76, 81, 82, 85, 87,
        89, 92, 94, 97, 98, 104, 104, 62, 60, 59, 58, 57, 57, 57, 56, 56, 56,
        61, 61, 65, 66, 69, 71, 74, 78, 79, 83, 83, 89, 90, 94, 95, 98, 102,
        103, 108, 108, 115, 115, 65, 62, 62, 60, 59, 59, 59, 59, 58, 58, 63, 63,
        67, 68, 71, 73, 76, 79, 81, 85, 85, 91, 92, 96, 98, 101, 105, 106, 111,
        111, 118, 118, 73, 70, 69, 67, 66, 66, 65, 65, 64, 64, 69, 69, 73, 74,
        77, 79, 81, 85, 86, 91, 91, 98, 99, 103, 105, 108, 112, 114, 119, 119,
        127, 127, 79, 75, 75, 73, 72, 71, 71, 70, 69, 69, 73, 73, 77, 78, 81,
        84, 86, 90, 91, 96, 96, 103, 103, 108, 110, 114, 118, 120, 125, 125,
        133, 133 },
      { /* Chroma */
        /* Size 4x4 */
        31, 42, 47, 53, 42, 48, 50, 54, 47, 50, 61, 67, 53, 54, 67, 78,
        /* Size 8x8 */
        31, 32, 38, 48, 47, 50, 53, 57, 32, 35, 42, 47, 45, 47, 50, 54, 38, 42,
        47, 48, 45, 47, 49, 52, 48, 47, 48, 53, 53, 54, 56, 58, 47, 45, 45, 53,
        58, 61, 63, 65, 50, 47, 47, 54, 61, 66, 69, 72, 53, 50, 49, 56, 63, 69,
        73, 77, 57, 54, 52, 58, 65, 72, 77, 82,
        /* Size 16x16 */
        32, 31, 30, 33, 36, 41, 47, 49, 49, 49, 50, 52, 54, 57, 60, 63, 31, 31,
        31, 34, 38, 42, 46, 47, 47, 47, 48, 50, 52, 54, 57, 60, 30, 31, 32, 35,
        40, 42, 45, 46, 45, 45, 46, 47, 49, 52, 54, 57, 33, 34, 35, 39, 43, 45,
        47, 46, 46, 45, 46, 47, 49, 51, 53, 56, 36, 38, 40, 43, 47, 47, 47, 47,
        46, 45, 46, 47, 48, 50, 52, 54, 41, 42, 42, 45, 47, 48, 50, 50, 49, 49,
        50, 50, 52, 53, 55, 57, 47, 46, 45, 47, 47, 50, 52, 52, 52, 52, 53, 53,
        55, 56, 58, 60, 49, 47, 46, 46, 47, 50, 52, 53, 54, 55, 55, 56, 57, 58,
        60, 62, 49, 47, 45, 46, 46, 49, 52, 54, 55, 57, 58, 59, 60, 61, 63, 65,
        49, 47, 45, 45, 45, 49, 52, 55, 57, 59, 60, 61, 63, 64, 66, 68, 50, 48,
        46, 46, 46, 50, 53, 55, 58, 60, 61, 63, 65, 67, 68, 71, 52, 50, 47, 47,
        47, 50, 53, 56, 59, 61, 63, 66, 68, 70, 72, 75, 54, 52, 49, 49, 48, 52,
        55, 57, 60, 63, 65, 68, 71, 73, 75, 78, 57, 54, 52, 51, 50, 53, 56, 58,
        61, 64, 67, 70, 73, 76, 79, 82, 60, 57, 54, 53, 52, 55, 58, 60, 63, 66,
        68, 72, 75, 79, 82, 85, 63, 60, 57, 56, 54, 57, 60, 62, 65, 68, 71, 75,
        78, 82, 85, 89,
        /* Size 32x32 */
        32, 31, 31, 30, 30, 32, 33, 34, 36, 37, 41, 41, 47, 49, 49, 48, 49, 49,
        49, 50, 50, 52, 52, 54, 54, 56, 57, 58, 60, 60, 63, 63, 31, 31, 31, 31,
        31, 32, 34, 35, 38, 38, 42, 42, 46, 48, 47, 47, 47, 47, 47, 48, 48, 50,
        50, 51, 52, 53, 54, 55, 57, 57, 60, 60, 31, 31, 31, 31, 31, 33, 34, 35,
        38, 39, 42, 42, 46, 47, 47, 47, 47, 47, 47, 48, 48, 49, 50, 51, 52, 53,
        54, 55, 57, 57, 60, 60, 30, 31, 31, 31, 31, 33, 35, 36, 39, 40, 42, 42,
        46, 47, 46, 46, 46, 45, 46, 47, 47, 48, 48, 50, 50, 51, 52, 53, 55, 55,
        58, 58, 30, 31, 31, 31, 32, 33, 35, 36, 40, 40, 42, 42, 45, 46, 46, 45,
        45, 45, 45, 46, 46, 47, 47, 49, 49, 51, 52, 52, 54, 54, 57, 57, 32, 32,
        33, 33, 33, 35, 37, 38, 41, 42, 43, 43, 46, 47, 46, 46, 45, 45, 45, 46,
        46, 47, 47, 49, 49, 50, 51, 52, 54, 54, 57, 57, 33, 34, 34, 35, 35, 37,
        39, 40, 43, 43, 45, 45, 47, 47, 46, 46, 46, 45, 45, 46, 46, 47, 47, 49,
        49, 50, 51, 52, 53, 54, 56, 56, 34, 35, 35, 36, 36, 38, 40, 41, 44, 44,
        45, 45, 47, 47, 47, 46, 46, 45, 45, 46, 46, 47, 47, 48, 49, 50, 51, 51,
        53, 53, 55, 55, 36, 38, 38, 39, 40, 41, 43, 44, 47, 47, 47, 47, 47, 48,
        47, 46, 46, 45, 45, 46, 46, 46, 47, 48, 48, 49, 50, 50, 52, 52, 54, 54,
        37, 38, 39, 40, 40, 42, 43, 44, 47, 47, 47, 47, 48, 48, 47, 47, 46, 45,
        46, 46, 46, 47, 47, 48, 48, 49, 50, 51, 52, 52, 55, 55, 41, 42, 42, 42,
        42, 43, 45, 45, 47, 47, 48, 48, 50, 50, 50, 49, 49, 49, 49, 50, 50, 50,
        50, 51, 52, 52, 53, 54, 55, 55, 57, 57, 41, 42, 42, 42, 42, 43, 45, 45,
        47, 47, 48, 48, 50, 50, 50, 49, 49, 49, 49, 50, 50, 50, 50, 51, 52, 52,
        53, 54, 55, 55, 57, 57, 47, 46, 46, 46, 45, 46, 47, 47, 47, 48, 50, 50,
        52, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 54, 55, 55, 56, 56, 58, 58,
        60, 60, 49, 48, 47, 47, 46, 47, 47, 47, 48, 48, 50, 50, 52, 53, 53, 53,
        53, 53, 53, 54, 54, 54, 54, 55, 55, 56, 56, 57, 58, 58, 60, 60, 49, 47,
        47, 46, 46, 46, 46, 47, 47, 47, 50, 50, 52, 53, 53, 54, 54, 55, 55, 55,
        55, 56, 56, 57, 57, 58, 58, 59, 60, 60, 62, 62, 48, 47, 47, 46, 45, 46,
        46, 46, 46, 47, 49, 49, 52, 53, 54, 54, 55, 55, 56, 56, 56, 57, 57, 58,
        58, 59, 60, 60, 61, 62, 63, 63, 49, 47, 47, 46, 45, 45, 46, 46, 46, 46,
        49, 49, 52, 53, 54, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62,
        63, 63, 65, 65, 49, 47, 47, 45, 45, 45, 45, 45, 45, 45, 49, 49, 52, 53,
        55, 55, 57, 58, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 65, 65, 67, 67,
        49, 47, 47, 46, 45, 45, 45, 45, 45, 46, 49, 49, 52, 53, 55, 56, 57, 59,
        59, 60, 60, 61, 61, 62, 63, 63, 64, 65, 66, 66, 68, 68, 50, 48, 48, 47,
        46, 46, 46, 46, 46, 46, 50, 50, 53, 54, 55, 56, 58, 60, 60, 61, 61, 63,
        63, 65, 65, 66, 67, 67, 68, 69, 71, 71, 50, 48, 48, 47, 46, 46, 46, 46,
        46, 46, 50, 50, 53, 54, 55, 56, 58, 60, 60, 61, 61, 63, 63, 65, 65, 66,
        67, 67, 68, 69, 71, 71, 52, 50, 49, 48, 47, 47, 47, 47, 46, 47, 50, 50,
        53, 54, 56, 57, 59, 61, 61, 63, 63, 66, 66, 67, 68, 69, 70, 71, 72, 72,
        74, 74, 52, 50, 50, 48, 47, 47, 47, 47, 47, 47, 50, 50, 53, 54, 56, 57,
        59, 61, 61, 63, 63, 66, 66, 68, 68, 69, 70, 71, 72, 73, 75, 75, 54, 51,
        51, 50, 49, 49, 49, 48, 48, 48, 51, 51, 54, 55, 57, 58, 60, 62, 62, 65,
        65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 77, 77, 54, 52, 52, 50, 49, 49,
        49, 49, 48, 48, 52, 52, 55, 55, 57, 58, 60, 62, 63, 65, 65, 68, 68, 70,
        71, 72, 73, 74, 75, 76, 78, 78, 56, 53, 53, 51, 51, 50, 50, 50, 49, 49,
        52, 52, 55, 56, 58, 59, 61, 63, 63, 66, 66, 69, 69, 71, 72, 73, 75, 75,
        77, 77, 80, 80, 57, 54, 54, 52, 52, 51, 51, 51, 50, 50, 53, 53, 56, 56,
        58, 60, 61, 63, 64, 67, 67, 70, 70, 72, 73, 75, 76, 77, 79, 79, 82, 82,
        58, 55, 55, 53, 52, 52, 52, 51, 50, 51, 54, 54, 56, 57, 59, 60, 62, 64,
        65, 67, 67, 71, 71, 73, 74, 75, 77, 78, 80, 80, 83, 83, 60, 57, 57, 55,
        54, 54, 53, 53, 52, 52, 55, 55, 58, 58, 60, 61, 63, 65, 66, 68, 68, 72,
        72, 74, 75, 77, 79, 80, 82, 82, 85, 85, 60, 57, 57, 55, 54, 54, 54, 53,
        52, 52, 55, 55, 58, 58, 60, 62, 63, 65, 66, 69, 69, 72, 73, 75, 76, 77,
        79, 80, 82, 82, 85, 85, 63, 60, 60, 58, 57, 57, 56, 55, 54, 55, 57, 57,
        60, 60, 62, 63, 65, 67, 68, 71, 71, 74, 75, 77, 78, 80, 82, 83, 85, 85,
        89, 89, 63, 60, 60, 58, 57, 57, 56, 55, 54, 55, 57, 57, 60, 60, 62, 63,
        65, 67, 68, 71, 71, 74, 75, 77, 78, 80, 82, 83, 85, 85, 89, 89,
        /* Size 4x8 */
        31, 42, 47, 54, 33, 44, 45, 51, 40, 47, 46, 50, 47, 50, 54, 57, 45, 49,
        59, 64, 48, 50, 61, 70, 51, 52, 63, 75, 55, 55, 66, 79,
        /* Size 8x4 */
        31, 33, 40, 47, 45, 48, 51, 55, 42, 44, 47, 50, 49, 50, 52, 55, 47, 45,
        46, 54, 59, 61, 63, 66, 54, 51, 50, 57, 64, 70, 75, 79,
        /* Size 8x16 */
        32, 31, 37, 48, 49, 52, 56, 61, 31, 31, 38, 47, 47, 50, 53, 57, 30, 32,
        40, 46, 45, 48, 51, 55, 33, 36, 43, 47, 46, 47, 50, 54, 37, 40, 47, 47,
        45, 47, 49, 52, 42, 43, 47, 50, 49, 50, 53, 56, 47, 46, 48, 52, 53, 53,
        55, 58, 48, 46, 47, 53, 55, 56, 58, 61, 48, 45, 46, 53, 57, 59, 61, 63,
        49, 45, 46, 53, 58, 62, 64, 66, 50, 46, 46, 54, 59, 64, 66, 69, 52, 48,
        47, 54, 61, 66, 70, 73, 54, 50, 49, 55, 62, 68, 72, 76, 57, 52, 50, 56,
        64, 70, 75, 79, 60, 54, 52, 58, 65, 72, 77, 82, 63, 57, 55, 60, 67, 75,
        80, 86,
        /* Size 16x8 */
        32, 31, 30, 33, 37, 42, 47, 48, 48, 49, 50, 52, 54, 57, 60, 63, 31, 31,
        32, 36, 40, 43, 46, 46, 45, 45, 46, 48, 50, 52, 54, 57, 37, 38, 40, 43,
        47, 47, 48, 47, 46, 46, 46, 47, 49, 50, 52, 55, 48, 47, 46, 47, 47, 50,
        52, 53, 53, 53, 54, 54, 55, 56, 58, 60, 49, 47, 45, 46, 45, 49, 53, 55,
        57, 58, 59, 61, 62, 64, 65, 67, 52, 50, 48, 47, 47, 50, 53, 56, 59, 62,
        64, 66, 68, 70, 72, 75, 56, 53, 51, 50, 49, 53, 55, 58, 61, 64, 66, 70,
        72, 75, 77, 80, 61, 57, 55, 54, 52, 56, 58, 61, 63, 66, 69, 73, 76, 79,
        82, 86,
        /* Size 16x32 */
        32, 31, 31, 35, 37, 42, 48, 48, 49, 49, 52, 52, 56, 57, 61, 63, 31, 31,
        31, 36, 38, 42, 47, 47, 47, 47, 50, 50, 54, 54, 58, 60, 31, 31, 31, 36,
        38, 42, 47, 47, 47, 47, 50, 50, 53, 54, 57, 60, 30, 32, 32, 37, 39, 42,
        46, 46, 46, 46, 48, 48, 52, 52, 56, 58, 30, 32, 32, 37, 40, 42, 46, 46,
        45, 45, 48, 48, 51, 52, 55, 57, 32, 33, 34, 39, 41, 44, 46, 46, 45, 45,
        48, 48, 51, 51, 54, 57, 33, 35, 36, 40, 43, 45, 47, 46, 46, 46, 47, 47,
        50, 51, 54, 56, 34, 37, 37, 42, 44, 45, 47, 47, 45, 46, 47, 47, 50, 51,
        53, 55, 37, 40, 40, 45, 47, 47, 47, 47, 45, 46, 47, 47, 49, 50, 52, 54,
        37, 40, 40, 45, 47, 47, 48, 47, 46, 46, 47, 47, 49, 50, 53, 55, 42, 43,
        43, 46, 47, 48, 50, 50, 49, 49, 50, 50, 53, 53, 56, 57, 42, 43, 43, 46,
        47, 48, 50, 50, 49, 49, 50, 50, 53, 53, 56, 57, 47, 46, 46, 47, 48, 50,
        52, 52, 53, 53, 53, 53, 55, 56, 58, 60, 49, 47, 46, 47, 48, 50, 53, 53,
        53, 54, 54, 54, 56, 57, 59, 60, 48, 46, 46, 47, 47, 50, 53, 53, 55, 55,
        56, 56, 58, 58, 61, 62, 48, 46, 46, 46, 47, 50, 53, 54, 56, 56, 57, 57,
        59, 60, 62, 64, 48, 46, 45, 46, 46, 49, 53, 54, 57, 57, 59, 59, 61, 61,
        63, 65, 49, 45, 45, 45, 46, 49, 53, 55, 58, 59, 61, 61, 63, 64, 66, 67,
        49, 46, 45, 46, 46, 49, 53, 55, 58, 59, 62, 62, 64, 64, 66, 68, 50, 47,
        46, 46, 46, 50, 54, 55, 59, 60, 64, 64, 66, 67, 69, 71, 50, 47, 46, 46,
        46, 50, 54, 55, 59, 60, 64, 64, 66, 67, 69, 71, 52, 48, 48, 47, 47, 50,
        54, 56, 61, 61, 66, 66, 69, 70, 72, 74, 52, 48, 48, 47, 47, 50, 54, 56,
        61, 61, 66, 66, 70, 71, 73, 75, 53, 50, 49, 48, 48, 51, 55, 57, 62, 62,
        68, 68, 71, 72, 75, 77, 54, 50, 50, 49, 49, 52, 55, 57, 62, 63, 68, 68,
        72, 73, 76, 78, 55, 51, 51, 50, 49, 52, 56, 58, 63, 63, 69, 69, 74, 75,
        78, 80, 57, 52, 52, 51, 50, 53, 56, 58, 64, 64, 70, 70, 75, 76, 79, 82,
        58, 53, 53, 51, 51, 54, 57, 59, 64, 65, 71, 71, 76, 77, 80, 83, 60, 55,
        54, 53, 52, 55, 58, 60, 65, 66, 72, 72, 77, 79, 82, 85, 60, 55, 55, 53,
        53, 55, 59, 60, 65, 66, 73, 73, 78, 79, 83, 85, 63, 58, 57, 56, 55, 58,
        60, 62, 67, 68, 75, 75, 80, 82, 86, 89, 63, 58, 57, 56, 55, 58, 60, 62,
        67, 68, 75, 75, 80, 82, 86, 89,
        /* Size 32x16 */
        32, 31, 31, 30, 30, 32, 33, 34, 37, 37, 42, 42, 47, 49, 48, 48, 48, 49,
        49, 50, 50, 52, 52, 53, 54, 55, 57, 58, 60, 60, 63, 63, 31, 31, 31, 32,
        32, 33, 35, 37, 40, 40, 43, 43, 46, 47, 46, 46, 46, 45, 46, 47, 47, 48,
        48, 50, 50, 51, 52, 53, 55, 55, 58, 58, 31, 31, 31, 32, 32, 34, 36, 37,
        40, 40, 43, 43, 46, 46, 46, 46, 45, 45, 45, 46, 46, 48, 48, 49, 50, 51,
        52, 53, 54, 55, 57, 57, 35, 36, 36, 37, 37, 39, 40, 42, 45, 45, 46, 46,
        47, 47, 47, 46, 46, 45, 46, 46, 46, 47, 47, 48, 49, 50, 51, 51, 53, 53,
        56, 56, 37, 38, 38, 39, 40, 41, 43, 44, 47, 47, 47, 47, 48, 48, 47, 47,
        46, 46, 46, 46, 46, 47, 47, 48, 49, 49, 50, 51, 52, 53, 55, 55, 42, 42,
        42, 42, 42, 44, 45, 45, 47, 47, 48, 48, 50, 50, 50, 50, 49, 49, 49, 50,
        50, 50, 50, 51, 52, 52, 53, 54, 55, 55, 58, 58, 48, 47, 47, 46, 46, 46,
        47, 47, 47, 48, 50, 50, 52, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55,
        55, 56, 56, 57, 58, 59, 60, 60, 48, 47, 47, 46, 46, 46, 46, 47, 47, 47,
        50, 50, 52, 53, 53, 54, 54, 55, 55, 55, 55, 56, 56, 57, 57, 58, 58, 59,
        60, 60, 62, 62, 49, 47, 47, 46, 45, 45, 46, 45, 45, 46, 49, 49, 53, 53,
        55, 56, 57, 58, 58, 59, 59, 61, 61, 62, 62, 63, 64, 64, 65, 65, 67, 67,
        49, 47, 47, 46, 45, 45, 46, 46, 46, 46, 49, 49, 53, 54, 55, 56, 57, 59,
        59, 60, 60, 61, 61, 62, 63, 63, 64, 65, 66, 66, 68, 68, 52, 50, 50, 48,
        48, 48, 47, 47, 47, 47, 50, 50, 53, 54, 56, 57, 59, 61, 62, 64, 64, 66,
        66, 68, 68, 69, 70, 71, 72, 73, 75, 75, 52, 50, 50, 48, 48, 48, 47, 47,
        47, 47, 50, 50, 53, 54, 56, 57, 59, 61, 62, 64, 64, 66, 66, 68, 68, 69,
        70, 71, 72, 73, 75, 75, 56, 54, 53, 52, 51, 51, 50, 50, 49, 49, 53, 53,
        55, 56, 58, 59, 61, 63, 64, 66, 66, 69, 70, 71, 72, 74, 75, 76, 77, 78,
        80, 80, 57, 54, 54, 52, 52, 51, 51, 51, 50, 50, 53, 53, 56, 57, 58, 60,
        61, 64, 64, 67, 67, 70, 71, 72, 73, 75, 76, 77, 79, 79, 82, 82, 61, 58,
        57, 56, 55, 54, 54, 53, 52, 53, 56, 56, 58, 59, 61, 62, 63, 66, 66, 69,
        69, 72, 73, 75, 76, 78, 79, 80, 82, 83, 86, 86, 63, 60, 60, 58, 57, 57,
        56, 55, 54, 55, 57, 57, 60, 60, 62, 64, 65, 67, 68, 71, 71, 74, 75, 77,
        78, 80, 82, 83, 85, 85, 89, 89 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 33, 42, 55, 33, 38, 46, 57, 42, 46, 63, 75, 55, 57, 75, 92,
        /* Size 8x8 */
        31, 32, 32, 34, 38, 46, 52, 63, 32, 32, 32, 34, 37, 44, 49, 59, 32, 32,
        35, 37, 40, 45, 49, 58, 34, 34, 37, 42, 47, 52, 56, 65, 38, 37, 40, 47,
        54, 60, 65, 73, 46, 44, 45, 52, 60, 69, 75, 84, 52, 49, 49, 56, 65, 75,
        82, 92, 63, 59, 58, 65, 73, 84, 92, 105,
        /* Size 16x16 */
        32, 31, 31, 31, 32, 32, 34, 36, 38, 41, 44, 48, 54, 58, 61, 65, 31, 32,
        32, 32, 32, 32, 34, 35, 38, 40, 42, 46, 51, 55, 58, 62, 31, 32, 32, 32,
        32, 32, 33, 34, 37, 38, 41, 44, 49, 53, 56, 59, 31, 32, 32, 33, 33, 33,
        35, 36, 38, 40, 42, 45, 49, 53, 56, 59, 32, 32, 32, 33, 34, 34, 36, 37,
        39, 40, 42, 45, 49, 53, 55, 59, 32, 32, 32, 33, 34, 35, 37, 38, 40, 41,
        42, 46, 49, 52, 55, 58, 34, 34, 33, 35, 36, 37, 39, 42, 44, 46, 47, 51,
        54, 57, 60, 63, 36, 35, 34, 36, 37, 38, 42, 48, 50, 52, 54, 57, 60, 63,
        65, 68, 38, 38, 37, 38, 39, 40, 44, 50, 52, 54, 57, 60, 64, 67, 69, 72,
        41, 40, 38, 40, 40, 41, 46, 52, 54, 57, 60, 63, 67, 70, 73, 75, 44, 42,
        41, 42, 42, 42, 47, 54, 57, 60, 63, 67, 71, 74, 77, 79, 48, 46, 44, 45,
        45, 46, 51, 57, 60, 63, 67, 71, 76, 79, 82, 85, 54, 51, 49, 49, 49, 49,
        54, 60, 64, 67, 71, 76, 82, 86, 89, 92, 58, 55, 53, 53, 53, 52, 57, 63,
        67, 70, 74, 79, 86, 90, 93, 97, 61, 58, 56, 56, 55, 55, 60, 65, 69, 73,
        77, 82, 89, 93, 97, 101, 65, 62, 59, 59, 59, 58, 63, 68, 72, 75, 79, 85,
        92, 97, 101, 105,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 34, 36, 36, 38, 39,
        41, 44, 44, 47, 48, 50, 54, 54, 58, 59, 61, 65, 65, 70, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 38, 38, 40, 42, 42, 46,
        47, 49, 52, 52, 56, 57, 59, 63, 63, 67, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 34, 34, 35, 35, 38, 38, 40, 42, 42, 45, 46, 48, 51, 51,
        55, 56, 58, 62, 62, 67, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        34, 34, 35, 35, 37, 38, 39, 42, 42, 45, 45, 47, 50, 50, 54, 55, 57, 61,
        61, 65, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34,
        37, 37, 38, 41, 41, 44, 44, 46, 49, 49, 53, 54, 56, 59, 59, 64, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 37, 37, 38, 41,
        41, 44, 44, 46, 49, 49, 53, 54, 56, 59, 59, 64, 31, 32, 32, 32, 32, 32,
        33, 33, 33, 33, 33, 34, 35, 35, 36, 36, 38, 39, 40, 42, 42, 44, 45, 47,
        49, 49, 53, 54, 56, 59, 59, 63, 31, 32, 32, 32, 32, 32, 33, 33, 33, 34,
        34, 35, 35, 36, 36, 36, 38, 39, 40, 42, 42, 45, 45, 47, 50, 50, 53, 54,
        56, 59, 59, 63, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 35, 36, 36,
        37, 37, 39, 39, 40, 42, 42, 45, 45, 47, 49, 49, 53, 54, 55, 59, 59, 63,
        32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 36, 37, 37, 38, 38, 40, 40,
        41, 42, 42, 45, 46, 47, 49, 49, 52, 53, 55, 58, 58, 62, 32, 32, 32, 32,
        32, 32, 33, 34, 34, 35, 35, 36, 37, 37, 38, 38, 40, 40, 41, 42, 42, 45,
        46, 47, 49, 49, 52, 53, 55, 58, 58, 62, 33, 33, 33, 33, 33, 33, 34, 35,
        35, 36, 36, 38, 39, 40, 42, 42, 43, 44, 45, 46, 46, 49, 50, 51, 53, 53,
        56, 57, 59, 62, 62, 66, 34, 34, 34, 34, 33, 33, 35, 35, 36, 37, 37, 39,
        39, 41, 42, 42, 44, 45, 46, 47, 47, 50, 51, 52, 54, 54, 57, 58, 60, 63,
        63, 67, 34, 34, 34, 34, 34, 34, 35, 36, 36, 37, 37, 40, 41, 42, 45, 45,
        46, 47, 48, 50, 50, 52, 53, 54, 56, 56, 59, 60, 62, 65, 65, 69, 36, 35,
        35, 35, 34, 34, 36, 36, 37, 38, 38, 42, 42, 45, 48, 48, 50, 50, 52, 54,
        54, 56, 57, 58, 60, 60, 63, 64, 65, 68, 68, 72, 36, 35, 35, 35, 34, 34,
        36, 36, 37, 38, 38, 42, 42, 45, 48, 48, 50, 50, 52, 54, 54, 56, 57, 58,
        60, 60, 63, 64, 65, 68, 68, 72, 38, 38, 38, 37, 37, 37, 38, 38, 39, 40,
        40, 43, 44, 46, 50, 50, 52, 53, 54, 57, 57, 59, 60, 61, 64, 64, 67, 68,
        69, 72, 72, 76, 39, 38, 38, 38, 37, 37, 39, 39, 39, 40, 40, 44, 45, 47,
        50, 50, 53, 54, 55, 58, 58, 60, 61, 62, 65, 65, 68, 69, 70, 73, 73, 77,
        41, 40, 40, 39, 38, 38, 40, 40, 40, 41, 41, 45, 46, 48, 52, 52, 54, 55,
        57, 60, 60, 62, 63, 65, 67, 67, 70, 71, 73, 75, 75, 79, 44, 42, 42, 42,
        41, 41, 42, 42, 42, 42, 42, 46, 47, 50, 54, 54, 57, 58, 60, 63, 63, 66,
        67, 68, 71, 71, 74, 75, 77, 79, 79, 83, 44, 42, 42, 42, 41, 41, 42, 42,
        42, 42, 42, 46, 47, 50, 54, 54, 57, 58, 60, 63, 63, 66, 67, 68, 71, 71,
        74, 75, 77, 79, 79, 83, 47, 46, 45, 45, 44, 44, 44, 45, 45, 45, 45, 49,
        50, 52, 56, 56, 59, 60, 62, 66, 66, 69, 70, 72, 75, 75, 78, 79, 81, 84,
        84, 88, 48, 47, 46, 45, 44, 44, 45, 45, 45, 46, 46, 50, 51, 53, 57, 57,
        60, 61, 63, 67, 67, 70, 71, 73, 76, 76, 79, 80, 82, 85, 85, 89, 50, 49,
        48, 47, 46, 46, 47, 47, 47, 47, 47, 51, 52, 54, 58, 58, 61, 62, 65, 68,
        68, 72, 73, 75, 78, 78, 82, 83, 85, 88, 88, 92, 54, 52, 51, 50, 49, 49,
        49, 50, 49, 49, 49, 53, 54, 56, 60, 60, 64, 65, 67, 71, 71, 75, 76, 78,
        82, 82, 86, 87, 89, 92, 92, 96, 54, 52, 51, 50, 49, 49, 49, 50, 49, 49,
        49, 53, 54, 56, 60, 60, 64, 65, 67, 71, 71, 75, 76, 78, 82, 82, 86, 87,
        89, 92, 92, 96, 58, 56, 55, 54, 53, 53, 53, 53, 53, 52, 52, 56, 57, 59,
        63, 63, 67, 68, 70, 74, 74, 78, 79, 82, 86, 86, 90, 91, 93, 97, 97, 101,
        59, 57, 56, 55, 54, 54, 54, 54, 54, 53, 53, 57, 58, 60, 64, 64, 68, 69,
        71, 75, 75, 79, 80, 83, 87, 87, 91, 92, 94, 98, 98, 102, 61, 59, 58, 57,
        56, 56, 56, 56, 55, 55, 55, 59, 60, 62, 65, 65, 69, 70, 73, 77, 77, 81,
        82, 85, 89, 89, 93, 94, 97, 101, 101, 105, 65, 63, 62, 61, 59, 59, 59,
        59, 59, 58, 58, 62, 63, 65, 68, 68, 72, 73, 75, 79, 79, 84, 85, 88, 92,
        92, 97, 98, 101, 105, 105, 109, 65, 63, 62, 61, 59, 59, 59, 59, 59, 58,
        58, 62, 63, 65, 68, 68, 72, 73, 75, 79, 79, 84, 85, 88, 92, 92, 97, 98,
        101, 105, 105, 109, 70, 67, 67, 65, 64, 64, 63, 63, 63, 62, 62, 66, 67,
        69, 72, 72, 76, 77, 79, 83, 83, 88, 89, 92, 96, 96, 101, 102, 105, 109,
        109, 114,
        /* Size 4x8 */
        32, 32, 42, 56, 32, 33, 41, 53, 32, 35, 42, 52, 34, 37, 50, 59, 38, 40,
        58, 68, 44, 45, 66, 78, 50, 50, 71, 86, 61, 58, 79, 97,
        /* Size 8x4 */
        32, 32, 32, 34, 38, 44, 50, 61, 32, 33, 35, 37, 40, 45, 50, 58, 42, 41,
        42, 50, 58, 66, 71, 79, 56, 53, 52, 59, 68, 78, 86, 97,
        /* Size 8x16 */
        32, 31, 32, 35, 39, 44, 53, 65, 31, 32, 32, 35, 38, 42, 51, 62, 31, 32,
        33, 34, 37, 41, 49, 59, 31, 32, 34, 35, 38, 42, 49, 59, 32, 32, 34, 36,
        39, 42, 49, 58, 32, 33, 35, 37, 40, 42, 49, 58, 34, 34, 37, 41, 44, 48,
        54, 63, 36, 34, 38, 46, 50, 54, 60, 68, 38, 37, 40, 47, 52, 57, 64, 72,
        41, 39, 41, 49, 54, 60, 67, 76, 44, 41, 43, 51, 57, 63, 71, 79, 48, 45,
        46, 54, 60, 67, 76, 85, 53, 49, 50, 57, 64, 71, 82, 92, 57, 53, 53, 60,
        67, 74, 86, 97, 61, 56, 56, 63, 69, 77, 89, 100, 65, 60, 58, 66, 72, 79,
        92, 105,
        /* Size 16x8 */
        32, 31, 31, 31, 32, 32, 34, 36, 38, 41, 44, 48, 53, 57, 61, 65, 31, 32,
        32, 32, 32, 33, 34, 34, 37, 39, 41, 45, 49, 53, 56, 60, 32, 32, 33, 34,
        34, 35, 37, 38, 40, 41, 43, 46, 50, 53, 56, 58, 35, 35, 34, 35, 36, 37,
        41, 46, 47, 49, 51, 54, 57, 60, 63, 66, 39, 38, 37, 38, 39, 40, 44, 50,
        52, 54, 57, 60, 64, 67, 69, 72, 44, 42, 41, 42, 42, 42, 48, 54, 57, 60,
        63, 67, 71, 74, 77, 79, 53, 51, 49, 49, 49, 49, 54, 60, 64, 67, 71, 76,
        82, 86, 89, 92, 65, 62, 59, 59, 58, 58, 63, 68, 72, 76, 79, 85, 92, 97,
        100, 105,
        /* Size 16x32 */
        32, 31, 31, 31, 32, 32, 35, 36, 39, 44, 44, 51, 53, 58, 65, 65, 31, 32,
        32, 32, 32, 32, 35, 35, 38, 42, 42, 49, 52, 56, 63, 63, 31, 32, 32, 32,
        32, 32, 35, 35, 38, 42, 42, 49, 51, 55, 62, 62, 31, 32, 32, 32, 32, 32,
        34, 35, 37, 41, 41, 48, 50, 54, 61, 61, 31, 32, 32, 32, 33, 33, 34, 34,
        37, 41, 41, 47, 49, 53, 59, 59, 31, 32, 32, 32, 33, 33, 34, 34, 37, 41,
        41, 47, 49, 53, 59, 59, 31, 32, 32, 33, 34, 34, 35, 36, 38, 42, 42, 48,
        49, 53, 59, 59, 32, 32, 32, 33, 34, 34, 36, 36, 38, 42, 42, 48, 50, 53,
        59, 59, 32, 32, 32, 33, 34, 34, 36, 37, 39, 42, 42, 48, 49, 53, 58, 58,
        32, 32, 33, 34, 35, 35, 37, 38, 40, 42, 42, 48, 49, 52, 58, 58, 32, 32,
        33, 34, 35, 35, 37, 38, 40, 42, 42, 48, 49, 52, 58, 58, 33, 33, 33, 35,
        36, 36, 40, 41, 43, 46, 46, 52, 53, 56, 62, 62, 34, 34, 34, 35, 37, 37,
        41, 42, 44, 48, 48, 53, 54, 57, 63, 63, 34, 34, 34, 35, 37, 37, 43, 44,
        46, 50, 50, 55, 56, 59, 65, 65, 36, 35, 34, 36, 38, 38, 46, 48, 50, 54,
        54, 58, 60, 63, 68, 68, 36, 35, 34, 36, 38, 38, 46, 48, 50, 54, 54, 58,
        60, 63, 68, 68, 38, 37, 37, 38, 40, 40, 47, 50, 52, 57, 57, 62, 64, 67,
        72, 72, 39, 38, 37, 39, 40, 40, 48, 50, 53, 58, 58, 63, 65, 68, 73, 73,
        41, 39, 39, 40, 41, 41, 49, 51, 54, 60, 60, 66, 67, 70, 76, 76, 44, 41,
        41, 42, 43, 43, 51, 53, 57, 63, 63, 69, 71, 74, 79, 79, 44, 41, 41, 42,
        43, 43, 51, 53, 57, 63, 63, 69, 71, 74, 79, 79, 47, 44, 44, 44, 45, 45,
        53, 56, 59, 66, 66, 73, 75, 78, 84, 84, 48, 45, 45, 45, 46, 46, 54, 56,
        60, 67, 67, 74, 76, 79, 85, 85, 50, 47, 46, 47, 47, 47, 55, 58, 61, 68,
        68, 76, 78, 82, 88, 88, 53, 50, 49, 50, 50, 50, 57, 60, 64, 71, 71, 79,
        82, 86, 92, 92, 53, 50, 49, 50, 50, 50, 57, 60, 64, 71, 71, 79, 82, 86,
        92, 92, 57, 54, 53, 53, 53, 53, 60, 63, 67, 74, 74, 83, 86, 90, 97, 97,
        58, 55, 54, 54, 54, 54, 61, 63, 68, 75, 75, 84, 87, 91, 98, 98, 61, 57,
        56, 56, 56, 56, 63, 65, 69, 77, 77, 86, 89, 93, 100, 100, 65, 61, 60,
        59, 58, 58, 66, 68, 72, 79, 79, 89, 92, 97, 105, 105, 65, 61, 60, 59,
        58, 58, 66, 68, 72, 79, 79, 89, 92, 97, 105, 105, 70, 65, 64, 63, 62,
        62, 70, 72, 76, 83, 83, 93, 96, 101, 109, 109,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 34, 34, 36, 36, 38, 39,
        41, 44, 44, 47, 48, 50, 53, 53, 57, 58, 61, 65, 65, 70, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 37, 38, 39, 41, 41, 44,
        45, 47, 50, 50, 54, 55, 57, 61, 61, 65, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 34, 34, 34, 34, 37, 37, 39, 41, 41, 44, 45, 46, 49, 49,
        53, 54, 56, 60, 60, 64, 31, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 35,
        35, 35, 36, 36, 38, 39, 40, 42, 42, 44, 45, 47, 50, 50, 53, 54, 56, 59,
        59, 63, 32, 32, 32, 32, 33, 33, 34, 34, 34, 35, 35, 36, 37, 37, 38, 38,
        40, 40, 41, 43, 43, 45, 46, 47, 50, 50, 53, 54, 56, 58, 58, 62, 32, 32,
        32, 32, 33, 33, 34, 34, 34, 35, 35, 36, 37, 37, 38, 38, 40, 40, 41, 43,
        43, 45, 46, 47, 50, 50, 53, 54, 56, 58, 58, 62, 35, 35, 35, 34, 34, 34,
        35, 36, 36, 37, 37, 40, 41, 43, 46, 46, 47, 48, 49, 51, 51, 53, 54, 55,
        57, 57, 60, 61, 63, 66, 66, 70, 36, 35, 35, 35, 34, 34, 36, 36, 37, 38,
        38, 41, 42, 44, 48, 48, 50, 50, 51, 53, 53, 56, 56, 58, 60, 60, 63, 63,
        65, 68, 68, 72, 39, 38, 38, 37, 37, 37, 38, 38, 39, 40, 40, 43, 44, 46,
        50, 50, 52, 53, 54, 57, 57, 59, 60, 61, 64, 64, 67, 68, 69, 72, 72, 76,
        44, 42, 42, 41, 41, 41, 42, 42, 42, 42, 42, 46, 48, 50, 54, 54, 57, 58,
        60, 63, 63, 66, 67, 68, 71, 71, 74, 75, 77, 79, 79, 83, 44, 42, 42, 41,
        41, 41, 42, 42, 42, 42, 42, 46, 48, 50, 54, 54, 57, 58, 60, 63, 63, 66,
        67, 68, 71, 71, 74, 75, 77, 79, 79, 83, 51, 49, 49, 48, 47, 47, 48, 48,
        48, 48, 48, 52, 53, 55, 58, 58, 62, 63, 66, 69, 69, 73, 74, 76, 79, 79,
        83, 84, 86, 89, 89, 93, 53, 52, 51, 50, 49, 49, 49, 50, 49, 49, 49, 53,
        54, 56, 60, 60, 64, 65, 67, 71, 71, 75, 76, 78, 82, 82, 86, 87, 89, 92,
        92, 96, 58, 56, 55, 54, 53, 53, 53, 53, 53, 52, 52, 56, 57, 59, 63, 63,
        67, 68, 70, 74, 74, 78, 79, 82, 86, 86, 90, 91, 93, 97, 97, 101, 65, 63,
        62, 61, 59, 59, 59, 59, 58, 58, 58, 62, 63, 65, 68, 68, 72, 73, 76, 79,
        79, 84, 85, 88, 92, 92, 97, 98, 100, 105, 105, 109, 65, 63, 62, 61, 59,
        59, 59, 59, 58, 58, 58, 62, 63, 65, 68, 68, 72, 73, 76, 79, 79, 84, 85,
        88, 92, 92, 97, 98, 100, 105, 105, 109 },
      { /* Chroma */
        /* Size 4x4 */
        31, 41, 46, 51, 41, 48, 48, 51, 46, 48, 58, 62, 51, 51, 62, 71,
        /* Size 8x8 */
        31, 31, 38, 44, 47, 48, 50, 55, 31, 32, 40, 44, 45, 46, 47, 52, 38, 40,
        47, 47, 46, 46, 47, 50, 44, 44, 47, 50, 51, 51, 52, 54, 47, 45, 46, 51,
        54, 56, 57, 60, 48, 46, 46, 51, 56, 61, 63, 66, 50, 47, 47, 52, 57, 63,
        66, 70, 55, 52, 50, 54, 60, 66, 70, 76,
        /* Size 16x16 */
        32, 31, 30, 33, 34, 36, 41, 49, 48, 49, 49, 50, 52, 54, 55, 57, 31, 31,
        31, 34, 36, 38, 42, 47, 47, 47, 47, 48, 50, 51, 53, 54, 30, 31, 32, 34,
        37, 40, 42, 46, 45, 45, 45, 46, 47, 49, 50, 52, 33, 34, 34, 37, 40, 42,
        44, 47, 46, 46, 45, 46, 47, 49, 50, 51, 34, 36, 37, 40, 42, 45, 46, 47,
        46, 46, 45, 46, 47, 48, 49, 50, 36, 38, 40, 42, 45, 47, 47, 48, 47, 46,
        45, 46, 47, 48, 49, 50, 41, 42, 42, 44, 46, 47, 48, 50, 50, 49, 49, 50,
        50, 51, 52, 53, 49, 47, 46, 47, 47, 48, 50, 53, 53, 53, 53, 54, 54, 55,
        56, 56, 48, 47, 45, 46, 46, 47, 50, 53, 54, 54, 55, 56, 57, 58, 58, 59,
        49, 47, 45, 46, 46, 46, 49, 53, 54, 55, 57, 58, 59, 60, 60, 61, 49, 47,
        45, 45, 45, 45, 49, 53, 55, 57, 58, 60, 61, 62, 63, 63, 50, 48, 46, 46,
        46, 46, 50, 54, 56, 58, 60, 61, 63, 65, 66, 67, 52, 50, 47, 47, 47, 47,
        50, 54, 57, 59, 61, 63, 66, 68, 69, 70, 54, 51, 49, 49, 48, 48, 51, 55,
        58, 60, 62, 65, 68, 70, 71, 73, 55, 53, 50, 50, 49, 49, 52, 56, 58, 60,
        63, 66, 69, 71, 73, 74, 57, 54, 52, 51, 50, 50, 53, 56, 59, 61, 63, 67,
        70, 73, 74, 76,
        /* Size 32x32 */
        32, 31, 31, 31, 30, 30, 33, 33, 34, 36, 36, 40, 41, 44, 49, 49, 48, 48,
        49, 49, 49, 50, 50, 51, 52, 52, 54, 54, 55, 57, 57, 59, 31, 31, 31, 31,
        31, 31, 33, 34, 36, 38, 38, 41, 42, 44, 48, 48, 47, 47, 47, 47, 47, 48,
        49, 49, 50, 50, 52, 52, 53, 55, 55, 57, 31, 31, 31, 31, 31, 31, 34, 34,
        36, 38, 38, 41, 42, 44, 47, 47, 47, 47, 47, 47, 47, 48, 48, 49, 50, 50,
        51, 52, 53, 54, 54, 56, 31, 31, 31, 31, 31, 31, 34, 35, 36, 39, 39, 41,
        42, 44, 47, 47, 46, 46, 46, 46, 46, 47, 47, 48, 49, 49, 50, 51, 52, 53,
        53, 55, 30, 31, 31, 31, 32, 32, 34, 35, 37, 40, 40, 42, 42, 44, 46, 46,
        45, 45, 45, 45, 45, 46, 46, 47, 47, 47, 49, 49, 50, 52, 52, 54, 30, 31,
        31, 31, 32, 32, 34, 35, 37, 40, 40, 42, 42, 44, 46, 46, 45, 45, 45, 45,
        45, 46, 46, 47, 47, 47, 49, 49, 50, 52, 52, 54, 33, 33, 34, 34, 34, 34,
        37, 38, 40, 42, 42, 44, 44, 45, 47, 47, 46, 46, 46, 45, 45, 46, 46, 47,
        47, 47, 49, 49, 50, 51, 51, 53, 33, 34, 34, 35, 35, 35, 38, 39, 40, 43,
        43, 44, 45, 46, 47, 47, 46, 46, 46, 45, 45, 46, 46, 47, 47, 47, 49, 49,
        50, 51, 51, 53, 34, 36, 36, 36, 37, 37, 40, 40, 42, 45, 45, 45, 46, 46,
        47, 47, 46, 46, 46, 45, 45, 46, 46, 47, 47, 47, 48, 49, 49, 50, 50, 52,
        36, 38, 38, 39, 40, 40, 42, 43, 45, 47, 47, 47, 47, 47, 48, 48, 47, 46,
        46, 45, 45, 46, 46, 46, 47, 47, 48, 48, 49, 50, 50, 51, 36, 38, 38, 39,
        40, 40, 42, 43, 45, 47, 47, 47, 47, 47, 48, 48, 47, 46, 46, 45, 45, 46,
        46, 46, 47, 47, 48, 48, 49, 50, 50, 51, 40, 41, 41, 41, 42, 42, 44, 44,
        45, 47, 47, 48, 48, 49, 50, 50, 49, 49, 49, 48, 48, 49, 49, 49, 49, 49,
        51, 51, 51, 52, 52, 54, 41, 42, 42, 42, 42, 42, 44, 45, 46, 47, 47, 48,
        48, 49, 50, 50, 50, 49, 49, 49, 49, 50, 50, 50, 50, 50, 51, 52, 52, 53,
        53, 55, 44, 44, 44, 44, 44, 44, 45, 46, 46, 47, 47, 49, 49, 50, 51, 51,
        51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 53, 53, 54, 54, 54, 56, 49, 48,
        47, 47, 46, 46, 47, 47, 47, 48, 48, 50, 50, 51, 53, 53, 53, 53, 53, 53,
        53, 54, 54, 54, 54, 54, 55, 55, 56, 56, 56, 58, 49, 48, 47, 47, 46, 46,
        47, 47, 47, 48, 48, 50, 50, 51, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54,
        54, 54, 55, 55, 56, 56, 56, 58, 48, 47, 47, 46, 45, 45, 46, 46, 46, 47,
        47, 49, 50, 51, 53, 53, 54, 54, 54, 55, 55, 56, 56, 56, 57, 57, 58, 58,
        58, 59, 59, 60, 48, 47, 47, 46, 45, 45, 46, 46, 46, 46, 46, 49, 49, 51,
        53, 53, 54, 54, 55, 55, 55, 56, 56, 57, 57, 57, 58, 58, 59, 60, 60, 61,
        49, 47, 47, 46, 45, 45, 46, 46, 46, 46, 46, 49, 49, 51, 53, 53, 54, 55,
        55, 57, 57, 57, 58, 58, 59, 59, 60, 60, 60, 61, 61, 63, 49, 47, 47, 46,
        45, 45, 45, 45, 45, 45, 45, 48, 49, 51, 53, 53, 55, 55, 57, 58, 58, 59,
        60, 60, 61, 61, 62, 62, 63, 63, 63, 65, 49, 47, 47, 46, 45, 45, 45, 45,
        45, 45, 45, 48, 49, 51, 53, 53, 55, 55, 57, 58, 58, 59, 60, 60, 61, 61,
        62, 62, 63, 63, 63, 65, 50, 48, 48, 47, 46, 46, 46, 46, 46, 46, 46, 49,
        50, 51, 54, 54, 56, 56, 57, 59, 59, 61, 61, 62, 63, 63, 64, 64, 65, 66,
        66, 67, 50, 49, 48, 47, 46, 46, 46, 46, 46, 46, 46, 49, 50, 51, 54, 54,
        56, 56, 58, 60, 60, 61, 61, 62, 63, 63, 65, 65, 66, 67, 67, 68, 51, 49,
        49, 48, 47, 47, 47, 47, 47, 46, 46, 49, 50, 51, 54, 54, 56, 57, 58, 60,
        60, 62, 62, 63, 65, 65, 66, 66, 67, 68, 68, 70, 52, 50, 50, 49, 47, 47,
        47, 47, 47, 47, 47, 49, 50, 52, 54, 54, 57, 57, 59, 61, 61, 63, 63, 65,
        66, 66, 68, 68, 69, 70, 70, 72, 52, 50, 50, 49, 47, 47, 47, 47, 47, 47,
        47, 49, 50, 52, 54, 54, 57, 57, 59, 61, 61, 63, 63, 65, 66, 66, 68, 68,
        69, 70, 70, 72, 54, 52, 51, 50, 49, 49, 49, 49, 48, 48, 48, 51, 51, 53,
        55, 55, 58, 58, 60, 62, 62, 64, 65, 66, 68, 68, 70, 70, 71, 73, 73, 74,
        54, 52, 52, 51, 49, 49, 49, 49, 49, 48, 48, 51, 52, 53, 55, 55, 58, 58,
        60, 62, 62, 64, 65, 66, 68, 68, 70, 71, 72, 73, 73, 75, 55, 53, 53, 52,
        50, 50, 50, 50, 49, 49, 49, 51, 52, 54, 56, 56, 58, 59, 60, 63, 63, 65,
        66, 67, 69, 69, 71, 72, 73, 74, 74, 76, 57, 55, 54, 53, 52, 52, 51, 51,
        50, 50, 50, 52, 53, 54, 56, 56, 59, 60, 61, 63, 63, 66, 67, 68, 70, 70,
        73, 73, 74, 76, 76, 78, 57, 55, 54, 53, 52, 52, 51, 51, 50, 50, 50, 52,
        53, 54, 56, 56, 59, 60, 61, 63, 63, 66, 67, 68, 70, 70, 73, 73, 74, 76,
        76, 78, 59, 57, 56, 55, 54, 54, 53, 53, 52, 51, 51, 54, 55, 56, 58, 58,
        60, 61, 63, 65, 65, 67, 68, 70, 72, 72, 74, 75, 76, 78, 78, 80,
        /* Size 4x8 */
        31, 38, 47, 52, 32, 40, 45, 49, 39, 47, 45, 48, 44, 47, 51, 53, 46, 47,
        56, 58, 47, 46, 59, 64, 48, 47, 61, 68, 53, 50, 64, 73,
        /* Size 8x4 */
        31, 32, 39, 44, 46, 47, 48, 53, 38, 40, 47, 47, 47, 46, 47, 50, 47, 45,
        45, 51, 56, 59, 61, 64, 52, 49, 48, 53, 58, 64, 68, 73,
        /* Size 8x16 */
        32, 31, 37, 45, 48, 49, 52, 57, 31, 31, 38, 45, 47, 47, 50, 54, 30, 32,
        40, 44, 45, 45, 48, 52, 33, 35, 42, 46, 46, 45, 47, 51, 35, 37, 44, 46,
        46, 45, 47, 51, 37, 40, 47, 47, 47, 45, 47, 50, 42, 43, 47, 49, 50, 49,
        50, 53, 49, 46, 48, 52, 53, 53, 54, 57, 48, 46, 47, 51, 54, 55, 57, 59,
        48, 45, 46, 51, 54, 57, 59, 61, 49, 45, 46, 51, 55, 58, 61, 64, 50, 46,
        46, 52, 56, 59, 64, 67, 52, 48, 47, 53, 57, 61, 66, 71, 54, 49, 48, 54,
        58, 62, 68, 73, 55, 51, 49, 54, 58, 63, 69, 74, 57, 52, 50, 55, 59, 64,
        70, 76,
        /* Size 16x8 */
        32, 31, 30, 33, 35, 37, 42, 49, 48, 48, 49, 50, 52, 54, 55, 57, 31, 31,
        32, 35, 37, 40, 43, 46, 46, 45, 45, 46, 48, 49, 51, 52, 37, 38, 40, 42,
        44, 47, 47, 48, 47, 46, 46, 46, 47, 48, 49, 50, 45, 45, 44, 46, 46, 47,
        49, 52, 51, 51, 51, 52, 53, 54, 54, 55, 48, 47, 45, 46, 46, 47, 50, 53,
        54, 54, 55, 56, 57, 58, 58, 59, 49, 47, 45, 45, 45, 45, 49, 53, 55, 57,
        58, 59, 61, 62, 63, 64, 52, 50, 48, 47, 47, 47, 50, 54, 57, 59, 61, 64,
        66, 68, 69, 70, 57, 54, 52, 51, 51, 50, 53, 57, 59, 61, 64, 67, 71, 73,
        74, 76,
        /* Size 16x32 */
        32, 31, 31, 33, 37, 37, 45, 48, 48, 49, 49, 51, 52, 54, 57, 57, 31, 31,
        31, 34, 38, 38, 45, 47, 47, 47, 47, 50, 50, 52, 55, 55, 31, 31, 31, 34,
        38, 38, 45, 47, 47, 47, 47, 49, 50, 51, 54, 54, 31, 31, 32, 34, 39, 39,
        45, 46, 46, 46, 46, 48, 49, 51, 53, 53, 30, 32, 32, 35, 40, 40, 44, 46,
        45, 45, 45, 47, 48, 49, 52, 52, 30, 32, 32, 35, 40, 40, 44, 46, 45, 45,
        45, 47, 48, 49, 52, 52, 33, 34, 35, 37, 42, 42, 46, 47, 46, 45, 45, 47,
        47, 49, 51, 51, 33, 35, 36, 38, 43, 43, 46, 47, 46, 46, 46, 47, 47, 49,
        51, 51, 35, 37, 37, 40, 44, 44, 46, 47, 46, 45, 45, 47, 47, 48, 51, 51,
        37, 39, 40, 43, 47, 47, 47, 47, 47, 45, 45, 46, 47, 48, 50, 50, 37, 39,
        40, 43, 47, 47, 47, 47, 47, 45, 45, 46, 47, 48, 50, 50, 41, 42, 42, 44,
        47, 47, 49, 49, 49, 48, 48, 49, 50, 51, 52, 52, 42, 42, 43, 44, 47, 47,
        49, 50, 50, 49, 49, 50, 50, 51, 53, 53, 44, 44, 44, 45, 47, 47, 50, 51,
        51, 51, 51, 52, 52, 53, 54, 54, 49, 47, 46, 47, 48, 48, 52, 53, 53, 53,
        53, 54, 54, 55, 57, 57, 49, 47, 46, 47, 48, 48, 52, 53, 53, 53, 53, 54,
        54, 55, 57, 57, 48, 46, 46, 46, 47, 47, 51, 53, 54, 55, 55, 56, 57, 58,
        59, 59, 48, 46, 46, 46, 47, 47, 51, 53, 54, 56, 56, 57, 57, 58, 60, 60,
        48, 46, 45, 46, 46, 46, 51, 53, 54, 57, 57, 58, 59, 60, 61, 61, 49, 46,
        45, 45, 46, 46, 51, 53, 55, 58, 58, 61, 61, 62, 64, 64, 49, 46, 45, 45,
        46, 46, 51, 53, 55, 58, 58, 61, 61, 62, 64, 64, 50, 47, 46, 46, 46, 46,
        52, 54, 56, 59, 59, 62, 63, 64, 66, 66, 50, 47, 46, 46, 46, 46, 52, 54,
        56, 59, 59, 63, 64, 65, 67, 67, 51, 48, 47, 47, 47, 47, 52, 54, 56, 60,
        60, 64, 65, 66, 68, 68, 52, 48, 48, 47, 47, 47, 53, 54, 57, 61, 61, 65,
        66, 68, 71, 71, 52, 48, 48, 47, 47, 47, 53, 54, 57, 61, 61, 65, 66, 68,
        71, 71, 54, 50, 49, 49, 48, 48, 54, 55, 58, 62, 62, 67, 68, 70, 73, 73,
        54, 51, 50, 49, 49, 49, 54, 55, 58, 62, 62, 67, 68, 70, 73, 73, 55, 51,
        51, 50, 49, 49, 54, 56, 58, 63, 63, 68, 69, 71, 74, 74, 57, 53, 52, 51,
        50, 50, 55, 56, 59, 64, 64, 69, 70, 73, 76, 76, 57, 53, 52, 51, 50, 50,
        55, 56, 59, 64, 64, 69, 70, 73, 76, 76, 59, 55, 54, 53, 52, 52, 57, 58,
        61, 65, 65, 70, 72, 74, 78, 78,
        /* Size 32x16 */
        32, 31, 31, 31, 30, 30, 33, 33, 35, 37, 37, 41, 42, 44, 49, 49, 48, 48,
        48, 49, 49, 50, 50, 51, 52, 52, 54, 54, 55, 57, 57, 59, 31, 31, 31, 31,
        32, 32, 34, 35, 37, 39, 39, 42, 42, 44, 47, 47, 46, 46, 46, 46, 46, 47,
        47, 48, 48, 48, 50, 51, 51, 53, 53, 55, 31, 31, 31, 32, 32, 32, 35, 36,
        37, 40, 40, 42, 43, 44, 46, 46, 46, 46, 45, 45, 45, 46, 46, 47, 48, 48,
        49, 50, 51, 52, 52, 54, 33, 34, 34, 34, 35, 35, 37, 38, 40, 43, 43, 44,
        44, 45, 47, 47, 46, 46, 46, 45, 45, 46, 46, 47, 47, 47, 49, 49, 50, 51,
        51, 53, 37, 38, 38, 39, 40, 40, 42, 43, 44, 47, 47, 47, 47, 47, 48, 48,
        47, 47, 46, 46, 46, 46, 46, 47, 47, 47, 48, 49, 49, 50, 50, 52, 37, 38,
        38, 39, 40, 40, 42, 43, 44, 47, 47, 47, 47, 47, 48, 48, 47, 47, 46, 46,
        46, 46, 46, 47, 47, 47, 48, 49, 49, 50, 50, 52, 45, 45, 45, 45, 44, 44,
        46, 46, 46, 47, 47, 49, 49, 50, 52, 52, 51, 51, 51, 51, 51, 52, 52, 52,
        53, 53, 54, 54, 54, 55, 55, 57, 48, 47, 47, 46, 46, 46, 47, 47, 47, 47,
        47, 49, 50, 51, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 55,
        56, 56, 56, 58, 48, 47, 47, 46, 45, 45, 46, 46, 46, 47, 47, 49, 50, 51,
        53, 53, 54, 54, 54, 55, 55, 56, 56, 56, 57, 57, 58, 58, 58, 59, 59, 61,
        49, 47, 47, 46, 45, 45, 45, 46, 45, 45, 45, 48, 49, 51, 53, 53, 55, 56,
        57, 58, 58, 59, 59, 60, 61, 61, 62, 62, 63, 64, 64, 65, 49, 47, 47, 46,
        45, 45, 45, 46, 45, 45, 45, 48, 49, 51, 53, 53, 55, 56, 57, 58, 58, 59,
        59, 60, 61, 61, 62, 62, 63, 64, 64, 65, 51, 50, 49, 48, 47, 47, 47, 47,
        47, 46, 46, 49, 50, 52, 54, 54, 56, 57, 58, 61, 61, 62, 63, 64, 65, 65,
        67, 67, 68, 69, 69, 70, 52, 50, 50, 49, 48, 48, 47, 47, 47, 47, 47, 50,
        50, 52, 54, 54, 57, 57, 59, 61, 61, 63, 64, 65, 66, 66, 68, 68, 69, 70,
        70, 72, 54, 52, 51, 51, 49, 49, 49, 49, 48, 48, 48, 51, 51, 53, 55, 55,
        58, 58, 60, 62, 62, 64, 65, 66, 68, 68, 70, 70, 71, 73, 73, 74, 57, 55,
        54, 53, 52, 52, 51, 51, 51, 50, 50, 52, 53, 54, 57, 57, 59, 60, 61, 64,
        64, 66, 67, 68, 71, 71, 73, 73, 74, 76, 76, 78, 57, 55, 54, 53, 52, 52,
        51, 51, 51, 50, 50, 52, 53, 54, 57, 57, 59, 60, 61, 64, 64, 66, 67, 68,
        71, 71, 73, 73, 74, 76, 76, 78 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 32, 38, 51, 32, 35, 40, 49, 38, 40, 54, 64, 51, 49, 64, 81,
        /* Size 8x8 */
        31, 32, 32, 34, 35, 41, 47, 53, 32, 32, 32, 33, 34, 40, 44, 50, 32, 32,
        34, 35, 37, 41, 45, 51, 34, 33, 35, 39, 42, 47, 51, 55, 35, 34, 37, 42,
        48, 53, 57, 61, 41, 40, 41, 47, 53, 60, 65, 70, 47, 44, 45, 51, 57, 65,
        71, 77, 53, 50, 51, 55, 61, 70, 77, 85,
        /* Size 16x16 */
        32, 31, 31, 31, 31, 32, 32, 34, 36, 38, 39, 44, 47, 49, 54, 59, 31, 32,
        32, 32, 32, 32, 33, 34, 35, 37, 38, 42, 45, 47, 51, 56, 31, 32, 32, 32,
        32, 32, 33, 33, 34, 36, 37, 41, 44, 46, 50, 54, 31, 32, 32, 32, 32, 33,
        33, 34, 35, 36, 38, 41, 44, 45, 49, 54, 31, 32, 32, 32, 33, 34, 34, 35,
        36, 38, 39, 42, 45, 46, 50, 54, 32, 32, 32, 33, 34, 35, 36, 37, 38, 39,
        40, 42, 45, 46, 49, 53, 32, 33, 33, 33, 34, 36, 36, 38, 40, 41, 42, 44,
        47, 48, 51, 55, 34, 34, 33, 34, 35, 37, 38, 39, 42, 44, 45, 47, 50, 51,
        54, 58, 36, 35, 34, 35, 36, 38, 40, 42, 48, 50, 50, 54, 56, 57, 60, 64,
        38, 37, 36, 36, 38, 39, 41, 44, 50, 51, 52, 56, 58, 60, 63, 67, 39, 38,
        37, 38, 39, 40, 42, 45, 50, 52, 54, 58, 60, 62, 65, 69, 44, 42, 41, 41,
        42, 42, 44, 47, 54, 56, 58, 63, 66, 68, 71, 75, 47, 45, 44, 44, 45, 45,
        47, 50, 56, 58, 60, 66, 69, 71, 75, 79, 49, 47, 46, 45, 46, 46, 48, 51,
        57, 60, 62, 68, 71, 73, 77, 81, 54, 51, 50, 49, 50, 49, 51, 54, 60, 63,
        65, 71, 75, 77, 82, 87, 59, 56, 54, 54, 54, 53, 55, 58, 64, 67, 69, 75,
        79, 81, 87, 92,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 35, 36, 36,
        38, 39, 39, 42, 44, 44, 47, 48, 49, 53, 54, 55, 59, 59, 31, 31, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 37, 39, 39, 41,
        43, 43, 46, 47, 48, 51, 52, 53, 57, 57, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 37, 38, 38, 41, 42, 43, 45, 46,
        47, 51, 51, 53, 56, 56, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        33, 34, 34, 34, 35, 35, 37, 38, 38, 41, 42, 42, 45, 46, 47, 51, 51, 52,
        56, 56, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34,
        34, 34, 36, 37, 37, 40, 41, 41, 44, 45, 46, 49, 50, 51, 54, 54, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 36, 37,
        37, 40, 41, 41, 44, 44, 45, 49, 49, 50, 54, 54, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 35, 36, 38, 38, 40, 41, 41,
        44, 45, 45, 49, 49, 50, 54, 54, 31, 32, 32, 32, 32, 32, 32, 33, 33, 33,
        34, 34, 34, 35, 35, 35, 36, 36, 38, 39, 39, 41, 42, 42, 44, 45, 46, 49,
        50, 51, 54, 54, 31, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35,
        35, 36, 36, 36, 38, 39, 39, 41, 42, 42, 45, 45, 46, 49, 50, 51, 54, 54,
        32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 37, 37,
        38, 39, 39, 41, 42, 42, 45, 45, 46, 49, 49, 51, 54, 54, 32, 32, 32, 32,
        32, 32, 33, 34, 34, 34, 35, 35, 36, 37, 37, 37, 38, 38, 39, 40, 40, 42,
        42, 43, 45, 46, 46, 49, 49, 50, 53, 53, 32, 32, 32, 32, 32, 32, 33, 34,
        34, 34, 35, 35, 36, 37, 37, 37, 38, 38, 39, 40, 40, 42, 42, 43, 45, 46,
        46, 49, 49, 50, 53, 53, 32, 33, 33, 33, 33, 33, 33, 34, 34, 35, 36, 36,
        36, 38, 38, 39, 40, 40, 41, 42, 42, 44, 44, 45, 47, 47, 48, 51, 51, 52,
        55, 55, 34, 34, 34, 34, 33, 33, 34, 35, 35, 35, 37, 37, 38, 39, 39, 41,
        42, 42, 44, 45, 45, 47, 47, 48, 50, 51, 51, 54, 54, 55, 58, 58, 34, 34,
        34, 34, 33, 33, 34, 35, 35, 35, 37, 37, 38, 39, 39, 41, 42, 42, 44, 45,
        45, 47, 47, 48, 50, 51, 51, 54, 54, 55, 58, 58, 35, 34, 34, 34, 34, 34,
        34, 35, 36, 36, 37, 37, 39, 41, 41, 43, 45, 45, 47, 47, 47, 49, 50, 51,
        53, 53, 54, 57, 57, 58, 61, 61, 36, 35, 35, 35, 34, 34, 35, 36, 36, 37,
        38, 38, 40, 42, 42, 45, 48, 48, 50, 50, 50, 53, 54, 54, 56, 57, 57, 59,
        60, 61, 64, 64, 36, 35, 35, 35, 34, 34, 35, 36, 36, 37, 38, 38, 40, 42,
        42, 45, 48, 48, 50, 50, 50, 53, 54, 54, 56, 57, 57, 59, 60, 61, 64, 64,
        38, 37, 37, 37, 36, 36, 36, 38, 38, 38, 39, 39, 41, 44, 44, 47, 50, 50,
        51, 52, 52, 55, 56, 56, 58, 59, 60, 62, 63, 64, 67, 67, 39, 39, 38, 38,
        37, 37, 38, 39, 39, 39, 40, 40, 42, 45, 45, 47, 50, 50, 52, 54, 54, 56,
        58, 58, 60, 61, 62, 64, 65, 66, 69, 69, 39, 39, 38, 38, 37, 37, 38, 39,
        39, 39, 40, 40, 42, 45, 45, 47, 50, 50, 52, 54, 54, 56, 58, 58, 60, 61,
        62, 64, 65, 66, 69, 69, 42, 41, 41, 41, 40, 40, 40, 41, 41, 41, 42, 42,
        44, 47, 47, 49, 53, 53, 55, 56, 56, 60, 61, 62, 64, 65, 66, 69, 69, 70,
        73, 73, 44, 43, 42, 42, 41, 41, 41, 42, 42, 42, 42, 42, 44, 47, 47, 50,
        54, 54, 56, 58, 58, 61, 63, 64, 66, 67, 68, 71, 71, 72, 75, 75, 44, 43,
        43, 42, 41, 41, 41, 42, 42, 42, 43, 43, 45, 48, 48, 51, 54, 54, 56, 58,
        58, 62, 64, 64, 66, 67, 68, 71, 72, 73, 76, 76, 47, 46, 45, 45, 44, 44,
        44, 44, 45, 45, 45, 45, 47, 50, 50, 53, 56, 56, 58, 60, 60, 64, 66, 66,
        69, 70, 71, 74, 75, 76, 79, 79, 48, 47, 46, 46, 45, 44, 45, 45, 45, 45,
        46, 46, 47, 51, 51, 53, 57, 57, 59, 61, 61, 65, 67, 67, 70, 71, 72, 75,
        76, 77, 80, 80, 49, 48, 47, 47, 46, 45, 45, 46, 46, 46, 46, 46, 48, 51,
        51, 54, 57, 57, 60, 62, 62, 66, 68, 68, 71, 72, 73, 77, 77, 78, 81, 81,
        53, 51, 51, 51, 49, 49, 49, 49, 49, 49, 49, 49, 51, 54, 54, 57, 59, 59,
        62, 64, 64, 69, 71, 71, 74, 75, 77, 81, 81, 83, 86, 86, 54, 52, 51, 51,
        50, 49, 49, 50, 50, 49, 49, 49, 51, 54, 54, 57, 60, 60, 63, 65, 65, 69,
        71, 72, 75, 76, 77, 81, 82, 83, 87, 87, 55, 53, 53, 52, 51, 50, 50, 51,
        51, 51, 50, 50, 52, 55, 55, 58, 61, 61, 64, 66, 66, 70, 72, 73, 76, 77,
        78, 83, 83, 85, 88, 88, 59, 57, 56, 56, 54, 54, 54, 54, 54, 54, 53, 53,
        55, 58, 58, 61, 64, 64, 67, 69, 69, 73, 75, 76, 79, 80, 81, 86, 87, 88,
        92, 92, 59, 57, 56, 56, 54, 54, 54, 54, 54, 54, 53, 53, 55, 58, 58, 61,
        64, 64, 67, 69, 69, 73, 75, 76, 79, 80, 81, 86, 87, 88, 92, 92,
        /* Size 4x8 */
        32, 32, 37, 52, 32, 33, 36, 49, 32, 34, 38, 49, 34, 37, 44, 54, 35, 38,
        49, 60, 40, 42, 55, 69, 46, 46, 59, 76, 52, 51, 64, 83,
        /* Size 8x4 */
        32, 32, 32, 34, 35, 40, 46, 52, 32, 33, 34, 37, 38, 42, 46, 51, 37, 36,
        38, 44, 49, 55, 59, 64, 52, 49, 49, 54, 60, 69, 76, 83,
        /* Size 8x16 */
        32, 31, 32, 32, 36, 44, 47, 53, 31, 32, 32, 33, 35, 42, 45, 51, 31, 32,
        32, 33, 35, 41, 44, 49, 31, 32, 33, 33, 35, 41, 44, 49, 32, 32, 34, 34,
        36, 42, 45, 50, 32, 33, 35, 36, 38, 42, 45, 49, 32, 33, 35, 36, 40, 44,
        47, 51, 34, 34, 36, 38, 42, 48, 50, 54, 36, 34, 37, 40, 48, 54, 56, 60,
        38, 36, 39, 41, 49, 56, 58, 63, 39, 37, 40, 42, 50, 58, 60, 65, 44, 41,
        42, 45, 53, 63, 66, 71, 47, 44, 45, 47, 56, 66, 69, 75, 49, 46, 47, 48,
        57, 67, 71, 77, 53, 49, 50, 51, 60, 71, 75, 82, 58, 54, 54, 55, 63, 75,
        79, 87,
        /* Size 16x8 */
        32, 31, 31, 31, 32, 32, 32, 34, 36, 38, 39, 44, 47, 49, 53, 58, 31, 32,
        32, 32, 32, 33, 33, 34, 34, 36, 37, 41, 44, 46, 49, 54, 32, 32, 32, 33,
        34, 35, 35, 36, 37, 39, 40, 42, 45, 47, 50, 54, 32, 33, 33, 33, 34, 36,
        36, 38, 40, 41, 42, 45, 47, 48, 51, 55, 36, 35, 35, 35, 36, 38, 40, 42,
        48, 49, 50, 53, 56, 57, 60, 63, 44, 42, 41, 41, 42, 42, 44, 48, 54, 56,
        58, 63, 66, 67, 71, 75, 47, 45, 44, 44, 45, 45, 47, 50, 56, 58, 60, 66,
        69, 71, 75, 79, 53, 51, 49, 49, 50, 49, 51, 54, 60, 63, 65, 71, 75, 77,
        82, 87,
        /* Size 16x32 */
        32, 31, 31, 31, 32, 32, 32, 35, 36, 38, 44, 44, 47, 53, 53, 59, 31, 32,
        32, 32, 32, 32, 33, 35, 35, 37, 43, 43, 46, 52, 52, 57, 31, 32, 32, 32,
        32, 32, 33, 35, 35, 37, 42, 42, 45, 51, 51, 56, 31, 32, 32, 32, 32, 32,
        33, 35, 35, 37, 42, 42, 45, 51, 51, 56, 31, 32, 32, 32, 32, 32, 33, 34,
        35, 36, 41, 41, 44, 49, 49, 54, 31, 32, 32, 32, 32, 33, 33, 34, 34, 36,
        41, 41, 44, 49, 49, 54, 31, 32, 32, 32, 33, 33, 33, 35, 35, 36, 41, 41,
        44, 49, 49, 54, 32, 32, 32, 32, 33, 34, 34, 36, 36, 38, 42, 42, 45, 49,
        49, 54, 32, 32, 32, 33, 34, 34, 34, 36, 36, 38, 42, 42, 45, 50, 50, 54,
        32, 32, 32, 33, 34, 34, 35, 37, 37, 38, 42, 42, 45, 49, 49, 54, 32, 32,
        33, 33, 35, 35, 36, 38, 38, 39, 42, 42, 45, 49, 49, 53, 32, 32, 33, 33,
        35, 35, 36, 38, 38, 39, 42, 42, 45, 49, 49, 53, 32, 33, 33, 33, 35, 36,
        36, 39, 40, 41, 44, 44, 47, 51, 51, 55, 34, 34, 34, 34, 36, 37, 38, 42,
        42, 44, 48, 48, 50, 54, 54, 58, 34, 34, 34, 34, 36, 37, 38, 42, 42, 44,
        48, 48, 50, 54, 54, 58, 35, 34, 34, 34, 37, 37, 39, 44, 45, 46, 50, 50,
        53, 57, 57, 61, 36, 35, 34, 35, 37, 38, 40, 47, 48, 49, 54, 54, 56, 60,
        60, 64, 36, 35, 34, 35, 37, 38, 40, 47, 48, 49, 54, 54, 56, 60, 60, 64,
        38, 37, 36, 37, 39, 40, 41, 48, 49, 51, 56, 56, 58, 63, 63, 67, 39, 38,
        37, 38, 40, 40, 42, 49, 50, 52, 58, 58, 60, 65, 65, 69, 39, 38, 37, 38,
        40, 40, 42, 49, 50, 52, 58, 58, 60, 65, 65, 69, 42, 40, 40, 40, 42, 42,
        44, 51, 52, 55, 61, 61, 64, 69, 69, 73, 44, 42, 41, 41, 42, 43, 45, 52,
        53, 56, 63, 63, 66, 71, 71, 75, 44, 42, 41, 41, 43, 43, 45, 52, 54, 56,
        63, 63, 66, 72, 72, 76, 47, 45, 44, 44, 45, 45, 47, 54, 56, 58, 66, 66,
        69, 75, 75, 79, 48, 46, 45, 45, 46, 46, 48, 55, 56, 59, 67, 67, 70, 76,
        76, 80, 49, 47, 46, 46, 47, 47, 48, 56, 57, 60, 67, 67, 71, 77, 77, 81,
        53, 50, 49, 49, 49, 49, 51, 58, 59, 62, 71, 71, 74, 81, 81, 86, 53, 51,
        49, 49, 50, 50, 51, 59, 60, 63, 71, 71, 75, 82, 82, 87, 55, 52, 51, 51,
        51, 51, 53, 60, 61, 64, 72, 72, 76, 83, 83, 88, 58, 55, 54, 54, 54, 54,
        55, 62, 63, 67, 75, 75, 79, 87, 87, 92, 58, 55, 54, 54, 54, 54, 55, 62,
        63, 67, 75, 75, 79, 87, 87, 92,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 34, 34, 35, 36, 36,
        38, 39, 39, 42, 44, 44, 47, 48, 49, 53, 53, 55, 58, 58, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 37, 38, 38, 40,
        42, 42, 45, 46, 47, 50, 51, 52, 55, 55, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 36, 37, 37, 40, 41, 41, 44, 45,
        46, 49, 49, 51, 54, 54, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
        33, 34, 34, 34, 35, 35, 37, 38, 38, 40, 41, 41, 44, 45, 46, 49, 49, 51,
        54, 54, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 35, 35, 35, 36, 36, 37,
        37, 37, 39, 40, 40, 42, 42, 43, 45, 46, 47, 49, 50, 51, 54, 54, 32, 32,
        32, 32, 32, 33, 33, 34, 34, 34, 35, 35, 36, 37, 37, 37, 38, 38, 40, 40,
        40, 42, 43, 43, 45, 46, 47, 49, 50, 51, 54, 54, 32, 33, 33, 33, 33, 33,
        33, 34, 34, 35, 36, 36, 36, 38, 38, 39, 40, 40, 41, 42, 42, 44, 45, 45,
        47, 48, 48, 51, 51, 53, 55, 55, 35, 35, 35, 35, 34, 34, 35, 36, 36, 37,
        38, 38, 39, 42, 42, 44, 47, 47, 48, 49, 49, 51, 52, 52, 54, 55, 56, 58,
        59, 60, 62, 62, 36, 35, 35, 35, 35, 34, 35, 36, 36, 37, 38, 38, 40, 42,
        42, 45, 48, 48, 49, 50, 50, 52, 53, 54, 56, 56, 57, 59, 60, 61, 63, 63,
        38, 37, 37, 37, 36, 36, 36, 38, 38, 38, 39, 39, 41, 44, 44, 46, 49, 49,
        51, 52, 52, 55, 56, 56, 58, 59, 60, 62, 63, 64, 67, 67, 44, 43, 42, 42,
        41, 41, 41, 42, 42, 42, 42, 42, 44, 48, 48, 50, 54, 54, 56, 58, 58, 61,
        63, 63, 66, 67, 67, 71, 71, 72, 75, 75, 44, 43, 42, 42, 41, 41, 41, 42,
        42, 42, 42, 42, 44, 48, 48, 50, 54, 54, 56, 58, 58, 61, 63, 63, 66, 67,
        67, 71, 71, 72, 75, 75, 47, 46, 45, 45, 44, 44, 44, 45, 45, 45, 45, 45,
        47, 50, 50, 53, 56, 56, 58, 60, 60, 64, 66, 66, 69, 70, 71, 74, 75, 76,
        79, 79, 53, 52, 51, 51, 49, 49, 49, 49, 50, 49, 49, 49, 51, 54, 54, 57,
        60, 60, 63, 65, 65, 69, 71, 72, 75, 76, 77, 81, 82, 83, 87, 87, 53, 52,
        51, 51, 49, 49, 49, 49, 50, 49, 49, 49, 51, 54, 54, 57, 60, 60, 63, 65,
        65, 69, 71, 72, 75, 76, 77, 81, 82, 83, 87, 87, 59, 57, 56, 56, 54, 54,
        54, 54, 54, 54, 53, 53, 55, 58, 58, 61, 64, 64, 67, 69, 69, 73, 75, 76,
        79, 80, 81, 86, 87, 88, 92, 92 },
      { /* Chroma */
        /* Size 4x4 */
        31, 38, 47, 49, 38, 47, 46, 46, 47, 46, 54, 57, 49, 46, 57, 66,
        /* Size 8x8 */
        31, 31, 35, 42, 48, 47, 49, 51, 31, 32, 36, 42, 46, 45, 46, 48, 35, 36,
        41, 45, 47, 45, 46, 48, 42, 42, 45, 48, 50, 49, 50, 51, 48, 46, 47, 50,
        53, 53, 54, 54, 47, 45, 45, 49, 53, 57, 59, 60, 49, 46, 46, 50, 54, 59,
        61, 64, 51, 48, 48, 51, 54, 60, 64, 68,
        /* Size 16x16 */
        32, 31, 30, 31, 33, 36, 38, 41, 49, 49, 48, 49, 50, 51, 52, 54, 31, 31,
        31, 32, 34, 38, 40, 42, 47, 47, 47, 47, 48, 48, 50, 52, 30, 31, 31, 32,
        35, 39, 41, 42, 46, 46, 46, 45, 46, 47, 48, 50, 31, 32, 32, 33, 36, 40,
        41, 43, 46, 46, 45, 45, 46, 46, 47, 49, 33, 34, 35, 36, 39, 43, 44, 45,
        47, 46, 46, 45, 46, 47, 47, 49, 36, 38, 39, 40, 43, 47, 47, 47, 48, 47,
        46, 45, 46, 46, 47, 48, 38, 40, 41, 41, 44, 47, 47, 48, 49, 48, 48, 47,
        47, 47, 48, 49, 41, 42, 42, 43, 45, 47, 48, 48, 50, 50, 49, 49, 50, 50,
        50, 52, 49, 47, 46, 46, 47, 48, 49, 50, 53, 53, 53, 53, 54, 54, 54, 55,
        49, 47, 46, 46, 46, 47, 48, 50, 53, 53, 54, 55, 55, 55, 56, 57, 48, 47,
        46, 45, 46, 46, 48, 49, 53, 54, 54, 55, 56, 56, 57, 58, 49, 47, 45, 45,
        45, 45, 47, 49, 53, 55, 55, 58, 59, 60, 61, 62, 50, 48, 46, 46, 46, 46,
        47, 50, 54, 55, 56, 59, 61, 61, 63, 64, 51, 48, 47, 46, 47, 46, 47, 50,
        54, 55, 56, 60, 61, 62, 64, 66, 52, 50, 48, 47, 47, 47, 48, 50, 54, 56,
        57, 61, 63, 64, 66, 68, 54, 52, 50, 49, 49, 48, 49, 52, 55, 57, 58, 62,
        64, 66, 68, 71,
        /* Size 32x32 */
        32, 31, 31, 31, 30, 30, 31, 33, 33, 34, 36, 36, 38, 41, 41, 45, 49, 49,
        49, 48, 48, 49, 49, 49, 50, 50, 51, 52, 52, 53, 54, 54, 31, 31, 31, 31,
        31, 31, 31, 34, 34, 35, 38, 38, 39, 42, 42, 45, 48, 48, 47, 47, 47, 47,
        47, 47, 49, 49, 49, 50, 50, 51, 53, 53, 31, 31, 31, 31, 31, 31, 32, 34,
        34, 35, 38, 38, 40, 42, 42, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48,
        48, 49, 50, 50, 52, 52, 31, 31, 31, 31, 31, 31, 32, 34, 34, 36, 38, 38,
        40, 42, 42, 45, 47, 47, 47, 47, 47, 47, 46, 47, 48, 48, 48, 49, 49, 50,
        52, 52, 30, 31, 31, 31, 31, 31, 32, 35, 35, 36, 39, 39, 41, 42, 42, 44,
        46, 46, 46, 46, 46, 45, 45, 45, 46, 47, 47, 48, 48, 48, 50, 50, 30, 31,
        31, 31, 31, 32, 32, 35, 35, 36, 40, 40, 41, 42, 42, 44, 46, 46, 46, 45,
        45, 45, 45, 45, 46, 46, 46, 47, 47, 48, 49, 49, 31, 31, 32, 32, 32, 32,
        33, 35, 36, 37, 40, 40, 41, 43, 43, 44, 46, 46, 46, 45, 45, 45, 45, 45,
        46, 46, 46, 47, 47, 48, 49, 49, 33, 34, 34, 34, 35, 35, 35, 38, 38, 40,
        43, 43, 43, 44, 44, 46, 47, 47, 46, 46, 46, 45, 45, 45, 46, 46, 47, 47,
        47, 48, 49, 49, 33, 34, 34, 34, 35, 35, 36, 38, 39, 40, 43, 43, 44, 45,
        45, 46, 47, 47, 46, 46, 46, 45, 45, 45, 46, 46, 47, 47, 47, 48, 49, 49,
        34, 35, 35, 36, 36, 36, 37, 40, 40, 41, 44, 44, 45, 45, 45, 46, 47, 47,
        47, 46, 46, 45, 45, 45, 46, 46, 46, 47, 47, 48, 49, 49, 36, 38, 38, 38,
        39, 40, 40, 43, 43, 44, 47, 47, 47, 47, 47, 47, 48, 48, 47, 46, 46, 45,
        45, 45, 46, 46, 46, 46, 47, 47, 48, 48, 36, 38, 38, 38, 39, 40, 40, 43,
        43, 44, 47, 47, 47, 47, 47, 47, 48, 48, 47, 46, 46, 45, 45, 45, 46, 46,
        46, 46, 47, 47, 48, 48, 38, 39, 40, 40, 41, 41, 41, 43, 44, 45, 47, 47,
        47, 48, 48, 48, 49, 49, 48, 48, 48, 47, 47, 47, 47, 47, 47, 48, 48, 48,
        49, 49, 41, 42, 42, 42, 42, 42, 43, 44, 45, 45, 47, 47, 48, 48, 48, 49,
        50, 50, 50, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 51, 52, 52, 41, 42,
        42, 42, 42, 42, 43, 44, 45, 45, 47, 47, 48, 48, 48, 49, 50, 50, 50, 49,
        49, 49, 49, 49, 50, 50, 50, 50, 50, 51, 52, 52, 45, 45, 45, 45, 44, 44,
        44, 46, 46, 46, 47, 47, 48, 49, 49, 50, 51, 51, 51, 51, 51, 51, 51, 51,
        52, 52, 52, 52, 52, 52, 53, 53, 49, 48, 47, 47, 46, 46, 46, 47, 47, 47,
        48, 48, 49, 50, 50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54,
        54, 54, 55, 55, 49, 48, 47, 47, 46, 46, 46, 47, 47, 47, 48, 48, 49, 50,
        50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 55, 55,
        49, 47, 47, 47, 46, 46, 46, 46, 46, 47, 47, 47, 48, 50, 50, 51, 53, 53,
        53, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, 56, 57, 57, 48, 47, 47, 47,
        46, 45, 45, 46, 46, 46, 46, 46, 48, 49, 49, 51, 53, 53, 54, 54, 54, 55,
        55, 56, 56, 56, 56, 57, 57, 58, 58, 58, 48, 47, 47, 47, 46, 45, 45, 46,
        46, 46, 46, 46, 48, 49, 49, 51, 53, 53, 54, 54, 54, 55, 55, 56, 56, 56,
        56, 57, 57, 58, 58, 58, 49, 47, 47, 47, 45, 45, 45, 45, 45, 45, 45, 45,
        47, 49, 49, 51, 53, 53, 54, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 60,
        61, 61, 49, 47, 47, 46, 45, 45, 45, 45, 45, 45, 45, 45, 47, 49, 49, 51,
        53, 53, 55, 55, 55, 57, 58, 58, 59, 60, 60, 61, 61, 61, 62, 62, 49, 47,
        47, 47, 45, 45, 45, 45, 45, 45, 45, 45, 47, 49, 49, 51, 53, 53, 55, 56,
        56, 58, 58, 59, 59, 60, 60, 61, 61, 62, 63, 63, 50, 49, 48, 48, 46, 46,
        46, 46, 46, 46, 46, 46, 47, 50, 50, 52, 54, 54, 55, 56, 56, 58, 59, 59,
        61, 61, 61, 63, 63, 63, 64, 64, 50, 49, 48, 48, 47, 46, 46, 46, 46, 46,
        46, 46, 47, 50, 50, 52, 54, 54, 55, 56, 56, 59, 60, 60, 61, 61, 62, 63,
        63, 64, 65, 65, 51, 49, 48, 48, 47, 46, 46, 47, 47, 46, 46, 46, 47, 50,
        50, 52, 54, 54, 55, 56, 56, 59, 60, 60, 61, 62, 62, 64, 64, 64, 66, 66,
        52, 50, 49, 49, 48, 47, 47, 47, 47, 47, 46, 46, 48, 50, 50, 52, 54, 54,
        56, 57, 57, 60, 61, 61, 63, 63, 64, 66, 66, 67, 68, 68, 52, 50, 50, 49,
        48, 47, 47, 47, 47, 47, 47, 47, 48, 50, 50, 52, 54, 54, 56, 57, 57, 60,
        61, 61, 63, 63, 64, 66, 66, 67, 68, 68, 53, 51, 50, 50, 48, 48, 48, 48,
        48, 48, 47, 47, 48, 51, 51, 52, 54, 54, 56, 58, 58, 60, 61, 62, 63, 64,
        64, 67, 67, 68, 69, 69, 54, 53, 52, 52, 50, 49, 49, 49, 49, 49, 48, 48,
        49, 52, 52, 53, 55, 55, 57, 58, 58, 61, 62, 63, 64, 65, 66, 68, 68, 69,
        71, 71, 54, 53, 52, 52, 50, 49, 49, 49, 49, 49, 48, 48, 49, 52, 52, 53,
        55, 55, 57, 58, 58, 61, 62, 63, 64, 65, 66, 68, 68, 69, 71, 71,
        /* Size 4x8 */
        31, 38, 47, 50, 31, 40, 46, 48, 36, 44, 47, 47, 42, 47, 50, 50, 47, 48,
        53, 54, 46, 46, 54, 60, 48, 46, 55, 64, 50, 48, 56, 67,
        /* Size 8x4 */
        31, 31, 36, 42, 47, 46, 48, 50, 38, 40, 44, 47, 48, 46, 46, 48, 47, 46,
        47, 50, 53, 54, 55, 56, 50, 48, 47, 50, 54, 60, 64, 67,
        /* Size 8x16 */
        32, 31, 35, 38, 48, 49, 50, 52, 31, 31, 37, 40, 47, 47, 48, 50, 30, 32,
        38, 40, 46, 45, 46, 48, 31, 33, 38, 41, 46, 45, 46, 48, 33, 36, 41, 44,
        47, 46, 46, 47, 37, 40, 45, 47, 47, 45, 46, 47, 39, 41, 46, 47, 48, 47,
        47, 48, 42, 43, 46, 48, 50, 49, 50, 50, 49, 46, 48, 49, 53, 53, 54, 54,
        48, 46, 47, 48, 53, 55, 55, 56, 48, 46, 46, 48, 53, 56, 56, 57, 49, 45,
        45, 47, 53, 58, 59, 61, 50, 46, 46, 48, 54, 59, 61, 63, 51, 47, 47, 48,
        54, 60, 61, 64, 52, 48, 47, 48, 54, 61, 63, 66, 54, 50, 49, 50, 55, 62,
        65, 68,
        /* Size 16x8 */
        32, 31, 30, 31, 33, 37, 39, 42, 49, 48, 48, 49, 50, 51, 52, 54, 31, 31,
        32, 33, 36, 40, 41, 43, 46, 46, 46, 45, 46, 47, 48, 50, 35, 37, 38, 38,
        41, 45, 46, 46, 48, 47, 46, 45, 46, 47, 47, 49, 38, 40, 40, 41, 44, 47,
        47, 48, 49, 48, 48, 47, 48, 48, 48, 50, 48, 47, 46, 46, 47, 47, 48, 50,
        53, 53, 53, 53, 54, 54, 54, 55, 49, 47, 45, 45, 46, 45, 47, 49, 53, 55,
        56, 58, 59, 60, 61, 62, 50, 48, 46, 46, 46, 46, 47, 50, 54, 55, 56, 59,
        61, 61, 63, 65, 52, 50, 48, 48, 47, 47, 48, 50, 54, 56, 57, 61, 63, 64,
        66, 68,
        /* Size 16x32 */
        32, 31, 31, 31, 35, 37, 38, 47, 48, 48, 49, 49, 50, 52, 52, 54, 31, 31,
        31, 32, 36, 38, 39, 46, 47, 47, 48, 48, 49, 50, 50, 53, 31, 31, 31, 32,
        37, 38, 40, 46, 47, 47, 47, 47, 48, 50, 50, 52, 31, 31, 31, 32, 37, 38,
        40, 46, 47, 47, 47, 47, 48, 50, 50, 52, 30, 31, 32, 32, 38, 39, 40, 45,
        46, 46, 45, 45, 46, 48, 48, 50, 30, 31, 32, 33, 38, 40, 41, 45, 46, 46,
        45, 45, 46, 48, 48, 50, 31, 32, 33, 33, 38, 40, 41, 45, 46, 46, 45, 45,
        46, 48, 48, 50, 33, 35, 35, 36, 41, 43, 43, 46, 47, 46, 45, 45, 46, 47,
        47, 49, 33, 35, 36, 36, 41, 43, 44, 46, 47, 46, 46, 46, 46, 47, 47, 49,
        34, 36, 37, 37, 42, 44, 45, 47, 47, 47, 45, 45, 46, 47, 47, 49, 37, 39,
        40, 41, 45, 47, 47, 47, 47, 47, 45, 45, 46, 47, 47, 48, 37, 39, 40, 41,
        45, 47, 47, 47, 47, 47, 45, 45, 46, 47, 47, 48, 39, 40, 41, 42, 46, 47,
        47, 48, 48, 48, 47, 47, 47, 48, 48, 50, 42, 42, 43, 43, 46, 47, 48, 50,
        50, 50, 49, 49, 50, 50, 50, 52, 42, 42, 43, 43, 46, 47, 48, 50, 50, 50,
        49, 49, 50, 50, 50, 52, 45, 45, 44, 45, 47, 47, 48, 51, 51, 51, 51, 51,
        52, 52, 52, 54, 49, 47, 46, 47, 48, 48, 49, 52, 53, 53, 53, 53, 54, 54,
        54, 55, 49, 47, 46, 47, 48, 48, 49, 52, 53, 53, 53, 53, 54, 54, 54, 55,
        48, 47, 46, 46, 47, 47, 48, 52, 53, 53, 55, 55, 55, 56, 56, 57, 48, 46,
        46, 46, 46, 47, 48, 52, 53, 54, 56, 56, 56, 57, 57, 59, 48, 46, 46, 46,
        46, 47, 48, 52, 53, 54, 56, 56, 56, 57, 57, 59, 49, 46, 45, 45, 46, 46,
        47, 52, 53, 54, 57, 57, 58, 60, 60, 61, 49, 46, 45, 45, 45, 46, 47, 52,
        53, 55, 58, 58, 59, 61, 61, 62, 49, 46, 45, 45, 46, 46, 47, 52, 53, 55,
        58, 58, 60, 61, 61, 63, 50, 47, 46, 46, 46, 46, 48, 53, 54, 55, 59, 59,
        61, 63, 63, 65, 50, 48, 46, 46, 46, 46, 48, 53, 54, 55, 59, 59, 61, 64,
        64, 65, 51, 48, 47, 47, 47, 47, 48, 53, 54, 55, 60, 60, 61, 64, 64, 66,
        52, 49, 48, 48, 47, 47, 48, 53, 54, 56, 61, 61, 63, 66, 66, 68, 52, 49,
        48, 48, 47, 47, 48, 53, 54, 56, 61, 61, 63, 66, 66, 68, 53, 50, 48, 48,
        48, 48, 49, 54, 54, 56, 61, 61, 63, 67, 67, 69, 54, 51, 50, 50, 49, 49,
        50, 55, 55, 57, 62, 62, 65, 68, 68, 71, 54, 51, 50, 50, 49, 49, 50, 55,
        55, 57, 62, 62, 65, 68, 68, 71,
        /* Size 32x16 */
        32, 31, 31, 31, 30, 30, 31, 33, 33, 34, 37, 37, 39, 42, 42, 45, 49, 49,
        48, 48, 48, 49, 49, 49, 50, 50, 51, 52, 52, 53, 54, 54, 31, 31, 31, 31,
        31, 31, 32, 35, 35, 36, 39, 39, 40, 42, 42, 45, 47, 47, 47, 46, 46, 46,
        46, 46, 47, 48, 48, 49, 49, 50, 51, 51, 31, 31, 31, 31, 32, 32, 33, 35,
        36, 37, 40, 40, 41, 43, 43, 44, 46, 46, 46, 46, 46, 45, 45, 45, 46, 46,
        47, 48, 48, 48, 50, 50, 31, 32, 32, 32, 32, 33, 33, 36, 36, 37, 41, 41,
        42, 43, 43, 45, 47, 47, 46, 46, 46, 45, 45, 45, 46, 46, 47, 48, 48, 48,
        50, 50, 35, 36, 37, 37, 38, 38, 38, 41, 41, 42, 45, 45, 46, 46, 46, 47,
        48, 48, 47, 46, 46, 46, 45, 46, 46, 46, 47, 47, 47, 48, 49, 49, 37, 38,
        38, 38, 39, 40, 40, 43, 43, 44, 47, 47, 47, 47, 47, 47, 48, 48, 47, 47,
        47, 46, 46, 46, 46, 46, 47, 47, 47, 48, 49, 49, 38, 39, 40, 40, 40, 41,
        41, 43, 44, 45, 47, 47, 47, 48, 48, 48, 49, 49, 48, 48, 48, 47, 47, 47,
        48, 48, 48, 48, 48, 49, 50, 50, 47, 46, 46, 46, 45, 45, 45, 46, 46, 47,
        47, 47, 48, 50, 50, 51, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53,
        53, 54, 55, 55, 48, 47, 47, 47, 46, 46, 46, 47, 47, 47, 47, 47, 48, 50,
        50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 55, 55,
        48, 47, 47, 47, 46, 46, 46, 46, 46, 47, 47, 47, 48, 50, 50, 51, 53, 53,
        53, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, 56, 57, 57, 49, 48, 47, 47,
        45, 45, 45, 45, 46, 45, 45, 45, 47, 49, 49, 51, 53, 53, 55, 56, 56, 57,
        58, 58, 59, 59, 60, 61, 61, 61, 62, 62, 49, 48, 47, 47, 45, 45, 45, 45,
        46, 45, 45, 45, 47, 49, 49, 51, 53, 53, 55, 56, 56, 57, 58, 58, 59, 59,
        60, 61, 61, 61, 62, 62, 50, 49, 48, 48, 46, 46, 46, 46, 46, 46, 46, 46,
        47, 50, 50, 52, 54, 54, 55, 56, 56, 58, 59, 60, 61, 61, 61, 63, 63, 63,
        65, 65, 52, 50, 50, 50, 48, 48, 48, 47, 47, 47, 47, 47, 48, 50, 50, 52,
        54, 54, 56, 57, 57, 60, 61, 61, 63, 64, 64, 66, 66, 67, 68, 68, 52, 50,
        50, 50, 48, 48, 48, 47, 47, 47, 47, 47, 48, 50, 50, 52, 54, 54, 56, 57,
        57, 60, 61, 61, 63, 64, 64, 66, 66, 67, 68, 68, 54, 53, 52, 52, 50, 50,
        50, 49, 49, 49, 48, 48, 50, 52, 52, 54, 55, 55, 57, 59, 59, 61, 62, 63,
        65, 65, 66, 68, 68, 69, 71, 71 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 32, 35, 43, 32, 34, 37, 43, 35, 37, 48, 54, 43, 43, 54, 65,
        /* Size 8x8 */
        31, 31, 32, 32, 34, 37, 43, 47, 31, 32, 32, 32, 34, 36, 41, 44, 32, 32,
        33, 34, 35, 38, 42, 45, 32, 32, 34, 35, 37, 39, 42, 46, 34, 34, 35, 37,
        41, 45, 49, 52, 37, 36, 38, 39, 45, 51, 56, 59, 43, 41, 42, 42, 49, 56,
        63, 67, 47, 44, 45, 46, 52, 59, 67, 71,
        /* Size 16x16 */
        32, 31, 31, 31, 31, 31, 32, 32, 34, 35, 36, 39, 41, 44, 47, 48, 31, 32,
        32, 32, 32, 32, 32, 33, 34, 35, 35, 38, 40, 42, 45, 46, 31, 32, 32, 32,
        32, 32, 32, 33, 34, 34, 35, 38, 39, 42, 45, 45, 31, 32, 32, 32, 32, 32,
        32, 33, 33, 34, 34, 37, 38, 41, 44, 44, 31, 32, 32, 32, 33, 33, 33, 34,
        35, 36, 36, 39, 40, 42, 44, 45, 31, 32, 32, 32, 33, 33, 34, 34, 35, 36,
        36, 39, 40, 42, 45, 45, 32, 32, 32, 32, 33, 34, 35, 36, 37, 38, 38, 40,
        41, 42, 45, 46, 32, 33, 33, 33, 34, 34, 36, 36, 38, 39, 40, 42, 43, 44,
        47, 47, 34, 34, 34, 33, 35, 35, 37, 38, 39, 42, 42, 45, 46, 47, 50, 51,
        35, 35, 34, 34, 36, 36, 38, 39, 42, 46, 47, 49, 50, 52, 55, 55, 36, 35,
        35, 34, 36, 36, 38, 40, 42, 47, 48, 50, 52, 54, 56, 57, 39, 38, 38, 37,
        39, 39, 40, 42, 45, 49, 50, 54, 55, 58, 60, 61, 41, 40, 39, 38, 40, 40,
        41, 43, 46, 50, 52, 55, 57, 60, 62, 63, 44, 42, 42, 41, 42, 42, 42, 44,
        47, 52, 54, 58, 60, 63, 66, 67, 47, 45, 45, 44, 44, 45, 45, 47, 50, 55,
        56, 60, 62, 66, 69, 70, 48, 46, 45, 44, 45, 45, 46, 47, 51, 55, 57, 61,
        63, 67, 70, 71,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 34,
        35, 36, 36, 38, 39, 39, 41, 44, 44, 45, 47, 48, 48, 51, 31, 31, 31, 31,
        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 35, 37,
        39, 39, 40, 43, 43, 44, 46, 47, 47, 50, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 35, 37, 38, 38, 40, 42,
        42, 43, 45, 46, 46, 49, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 34, 34, 34, 35, 35, 35, 37, 38, 38, 40, 42, 42, 43, 45, 46,
        46, 49, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34,
        34, 34, 34, 35, 35, 36, 38, 38, 39, 42, 42, 42, 45, 45, 45, 48, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34,
        34, 36, 37, 37, 38, 41, 41, 41, 44, 44, 44, 47, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 36, 37, 37,
        38, 41, 41, 41, 44, 44, 44, 47, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 36, 38, 38, 39, 41, 41, 42,
        44, 45, 45, 47, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
        34, 35, 35, 35, 36, 36, 36, 37, 39, 39, 40, 42, 42, 42, 44, 45, 45, 48,
        31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 35, 35,
        36, 36, 36, 38, 39, 39, 40, 42, 42, 42, 45, 45, 45, 48, 31, 32, 32, 32,
        32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 38,
        39, 39, 40, 42, 42, 42, 45, 45, 45, 48, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 33, 33, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 39, 40, 40, 41, 42,
        42, 43, 45, 45, 45, 48, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 35,
        35, 35, 36, 37, 37, 37, 38, 38, 38, 39, 40, 40, 41, 42, 42, 43, 45, 46,
        46, 48, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 35, 35, 35, 36, 37,
        37, 37, 38, 38, 38, 39, 40, 40, 41, 42, 42, 43, 45, 46, 46, 48, 32, 33,
        33, 33, 33, 33, 33, 33, 34, 34, 34, 35, 36, 36, 36, 38, 38, 38, 39, 40,
        40, 41, 42, 42, 43, 44, 44, 45, 47, 47, 47, 50, 34, 34, 34, 34, 34, 33,
        33, 34, 35, 35, 35, 36, 37, 37, 38, 39, 39, 40, 42, 42, 42, 44, 45, 45,
        46, 47, 47, 48, 50, 51, 51, 53, 34, 34, 34, 34, 34, 33, 33, 34, 35, 35,
        35, 36, 37, 37, 38, 39, 39, 40, 42, 42, 42, 44, 45, 45, 46, 47, 47, 48,
        50, 51, 51, 53, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 36, 37, 37,
        38, 40, 40, 41, 43, 44, 44, 45, 46, 46, 47, 49, 49, 49, 51, 52, 52, 54,
        35, 35, 35, 35, 34, 34, 34, 34, 36, 36, 36, 37, 38, 38, 39, 42, 42, 43,
        46, 47, 47, 48, 49, 49, 50, 52, 52, 53, 55, 55, 55, 57, 36, 35, 35, 35,
        35, 34, 34, 35, 36, 36, 36, 37, 38, 38, 40, 42, 42, 44, 47, 48, 48, 50,
        50, 50, 52, 54, 54, 54, 56, 57, 57, 58, 36, 35, 35, 35, 35, 34, 34, 35,
        36, 36, 36, 37, 38, 38, 40, 42, 42, 44, 47, 48, 48, 50, 50, 50, 52, 54,
        54, 54, 56, 57, 57, 58, 38, 37, 37, 37, 36, 36, 36, 36, 37, 38, 38, 39,
        39, 39, 41, 44, 44, 45, 48, 50, 50, 51, 52, 52, 54, 56, 56, 57, 58, 59,
        59, 61, 39, 39, 38, 38, 38, 37, 37, 38, 39, 39, 39, 40, 40, 40, 42, 45,
        45, 46, 49, 50, 50, 52, 54, 54, 55, 58, 58, 58, 60, 61, 61, 63, 39, 39,
        38, 38, 38, 37, 37, 38, 39, 39, 39, 40, 40, 40, 42, 45, 45, 46, 49, 50,
        50, 52, 54, 54, 55, 58, 58, 58, 60, 61, 61, 63, 41, 40, 40, 40, 39, 38,
        38, 39, 40, 40, 40, 41, 41, 41, 43, 46, 46, 47, 50, 52, 52, 54, 55, 55,
        57, 60, 60, 60, 62, 63, 63, 66, 44, 43, 42, 42, 42, 41, 41, 41, 42, 42,
        42, 42, 42, 42, 44, 47, 47, 49, 52, 54, 54, 56, 58, 58, 60, 63, 63, 64,
        66, 67, 67, 69, 44, 43, 42, 42, 42, 41, 41, 41, 42, 42, 42, 42, 42, 42,
        44, 47, 47, 49, 52, 54, 54, 56, 58, 58, 60, 63, 63, 64, 66, 67, 67, 69,
        45, 44, 43, 43, 42, 41, 41, 42, 42, 42, 42, 43, 43, 43, 45, 48, 48, 49,
        53, 54, 54, 57, 58, 58, 60, 64, 64, 65, 67, 68, 68, 70, 47, 46, 45, 45,
        45, 44, 44, 44, 44, 45, 45, 45, 45, 45, 47, 50, 50, 51, 55, 56, 56, 58,
        60, 60, 62, 66, 66, 67, 69, 70, 70, 73, 48, 47, 46, 46, 45, 44, 44, 45,
        45, 45, 45, 45, 46, 46, 47, 51, 51, 52, 55, 57, 57, 59, 61, 61, 63, 67,
        67, 68, 70, 71, 71, 74, 48, 47, 46, 46, 45, 44, 44, 45, 45, 45, 45, 45,
        46, 46, 47, 51, 51, 52, 55, 57, 57, 59, 61, 61, 63, 67, 67, 68, 70, 71,
        71, 74, 51, 50, 49, 49, 48, 47, 47, 47, 48, 48, 48, 48, 48, 48, 50, 53,
        53, 54, 57, 58, 58, 61, 63, 63, 66, 69, 69, 70, 73, 74, 74, 77,
        /* Size 4x8 */
        31, 32, 35, 43, 32, 33, 34, 41, 32, 34, 36, 42, 32, 35, 38, 42, 34, 37,
        43, 49, 37, 40, 49, 56, 42, 43, 53, 63, 46, 46, 56, 67,
        /* Size 8x4 */
        31, 32, 32, 32, 34, 37, 42, 46, 32, 33, 34, 35, 37, 40, 43, 46, 35, 34,
        36, 38, 43, 49, 53, 56, 43, 41, 42, 42, 49, 56, 63, 67,
        /* Size 8x16 */
        32, 31, 31, 32, 35, 36, 44, 47, 31, 32, 32, 32, 35, 35, 42, 45, 31, 32,
        32, 32, 34, 35, 41, 45, 31, 32, 32, 33, 34, 34, 41, 44, 31, 32, 33, 34,
        35, 36, 42, 44, 32, 32, 33, 34, 36, 36, 42, 45, 32, 33, 34, 35, 37, 38,
        42, 45, 32, 33, 34, 36, 39, 40, 44, 47, 34, 34, 35, 37, 41, 42, 48, 50,
        35, 34, 36, 38, 45, 47, 52, 55, 36, 34, 36, 38, 46, 48, 54, 56, 39, 37,
        39, 40, 48, 50, 58, 60, 41, 39, 40, 41, 49, 51, 60, 62, 44, 41, 42, 43,
        51, 53, 63, 66, 47, 44, 44, 45, 53, 56, 66, 69, 48, 45, 45, 46, 54, 56,
        67, 70,
        /* Size 16x8 */
        32, 31, 31, 31, 31, 32, 32, 32, 34, 35, 36, 39, 41, 44, 47, 48, 31, 32,
        32, 32, 32, 32, 33, 33, 34, 34, 34, 37, 39, 41, 44, 45, 31, 32, 32, 32,
        33, 33, 34, 34, 35, 36, 36, 39, 40, 42, 44, 45, 32, 32, 32, 33, 34, 34,
        35, 36, 37, 38, 38, 40, 41, 43, 45, 46, 35, 35, 34, 34, 35, 36, 37, 39,
        41, 45, 46, 48, 49, 51, 53, 54, 36, 35, 35, 34, 36, 36, 38, 40, 42, 47,
        48, 50, 51, 53, 56, 56, 44, 42, 41, 41, 42, 42, 42, 44, 48, 52, 54, 58,
        60, 63, 66, 67, 47, 45, 45, 44, 44, 45, 45, 47, 50, 55, 56, 60, 62, 66,
        69, 70,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 32, 32, 32, 35, 36, 36, 40, 44, 44, 47, 53, 31, 31,
        32, 32, 32, 32, 32, 33, 35, 35, 35, 39, 43, 43, 46, 52, 31, 32, 32, 32,
        32, 32, 32, 33, 35, 35, 35, 39, 42, 42, 45, 51, 31, 32, 32, 32, 32, 32,
        32, 33, 35, 35, 35, 39, 42, 42, 45, 51, 31, 32, 32, 32, 32, 32, 32, 33,
        34, 35, 35, 39, 41, 41, 45, 50, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34,
        34, 38, 41, 41, 44, 49, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 38,
        41, 41, 44, 49, 31, 32, 32, 32, 32, 33, 33, 33, 34, 35, 35, 38, 41, 41,
        44, 49, 31, 32, 32, 32, 33, 34, 34, 34, 35, 36, 36, 39, 42, 42, 44, 49,
        32, 32, 32, 32, 33, 34, 34, 34, 36, 36, 36, 39, 42, 42, 45, 50, 32, 32,
        32, 32, 33, 34, 34, 34, 36, 36, 36, 39, 42, 42, 45, 50, 32, 32, 32, 32,
        33, 35, 35, 35, 37, 37, 37, 40, 42, 42, 45, 49, 32, 32, 33, 33, 34, 35,
        35, 36, 37, 38, 38, 41, 42, 42, 45, 49, 32, 32, 33, 33, 34, 35, 35, 36,
        37, 38, 38, 41, 42, 42, 45, 49, 32, 33, 33, 33, 34, 36, 36, 36, 39, 40,
        40, 42, 44, 44, 47, 51, 34, 34, 34, 34, 35, 37, 37, 38, 41, 42, 42, 45,
        48, 48, 50, 54, 34, 34, 34, 34, 35, 37, 37, 38, 41, 42, 42, 45, 48, 48,
        50, 54, 34, 34, 34, 34, 35, 37, 37, 38, 42, 43, 43, 46, 49, 49, 51, 55,
        35, 35, 34, 34, 36, 38, 38, 39, 45, 47, 47, 50, 52, 52, 55, 59, 36, 35,
        34, 34, 36, 38, 38, 40, 46, 48, 48, 51, 54, 54, 56, 60, 36, 35, 34, 34,
        36, 38, 38, 40, 46, 48, 48, 51, 54, 54, 56, 60, 38, 37, 36, 36, 37, 40,
        40, 41, 47, 49, 49, 53, 56, 56, 58, 63, 39, 38, 37, 37, 39, 40, 40, 42,
        48, 50, 50, 54, 58, 58, 60, 65, 39, 38, 37, 37, 39, 40, 40, 42, 48, 50,
        50, 54, 58, 58, 60, 65, 41, 40, 39, 39, 40, 41, 41, 43, 49, 51, 51, 56,
        60, 60, 62, 67, 44, 42, 41, 41, 42, 43, 43, 45, 51, 53, 53, 59, 63, 63,
        66, 71, 44, 42, 41, 41, 42, 43, 43, 45, 51, 53, 53, 59, 63, 63, 66, 71,
        44, 43, 42, 42, 42, 43, 43, 45, 51, 54, 54, 59, 64, 64, 67, 72, 47, 45,
        44, 44, 44, 45, 45, 47, 53, 56, 56, 61, 66, 66, 69, 75, 48, 46, 45, 45,
        45, 46, 46, 48, 54, 56, 56, 62, 67, 67, 70, 76, 48, 46, 45, 45, 45, 46,
        46, 48, 54, 56, 56, 62, 67, 67, 70, 76, 51, 49, 47, 47, 48, 48, 48, 50,
        56, 58, 58, 64, 69, 69, 73, 79,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 34, 34, 34,
        35, 36, 36, 38, 39, 39, 41, 44, 44, 44, 47, 48, 48, 51, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 35, 37,
        38, 38, 40, 42, 42, 43, 45, 46, 46, 49, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 34, 36, 37, 37, 39, 41,
        41, 42, 44, 45, 45, 47, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        33, 33, 33, 34, 34, 34, 34, 34, 34, 36, 37, 37, 39, 41, 41, 42, 44, 45,
        45, 47, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35,
        35, 35, 36, 36, 36, 37, 39, 39, 40, 42, 42, 42, 44, 45, 45, 48, 32, 32,
        32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 38, 38,
        38, 40, 40, 40, 41, 43, 43, 43, 45, 46, 46, 48, 32, 32, 32, 32, 32, 33,
        33, 33, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 38, 38, 38, 40, 40, 40,
        41, 43, 43, 43, 45, 46, 46, 48, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34,
        34, 35, 36, 36, 36, 38, 38, 38, 39, 40, 40, 41, 42, 42, 43, 45, 45, 45,
        47, 48, 48, 50, 35, 35, 35, 35, 34, 34, 34, 34, 35, 36, 36, 37, 37, 37,
        39, 41, 41, 42, 45, 46, 46, 47, 48, 48, 49, 51, 51, 51, 53, 54, 54, 56,
        36, 35, 35, 35, 35, 34, 34, 35, 36, 36, 36, 37, 38, 38, 40, 42, 42, 43,
        47, 48, 48, 49, 50, 50, 51, 53, 53, 54, 56, 56, 56, 58, 36, 35, 35, 35,
        35, 34, 34, 35, 36, 36, 36, 37, 38, 38, 40, 42, 42, 43, 47, 48, 48, 49,
        50, 50, 51, 53, 53, 54, 56, 56, 56, 58, 40, 39, 39, 39, 39, 38, 38, 38,
        39, 39, 39, 40, 41, 41, 42, 45, 45, 46, 50, 51, 51, 53, 54, 54, 56, 59,
        59, 59, 61, 62, 62, 64, 44, 43, 42, 42, 41, 41, 41, 41, 42, 42, 42, 42,
        42, 42, 44, 48, 48, 49, 52, 54, 54, 56, 58, 58, 60, 63, 63, 64, 66, 67,
        67, 69, 44, 43, 42, 42, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 44, 48,
        48, 49, 52, 54, 54, 56, 58, 58, 60, 63, 63, 64, 66, 67, 67, 69, 47, 46,
        45, 45, 45, 44, 44, 44, 44, 45, 45, 45, 45, 45, 47, 50, 50, 51, 55, 56,
        56, 58, 60, 60, 62, 66, 66, 67, 69, 70, 70, 73, 53, 52, 51, 51, 50, 49,
        49, 49, 49, 50, 50, 49, 49, 49, 51, 54, 54, 55, 59, 60, 60, 63, 65, 65,
        67, 71, 71, 72, 75, 76, 76, 79 },
      { /* Chroma */
        /* Size 4x4 */
        31, 37, 47, 47, 37, 44, 47, 45, 47, 47, 53, 53, 47, 45, 53, 59,
        /* Size 8x8 */
        31, 31, 34, 37, 43, 48, 47, 49, 31, 32, 35, 40, 43, 46, 45, 46, 34, 35,
        39, 43, 45, 46, 45, 46, 37, 40, 43, 47, 47, 47, 45, 46, 43, 43, 45, 47,
        49, 50, 50, 50, 48, 46, 46, 47, 50, 53, 55, 55, 47, 45, 45, 45, 50, 55,
        58, 60, 49, 46, 46, 46, 50, 55, 60, 61,
        /* Size 16x16 */
        32, 31, 31, 30, 33, 33, 36, 38, 41, 47, 49, 48, 49, 49, 50, 50, 31, 31,
        31, 31, 34, 34, 38, 40, 42, 46, 47, 47, 47, 47, 48, 48, 31, 31, 31, 31,
        34, 35, 39, 40, 42, 46, 47, 46, 46, 46, 47, 47, 30, 31, 31, 32, 34, 35,
        40, 41, 42, 45, 46, 45, 45, 45, 46, 46, 33, 34, 34, 34, 37, 38, 42, 43,
        44, 46, 47, 46, 46, 45, 46, 46, 33, 34, 35, 35, 38, 39, 43, 44, 45, 47,
        47, 46, 46, 45, 46, 46, 36, 38, 39, 40, 42, 43, 47, 47, 47, 47, 48, 46,
        46, 45, 46, 46, 38, 40, 40, 41, 43, 44, 47, 47, 48, 48, 49, 48, 47, 47,
        47, 47, 41, 42, 42, 42, 44, 45, 47, 48, 48, 50, 50, 49, 49, 49, 50, 50,
        47, 46, 46, 45, 46, 47, 47, 48, 50, 52, 52, 52, 52, 52, 53, 53, 49, 47,
        47, 46, 47, 47, 48, 49, 50, 52, 53, 53, 53, 53, 54, 54, 48, 47, 46, 45,
        46, 46, 46, 48, 49, 52, 53, 54, 55, 55, 56, 56, 49, 47, 46, 45, 46, 46,
        46, 47, 49, 52, 53, 55, 55, 57, 57, 58, 49, 47, 46, 45, 45, 45, 45, 47,
        49, 52, 53, 55, 57, 58, 59, 60, 50, 48, 47, 46, 46, 46, 46, 47, 50, 53,
        54, 56, 57, 59, 61, 61, 50, 48, 47, 46, 46, 46, 46, 47, 50, 53, 54, 56,
        58, 60, 61, 61,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 30, 30, 31, 33, 33, 33, 35, 36, 36, 38, 41, 41, 43,
        47, 49, 49, 49, 48, 48, 49, 49, 49, 49, 50, 50, 50, 51, 31, 31, 31, 31,
        31, 31, 31, 31, 33, 34, 34, 36, 37, 37, 39, 42, 42, 43, 47, 48, 48, 48,
        47, 47, 47, 47, 47, 48, 49, 49, 49, 50, 31, 31, 31, 31, 31, 31, 31, 32,
        34, 34, 34, 37, 38, 38, 40, 42, 42, 43, 46, 47, 47, 47, 47, 47, 47, 47,
        47, 47, 48, 48, 48, 49, 31, 31, 31, 31, 31, 31, 31, 32, 34, 34, 34, 37,
        38, 38, 40, 42, 42, 43, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48,
        48, 49, 31, 31, 31, 31, 31, 31, 31, 32, 34, 35, 35, 37, 39, 39, 40, 42,
        42, 43, 46, 47, 47, 46, 46, 46, 46, 46, 46, 46, 47, 47, 47, 48, 30, 31,
        31, 31, 31, 32, 32, 32, 34, 35, 35, 38, 40, 40, 41, 42, 42, 43, 45, 46,
        46, 46, 45, 45, 45, 45, 45, 45, 46, 46, 46, 47, 30, 31, 31, 31, 31, 32,
        32, 32, 34, 35, 35, 38, 40, 40, 41, 42, 42, 43, 45, 46, 46, 46, 45, 45,
        45, 45, 45, 45, 46, 46, 46, 47, 31, 31, 32, 32, 32, 32, 32, 33, 35, 36,
        36, 38, 40, 40, 41, 43, 43, 43, 46, 46, 46, 46, 45, 45, 45, 45, 45, 45,
        46, 46, 46, 47, 33, 33, 34, 34, 34, 34, 34, 35, 37, 38, 38, 41, 42, 42,
        43, 44, 44, 45, 46, 47, 47, 46, 46, 46, 46, 45, 45, 45, 46, 46, 46, 47,
        33, 34, 34, 34, 35, 35, 35, 36, 38, 39, 39, 41, 43, 43, 44, 45, 45, 45,
        47, 47, 47, 46, 46, 46, 46, 45, 45, 45, 46, 46, 46, 47, 33, 34, 34, 34,
        35, 35, 35, 36, 38, 39, 39, 41, 43, 43, 44, 45, 45, 45, 47, 47, 47, 46,
        46, 46, 46, 45, 45, 45, 46, 46, 46, 47, 35, 36, 37, 37, 37, 38, 38, 38,
        41, 41, 41, 44, 46, 46, 46, 46, 46, 46, 47, 47, 47, 47, 46, 46, 46, 45,
        45, 45, 46, 46, 46, 47, 36, 37, 38, 38, 39, 40, 40, 40, 42, 43, 43, 46,
        47, 47, 47, 47, 47, 47, 47, 48, 48, 47, 46, 46, 46, 45, 45, 45, 46, 46,
        46, 46, 36, 37, 38, 38, 39, 40, 40, 40, 42, 43, 43, 46, 47, 47, 47, 47,
        47, 47, 47, 48, 48, 47, 46, 46, 46, 45, 45, 45, 46, 46, 46, 46, 38, 39,
        40, 40, 40, 41, 41, 41, 43, 44, 44, 46, 47, 47, 47, 48, 48, 48, 48, 49,
        49, 48, 48, 48, 47, 47, 47, 47, 47, 47, 47, 48, 41, 42, 42, 42, 42, 42,
        42, 43, 44, 45, 45, 46, 47, 47, 48, 48, 48, 49, 50, 50, 50, 50, 49, 49,
        49, 49, 49, 49, 50, 50, 50, 50, 41, 42, 42, 42, 42, 42, 42, 43, 44, 45,
        45, 46, 47, 47, 48, 48, 48, 49, 50, 50, 50, 50, 49, 49, 49, 49, 49, 49,
        50, 50, 50, 50, 43, 43, 43, 43, 43, 43, 43, 43, 45, 45, 45, 46, 47, 47,
        48, 49, 49, 49, 50, 51, 51, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51,
        47, 47, 46, 46, 46, 45, 45, 46, 46, 47, 47, 47, 47, 47, 48, 50, 50, 50,
        52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 49, 48, 47, 47,
        47, 46, 46, 46, 47, 47, 47, 47, 48, 48, 49, 50, 50, 51, 52, 53, 53, 53,
        53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 49, 48, 47, 47, 47, 46, 46, 46,
        47, 47, 47, 47, 48, 48, 49, 50, 50, 51, 52, 53, 53, 53, 53, 53, 53, 53,
        53, 53, 54, 54, 54, 54, 49, 48, 47, 47, 46, 46, 46, 46, 46, 46, 46, 47,
        47, 47, 48, 50, 50, 50, 52, 53, 53, 53, 54, 54, 54, 55, 55, 55, 55, 55,
        55, 56, 48, 47, 47, 47, 46, 45, 45, 45, 46, 46, 46, 46, 46, 46, 48, 49,
        49, 50, 52, 53, 53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 56, 57, 48, 47,
        47, 47, 46, 45, 45, 45, 46, 46, 46, 46, 46, 46, 48, 49, 49, 50, 52, 53,
        53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 56, 57, 49, 47, 47, 47, 46, 45,
        45, 45, 46, 46, 46, 46, 46, 46, 47, 49, 49, 50, 52, 53, 53, 54, 55, 55,
        55, 57, 57, 57, 57, 58, 58, 58, 49, 47, 47, 47, 46, 45, 45, 45, 45, 45,
        45, 45, 45, 45, 47, 49, 49, 50, 52, 53, 53, 55, 55, 55, 57, 58, 58, 59,
        59, 60, 60, 60, 49, 47, 47, 47, 46, 45, 45, 45, 45, 45, 45, 45, 45, 45,
        47, 49, 49, 50, 52, 53, 53, 55, 55, 55, 57, 58, 58, 59, 59, 60, 60, 60,
        49, 48, 47, 47, 46, 45, 45, 45, 45, 45, 45, 45, 45, 45, 47, 49, 49, 50,
        52, 53, 53, 55, 56, 56, 57, 59, 59, 59, 60, 60, 60, 61, 50, 49, 48, 48,
        47, 46, 46, 46, 46, 46, 46, 46, 46, 46, 47, 50, 50, 50, 53, 54, 54, 55,
        56, 56, 57, 59, 59, 60, 61, 61, 61, 62, 50, 49, 48, 48, 47, 46, 46, 46,
        46, 46, 46, 46, 46, 46, 47, 50, 50, 50, 53, 54, 54, 55, 56, 56, 58, 60,
        60, 60, 61, 61, 61, 63, 50, 49, 48, 48, 47, 46, 46, 46, 46, 46, 46, 46,
        46, 46, 47, 50, 50, 50, 53, 54, 54, 55, 56, 56, 58, 60, 60, 60, 61, 61,
        61, 63, 51, 50, 49, 49, 48, 47, 47, 47, 47, 47, 47, 47, 46, 46, 48, 50,
        50, 51, 53, 54, 54, 56, 57, 57, 58, 60, 60, 61, 62, 63, 63, 64,
        /* Size 4x8 */
        31, 38, 47, 48, 31, 40, 46, 45, 35, 43, 47, 46, 39, 47, 47, 45, 43, 47,
        50, 50, 47, 47, 53, 55, 46, 46, 53, 58, 48, 46, 54, 59,
        /* Size 8x4 */
        31, 31, 35, 39, 43, 47, 46, 48, 38, 40, 43, 47, 47, 47, 46, 46, 47, 46,
        47, 47, 50, 53, 53, 54, 48, 45, 46, 45, 50, 55, 58, 59,
        /* Size 8x16 */
        32, 31, 33, 37, 45, 48, 49, 50, 31, 31, 34, 38, 45, 47, 47, 48, 31, 32,
        34, 39, 45, 46, 46, 47, 30, 32, 35, 40, 44, 46, 45, 46, 33, 35, 37, 42,
        46, 47, 45, 46, 33, 36, 38, 43, 46, 47, 46, 46, 37, 40, 43, 47, 47, 47,
        45, 46, 39, 41, 43, 47, 48, 48, 47, 47, 42, 43, 44, 47, 49, 50, 49, 50,
        47, 46, 46, 48, 51, 52, 53, 53, 49, 46, 47, 48, 52, 53, 53, 54, 48, 46,
        46, 47, 51, 53, 56, 56, 48, 45, 46, 46, 51, 53, 57, 57, 49, 45, 45, 46,
        51, 53, 58, 59, 50, 46, 46, 46, 52, 54, 59, 61, 50, 46, 46, 46, 52, 54,
        59, 61,
        /* Size 16x8 */
        32, 31, 31, 30, 33, 33, 37, 39, 42, 47, 49, 48, 48, 49, 50, 50, 31, 31,
        32, 32, 35, 36, 40, 41, 43, 46, 46, 46, 45, 45, 46, 46, 33, 34, 34, 35,
        37, 38, 43, 43, 44, 46, 47, 46, 46, 45, 46, 46, 37, 38, 39, 40, 42, 43,
        47, 47, 47, 48, 48, 47, 46, 46, 46, 46, 45, 45, 45, 44, 46, 46, 47, 48,
        49, 51, 52, 51, 51, 51, 52, 52, 48, 47, 46, 46, 47, 47, 47, 48, 50, 52,
        53, 53, 53, 53, 54, 54, 49, 47, 46, 45, 45, 46, 45, 47, 49, 53, 53, 56,
        57, 58, 59, 59, 50, 48, 47, 46, 46, 46, 46, 47, 50, 53, 54, 56, 57, 59,
        61, 61,
        /* Size 16x32 */
        32, 31, 31, 31, 33, 37, 37, 38, 45, 48, 48, 49, 49, 49, 50, 52, 31, 31,
        31, 31, 33, 38, 38, 39, 45, 47, 47, 48, 48, 48, 49, 51, 31, 31, 31, 31,
        34, 38, 38, 40, 45, 47, 47, 47, 47, 47, 48, 50, 31, 31, 31, 31, 34, 38,
        38, 40, 45, 47, 47, 47, 47, 47, 48, 50, 31, 31, 32, 32, 34, 39, 39, 40,
        45, 46, 46, 46, 46, 46, 47, 49, 30, 31, 32, 32, 35, 40, 40, 41, 44, 46,
        46, 45, 45, 45, 46, 48, 30, 31, 32, 32, 35, 40, 40, 41, 44, 46, 46, 45,
        45, 45, 46, 48, 31, 32, 33, 33, 35, 40, 40, 41, 45, 46, 46, 45, 45, 45,
        46, 48, 33, 34, 35, 35, 37, 42, 42, 43, 46, 47, 47, 46, 45, 45, 46, 47,
        33, 35, 36, 36, 38, 43, 43, 44, 46, 47, 47, 46, 46, 46, 46, 47, 33, 35,
        36, 36, 38, 43, 43, 44, 46, 47, 47, 46, 46, 46, 46, 47, 35, 37, 38, 38,
        41, 45, 45, 46, 47, 47, 47, 46, 45, 45, 46, 47, 37, 39, 40, 40, 43, 47,
        47, 47, 47, 47, 47, 46, 45, 45, 46, 47, 37, 39, 40, 40, 43, 47, 47, 47,
        47, 47, 47, 46, 45, 45, 46, 47, 39, 40, 41, 41, 43, 47, 47, 47, 48, 48,
        48, 47, 47, 47, 47, 48, 42, 42, 43, 43, 44, 47, 47, 48, 49, 50, 50, 49,
        49, 49, 50, 50, 42, 42, 43, 43, 44, 47, 47, 48, 49, 50, 50, 49, 49, 49,
        50, 50, 43, 43, 43, 43, 45, 47, 47, 48, 50, 50, 50, 50, 50, 50, 50, 51,
        47, 46, 46, 46, 46, 48, 48, 48, 51, 52, 52, 52, 53, 53, 53, 53, 49, 47,
        46, 46, 47, 48, 48, 49, 52, 53, 53, 53, 53, 53, 54, 54, 49, 47, 46, 46,
        47, 48, 48, 49, 52, 53, 53, 53, 53, 53, 54, 54, 48, 47, 46, 46, 46, 47,
        47, 48, 52, 53, 53, 54, 55, 55, 55, 56, 48, 47, 46, 46, 46, 47, 47, 48,
        51, 53, 53, 54, 56, 56, 56, 57, 48, 47, 46, 46, 46, 47, 47, 48, 51, 53,
        53, 54, 56, 56, 56, 57, 48, 47, 45, 45, 46, 46, 46, 47, 51, 53, 53, 55,
        57, 57, 57, 59, 49, 46, 45, 45, 45, 46, 46, 47, 51, 53, 53, 56, 58, 58,
        59, 61, 49, 46, 45, 45, 45, 46, 46, 47, 51, 53, 53, 56, 58, 58, 59, 61,
        49, 47, 45, 45, 45, 46, 46, 47, 52, 53, 53, 56, 58, 58, 60, 62, 50, 48,
        46, 46, 46, 46, 46, 48, 52, 54, 54, 57, 59, 59, 61, 63, 50, 48, 46, 46,
        46, 46, 46, 48, 52, 54, 54, 57, 59, 59, 61, 64, 50, 48, 46, 46, 46, 46,
        46, 48, 52, 54, 54, 57, 59, 59, 61, 64, 51, 49, 47, 47, 47, 47, 47, 48,
        52, 54, 54, 58, 60, 60, 62, 65,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 30, 30, 31, 33, 33, 33, 35, 37, 37, 39, 42, 42, 43,
        47, 49, 49, 48, 48, 48, 48, 49, 49, 49, 50, 50, 50, 51, 31, 31, 31, 31,
        31, 31, 31, 32, 34, 35, 35, 37, 39, 39, 40, 42, 42, 43, 46, 47, 47, 47,
        47, 47, 47, 46, 46, 47, 48, 48, 48, 49, 31, 31, 31, 31, 32, 32, 32, 33,
        35, 36, 36, 38, 40, 40, 41, 43, 43, 43, 46, 46, 46, 46, 46, 46, 45, 45,
        45, 45, 46, 46, 46, 47, 31, 31, 31, 31, 32, 32, 32, 33, 35, 36, 36, 38,
        40, 40, 41, 43, 43, 43, 46, 46, 46, 46, 46, 46, 45, 45, 45, 45, 46, 46,
        46, 47, 33, 33, 34, 34, 34, 35, 35, 35, 37, 38, 38, 41, 43, 43, 43, 44,
        44, 45, 46, 47, 47, 46, 46, 46, 46, 45, 45, 45, 46, 46, 46, 47, 37, 38,
        38, 38, 39, 40, 40, 40, 42, 43, 43, 45, 47, 47, 47, 47, 47, 47, 48, 48,
        48, 47, 47, 47, 46, 46, 46, 46, 46, 46, 46, 47, 37, 38, 38, 38, 39, 40,
        40, 40, 42, 43, 43, 45, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 47, 47,
        46, 46, 46, 46, 46, 46, 46, 47, 38, 39, 40, 40, 40, 41, 41, 41, 43, 44,
        44, 46, 47, 47, 47, 48, 48, 48, 48, 49, 49, 48, 48, 48, 47, 47, 47, 47,
        48, 48, 48, 48, 45, 45, 45, 45, 45, 44, 44, 45, 46, 46, 46, 47, 47, 47,
        48, 49, 49, 50, 51, 52, 52, 52, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52,
        48, 47, 47, 47, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 50, 50, 50,
        52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 48, 47, 47, 47,
        46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 50, 50, 50, 52, 53, 53, 53,
        53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 49, 48, 47, 47, 46, 45, 45, 45,
        46, 46, 46, 46, 46, 46, 47, 49, 49, 50, 52, 53, 53, 54, 54, 54, 55, 56,
        56, 56, 57, 57, 57, 58, 49, 48, 47, 47, 46, 45, 45, 45, 45, 46, 46, 45,
        45, 45, 47, 49, 49, 50, 53, 53, 53, 55, 56, 56, 57, 58, 58, 58, 59, 59,
        59, 60, 49, 48, 47, 47, 46, 45, 45, 45, 45, 46, 46, 45, 45, 45, 47, 49,
        49, 50, 53, 53, 53, 55, 56, 56, 57, 58, 58, 58, 59, 59, 59, 60, 50, 49,
        48, 48, 47, 46, 46, 46, 46, 46, 46, 46, 46, 46, 47, 50, 50, 50, 53, 54,
        54, 55, 56, 56, 57, 59, 59, 60, 61, 61, 61, 62, 52, 51, 50, 50, 49, 48,
        48, 48, 47, 47, 47, 47, 47, 47, 48, 50, 50, 51, 53, 54, 54, 56, 57, 57,
        59, 61, 61, 62, 63, 64, 64, 65 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 32, 34, 38, 32, 33, 35, 39, 34, 35, 39, 45, 38, 39, 45, 54,
        /* Size 8x8 */
        31, 31, 32, 32, 33, 34, 37, 41, 31, 32, 32, 32, 33, 34, 36, 39, 32, 32,
        32, 33, 34, 35, 37, 40, 32, 32, 33, 34, 35, 36, 38, 41, 33, 33, 34, 35,
        37, 39, 41, 44, 34, 34, 35, 36, 39, 43, 46, 49, 37, 36, 37, 38, 41, 46,
        51, 54, 41, 39, 40, 41, 44, 49, 54, 58,
        /* Size 16x16 */
        32, 31, 31, 31, 31, 31, 31, 32, 32, 34, 34, 36, 36, 39, 39, 44, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 34, 34, 35, 35, 38, 38, 42, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 34, 34, 35, 35, 38, 38, 42, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 34, 34, 37, 37, 41, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 34, 34, 37, 37, 41, 31, 32, 32, 32, 32, 33, 33, 34, 34, 35,
        35, 36, 36, 39, 39, 42, 31, 32, 32, 32, 32, 33, 33, 34, 34, 35, 35, 36,
        36, 39, 39, 42, 32, 32, 32, 32, 32, 34, 34, 35, 35, 37, 37, 38, 38, 40,
        40, 42, 32, 32, 32, 32, 32, 34, 34, 35, 35, 37, 37, 38, 38, 40, 40, 42,
        34, 34, 34, 33, 33, 35, 35, 37, 37, 39, 39, 42, 42, 45, 45, 47, 34, 34,
        34, 33, 33, 35, 35, 37, 37, 39, 39, 42, 42, 45, 45, 47, 36, 35, 35, 34,
        34, 36, 36, 38, 38, 42, 42, 48, 48, 50, 50, 54, 36, 35, 35, 34, 34, 36,
        36, 38, 38, 42, 42, 48, 48, 50, 50, 54, 39, 38, 38, 37, 37, 39, 39, 40,
        40, 45, 45, 50, 50, 54, 54, 58, 39, 38, 38, 37, 37, 39, 39, 40, 40, 45,
        45, 50, 50, 54, 54, 58, 44, 42, 42, 41, 41, 42, 42, 42, 42, 47, 47, 54,
        54, 58, 58, 63,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33,
        34, 34, 34, 35, 36, 36, 36, 37, 39, 39, 39, 41, 44, 44, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34,
        35, 35, 35, 37, 39, 39, 39, 41, 43, 43, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 35, 35, 37,
        38, 38, 38, 40, 42, 42, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 35, 35, 37, 38, 38, 38, 40,
        42, 42, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 34, 34, 34, 34, 35, 35, 35, 37, 38, 38, 38, 40, 42, 42, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34,
        34, 34, 35, 35, 35, 36, 38, 38, 38, 39, 41, 41, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34,
        34, 36, 37, 37, 37, 39, 41, 41, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 36, 37, 37,
        37, 39, 41, 41, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 36, 37, 37, 37, 39, 41, 41,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 34,
        34, 34, 34, 35, 35, 35, 35, 37, 38, 38, 38, 40, 41, 41, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 36,
        36, 36, 36, 38, 39, 39, 39, 40, 42, 42, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 36, 36, 36, 36, 38,
        39, 39, 39, 40, 42, 42, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
        33, 33, 34, 34, 34, 34, 35, 35, 35, 36, 36, 36, 36, 38, 39, 39, 39, 40,
        42, 42, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34,
        34, 35, 36, 36, 36, 36, 37, 37, 37, 38, 40, 40, 40, 41, 42, 42, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 35, 35, 36, 37, 37,
        37, 37, 38, 38, 38, 39, 40, 40, 40, 41, 42, 42, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 34, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 37, 38, 38,
        38, 39, 40, 40, 40, 41, 42, 42, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        34, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 37, 38, 38, 38, 39, 40, 40,
        40, 41, 42, 42, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35,
        36, 36, 36, 37, 38, 38, 38, 39, 40, 40, 40, 41, 42, 42, 42, 44, 45, 45,
        34, 34, 34, 34, 34, 34, 33, 33, 33, 34, 35, 35, 35, 36, 37, 37, 37, 38,
        39, 39, 39, 41, 42, 42, 42, 44, 45, 45, 45, 46, 47, 47, 34, 34, 34, 34,
        34, 34, 33, 33, 33, 34, 35, 35, 35, 36, 37, 37, 37, 38, 39, 39, 39, 41,
        42, 42, 42, 44, 45, 45, 45, 46, 47, 47, 34, 34, 34, 34, 34, 34, 33, 33,
        33, 34, 35, 35, 35, 36, 37, 37, 37, 38, 39, 39, 39, 41, 42, 42, 42, 44,
        45, 45, 45, 46, 47, 47, 35, 34, 34, 34, 34, 34, 34, 34, 34, 35, 36, 36,
        36, 36, 37, 37, 37, 39, 41, 41, 41, 43, 45, 45, 45, 46, 47, 47, 47, 49,
        50, 50, 36, 35, 35, 35, 35, 35, 34, 34, 34, 35, 36, 36, 36, 37, 38, 38,
        38, 40, 42, 42, 42, 45, 48, 48, 48, 49, 50, 50, 50, 52, 54, 54, 36, 35,
        35, 35, 35, 35, 34, 34, 34, 35, 36, 36, 36, 37, 38, 38, 38, 40, 42, 42,
        42, 45, 48, 48, 48, 49, 50, 50, 50, 52, 54, 54, 36, 35, 35, 35, 35, 35,
        34, 34, 34, 35, 36, 36, 36, 37, 38, 38, 38, 40, 42, 42, 42, 45, 48, 48,
        48, 49, 50, 50, 50, 52, 54, 54, 37, 37, 37, 37, 37, 36, 36, 36, 36, 37,
        38, 38, 38, 38, 39, 39, 39, 41, 44, 44, 44, 46, 49, 49, 49, 51, 52, 52,
        52, 54, 56, 56, 39, 39, 38, 38, 38, 38, 37, 37, 37, 38, 39, 39, 39, 40,
        40, 40, 40, 42, 45, 45, 45, 47, 50, 50, 50, 52, 54, 54, 54, 56, 58, 58,
        39, 39, 38, 38, 38, 38, 37, 37, 37, 38, 39, 39, 39, 40, 40, 40, 40, 42,
        45, 45, 45, 47, 50, 50, 50, 52, 54, 54, 54, 56, 58, 58, 39, 39, 38, 38,
        38, 38, 37, 37, 37, 38, 39, 39, 39, 40, 40, 40, 40, 42, 45, 45, 45, 47,
        50, 50, 50, 52, 54, 54, 54, 56, 58, 58, 41, 41, 40, 40, 40, 39, 39, 39,
        39, 40, 40, 40, 40, 41, 41, 41, 41, 44, 46, 46, 46, 49, 52, 52, 52, 54,
        56, 56, 56, 58, 60, 60, 44, 43, 42, 42, 42, 41, 41, 41, 41, 41, 42, 42,
        42, 42, 42, 42, 42, 45, 47, 47, 47, 50, 54, 54, 54, 56, 58, 58, 58, 60,
        63, 63, 44, 43, 42, 42, 42, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42,
        42, 45, 47, 47, 47, 50, 54, 54, 54, 56, 58, 58, 58, 60, 63, 63,
        /* Size 4x8 */
        31, 32, 34, 39, 32, 32, 34, 38, 32, 33, 34, 38, 32, 33, 36, 40, 33, 34,
        38, 42, 34, 36, 41, 47, 37, 38, 44, 52, 40, 40, 46, 56,
        /* Size 8x4 */
        31, 32, 32, 32, 33, 34, 37, 40, 32, 32, 33, 33, 34, 36, 38, 40, 34, 34,
        34, 36, 38, 41, 44, 46, 39, 38, 38, 40, 42, 47, 52, 56,
        /* Size 8x16 */
        32, 31, 31, 32, 32, 36, 36, 44, 31, 32, 32, 32, 32, 35, 35, 42, 31, 32,
        32, 32, 32, 35, 35, 42, 31, 32, 32, 33, 33, 34, 34, 41, 31, 32, 32, 33,
        33, 34, 34, 41, 32, 32, 32, 34, 34, 36, 36, 42, 32, 32, 32, 34, 34, 36,
        36, 42, 32, 33, 33, 35, 35, 38, 38, 42, 32, 33, 33, 35, 35, 38, 38, 42,
        34, 34, 34, 37, 37, 42, 42, 48, 34, 34, 34, 37, 37, 42, 42, 48, 36, 34,
        34, 38, 38, 48, 48, 54, 36, 34, 34, 38, 38, 48, 48, 54, 39, 37, 37, 40,
        40, 50, 50, 58, 39, 37, 37, 40, 40, 50, 50, 58, 44, 41, 41, 43, 43, 53,
        53, 63,
        /* Size 16x8 */
        32, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 36, 36, 39, 39, 44, 31, 32,
        32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 37, 37, 41, 31, 32, 32, 32,
        32, 32, 32, 33, 33, 34, 34, 34, 34, 37, 37, 41, 32, 32, 32, 33, 33, 34,
        34, 35, 35, 37, 37, 38, 38, 40, 40, 43, 32, 32, 32, 33, 33, 34, 34, 35,
        35, 37, 37, 38, 38, 40, 40, 43, 36, 35, 35, 34, 34, 36, 36, 38, 38, 42,
        42, 48, 48, 50, 50, 53, 36, 35, 35, 34, 34, 36, 36, 38, 38, 42, 42, 48,
        48, 50, 50, 53, 44, 42, 42, 41, 41, 42, 42, 42, 42, 48, 48, 54, 54, 58,
        58, 63,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 32, 32, 32, 32, 34, 36, 36, 36, 39, 44, 44, 31, 31,
        31, 31, 31, 32, 32, 32, 32, 34, 35, 35, 35, 39, 43, 43, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 34, 35, 35, 35, 38, 42, 42, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 34, 35, 35, 35, 38, 42, 42, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 34, 35, 35, 35, 38, 42, 42, 31, 32, 32, 32, 32, 32, 32, 32, 32, 34,
        35, 35, 35, 38, 41, 41, 31, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34,
        34, 37, 41, 41, 31, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 37,
        41, 41, 31, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 37, 41, 41,
        31, 32, 32, 32, 32, 33, 33, 33, 33, 34, 35, 35, 35, 38, 41, 41, 32, 32,
        32, 32, 32, 33, 34, 34, 34, 35, 36, 36, 36, 39, 42, 42, 32, 32, 32, 32,
        32, 33, 34, 34, 34, 35, 36, 36, 36, 39, 42, 42, 32, 32, 32, 32, 32, 33,
        34, 34, 34, 35, 36, 36, 36, 39, 42, 42, 32, 32, 32, 32, 32, 33, 34, 34,
        34, 36, 37, 37, 37, 40, 42, 42, 32, 32, 33, 33, 33, 34, 35, 35, 35, 37,
        38, 38, 38, 40, 42, 42, 32, 32, 33, 33, 33, 34, 35, 35, 35, 37, 38, 38,
        38, 40, 42, 42, 32, 32, 33, 33, 33, 34, 35, 35, 35, 37, 38, 38, 38, 40,
        42, 42, 33, 33, 33, 33, 33, 34, 36, 36, 36, 38, 40, 40, 40, 42, 45, 45,
        34, 34, 34, 34, 34, 35, 37, 37, 37, 39, 42, 42, 42, 45, 48, 48, 34, 34,
        34, 34, 34, 35, 37, 37, 37, 39, 42, 42, 42, 45, 48, 48, 34, 34, 34, 34,
        34, 35, 37, 37, 37, 39, 42, 42, 42, 45, 48, 48, 35, 34, 34, 34, 34, 36,
        37, 37, 37, 41, 45, 45, 45, 47, 50, 50, 36, 35, 34, 34, 34, 36, 38, 38,
        38, 43, 48, 48, 48, 51, 54, 54, 36, 35, 34, 34, 34, 36, 38, 38, 38, 43,
        48, 48, 48, 51, 54, 54, 36, 35, 34, 34, 34, 36, 38, 38, 38, 43, 48, 48,
        48, 51, 54, 54, 37, 37, 36, 36, 36, 38, 39, 39, 39, 44, 49, 49, 49, 52,
        56, 56, 39, 38, 37, 37, 37, 39, 40, 40, 40, 45, 50, 50, 50, 54, 58, 58,
        39, 38, 37, 37, 37, 39, 40, 40, 40, 45, 50, 50, 50, 54, 58, 58, 39, 38,
        37, 37, 37, 39, 40, 40, 40, 45, 50, 50, 50, 54, 58, 58, 41, 40, 39, 39,
        39, 40, 42, 42, 42, 46, 52, 52, 52, 56, 60, 60, 44, 42, 41, 41, 41, 42,
        43, 43, 43, 48, 53, 53, 53, 58, 63, 63, 44, 42, 41, 41, 41, 42, 43, 43,
        43, 48, 53, 53, 53, 58, 63, 63,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33,
        34, 34, 34, 35, 36, 36, 36, 37, 39, 39, 39, 41, 44, 44, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34,
        35, 35, 35, 37, 38, 38, 38, 40, 42, 42, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 36,
        37, 37, 37, 39, 41, 41, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 36, 37, 37, 37, 39,
        41, 41, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
        33, 33, 34, 34, 34, 34, 34, 34, 34, 36, 37, 37, 37, 39, 41, 41, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35,
        35, 36, 36, 36, 36, 38, 39, 39, 39, 40, 42, 42, 32, 32, 32, 32, 32, 32,
        33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 37, 38, 38,
        38, 39, 40, 40, 40, 42, 43, 43, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
        34, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 37, 38, 38, 38, 39, 40, 40,
        40, 42, 43, 43, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34,
        35, 35, 35, 36, 37, 37, 37, 37, 38, 38, 38, 39, 40, 40, 40, 42, 43, 43,
        34, 34, 34, 34, 34, 34, 33, 33, 33, 34, 35, 35, 35, 36, 37, 37, 37, 38,
        39, 39, 39, 41, 43, 43, 43, 44, 45, 45, 45, 46, 48, 48, 36, 35, 35, 35,
        35, 35, 34, 34, 34, 35, 36, 36, 36, 37, 38, 38, 38, 40, 42, 42, 42, 45,
        48, 48, 48, 49, 50, 50, 50, 52, 53, 53, 36, 35, 35, 35, 35, 35, 34, 34,
        34, 35, 36, 36, 36, 37, 38, 38, 38, 40, 42, 42, 42, 45, 48, 48, 48, 49,
        50, 50, 50, 52, 53, 53, 36, 35, 35, 35, 35, 35, 34, 34, 34, 35, 36, 36,
        36, 37, 38, 38, 38, 40, 42, 42, 42, 45, 48, 48, 48, 49, 50, 50, 50, 52,
        53, 53, 39, 39, 38, 38, 38, 38, 37, 37, 37, 38, 39, 39, 39, 40, 40, 40,
        40, 42, 45, 45, 45, 47, 51, 51, 51, 52, 54, 54, 54, 56, 58, 58, 44, 43,
        42, 42, 42, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 45, 48, 48,
        48, 50, 54, 54, 54, 56, 58, 58, 58, 60, 63, 63, 44, 43, 42, 42, 42, 41,
        41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 45, 48, 48, 48, 50, 54, 54,
        54, 56, 58, 58, 58, 60, 63, 63 },
      { /* Chroma */
        /* Size 4x4 */
        31, 34, 42, 47, 34, 39, 45, 46, 42, 45, 48, 49, 47, 46, 49, 54,
        /* Size 8x8 */
        31, 31, 32, 35, 39, 45, 48, 48, 31, 31, 33, 37, 41, 44, 46, 46, 32, 33,
        35, 39, 42, 45, 46, 45, 35, 37, 39, 43, 45, 47, 47, 46, 39, 41, 42, 45,
        47, 48, 48, 47, 45, 44, 45, 47, 48, 50, 51, 51, 48, 46, 46, 47, 48, 51,
        53, 54, 48, 46, 45, 46, 47, 51, 54, 56,
        /* Size 16x16 */
        32, 31, 31, 30, 30, 33, 33, 36, 36, 41, 41, 49, 49, 48, 48, 49, 31, 31,
        31, 31, 31, 34, 34, 38, 38, 42, 42, 47, 47, 47, 47, 47, 31, 31, 31, 31,
        31, 34, 34, 38, 38, 42, 42, 47, 47, 47, 47, 47, 30, 31, 31, 32, 32, 35,
        35, 40, 40, 42, 42, 46, 46, 45, 45, 45, 30, 31, 31, 32, 32, 35, 35, 40,
        40, 42, 42, 46, 46, 45, 45, 45, 33, 34, 34, 35, 35, 39, 39, 43, 43, 45,
        45, 47, 47, 46, 46, 45, 33, 34, 34, 35, 35, 39, 39, 43, 43, 45, 45, 47,
        47, 46, 46, 45, 36, 38, 38, 40, 40, 43, 43, 47, 47, 47, 47, 48, 48, 46,
        46, 45, 36, 38, 38, 40, 40, 43, 43, 47, 47, 47, 47, 48, 48, 46, 46, 45,
        41, 42, 42, 42, 42, 45, 45, 47, 47, 48, 48, 50, 50, 49, 49, 49, 41, 42,
        42, 42, 42, 45, 45, 47, 47, 48, 48, 50, 50, 49, 49, 49, 49, 47, 47, 46,
        46, 47, 47, 48, 48, 50, 50, 53, 53, 53, 53, 53, 49, 47, 47, 46, 46, 47,
        47, 48, 48, 50, 50, 53, 53, 53, 53, 53, 48, 47, 47, 45, 45, 46, 46, 46,
        46, 49, 49, 53, 53, 54, 54, 55, 48, 47, 47, 45, 45, 46, 46, 46, 46, 49,
        49, 53, 53, 54, 54, 55, 49, 47, 47, 45, 45, 45, 45, 45, 45, 49, 49, 53,
        53, 55, 55, 58,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 30, 30, 30, 32, 33, 33, 33, 35, 36, 36, 36, 39,
        41, 41, 41, 45, 49, 49, 49, 49, 48, 48, 48, 49, 49, 49, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 32, 34, 34, 34, 35, 37, 37, 37, 39, 42, 42, 42, 45,
        48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 33, 34, 34, 34, 36, 38, 38, 38, 40, 42, 42, 42, 45, 47, 47, 47, 47,
        47, 47, 47, 47, 47, 47, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 34,
        34, 36, 38, 38, 38, 40, 42, 42, 42, 45, 47, 47, 47, 47, 47, 47, 47, 47,
        47, 47, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 34, 34, 36, 38, 38,
        38, 40, 42, 42, 42, 45, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 33, 35, 35, 35, 37, 39, 39, 39, 41, 42, 42,
        42, 44, 47, 47, 47, 46, 46, 46, 46, 46, 46, 46, 30, 31, 31, 31, 31, 31,
        32, 32, 32, 33, 35, 35, 35, 37, 40, 40, 40, 41, 42, 42, 42, 44, 46, 46,
        46, 46, 45, 45, 45, 45, 45, 45, 30, 31, 31, 31, 31, 31, 32, 32, 32, 33,
        35, 35, 35, 37, 40, 40, 40, 41, 42, 42, 42, 44, 46, 46, 46, 46, 45, 45,
        45, 45, 45, 45, 30, 31, 31, 31, 31, 31, 32, 32, 32, 33, 35, 35, 35, 37,
        40, 40, 40, 41, 42, 42, 42, 44, 46, 46, 46, 46, 45, 45, 45, 45, 45, 45,
        32, 32, 33, 33, 33, 33, 33, 33, 33, 35, 37, 37, 37, 39, 41, 41, 41, 42,
        43, 43, 43, 45, 47, 47, 47, 46, 46, 46, 46, 45, 45, 45, 33, 34, 34, 34,
        34, 35, 35, 35, 35, 37, 39, 39, 39, 41, 43, 43, 43, 44, 45, 45, 45, 46,
        47, 47, 47, 47, 46, 46, 46, 46, 45, 45, 33, 34, 34, 34, 34, 35, 35, 35,
        35, 37, 39, 39, 39, 41, 43, 43, 43, 44, 45, 45, 45, 46, 47, 47, 47, 47,
        46, 46, 46, 46, 45, 45, 33, 34, 34, 34, 34, 35, 35, 35, 35, 37, 39, 39,
        39, 41, 43, 43, 43, 44, 45, 45, 45, 46, 47, 47, 47, 47, 46, 46, 46, 46,
        45, 45, 35, 35, 36, 36, 36, 37, 37, 37, 37, 39, 41, 41, 41, 43, 45, 45,
        45, 45, 46, 46, 46, 47, 47, 47, 47, 47, 46, 46, 46, 46, 45, 45, 36, 37,
        38, 38, 38, 39, 40, 40, 40, 41, 43, 43, 43, 45, 47, 47, 47, 47, 47, 47,
        47, 47, 48, 48, 48, 47, 46, 46, 46, 46, 45, 45, 36, 37, 38, 38, 38, 39,
        40, 40, 40, 41, 43, 43, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48,
        48, 47, 46, 46, 46, 46, 45, 45, 36, 37, 38, 38, 38, 39, 40, 40, 40, 41,
        43, 43, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 46, 46,
        46, 46, 45, 45, 39, 39, 40, 40, 40, 41, 41, 41, 41, 42, 44, 44, 44, 45,
        47, 47, 47, 47, 48, 48, 48, 48, 49, 49, 49, 48, 48, 48, 48, 47, 47, 47,
        41, 42, 42, 42, 42, 42, 42, 42, 42, 43, 45, 45, 45, 46, 47, 47, 47, 48,
        48, 48, 48, 49, 50, 50, 50, 50, 49, 49, 49, 49, 49, 49, 41, 42, 42, 42,
        42, 42, 42, 42, 42, 43, 45, 45, 45, 46, 47, 47, 47, 48, 48, 48, 48, 49,
        50, 50, 50, 50, 49, 49, 49, 49, 49, 49, 41, 42, 42, 42, 42, 42, 42, 42,
        42, 43, 45, 45, 45, 46, 47, 47, 47, 48, 48, 48, 48, 49, 50, 50, 50, 50,
        49, 49, 49, 49, 49, 49, 45, 45, 45, 45, 45, 44, 44, 44, 44, 45, 46, 46,
        46, 47, 47, 47, 47, 48, 49, 49, 49, 50, 51, 51, 51, 51, 51, 51, 51, 51,
        51, 51, 49, 48, 47, 47, 47, 47, 46, 46, 46, 47, 47, 47, 47, 47, 48, 48,
        48, 49, 50, 50, 50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 49, 48,
        47, 47, 47, 47, 46, 46, 46, 47, 47, 47, 47, 47, 48, 48, 48, 49, 50, 50,
        50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 49, 48, 47, 47, 47, 47,
        46, 46, 46, 47, 47, 47, 47, 47, 48, 48, 48, 49, 50, 50, 50, 51, 53, 53,
        53, 53, 53, 53, 53, 53, 53, 53, 49, 48, 47, 47, 47, 46, 46, 46, 46, 46,
        47, 47, 47, 47, 47, 47, 47, 48, 50, 50, 50, 51, 53, 53, 53, 53, 53, 53,
        53, 54, 54, 54, 48, 48, 47, 47, 47, 46, 45, 45, 45, 46, 46, 46, 46, 46,
        46, 46, 46, 48, 49, 49, 49, 51, 53, 53, 53, 53, 54, 54, 54, 55, 55, 55,
        48, 48, 47, 47, 47, 46, 45, 45, 45, 46, 46, 46, 46, 46, 46, 46, 46, 48,
        49, 49, 49, 51, 53, 53, 53, 53, 54, 54, 54, 55, 55, 55, 48, 48, 47, 47,
        47, 46, 45, 45, 45, 46, 46, 46, 46, 46, 46, 46, 46, 48, 49, 49, 49, 51,
        53, 53, 53, 53, 54, 54, 54, 55, 55, 55, 49, 48, 47, 47, 47, 46, 45, 45,
        45, 45, 46, 46, 46, 46, 46, 46, 46, 47, 49, 49, 49, 51, 53, 53, 53, 54,
        55, 55, 55, 56, 57, 57, 49, 48, 47, 47, 47, 46, 45, 45, 45, 45, 45, 45,
        45, 45, 45, 45, 45, 47, 49, 49, 49, 51, 53, 53, 53, 54, 55, 55, 55, 57,
        58, 58, 49, 48, 47, 47, 47, 46, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
        45, 47, 49, 49, 49, 51, 53, 53, 53, 54, 55, 55, 55, 57, 58, 58,
        /* Size 4x8 */
        31, 34, 42, 48, 31, 35, 42, 46, 33, 37, 44, 46, 36, 41, 46, 46, 40, 44,
        48, 48, 45, 46, 49, 51, 47, 47, 50, 54, 47, 46, 49, 55,
        /* Size 8x4 */
        31, 31, 33, 36, 40, 45, 47, 47, 34, 35, 37, 41, 44, 46, 47, 46, 42, 42,
        44, 46, 48, 49, 50, 49, 48, 46, 46, 46, 48, 51, 54, 55,
        /* Size 8x16 */
        32, 31, 31, 37, 37, 48, 48, 49, 31, 31, 31, 38, 38, 47, 47, 47, 31, 31,
        31, 38, 38, 47, 47, 47, 30, 32, 32, 40, 40, 46, 46, 45, 30, 32, 32, 40,
        40, 46, 46, 45, 33, 36, 36, 43, 43, 47, 47, 46, 33, 36, 36, 43, 43, 47,
        47, 46, 37, 40, 40, 47, 47, 47, 47, 45, 37, 40, 40, 47, 47, 47, 47, 45,
        42, 43, 43, 47, 47, 50, 50, 49, 42, 43, 43, 47, 47, 50, 50, 49, 49, 46,
        46, 48, 48, 53, 53, 53, 49, 46, 46, 48, 48, 53, 53, 53, 48, 46, 46, 47,
        47, 53, 53, 56, 48, 46, 46, 47, 47, 53, 53, 56, 49, 45, 45, 46, 46, 53,
        53, 58,
        /* Size 16x8 */
        32, 31, 31, 30, 30, 33, 33, 37, 37, 42, 42, 49, 49, 48, 48, 49, 31, 31,
        31, 32, 32, 36, 36, 40, 40, 43, 43, 46, 46, 46, 46, 45, 31, 31, 31, 32,
        32, 36, 36, 40, 40, 43, 43, 46, 46, 46, 46, 45, 37, 38, 38, 40, 40, 43,
        43, 47, 47, 47, 47, 48, 48, 47, 47, 46, 37, 38, 38, 40, 40, 43, 43, 47,
        47, 47, 47, 48, 48, 47, 47, 46, 48, 47, 47, 46, 46, 47, 47, 47, 47, 50,
        50, 53, 53, 53, 53, 53, 48, 47, 47, 46, 46, 47, 47, 47, 47, 50, 50, 53,
        53, 53, 53, 53, 49, 47, 47, 45, 45, 46, 46, 45, 45, 49, 49, 53, 53, 56,
        56, 58,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 33, 37, 37, 37, 42, 48, 48, 48, 48, 49, 49, 31, 31,
        31, 31, 31, 34, 37, 37, 37, 42, 47, 47, 47, 48, 48, 48, 31, 31, 31, 31,
        31, 34, 38, 38, 38, 42, 47, 47, 47, 47, 47, 47, 31, 31, 31, 31, 31, 34,
        38, 38, 38, 42, 47, 47, 47, 47, 47, 47, 31, 31, 31, 31, 31, 34, 38, 38,
        38, 42, 47, 47, 47, 47, 47, 47, 31, 31, 32, 32, 32, 35, 39, 39, 39, 42,
        46, 46, 46, 46, 46, 46, 30, 31, 32, 32, 32, 35, 40, 40, 40, 42, 46, 46,
        46, 45, 45, 45, 30, 31, 32, 32, 32, 35, 40, 40, 40, 42, 46, 46, 46, 45,
        45, 45, 30, 31, 32, 32, 32, 35, 40, 40, 40, 42, 46, 46, 46, 45, 45, 45,
        32, 33, 34, 34, 34, 37, 41, 41, 41, 44, 46, 46, 46, 46, 45, 45, 33, 34,
        36, 36, 36, 39, 43, 43, 43, 45, 47, 47, 47, 46, 46, 46, 33, 34, 36, 36,
        36, 39, 43, 43, 43, 45, 47, 47, 47, 46, 46, 46, 33, 34, 36, 36, 36, 39,
        43, 43, 43, 45, 47, 47, 47, 46, 46, 46, 35, 36, 38, 38, 38, 41, 45, 45,
        45, 46, 47, 47, 47, 46, 45, 45, 37, 38, 40, 40, 40, 43, 47, 47, 47, 47,
        47, 47, 47, 46, 45, 45, 37, 38, 40, 40, 40, 43, 47, 47, 47, 47, 47, 47,
        47, 46, 45, 45, 37, 38, 40, 40, 40, 43, 47, 47, 47, 47, 47, 47, 47, 46,
        45, 45, 39, 40, 41, 41, 41, 44, 47, 47, 47, 48, 49, 49, 49, 48, 47, 47,
        42, 42, 43, 43, 43, 45, 47, 47, 47, 48, 50, 50, 50, 50, 49, 49, 42, 42,
        43, 43, 43, 45, 47, 47, 47, 48, 50, 50, 50, 50, 49, 49, 42, 42, 43, 43,
        43, 45, 47, 47, 47, 48, 50, 50, 50, 50, 49, 49, 45, 45, 44, 44, 44, 46,
        47, 47, 47, 49, 51, 51, 51, 51, 51, 51, 49, 48, 46, 46, 46, 47, 48, 48,
        48, 50, 53, 53, 53, 53, 53, 53, 49, 48, 46, 46, 46, 47, 48, 48, 48, 50,
        53, 53, 53, 53, 53, 53, 49, 48, 46, 46, 46, 47, 48, 48, 48, 50, 53, 53,
        53, 53, 53, 53, 48, 47, 46, 46, 46, 47, 47, 47, 47, 50, 53, 53, 53, 54,
        54, 54, 48, 47, 46, 46, 46, 46, 47, 47, 47, 50, 53, 53, 53, 54, 56, 56,
        48, 47, 46, 46, 46, 46, 47, 47, 47, 50, 53, 53, 53, 54, 56, 56, 48, 47,
        46, 46, 46, 46, 47, 47, 47, 50, 53, 53, 53, 54, 56, 56, 48, 47, 45, 45,
        45, 46, 46, 46, 46, 49, 53, 53, 53, 55, 57, 57, 49, 47, 45, 45, 45, 45,
        46, 46, 46, 49, 53, 53, 53, 56, 58, 58, 49, 47, 45, 45, 45, 45, 46, 46,
        46, 49, 53, 53, 53, 56, 58, 58,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 30, 30, 30, 32, 33, 33, 33, 35, 37, 37, 37, 39,
        42, 42, 42, 45, 49, 49, 49, 48, 48, 48, 48, 48, 49, 49, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 33, 34, 34, 34, 36, 38, 38, 38, 40, 42, 42, 42, 45,
        48, 48, 48, 47, 47, 47, 47, 47, 47, 47, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 34, 36, 36, 36, 38, 40, 40, 40, 41, 43, 43, 43, 44, 46, 46, 46, 46,
        46, 46, 46, 45, 45, 45, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 36, 36,
        36, 38, 40, 40, 40, 41, 43, 43, 43, 44, 46, 46, 46, 46, 46, 46, 46, 45,
        45, 45, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 36, 36, 36, 38, 40, 40,
        40, 41, 43, 43, 43, 44, 46, 46, 46, 46, 46, 46, 46, 45, 45, 45, 33, 34,
        34, 34, 34, 35, 35, 35, 35, 37, 39, 39, 39, 41, 43, 43, 43, 44, 45, 45,
        45, 46, 47, 47, 47, 47, 46, 46, 46, 46, 45, 45, 37, 37, 38, 38, 38, 39,
        40, 40, 40, 41, 43, 43, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48,
        48, 47, 47, 47, 47, 46, 46, 46, 37, 37, 38, 38, 38, 39, 40, 40, 40, 41,
        43, 43, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 47, 47,
        47, 46, 46, 46, 37, 37, 38, 38, 38, 39, 40, 40, 40, 41, 43, 43, 43, 45,
        47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 47, 47, 47, 46, 46, 46,
        42, 42, 42, 42, 42, 42, 42, 42, 42, 44, 45, 45, 45, 46, 47, 47, 47, 48,
        48, 48, 48, 49, 50, 50, 50, 50, 50, 50, 50, 49, 49, 49, 48, 47, 47, 47,
        47, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 49, 50, 50, 50, 51,
        53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 48, 47, 47, 47, 47, 46, 46, 46,
        46, 46, 47, 47, 47, 47, 47, 47, 47, 49, 50, 50, 50, 51, 53, 53, 53, 53,
        53, 53, 53, 53, 53, 53, 48, 47, 47, 47, 47, 46, 46, 46, 46, 46, 47, 47,
        47, 47, 47, 47, 47, 49, 50, 50, 50, 51, 53, 53, 53, 53, 53, 53, 53, 53,
        53, 53, 48, 48, 47, 47, 47, 46, 45, 45, 45, 46, 46, 46, 46, 46, 46, 46,
        46, 48, 50, 50, 50, 51, 53, 53, 53, 54, 54, 54, 54, 55, 56, 56, 49, 48,
        47, 47, 47, 46, 45, 45, 45, 45, 46, 46, 46, 45, 45, 45, 45, 47, 49, 49,
        49, 51, 53, 53, 53, 54, 56, 56, 56, 57, 58, 58, 49, 48, 47, 47, 47, 46,
        45, 45, 45, 45, 46, 46, 46, 45, 45, 45, 45, 47, 49, 49, 49, 51, 53, 53,
        53, 54, 56, 56, 56, 57, 58, 58 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        32, 32, 32, 35, 32, 32, 33, 35, 32, 33, 35, 38, 35, 35, 38, 46,
        /* Size 8x8 */
        31, 31, 31, 32, 32, 32, 34, 35, 31, 32, 32, 32, 32, 33, 34, 35, 31, 32,
        32, 32, 32, 33, 33, 34, 32, 32, 32, 33, 34, 34, 35, 36, 32, 32, 32, 34,
        35, 35, 36, 38, 32, 33, 33, 34, 35, 36, 38, 40, 34, 34, 33, 35, 36, 38,
        39, 42, 35, 35, 34, 36, 38, 40, 42, 48,
        /* Size 16x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 34, 36, 36, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 34, 34, 34, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 34, 34, 34, 31, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34,
        35, 35, 36, 36, 31, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 35, 35, 36,
        36, 36, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 35, 36, 36, 37, 37,
        32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 36, 37, 37, 38, 38, 32, 32,
        32, 32, 32, 32, 33, 34, 34, 35, 35, 36, 37, 37, 38, 38, 33, 33, 33, 33,
        33, 33, 34, 35, 35, 36, 36, 38, 39, 40, 42, 42, 34, 34, 34, 34, 33, 33,
        35, 35, 36, 37, 37, 39, 39, 41, 42, 42, 34, 34, 34, 34, 34, 34, 35, 36,
        36, 37, 37, 40, 41, 42, 45, 45, 36, 35, 35, 35, 34, 34, 36, 36, 37, 38,
        38, 42, 42, 45, 48, 48, 36, 35, 35, 35, 34, 34, 36, 36, 37, 38, 38, 42,
        42, 45, 48, 48,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 36, 36, 36, 37, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        33, 34, 34, 34, 34, 35, 35, 35, 35, 37, 31, 31, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34,
        34, 35, 35, 35, 35, 36, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 35,
        35, 36, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 36, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 36, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34,
        34, 34, 34, 34, 35, 35, 35, 36, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34,
        34, 34, 34, 35, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34,
        34, 35, 35, 35, 35, 36, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 36, 36, 36,
        36, 37, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33,
        33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 36, 37, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34,
        34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 36, 37, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35,
        35, 35, 36, 36, 36, 36, 36, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 36, 36, 36, 36, 37,
        37, 37, 37, 38, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34,
        34, 34, 34, 35, 35, 35, 35, 35, 36, 36, 36, 36, 37, 37, 38, 38, 38, 39,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 35,
        35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 36,
        36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 37, 37, 37,
        37, 38, 38, 38, 38, 39, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
        34, 34, 34, 34, 35, 35, 36, 36, 36, 36, 37, 38, 38, 38, 38, 39, 40, 40,
        40, 41, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35,
        35, 36, 36, 36, 36, 37, 38, 39, 39, 39, 40, 41, 42, 42, 42, 42, 34, 34,
        34, 34, 34, 34, 34, 33, 33, 33, 33, 34, 35, 35, 35, 35, 36, 36, 37, 37,
        37, 38, 39, 39, 39, 39, 41, 42, 42, 42, 42, 43, 34, 34, 34, 34, 34, 34,
        34, 33, 33, 33, 33, 34, 35, 35, 35, 35, 36, 36, 37, 37, 37, 38, 39, 39,
        39, 39, 41, 42, 42, 42, 42, 43, 34, 34, 34, 34, 34, 34, 34, 33, 33, 33,
        33, 34, 35, 35, 35, 35, 36, 36, 37, 37, 37, 38, 39, 39, 39, 39, 41, 42,
        42, 42, 42, 43, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 36,
        36, 36, 36, 37, 37, 37, 37, 38, 40, 41, 41, 41, 42, 44, 45, 45, 45, 45,
        35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 35, 36, 36, 36, 36, 37, 37,
        38, 38, 38, 39, 41, 42, 42, 42, 44, 46, 47, 47, 47, 48, 36, 35, 35, 35,
        35, 35, 35, 34, 34, 34, 34, 35, 36, 36, 36, 36, 37, 38, 38, 38, 38, 40,
        42, 42, 42, 42, 45, 47, 48, 48, 48, 49, 36, 35, 35, 35, 35, 35, 35, 34,
        34, 34, 34, 35, 36, 36, 36, 36, 37, 38, 38, 38, 38, 40, 42, 42, 42, 42,
        45, 47, 48, 48, 48, 49, 36, 35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 35,
        36, 36, 36, 36, 37, 38, 38, 38, 38, 40, 42, 42, 42, 42, 45, 47, 48, 48,
        48, 49, 37, 37, 36, 36, 36, 36, 36, 35, 35, 35, 35, 36, 37, 37, 37, 37,
        38, 39, 39, 39, 39, 41, 42, 43, 43, 43, 45, 48, 49, 49, 49, 50,
        /* Size 4x8 */
        31, 31, 32, 35, 32, 32, 32, 35, 32, 32, 33, 34, 32, 32, 34, 36, 32, 33,
        35, 38, 33, 33, 36, 40, 34, 34, 37, 42, 35, 34, 38, 48,
        /* Size 8x4 */
        31, 32, 32, 32, 32, 33, 34, 35, 31, 32, 32, 32, 33, 33, 34, 34, 32, 32,
        33, 34, 35, 36, 37, 38, 35, 35, 34, 36, 38, 40, 42, 48,
        /* Size 8x16 */
        32, 31, 31, 31, 32, 32, 35, 36, 31, 32, 32, 32, 32, 32, 35, 35, 31, 32,
        32, 32, 32, 32, 35, 35, 31, 32, 32, 32, 32, 32, 34, 35, 31, 32, 32, 32,
        33, 33, 34, 34, 31, 32, 32, 32, 33, 33, 34, 34, 31, 32, 32, 33, 34, 34,
        35, 36, 32, 32, 32, 33, 34, 34, 36, 36, 32, 32, 32, 33, 34, 34, 36, 37,
        32, 32, 33, 34, 35, 35, 37, 38, 32, 32, 33, 34, 35, 35, 37, 38, 33, 33,
        33, 35, 36, 36, 40, 41, 34, 34, 34, 35, 37, 37, 41, 42, 34, 34, 34, 35,
        37, 37, 43, 44, 36, 35, 34, 36, 38, 38, 46, 48, 36, 35, 34, 36, 38, 38,
        46, 48,
        /* Size 16x8 */
        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 34, 34, 36, 36, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 31, 32, 32, 32, 32, 32,
        33, 33, 33, 34, 34, 35, 35, 35, 36, 36, 32, 32, 32, 32, 33, 33, 34, 34,
        34, 35, 35, 36, 37, 37, 38, 38, 32, 32, 32, 32, 33, 33, 34, 34, 34, 35,
        35, 36, 37, 37, 38, 38, 35, 35, 35, 34, 34, 34, 35, 36, 36, 37, 37, 40,
        41, 43, 46, 46, 36, 35, 35, 35, 34, 34, 36, 36, 37, 38, 38, 41, 42, 44,
        48, 48,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 35, 36, 36, 36, 31, 31,
        31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 35, 35, 35, 35, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 35, 35, 35, 35, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 35, 35, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 35, 35, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 35, 35, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        34, 35, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 35,
        35, 35, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34,
        31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 31, 32,
        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 31, 32, 32, 32,
        32, 32, 33, 33, 33, 33, 33, 34, 35, 35, 35, 35, 31, 32, 32, 32, 32, 32,
        33, 33, 34, 34, 34, 34, 35, 36, 36, 36, 32, 32, 32, 32, 32, 32, 33, 34,
        34, 34, 34, 35, 36, 36, 36, 36, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34,
        34, 35, 36, 36, 36, 36, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34, 35,
        36, 36, 36, 36, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 36, 37,
        37, 37, 32, 32, 32, 33, 33, 33, 33, 34, 35, 35, 35, 36, 37, 38, 38, 38,
        32, 32, 32, 33, 33, 33, 34, 35, 35, 35, 35, 36, 37, 38, 38, 38, 32, 32,
        32, 33, 33, 33, 34, 35, 35, 35, 35, 36, 37, 38, 38, 38, 32, 32, 32, 33,
        33, 33, 34, 35, 35, 35, 35, 36, 37, 38, 38, 38, 32, 33, 33, 33, 33, 33,
        34, 35, 36, 36, 36, 37, 39, 40, 40, 40, 33, 33, 33, 33, 33, 33, 35, 36,
        36, 36, 36, 38, 40, 41, 41, 41, 34, 34, 34, 34, 34, 34, 35, 36, 37, 37,
        37, 39, 41, 42, 42, 42, 34, 34, 34, 34, 34, 34, 35, 36, 37, 37, 37, 39,
        41, 42, 42, 42, 34, 34, 34, 34, 34, 34, 35, 36, 37, 37, 37, 39, 41, 42,
        42, 42, 34, 34, 34, 34, 34, 34, 35, 37, 37, 37, 37, 40, 43, 44, 44, 44,
        35, 35, 34, 34, 34, 34, 36, 37, 38, 38, 38, 41, 45, 47, 47, 47, 36, 35,
        35, 34, 34, 34, 36, 37, 38, 38, 38, 42, 46, 48, 48, 48, 36, 35, 35, 34,
        34, 34, 36, 37, 38, 38, 38, 42, 46, 48, 48, 48, 36, 35, 35, 34, 34, 34,
        36, 37, 38, 38, 38, 42, 46, 48, 48, 48, 37, 36, 36, 36, 36, 36, 37, 38,
        39, 39, 39, 42, 46, 49, 49, 49,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 36, 36, 36, 37, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 34, 34, 34, 34, 35, 35, 35, 35, 36, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34,
        34, 34, 35, 35, 35, 36, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34,
        34, 36, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 36, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
        33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 36, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35,
        35, 35, 35, 36, 36, 36, 36, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 37, 37,
        37, 37, 37, 38, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34,
        34, 34, 34, 35, 35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35,
        35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 36,
        36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 33, 33, 33, 33, 33, 33, 33, 33,
        33, 33, 33, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 37, 38, 39, 39, 39,
        40, 41, 42, 42, 42, 42, 35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 35,
        35, 36, 36, 36, 36, 37, 37, 37, 37, 39, 40, 41, 41, 41, 43, 45, 46, 46,
        46, 46, 36, 35, 35, 35, 35, 35, 35, 35, 34, 34, 34, 35, 36, 36, 36, 36,
        37, 38, 38, 38, 38, 40, 41, 42, 42, 42, 44, 47, 48, 48, 48, 49, 36, 35,
        35, 35, 35, 35, 35, 35, 34, 34, 34, 35, 36, 36, 36, 36, 37, 38, 38, 38,
        38, 40, 41, 42, 42, 42, 44, 47, 48, 48, 48, 49, 36, 35, 35, 35, 35, 35,
        35, 35, 34, 34, 34, 35, 36, 36, 36, 36, 37, 38, 38, 38, 38, 40, 41, 42,
        42, 42, 44, 47, 48, 48, 48, 49 },
      { /* Chroma */
        /* Size 4x4 */
        31, 32, 38, 46, 32, 34, 41, 46, 38, 41, 47, 47, 46, 46, 47, 52,
        /* Size 8x8 */
        31, 31, 30, 34, 36, 39, 42, 48, 31, 31, 31, 34, 37, 40, 42, 47, 30, 31,
        32, 35, 39, 41, 42, 46, 34, 34, 35, 39, 42, 44, 45, 47, 36, 37, 39, 42,
        46, 47, 47, 47, 39, 40, 41, 44, 47, 47, 48, 49, 42, 42, 42, 45, 47, 48,
        48, 50, 48, 47, 46, 47, 47, 49, 50, 53,
        /* Size 16x16 */
        32, 31, 31, 31, 30, 30, 33, 33, 34, 36, 36, 40, 41, 44, 49, 49, 31, 31,
        31, 31, 31, 31, 33, 34, 36, 38, 38, 41, 42, 44, 48, 48, 31, 31, 31, 31,
        31, 31, 34, 34, 36, 38, 38, 41, 42, 44, 47, 47, 31, 31, 31, 31, 31, 31,
        34, 35, 36, 39, 39, 41, 42, 44, 47, 47, 30, 31, 31, 31, 32, 32, 34, 35,
        37, 40, 40, 42, 42, 44, 46, 46, 30, 31, 31, 31, 32, 32, 34, 35, 37, 40,
        40, 42, 42, 44, 46, 46, 33, 33, 34, 34, 34, 34, 37, 38, 40, 42, 42, 44,
        44, 45, 47, 47, 33, 34, 34, 35, 35, 35, 38, 39, 40, 43, 43, 44, 45, 46,
        47, 47, 34, 36, 36, 36, 37, 37, 40, 40, 42, 45, 45, 45, 46, 46, 47, 47,
        36, 38, 38, 39, 40, 40, 42, 43, 45, 47, 47, 47, 47, 47, 48, 48, 36, 38,
        38, 39, 40, 40, 42, 43, 45, 47, 47, 47, 47, 47, 48, 48, 40, 41, 41, 41,
        42, 42, 44, 44, 45, 47, 47, 48, 48, 49, 50, 50, 41, 42, 42, 42, 42, 42,
        44, 45, 46, 47, 47, 48, 48, 49, 50, 50, 44, 44, 44, 44, 44, 44, 45, 46,
        46, 47, 47, 49, 49, 50, 51, 51, 49, 48, 47, 47, 46, 46, 47, 47, 47, 48,
        48, 50, 50, 51, 53, 53, 49, 48, 47, 47, 46, 46, 47, 47, 47, 48, 48, 50,
        50, 51, 53, 53,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 33, 33, 33, 33, 34, 36,
        36, 36, 36, 38, 40, 41, 41, 41, 44, 47, 49, 49, 49, 49, 31, 31, 31, 31,
        31, 31, 31, 31, 30, 30, 30, 32, 33, 34, 34, 34, 35, 36, 37, 37, 37, 39,
        41, 42, 42, 42, 44, 47, 48, 48, 48, 48, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 32, 33, 34, 34, 34, 36, 37, 38, 38, 38, 39, 41, 42, 42, 42,
        44, 46, 48, 48, 48, 47, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
        34, 34, 34, 34, 36, 37, 38, 38, 38, 40, 41, 42, 42, 42, 44, 46, 47, 47,
        47, 47, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 34, 34, 34, 34,
        36, 37, 38, 38, 38, 40, 41, 42, 42, 42, 44, 46, 47, 47, 47, 47, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 34, 34, 34, 34, 36, 37, 38, 38,
        38, 40, 41, 42, 42, 42, 44, 46, 47, 47, 47, 47, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 33, 34, 35, 35, 35, 36, 38, 39, 39, 39, 40, 41, 42,
        42, 42, 44, 46, 47, 47, 47, 47, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 33, 34, 35, 35, 35, 37, 38, 39, 39, 39, 41, 42, 42, 42, 42, 44, 46,
        46, 46, 46, 46, 30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 35,
        35, 35, 37, 39, 40, 40, 40, 41, 42, 42, 42, 42, 44, 45, 46, 46, 46, 46,
        30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 37, 39,
        40, 40, 40, 41, 42, 42, 42, 42, 44, 45, 46, 46, 46, 46, 30, 30, 31, 31,
        31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 37, 39, 40, 40, 40, 41,
        42, 42, 42, 42, 44, 45, 46, 46, 46, 46, 31, 32, 32, 32, 32, 32, 33, 33,
        33, 33, 33, 34, 36, 37, 37, 37, 38, 40, 41, 41, 41, 42, 43, 43, 43, 43,
        44, 46, 46, 46, 46, 46, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 36,
        37, 38, 38, 38, 40, 41, 42, 42, 42, 43, 44, 44, 44, 44, 45, 46, 47, 47,
        47, 46, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 37, 38, 39, 39, 39,
        40, 42, 43, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 47, 47, 47, 33, 34,
        34, 34, 34, 34, 35, 35, 35, 35, 35, 37, 38, 39, 39, 39, 40, 42, 43, 43,
        43, 44, 44, 45, 45, 45, 46, 47, 47, 47, 47, 47, 33, 34, 34, 34, 34, 34,
        35, 35, 35, 35, 35, 37, 38, 39, 39, 39, 40, 42, 43, 43, 43, 44, 44, 45,
        45, 45, 46, 47, 47, 47, 47, 47, 34, 35, 36, 36, 36, 36, 36, 37, 37, 37,
        37, 38, 40, 40, 40, 40, 42, 44, 45, 45, 45, 45, 45, 46, 46, 46, 46, 47,
        47, 47, 47, 47, 36, 36, 37, 37, 37, 37, 38, 38, 39, 39, 39, 40, 41, 42,
        42, 42, 44, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
        36, 37, 38, 38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 43, 43, 45, 46,
        47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 36, 37, 38, 38,
        38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 43, 43, 45, 46, 47, 47, 47, 47,
        47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 36, 37, 38, 38, 38, 38, 39, 39,
        40, 40, 40, 41, 42, 43, 43, 43, 45, 46, 47, 47, 47, 47, 47, 47, 47, 47,
        47, 47, 48, 48, 48, 47, 38, 39, 39, 40, 40, 40, 40, 41, 41, 41, 41, 42,
        43, 44, 44, 44, 45, 47, 47, 47, 47, 47, 48, 48, 48, 48, 48, 48, 49, 49,
        49, 48, 40, 41, 41, 41, 41, 41, 41, 42, 42, 42, 42, 43, 44, 44, 44, 44,
        45, 47, 47, 47, 47, 48, 48, 48, 48, 48, 49, 49, 50, 50, 50, 49, 41, 42,
        42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 44, 45, 45, 45, 46, 47, 47, 47,
        47, 48, 48, 48, 48, 48, 49, 50, 50, 50, 50, 50, 41, 42, 42, 42, 42, 42,
        42, 42, 42, 42, 42, 43, 44, 45, 45, 45, 46, 47, 47, 47, 47, 48, 48, 48,
        48, 48, 49, 50, 50, 50, 50, 50, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42,
        42, 43, 44, 45, 45, 45, 46, 47, 47, 47, 47, 48, 48, 48, 48, 48, 49, 50,
        50, 50, 50, 50, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 46,
        46, 46, 46, 47, 47, 47, 47, 48, 49, 49, 49, 49, 50, 51, 51, 51, 51, 51,
        47, 47, 46, 46, 46, 46, 46, 46, 45, 45, 45, 46, 46, 47, 47, 47, 47, 47,
        47, 47, 47, 48, 49, 50, 50, 50, 51, 52, 52, 52, 52, 52, 49, 48, 48, 47,
        47, 47, 47, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 48, 48, 49,
        50, 50, 50, 50, 51, 52, 53, 53, 53, 53, 49, 48, 48, 47, 47, 47, 47, 46,
        46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 48, 48, 49, 50, 50, 50, 50,
        51, 52, 53, 53, 53, 53, 49, 48, 48, 47, 47, 47, 47, 46, 46, 46, 46, 46,
        47, 47, 47, 47, 47, 47, 48, 48, 48, 49, 50, 50, 50, 50, 51, 52, 53, 53,
        53, 53, 49, 48, 47, 47, 47, 47, 47, 46, 46, 46, 46, 46, 46, 47, 47, 47,
        47, 47, 47, 47, 47, 48, 49, 50, 50, 50, 51, 52, 53, 53, 53, 53,
        /* Size 4x8 */
        31, 31, 37, 48, 31, 31, 38, 47, 31, 32, 40, 46, 34, 36, 43, 47, 37, 39,
        46, 47, 39, 41, 47, 48, 42, 43, 47, 50, 48, 46, 48, 53,
        /* Size 8x4 */
        31, 31, 31, 34, 37, 39, 42, 48, 31, 31, 32, 36, 39, 41, 43, 46, 37, 38,
        40, 43, 46, 47, 47, 48, 48, 47, 46, 47, 47, 48, 50, 53,
        /* Size 8x16 */
        32, 31, 31, 33, 37, 37, 45, 48, 31, 31, 31, 34, 38, 38, 45, 47, 31, 31,
        31, 34, 38, 38, 45, 47, 31, 31, 32, 34, 39, 39, 45, 46, 30, 32, 32, 35,
        40, 40, 44, 46, 30, 32, 32, 35, 40, 40, 44, 46, 33, 34, 35, 37, 42, 42,
        46, 47, 33, 35, 36, 38, 43, 43, 46, 47, 35, 37, 37, 40, 44, 44, 46, 47,
        37, 39, 40, 43, 47, 47, 47, 47, 37, 39, 40, 43, 47, 47, 47, 47, 41, 42,
        42, 44, 47, 47, 49, 49, 42, 42, 43, 44, 47, 47, 49, 50, 44, 44, 44, 45,
        47, 47, 50, 51, 49, 47, 46, 47, 48, 48, 52, 53, 49, 47, 46, 47, 48, 48,
        52, 53,
        /* Size 16x8 */
        32, 31, 31, 31, 30, 30, 33, 33, 35, 37, 37, 41, 42, 44, 49, 49, 31, 31,
        31, 31, 32, 32, 34, 35, 37, 39, 39, 42, 42, 44, 47, 47, 31, 31, 31, 32,
        32, 32, 35, 36, 37, 40, 40, 42, 43, 44, 46, 46, 33, 34, 34, 34, 35, 35,
        37, 38, 40, 43, 43, 44, 44, 45, 47, 47, 37, 38, 38, 39, 40, 40, 42, 43,
        44, 47, 47, 47, 47, 47, 48, 48, 37, 38, 38, 39, 40, 40, 42, 43, 44, 47,
        47, 47, 47, 47, 48, 48, 45, 45, 45, 45, 44, 44, 46, 46, 46, 47, 47, 49,
        49, 50, 52, 52, 48, 47, 47, 46, 46, 46, 47, 47, 47, 47, 47, 49, 50, 51,
        53, 53,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 31, 33, 35, 37, 37, 37, 40, 45, 48, 48, 48, 31, 31,
        31, 31, 31, 31, 33, 36, 37, 37, 37, 41, 45, 48, 48, 48, 31, 31, 31, 31,
        31, 31, 34, 36, 38, 38, 38, 41, 45, 47, 47, 47, 31, 31, 31, 31, 31, 31,
        34, 37, 38, 38, 38, 41, 45, 47, 47, 47, 31, 31, 31, 31, 31, 31, 34, 37,
        38, 38, 38, 41, 45, 47, 47, 47, 31, 31, 31, 31, 31, 31, 34, 37, 38, 38,
        38, 41, 45, 47, 47, 47, 31, 31, 31, 32, 32, 32, 34, 37, 39, 39, 39, 41,
        45, 46, 46, 46, 30, 31, 31, 32, 32, 32, 34, 38, 39, 39, 39, 42, 44, 46,
        46, 46, 30, 31, 32, 32, 32, 32, 35, 38, 40, 40, 40, 42, 44, 46, 46, 46,
        30, 31, 32, 32, 32, 32, 35, 38, 40, 40, 40, 42, 44, 46, 46, 46, 30, 31,
        32, 32, 32, 32, 35, 38, 40, 40, 40, 42, 44, 46, 46, 46, 31, 32, 33, 33,
        33, 33, 36, 39, 41, 41, 41, 43, 45, 46, 46, 46, 33, 34, 34, 35, 35, 35,
        37, 40, 42, 42, 42, 44, 46, 47, 47, 47, 33, 34, 35, 36, 36, 36, 38, 41,
        43, 43, 43, 44, 46, 47, 47, 47, 33, 34, 35, 36, 36, 36, 38, 41, 43, 43,
        43, 44, 46, 47, 47, 47, 33, 34, 35, 36, 36, 36, 38, 41, 43, 43, 43, 44,
        46, 47, 47, 47, 35, 36, 37, 37, 37, 37, 40, 43, 44, 44, 44, 45, 46, 47,
        47, 47, 36, 37, 38, 39, 39, 39, 42, 44, 46, 46, 46, 47, 47, 47, 47, 47,
        37, 38, 39, 40, 40, 40, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 37, 38,
        39, 40, 40, 40, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 37, 38, 39, 40,
        40, 40, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 39, 39, 40, 41, 41, 41,
        43, 46, 47, 47, 47, 48, 48, 48, 48, 48, 41, 41, 42, 42, 42, 42, 44, 46,
        47, 47, 47, 48, 49, 49, 49, 49, 42, 42, 42, 43, 43, 43, 44, 46, 47, 47,
        47, 48, 49, 50, 50, 50, 42, 42, 42, 43, 43, 43, 44, 46, 47, 47, 47, 48,
        49, 50, 50, 50, 42, 42, 42, 43, 43, 43, 44, 46, 47, 47, 47, 48, 49, 50,
        50, 50, 44, 44, 44, 44, 44, 44, 45, 47, 47, 47, 47, 49, 50, 51, 51, 51,
        47, 46, 46, 46, 46, 46, 46, 47, 48, 48, 48, 49, 51, 52, 52, 52, 49, 48,
        47, 46, 46, 46, 47, 48, 48, 48, 48, 50, 52, 53, 53, 53, 49, 48, 47, 46,
        46, 46, 47, 48, 48, 48, 48, 50, 52, 53, 53, 53, 49, 48, 47, 46, 46, 46,
        47, 48, 48, 48, 48, 50, 52, 53, 53, 53, 49, 48, 47, 46, 46, 46, 47, 47,
        47, 47, 47, 49, 52, 53, 53, 53,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 33, 33, 33, 33, 35, 36,
        37, 37, 37, 39, 41, 42, 42, 42, 44, 47, 49, 49, 49, 49, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 34, 34, 34, 34, 36, 37, 38, 38, 38, 39,
        41, 42, 42, 42, 44, 46, 48, 48, 48, 48, 31, 31, 31, 31, 31, 31, 31, 31,
        32, 32, 32, 33, 34, 35, 35, 35, 37, 38, 39, 39, 39, 40, 42, 42, 42, 42,
        44, 46, 47, 47, 47, 47, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33,
        35, 36, 36, 36, 37, 39, 40, 40, 40, 41, 42, 43, 43, 43, 44, 46, 46, 46,
        46, 46, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 35, 36, 36, 36,
        37, 39, 40, 40, 40, 41, 42, 43, 43, 43, 44, 46, 46, 46, 46, 46, 31, 31,
        31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 35, 36, 36, 36, 37, 39, 40, 40,
        40, 41, 42, 43, 43, 43, 44, 46, 46, 46, 46, 46, 33, 33, 34, 34, 34, 34,
        34, 34, 35, 35, 35, 36, 37, 38, 38, 38, 40, 42, 43, 43, 43, 43, 44, 44,
        44, 44, 45, 46, 47, 47, 47, 47, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38,
        38, 39, 40, 41, 41, 41, 43, 44, 45, 45, 45, 46, 46, 46, 46, 46, 47, 47,
        48, 48, 48, 47, 37, 37, 38, 38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43,
        43, 43, 44, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 47,
        37, 37, 38, 38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 43, 43, 44, 46,
        47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 47, 37, 37, 38, 38,
        38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 43, 43, 44, 46, 47, 47, 47, 47,
        47, 47, 47, 47, 47, 48, 48, 48, 48, 47, 40, 41, 41, 41, 41, 41, 41, 42,
        42, 42, 42, 43, 44, 44, 44, 44, 45, 47, 47, 47, 47, 48, 48, 48, 48, 48,
        49, 49, 50, 50, 50, 49, 45, 45, 45, 45, 45, 45, 45, 44, 44, 44, 44, 45,
        46, 46, 46, 46, 46, 47, 47, 47, 47, 48, 49, 49, 49, 49, 50, 51, 52, 52,
        52, 52, 48, 48, 47, 47, 47, 47, 46, 46, 46, 46, 46, 46, 47, 47, 47, 47,
        47, 47, 47, 47, 47, 48, 49, 50, 50, 50, 51, 52, 53, 53, 53, 53, 48, 48,
        47, 47, 47, 47, 46, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47,
        47, 48, 49, 50, 50, 50, 51, 52, 53, 53, 53, 53, 48, 48, 47, 47, 47, 47,
        46, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 49, 50,
        50, 50, 51, 52, 53, 53, 53, 53 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        31, 32, 32, 32, 32, 32, 32, 33, 32, 32, 33, 34, 32, 33, 34, 35,
        /* Size 8x8 */
        31, 31, 31, 31, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 32, 33, 31, 32,
        32, 32, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32,
        33, 33, 34, 35, 32, 32, 32, 32, 33, 34, 34, 35, 32, 32, 32, 32, 34, 34,
        35, 36, 33, 33, 33, 33, 35, 35, 36, 38,
        /* Size 16x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 31, 31,
        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 33, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
        33, 34, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 35,
        31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 31, 32,
        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 33, 33, 34, 35, 35, 35, 36, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 34, 34, 35, 35, 35, 36, 37, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 34, 34, 35, 35, 35, 36, 37, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34,
        34, 35, 36, 36, 36, 38, 34, 34, 34, 34, 34, 33, 33, 34, 35, 35, 35, 36,
        37, 37, 38, 39,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 33, 34, 34, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
        34, 34, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 33, 34, 34, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        33, 33, 34, 34, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34,
        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 33, 33, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
        33, 33, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
        33, 33, 33, 33, 34, 34, 34, 34, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34,
        34, 34, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
        33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33,
        33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34,
        34, 34, 34, 35, 35, 35, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 35, 35,
        35, 35, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
        33, 33, 33, 33, 33, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34,
        34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35,
        35, 35, 35, 35, 36, 36, 37, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35,
        36, 36, 37, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 37, 37,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34,
        34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 32, 32, 33, 33,
        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35,
        35, 35, 36, 36, 36, 36, 36, 37, 38, 38, 33, 33, 33, 33, 33, 33, 33, 33,
        33, 33, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 36,
        36, 36, 37, 38, 38, 38, 34, 34, 34, 34, 34, 34, 34, 34, 34, 33, 33, 33,
        33, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38,
        39, 39, 34, 34, 34, 34, 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, 34, 34,
        35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38, 39, 39,
        /* Size 4x8 */
        31, 31, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32,
        33, 34, 32, 32, 34, 34, 32, 33, 34, 35, 33, 33, 35, 36,
        /* Size 8x4 */
        31, 31, 32, 32, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 33, 33, 32, 32,
        32, 32, 33, 34, 34, 35, 32, 32, 32, 33, 34, 34, 35, 36,
        /* Size 8x16 */
        32, 31, 31, 31, 31, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 33, 31, 32,
        32, 32, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 32, 33, 31, 32, 32, 32,
        32, 32, 32, 33, 31, 32, 32, 32, 32, 33, 33, 33, 31, 32, 32, 32, 32, 33,
        33, 33, 31, 32, 32, 32, 32, 33, 33, 33, 31, 32, 32, 32, 33, 34, 34, 34,
        32, 32, 32, 32, 33, 34, 34, 34, 32, 32, 32, 32, 33, 34, 34, 34, 32, 32,
        32, 32, 33, 35, 35, 35, 32, 32, 33, 33, 34, 35, 35, 36, 32, 32, 33, 33,
        34, 35, 35, 36, 32, 33, 33, 33, 34, 36, 36, 36, 34, 34, 34, 34, 35, 37,
        37, 38,
        /* Size 16x8 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 34, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 31, 32, 32, 32, 32, 32, 32, 32,
        33, 33, 33, 33, 34, 34, 34, 35, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34,
        34, 35, 35, 35, 36, 37, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35,
        35, 35, 36, 37, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 35, 36, 36,
        36, 38,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 34, 31, 31,
        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        33, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 33, 33, 33, 33, 34, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
        33, 33, 34, 34, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34,
        34, 35, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 34, 34, 34, 34, 34, 35, 35, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 34, 35, 35, 35, 35, 35, 36, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34,
        35, 35, 35, 35, 36, 36, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 35, 35,
        35, 35, 36, 37, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35,
        36, 37, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 36, 37,
        32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 36, 37, 32, 33,
        33, 33, 33, 33, 33, 33, 34, 35, 36, 36, 36, 36, 36, 38, 33, 33, 33, 33,
        33, 33, 33, 34, 34, 35, 36, 36, 36, 36, 37, 38, 34, 34, 34, 34, 34, 34,
        34, 34, 35, 36, 37, 37, 37, 37, 38, 39, 34, 34, 34, 34, 34, 34, 34, 34,
        35, 36, 37, 37, 37, 37, 38, 39,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 33, 34, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
        34, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 33, 33, 33, 33, 33, 34, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
        33, 34, 34, 34, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
        33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 35, 35, 36, 36, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34,
        35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35,
        35, 35, 36, 36, 37, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
        33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36,
        37, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
        34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 32, 33,
        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34,
        34, 35, 35, 36, 36, 36, 36, 36, 36, 37, 38, 38, 34, 34, 34, 34, 34, 34,
        34, 34, 34, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36,
        37, 37, 37, 37, 38, 38, 39, 39 },
      { /* Chroma */
        /* Size 4x4 */
        31, 31, 34, 38, 31, 32, 35, 40, 34, 35, 39, 43, 38, 40, 43, 47,
        /* Size 8x8 */
        31, 31, 31, 30, 34, 35, 37, 40, 31, 31, 31, 31, 34, 35, 38, 41, 31, 31,
        31, 31, 35, 36, 39, 41, 30, 31, 31, 32, 35, 36, 40, 42, 34, 34, 35, 35,
        39, 40, 43, 44, 35, 35, 36, 36, 40, 41, 44, 45, 37, 38, 39, 40, 43, 44,
        47, 47, 40, 41, 41, 42, 44, 45, 47, 48,
        /* Size 16x16 */
        32, 31, 31, 31, 31, 30, 30, 31, 33, 33, 33, 35, 36, 36, 38, 41, 31, 31,
        31, 31, 31, 31, 31, 31, 33, 34, 34, 36, 37, 37, 39, 42, 31, 31, 31, 31,
        31, 31, 31, 32, 34, 34, 34, 37, 38, 38, 40, 42, 31, 31, 31, 31, 31, 31,
        31, 32, 34, 34, 34, 37, 38, 38, 40, 42, 31, 31, 31, 31, 31, 31, 31, 32,
        34, 35, 35, 37, 39, 39, 40, 42, 30, 31, 31, 31, 31, 32, 32, 32, 34, 35,
        35, 38, 40, 40, 41, 42, 30, 31, 31, 31, 31, 32, 32, 32, 34, 35, 35, 38,
        40, 40, 41, 42, 31, 31, 32, 32, 32, 32, 32, 33, 35, 36, 36, 38, 40, 40,
        41, 43, 33, 33, 34, 34, 34, 34, 34, 35, 37, 38, 38, 41, 42, 42, 43, 44,
        33, 34, 34, 34, 35, 35, 35, 36, 38, 39, 39, 41, 43, 43, 44, 45, 33, 34,
        34, 34, 35, 35, 35, 36, 38, 39, 39, 41, 43, 43, 44, 45, 35, 36, 37, 37,
        37, 38, 38, 38, 41, 41, 41, 44, 46, 46, 46, 46, 36, 37, 38, 38, 39, 40,
        40, 40, 42, 43, 43, 46, 47, 47, 47, 47, 36, 37, 38, 38, 39, 40, 40, 40,
        42, 43, 43, 46, 47, 47, 47, 47, 38, 39, 40, 40, 40, 41, 41, 41, 43, 44,
        44, 46, 47, 47, 47, 48, 41, 42, 42, 42, 42, 42, 42, 43, 44, 45, 45, 46,
        47, 47, 48, 48,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 32, 33, 33,
        33, 33, 33, 34, 35, 36, 36, 36, 36, 37, 38, 40, 41, 41, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 32, 33, 34, 34, 34, 34, 35,
        36, 37, 37, 37, 37, 37, 39, 40, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 34, 35, 36, 37, 37, 37,
        37, 38, 39, 40, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 32, 32, 34, 34, 34, 34, 34, 35, 36, 38, 38, 38, 38, 38, 40, 41,
        42, 42, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33,
        34, 34, 34, 34, 34, 35, 37, 38, 38, 38, 38, 39, 40, 41, 42, 42, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 34,
        34, 35, 37, 38, 38, 38, 38, 39, 40, 41, 42, 42, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 34, 34, 35, 37, 38,
        38, 38, 38, 39, 40, 41, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 32, 33, 34, 34, 34, 34, 34, 36, 37, 38, 38, 38, 38, 39,
        40, 41, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        32, 33, 34, 35, 35, 35, 35, 36, 37, 38, 39, 39, 39, 39, 40, 41, 42, 42,
        30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 35,
        35, 35, 35, 36, 37, 39, 39, 39, 39, 40, 40, 41, 42, 42, 30, 30, 31, 31,
        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 34, 35, 35, 35, 35, 36,
        38, 39, 40, 40, 40, 40, 41, 42, 42, 42, 30, 30, 31, 31, 31, 31, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 33, 34, 35, 35, 35, 35, 36, 38, 39, 40, 40,
        40, 40, 41, 42, 42, 42, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 33, 34, 35, 35, 35, 35, 36, 38, 39, 40, 40, 40, 40, 41, 42,
        42, 42, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33,
        34, 35, 35, 35, 35, 36, 38, 39, 40, 40, 40, 40, 41, 42, 42, 42, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 35, 36, 36, 36,
        36, 37, 38, 40, 40, 40, 40, 41, 41, 42, 43, 43, 32, 32, 32, 32, 33, 33,
        33, 33, 33, 33, 33, 33, 33, 33, 34, 35, 36, 37, 37, 37, 37, 38, 39, 41,
        41, 41, 41, 42, 42, 43, 43, 43, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34,
        34, 34, 34, 34, 35, 36, 37, 38, 38, 38, 38, 39, 41, 42, 42, 42, 42, 43,
        43, 44, 44, 44, 33, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35,
        36, 37, 38, 39, 39, 39, 39, 40, 41, 43, 43, 43, 43, 43, 44, 44, 45, 45,
        33, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 37, 38, 39,
        39, 39, 39, 40, 41, 43, 43, 43, 43, 43, 44, 44, 45, 45, 33, 34, 34, 34,
        34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 37, 38, 39, 39, 39, 39, 40,
        41, 43, 43, 43, 43, 43, 44, 44, 45, 45, 33, 34, 34, 34, 34, 34, 34, 34,
        35, 35, 35, 35, 35, 35, 36, 37, 38, 39, 39, 39, 39, 40, 41, 43, 43, 43,
        43, 43, 44, 44, 45, 45, 34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36,
        36, 36, 37, 38, 39, 40, 40, 40, 40, 41, 42, 44, 44, 44, 44, 44, 45, 45,
        45, 45, 35, 36, 36, 36, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 39,
        41, 41, 41, 41, 41, 42, 44, 45, 46, 46, 46, 46, 46, 46, 46, 46, 36, 37,
        37, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 40, 41, 42, 43, 43, 43,
        43, 44, 45, 46, 47, 47, 47, 47, 47, 47, 47, 47, 36, 37, 37, 38, 38, 38,
        38, 38, 39, 39, 40, 40, 40, 40, 40, 41, 42, 43, 43, 43, 43, 44, 46, 47,
        47, 47, 47, 47, 47, 47, 47, 47, 36, 37, 37, 38, 38, 38, 38, 38, 39, 39,
        40, 40, 40, 40, 40, 41, 42, 43, 43, 43, 43, 44, 46, 47, 47, 47, 47, 47,
        47, 47, 47, 47, 36, 37, 37, 38, 38, 38, 38, 38, 39, 39, 40, 40, 40, 40,
        40, 41, 42, 43, 43, 43, 43, 44, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47,
        37, 37, 38, 38, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 41, 42, 43, 43,
        43, 43, 43, 44, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 38, 39, 39, 40,
        40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 42, 43, 44, 44, 44, 44, 45,
        46, 47, 47, 47, 47, 47, 47, 48, 48, 48, 40, 40, 40, 41, 41, 41, 41, 41,
        41, 41, 42, 42, 42, 42, 42, 43, 44, 44, 44, 44, 44, 45, 46, 47, 47, 47,
        47, 47, 48, 48, 48, 48, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
        42, 42, 43, 43, 44, 45, 45, 45, 45, 45, 46, 47, 47, 47, 47, 47, 48, 48,
        48, 48, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43,
        44, 45, 45, 45, 45, 45, 46, 47, 47, 47, 47, 47, 48, 48, 48, 48,
        /* Size 4x8 */
        31, 31, 35, 37, 31, 31, 36, 38, 31, 32, 37, 39, 31, 32, 37, 40, 34, 36,
        40, 43, 35, 37, 42, 44, 38, 40, 45, 47, 41, 42, 45, 47,
        /* Size 8x4 */
        31, 31, 31, 31, 34, 35, 38, 41, 31, 31, 32, 32, 36, 37, 40, 42, 35, 36,
        37, 37, 40, 42, 45, 45, 37, 38, 39, 40, 43, 44, 47, 47,
        /* Size 8x16 */
        32, 31, 31, 31, 33, 37, 37, 38, 31, 31, 31, 31, 33, 38, 38, 39, 31, 31,
        31, 31, 34, 38, 38, 40, 31, 31, 31, 31, 34, 38, 38, 40, 31, 31, 32, 32,
        34, 39, 39, 40, 30, 31, 32, 32, 35, 40, 40, 41, 30, 31, 32, 32, 35, 40,
        40, 41, 31, 32, 33, 33, 35, 40, 40, 41, 33, 34, 35, 35, 37, 42, 42, 43,
        33, 35, 36, 36, 38, 43, 43, 44, 33, 35, 36, 36, 38, 43, 43, 44, 35, 37,
        38, 38, 41, 45, 45, 46, 37, 39, 40, 40, 43, 47, 47, 47, 37, 39, 40, 40,
        43, 47, 47, 47, 39, 40, 41, 41, 43, 47, 47, 47, 42, 42, 43, 43, 44, 47,
        47, 48,
        /* Size 16x8 */
        32, 31, 31, 31, 31, 30, 30, 31, 33, 33, 33, 35, 37, 37, 39, 42, 31, 31,
        31, 31, 31, 31, 31, 32, 34, 35, 35, 37, 39, 39, 40, 42, 31, 31, 31, 31,
        32, 32, 32, 33, 35, 36, 36, 38, 40, 40, 41, 43, 31, 31, 31, 31, 32, 32,
        32, 33, 35, 36, 36, 38, 40, 40, 41, 43, 33, 33, 34, 34, 34, 35, 35, 35,
        37, 38, 38, 41, 43, 43, 43, 44, 37, 38, 38, 38, 39, 40, 40, 40, 42, 43,
        43, 45, 47, 47, 47, 47, 37, 38, 38, 38, 39, 40, 40, 40, 42, 43, 43, 45,
        47, 47, 47, 47, 38, 39, 40, 40, 40, 41, 41, 41, 43, 44, 44, 46, 47, 47,
        47, 48,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 33, 35, 37, 37, 37, 37, 38, 42, 31, 31,
        31, 31, 31, 31, 31, 31, 33, 35, 37, 37, 37, 37, 39, 42, 31, 31, 31, 31,
        31, 31, 31, 32, 33, 35, 38, 38, 38, 38, 39, 42, 31, 31, 31, 31, 31, 31,
        31, 32, 34, 36, 38, 38, 38, 38, 40, 42, 31, 31, 31, 31, 31, 31, 31, 32,
        34, 36, 38, 38, 38, 38, 40, 42, 31, 31, 31, 31, 31, 31, 31, 32, 34, 36,
        38, 38, 38, 38, 40, 42, 31, 31, 31, 31, 31, 31, 31, 32, 34, 36, 38, 38,
        38, 38, 40, 42, 31, 31, 31, 31, 31, 31, 31, 32, 34, 36, 38, 38, 38, 38,
        40, 42, 31, 31, 31, 31, 32, 32, 32, 32, 34, 36, 39, 39, 39, 39, 40, 42,
        30, 31, 31, 32, 32, 32, 32, 32, 34, 37, 39, 39, 39, 39, 40, 42, 30, 31,
        31, 32, 32, 32, 32, 33, 35, 37, 40, 40, 40, 40, 41, 42, 30, 31, 31, 32,
        32, 32, 32, 33, 35, 37, 40, 40, 40, 40, 41, 42, 30, 31, 31, 32, 32, 32,
        32, 33, 35, 37, 40, 40, 40, 40, 41, 42, 30, 31, 31, 32, 32, 32, 32, 33,
        35, 37, 40, 40, 40, 40, 41, 42, 31, 31, 32, 32, 33, 33, 33, 33, 35, 38,
        40, 40, 40, 40, 41, 43, 32, 32, 33, 33, 34, 34, 34, 34, 36, 39, 41, 41,
        41, 41, 42, 44, 33, 33, 34, 35, 35, 35, 35, 35, 37, 40, 42, 42, 42, 42,
        43, 44, 33, 34, 35, 35, 36, 36, 36, 36, 38, 40, 43, 43, 43, 43, 44, 45,
        33, 34, 35, 35, 36, 36, 36, 36, 38, 40, 43, 43, 43, 43, 44, 45, 33, 34,
        35, 35, 36, 36, 36, 36, 38, 40, 43, 43, 43, 43, 44, 45, 33, 34, 35, 35,
        36, 36, 36, 36, 38, 40, 43, 43, 43, 43, 44, 45, 34, 35, 36, 37, 37, 37,
        37, 37, 39, 42, 44, 44, 44, 44, 45, 45, 35, 36, 37, 38, 38, 38, 38, 39,
        41, 43, 45, 45, 45, 45, 46, 46, 36, 37, 38, 39, 39, 39, 39, 40, 42, 44,
        47, 47, 47, 47, 47, 47, 37, 38, 39, 40, 40, 40, 40, 41, 43, 45, 47, 47,
        47, 47, 47, 47, 37, 38, 39, 40, 40, 40, 40, 41, 43, 45, 47, 47, 47, 47,
        47, 47, 37, 38, 39, 40, 40, 40, 40, 41, 43, 45, 47, 47, 47, 47, 47, 47,
        37, 38, 39, 40, 40, 40, 40, 41, 43, 45, 47, 47, 47, 47, 47, 47, 39, 39,
        40, 41, 41, 41, 41, 42, 43, 45, 47, 47, 47, 47, 47, 48, 40, 41, 41, 42,
        42, 42, 42, 42, 44, 45, 47, 47, 47, 47, 47, 48, 42, 42, 42, 43, 43, 43,
        43, 43, 44, 46, 47, 47, 47, 47, 48, 48, 42, 42, 42, 43, 43, 43, 43, 43,
        44, 46, 47, 47, 47, 47, 48, 48,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 32, 33, 33,
        33, 33, 33, 34, 35, 36, 37, 37, 37, 37, 39, 40, 42, 42, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 34, 35,
        36, 37, 38, 38, 38, 38, 39, 41, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 32, 33, 34, 35, 35, 35, 35, 36, 37, 38, 39, 39,
        39, 39, 40, 41, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 33, 35, 35, 35, 35, 35, 37, 38, 39, 40, 40, 40, 40, 41, 42,
        43, 43, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 33, 34,
        35, 36, 36, 36, 36, 37, 38, 39, 40, 40, 40, 40, 41, 42, 43, 43, 31, 31,
        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 33, 34, 35, 36, 36, 36,
        36, 37, 38, 39, 40, 40, 40, 40, 41, 42, 43, 43, 31, 31, 31, 31, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 33, 34, 35, 36, 36, 36, 36, 37, 38, 39,
        40, 40, 40, 40, 41, 42, 43, 43, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        33, 33, 33, 33, 33, 34, 35, 36, 36, 36, 36, 37, 39, 40, 41, 41, 41, 41,
        42, 42, 43, 43, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35,
        35, 36, 37, 38, 38, 38, 38, 39, 41, 42, 43, 43, 43, 43, 43, 44, 44, 44,
        35, 35, 35, 36, 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 38, 39, 40, 40,
        40, 40, 40, 42, 43, 44, 45, 45, 45, 45, 45, 45, 46, 46, 37, 37, 38, 38,
        38, 38, 38, 38, 39, 39, 40, 40, 40, 40, 40, 41, 42, 43, 43, 43, 43, 44,
        45, 47, 47, 47, 47, 47, 47, 47, 47, 47, 37, 37, 38, 38, 38, 38, 38, 38,
        39, 39, 40, 40, 40, 40, 40, 41, 42, 43, 43, 43, 43, 44, 45, 47, 47, 47,
        47, 47, 47, 47, 47, 47, 37, 37, 38, 38, 38, 38, 38, 38, 39, 39, 40, 40,
        40, 40, 40, 41, 42, 43, 43, 43, 43, 44, 45, 47, 47, 47, 47, 47, 47, 47,
        47, 47, 37, 37, 38, 38, 38, 38, 38, 38, 39, 39, 40, 40, 40, 40, 40, 41,
        42, 43, 43, 43, 43, 44, 45, 47, 47, 47, 47, 47, 47, 47, 47, 47, 38, 39,
        39, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 42, 43, 44, 44, 44,
        44, 45, 46, 47, 47, 47, 47, 47, 47, 47, 48, 48, 42, 42, 42, 42, 42, 42,
        42, 42, 42, 42, 42, 42, 42, 42, 43, 44, 44, 45, 45, 45, 45, 45, 46, 47,
        47, 47, 47, 47, 48, 48, 48, 48 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        31, 31, 31, 32, 31, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 33,
        /* Size 8x8 */
        31, 31, 31, 31, 31, 31, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32,
        32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32,
        32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        33, 33, 32, 32, 32, 32, 32, 32, 33, 33,
        /* Size 16x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 31, 31, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 33, 33, 33,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
        33, 33, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
        33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
        33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
        /* Size 4x8 */
        31, 31, 31, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32,
        32, 32, 31, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33,
        /* Size 8x4 */
        31, 31, 31, 31, 31, 31, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
        /* Size 8x16 */
        32, 31, 31, 31, 31, 31, 31, 32, 31, 31, 31, 31, 31, 31, 32, 32, 31, 31,
        32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32,
        32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32,
        32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32,
        31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32,
        32, 32, 32, 32, 33, 33, 31, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32,
        32, 32, 33, 34, 32, 32, 32, 32, 32, 32, 33, 34, 32, 32, 32, 32, 32, 32,
        33, 34,
        /* Size 16x8 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34,
        34, 34,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 33, 33, 34, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
        34, 34, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 33, 34, 34,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
        33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33,
        34, 34, 34, 34, 34, 34, 34, 34 },
      { /* Chroma */
        /* Size 4x4 */
        31, 31, 31, 34, 31, 31, 31, 35, 31, 31, 32, 35, 34, 35, 35, 39,
        /* Size 8x8 */
        31, 31, 31, 31, 30, 31, 33, 33, 31, 31, 31, 31, 31, 32, 34, 34, 31, 31,
        31, 31, 31, 32, 34, 34, 31, 31, 31, 31, 31, 32, 35, 35, 30, 31, 31, 31,
        32, 32, 35, 35, 31, 32, 32, 32, 32, 33, 36, 36, 33, 34, 34, 35, 35, 36,
        39, 39, 33, 34, 34, 35, 35, 36, 39, 39,
        /* Size 16x16 */
        32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 33, 33, 33, 33, 31, 31,
        31, 31, 31, 31, 31, 31, 30, 30, 30, 32, 33, 34, 34, 34, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 32, 34, 34, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 32, 34, 34, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 32, 34, 34, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33,
        34, 35, 35, 35, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35,
        35, 35, 30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35,
        30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 30, 30,
        31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 31, 32, 32, 32,
        32, 32, 33, 33, 33, 33, 33, 34, 36, 37, 37, 37, 33, 33, 33, 34, 34, 34,
        34, 34, 34, 34, 34, 36, 37, 38, 38, 38, 33, 34, 34, 34, 34, 34, 35, 35,
        35, 35, 35, 37, 38, 39, 39, 39, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35,
        35, 37, 38, 39, 39, 39, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 37,
        38, 39, 39, 39,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30,
        30, 30, 30, 31, 31, 32, 33, 33, 33, 33, 33, 33, 33, 34, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 31,
        31, 32, 33, 33, 33, 33, 33, 33, 33, 34, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 31, 32, 32, 33, 34,
        34, 34, 34, 34, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 33, 34, 34, 34, 34, 34,
        34, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 32, 33, 33, 34, 34, 34, 34, 34, 34, 35, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 32, 32, 33, 34, 34, 34, 34, 34, 34, 34, 35, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 33,
        34, 34, 34, 34, 34, 34, 34, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 33, 34, 34, 34, 34,
        34, 34, 34, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 32, 33, 34, 34, 34, 34, 34, 34, 34, 35,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 32, 32, 33, 34, 34, 34, 34, 34, 34, 34, 35, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
        32, 33, 34, 34, 34, 34, 34, 34, 34, 35, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 33, 34, 35,
        35, 35, 35, 35, 35, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 33, 34, 35, 35, 35, 35, 35,
        35, 35, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 32, 33, 33, 34, 35, 35, 35, 35, 35, 35, 36, 30, 30,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 32, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 30, 30, 30, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34,
        34, 35, 35, 35, 35, 35, 35, 36, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 35,
        35, 35, 35, 36, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36,
        30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 30, 30, 30, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 30, 30, 30, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35,
        35, 35, 35, 35, 35, 36, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 36, 36, 36, 36, 36,
        36, 37, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
        33, 33, 33, 33, 33, 34, 34, 35, 36, 37, 37, 37, 37, 37, 37, 37, 32, 32,
        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34,
        34, 34, 35, 36, 37, 37, 37, 37, 37, 37, 37, 38, 33, 33, 33, 33, 33, 34,
        34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 36, 37,
        37, 38, 38, 38, 38, 38, 38, 39, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34,
        34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 37, 37, 38, 39, 39, 39,
        39, 39, 39, 40, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35,
        35, 35, 35, 35, 35, 35, 35, 36, 37, 37, 38, 39, 39, 39, 39, 39, 39, 40,
        33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35,
        35, 35, 35, 36, 37, 37, 38, 39, 39, 39, 39, 39, 39, 40, 33, 33, 34, 34,
        34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36,
        37, 37, 38, 39, 39, 39, 39, 39, 39, 40, 33, 33, 34, 34, 34, 34, 34, 34,
        34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 37, 37, 38, 39,
        39, 39, 39, 39, 39, 40, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35,
        35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 37, 37, 38, 39, 39, 39, 39, 39,
        39, 40, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, 36,
        36, 36, 36, 36, 36, 37, 37, 38, 39, 40, 40, 40, 40, 40, 40, 40,
        /* Size 4x8 */
        31, 31, 31, 34, 31, 31, 31, 35, 31, 31, 31, 35, 31, 32, 32, 36, 31, 32,
        32, 36, 31, 33, 33, 37, 34, 36, 36, 40, 34, 36, 36, 40,
        /* Size 8x4 */
        31, 31, 31, 31, 31, 31, 34, 34, 31, 31, 31, 32, 32, 33, 36, 36, 31, 31,
        31, 32, 32, 33, 36, 36, 34, 35, 35, 36, 36, 37, 40, 40,
        /* Size 8x16 */
        32, 31, 31, 31, 31, 31, 33, 35, 31, 31, 31, 31, 31, 31, 33, 36, 31, 31,
        31, 31, 31, 31, 34, 36, 31, 31, 31, 31, 31, 31, 34, 37, 31, 31, 31, 31,
        31, 31, 34, 37, 31, 31, 31, 31, 31, 31, 34, 37, 31, 31, 31, 32, 32, 32,
        34, 37, 30, 31, 31, 32, 32, 32, 34, 38, 30, 31, 32, 32, 32, 32, 35, 38,
        30, 31, 32, 32, 32, 32, 35, 38, 30, 31, 32, 32, 32, 32, 35, 38, 31, 32,
        33, 33, 33, 33, 36, 39, 33, 34, 34, 35, 35, 35, 37, 40, 33, 34, 35, 36,
        36, 36, 38, 41, 33, 34, 35, 36, 36, 36, 38, 41, 33, 34, 35, 36, 36, 36,
        38, 41,
        /* Size 16x8 */
        32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 33, 33, 33, 33, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 34, 34, 34, 34, 31, 31, 31, 31,
        31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 31, 31, 31, 31, 31, 31,
        32, 32, 32, 32, 32, 33, 35, 36, 36, 36, 31, 31, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 33, 35, 36, 36, 36, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
        32, 33, 35, 36, 36, 36, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 36,
        37, 38, 38, 38, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 40, 41,
        41, 41,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 35, 37, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 35, 37, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 36, 37, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 32, 33, 35, 36, 38, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 32, 34, 35, 36, 38, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 33, 34, 35, 37, 38, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33,
        34, 35, 37, 38, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35,
        37, 38, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35, 37, 38,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35, 37, 38, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35, 37, 38, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 33, 34, 35, 37, 38, 31, 31, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 33, 34, 36, 37, 39, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 33, 34, 36, 37, 39, 30, 31, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 33, 34, 36, 38, 39, 30, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33,
        35, 36, 38, 40, 30, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 35, 36,
        38, 40, 30, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 35, 36, 38, 40,
        30, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 35, 36, 38, 40, 30, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 35, 36, 38, 40, 30, 31, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 33, 35, 36, 38, 40, 31, 31, 31, 32, 32, 33,
        33, 33, 33, 33, 33, 34, 35, 37, 38, 40, 31, 32, 32, 33, 33, 33, 33, 33,
        33, 33, 33, 35, 36, 37, 39, 41, 32, 32, 33, 33, 34, 34, 34, 34, 34, 34,
        34, 35, 37, 38, 40, 41, 33, 33, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36,
        37, 39, 40, 42, 33, 34, 34, 35, 35, 36, 36, 36, 36, 36, 36, 37, 38, 40,
        41, 43, 33, 34, 34, 35, 35, 36, 36, 36, 36, 36, 36, 37, 38, 40, 41, 43,
        33, 34, 34, 35, 35, 36, 36, 36, 36, 36, 36, 37, 38, 40, 41, 43, 33, 34,
        34, 35, 35, 36, 36, 36, 36, 36, 36, 37, 38, 40, 41, 43, 33, 34, 34, 35,
        35, 36, 36, 36, 36, 36, 36, 37, 38, 40, 41, 43, 33, 34, 34, 35, 35, 36,
        36, 36, 36, 36, 36, 37, 38, 40, 41, 43, 34, 34, 35, 35, 36, 36, 36, 36,
        36, 36, 36, 38, 39, 40, 42, 44,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30,
        30, 30, 30, 31, 31, 32, 33, 33, 33, 33, 33, 33, 33, 34, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        32, 32, 33, 34, 34, 34, 34, 34, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34,
        34, 34, 34, 34, 34, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 33, 34, 35, 35, 35, 35, 35,
        35, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 33, 33, 34, 35, 36, 36, 36, 36, 36, 36, 36, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34,
        35, 36, 36, 36, 36, 36, 36, 36, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 35, 36, 36, 36,
        36, 36, 36, 36, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 35, 36, 36, 36, 36, 36, 36, 36,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 33, 33, 34, 35, 36, 36, 36, 36, 36, 36, 36, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
        33, 34, 35, 36, 36, 36, 36, 36, 36, 36, 32, 32, 32, 32, 32, 33, 33, 33,
        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 35, 35, 36, 37,
        37, 37, 37, 37, 37, 38, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34,
        34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 36, 37, 37, 38, 38, 38, 38, 38,
        38, 39, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36,
        36, 36, 36, 36, 36, 37, 37, 38, 39, 40, 40, 40, 40, 40, 40, 40, 35, 35,
        36, 36, 36, 37, 37, 37, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38,
        38, 38, 39, 40, 40, 41, 41, 41, 41, 41, 41, 42, 37, 37, 37, 38, 38, 38,
        38, 38, 38, 38, 38, 38, 39, 39, 39, 40, 40, 40, 40, 40, 40, 40, 41, 41,
        42, 43, 43, 43, 43, 43, 43, 44 },
  },
  {
      { /* Luma */
        /* Size 4x4 */
        31, 31, 31, 31, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32,
        /* Size 8x8 */
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
        32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
        /* Size 16x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        /* Size 4x8 */
        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32,
        32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32,
        /* Size 8x4 */
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31,
        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
        /* Size 8x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 31, 31, 31, 32,
        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
        32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
        31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31,
        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
        32, 32,
        /* Size 16x8 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 32, 32 },
      { /* Chroma */
        /* Size 4x4 */
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        /* Size 8x8 */
        31, 31, 31, 31, 31, 31, 31, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 30, 31, 31, 31, 31, 31, 31, 31,
        /* Size 16x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 32,
        /* Size 32x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30,
        30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        32, 32, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
        /* Size 4x8 */
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 30, 31, 32, 32,
        /* Size 8x4 */
        31, 31, 31, 31, 31, 31, 31, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32,
        /* Size 8x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31, 31, 31,
        31, 32, 32, 32, 30, 31, 31, 31, 31, 32, 32, 32, 30, 31, 31, 31, 32, 32,
        32, 32,
        /* Size 16x8 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
        32, 32,
        /* Size 16x32 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        30, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 30, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 30, 30, 31, 31,
        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 30, 30, 31, 31, 31, 31,
        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 30, 30, 31, 31, 31, 31, 31, 31,
        32, 32, 32, 32, 32, 32, 32, 32,
        /* Size 32x16 */
        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
        32, 32, 32, 32, 32, 32, 32, 32 },
  },
}

Annex A: Levels

Overview

Levels specify restrictions on the capabilities needed to decode the bitstreams.

There is only a single level currently defined in this Specification. The level is called level 1.

Level 1 limits the bitstream to a worst case of roughly a 1080P 60fps 20Mbps stream by the following restrictions:

  • Width must be less than or equal to 1920.

  • Height must be less than or equal to 1080.

  • The number of frames per second must be less than or equal to 60 (this includes both output frames and frames that are not output).

  • The size in bits for an intra frame must be less than or equal to 100,000,000 / 60.

  • The size in bits for an inter frame must be less than or equal to 50,000,000 / 60.

  • The number of times the function read_bool is called for an intra frame must be less than or equal to 2 * 100,000,000 / 60.

  • The number of times the function read_bool is called for an inter frame must be less than or equal to 2 * 50,000,000 / 60.

Annex B: Raw Bitstream Format

Overview

An AV1 bitstream consists of a number of OBUs that are normally held within a container format alongside audio and timing information.

This annex defines a simple method of packing OBUs into a raw bitstream format.

Raw Bitstream Syntax

raw_bitstream( sz ) {
    while ( sz > 0 ) {
        obu_size                                                             le(4)
        open_bitstream_unit( obu_size )
        sz -= 4 + obu_size
    }
}

Raw Bitstream semantics

sz specifies the number of bytes in the entire bitstream and is provided by external means.

obu_size specifies the size in bytes of the next OBU.

Annex C: Included Experiments

Overview

This is a temporary section that describes how the specification relates to the current code base.

Included Experiments

The specification has been updated to include the following list of adopted experiments:

Experiment Notes
ext_partition  
max_tile Bug 980 not yet fixed in code or spec
new_multisymbol  
palette_delta_encoding  
HLS R19  
altref2  
cdef_singlepass  
cfl Bug 928 not yet fixed in code or spec
chroma_sub8x8  
colorspace_headers  
compound_segment Bug 929 not yet fixed in code or spec
dependent_horztiles May only be needed when no tile groups present?
ext_delta_q  
ext-comp-refs  
interintra  
loopfiltering_across_tiles  
mv_compress  
palette_throughput  
reference_buffer  
smooth_hv  
tempmv_signaling  
wedge  
frame_size  
parallel_deblocking  
tmv  
alt_intra  
aom_qm  
cb4x4  
cdef Needs modification to support striped mode
compound_round  
convolve_round  
daala_ec  
delta_q  
dual_filter  
ec_adapt  
ec_multisymbol  
ec_smallmul  
ext_inter Bug 857, 858, 951 not yet fixed in code or spec
ext_refs Bug 78 not yet fixed in code or spec
ext-intra  
ext-tx  
filter_7bit  
global_motion  
independent_row_tile  
misc_fixes  
motion_var  
new_tokenset  
one_sided_compound  
palette  
rect_intra_pred  
rect_tx  
ref-mv Bug 981 not yet fixed in code or spec
restricted  
segmentation  
map  
update  
simp_mv_pred  
tile_groups  
var_tx  
warped_motion Bug 950 not yet fixed in code or spec
loopfilter_level  
deblock_13tap  
gm_ref_mv  
kf_ctx  
intra_edge  
simple_bwd_adapt  
ext_partition_types Bug 914 not yet fixed in code or spec
mfmv  
short_filter  
frame_marker  

Excluded Experiments

The specification has not yet been updated with the following experiments:

Experiment Notes
q_adapt_probs Bug 936 not yet fixed
txmg Unclear if this is to be adopted
daala_tx Unclear if this is to be adopted
filter_intra Unclear if this is to be adopted
ext_tile Code still under development
loop_restoration Code still under development
striped_loop_restoration Code still under development
txk_sel Bugs 869, 866 not yet fixed in code
lv_map Bugs 840, 841 not yet fixed in code
CICP No code for this yet
Timecodes No code for this yet

Bibliography

  1. Recommendation ITU-R BT.601-7 (2011), Studio encoding parameters of digital television for standard 4:3 and wide screen 16:9 aspect ratios.

  2. Recommendation ITU-R BT.709-6 (2015), Parameter values for the HDTV standards for production and international programme exchange.

  3. SMPTE ST 170 (2004), Television – Composite Analog Video Signal – NTSC for Studio Applications.

  4. SMPTE ST 240 (1999), For Television – 1125-Line High-Definition Production Systems – Signal Parameters.

  5. Recommendation ITU-R BT.2020-2 (2015), Parameter values for ultra-high definition television systems for production and international programme exchange.

  6. IEC 61966-2-1 (1999), Multimedia systems and equipment – Colour measurement and management – Part 2-1: Colour management – Default RGB colour space – sRGB.


This area is for testing, and not part of the AV1 bitstream document.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris mollis pretium lectus, pretium aliquet purus consequat quis. Aenean tincidunt sit amet sem sit amet pellentesque. Aliquam bibendum neque ac magna semper, et efficitur lectus consectetur. Mauris sodales risus tincidunt sapien ornare, volutpat cursus ex molestie. Nunc sed aliquam ex, nec ornare sem. Cras vel felis sit amet mauris accumsan ullamcorper. Pellentesque vehicula, ante eu suscipit ultricies, nulla metus ultricies dui, id lacinia metus nibh sed orci.

Heretical Syntax Tables
Below is a syntax table marked up as an HTML <table>. While a bit awkward to construct, it’s made much less awkward by placing the elementation notation in the first column – which leaves the right column free to overflow. This has the further advantage of breaking gracefully on rows in a print-like presentation. Sadly, (1) each line of code must be delimited with backticks (`) or the leading indentation is flattened, and (2) pipe characters within code must be backslash-escaped so they’re not mistaken for cell delimiters.

An alternative post-proc method for preserving indentation might replace each leading space in table.syntax td:nth-child(2) with a non-breaking space (&nbsp;). This would avoid the need for backticks, but pipes would still need escaping.

Corner-case kramdown bug
Actually, the table below exposes a kramdown bug. Each line of pseudocode is delimited with backticks except for line 3 (profile_low_bit). For reasons unknown, delimiting this string with backticks breaks table transformation.

Type Pseudocode
  uncompressed_header( ) {
f(2) frame_marker
f(1) profile_low_bit
f(1) profile_high_bit
  Profile = (profile_high_bit << 1) + profile_low_bit
  if ( Profile == 3 )
f(1) reserved_zero
f(1) show_existing_frame
  if ( show_existing_frame == 1 ) {
f(3) frame_to_show_map_idx
  header_size_in_bytes = 0
  refresh_frame_flags = 0
  loop_filter_level = 0
  return
  }
  LastFrameType = frame_type
f(1) frame_type
f(1) show_frame
  if ( frame_type == KEY_FRAME || show_frame ) {
  intra_only = 0
  } else {
f(1) intra_only
  }
  }

Proin dapibus nisl nec velit feugiat, et volutpat turpis euismod. Nulla suscipit a orci et congue. Suspendisse potenti. Sed vestibulum justo in erat blandit, nec placerat orci dictum. Ut ultricies facilisis arcu ut malesuada. Quisque sapien purus, vestibulum et vulputate eu, vulputate at lacus. Curabitur quam ante, viverra eu molestie id, fermentum sit amet odio. Pellentesque efficitur risus sit amet consectetur dictum. Maecenas ut ultrices velit. Donec eleifend mi ipsum, egestas consectetur magna suscipit at.

Donec ac turpis ligula. Nulla sed lectus nec ex feugiat hendrerit ac in lorem. Etiam tempus, augue vel blandit maximus, velit massa dapibus eros, in semper justo eros nec odio. Aenean vulputate mattis varius. Donec nisi sapien, efficitur a risus at, sollicitudin aliquet leo. Donec commodo mi quis nunc porttitor efficitur. Sed id pulvinar urna, at malesuada ligula. Vestibulum vitae viverra lectus, in accumsan erat. Nulla elit nibh, dapibus vitae dignissim vitae, blandit et nulla. Donec eleifend bibendum tincidunt. Sed convallis risus tincidunt tellus elementum, volutpat egestas ipsum placerat. Phasellus ante massa, elementum vel nunc sit amet, venenatis suscipit justo. Pellentesque eu libero id magna vehicula facilisis. Ut luctus dictum enim quis cursus. Vivamus sem tortor, tristique in justo et, aliquam vehicula ipsum.

Nullam fringilla elit quis diam tristique scelerisque. Vivamus scelerisque eget leo eu maximus. Vestibulum vitae hendrerit turpis. In ornare feugiat odio, id pellentesque lectus convallis et. Integer commodo eros eget mi lacinia, non fringilla metus eleifend. Nam nisl tortor, suscipit ac lorem at, dignissim convallis elit. Proin et dapibus erat. Praesent at nibh pellentesque, dapibus lacus ut, blandit sapien. Sed quis suscipit ante.

Nulla facilisi. Maecenas dictum tristique nunc, vel tempor tellus faucibus in. Maecenas ipsum enim, vehicula id augue at, commodo placerat purus. Praesent condimentum volutpat leo quis porta. Fusce suscipit metus vitae sapien rutrum, quis condimentum enim aliquet. Nullam non turpis blandit, tincidunt dui vitae, varius neque. Suspendisse ac pellentesque felis. Duis pulvinar congue ullamcorper. Aliquam tincidunt dignissim malesuada.