<?php
/**
* SeekQuarry/Yioop --
* Open Source Pure PHP Search Engine, Crawler, and Indexer
*
* Copyright (C) 2009 - 2026 Chris Pollett chris@pollett.org
*
* LICENSE:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* END LICENSE
*
* @author Chris Pollett chris@pollett.org
* @license https://www.gnu.org/licenses/ GPL3
* @link https://www.seekquarry.com/
* @copyright 2009 - 2026
* @filesource
*
* This class holds the tables H.264 fixes. HEVC reads some of them too.
*/
namespace seekquarry\yioop\library\av_processing;
/**
* H264Tables holds the tables the H.264 standard fixes, gathered in one
* place so that the decoding code beside it reads as arithmetic rather
* than as rows of numbers. The tables cover the ranges the arithmetic
* coding narrows by, the states it moves between, the codes the simpler
* coding reads a block's values with, and the thresholds the smoothing
* of block edges works to.
*
* The numbers are the ones the standard publishes in its tables 7-3,
* 7-4, 8-14 to 8-17, 9-4 to 9-10, 9-12 to 9-33, 9-44 and 9-45. They were
* copied from published tabulations and checked against values the
* standard fixes elsewhere; the decoding that reads them is original.
*
* HEVC reads some of the same tables, since the two formats share the
* arithmetic coding.
*/
final class H264Tables
{
/**
* RANGE_TAB_LPS is how far the arithmetic coding narrows its range when the
* less likely value is read, for every state and range it can be in.
* @var mixed
*/
public const RANGE_TAB_LPS = [
[128,176,208,240], [128,167,197,227], [128,158,187,216],
[123,150,178,205], [116,142,169,195], [111,135,160,185],
[105,128,152,175], [100,122,144,166], [95,116,137,158],
[90,110,130,150], [85,104,123,142], [81,99,117,135], [77,94,111,128],
[73,89,105,122], [69,85,100,116], [66,80,95,110], [62,76,90,104],
[59,72,86,99], [56,69,81,94], [53,65,77,89], [51,62,73,85],
[48,59,69,80], [46,56,66,76], [43,53,63,72], [41,50,59,69],
[39,48,56,65], [37,45,54,62], [35,43,51,59], [33,41,48,56],
[32,39,46,53], [30,37,43,50], [29,35,41,48], [27,33,39,45],
[26,31,37,43], [24,30,35,41], [23,28,33,39], [22,27,32,37],
[21,26,30,35], [20,24,29,33], [19,23,27,31], [18,22,26,30],
[17,21,25,28], [16,20,23,27], [15,19,22,25], [14,18,21,24],
[14,17,20,23], [13,16,19,22], [12,15,18,21], [12,14,17,20],
[11,14,16,19], [11,13,15,18], [10,12,15,17], [10,12,14,16],
[9,11,13,15], [9,11,12,14], [8,10,12,14], [8,9,11,13], [7,9,11,12],
[7,9,10,12], [7,8,10,11], [6,8,9,11], [6,7,9,10], [6,7,8,9], [2,2,2,2],
];
/**
* TRANS_IDX_LPS is which state the coding moves to after reading the less
* likely value, so the probabilities follow the stream.
* @var mixed
*/
public const TRANS_IDX_LPS = [
0, 0, 1, 2, 2, 4, 4, 5, 6, 7, 8, 9, 9, 11, 11, 12, 13, 13, 15, 15, 16,
16, 18, 18, 19, 19, 21, 21, 22, 22, 23, 24, 24, 25, 26, 26, 27, 27, 28,
29, 29, 30, 30, 30, 31, 32, 32, 33, 33, 33, 34, 34, 35, 35, 35, 36, 36,
36, 37, 37, 37, 38, 38, 63,
];
/**
* TRANS_IDX_MPS is which state it moves to after reading the more likely
* value.
* @var mixed
*/
public const TRANS_IDX_MPS = [
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, 62, 63,
];
/**
* CTX_INIT_I is the states the coding starts from for a self contained
* picture, one pair of numbers for each context.
* @var mixed
*/
public const CTX_INIT_I = [
[20,-15], [2,54], [3,74], [20,-15], [2,54], [3,74], [-28,127],
[-23,104], [-6,53], [-1,54], [7,51], [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,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], [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,0], [0,0], [0,0], [0,41], [0,63], [0,63], [0,63], [-9,83],
[4,86], [0,97], [-7,72], [13,41], [3,62], [0,11], [1,55], [0,69],
[-17,127], [-13,102], [0,82], [-7,74], [-21,107], [-27,127], [-31,127],
[-24,127], [-18,95], [-27,127], [-21,114], [-30,127], [-17,123],
[-12,115], [-16,122], [-11,115], [-12,63], [-2,68], [-15,84], [-13,104],
[-3,70], [-8,93], [-10,90], [-30,127], [-1,74], [-6,97], [-7,91],
[-20,127], [-4,56], [-5,82], [-7,76], [-22,125], [-7,93], [-11,87],
[-3,77], [-5,71], [-4,63], [-4,68], [-12,84], [-7,62], [-7,65], [8,61],
[5,56], [-2,66], [1,64], [0,61], [-2,78], [1,50], [7,52], [10,35],
[0,44], [11,38], [1,45], [0,46], [5,44], [31,17], [1,51], [7,50],
[28,19], [16,33], [14,62], [-13,108], [-15,100], [-13,101], [-13,91],
[-12,94], [-10,88], [-16,84], [-10,86], [-7,83], [-13,87], [-19,94],
[1,70], [0,72], [-5,74], [18,59], [-8,102], [-15,100], [0,95], [-4,75],
[2,72], [-11,75], [-3,71], [15,46], [-13,69], [0,62], [0,65], [21,37],
[-15,72], [9,57], [16,54], [0,62], [12,72], [24,0], [15,9], [8,25],
[13,18], [15,9], [13,19], [10,37], [12,18], [6,29], [20,33], [15,30],
[4,45], [1,58], [0,62], [7,61], [12,38], [11,45], [15,39], [11,42],
[13,44], [16,45], [12,41], [10,49], [30,34], [18,42], [10,55], [17,51],
[17,46], [0,89], [26,-19], [22,-17], [26,-17], [30,-25], [28,-20],
[33,-23], [37,-27], [33,-23], [40,-28], [38,-17], [33,-11], [40,-15],
[41,-6], [38,1], [41,17], [30,-6], [27,3], [26,22], [37,-16], [35,-4],
[38,-8], [38,-3], [37,3], [38,5], [42,0], [35,16], [39,22], [14,48],
[27,37], [21,60], [12,68], [2,97], [-3,71], [-6,42], [-5,50], [-3,54],
[-2,62], [0,58], [1,63], [-2,72], [-1,74], [-9,91], [-5,67], [-5,27],
[-3,39], [-2,44], [0,46], [-16,64], [-8,68], [-10,78], [-6,77],
[-10,86], [-12,92], [-15,55], [-10,60], [-6,62], [-4,65], [-12,73],
[-8,76], [-7,80], [-9,88], [-17,110], [-11,97], [-20,84], [-11,79],
[-6,73], [-4,74], [-13,86], [-13,96], [-11,97], [-19,117], [-8,78],
[-5,33], [-4,48], [-2,53], [-3,62], [-13,71], [-10,79], [-12,86],
[-13,90], [-14,97], [0,0], [-6,93], [-6,84], [-8,79], [0,66], [-1,71],
[0,62], [-2,60], [-2,59], [-5,75], [-3,62], [-4,58], [-9,66], [-1,79],
[0,71], [3,68], [10,44], [-7,62], [15,36], [14,40], [16,27], [12,29],
[1,44], [20,36], [18,32], [5,42], [1,48], [10,62], [17,46], [9,64],
[-12,104], [-11,97], [-16,96], [-7,88], [-8,85], [-7,85], [-9,85],
[-13,88], [4,66], [-3,77], [-3,76], [-6,76], [10,58], [-1,76], [-1,83],
[-7,99], [-14,95], [2,95], [0,76], [-5,74], [0,70], [-11,75], [1,68],
[0,65], [-14,73], [3,62], [4,62], [-1,68], [-13,75], [11,55], [5,64],
[12,70], [15,6], [6,19], [7,16], [12,14], [18,13], [13,11], [13,15],
[15,16], [12,23], [13,23], [15,20], [14,26], [14,44], [17,40], [17,47],
[24,17], [21,21], [25,22], [31,27], [22,29], [19,35], [14,50], [10,57],
[7,63], [-2,77], [-4,82], [-3,94], [9,69], [-12,109], [36,-35],
[36,-34], [32,-26], [37,-30], [44,-32], [34,-18], [34,-15], [40,-15],
[33,-7], [35,-5], [33,0], [38,2], [33,13], [23,35], [13,58], [29,-3],
[26,0], [22,30], [31,-7], [35,-15], [34,-3], [34,3], [36,-1], [34,5],
[32,11], [35,5], [34,12], [39,11], [30,29], [34,26], [29,39], [19,66],
[31,21], [31,31], [25,50], [-17,120], [-20,112], [-18,114], [-11,85],
[-15,92], [-14,89], [-26,71], [-15,81], [-14,80], [0,68], [-14,70],
[-24,56], [-23,68], [-24,50], [-11,74], [23,-13], [26,-13], [40,-15],
[49,-14], [44,3], [45,6], [44,34], [33,54], [19,82], [-3,75], [-1,23],
[1,34], [1,43], [0,54], [-2,55], [0,61], [1,64], [0,68], [-9,92],
[-14,106], [-13,97], [-15,90], [-12,90], [-18,88], [-10,73], [-9,79],
[-14,86], [-10,73], [-10,70], [-10,69], [-5,66], [-9,64], [-5,58],
[2,59], [21,-10], [24,-11], [28,-8], [28,-1], [29,3], [29,9], [35,20],
[29,36], [14,67], [-17,123], [-12,115], [-16,122], [-11,115], [-12,63],
[-2,68], [-15,84], [-13,104], [-3,70], [-8,93], [-10,90], [-30,127],
[-17,123], [-12,115], [-16,122], [-11,115], [-12,63], [-2,68], [-15,84],
[-13,104], [-3,70], [-8,93], [-10,90], [-30,127], [-7,93], [-11,87],
[-3,77], [-5,71], [-4,63], [-4,68], [-12,84], [-7,62], [-7,65], [8,61],
[5,56], [-2,66], [1,64], [0,61], [-2,78], [1,50], [7,52], [10,35],
[0,44], [11,38], [1,45], [0,46], [5,44], [31,17], [1,51], [7,50],
[28,19], [16,33], [14,62], [-13,108], [-15,100], [-13,101], [-13,91],
[-12,94], [-10,88], [-16,84], [-10,86], [-7,83], [-13,87], [-19,94],
[1,70], [0,72], [-5,74], [18,59], [-7,93], [-11,87], [-3,77], [-5,71],
[-4,63], [-4,68], [-12,84], [-7,62], [-7,65], [8,61], [5,56], [-2,66],
[1,64], [0,61], [-2,78], [1,50], [7,52], [10,35], [0,44], [11,38],
[1,45], [0,46], [5,44], [31,17], [1,51], [7,50], [28,19], [16,33],
[14,62], [-13,108], [-15,100], [-13,101], [-13,91], [-12,94], [-10,88],
[-16,84], [-10,86], [-7,83], [-13,87], [-19,94], [1,70], [0,72],
[-5,74], [18,59], [24,0], [15,9], [8,25], [13,18], [15,9], [13,19],
[10,37], [12,18], [6,29], [20,33], [15,30], [4,45], [1,58], [0,62],
[7,61], [12,38], [11,45], [15,39], [11,42], [13,44], [16,45], [12,41],
[10,49], [30,34], [18,42], [10,55], [17,51], [17,46], [0,89], [26,-19],
[22,-17], [26,-17], [30,-25], [28,-20], [33,-23], [37,-27], [33,-23],
[40,-28], [38,-17], [33,-11], [40,-15], [41,-6], [38,1], [41,17],
[24,0], [15,9], [8,25], [13,18], [15,9], [13,19], [10,37], [12,18],
[6,29], [20,33], [15,30], [4,45], [1,58], [0,62], [7,61], [12,38],
[11,45], [15,39], [11,42], [13,44], [16,45], [12,41], [10,49], [30,34],
[18,42], [10,55], [17,51], [17,46], [0,89], [26,-19], [22,-17],
[26,-17], [30,-25], [28,-20], [33,-23], [37,-27], [33,-23], [40,-28],
[38,-17], [33,-11], [40,-15], [41,-6], [38,1], [41,17], [-17,120],
[-20,112], [-18,114], [-11,85], [-15,92], [-14,89], [-26,71], [-15,81],
[-14,80], [0,68], [-14,70], [-24,56], [-23,68], [-24,50], [-11,74],
[-14,106], [-13,97], [-15,90], [-12,90], [-18,88], [-10,73], [-9,79],
[-14,86], [-10,73], [-10,70], [-10,69], [-5,66], [-9,64], [-5,58],
[2,59], [23,-13], [26,-13], [40,-15], [49,-14], [44,3], [45,6], [44,34],
[33,54], [19,82], [21,-10], [24,-11], [28,-8], [28,-1], [29,3], [29,9],
[35,20], [29,36], [14,67], [-3,75], [-1,23], [1,34], [1,43], [0,54],
[-2,55], [0,61], [1,64], [0,68], [-9,92], [-17,120], [-20,112],
[-18,114], [-11,85], [-15,92], [-14,89], [-26,71], [-15,81], [-14,80],
[0,68], [-14,70], [-24,56], [-23,68], [-24,50], [-11,74], [-14,106],
[-13,97], [-15,90], [-12,90], [-18,88], [-10,73], [-9,79], [-14,86],
[-10,73], [-10,70], [-10,69], [-5,66], [-9,64], [-5,58], [2,59],
[23,-13], [26,-13], [40,-15], [49,-14], [44,3], [45,6], [44,34],
[33,54], [19,82], [21,-10], [24,-11], [28,-8], [28,-1], [29,3], [29,9],
[35,20], [29,36], [14,67], [-3,75], [-1,23], [1,34], [1,43], [0,54],
[-2,55], [0,61], [1,64], [0,68], [-9,92], [-6,93], [-6,84], [-8,79],
[0,66], [-1,71], [0,62], [-2,60], [-2,59], [-5,75], [-3,62], [-4,58],
[-9,66], [-1,79], [0,71], [3,68], [10,44], [-7,62], [15,36], [14,40],
[16,27], [12,29], [1,44], [20,36], [18,32], [5,42], [1,48], [10,62],
[17,46], [9,64], [-12,104], [-11,97], [-16,96], [-7,88], [-8,85],
[-7,85], [-9,85], [-13,88], [4,66], [-3,77], [-3,76], [-6,76], [10,58],
[-1,76], [-1,83], [-6,93], [-6,84], [-8,79], [0,66], [-1,71], [0,62],
[-2,60], [-2,59], [-5,75], [-3,62], [-4,58], [-9,66], [-1,79], [0,71],
[3,68], [10,44], [-7,62], [15,36], [14,40], [16,27], [12,29], [1,44],
[20,36], [18,32], [5,42], [1,48], [10,62], [17,46], [9,64], [-12,104],
[-11,97], [-16,96], [-7,88], [-8,85], [-7,85], [-9,85], [-13,88],
[4,66], [-3,77], [-3,76], [-6,76], [10,58], [-1,76], [-1,83], [15,6],
[6,19], [7,16], [12,14], [18,13], [13,11], [13,15], [15,16], [12,23],
[13,23], [15,20], [14,26], [14,44], [17,40], [17,47], [24,17], [21,21],
[25,22], [31,27], [22,29], [19,35], [14,50], [10,57], [7,63], [-2,77],
[-4,82], [-3,94], [9,69], [-12,109], [36,-35], [36,-34], [32,-26],
[37,-30], [44,-32], [34,-18], [34,-15], [40,-15], [33,-7], [35,-5],
[33,0], [38,2], [33,13], [23,35], [13,58], [15,6], [6,19], [7,16],
[12,14], [18,13], [13,11], [13,15], [15,16], [12,23], [13,23], [15,20],
[14,26], [14,44], [17,40], [17,47], [24,17], [21,21], [25,22], [31,27],
[22,29], [19,35], [14,50], [10,57], [7,63], [-2,77], [-4,82], [-3,94],
[9,69], [-12,109], [36,-35], [36,-34], [32,-26], [37,-30], [44,-32],
[34,-18], [34,-15], [40,-15], [33,-7], [35,-5], [33,0], [38,2], [33,13],
[23,35], [13,58], [-3,71], [-6,42], [-5,50], [-3,54], [-2,62], [0,58],
[1,63], [-2,72], [-1,74], [-9,91], [-5,67], [-5,27], [-3,39], [-2,44],
[0,46], [-16,64], [-8,68], [-10,78], [-6,77], [-10,86], [-12,92],
[-15,55], [-10,60], [-6,62], [-4,65], [-12,73], [-8,76], [-7,80],
[-9,88], [-17,110], [-3,71], [-6,42], [-5,50], [-3,54], [-2,62], [0,58],
[1,63], [-2,72], [-1,74], [-9,91], [-5,67], [-5,27], [-3,39], [-2,44],
[0,46], [-16,64], [-8,68], [-10,78], [-6,77], [-10,86], [-12,92],
[-15,55], [-10,60], [-6,62], [-4,65], [-12,73], [-8,76], [-7,80],
[-9,88], [-17,110], [-3,70], [-8,93], [-10,90], [-30,127], [-3,70],
[-8,93], [-10,90], [-30,127], [-3,70], [-8,93], [-10,90], [-30,127],
];
/**
* SIG_COEFF_8X8 says which probability to read the
* does-this-place-hold-a-value decision with, for each of the
* sixty-four places of an eight by eight block.
* @var mixed
*/
public const SIG_COEFF_8X8 = [
0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5, 4, 4, 4, 4, 3, 3, 6, 7,
7, 7, 8, 9, 10, 9, 8, 7, 7, 6, 11, 12, 13, 11, 6, 7, 8, 9, 14, 10, 9, 8,
6, 11, 12, 13, 11, 6, 9, 14, 10, 9, 11, 12, 13, 11, 14, 10, 12,
];
/**
* LAST_COEFF_8X8 says which probability to read the
* is-this-the-last-value decision with, for each place of an
* eight by eight block.
* @var mixed
*/
public const LAST_COEFF_8X8 = [
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8,
];
/**
* COEFF_TOKEN_LEN is how many bits each code for the number of values in a
* block takes.
* @var mixed
*/
public const COEFF_TOKEN_LEN = [
[
1, 0, 0, 0, 6, 2, 0, 0, 8, 6, 3, 0, 9, 8, 7, 5, 10, 9, 8, 6, 11, 10,
9, 7, 13, 11, 10, 8, 13, 13, 11, 9, 13, 13, 13, 10, 14, 14, 13, 11,
14, 14, 14, 13, 15, 15, 14, 14, 15, 15, 15, 14, 16, 15, 15,
15,16,16,16,15,16,16,16,16,16,16,16,16],
[
2, 0, 0, 0, 6, 2, 0, 0, 6, 5, 3, 0, 7, 6, 6, 4, 8, 6, 6, 4, 8, 7, 7,
5, 9, 8, 8, 6, 11, 9, 9, 6, 11, 11, 11, 7, 12, 11, 11, 9, 12, 12,
12, 11, 12, 12, 12, 11, 13, 13, 13, 12, 13, 13, 13, 13, 13, 14,
13,13,14,14,14,13,14,14,14,14],
[
4, 0, 0, 0, 6, 4, 0, 0, 6, 5, 4, 0, 6, 5, 5, 4, 7, 5, 5, 4, 7, 5, 5,
4, 7, 6, 6, 4, 7, 6, 6, 4, 8, 7, 7, 5, 8, 8, 7, 6, 9, 8, 8, 7, 9, 9,
8, 8, 9, 9, 9, 8, 10, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10,10,10],
[
6, 0, 0, 0, 6, 6, 0, 0, 6, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],
];
/**
* COEFF_TOKEN_BITS is the bits themselves for those codes.
* @var mixed
*/
public const COEFF_TOKEN_BITS = [
[
1, 0, 0, 0, 5, 1, 0, 0, 7, 4, 1, 0, 7, 6, 5, 3, 7, 6, 5, 3, 7, 6, 5,
4, 15, 6, 5, 4, 11, 14, 5, 4, 8, 10, 13, 4, 15, 14, 9, 4, 11, 10,
13, 12, 15, 14, 9, 12, 11, 10, 13, 8, 15, 1, 9, 12, 11, 14, 13,
8,7,10,9,12,4,6,5,8],
[
3, 0, 0, 0, 11, 2, 0, 0, 7, 7, 3, 0, 7, 10, 9, 5, 7, 6, 5, 4, 4, 6,
5, 6, 7, 6, 5, 8, 15, 6, 5, 4, 11, 14, 13, 4, 15, 10, 9, 4, 11, 14,
13, 12, 8, 10, 9, 8, 15, 14, 13, 12, 11, 10, 9, 12, 7, 11, 6, 8,
9,8,10,1,7,6,5,4],
[
15, 0, 0, 0, 15, 14, 0, 0, 11, 15, 13, 0, 8, 12, 14, 12, 15, 10, 11,
11, 11, 8, 9, 10, 9, 14, 13, 9, 8, 10, 9, 8, 15, 14, 13, 13, 11, 14,
10, 12, 15, 10, 13, 12, 11, 14, 9, 12, 8, 10, 13, 8, 13,
7,9,12,9,12,11,10,5,8,7,6,1,4,3,2],
[
3, 0, 0, 0, 0, 1, 0, 0, 4, 5, 6, 0, 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],
];
/**
* CHROMA_DC_TOKEN_LEN is how many bits each such code takes for the first
* values of the color planes, which use a table of their own.
* @var mixed
*/
public const CHROMA_DC_TOKEN_LEN = [
2, 0, 0, 0, 6, 1, 0, 0, 6, 6, 3, 0, 6, 7, 7, 6, 6, 8, 8, 7,
];
/**
* CHROMA_DC_TOKEN_BITS is the bits themselves for those codes.
* @var mixed
*/
public const CHROMA_DC_TOKEN_BITS = [
1, 0, 0, 0, 7, 1, 0, 0, 4, 6, 1, 0, 3, 3, 2, 5, 2, 3, 2, 0,
];
/**
* TOTAL_ZEROS_LEN is how many bits each code for the number of zeros before
* the last value takes.
* @var mixed
*/
public const TOTAL_ZEROS_LEN = [
[1,3,3,4,4,5,5,6,6,7,7,8,8,9,9,9], [3,3,3,3,3,4,4,4,4,5,5,6,6,6,6],
[4,3,3,3,4,4,3,3,4,5,5,6,5,6], [5,3,4,4,3,3,3,4,3,4,5,5,5],
[4,4,4,3,3,3,3,3,4,5,4,5], [6,5,3,3,3,3,3,3,4,3,6],
[6,5,3,3,3,2,3,4,3,6], [6,4,5,3,2,2,3,3,6], [6,6,4,2,2,3,2,5],
[5,5,3,2,2,2,4], [4,4,3,3,1,3], [4,4,2,1,3], [3,3,1,2], [2,2,1], [1,1],
];
/**
* TOTAL_ZEROS_BITS is the bits themselves for those codes.
* @var mixed
*/
public const TOTAL_ZEROS_BITS = [
[1,3,2,3,2,3,2,3,2,3,2,3,2,3,2,1], [7,6,5,4,3,5,4,3,2,3,2,3,2,1,0],
[5,7,6,5,4,3,4,3,2,3,2,1,1,0], [3,7,5,4,6,5,4,3,3,2,2,1,0],
[5,4,3,7,6,5,4,3,2,1,1,0], [1,1,7,6,5,4,3,2,1,1,0],
[1,1,5,4,3,3,2,1,1,0], [1,1,1,3,3,2,2,1,0], [1,0,1,3,2,1,1,1],
[1,0,1,3,2,1,1], [0,1,1,2,1,3], [0,1,1,1,1], [0,1,1,1], [0,1,1], [0,1],
];
/**
* COLOR_FIRST_ZERO_COUNT_LENGTHS is how many bits each code takes
* that says how many zeros sit before the last value of a
* color planes'
* first values.
* @var mixed
*/
public const COLOR_FIRST_ZERO_COUNT_LENGTHS = [
[1,2,3,3], [1,2,2,0], [1,1,0,0],
];
/**
* COLOR_FIRST_ZERO_COUNT_BITS is the bits themselves for those codes.
* @var mixed
*/
public const COLOR_FIRST_ZERO_COUNT_BITS = [
[1,1,1,0], [1,1,0,0], [1,0,0,0],
];
/**
* RUN_LEN is how many bits each code for a run of zeros between values
* takes.
* @var mixed
*/
public const RUN_LEN = [
[1,1], [1,2,2], [2,2,2,2], [2,2,2,3,3], [2,2,3,3,3,3], [2,3,3,3,3,3,3],
[3,3,3,3,3,3,3,4,5,6,7,8,9,10,11],
];
/**
* RUN_BITS is the bits themselves for those codes.
* @var mixed
*/
public const RUN_BITS = [
[1,0], [1,1,0], [3,2,1,0], [3,2,1,1,0], [3,2,3,2,1,0], [3,0,1,3,2,5,4],
[7,6,5,4,3,2,1,1,1,1,1,1,1,1,1],
];
/**
* CODE_TO_BLOCKS_WITH_VALUES is which groups of a macroblock carry values,
* for
* each number the stream may write in their place.
* @var mixed
*/
public const CODE_TO_BLOCKS_WITH_VALUES = [
47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46, 16, 3, 5,
10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4, 8, 17, 18, 20, 24, 6,
9, 22, 25, 32, 33, 34, 36, 40, 38, 41,
];
/**
* DEBLOCK_ALPHA is the threshold an edge must be sharper than before it is
* smoothed, one entry per quantizer.
* @var mixed
*/
public const DEBLOCK_ALPHA = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 5, 6, 7, 8, 9, 10,
12, 13, 15, 17, 20, 22, 25, 28, 32, 36, 40, 45, 50, 56, 63, 71, 80, 90,
101, 113, 127, 144, 162, 182, 203, 226, 255, 255,
];
/**
* DEBLOCK_BETA is the threshold a neighboring sample must be within before
* it is moved, one entry per quantizer.
* @var mixed
*/
public const DEBLOCK_BETA = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 3, 3, 3, 3, 4,
4, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14,
15, 15, 16, 16, 17, 17, 18, 18,
];
/**
* EDGE_MOVE_LIMITS says how far a sample beside a block edge may
* be moved while the edge is smoothed, for each quantizer and
* each strength of smoothing.
* @var mixed
*/
public const EDGE_MOVE_LIMITS = [
[-1,0,0,0], [-1,0,0,0], [-1,0,0,0], [-1,0,0,0], [-1,0,0,0], [-1,0,0,0],
[-1,0,0,0], [-1,0,0,0], [-1,0,0,0], [-1,0,0,0], [-1,0,0,0], [-1,0,0,0],
[-1,0,0,0], [-1,0,0,0], [-1,0,0,0], [-1,0,0,0], [-1,0,0,0], [-1,0,0,1],
[-1,0,0,1], [-1,0,0,1], [-1,0,0,1], [-1,0,1,1], [-1,0,1,1], [-1,1,1,1],
[-1,1,1,1], [-1,1,1,1], [-1,1,1,1], [-1,1,1,2], [-1,1,1,2], [-1,1,1,2],
[-1,1,1,2], [-1,1,2,3], [-1,1,2,3], [-1,2,2,3], [-1,2,2,4], [-1,2,3,4],
[-1,2,3,4], [-1,3,3,5], [-1,3,4,6], [-1,3,4,6], [-1,4,5,7], [-1,4,5,8],
[-1,4,6,9], [-1,5,7,10], [-1,6,8,11], [-1,6,8,13], [-1,7,10,14],
[-1,8,11,16], [-1,9,12,18], [-1,10,13,20], [-1,11,15,23], [-1,13,17,25],
];
}