1 /****************************************************************************** 2 * 3 * Copyright (C) 2015 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ***************************************************************************** 18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore 19 */ 20 21 /** 22 ******************************************************************************* 23 * @file 24 * ih264_common_tables.c 25 * 26 * @brief 27 * Contains common global tables 28 * 29 * @author 30 * ittiam 31 * 32 * @remarks 33 * none 34 * 35 ******************************************************************************* 36 */ 37 38 /*****************************************************************************/ 39 /* File Includes */ 40 /*****************************************************************************/ 41 42 /* User Include Files */ 43 #include "ih264_typedefs.h" 44 #include "ih264_macros.h" 45 #include "ih264_defs.h" 46 #include "ih264_structs.h" 47 #include "ih264_common_tables.h" 48 49 50 /*****************************************************************************/ 51 /* Global definitions */ 52 /*****************************************************************************/ 53 54 /** 55 ****************************************************************************** 56 * @brief while encoding, basing on the input configuration parameters, the 57 * the level of the bitstream is computed basing on the table below. 58 * input : table_idx 59 * output : level_idc or cpb size 60 * @remarks Table A-1 - level table limits 61 ****************************************************************************** 62 */ 63 const level_tables_t gas_ih264_lvl_tbl[16] = 64 { 65 { IH264_LEVEL_10, 1485, 99, 297, 64, 175, 64 }, 66 { IH264_LEVEL_1B, 1485, 99, 297, 128, 350, 64 }, 67 { IH264_LEVEL_11, 3000, 396, 675, 192, 500, 128 }, 68 { IH264_LEVEL_12, 6000, 396, 1782, 384, 1000, 128 }, 69 { IH264_LEVEL_13, 11880, 396, 1782, 768, 2000, 128 }, 70 { IH264_LEVEL_20, 11880, 396, 1782, 2000, 2000, 128 }, 71 { IH264_LEVEL_21, 19800, 792, 3564, 4000, 4000, 256 }, 72 { IH264_LEVEL_22, 20250, 1620, 6075, 4000, 4000, 256 }, 73 { IH264_LEVEL_30, 40500, 1620, 6075, 10000, 10000, 256 }, 74 { IH264_LEVEL_31, 108000, 3600, 13500, 14000, 14000, 512 }, 75 { IH264_LEVEL_32, 216000, 5120, 15360, 20000, 20000, 512 }, 76 { IH264_LEVEL_40, 245760, 8192, 24576, 20000, 25000, 512 }, 77 { IH264_LEVEL_41, 245760, 8192, 24576, 50000, 62500, 512 }, 78 { IH264_LEVEL_42, 522240, 8704, 26112, 50000, 62500, 512 }, 79 { IH264_LEVEL_50, 589824, 22080, 82800, 135000, 135000, 512 }, 80 { IH264_LEVEL_51, 983040, 36864, 138240, 240000, 240000, 512 }, 81 }; 82 83 /* Array containing supported levels */ 84 const WORD32 gai4_ih264_levels[] = 85 { 86 IH264_LEVEL_10, 87 IH264_LEVEL_11, 88 IH264_LEVEL_12, 89 IH264_LEVEL_13, 90 IH264_LEVEL_20, 91 IH264_LEVEL_21, 92 IH264_LEVEL_22, 93 IH264_LEVEL_30, 94 IH264_LEVEL_31, 95 IH264_LEVEL_32, 96 IH264_LEVEL_40, 97 IH264_LEVEL_41, 98 IH264_LEVEL_42, 99 IH264_LEVEL_50, 100 IH264_LEVEL_51, 101 }; 102 103 /* Array giving size of max luma samples in a picture for a given level */ 104 const WORD32 gai4_ih264_max_luma_pic_size[] = 105 { 106 /* Level 1 */ 107 25344, 108 /* Level 1.1 */ 109 101376, 110 /* Level 1.2 */ 111 101376, 112 /* Level 1.3 */ 113 101376, 114 /* Level 2 */ 115 101376, 116 /* Level 2.1 */ 117 202752, 118 /* Level 2.2 */ 119 414720, 120 /* Level 3 */ 121 414720, 122 /* Level 3.1 */ 123 921600, 124 /* Level 3.2 */ 125 1310720, 126 /* Level 4 */ 127 2097152, 128 /* Level 4.1 */ 129 2097152, 130 /* Level 4.2 */ 131 2228224, 132 /* Level 5 */ 133 5652480, 134 /* Level 5.1 */ 135 9437184 136 }; 137 138 /* Max width and height allowed for a given level */ 139 /* This is derived as SQRT(8 * gai4_ih264_max_luma_pic_size[]) */ 140 const WORD32 gai4_ih264_max_wd_ht[] = 141 { 142 /* Level 1 */ 143 451, 144 /* Level 1.1 */ 145 901, 146 /* Level 1.2 */ 147 901, 148 /* Level 1.3 */ 149 901, 150 /* Level 2 */ 151 901, 152 /* Level 2.1 */ 153 1274, 154 /* Level 2.2 */ 155 1822, 156 /* Level 3 */ 157 1822, 158 /* Level 3.1 */ 159 2716, 160 /* Level 3.2 */ 161 3239, 162 /* Level 4 */ 163 4096, 164 /* Level 4.1 */ 165 4096, 166 /* Level 4.2 */ 167 4223, 168 /* Level 5 */ 169 6725, 170 /* Level 5.1 */ 171 8689 172 }; 173 174 /* Min width and height allowed for a given level */ 175 /* This is derived as gai4_ih264_max_luma_pic_size[]/gai4_ih264_max_wd_ht[] */ 176 const WORD32 gai4_ih264_min_wd_ht[] = 177 { 178 /* Level 1 */ 179 57, 180 /* Level 1.1 */ 181 113, 182 /* Level 1.2 */ 183 113, 184 /* Level 1.3 */ 185 113, 186 /* Level 2 */ 187 113, 188 /* Level 2.1 */ 189 160, 190 /* Level 2.2 */ 191 228, 192 /* Level 3 */ 193 228, 194 /* Level 3.1 */ 195 340, 196 /* Level 3.2 */ 197 405, 198 /* Level 4 */ 199 512, 200 /* Level 4.1 */ 201 512, 202 /* Level 4.2 */ 203 528, 204 /* Level 5 */ 205 841, 206 /* Level 5.1 */ 207 1087 208 209 }; 210 211 /* Table 7-11 Macroblock types for I slices */ 212 intra_mbtype_info_t gas_ih264_i_mbtype_info[] = 213 { 214 /* For first entry, if transform_size_8x8_flag is 1, mode will be MBPART_I8x8 */ 215 /* This has to be taken care while accessing the table */ 216 {0, MBPART_I4x4, VERT_I16x16, 0, 0}, 217 {0, MBPART_I16x16, VERT_I16x16, 0, 0}, 218 {0, MBPART_I16x16, HORZ_I16x16, 0, 0}, 219 {0, MBPART_I16x16, DC_I16x16, 0, 0}, 220 {0, MBPART_I16x16, PLANE_I16x16, 0, 0}, 221 {0, MBPART_I16x16, VERT_I16x16, 1, 0}, 222 {0, MBPART_I16x16, HORZ_I16x16, 1, 0}, 223 {0, MBPART_I16x16, DC_I16x16, 1, 0}, 224 {0, MBPART_I16x16, PLANE_I16x16, 1, 0}, 225 {0, MBPART_I16x16, VERT_I16x16, 2, 0}, 226 {0, MBPART_I16x16, HORZ_I16x16, 2, 0}, 227 {0, MBPART_I16x16, DC_I16x16, 2, 0}, 228 {0, MBPART_I16x16, PLANE_I16x16, 2, 0}, 229 {0, MBPART_I16x16, VERT_I16x16, 0, 15}, 230 {0, MBPART_I16x16, HORZ_I16x16, 0, 15}, 231 {0, MBPART_I16x16, DC_I16x16, 0, 15}, 232 {0, MBPART_I16x16, PLANE_I16x16, 0, 15}, 233 {0, MBPART_I16x16, VERT_I16x16, 1, 15}, 234 {0, MBPART_I16x16, HORZ_I16x16, 1, 15}, 235 {0, MBPART_I16x16, DC_I16x16, 1, 15}, 236 {0, MBPART_I16x16, PLANE_I16x16, 1, 15}, 237 {0, MBPART_I16x16, VERT_I16x16, 2, 15}, 238 {0, MBPART_I16x16, HORZ_I16x16, 2, 15}, 239 {0, MBPART_I16x16, DC_I16x16, 2, 15}, 240 {0, MBPART_I16x16, PLANE_I16x16, 2, 15}, 241 {0, MBPART_IPCM, VERT_I16x16, 0, 0} 242 }; 243 244 /* Table 7-13 Macroblock types for P slices */ 245 inter_mbtype_info_t gas_ih264_p_mbtype_info[] = 246 { 247 {1, MBPART_L0, MBPART_NA, 16, 16}, 248 {2, MBPART_L0, MBPART_L0, 16, 8}, 249 {2, MBPART_L0, MBPART_L0, 8, 16}, 250 {4, MBPART_NA, MBPART_NA, 8, 8}, 251 {4, MBPART_NA, MBPART_NA, 8, 8}, 252 }; 253 254 /* Table 7-14 Macroblock types for B slices */ 255 inter_mbtype_info_t gas_ih264_b_mbtype_info[] = 256 { 257 {0, MBPART_DIRECT, MBPART_NA, 8, 8, }, 258 {1, MBPART_L0, MBPART_NA, 16, 16, }, 259 {1, MBPART_L1, MBPART_NA, 16, 16, }, 260 {1, MBPART_BI, MBPART_NA, 16, 16, }, 261 {2, MBPART_L0, MBPART_L0, 16, 8, }, 262 {2, MBPART_L0, MBPART_L0, 8, 16, }, 263 {2, MBPART_L1, MBPART_L1, 16, 8, }, 264 {2, MBPART_L1, MBPART_L1, 8, 16, }, 265 {2, MBPART_L0, MBPART_L1, 16, 8, }, 266 {2, MBPART_L0, MBPART_L1, 8, 16, }, 267 {2, MBPART_L1, MBPART_L0, 16, 8, }, 268 {2, MBPART_L1, MBPART_L0, 8, 16, }, 269 {2, MBPART_L0, MBPART_BI, 16, 8, }, 270 {2, MBPART_L0, MBPART_BI, 8, 16, }, 271 {2, MBPART_L1, MBPART_BI, 16, 8, }, 272 {2, MBPART_L1, MBPART_BI, 8, 16, }, 273 {2, MBPART_BI, MBPART_L0, 16, 8, }, 274 {2, MBPART_BI, MBPART_L0, 8, 16, }, 275 {2, MBPART_BI, MBPART_L1, 16, 8, }, 276 {2, MBPART_BI, MBPART_L1, 8, 16, }, 277 {2, MBPART_BI, MBPART_BI, 16, 8, }, 278 {2, MBPART_BI, MBPART_BI, 8, 16, }, 279 {4, MBPART_NA, MBPART_NA, 8, 8, }, 280 }; 281 282 /* Table 7-17 - Sub-macroblock types in P macroblocks */ 283 submbtype_info_t gas_ih264_p_submbtype_info[] = 284 { 285 {1, MBPART_L0, 8, 8}, 286 {2, MBPART_L0, 8, 4}, 287 {2, MBPART_L0, 4, 8}, 288 {4, MBPART_L0, 4, 4}, 289 }; 290 291 /* Table 7-18 - Sub-macroblock types in B macroblocks */ 292 submbtype_info_t gas_ih264_b_submbtype_info[] = 293 { 294 {4, MBPART_DIRECT, 4, 4}, 295 {1, MBPART_L0, 8, 8}, 296 {1, MBPART_L1, 8, 8}, 297 {1, MBPART_BI, 8, 8}, 298 {2, MBPART_L0, 8, 4}, 299 {2, MBPART_L0, 4, 8}, 300 {2, MBPART_L1, 8, 4}, 301 {2, MBPART_L1, 4, 8}, 302 {2, MBPART_BI, 8, 4}, 303 {2, MBPART_BI, 4, 8}, 304 {4, MBPART_L0, 4, 4}, 305 {4, MBPART_L1, 4, 4}, 306 {4, MBPART_BI, 4, 4}, 307 }; 308 309 const UWORD8 gau1_ih264_inv_scan_prog4x4[] = 310 { 311 0, 1, 4, 8, 312 5, 2, 3, 6, 313 9, 12, 13, 10, 314 7, 11, 14, 15 315 }; 316 317 const UWORD8 gau1_ih264_inv_scan_int4x4[] = 318 { 319 0, 4, 1, 8, 320 12, 5, 9, 13, 321 2, 6, 10, 14, 322 3, 7, 11, 15 323 }; 324 325 /* Inverse scan tables for individual 4x4 blocks of 8x8 transform coeffs of CAVLC */ 326 /* progressive */ 327 const UWORD8 gau1_ih264_inv_scan_prog8x8_cavlc[64] = 328 { 329 0, 9, 17, 18, 12, 40, 27, 7, 330 35, 57, 29, 30, 58, 38, 53, 47, 331 1, 2, 24, 11, 19, 48, 20, 14, 332 42, 50, 22, 37, 59, 31, 60, 55, 333 8, 3, 32, 4, 26, 41, 13, 21, 334 49, 43, 15, 44, 52, 39, 61, 62, 335 16, 10, 25, 5, 33, 34, 6, 28, 336 56, 36, 23, 51, 45, 46, 54, 63 337 }; 338 /* interlace */ 339 const UWORD8 gau1_ih264_inv_scan_int8x8_cavlc[64] = 340 { 341 0, 9, 2, 56, 18, 26, 34, 27, 342 35, 28, 36, 29, 45, 7, 54, 39, 343 8, 24, 25, 33, 41, 11, 42, 12, 344 43, 13, 44, 14, 53, 15, 62, 47, 345 16, 32, 40, 10, 49, 4, 50, 5, 346 51, 6, 52, 22, 61, 38, 23, 55, 347 1, 17, 48, 3, 57, 19, 58, 20, 348 59, 21, 60, 37, 30, 46, 31, 63 349 }; 350 351 /*Inverse scan tables for individual 8x8 blocks of 8x8 transform coeffs of CABAC */ 352 /* progressive */ 353 const UWORD8 gau1_ih264_inv_scan_prog8x8_cabac[64] = 354 { 355 0, 1, 8, 16, 9, 2, 3, 10, 356 17, 24, 32, 25, 18, 11, 4, 5, 357 12, 19, 26, 33, 40, 48, 41, 34, 358 27, 20, 13, 6, 7, 14, 21, 28, 359 35, 42, 49, 56, 57, 50, 43, 36, 360 29, 22, 15, 23, 30, 37, 44, 51, 361 58, 59, 52, 45, 38, 31, 39, 46, 362 53, 60, 61, 54, 47, 55, 62, 63 363 }; 364 /* interlace */ 365 const UWORD8 gau1_ih264_inv_scan_int8x8_cabac[64] = 366 { 367 0, 8, 16, 1, 9, 24, 32, 17, 368 2, 25, 40, 48, 56, 33, 10, 3, 369 18, 41, 49, 57, 26, 11, 4, 19, 370 34, 42, 50, 58, 27, 12, 5, 20, 371 35, 43, 51, 59, 28, 13, 6, 21, 372 36, 44, 52, 60, 29, 14, 22, 37, 373 45, 53, 61, 30, 7, 15, 38, 46, 374 54, 62, 23, 31, 39, 47, 55, 63 375 }; 376 377 const UWORD8 *const gpau1_ih264_inv_scan8x8[] = 378 { 379 gau1_ih264_inv_scan_prog8x8_cavlc, 380 gau1_ih264_inv_scan_int8x8_cavlc, 381 gau1_ih264_inv_scan_prog8x8_cabac, 382 gau1_ih264_inv_scan_int8x8_cabac 383 }; 384 385 const UWORD8 *const gpau1_ih264_inv_scan4x4[] = 386 { 387 gau1_ih264_inv_scan_prog4x4, 388 gau1_ih264_inv_scan_int4x4, 389 }; 390 391 const UWORD8 gau1_ih264_8x8_subblk_idx[] = 392 { 393 0, 1, 4, 5, 394 2, 3, 6, 7, 395 8, 9, 12, 13, 396 10, 11, 14, 15 397 }; 398 399 /* Table 8-15 Chroma QP offset table */ 400 const UWORD8 gau1_ih264_chroma_qp[] = 401 { 402 0, 1, 2, 3, 4, 5, 6, 7, 403 8, 9, 10, 11, 12, 13, 14, 15, 404 16, 17, 18, 19, 20, 21, 22, 23, 405 24, 25, 26, 27, 28, 29, 29, 30, 406 31, 32, 32, 33, 34, 34, 35, 35, 407 36, 36, 37, 37, 37, 38, 38, 38, 408 39, 39, 39, 39 409 }; 410 411 /** 412 ****************************************************************************** 413 * @brief look up table to compute neigbour availability of 4x4 blocks 414 * input : subblk idx, mb neighbor availability 415 * output : sub blk neighbor availability 416 * @remarks 417 ****************************************************************************** 418 */ 419 const UWORD8 gau1_ih264_4x4_ngbr_avbl[16][16] = 420 { 421 { 0x0, 0x1, 0xc, 0x7, 0x1, 0x1, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 }, 422 { 0x1, 0x1, 0xf, 0x7, 0x1, 0x1, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 }, 423 { 0x2, 0x1, 0xc, 0x7, 0x1, 0x1, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 }, 424 { 0x3, 0x1, 0xf, 0x7, 0x1, 0x1, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 }, 425 426 { 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 }, 427 { 0xd, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 }, 428 { 0xe, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 }, 429 { 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 }, 430 431 { 0x0, 0x1, 0xc, 0x7, 0x1, 0x9, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 }, 432 { 0x1, 0x1, 0xf, 0x7, 0x1, 0x9, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 }, 433 { 0x2, 0x1, 0xc, 0x7, 0x1, 0x9, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 }, 434 { 0x3, 0x1, 0xf, 0x7, 0x1, 0x9, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 }, 435 436 { 0xc, 0xf, 0xc, 0x7, 0xf, 0xf, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 }, 437 { 0xd, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 }, 438 { 0xe, 0xf, 0xc, 0x7, 0xf, 0xf, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 }, 439 { 0xf, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 }, 440 }; 441 442 443 /** 444 ****************************************************************************** 445 * @brief look up table to compute neigbour availability of 8x8 blocks 446 * input : subblk idx, mb neighbor availability 447 * output : sub blk neighbor availability 448 * @remarks 449 ****************************************************************************** 450 */ 451 const UWORD8 gau1_ih264_8x8_ngbr_avbl[16][4] = 452 { 453 { 0x0, 0x1, 0xc, 0x7 }, 454 { 0x1, 0x1, 0xf, 0x7 }, 455 { 0x2, 0x1, 0xc, 0x7 }, 456 { 0x3, 0x1, 0xf, 0x7 }, 457 458 { 0xc, 0x7, 0xc, 0x7 }, 459 { 0xd, 0x7, 0xf, 0x7 }, 460 { 0xe, 0x7, 0xc, 0x7 }, 461 { 0xf, 0x7, 0xf, 0x7 }, 462 463 { 0x0, 0x9, 0xc, 0x7 }, 464 { 0x1, 0x9, 0xf, 0x7 }, 465 { 0x2, 0x9, 0xc, 0x7 }, 466 { 0x3, 0x9, 0xf, 0x7 }, 467 468 { 0xc, 0xf, 0xc, 0x7 }, 469 { 0xd, 0xf, 0xf, 0x7 }, 470 { 0xe, 0xf, 0xc, 0x7 }, 471 { 0xf, 0xf, 0xf, 0x7 }, 472 }; 473 474 /* Table 7-3 Default intra 4x4 scaling list */ 475 const UWORD16 gau2_ih264_default_intra4x4_scaling_list[] = 476 { 477 6, 13, 13, 20, 478 20, 20, 28, 28, 479 28, 28, 32, 32, 480 32, 37, 37, 42 481 }; 482 483 /* Table 7-3 Default inter 4x4 scaling list */ 484 const UWORD16 gau2_ih264_default_inter4x4_scaling_list[] = 485 { 486 10, 14, 14, 20, 487 20, 20, 24, 24, 488 24, 24, 27, 27, 489 27, 30, 30, 34 490 }; 491 492 /* Inverse scanned output of gau2_ih264_default_intra4x4_scaling_list */ 493 const UWORD16 gau2_ih264_default_intra4x4_weight_scale[] = 494 { 495 6, 13, 20, 28, 496 13, 20, 28, 32, 497 20, 28, 32, 37, 498 28, 32, 37, 42 499 }; 500 501 /* Inverse scanned output of gau2_ih264_default_inter4x4_scaling_list */ 502 const UWORD16 gau2_ih264_default_inter4x4_weight_scale[] = 503 { 504 10, 14, 20, 24, 505 14, 20, 24, 27, 506 20, 24, 27, 30, 507 24, 27, 30, 34 508 }; 509 510 /* Table 7-4 Default intra 8x8 scaling list */ 511 const UWORD16 gau2_ih264_default_intra8x8_scaling_list[] = 512 { 513 6, 10, 10, 13, 11, 13, 16, 16, 514 16, 16, 18, 18, 18, 18, 18, 23, 515 23, 23, 23, 23, 23, 25, 25, 25, 516 25, 25, 25, 25, 27, 27, 27, 27, 517 27, 27, 27, 27, 29, 29, 29, 29, 518 29, 29, 29, 31, 31, 31, 31, 31, 519 31, 33, 33, 33, 33, 33, 36, 36, 520 36, 36, 38, 38, 38, 40, 40, 42 521 }; 522 523 /* Table 7-4 Default inter 8x8 scaling list */ 524 const UWORD16 gau2_ih264_default_inter8x8_scaling_list[] = 525 { 526 9, 13, 13, 15, 13, 15, 17, 17, 527 17, 17, 19, 19, 19, 19, 19, 21, 528 21, 21, 21, 21, 21, 22, 22, 22, 529 22, 22, 22, 22, 24, 24, 24, 24, 530 24, 24, 24, 24, 25, 25, 25, 25, 531 25, 25, 25, 27, 27, 27, 27, 27, 532 27, 28, 28, 28, 28, 28, 30, 30, 533 30, 30, 32, 32, 32, 33, 33, 35 534 }; 535 536 /* Inverse scanned output of gau2_ih264_default_intra8x8_scaling_list */ 537 const UWORD16 gau2_ih264_default_intra8x8_weight_scale[] = 538 { 539 6, 10, 13, 16, 18, 23, 25, 27, 540 10, 11, 16, 18, 23, 25, 27, 29, 541 13, 16, 18, 23, 25, 27, 29, 31, 542 16, 18, 23, 25, 27, 29, 31, 33, 543 18, 23, 25, 27, 29, 31, 33, 36, 544 23, 25, 27, 29, 31, 33, 36, 38, 545 25, 27, 29, 31, 33, 36, 38, 40, 546 27, 29, 31, 33, 36, 38, 40, 42 547 }; 548 549 /* Inverse scanned output of gau2_ih264_default_inter8x8_scaling_list */ 550 const UWORD16 gau2_ih264_default_inter8x8_weight_scale[] = 551 { 552 9, 13, 15, 17, 19, 21, 22, 24, 553 13, 13, 17, 19, 21, 22, 24, 25, 554 15, 17, 19, 21, 22, 24, 25, 27, 555 17, 19, 21, 22, 24, 25, 27, 28, 556 19, 21, 22, 24, 25, 27, 28, 30, 557 21, 22, 24, 25, 27, 28, 30, 32, 558 22, 24, 25, 27, 28, 30, 32, 33, 559 24, 25, 27, 28, 30, 32, 33, 35 560 }; 561 /* Eq 7-8 Flat scaling matrix for 4x4 */ 562 const UWORD16 gau2_ih264_flat_4x4_weight_scale[] = 563 { 564 16, 16, 16, 16, 565 16, 16, 16, 16, 566 16, 16, 16, 16, 567 16, 16, 16, 16 568 }; 569 570 /* Eq 7-9 Flat scaling matrix for 8x8 */ 571 const UWORD16 gau2_ih264_flat_8x8_weight_scale[] = 572 { 573 16, 16, 16, 16, 16, 16, 16, 16, 574 16, 16, 16, 16, 16, 16, 16, 16, 575 16, 16, 16, 16, 16, 16, 16, 16, 576 16, 16, 16, 16, 16, 16, 16, 16, 577 16, 16, 16, 16, 16, 16, 16, 16, 578 16, 16, 16, 16, 16, 16, 16, 16, 579 16, 16, 16, 16, 16, 16, 16, 16, 580 16, 16, 16, 16, 16, 16, 16, 16 581 }; 582 583 /** 584 ****************************************************************************** 585 * @brief Scale Table for inverse quantizing 4x4 subblock. To inverse quantize 586 * a given 4x4 quantized block, the coefficient at index location (i,j) is scaled 587 * by one of the constants in this table and right shift the result by abs (4 - 588 * floor(qp/6)), here qp is the quantization parameter used to quantize the mb. 589 * 590 * input : 16 * qp%6, index location (i,j) 591 * output : scale constant. 592 * 593 * @remarks 16 constants for each index position of the subblock and 6 for each 594 * qp%6 in the range 0-5 inclusive. 595 ****************************************************************************** 596 */ 597 const UWORD16 gau2_ih264_iquant_scale_matrix_4x4[96] = 598 { 599 10, 13, 10, 13, 600 13, 16, 13, 16, 601 10, 13, 10, 13, 602 13, 16, 13, 16, 603 604 11, 14, 11, 14, 605 14, 18, 14, 18, 606 11, 14, 11, 14, 607 14, 18, 14, 18, 608 609 13, 16, 13, 16, 610 16, 20, 16, 20, 611 13, 16, 13, 16, 612 16, 20, 16, 20, 613 614 14, 18, 14, 18, 615 18, 23, 18, 23, 616 14, 18, 14, 18, 617 18, 23, 18, 23, 618 619 16, 20, 16, 20, 620 20, 25, 20, 25, 621 16, 20, 16, 20, 622 20, 25, 20, 25, 623 624 18, 23, 18, 23, 625 23, 29, 23, 29, 626 18, 23, 18, 23, 627 23, 29, 23, 29, 628 629 }; 630 631 /** 632 ****************************************************************************** 633 * @brief Scale Table for inverse quantizing 8x8 subblock. To inverse quantize 634 * a given 8x8 quantized block, the coefficient at index location (i,j) is scaled 635 * by one of the constants in this table and right shift the result by abs (4 - 636 * floor(qp/6)), here qp is the quantization parameter used to quantize the mb. 637 * 638 * input : qp%6, index location (i,j) 639 * output : scale constant. 640 * 641 * @remarks 64 constants for each index position of the subblock and 6 for each 642 * qp%6 in the range 0-5 inclusive. 643 ****************************************************************************** 644 */ 645 const UWORD16 gau2_ih264_iquant_scale_matrix_8x8 [384] = 646 { 647 20, 19, 25, 19, 20, 19, 25, 19, 648 19, 18, 24, 18, 19, 18, 24, 18, 649 25, 24, 32, 24, 25, 24, 32, 24, 650 19, 18, 24, 18, 19, 18, 24, 18, 651 20, 19, 25, 19, 20, 19, 25, 19, 652 19, 18, 24, 18, 19, 18, 24, 18, 653 25, 24, 32, 24, 25, 24, 32, 24, 654 19, 18, 24, 18, 19, 18, 24, 18, 655 656 22, 21, 28, 21, 22, 21, 28, 21, 657 21, 19, 26, 19, 21, 19, 26, 19, 658 28, 26, 35, 26, 28, 26, 35, 26, 659 21, 19, 26, 19, 21, 19, 26, 19, 660 22, 21, 28, 21, 22, 21, 28, 21, 661 21, 19, 26, 19, 21, 19, 26, 19, 662 28, 26, 35, 26, 28, 26, 35, 26, 663 21, 19, 26, 19, 21, 19, 26, 19, 664 665 26, 24, 33, 24, 26, 24, 33, 24, 666 24, 23, 31, 23, 24, 23, 31, 23, 667 33, 31, 42, 31, 33, 31, 42, 31, 668 24, 23, 31, 23, 24, 23, 31, 23, 669 26, 24, 33, 24, 26, 24, 33, 24, 670 24, 23, 31, 23, 24, 23, 31, 23, 671 33, 31, 42, 31, 33, 31, 42, 31, 672 24, 23, 31, 23, 24, 23, 31, 23, 673 674 28, 26, 35, 26, 28, 26, 35, 26, 675 26, 25, 33, 25, 26, 25, 33, 25, 676 35, 33, 45, 33, 35, 33, 45, 33, 677 26, 25, 33, 25, 26, 25, 33, 25, 678 28, 26, 35, 26, 28, 26, 35, 26, 679 26, 25, 33, 25, 26, 25, 33, 25, 680 35, 33, 45, 33, 35, 33, 45, 33, 681 26, 25, 33, 25, 26, 25, 33, 25, 682 683 32, 30, 40, 30, 32, 30, 40, 30, 684 30, 28, 38, 28, 30, 28, 38, 28, 685 40, 38, 51, 38, 40, 38, 51, 38, 686 30, 28, 38, 28, 30, 28, 38, 28, 687 32, 30, 40, 30, 32, 30, 40, 30, 688 30, 28, 38, 28, 30, 28, 38, 28, 689 40, 38, 51, 38, 40, 38, 51, 38, 690 30, 28, 38, 28, 30, 28, 38, 28, 691 692 36, 34, 46, 34, 36, 34, 46, 34, 693 34, 32, 43, 32, 34, 32, 43, 32, 694 46, 43, 58, 43, 46, 43, 58, 43, 695 34, 32, 43, 32, 34, 32, 43, 32, 696 36, 34, 46, 34, 36, 34, 46, 34, 697 34, 32, 43, 32, 34, 32, 43, 32, 698 46, 43, 58, 43, 46, 43, 58, 43, 699 34, 32, 43, 32, 34, 32, 43, 32, 700 701 }; 702