📄 macroblock.h
字号:
/*
***********************************************************************
* COPYRIGHT AND WARRANTY INFORMATION
*
* Copyright 2001, International Telecommunications Union, Geneva
*
* DISCLAIMER OF WARRANTY
*
* These software programs are available to the user without any
* license fee or royalty on an "as is" basis. The ITU disclaims
* any and all warranties, whether express, implied, or
* statutory, including any implied warranties of merchantability
* or of fitness for a particular purpose. In no event shall the
* contributor or the ITU be liable for any incidental, punitive, or
* consequential damages of any kind whatsoever arising from the
* use of these programs.
*
* This disclaimer of warranty extends to the user of these programs
* and user's customers, employees, agents, transferees, successors,
* and assigns.
*
* The ITU does not represent or warrant that the programs furnished
* hereunder are free of infringement of any third-party patents.
* Commercial implementations of ITU-T Recommendations, including
* shareware, may be subject to royalty fees to patent holders.
* Information regarding the ITU-T patent policy is available from
* the ITU Web site at http://www.itu.int.
*
* THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE ITU-T PATENT POLICY.
************************************************************************
*/
/*!
************************************************************************
* \file macroblock.h
*
* \author
* Inge Lille-Lang鴜 <inge.lille-langoy@telenor.com>
* Copyright (C) 1999 Telenor Satellite Services, Norway
************************************************************************
*/
#ifndef _MACROBLOCK_H_
#define _MACROBLOCK_H_
#define SINGLE_SCAN 0
#define DOUBLE_SCAN 1
#ifndef USE_6_INTRA_MODES
/*
Array used to decide type of prediction:
0 = DC prediction
1 = vertical prediction
2 = horizontal prediction
3 = diagonal SE
4 = diagonal NE
5 = diagonal SSE
6 = diagonal NNE
7 = diagonal ENE
8 = diagonal ESE
all not appl. choises is set to 9
*/
const byte PRED_IPRED[10][10][9]=
{
{ // A=outside
{0,9,9,9,9,9,9,9,9}, // B=outside
{0,2,9,9,9,9,9,9,9}, // B=mode0 // typo in Seoul doc
{9,9,9,9,9,9,9,9,9}, // B=mode1
{2,0,9,9,9,9,9,9,9}, // B=mode2
{9,9,9,9,9,9,9,9,9}, // B=mode3
{9,9,9,9,9,9,9,9,9}, // B=mode4
{9,9,9,9,9,9,9,9,9}, // B=mode5
{9,9,9,9,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,3}, // 5 bits
{3,0}, {1,2}, {2,1}, {0,4}, // 7 bits
{4,0}, {3,1}, {1,3}, {0,5},
{5,0}, {2,2}, {1,4}, {4,1}, // 9 bits
{0,6}, {3,2}, {1,5}, {2,3},
{5,1}, {6,0}, {0,7}, {4,2},
{2,4}, {3,3}, {6,1}, {1,6},
{7,0}, {0,8}, {5,2}, {4,3}, // 11 bits
{2,5}, {3,4}, {1,7}, {4,4},
{7,1}, {8,0}, {6,2}, {3,5},
{5,3}, {2,6}, {1,8}, {2,7},
{7,2}, {8,1}, {5,4}, {4,5},
{3,6}, {6,3}, {8,2}, {4,6},
{5,5}, {6,4}, {2,8}, {7,3},
{3,7}, {6,5}, {5,6}, {7,4},
{4,7}, {8,3}, {3,8}, {7,5}, // 13 bits
{8,4}, {5,7}, {4,8}, {6,6},
{7,6}, {5,8}, {8,5}, {6,7},
{8,6}, {7,7}, {6,8}, {8,7},
{7,8}, {8,8}
};
#else //!< USE_6_INTRA_MODES
/*
Array used to decide type of prediction:
0 = DC prediction
1 = vertical prediction
2 = horisontal prediction
3 = diagonal
4 = diagonal
all not appl. choises is set to 0
*/
const byte PRED_IPRED[7][7][6]=
{
{
{0,0,0,0,0,0},
{0,4,5,0,0,0},
{0,4,5,0,0,0},
{0,4,5,0,0,0},
{0,4,5,0,0,0},
{4,0,5,0,0,0},
{5,0,4,0,0,0},
},
{
{0,2,1,0,0,0},
{0,4,1,3,5,2},
{0,1,4,3,2,5},
{0,1,2,3,4,5},
{3,0,4,1,5,2},
{4,0,3,5,1,2},
{5,4,0,3,1,2},
},
{
{1,0,2,0,0,0},
{1,0,4,3,2,5},
{1,0,2,4,3,5},
{1,0,2,3,4,5},
{3,1,0,4,2,5},
{4,0,1,5,3,2},
{0,1,5,4,3,2},
},
{
{2,0,1,0,0,0},
{2,3,0,4,1,5},
{2,0,3,1,4,5},
{2,1,0,3,4,5},
{2,3,1,0,5,4},
{2,4,0,3,5,1},
{2,0,1,4,5,3},
},
{
{0,1,2,0,0,0},
{3,0,4,2,1,5},
{0,3,2,1,4,5},
{3,0,2,1,4,5},
{3,0,4,2,1,5},
{4,3,0,5,1,2},
{5,3,0,4,1,2},
},
{
{0,1,2,0,0,0},
{0,4,3,1,5,2},
{0,4,1,3,2,5},
{0,4,2,1,3,5},
{4,0,3,5,1,2},
{4,0,3,5,1,2},
{4,5,0,3,1,2},
},
{
{0,1,2,0,0,0},
{0,4,3,5,1,2},
{0,1,4,3,5,2},
{0,1,3,2,4,5},
{3,0,5,4,1,2},
{4,0,5,3,1,2},
{5,0,4,1,3,2},
}
};
const byte IPRED_ORDER[36][2]=
{
{0,0},{1,0},{0,1},{0,2},{1,1},{2,0},
{3,0},{2,1},{1,2},{0,3},{0,4},{1,3},
{2,2},{3,1},{4,0},{5,0},{4,1},{3,2},
{2,3},{1,4},{0,5},{1,5},{2,4},{3,3},
{4,2},{5,1},{5,2},{4,3},{3,4},{2,5},
{3,5},{4,4},{5,3},{5,4},{4,5},{5,5}
};
#endif //!< USE_6_INTRA_MODES
//! single scan pattern
const byte SNGL_SCAN[16][2] =
{
{0,0},{1,0},{0,1},{0,2},
{1,1},{2,0},{3,0},{2,1},
{1,2},{0,3},{1,3},{2,2},
{3,1},{3,2},{2,3},{3,3}
};
//! double scan pattern
const byte DBL_SCAN[8][2][2] =
{
{{0,0},{0,1}},
{{1,0},{0,2}},
{{2,1},{0,1}},
{{2,1},{1,2}},
{{2,0},{2,3}},
{{3,1},{0,3}},
{{3,2},{1,3}},
{{3,3},{2,3}},
};
//! gives CBP value from codeword number, both for intra and inter
const byte NCBP[48][2]=
{
{47, 0},{31,16},{15, 1},{ 0, 2},{23, 4},{27, 8},{29,32},{30, 3},{ 7, 5},{11,10},{13,12},{14,15},
{39,47},{43, 7},{45,11},{46,13},{16,14},{ 3, 6},{ 5, 9},{10,31},{12,35},{19,37},{21,42},{26,44},
{28,33},{35,34},{37,36},{42,40},{44,39},{ 1,43},{ 2,45},{ 4,46},{ 8,17},{17,18},{18,20},{20,24},
{24,19},{ 6,21},{ 9,26},{22,28},{25,23},{32,27},{33,29},{34,30},{36,22},{40,25},{38,38},{41,41},
};
//! used to control block sizes : Not used/16x16/16x8/8x16/8x8/8x4/4x8/4x4
const int BLOCK_STEP[8][2]=
{
{0,0},{4,4},{4,2},{2,4},{2,2},{2,1},{1,2},{1,1}
};
//! QP dependent scale factor for coefficients
const int JQ1[]=
{
3881, 4351, 4890, 5481, 6154, 6914, 7761, 8718,
9781, 10987,12339,13828, 15523, 17435, 19561, 21873,
24552,27656,30847,34870, 38807, 43747, 49103, 54683,
61694,68745,77615,89113,100253,109366,126635,141533,
};
//! Dequantization coefficients
const int dequant_coef[6][4][4] = {
{{16,20,16,20},{20,26,20,26},{16,20,16,20},{20,26,20,26}},
{{18,23,18,23},{23,29,23,29},{18,23,18,23},{23,29,23,29}},
{{20,25,20,25},{25,32,25,32},{20,25,20,25},{25,32,25,32}},
{{22,28,22,28},{28,36,28,36},{22,28,22,28},{28,36,28,36}},
{{25,32,25,32},{32,40,32,40},{25,32,25,32},{32,40,32,40}},
{{28,36,28,36},{36,45,36,45},{28,36,28,36},{36,45,36,45}},
};
const int JQ[32] =
{
620, 553, 492, 439, 391, 348, 310, 276,
246, 219, 195, 174, 155, 138, 123, 110,
98, 87, 78, 69, 62, 55, 49, 44,
39, 35, 31, 27, 24, 22, 19, 17,
};
// gives chroma QP from QP
const byte QP_SCALE_CR[40] =
{
0 , 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
16,17,17,18,19,20,20,21,22,22,23,23,24,24,25,25,
26,26,26,27,27,27,28,28
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -