📄 umc_h264_tables.cpp
字号:
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 2004 - 2007 Intel Corporation. All Rights Reserved.
//
#include "umc_h264_tables.h"
namespace UMC_H264_ENCODER
{
const Ipp8u EdgePelCountTable [52] =
{
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,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4
};
const Ipp8u EdgePelDiffTable [52] =
{
0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,10,10,11,12,13,14,15,16,17,18,19,20,21
// QP/2
//0,1,1,2,2,3,3,4,4,5,5,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,19,19,20,20,21,21,22,22,23,23,24,24,25
// QP/3
//0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13,13,14,14,14,15,15,15,16,16,16,17
// QP/4
//0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,12
};
const Ipp32s QP_DIV_6[88] = {
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9,
10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
13, 13, 14, 14, 14, 14
};
const Ipp32s QP_MOD_6[88] = {
0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3
};
const Ipp16s MAX_PIX_VALUE[5] = { 255, 511, 1023, 2047, 4095};
const Ipp8u block_subblock_mapping[16] =
{0,1,4,5,2,3,6,7,8,9,12,13,10,11,14,15};
const Ipp8u xoff[16] = {0,4,0,4,8,12,8,12,0,4,0, 4, 8,12, 8,12};
const Ipp8u yoff[16] = {0,0,4,4,0, 0,4,4, 8,8,12,12,8, 8,12,12};
// Offset for 8x8 blocks
const Ipp8u xoff8[4] = {0,8,0,8};
const Ipp8u yoff8[4] = {0,0,8,8};
// Offset for 16x16 block
const Ipp8u yoff16[1] = {0};
// Offsets to advance from one luma subblock to the next, using 8x8
// block ordering of subblocks (ie, subblocks 0..3 are the subblocks
// in 8x8 block 0. Table is indexed by current subblock, containing a
// pair of values for each. The first value is the x offset to be added,
// the second value is the pitch multiplier to use to add the y offset.
const Ipp8s xyoff[16][2] = {
{4,0},{-4,4},{4,0},{4,-4},
{4,0},{-4,4},{4,0},{-12,4},
{4,0},{-4,4},{4,0},{4,-4},
{4,0},{-4,4},{4,0},{-12,4}
};
//////////////////////////////////////////////////////////
// scan matrices, for Run Length Encoding
const Ipp16u bit_index_mask[16] = {
0xfffe, 0xfffd, 0xfffb, 0xfff7,
0xffef, 0xffdf, 0xffbf, 0xff7f,
0xfeff, 0xfdff, 0xfbff, 0xf7ff,
0xefff, 0xdfff, 0xbfff, 0x7fff
};
// chroma QP mapping
const Ipp8u QPtoChromaQP[52] =
{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,29,30,31,32,32,33,
34,34,35,35,36,36,37,37,37,38,38,38,39,39,39,39};
///////////////////////////////////////
// Tables for decoding CBP for chroma_format_idc == 0 and != 0 cases
// Table 9-4 a) and b) of the standard specification.
const Ipp8u dec_cbp_inter[48] =
{0,16,1,2,4,8,32,3,5,10,12,15,47,7,11,13,14,6,9,31,35,37,42,44,33,34,36,40,
39,43,45,46,17,18,20,24,19,21,26,28,23,27,29,30,22,25,38,41};
const Ipp8u dec_cbp_intra[48] =
{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};
const Ipp8u dec_cbp_intra_monochrome[16] = {
15, 0, 7, 11, 13, 14, 3, 5, 10, 12, 1, 2, 4, 8, 6, 9
};
const Ipp8u dec_cbp_inter_monochrome[16] = {
0, 1, 2, 4, 8, 3, 5, 10, 12, 15, 7, 11, 13, 14, 6, 9
};
// 4x4 coded block CBP flags/masks
const Ipp32u CBP4x4Mask[32] =
{
0x00000001, 0x00000002, 0x00000004, 0x00000008,
0x00000010, 0x00000020, 0x00000040, 0x00000080,
0x00000100, 0x00000200, 0x00000400, 0x00000800,
0x00001000, 0x00002000, 0x00004000, 0x00008000,
0x00010000, 0x00020000, 0x00040000, 0x00080000,
0x00100000, 0x00200000, 0x00400000, 0x00800000,
0x01000000, 0x02000000, 0x04000000, 0x08000000,
0x10000000, 0x20000000, 0x40000000, 0x80000000,
};
// 8x8 coded block CBP flags/masks
const Ipp32u CBP8x8Mask[12] =
{
0x00000f,
0x0000f0,
0x000f00,
0x00f000,
0x010000, 0x020000, 0x040000, 0x080000,
0x100000, 0x200000, 0x400000, 0x800000,
};
////////////////////////////////////////////////////////
// Mappings from block number in loop to 8x8 block number
const Ipp8u subblock_block_ss[24] =
{0,0,1,1,0,0,1,1,2,2,3,3,2,2,3,3, /*luma*/
4,4,4,4,5,5,5,5/*chroma*/};
const Ipp8u subblock_block_ds[32] =
{0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,2,2,2,2,3,3,3,3};
// Mapping from block number in loop to 8x8 block number
const Ipp8u subblock_block_mapping[16] =
{0,0,1,1,0,0,1,1,2,2,3,3,2,2,3,3};
// chroma block re-mapping
const Ipp8u subblock_block_chroma[8] = {4,4,4,4,5,5,5,5};
// Mapping from chroma block number to luma block number where the vector
// to be used for chroma can be found
const Ipp8u chroma_block_address[4] = {0,2,8,10};
// Table used to prevent single or 'expensive' coefficients are coded
const Ipp8u coeff_importance[16] = {3,2,2,1,1,1,0,0,0,0,0,0,0,0,0,0};
const Ipp8u coeff_importance8x8[64] = {3,3,3,3,2,2,2,2,2,2,2,2,1,1,1,1,
1,1,1,1,1,1,1,1,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};
const Ipp32s COEFF_BLOCK_THRESHOLD = 3;
const Ipp32s COEFF_MB_THRESHOLD = 5;
// The purpose of the these thresholds is to prevent that single or
// 'expensive' coefficients are coded. With 4x4 transform there is
// larger chance that a single coefficient in a 8x8 or 16x16 block
// may be nonzero. A single small (level=1) coefficient in a 8x8 block
// will cost in bits: 3 or more bits for the coefficient, 4 bits for
// EOBs for the 4x4 blocks, possibly also more bits for CBP. Hence
// the total 'cost' of that single coefficient will typically be 10-12
// bits which in a RD consideration is too much to justify the Distortion
// improvement. The action below is to watch such 'single' coefficients
// and set the reconstructed block equal to the prediction according to
// a given criterium. The action is taken only for inter blocks. Action
// is taken only for luma blocks. Notice that this is a pure encoder issue
// and hence does not have any implication on the standard.
// i22 is a parameter set in dct4 and accumulated for each 8x8 block.
// If level=1 for a coefficient, i22 is increased by a number depending
// on RUN for that coefficient. The numbers are (see also dct4):
// 3,2,2,1,1,1,0,0,... when RUN equals 0,1,2,3,4,5,6, etc.
// If level >1 i22 is increased by 9 (or any number above 3).
// The threshold is set to 3. This means for example:
// 1: If there is one coefficient with (RUN,level)=(0,1) in a
// 8x8 block this coefficient is discarded.
// 2: If there are two coefficients with (RUN,level)=(1,1) and
// (4,1) the coefficients are also discarded
// i33 is the accumulation of i22 over a whole macroblock. If i33 is
// 5 or less for the whole MB, all nonzero coefficients are discarded
// for the MB and the reconstructed block is set equal to the prediction.
//
// Search for i22 and i33 to see how the thresholds are used
// Encoder tables for coefficient encoding
const Ipp8u enc_levrun_inter[16] =
{4,2,2,1,1,1,1,1,1,1,0,0,0,0,0,0};
const Ipp8u enc_levrun_intra[8] =
{9,3,1,1,1,0,0,0};
const Ipp8u enc_ntab_inter[10][4] = {
{ 1, 7,15,29},
{ 3,17, 0, 0},
{ 5,19, 0, 0},
{ 9, 0, 0, 0},
{11, 0, 0, 0},
{13, 0, 0, 0},
{21, 0, 0, 0},
{23, 0, 0, 0},
{25, 0, 0, 0},
{27, 0, 0, 0},
};
const Ipp8u enc_ntab_intra[5][9] = {
{ 1, 5, 9,11,13,23,25,27,29},
{ 3,19,21, 0, 0, 0, 0, 0, 0},
{ 7, 0, 0, 0, 0, 0, 0, 0, 0},
{15, 0, 0, 0, 0, 0, 0, 0, 0},
{17, 0, 0, 0, 0, 0, 0, 0, 0}
};
const Ipp8u enc_ntab_cDC[2][2] = { {1,3}, {5,0} };
const Ipp8u enc_levrun_cDC[4] = { 2,1,0,0 };
////////////////////////////////////////////////////////////////////
// Translation from block number in chroma loop to
// actual chroma block number
const Ipp8u block_trans[8] = {16,17,18,19,20,21,22,23};
/////////////////////////////////////////////////////////////////////
// RD multiplier (Lagrange factor)
#ifdef _TEST_PARM_
Ipp16u uTestValue = 0;
#endif
// Smoothed P frame version
const Ipp16u rd_quant[52] = {
13, 13, 13, 14,
18, 21, 23, 26,
28, 29, 29, 29,
29, 29, 29, 32,
34, 36, 38, 39,
39, 40, 42, 43,
43, 44, 46, 48,
50, 52, 56, 62,
74, 86, 86, 99,
111, 111, 119, 133,
148, 153, 165, 176,
188, 202, 232, 248,
314, 347, 384, 453
};
#ifdef _INTRA_MODE_SWITCH_
// untuned.
Ipp16u rd_quant_intra[52] = {
1, 1, 2, 2,
3, 4, 5, 6,
7, 9, 11, 13,
16, 21, 26, 31,
38, 45, 53, 61,
71, 76, 86, 98,
111, 128, 149, 174,
203, 247, 289, 338,
396, 453, 515, 585,
666, 725, 817, 921,
1038, 1185, 1375, 1597,
1856, 2158, 2510, 2920,
3400, 4544, 5391, 6396
#else
const Ipp16u rd_quant_intra[52] = {
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 2, 2,
7, 12, 14, 26,
46, 54, 65, 74,
95, 103, 115, 123,
182, 224, 275, 314,
409, 423, 423, 516,
588, 692, 898, 1021,
1125, 1365, 1410, 2006,
2590, 2590, 5395, 5395,
7185, 9268, 11951, 14010
#endif
};
const Ipp16u rd_quant_intra_min[52] = {
25, 44, 49, 49,
113, 144, 106, 188,
129, 135, 263, 247,
290, 151, 121, 175,
234, 329, 356, 484,
501, 529, 685, 714,
795, 719, 649, 761,
804, 990, 1210, 1206,
1805, 1744, 1488, 1731,
1404, 1138, 2060, 2768,
3139, 3294, 3284, 3628,
4008, 4205, 4645, 7605,
8485, 28887, 32000, 32000
};
// empty threshold tables
// All 4x4 blocks of a 16x16 block with a SAD below this
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -