⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umc_h264_tables.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
////               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 - 2005 Intel Corporation. All Rights Reserved.//#include "umc_h264_tables.h"namespace UMC_H264_ENCODER{// For consistency I placed both encoder and decoder tables in this file.// The tables used only in the encoder are all very small, except// bits_for_mv__, so I moved this to tccore.cpp./////////////////////////////////////////////////////////// offsets for 4x4 blocks// These are offsets for straightforward code and scan from the// upper left corner, one 4x4 block at a time, until reaching// the lower right corner.Ipp32u C1MV_offset[16];Ipp8u C1MVtable[2048];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 blocksconst Ipp8u xoff8[4] = {0,8,0,8};const Ipp8u yoff8[4] = {0,0,8,8};// Offset for 16x16 blockconst 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 Encodingconst Ipp16u bit_index_mask[16] = {                      0xfffe, 0xfffd, 0xfffb, 0xfff7,                      0xffef, 0xffdf, 0xffbf, 0xff7f,                      0xfeff, 0xfdff, 0xfbff, 0xf7ff,                      0xefff, 0xdfff, 0xbfff, 0x7fff};// chroma QP mappingconst 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 CBPconst 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};// 4x4 coded block CBP flags/masksconst Ipp32u CBP4x4Mask[24] ={    0x000001, 0x000002, 0x000004, 0x000008,    0x000010, 0x000020, 0x000040, 0x000080,    0x000100, 0x000200, 0x000400, 0x000800,    0x001000, 0x002000, 0x004000, 0x008000,    0x010000, 0x020000, 0x040000, 0x080000,    0x100000, 0x200000, 0x400000, 0x800000,};////////////////////////////////////////////////////////// Mappings from block number in loop to 8x8 block numberconst 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 numberconst Ipp8u subblock_block_mapping[16] =    {0,0,1,1,0,0,1,1,2,2,3,3,2,2,3,3};// chroma block re-mappingconst 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 foundconst Ipp8u chroma_block_address[4] = {0,2,8,10};// Table used to prevent single or 'expensive' coefficients are codedconst Ipp8u coeff_importance[16] = {3,2,2,1,1,1,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 encodingconst 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 numberconst 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 versionIpp16u 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#elseIpp16u 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    };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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -