twitchapon-anim

Basic Twitchapon Receiver/Visuals
git clone git://bsandro.tech/twitchapon-anim
Log | Files | Refs | README | LICENSE

token.go (13089B)


      1 // Copyright 2011 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 package vp8
      6 
      7 // This file contains token probabilities for decoding DCT/WHT coefficients, as
      8 // specified in chapter 13.
      9 
     10 func (d *Decoder) parseTokenProb() {
     11 	for i := range d.tokenProb {
     12 		for j := range d.tokenProb[i] {
     13 			for k := range d.tokenProb[i][j] {
     14 				for l := range d.tokenProb[i][j][k] {
     15 					if d.fp.readBit(tokenProbUpdateProb[i][j][k][l]) {
     16 						d.tokenProb[i][j][k][l] = uint8(d.fp.readUint(uniformProb, 8))
     17 					}
     18 				}
     19 			}
     20 		}
     21 	}
     22 }
     23 
     24 // The plane enumeration is specified in section 13.3.
     25 const (
     26 	planeY1WithY2 = iota
     27 	planeY2
     28 	planeUV
     29 	planeY1SansY2
     30 	nPlane
     31 )
     32 
     33 const (
     34 	nBand    = 8
     35 	nContext = 3
     36 	nProb    = 11
     37 )
     38 
     39 // Token probability update probabilities are specified in section 13.4.
     40 var tokenProbUpdateProb = [nPlane][nBand][nContext][nProb]uint8{
     41 	{
     42 		{
     43 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     44 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     45 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     46 		},
     47 		{
     48 			{176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     49 			{223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255},
     50 			{249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255},
     51 		},
     52 		{
     53 			{255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255},
     54 			{234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     55 			{253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     56 		},
     57 		{
     58 			{255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     59 			{239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     60 			{254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     61 		},
     62 		{
     63 			{255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     64 			{251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     65 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     66 		},
     67 		{
     68 			{255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     69 			{251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     70 			{254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     71 		},
     72 		{
     73 			{255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255},
     74 			{250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255},
     75 			{254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     76 		},
     77 		{
     78 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     79 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     80 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     81 		},
     82 	},
     83 	{
     84 		{
     85 			{217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     86 			{225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255},
     87 			{234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255},
     88 		},
     89 		{
     90 			{255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     91 			{223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     92 			{238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255},
     93 		},
     94 		{
     95 			{255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255},
     96 			{249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     97 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
     98 		},
     99 		{
    100 			{255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    101 			{247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    102 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    103 		},
    104 		{
    105 			{255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    106 			{252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    107 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    108 		},
    109 		{
    110 			{255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    111 			{253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    112 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    113 		},
    114 		{
    115 			{255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255},
    116 			{250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    117 			{254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    118 		},
    119 		{
    120 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    121 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    122 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    123 		},
    124 	},
    125 	{
    126 		{
    127 			{186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255},
    128 			{234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255},
    129 			{251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255},
    130 		},
    131 		{
    132 			{255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    133 			{236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    134 			{251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255},
    135 		},
    136 		{
    137 			{255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    138 			{254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    139 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    140 		},
    141 		{
    142 			{255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    143 			{254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    144 			{254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    145 		},
    146 		{
    147 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    148 			{254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    149 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    150 		},
    151 		{
    152 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    153 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    154 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    155 		},
    156 		{
    157 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    158 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    159 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    160 		},
    161 		{
    162 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    163 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    164 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    165 		},
    166 	},
    167 	{
    168 		{
    169 			{248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    170 			{250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255},
    171 			{248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255},
    172 		},
    173 		{
    174 			{255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255},
    175 			{246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255},
    176 			{252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255},
    177 		},
    178 		{
    179 			{255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255},
    180 			{248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255},
    181 			{253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255},
    182 		},
    183 		{
    184 			{255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    185 			{245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    186 			{253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    187 		},
    188 		{
    189 			{255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255},
    190 			{252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    191 			{255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    192 		},
    193 		{
    194 			{255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    195 			{249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    196 			{255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255},
    197 		},
    198 		{
    199 			{255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255},
    200 			{250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    201 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    202 		},
    203 		{
    204 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    205 			{254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    206 			{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
    207 		},
    208 	},
    209 }
    210 
    211 // Default token probabilities are specified in section 13.5.
    212 var defaultTokenProb = [nPlane][nBand][nContext][nProb]uint8{
    213 	{
    214 		{
    215 			{128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
    216 			{128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
    217 			{128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
    218 		},
    219 		{
    220 			{253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128},
    221 			{189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128},
    222 			{106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128},
    223 		},
    224 		{
    225 			{1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128},
    226 			{181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128},
    227 			{78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128},
    228 		},
    229 		{
    230 			{1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128},
    231 			{184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128},
    232 			{77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128},
    233 		},
    234 		{
    235 			{1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128},
    236 			{170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128},
    237 			{37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128},
    238 		},
    239 		{
    240 			{1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128},
    241 			{207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128},
    242 			{102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128},
    243 		},
    244 		{
    245 			{1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128},
    246 			{177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128},
    247 			{80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128},
    248 		},
    249 		{
    250 			{1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
    251 			{246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
    252 			{255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
    253 		},
    254 	},
    255 	{
    256 		{
    257 			{198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62},
    258 			{131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1},
    259 			{68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128},
    260 		},
    261 		{
    262 			{1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128},
    263 			{184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128},
    264 			{81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128},
    265 		},
    266 		{
    267 			{1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128},
    268 			{99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128},
    269 			{23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128},
    270 		},
    271 		{
    272 			{1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128},
    273 			{109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128},
    274 			{44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128},
    275 		},
    276 		{
    277 			{1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128},
    278 			{94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128},
    279 			{22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128},
    280 		},
    281 		{
    282 			{1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128},
    283 			{124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128},
    284 			{35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128},
    285 		},
    286 		{
    287 			{1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128},
    288 			{121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128},
    289 			{45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128},
    290 		},
    291 		{
    292 			{1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128},
    293 			{203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128},
    294 			{137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128},
    295 		},
    296 	},
    297 	{
    298 		{
    299 			{253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128},
    300 			{175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128},
    301 			{73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128},
    302 		},
    303 		{
    304 			{1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128},
    305 			{239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128},
    306 			{155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128},
    307 		},
    308 		{
    309 			{1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128},
    310 			{201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128},
    311 			{69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128},
    312 		},
    313 		{
    314 			{1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128},
    315 			{223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128},
    316 			{141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128},
    317 		},
    318 		{
    319 			{1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128},
    320 			{190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128},
    321 			{149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
    322 		},
    323 		{
    324 			{1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128},
    325 			{247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128},
    326 			{240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128},
    327 		},
    328 		{
    329 			{1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128},
    330 			{213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128},
    331 			{55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128},
    332 		},
    333 		{
    334 			{128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
    335 			{128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
    336 			{128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
    337 		},
    338 	},
    339 	{
    340 		{
    341 			{202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255},
    342 			{126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128},
    343 			{61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128},
    344 		},
    345 		{
    346 			{1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128},
    347 			{166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128},
    348 			{39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128},
    349 		},
    350 		{
    351 			{1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128},
    352 			{124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128},
    353 			{24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128},
    354 		},
    355 		{
    356 			{1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128},
    357 			{149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128},
    358 			{28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128},
    359 		},
    360 		{
    361 			{1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128},
    362 			{123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128},
    363 			{20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128},
    364 		},
    365 		{
    366 			{1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128},
    367 			{168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128},
    368 			{47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128},
    369 		},
    370 		{
    371 			{1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128},
    372 			{141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128},
    373 			{42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128},
    374 		},
    375 		{
    376 			{1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
    377 			{244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
    378 			{238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
    379 		},
    380 	},
    381 }