Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComRom.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComRom.cpp
r1196 r1313 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 31 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 32 */ 33 34 33 /** \file TComRom.cpp 35 34 \brief global variables & functions 36 35 */ 37 38 36 #include "TComRom.h" 39 37 #include <memory.h> 40 38 #include <stdlib.h> 41 39 #include <stdio.h> 40 #include <iomanip> 41 #include <assert.h> 42 #include "TComDataCU.h" 43 #include "Debug.h" 42 44 // ==================================================================================================================== 43 45 // Initialize / destroy functions 44 46 // ==================================================================================================================== 45 46 47 //! \ingroup TLibCommon 47 48 //! \{ 48 49 const Char* nalUnitTypeToString(NalUnitType type) 50 { 51 switch (type) 52 { 53 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R"; 54 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N"; 55 case NAL_UNIT_CODED_SLICE_TSA_R: return "TSA_R"; 56 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N"; 57 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R"; 58 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N"; 59 case NAL_UNIT_CODED_SLICE_BLA_W_LP: return "BLA_W_LP"; 60 case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL"; 61 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP"; 62 case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL"; 63 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP"; 64 case NAL_UNIT_CODED_SLICE_CRA: return "CRA"; 65 case NAL_UNIT_CODED_SLICE_RADL_R: return "RADL_R"; 66 case NAL_UNIT_CODED_SLICE_RADL_N: return "RADL_N"; 67 case NAL_UNIT_CODED_SLICE_RASL_R: return "RASL_R"; 68 case NAL_UNIT_CODED_SLICE_RASL_N: return "RASL_N"; 69 case NAL_UNIT_VPS: return "VPS"; 70 case NAL_UNIT_SPS: return "SPS"; 71 case NAL_UNIT_PPS: return "PPS"; 72 case NAL_UNIT_ACCESS_UNIT_DELIMITER: return "AUD"; 73 case NAL_UNIT_EOS: return "EOS"; 74 case NAL_UNIT_EOB: return "EOB"; 75 case NAL_UNIT_FILLER_DATA: return "FILLER"; 76 case NAL_UNIT_PREFIX_SEI: return "Prefix SEI"; 77 case NAL_UNIT_SUFFIX_SEI: return "Suffix SEI"; 78 default: return "UNK"; 79 } 80 } 81 class ScanGenerator 82 { 83 private: 84 UInt m_line, m_column; 85 const UInt m_blockWidth, m_blockHeight; 86 const UInt m_stride; 87 const COEFF_SCAN_TYPE m_scanType; 88 public: 89 ScanGenerator(UInt blockWidth, UInt blockHeight, UInt stride, COEFF_SCAN_TYPE scanType) 90 : m_line(0), m_column(0), m_blockWidth(blockWidth), m_blockHeight(blockHeight), m_stride(stride), m_scanType(scanType) 91 { } 92 UInt GetCurrentX() const { return m_column; } 93 UInt GetCurrentY() const { return m_line; } 94 UInt GetNextIndex(UInt blockOffsetX, UInt blockOffsetY) 95 { 96 Int rtn=((m_line + blockOffsetY) * m_stride) + m_column + blockOffsetX; 97 //advance line and column to the next position 98 switch (m_scanType) 99 { 100 //------------------------------------------------ 101 case SCAN_DIAG: 102 { 103 if ((m_column == (m_blockWidth - 1)) || (m_line == 0)) //if we reach the end of a rank, go diagonally down to the next one 104 { 105 m_line += m_column + 1; 106 m_column = 0; 107 if (m_line >= m_blockHeight) //if that takes us outside the block, adjust so that we are back on the bottom row 108 { 109 m_column += m_line - (m_blockHeight - 1); 110 m_line = m_blockHeight - 1; 111 } 112 } 113 else 114 { 115 m_column++; 116 m_line--; 117 } 118 } 119 break; 120 //------------------------------------------------ 121 case SCAN_HOR: 122 { 123 if (m_column == (m_blockWidth - 1)) 124 { 125 m_line++; 126 m_column = 0; 127 } 128 else 129 { 130 m_column++; 131 } 132 } 133 break; 134 //------------------------------------------------ 135 case SCAN_VER: 136 { 137 if (m_line == (m_blockHeight - 1)) 138 { 139 m_column++; 140 m_line = 0; 141 } 142 else 143 { 144 m_line++; 145 } 146 } 147 break; 148 //------------------------------------------------ 149 default: 150 { 151 std::cerr << "ERROR: Unknown scan type \"" << m_scanType << "\"in ScanGenerator::GetNextIndex" << std::endl; 152 exit(1); 153 } 154 break; 155 } 156 return rtn; 157 } 158 }; 49 159 // initialize ROM variables 50 160 Void initROM() 51 161 { 52 162 Int i, c; 53 54 163 // g_aucConvertToBit[ x ]: log2(x/4), if x=4 -> 0, x=8 -> 1, x=16 -> 2, ... 55 164 ::memset( g_aucConvertToBit, -1, sizeof( g_aucConvertToBit ) ); … … 60 169 c++; 61 170 } 62 63 c=2; 64 for ( i=0; i<MAX_CU_DEPTH; i++ ) 65 { 66 g_auiSigLastScan[0][i] = new UInt[ c*c ]; 67 g_auiSigLastScan[1][i] = new UInt[ c*c ]; 68 g_auiSigLastScan[2][i] = new UInt[ c*c ]; 69 initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], c, c); 70 71 c <<= 1; 72 } 73 74 #if H_MV 171 // initialise scan orders 172 for(UInt log2BlockHeight = 0; log2BlockHeight < MAX_CU_DEPTH; log2BlockHeight++) 173 { 174 for(UInt log2BlockWidth = 0; log2BlockWidth < MAX_CU_DEPTH; log2BlockWidth++) 175 { 176 const UInt blockWidth = 1 << log2BlockWidth; 177 const UInt blockHeight = 1 << log2BlockHeight; 178 const UInt totalValues = blockWidth * blockHeight; 179 //-------------------------------------------------------------------------------------------------- 180 //non-grouped scan orders 181 for (UInt scanTypeIndex = 0; scanTypeIndex < SCAN_NUMBER_OF_TYPES; scanTypeIndex++) 182 { 183 const COEFF_SCAN_TYPE scanType = COEFF_SCAN_TYPE(scanTypeIndex); 184 g_scanOrder[SCAN_UNGROUPED][scanType][log2BlockWidth][log2BlockHeight] = new UInt[totalValues]; 185 ScanGenerator fullBlockScan(blockWidth, blockHeight, blockWidth, scanType); 186 for (UInt scanPosition = 0; scanPosition < totalValues; scanPosition++) 187 { 188 g_scanOrder[SCAN_UNGROUPED][scanType][log2BlockWidth][log2BlockHeight][scanPosition] = fullBlockScan.GetNextIndex(0, 0); 189 } 190 } 191 //-------------------------------------------------------------------------------------------------- 192 //grouped scan orders 193 const UInt groupWidth = 1 << MLS_CG_LOG2_WIDTH; 194 const UInt groupHeight = 1 << MLS_CG_LOG2_HEIGHT; 195 const UInt widthInGroups = blockWidth >> MLS_CG_LOG2_WIDTH; 196 const UInt heightInGroups = blockHeight >> MLS_CG_LOG2_HEIGHT; 197 const UInt groupSize = groupWidth * groupHeight; 198 const UInt totalGroups = widthInGroups * heightInGroups; 199 for (UInt scanTypeIndex = 0; scanTypeIndex < SCAN_NUMBER_OF_TYPES; scanTypeIndex++) 200 { 201 const COEFF_SCAN_TYPE scanType = COEFF_SCAN_TYPE(scanTypeIndex); 202 g_scanOrder[SCAN_GROUPED_4x4][scanType][log2BlockWidth][log2BlockHeight] = new UInt[totalValues]; 203 ScanGenerator fullBlockScan(widthInGroups, heightInGroups, groupWidth, scanType); 204 for (UInt groupIndex = 0; groupIndex < totalGroups; groupIndex++) 205 { 206 const UInt groupPositionY = fullBlockScan.GetCurrentY(); 207 const UInt groupPositionX = fullBlockScan.GetCurrentX(); 208 const UInt groupOffsetX = groupPositionX * groupWidth; 209 const UInt groupOffsetY = groupPositionY * groupHeight; 210 const UInt groupOffsetScan = groupIndex * groupSize; 211 ScanGenerator groupScan(groupWidth, groupHeight, blockWidth, scanType); 212 for (UInt scanPosition = 0; scanPosition < groupSize; scanPosition++) 213 { 214 g_scanOrder[SCAN_GROUPED_4x4][scanType][log2BlockWidth][log2BlockHeight][groupOffsetScan + scanPosition] = groupScan.GetNextIndex(groupOffsetX, groupOffsetY); 215 } 216 fullBlockScan.GetNextIndex(0,0); 217 } 218 } 219 //-------------------------------------------------------------------------------------------------- 220 } 221 } 222 #if NH_MV 75 223 #if H_MV_HLS_PTL_LIMITS 76 224 g_generalTierAndLevelLimits[ Level::LEVEL1 ] = TComGeneralTierAndLevelLimits( 36864, 350, INT_MIN, 16, 1, 1 ); … … 89 237 #endif 90 238 #endif 91 92 } 93 239 } 94 240 Void destroyROM() 95 241 { 96 for (Int i=0; i<MAX_CU_DEPTH; i++ ) 97 { 98 delete[] g_auiSigLastScan[0][i]; 99 delete[] g_auiSigLastScan[1][i]; 100 delete[] g_auiSigLastScan[2][i]; 101 } 102 103 #if H_3D_DIM_DMM 242 for(UInt groupTypeIndex = 0; groupTypeIndex < SCAN_NUMBER_OF_GROUP_TYPES; groupTypeIndex++) 243 { 244 for (UInt scanOrderIndex = 0; scanOrderIndex < SCAN_NUMBER_OF_TYPES; scanOrderIndex++) 245 { 246 for (UInt log2BlockWidth = 0; log2BlockWidth < MAX_CU_DEPTH; log2BlockWidth++) 247 { 248 for (UInt log2BlockHeight = 0; log2BlockHeight < MAX_CU_DEPTH; log2BlockHeight++) 249 { 250 delete [] g_scanOrder[groupTypeIndex][scanOrderIndex][log2BlockWidth][log2BlockHeight]; 251 } 252 } 253 } 254 } 255 #if NH_3D_DMM 104 256 if( !g_dmmWedgeLists.empty() ) 105 257 { 106 for( UInt ui = 0; ui < g_dmmWedgeLists.size(); ui++ ) 107 { 108 g_dmmWedgeLists[ui].clear(); 109 } 258 for( UInt ui = 0; ui < g_dmmWedgeLists.size(); ui++ ) { g_dmmWedgeLists[ui].clear(); } 110 259 g_dmmWedgeLists.clear(); 111 260 } 112 if( !g_dmmWedgeRefLists.empty() )113 {114 for( UInt ui = 0; ui < g_dmmWedgeRefLists.size(); ui++ )115 {116 g_dmmWedgeRefLists[ui].clear();117 }118 g_dmmWedgeRefLists.clear();119 }120 121 261 if( !g_dmmWedgeNodeLists.empty() ) 122 262 { 123 for( UInt ui = 0; ui < g_dmmWedgeNodeLists.size(); ui++ ) 124 { 125 g_dmmWedgeNodeLists[ui].clear(); 126 } 263 for( UInt ui = 0; ui < g_dmmWedgeNodeLists.size(); ui++ ) { g_dmmWedgeNodeLists[ui].clear(); } 127 264 g_dmmWedgeNodeLists.clear(); 128 265 } 129 266 #endif 130 267 } 131 132 268 // ==================================================================================================================== 133 269 // Data structure related table & variable 134 270 // ==================================================================================================================== 135 136 UInt g_uiMaxCUWidth = MAX_CU_SIZE; 137 UInt g_uiMaxCUHeight = MAX_CU_SIZE; 138 UInt g_uiMaxCUDepth = MAX_CU_DEPTH; 139 UInt g_uiAddCUDepth = 0; 140 UInt g_auiZscanToRaster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; 141 UInt g_auiRasterToZscan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; 142 UInt g_auiRasterToPelX [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; 143 UInt g_auiRasterToPelY [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; 144 145 UInt g_auiPUOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5}; 146 271 UInt g_auiZscanToRaster [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, }; 272 UInt g_auiRasterToZscan [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, }; 273 UInt g_auiRasterToPelX [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, }; 274 UInt g_auiRasterToPelY [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, }; 275 const UInt g_auiPUOffset[NUMBER_OF_PART_SIZES] = { 0, 8, 4, 4, 2, 10, 1, 5}; 147 276 Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ) 148 277 { 149 278 Int iStride = 1 << ( iMaxDepth - 1 ); 150 151 279 if ( iDepth == iMaxDepth ) 152 280 { … … 163 291 } 164 292 } 165 166 293 Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) 167 294 { 168 295 UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); 169 296 UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); 170 171 297 UInt uiNumPartInWidth = (UInt)uiMaxCUWidth / uiMinCUWidth; 172 298 UInt uiNumPartInHeight = (UInt)uiMaxCUHeight / uiMinCUHeight; 173 174 299 for ( UInt i = 0; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) 175 300 { … … 177 302 } 178 303 } 179 180 304 Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) 181 305 { 182 306 UInt i; 183 184 307 UInt* uiTempX = &g_auiRasterToPelX[0]; 185 308 UInt* uiTempY = &g_auiRasterToPelY[0]; 186 187 309 UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); 188 310 UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); 189 190 311 UInt uiNumPartInWidth = uiMaxCUWidth / uiMinCUWidth; 191 312 UInt uiNumPartInHeight = uiMaxCUHeight / uiMinCUHeight; 192 193 313 uiTempX[0] = 0; uiTempX++; 194 314 for ( i = 1; i < uiNumPartInWidth; i++ ) … … 201 321 uiTempX += uiNumPartInWidth; 202 322 } 203 204 323 for ( i = 1; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) 205 324 { 206 325 uiTempY[i] = ( i / uiNumPartInWidth ) * uiMinCUWidth; 207 326 } 208 }; 209 210 211 Int g_quantScales[6] = 327 } 328 const Int g_quantScales[SCALING_LIST_REM_NUM] = 212 329 { 213 330 26214,23302,20560,18396,16384,14564 214 }; 215 216 Int g_invQuantScales[6] = 331 }; 332 const Int g_invQuantScales[SCALING_LIST_REM_NUM] = 217 333 { 218 334 40,45,51,57,64,72 219 335 }; 220 221 const Short g_aiT4[4][4] = 222 { 223 { 64, 64, 64, 64}, 224 { 83, 36,-36,-83}, 225 { 64,-64,-64, 64}, 226 { 36,-83, 83,-36} 227 }; 228 229 const Short g_aiT8[8][8] = 230 { 231 { 64, 64, 64, 64, 64, 64, 64, 64}, 232 { 89, 75, 50, 18,-18,-50,-75,-89}, 233 { 83, 36,-36,-83,-83,-36, 36, 83}, 234 { 75,-18,-89,-50, 50, 89, 18,-75}, 235 { 64,-64,-64, 64, 64,-64,-64, 64}, 236 { 50,-89, 18, 75,-75,-18, 89,-50}, 237 { 36,-83, 83,-36,-36, 83,-83, 36}, 238 { 18,-50, 75,-89, 89,-75, 50,-18} 239 }; 240 241 const Short g_aiT16[16][16] = 242 { 243 { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, 244 { 90, 87, 80, 70, 57, 43, 25, 9, -9,-25,-43,-57,-70,-80,-87,-90}, 245 { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89}, 246 { 87, 57, 9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87}, 247 { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83}, 248 { 80, 9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80}, 249 { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75}, 250 { 70,-43,-87, 9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70}, 251 { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64}, 252 { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87, 9,-90, 25, 80,-57}, 253 { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50}, 254 { 43,-90, 57, 25,-87, 70, 9,-80, 80, -9,-70, 87,-25,-57, 90,-43}, 255 { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36}, 256 { 25,-70, 90,-80, 43, 9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25}, 257 { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18}, 258 { 9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9} 259 }; 260 261 const Short g_aiT32[32][32] = 262 { 263 { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, 264 { 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4, -4,-13,-22,-31,-38,-46,-54,-61,-67,-73,-78,-82,-85,-88,-90,-90}, 265 { 90, 87, 80, 70, 57, 43, 25, 9, -9,-25,-43,-57,-70,-80,-87,-90,-90,-87,-80,-70,-57,-43,-25, -9, 9, 25, 43, 57, 70, 80, 87, 90}, 266 { 90, 82, 67, 46, 22, -4,-31,-54,-73,-85,-90,-88,-78,-61,-38,-13, 13, 38, 61, 78, 88, 90, 85, 73, 54, 31, 4,-22,-46,-67,-82,-90}, 267 { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89, 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89}, 268 { 88, 67, 31,-13,-54,-82,-90,-78,-46, -4, 38, 73, 90, 85, 61, 22,-22,-61,-85,-90,-73,-38, 4, 46, 78, 90, 82, 54, 13,-31,-67,-88}, 269 { 87, 57, 9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87,-87,-57, -9, 43, 80, 90, 70, 25,-25,-70,-90,-80,-43, 9, 57, 87}, 270 { 85, 46,-13,-67,-90,-73,-22, 38, 82, 88, 54, -4,-61,-90,-78,-31, 31, 78, 90, 61, 4,-54,-88,-82,-38, 22, 73, 90, 67, 13,-46,-85}, 271 { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83}, 272 { 82, 22,-54,-90,-61, 13, 78, 85, 31,-46,-90,-67, 4, 73, 88, 38,-38,-88,-73, -4, 67, 90, 46,-31,-85,-78,-13, 61, 90, 54,-22,-82}, 273 { 80, 9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80,-80, -9, 70, 87, 25,-57,-90,-43, 43, 90, 57,-25,-87,-70, 9, 80}, 274 { 78, -4,-82,-73, 13, 85, 67,-22,-88,-61, 31, 90, 54,-38,-90,-46, 46, 90, 38,-54,-90,-31, 61, 88, 22,-67,-85,-13, 73, 82, 4,-78}, 275 { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75, 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75}, 276 { 73,-31,-90,-22, 78, 67,-38,-90,-13, 82, 61,-46,-88, -4, 85, 54,-54,-85, 4, 88, 46,-61,-82, 13, 90, 38,-67,-78, 22, 90, 31,-73}, 277 { 70,-43,-87, 9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70,-70, 43, 87, -9,-90,-25, 80, 57,-57,-80, 25, 90, 9,-87,-43, 70}, 278 { 67,-54,-78, 38, 85,-22,-90, 4, 90, 13,-88,-31, 82, 46,-73,-61, 61, 73,-46,-82, 31, 88,-13,-90, -4, 90, 22,-85,-38, 78, 54,-67}, 279 { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64}, 280 { 61,-73,-46, 82, 31,-88,-13, 90, -4,-90, 22, 85,-38,-78, 54, 67,-67,-54, 78, 38,-85,-22, 90, 4,-90, 13, 88,-31,-82, 46, 73,-61}, 281 { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87, 9,-90, 25, 80,-57,-57, 80, 25,-90, 9, 87,-43,-70, 70, 43,-87, -9, 90,-25,-80, 57}, 282 { 54,-85, -4, 88,-46,-61, 82, 13,-90, 38, 67,-78,-22, 90,-31,-73, 73, 31,-90, 22, 78,-67,-38, 90,-13,-82, 61, 46,-88, 4, 85,-54}, 283 { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50, 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50}, 284 { 46,-90, 38, 54,-90, 31, 61,-88, 22, 67,-85, 13, 73,-82, 4, 78,-78, -4, 82,-73,-13, 85,-67,-22, 88,-61,-31, 90,-54,-38, 90,-46}, 285 { 43,-90, 57, 25,-87, 70, 9,-80, 80, -9,-70, 87,-25,-57, 90,-43,-43, 90,-57,-25, 87,-70, -9, 80,-80, 9, 70,-87, 25, 57,-90, 43}, 286 { 38,-88, 73, -4,-67, 90,-46,-31, 85,-78, 13, 61,-90, 54, 22,-82, 82,-22,-54, 90,-61,-13, 78,-85, 31, 46,-90, 67, 4,-73, 88,-38}, 287 { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36}, 288 { 31,-78, 90,-61, 4, 54,-88, 82,-38,-22, 73,-90, 67,-13,-46, 85,-85, 46, 13,-67, 90,-73, 22, 38,-82, 88,-54, -4, 61,-90, 78,-31}, 289 { 25,-70, 90,-80, 43, 9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25,-25, 70,-90, 80,-43, -9, 57,-87, 87,-57, 9, 43,-80, 90,-70, 25}, 290 { 22,-61, 85,-90, 73,-38, -4, 46,-78, 90,-82, 54,-13,-31, 67,-88, 88,-67, 31, 13,-54, 82,-90, 78,-46, 4, 38,-73, 90,-85, 61,-22}, 291 { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18, 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18}, 292 { 13,-38, 61,-78, 88,-90, 85,-73, 54,-31, 4, 22,-46, 67,-82, 90,-90, 82,-67, 46,-22, -4, 31,-54, 73,-85, 90,-88, 78,-61, 38,-13}, 293 { 9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9, -9, 25,-43, 57,-70, 80,-87, 90,-90, 87,-80, 70,-57, 43,-25, 9}, 294 { 4,-13, 22,-31, 38,-46, 54,-61, 67,-73, 78,-82, 85,-88, 90,-90, 90,-90, 88,-85, 82,-78, 73,-67, 61,-54, 46,-38, 31,-22, 13, -4} 295 }; 296 297 const UChar g_aucChromaScale[58]= 298 { 299 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, 300 17,18,19,20,21,22,23,24,25,26,27,28,29,29,30,31,32, 301 33,33,34,34,35,35,36,36,37,37,38,39,40,41,42,43,44, 302 45,46,47,48,49,50,51 303 }; 304 305 306 // Mode-Dependent DCT/DST 307 const Short g_as_DST_MAT_4 [4][4]= 308 { 309 {29, 55, 74, 84}, 310 {74, 74, 0 , -74}, 311 {84, -29, -74, 55}, 312 {55, -84, 74, -29}, 313 }; 314 315 316 // ==================================================================================================================== 317 // ADI 318 // ==================================================================================================================== 319 320 #if FAST_UDI_USE_MPM 321 const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] = 336 //-------------------------------------------------------------------------------------------------- 337 //structures 338 #define DEFINE_DST4x4_MATRIX(a,b,c,d) \ 339 { \ 340 { a, b, c, d }, \ 341 { c, c, 0, -c }, \ 342 { d, -a, -c, b }, \ 343 { b, -d, c, -a }, \ 344 } 345 #define DEFINE_DCT4x4_MATRIX(a,b,c) \ 346 { \ 347 { a, a, a, a}, \ 348 { b, c, -c, -b}, \ 349 { a, -a, -a, a}, \ 350 { c, -b, b, -c} \ 351 } 352 #define DEFINE_DCT8x8_MATRIX(a,b,c,d,e,f,g) \ 353 { \ 354 { a, a, a, a, a, a, a, a}, \ 355 { d, e, f, g, -g, -f, -e, -d}, \ 356 { b, c, -c, -b, -b, -c, c, b}, \ 357 { e, -g, -d, -f, f, d, g, -e}, \ 358 { a, -a, -a, a, a, -a, -a, a}, \ 359 { f, -d, g, e, -e, -g, d, -f}, \ 360 { c, -b, b, -c, -c, b, -b, c}, \ 361 { g, -f, e, -d, d, -e, f, -g} \ 362 } 363 #define DEFINE_DCT16x16_MATRIX(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) \ 364 { \ 365 { a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a}, \ 366 { h, i, j, k, l, m, n, o, -o, -n, -m, -l, -k, -j, -i, -h}, \ 367 { d, e, f, g, -g, -f, -e, -d, -d, -e, -f, -g, g, f, e, d}, \ 368 { i, l, o, -m, -j, -h, -k, -n, n, k, h, j, m, -o, -l, -i}, \ 369 { b, c, -c, -b, -b, -c, c, b, b, c, -c, -b, -b, -c, c, b}, \ 370 { j, o, -k, -i, -n, l, h, m, -m, -h, -l, n, i, k, -o, -j}, \ 371 { e, -g, -d, -f, f, d, g, -e, -e, g, d, f, -f, -d, -g, e}, \ 372 { k, -m, -i, o, h, n, -j, -l, l, j, -n, -h, -o, i, m, -k}, \ 373 { a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a}, \ 374 { l, -j, -n, h, -o, -i, m, k, -k, -m, i, o, -h, n, j, -l}, \ 375 { f, -d, g, e, -e, -g, d, -f, -f, d, -g, -e, e, g, -d, f}, \ 376 { m, -h, l, n, -i, k, o, -j, j, -o, -k, i, -n, -l, h, -m}, \ 377 { c, -b, b, -c, -c, b, -b, c, c, -b, b, -c, -c, b, -b, c}, \ 378 { n, -k, h, -j, m, o, -l, i, -i, l, -o, -m, j, -h, k, -n}, \ 379 { g, -f, e, -d, d, -e, f, -g, -g, f, -e, d, -d, e, -f, g}, \ 380 { o, -n, m, -l, k, -j, i, -h, h, -i, j, -k, l, -m, n, -o} \ 381 } 382 #define DEFINE_DCT32x32_MATRIX(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E) \ 383 { \ 384 { a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a}, \ 385 { p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, -E, -D, -C, -B, -A, -z, -y, -x, -w, -v, -u, -t, -s, -r, -q, -p}, \ 386 { h, i, j, k, l, m, n, o, -o, -n, -m, -l, -k, -j, -i, -h, -h, -i, -j, -k, -l, -m, -n, -o, o, n, m, l, k, j, i, h}, \ 387 { q, t, w, z, C, -E, -B, -y, -v, -s, -p, -r, -u, -x, -A, -D, D, A, x, u, r, p, s, v, y, B, E, -C, -z, -w, -t, -q}, \ 388 { d, e, f, g, -g, -f, -e, -d, -d, -e, -f, -g, g, f, e, d, d, e, f, g, -g, -f, -e, -d, -d, -e, -f, -g, g, f, e, d}, \ 389 { r, w, B, -D, -y, -t, -p, -u, -z, -E, A, v, q, s, x, C, -C, -x, -s, -q, -v, -A, E, z, u, p, t, y, D, -B, -w, -r}, \ 390 { i, l, o, -m, -j, -h, -k, -n, n, k, h, j, m, -o, -l, -i, -i, -l, -o, m, j, h, k, n, -n, -k, -h, -j, -m, o, l, i}, \ 391 { s, z, -D, -w, -p, -v, -C, A, t, r, y, -E, -x, -q, -u, -B, B, u, q, x, E, -y, -r, -t, -A, C, v, p, w, D, -z, -s}, \ 392 { b, c, -c, -b, -b, -c, c, b, b, c, -c, -b, -b, -c, c, b, b, c, -c, -b, -b, -c, c, b, b, c, -c, -b, -b, -c, c, b}, \ 393 { t, C, -y, -p, -x, D, u, s, B, -z, -q, -w, E, v, r, A, -A, -r, -v, -E, w, q, z, -B, -s, -u, -D, x, p, y, -C, -t}, \ 394 { j, o, -k, -i, -n, l, h, m, -m, -h, -l, n, i, k, -o, -j, -j, -o, k, i, n, -l, -h, -m, m, h, l, -n, -i, -k, o, j}, \ 395 { u, -E, -t, -v, D, s, w, -C, -r, -x, B, q, y, -A, -p, -z, z, p, A, -y, -q, -B, x, r, C, -w, -s, -D, v, t, E, -u}, \ 396 { e, -g, -d, -f, f, d, g, -e, -e, g, d, f, -f, -d, -g, e, e, -g, -d, -f, f, d, g, -e, -e, g, d, f, -f, -d, -g, e}, \ 397 { v, -B, -p, -C, u, w, -A, -q, -D, t, x, -z, -r, -E, s, y, -y, -s, E, r, z, -x, -t, D, q, A, -w, -u, C, p, B, -v}, \ 398 { k, -m, -i, o, h, n, -j, -l, l, j, -n, -h, -o, i, m, -k, -k, m, i, -o, -h, -n, j, l, -l, -j, n, h, o, -i, -m, k}, \ 399 { w, -y, -u, A, s, -C, -q, E, p, D, -r, -B, t, z, -v, -x, x, v, -z, -t, B, r, -D, -p, -E, q, C, -s, -A, u, y, -w}, \ 400 { a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a}, \ 401 { x, -v, -z, t, B, -r, -D, p, -E, -q, C, s, -A, -u, y, w, -w, -y, u, A, -s, -C, q, E, -p, D, r, -B, -t, z, v, -x}, \ 402 { l, -j, -n, h, -o, -i, m, k, -k, -m, i, o, -h, n, j, -l, -l, j, n, -h, o, i, -m, -k, k, m, -i, -o, h, -n, -j, l}, \ 403 { y, -s, -E, r, -z, -x, t, D, -q, A, w, -u, -C, p, -B, -v, v, B, -p, C, u, -w, -A, q, -D, -t, x, z, -r, E, s, -y}, \ 404 { f, -d, g, e, -e, -g, d, -f, -f, d, -g, -e, e, g, -d, f, f, -d, g, e, -e, -g, d, -f, -f, d, -g, -e, e, g, -d, f}, \ 405 { z, -p, A, y, -q, B, x, -r, C, w, -s, D, v, -t, E, u, -u, -E, t, -v, -D, s, -w, -C, r, -x, -B, q, -y, -A, p, -z}, \ 406 { m, -h, l, n, -i, k, o, -j, j, -o, -k, i, -n, -l, h, -m, -m, h, -l, -n, i, -k, -o, j, -j, o, k, -i, n, l, -h, m}, \ 407 { A, -r, v, -E, -w, q, -z, -B, s, -u, D, x, -p, y, C, -t, t, -C, -y, p, -x, -D, u, -s, B, z, -q, w, E, -v, r, -A}, \ 408 { c, -b, b, -c, -c, b, -b, c, c, -b, b, -c, -c, b, -b, c, c, -b, b, -c, -c, b, -b, c, c, -b, b, -c, -c, b, -b, c}, \ 409 { B, -u, q, -x, E, y, -r, t, -A, -C, v, -p, w, -D, -z, s, -s, z, D, -w, p, -v, C, A, -t, r, -y, -E, x, -q, u, -B}, \ 410 { n, -k, h, -j, m, o, -l, i, -i, l, -o, -m, j, -h, k, -n, -n, k, -h, j, -m, -o, l, -i, i, -l, o, m, -j, h, -k, n}, \ 411 { C, -x, s, -q, v, -A, -E, z, -u, p, -t, y, -D, -B, w, -r, r, -w, B, D, -y, t, -p, u, -z, E, A, -v, q, -s, x, -C}, \ 412 { g, -f, e, -d, d, -e, f, -g, -g, f, -e, d, -d, e, -f, g, g, -f, e, -d, d, -e, f, -g, -g, f, -e, d, -d, e, -f, g}, \ 413 { D, -A, x, -u, r, -p, s, -v, y, -B, E, C, -z, w, -t, q, -q, t, -w, z, -C, -E, B, -y, v, -s, p, -r, u, -x, A, -D}, \ 414 { o, -n, m, -l, k, -j, i, -h, h, -i, j, -k, l, -m, n, -o, -o, n, -m, l, -k, j, -i, h, -h, i, -j, k, -l, m, -n, o}, \ 415 { E, -D, C, -B, A, -z, y, -x, w, -v, u, -t, s, -r, q, -p, p, -q, r, -s, t, -u, v, -w, x, -y, z, -A, B, -C, D, -E} \ 416 } 417 //-------------------------------------------------------------------------------------------------- 418 //coefficients 419 #if RExt__HIGH_PRECISION_FORWARD_TRANSFORM 420 const TMatrixCoeff g_aiT4 [TRANSFORM_NUMBER_OF_DIRECTIONS][4][4] = 421 { 422 DEFINE_DCT4x4_MATRIX (16384, 21266, 9224), 423 DEFINE_DCT4x4_MATRIX ( 64, 83, 36) 424 }; 425 const TMatrixCoeff g_aiT8 [TRANSFORM_NUMBER_OF_DIRECTIONS][8][8] = 426 { 427 DEFINE_DCT8x8_MATRIX (16384, 21266, 9224, 22813, 19244, 12769, 4563), 428 DEFINE_DCT8x8_MATRIX ( 64, 83, 36, 89, 75, 50, 18) 429 }; 430 const TMatrixCoeff g_aiT16[TRANSFORM_NUMBER_OF_DIRECTIONS][16][16] = 431 { 432 DEFINE_DCT16x16_MATRIX(16384, 21266, 9224, 22813, 19244, 12769, 4563, 23120, 22063, 20450, 17972, 14642, 11109, 6446, 2316), 433 DEFINE_DCT16x16_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9) 434 }; 435 const TMatrixCoeff g_aiT32[TRANSFORM_NUMBER_OF_DIRECTIONS][32][32] = 436 { 437 DEFINE_DCT32x32_MATRIX(16384, 21266, 9224, 22813, 19244, 12769, 4563, 23120, 22063, 20450, 17972, 14642, 11109, 6446, 2316, 23106, 22852, 22445, 21848, 20995, 19810, 18601, 17143, 15718, 13853, 11749, 9846, 7908, 5573, 3281, 946), 438 DEFINE_DCT32x32_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9, 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4) 439 }; 440 const TMatrixCoeff g_as_DST_MAT_4[TRANSFORM_NUMBER_OF_DIRECTIONS][4][4] = 441 { 442 DEFINE_DST4x4_MATRIX( 7424, 14081, 18893, 21505), 443 DEFINE_DST4x4_MATRIX( 29, 55, 74, 84) 444 }; 445 #else 446 const TMatrixCoeff g_aiT4 [TRANSFORM_NUMBER_OF_DIRECTIONS][4][4] = 447 { 448 DEFINE_DCT4x4_MATRIX ( 64, 83, 36), 449 DEFINE_DCT4x4_MATRIX ( 64, 83, 36) 450 }; 451 const TMatrixCoeff g_aiT8 [TRANSFORM_NUMBER_OF_DIRECTIONS][8][8] = 452 { 453 DEFINE_DCT8x8_MATRIX ( 64, 83, 36, 89, 75, 50, 18), 454 DEFINE_DCT8x8_MATRIX ( 64, 83, 36, 89, 75, 50, 18) 455 }; 456 const TMatrixCoeff g_aiT16[TRANSFORM_NUMBER_OF_DIRECTIONS][16][16] = 457 { 458 DEFINE_DCT16x16_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9), 459 DEFINE_DCT16x16_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9) 460 }; 461 const TMatrixCoeff g_aiT32[TRANSFORM_NUMBER_OF_DIRECTIONS][32][32] = 462 { 463 DEFINE_DCT32x32_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9, 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4), 464 DEFINE_DCT32x32_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9, 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4) 465 }; 466 const TMatrixCoeff g_as_DST_MAT_4[TRANSFORM_NUMBER_OF_DIRECTIONS][4][4] = 467 { 468 DEFINE_DST4x4_MATRIX( 29, 55, 74, 84), 469 DEFINE_DST4x4_MATRIX( 29, 55, 74, 84) 470 }; 471 #endif 472 //-------------------------------------------------------------------------------------------------- 473 #undef DEFINE_DST4x4_MATRIX 474 #undef DEFINE_DCT4x4_MATRIX 475 #undef DEFINE_DCT8x8_MATRIX 476 #undef DEFINE_DCT16x16_MATRIX 477 #undef DEFINE_DCT32x32_MATRIX 478 //-------------------------------------------------------------------------------------------------- 479 const UChar g_aucChromaScale[NUM_CHROMA_FORMAT][chromaQPMappingTableSize]= 480 { 481 //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,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57 482 { 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 483 { 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,33,33,34,34,35,35,36,36,37,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51 }, 484 { 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,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,51,51,51,51,51,51 }, 485 { 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,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,51,51,51,51,51,51 } 486 }; 487 // ==================================================================================================================== 488 // Intra prediction 489 // ==================================================================================================================== 490 const UChar g_aucIntraModeNumFast_UseMPM[MAX_CU_DEPTH] = 322 491 { 323 492 3, // 2x2 324 493 8, // 4x4 325 494 8, // 8x8 326 3, // 16x16 327 3, // 32x32 328 3 // 64x64 329 }; 330 #else // FAST_UDI_USE_MPM 331 const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] = 495 3, // 16x16 496 3, // 32x32 497 3 // 64x64 498 }; 499 const UChar g_aucIntraModeNumFast_NotUseMPM[MAX_CU_DEPTH] = 332 500 { 333 501 3, // 2x2 … … 338 506 5 // 64x64 33 339 507 }; 340 #endif // FAST_UDI_USE_MPM 341 342 // chroma 343 344 const UChar g_aucConvertTxtTypeToIdx[4] = { 0, 1, 1, 2 }; 345 346 347 // ==================================================================================================================== 348 // Bit-depth 349 // ==================================================================================================================== 350 351 Int g_bitDepthY = 8; 352 Int g_bitDepthC = 8; 353 354 UInt g_uiPCMBitDepthLuma = 8; // PCM bit-depth 355 UInt g_uiPCMBitDepthChroma = 8; // PCM bit-depth 356 357 #if H_3D_DIM_DMM 508 const UChar g_chroma422IntraAngleMappingTable[NUM_INTRA_MODE] = 509 //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, 30, 31, 32, 33, 34, DM 510 { 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31, DM_CHROMA_IDX}; 511 #if NH_3D_DMM 358 512 // ==================================================================================================================== 359 513 // Depth coding modes … … 368 522 FULL_PEL // 128x128 369 523 }; 370 371 524 const UChar g_dmm1TabIdxBits[6] = 372 525 { //2x2 4x4 8x8 16x16 32x32 64x64 373 526 0, 7, 10, 9, 9, 13 }; 374 375 const UChar g_dmm3IntraTabIdxBits[6] =376 { //2x2 4x4 8x8 16x16 32x32 64x64377 0, 4, 7, 8, 8, 0 };378 379 527 Bool g_wedgePattern[32*32]; 380 381 528 extern std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; 382 extern std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists;383 529 extern std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; 384 530 #endif 385 386 531 // ==================================================================================================================== 387 532 // Misc. 388 533 // ==================================================================================================================== 389 390 534 Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; 391 535 #if ENC_DEC_TRACE 392 FILE* g_hTrace = NULL; 536 FILE* g_hTrace = NULL; // Set to NULL to open up a file. Set to stdout to use the current output 393 537 const Bool g_bEncDecTraceEnable = true; 394 538 const Bool g_bEncDecTraceDisable = false; 395 Bool g_HLSTraceEnable = true;539 Bool g_HLSTraceEnable = false; 396 540 Bool g_bJustDoIt = false; 397 541 UInt64 g_nSymbolCounter = 0; … … 402 546 Bool g_disableNumbering = false; 403 547 Bool g_disableHLSTrace = false; 404 UInt64 g_stopAtCounter = 937234; 405 Bool g_traceCopyBack = false; 406 Bool g_decTraceDispDer = false; 407 Bool g_decTraceMvFromMerge = false; 408 Bool g_decTracePicOutput = false; 409 Bool g_stopAtPos = true; 410 Bool g_outputPos = true; 411 Bool g_traceCameraParameters = false; 412 Bool g_encNumberOfWrittenBits = true; 548 UInt64 g_stopAtCounter = 4660; 549 Bool g_traceCopyBack = false; 550 Bool g_decTraceDispDer = false; 551 Bool g_decTraceMvFromMerge = false; 552 Bool g_decTracePicOutput = false; 553 Bool g_startStopTrace = false; 554 Bool g_outputPos = false; 555 Bool g_traceCameraParameters = false; 556 Bool g_encNumberOfWrittenBits = false; 557 Bool g_traceEncFracBits = false; 558 Bool g_traceIntraSearchCost = false; 559 Bool g_traceRDCost = false; 560 Bool g_traceSAOCost = false; 561 Bool g_traceModeCheck = false; 562 UInt g_indent = false; 413 563 #endif 414 564 #endif … … 416 566 // Scanning order & context model mapping 417 567 // ==================================================================================================================== 418 419 568 // scanning order table 420 UInt* g_auiSigLastScan[ 3 ][ MAX_CU_DEPTH ]; 421 422 const UInt g_sigLastScan8x8[ 3 ][ 4 ] = 423 { 424 {0, 2, 1, 3}, 425 {0, 1, 2, 3}, 426 {0, 2, 1, 3} 427 }; 428 UInt g_sigLastScanCG32x32[ 64 ]; 429 430 const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24}; 431 const UInt g_uiGroupIdx[ 32 ] = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9}; 432 433 Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight) 434 { 435 const UInt uiNumScanPos = UInt( iWidth * iWidth ); 436 UInt uiNextScanPos = 0; 437 438 if( iWidth < 16 ) 439 { 440 UInt* pBuffTemp = pBuffD; 441 if( iWidth == 8 ) 442 { 443 pBuffTemp = g_sigLastScanCG32x32; 444 } 445 for( UInt uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ ) 446 { 447 Int iPrimDim = Int( uiScanLine ); 448 Int iScndDim = 0; 449 while( iPrimDim >= iWidth ) 450 { 451 iScndDim++; 452 iPrimDim--; 453 } 454 while( iPrimDim >= 0 && iScndDim < iWidth ) 455 { 456 pBuffTemp[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ; 457 uiNextScanPos++; 458 iScndDim++; 459 iPrimDim--; 460 } 461 } 462 } 463 if( iWidth > 4 ) 464 { 465 UInt uiNumBlkSide = iWidth >> 2; 466 UInt uiNumBlks = uiNumBlkSide * uiNumBlkSide; 467 UInt log2Blk = g_aucConvertToBit[ uiNumBlkSide ] + 1; 468 469 for( UInt uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ ) 470 { 471 uiNextScanPos = 0; 472 UInt initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ]; 473 if( iWidth == 32 ) 474 { 475 initBlkPos = g_sigLastScanCG32x32[ uiBlk ]; 476 } 477 UInt offsetY = initBlkPos / uiNumBlkSide; 478 UInt offsetX = initBlkPos - offsetY * uiNumBlkSide; 479 UInt offsetD = 4 * ( offsetX + offsetY * iWidth ); 480 UInt offsetScan = 16 * uiBlk; 481 for( UInt uiScanLine = 0; uiNextScanPos < 16; uiScanLine++ ) 482 { 483 Int iPrimDim = Int( uiScanLine ); 484 Int iScndDim = 0; 485 while( iPrimDim >= 4 ) 486 { 487 iScndDim++; 488 iPrimDim--; 489 } 490 while( iPrimDim >= 0 && iScndDim < 4 ) 491 { 492 pBuffD[ uiNextScanPos + offsetScan ] = iPrimDim * iWidth + iScndDim + offsetD; 493 uiNextScanPos++; 494 iScndDim++; 495 iPrimDim--; 496 } 497 } 498 } 499 } 500 501 UInt uiCnt = 0; 502 if( iWidth > 2 ) 503 { 504 UInt numBlkSide = iWidth >> 2; 505 for(Int blkY=0; blkY < numBlkSide; blkY++) 506 { 507 for(Int blkX=0; blkX < numBlkSide; blkX++) 508 { 509 UInt offset = blkY * 4 * iWidth + blkX * 4; 510 for(Int y=0; y < 4; y++) 511 { 512 for(Int x=0; x < 4; x++) 513 { 514 pBuffH[uiCnt] = y*iWidth + x + offset; 515 uiCnt ++; 516 } 517 } 518 } 519 } 520 521 uiCnt = 0; 522 for(Int blkX=0; blkX < numBlkSide; blkX++) 523 { 524 for(Int blkY=0; blkY < numBlkSide; blkY++) 525 { 526 UInt offset = blkY * 4 * iWidth + blkX * 4; 527 for(Int x=0; x < 4; x++) 528 { 529 for(Int y=0; y < 4; y++) 530 { 531 pBuffV[uiCnt] = y*iWidth + x + offset; 532 uiCnt ++; 533 } 534 } 535 } 536 } 537 } 538 else 539 { 540 for(Int iY=0; iY < iHeight; iY++) 541 { 542 for(Int iX=0; iX < iWidth; iX++) 543 { 544 pBuffH[uiCnt] = iY*iWidth + iX; 545 uiCnt ++; 546 } 547 } 548 549 uiCnt = 0; 550 for(Int iX=0; iX < iWidth; iX++) 551 { 552 for(Int iY=0; iY < iHeight; iY++) 553 { 554 pBuffV[uiCnt] = iY*iWidth + iX; 555 uiCnt ++; 556 } 557 } 558 } 559 } 560 561 Int g_quantTSDefault4x4[16] = 569 UInt* g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][ MAX_CU_DEPTH ][ MAX_CU_DEPTH ]; 570 const UInt ctxIndMap4x4[4*4] = 571 { 572 0, 1, 4, 5, 573 2, 3, 4, 5, 574 6, 6, 8, 8, 575 7, 7, 8, 8 576 }; 577 const UInt g_uiMinInGroup[ LAST_SIGNIFICANT_GROUPS ] = {0,1,2,3,4,6,8,12,16,24}; 578 const UInt g_uiGroupIdx[ MAX_TU_SIZE ] = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9}; 579 const Char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] = 580 { 581 { 582 "INTRA4X4_LUMA", 583 "INTRA4X4_CHROMAU", 584 "INTRA4X4_CHROMAV", 585 "INTER4X4_LUMA", 586 "INTER4X4_CHROMAU", 587 "INTER4X4_CHROMAV" 588 }, 589 { 590 "INTRA8X8_LUMA", 591 "INTRA8X8_CHROMAU", 592 "INTRA8X8_CHROMAV", 593 "INTER8X8_LUMA", 594 "INTER8X8_CHROMAU", 595 "INTER8X8_CHROMAV" 596 }, 597 { 598 "INTRA16X16_LUMA", 599 "INTRA16X16_CHROMAU", 600 "INTRA16X16_CHROMAV", 601 "INTER16X16_LUMA", 602 "INTER16X16_CHROMAU", 603 "INTER16X16_CHROMAV" 604 }, 605 { 606 "INTRA32X32_LUMA", 607 "INTRA32X32_CHROMAU_FROM16x16_CHROMAU", 608 "INTRA32X32_CHROMAV_FROM16x16_CHROMAV", 609 "INTER32X32_LUMA", 610 "INTER32X32_CHROMAU_FROM16x16_CHROMAU", 611 "INTER32X32_CHROMAV_FROM16x16_CHROMAV" 612 }, 613 }; 614 const Char *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] = 615 { 616 { 617 }, 618 { 619 }, 620 { 621 "INTRA16X16_LUMA_DC", 622 "INTRA16X16_CHROMAU_DC", 623 "INTRA16X16_CHROMAV_DC", 624 "INTER16X16_LUMA_DC", 625 "INTER16X16_CHROMAU_DC", 626 "INTER16X16_CHROMAV_DC" 627 }, 628 { 629 "INTRA32X32_LUMA_DC", 630 "INTRA32X32_CHROMAU_DC_FROM16x16_CHROMAU", 631 "INTRA32X32_CHROMAV_DC_FROM16x16_CHROMAV", 632 "INTER32X32_LUMA_DC", 633 "INTER32X32_CHROMAU_DC_FROM16x16_CHROMAU", 634 "INTER32X32_CHROMAV_DC_FROM16x16_CHROMAV" 635 }, 636 }; 637 const Int g_quantTSDefault4x4[4*4] = 562 638 { 563 639 16,16,16,16, … … 566 642 16,16,16,16 567 643 }; 568 569 Int g_quantIntraDefault8x8[64] = 644 const Int g_quantIntraDefault8x8[8*8] = 570 645 { 571 646 16,16,16,16,17,18,21,24, … … 578 653 24,25,29,36,47,65,88,115 579 654 }; 580 581 Int g_quantInterDefault8x8[64] = 655 const Int g_quantInterDefault8x8[8*8] = 582 656 { 583 657 16,16,16,16,17,18,20,24, … … 590 664 24,25,28,33,41,54,71,91 591 665 }; 592 UInt g_scalingListSize [4] = {16,64,256,1024}; 593 UInt g_scalingListSizeX [4] = { 4, 8, 16, 32}; 594 UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2}; 595 Int g_eTTable[4] = {0,3,1,2}; 596 666 const UInt g_scalingListSize [SCALING_LIST_SIZE_NUM] = {16,64,256,1024}; 667 const UInt g_scalingListSizeX [SCALING_LIST_SIZE_NUM] = { 4, 8, 16, 32}; 597 668 #if H_MV_ENC_DEC_TRAC 598 669 #if ENC_DEC_TRACE 670 Void tracePSHeader( const Char* psName, Int layerId ) 671 { 672 if ( !g_disableHLSTrace ) 673 { 674 fprintf( g_hTrace, "=========== "); 675 fprintf( g_hTrace, "%s", psName ); 676 fprintf( g_hTrace, " Layer %d ===========", layerId ); 677 fprintf( g_hTrace, "\n" ); 678 fflush ( g_hTrace ); 679 } 680 } 599 681 Void stopAtPos( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight ) 600 682 { 601 602 683 if ( g_outputPos ) 603 684 { … … 610 691 << std::endl; 611 692 } 612 613 Bool stopFlag = false; 614 if ( g_stopAtPos && poc == 0 && layerId == 2 ) 615 { 616 Bool stopAtCU = true; 617 if ( stopAtCU ) // Stop at CU with specific size 618 { 619 stopFlag = ( cuPelX == 0 ) && ( cuPelY == 0 ) && ( cuWidth == 8 ) && ( cuHeight == 8 ); 620 } 621 else 622 { // Stop at specific position 623 Int xPos = 888; 624 Int yPos = 248; 625 626 Int cuPelXEnd = cuPelX + cuWidth - 1; 627 Int cuPelYEnd = cuPelY + cuHeight - 1; 628 629 stopFlag = (cuPelX <= xPos ) && (cuPelXEnd >= xPos ) && (cuPelY <= yPos ) && (cuPelYEnd >= yPos ); 630 } 631 } 632 633 if ( stopFlag ) 634 { // Set breakpoint here. 635 std::cout << "Stop position. Break point here." << std::endl; 693 Bool startTrace = false; 694 if ( g_startStopTrace && poc == 0 && layerId == 0 ) 695 { 696 startTrace = ( cuPelX == 0 ) && ( cuPelY == 0 ) && ( cuWidth == 64 ) && ( cuHeight == 64 ); 697 } 698 if ( startTrace ) 699 { 700 g_outputPos = true; 701 g_traceEncFracBits = false; 702 g_traceIntraSearchCost = false; 703 g_encNumberOfWrittenBits = false; 704 g_traceRDCost = true; 705 g_traceModeCheck = true; 706 g_traceCopyBack = false; 636 707 } 637 } 638 708 Bool stopTrace = false; 709 if ( g_startStopTrace && poc == 0 && layerId == 0 ) 710 { 711 stopTrace = ( cuPelX == 128 ) && ( cuPelY == 0 ) && ( cuWidth == 64 ) && ( cuHeight == 64 ); 712 } 713 if ( stopTrace ) 714 { 715 g_outputPos = false; 716 g_traceModeCheck = false; 717 g_traceEncFracBits = false; 718 g_traceIntraSearchCost = false; 719 g_encNumberOfWrittenBits = false; 720 g_traceRDCost = false; 721 g_traceCopyBack = false; 722 } 723 } 639 724 Void writeToTraceFile( const Char* symbolName, Int val, Bool doIt ) 640 725 { 641 726 if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt ) 642 727 { 643 if ( g_stopAtCounter == g_nSymbolCounter ) 644 { 645 std::cout << "Break point here." << std::endl; 646 } 728 incSymbolCounter(); 647 729 if ( !g_disableNumbering ) 648 730 { 649 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter ++);731 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter ); 650 732 } 651 733 fprintf( g_hTrace, "%-50s : %d\n", symbolName, val ); 652 fflush ( g_hTrace ); 653 g_nSymbolCounter++; 654 } 655 } 656 734 fflush ( g_hTrace ); 735 } 736 } 737 UInt64 incSymbolCounter( ) 738 { 739 g_nSymbolCounter++; 740 if ( g_stopAtCounter == g_nSymbolCounter ) 741 { 742 std::cout << "Break point here." << std::endl; 743 } 744 return g_nSymbolCounter; 745 } 657 746 Void writeToTraceFile( const Char* symbolName, Bool doIt ) 658 747 { 659 748 if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt ) 660 749 { 750 incSymbolCounter(); 661 751 fprintf( g_hTrace, "%s", symbolName ); 662 fflush ( g_hTrace ); 663 g_nSymbolCounter++; 664 } 665 } 666 752 fflush ( g_hTrace ); 753 } 754 } 755 Void printStr( std::string str ) 756 { 757 std::cout << str << std::endl; 758 } 759 Void printStrIndent( Bool b, std::string strStr ) 760 { 761 if ( b ) 762 { 763 std::cout << std::string(g_indent, ' '); 764 printStr( strStr ); 765 } 766 } 767 Void prinStrIncIndent( Bool b, std::string strStr ) 768 { 769 if ( b ) 770 { 771 printStrIndent( true, strStr ); 772 if (g_indent < 50) 773 { 774 g_indent++; 775 } 776 } 777 } 778 Void decIndent( Bool b ) 779 { 780 if (b && g_indent > 0) 781 { 782 g_indent--; 783 } 784 } 667 785 #endif 668 786 #endif 669 #if H_3D_DIM_DMM787 #if NH_3D_DMM 670 788 std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; 671 std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists;672 789 std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; 673 674 790 Void initWedgeLists( Bool initNodeList ) 675 791 { 676 792 if( !g_dmmWedgeLists.empty() ) return; 677 678 for( UInt ui = g_aucConvertToBit[DIM_MIN_SIZE]; ui < (g_aucConvertToBit[DIM_MAX_SIZE]); ui++ ) 679 { 680 UInt uiWedgeBlockSize = ((UInt)DIM_MIN_SIZE)<<ui; 793 for( UInt ui = g_aucConvertToBit[DMM_MIN_SIZE]; ui < (g_aucConvertToBit[DMM_MAX_SIZE]); ui++ ) 794 { 795 UInt uiWedgeBlockSize = ((UInt)DMM_MIN_SIZE)<<ui; 681 796 std::vector<TComWedgelet> acWedgeList; 682 797 std::vector<TComWedgeRef> acWedgeRefList; 683 798 createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_dmmWedgeResolution[ui] ); 684 799 g_dmmWedgeLists.push_back( acWedgeList ); 685 g_dmmWedgeRefLists.push_back( acWedgeRefList );686 687 800 if( initNodeList ) 688 801 { … … 695 808 TComWedgeNode cWedgeNode; 696 809 cWedgeNode.setPatternIdx( uiPos ); 697 698 810 UInt uiRefPos = 0; 699 811 for( Int iOffS = -1; iOffS <= 1; iOffS++ ) … … 702 814 { 703 815 if( iOffS == 0 && iOffE == 0 ) { continue; } 704 705 816 Int iSx = (Int)acWedgeList[uiPos].getStartX(); 706 817 Int iSy = (Int)acWedgeList[uiPos].getStartY(); 707 818 Int iEx = (Int)acWedgeList[uiPos].getEndX(); 708 819 Int iEy = (Int)acWedgeList[uiPos].getEndY(); 709 710 820 switch( acWedgeList[uiPos].getOri() ) 711 821 { … … 718 828 default: assert( 0 ); 719 829 } 720 721 830 for( UInt k = 0; k < acWedgeRefList.size(); k++ ) 722 831 { … … 730 839 Bool bNew = true; 731 840 for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } } 732 733 841 if( bNew ) 734 842 { … … 749 857 } 750 858 } 751 752 859 Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes ) 753 860 { 754 861 assert( uiWidth == uiHeight ); 755 756 862 Int posStart = 0, posEnd = 0; 757 758 863 UInt uiBlockSize = 0; 759 864 switch( eWedgeRes ) … … 762 867 case( HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; } 763 868 } 764 765 869 TComWedgelet cTempWedgelet( uiWidth, uiHeight ); 766 870 for( UInt uiOri = 0; uiOri < 6; uiOri++ ) 767 871 { 768 769 872 posEnd = (Int) racWedgeList.size(); 770 873 if (uiOri == 0 || uiOri == 4) … … 793 896 posStart = posEnd; 794 897 } 795 796 797 } 798 898 } 799 899 Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList ) 800 900 { … … 830 930 if( bValid ) 831 931 { 832 cWedgelet.findClosestAngle();833 932 racWedgeList.push_back( cWedgelet ); 834 933 TComWedgeRef cWedgeRef; … … 837 936 } 838 937 } 839 #endif //H_3D_DIM_DMM 840 938 WedgeList* getWedgeListScaled( UInt blkSize ) 939 { 940 return &g_dmmWedgeLists[ g_aucConvertToBit[( 16 >= blkSize ) ? blkSize : 16] ]; 941 } 942 WedgeNodeList* getWedgeNodeListScaled( UInt blkSize ) 943 { 944 return &g_dmmWedgeNodeLists[ g_aucConvertToBit[( 16 >= blkSize ) ? blkSize : 16] ]; 945 } 946 #endif //NH_3D_DMM 841 947 //! \}
Note: See TracChangeset for help on using the changeset viewer.