[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
[1200] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1200] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[5] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
[2] | 33 | /** \file TComRom.cpp |
---|
| 34 | \brief global variables & functions |
---|
| 35 | */ |
---|
| 36 | #include "TComRom.h" |
---|
| 37 | #include <memory.h> |
---|
| 38 | #include <stdlib.h> |
---|
| 39 | #include <stdio.h> |
---|
[1200] | 40 | #include <iomanip> |
---|
| 41 | #include <assert.h> |
---|
| 42 | #include "TComDataCU.h" |
---|
| 43 | #include "Debug.h" |
---|
[2] | 44 | // ==================================================================================================================== |
---|
| 45 | // Initialize / destroy functions |
---|
| 46 | // ==================================================================================================================== |
---|
[56] | 47 | //! \ingroup TLibCommon |
---|
| 48 | //! \{ |
---|
[1200] | 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 | }; |
---|
[2] | 159 | // initialize ROM variables |
---|
| 160 | Void initROM() |
---|
| 161 | { |
---|
| 162 | Int i, c; |
---|
| 163 | // g_aucConvertToBit[ x ]: log2(x/4), if x=4 -> 0, x=8 -> 1, x=16 -> 2, ... |
---|
| 164 | ::memset( g_aucConvertToBit, -1, sizeof( g_aucConvertToBit ) ); |
---|
| 165 | c=0; |
---|
[655] | 166 | for ( i=4; i<=MAX_CU_SIZE; i*=2 ) |
---|
[2] | 167 | { |
---|
| 168 | g_aucConvertToBit[ i ] = c; |
---|
| 169 | c++; |
---|
| 170 | } |
---|
[1200] | 171 | // initialise scan orders |
---|
| 172 | for(UInt log2BlockHeight = 0; log2BlockHeight < MAX_CU_DEPTH; log2BlockHeight++) |
---|
[2] | 173 | { |
---|
[1200] | 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 |
---|
[1066] | 223 | #if H_MV_HLS_PTL_LIMITS |
---|
| 224 | g_generalTierAndLevelLimits[ Level::LEVEL1 ] = TComGeneralTierAndLevelLimits( 36864, 350, INT_MIN, 16, 1, 1 ); |
---|
| 225 | g_generalTierAndLevelLimits[ Level::LEVEL2 ] = TComGeneralTierAndLevelLimits( 122880, 1500, INT_MIN, 16, 1, 1 ); |
---|
| 226 | g_generalTierAndLevelLimits[ Level::LEVEL2_1 ] = TComGeneralTierAndLevelLimits( 245760, 3000, INT_MIN, 20, 1, 1 ); |
---|
| 227 | g_generalTierAndLevelLimits[ Level::LEVEL3 ] = TComGeneralTierAndLevelLimits( 552960, 6000, INT_MIN, 30, 2, 2 ); |
---|
| 228 | g_generalTierAndLevelLimits[ Level::LEVEL3_1 ] = TComGeneralTierAndLevelLimits( 983040, 10000, INT_MIN, 40, 3, 3 ); |
---|
| 229 | g_generalTierAndLevelLimits[ Level::LEVEL4 ] = TComGeneralTierAndLevelLimits( 2228224, 12000, 30000, 75, 5, 5 ); |
---|
| 230 | g_generalTierAndLevelLimits[ Level::LEVEL4_1 ] = TComGeneralTierAndLevelLimits( 2228224, 20000, 50000, 75, 5, 5 ); |
---|
| 231 | g_generalTierAndLevelLimits[ Level::LEVEL5 ] = TComGeneralTierAndLevelLimits( 8912896, 25000, 100000, 200, 11, 10 ); |
---|
| 232 | g_generalTierAndLevelLimits[ Level::LEVEL5_1 ] = TComGeneralTierAndLevelLimits( 8912896, 40000, 160000, 200, 11, 10 ); |
---|
| 233 | g_generalTierAndLevelLimits[ Level::LEVEL5_2 ] = TComGeneralTierAndLevelLimits( 8912896, 60000, 240000, 200, 11, 10 ); |
---|
| 234 | g_generalTierAndLevelLimits[ Level::LEVEL6 ] = TComGeneralTierAndLevelLimits( 35651584, 60000, 240000, 600, 22, 20 ); |
---|
| 235 | g_generalTierAndLevelLimits[ Level::LEVEL6_1 ] = TComGeneralTierAndLevelLimits( 35651584, 120000, 480000, 600, 22, 20 ); |
---|
| 236 | g_generalTierAndLevelLimits[ Level::LEVEL6_2 ] = TComGeneralTierAndLevelLimits( 35651584, 240000, 800000, 600, 22, 20 ); |
---|
| 237 | #endif |
---|
| 238 | #endif |
---|
[2] | 239 | } |
---|
| 240 | Void destroyROM() |
---|
| 241 | { |
---|
[1200] | 242 | for(UInt groupTypeIndex = 0; groupTypeIndex < SCAN_NUMBER_OF_GROUP_TYPES; groupTypeIndex++) |
---|
[2] | 243 | { |
---|
[1200] | 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 | } |
---|
[2] | 254 | } |
---|
[608] | 255 | #if H_3D_DIM_DMM |
---|
| 256 | if( !g_dmmWedgeLists.empty() ) |
---|
[2] | 257 | { |
---|
[1196] | 258 | for( UInt ui = 0; ui < g_dmmWedgeLists.size(); ui++ ) |
---|
| 259 | { |
---|
| 260 | g_dmmWedgeLists[ui].clear(); |
---|
| 261 | } |
---|
[608] | 262 | g_dmmWedgeLists.clear(); |
---|
[2] | 263 | } |
---|
[608] | 264 | if( !g_dmmWedgeRefLists.empty() ) |
---|
[2] | 265 | { |
---|
[1196] | 266 | for( UInt ui = 0; ui < g_dmmWedgeRefLists.size(); ui++ ) |
---|
| 267 | { |
---|
| 268 | g_dmmWedgeRefLists[ui].clear(); |
---|
| 269 | } |
---|
[608] | 270 | g_dmmWedgeRefLists.clear(); |
---|
[2] | 271 | } |
---|
[608] | 272 | if( !g_dmmWedgeNodeLists.empty() ) |
---|
[189] | 273 | { |
---|
[1196] | 274 | for( UInt ui = 0; ui < g_dmmWedgeNodeLists.size(); ui++ ) |
---|
| 275 | { |
---|
| 276 | g_dmmWedgeNodeLists[ui].clear(); |
---|
| 277 | } |
---|
[608] | 278 | g_dmmWedgeNodeLists.clear(); |
---|
[189] | 279 | } |
---|
[2] | 280 | #endif |
---|
| 281 | } |
---|
| 282 | // ==================================================================================================================== |
---|
| 283 | // Data structure related table & variable |
---|
| 284 | // ==================================================================================================================== |
---|
[1200] | 285 | UInt g_auiZscanToRaster [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, }; |
---|
| 286 | UInt g_auiRasterToZscan [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, }; |
---|
| 287 | UInt g_auiRasterToPelX [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, }; |
---|
| 288 | UInt g_auiRasterToPelY [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, }; |
---|
| 289 | const UInt g_auiPUOffset[NUMBER_OF_PART_SIZES] = { 0, 8, 4, 4, 2, 10, 1, 5}; |
---|
[2] | 290 | Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ) |
---|
| 291 | { |
---|
| 292 | Int iStride = 1 << ( iMaxDepth - 1 ); |
---|
| 293 | if ( iDepth == iMaxDepth ) |
---|
| 294 | { |
---|
| 295 | rpuiCurrIdx[0] = uiStartVal; |
---|
| 296 | rpuiCurrIdx++; |
---|
| 297 | } |
---|
| 298 | else |
---|
| 299 | { |
---|
| 300 | Int iStep = iStride >> iDepth; |
---|
| 301 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal, rpuiCurrIdx ); |
---|
| 302 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep, rpuiCurrIdx ); |
---|
| 303 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride, rpuiCurrIdx ); |
---|
| 304 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride+iStep, rpuiCurrIdx ); |
---|
| 305 | } |
---|
| 306 | } |
---|
| 307 | Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
| 308 | { |
---|
| 309 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
| 310 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
| 311 | UInt uiNumPartInWidth = (UInt)uiMaxCUWidth / uiMinCUWidth; |
---|
| 312 | UInt uiNumPartInHeight = (UInt)uiMaxCUHeight / uiMinCUHeight; |
---|
| 313 | for ( UInt i = 0; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
| 314 | { |
---|
| 315 | g_auiRasterToZscan[ g_auiZscanToRaster[i] ] = i; |
---|
| 316 | } |
---|
| 317 | } |
---|
| 318 | Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
| 319 | { |
---|
| 320 | UInt i; |
---|
| 321 | UInt* uiTempX = &g_auiRasterToPelX[0]; |
---|
| 322 | UInt* uiTempY = &g_auiRasterToPelY[0]; |
---|
| 323 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
| 324 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
| 325 | UInt uiNumPartInWidth = uiMaxCUWidth / uiMinCUWidth; |
---|
| 326 | UInt uiNumPartInHeight = uiMaxCUHeight / uiMinCUHeight; |
---|
| 327 | uiTempX[0] = 0; uiTempX++; |
---|
| 328 | for ( i = 1; i < uiNumPartInWidth; i++ ) |
---|
| 329 | { |
---|
| 330 | uiTempX[0] = uiTempX[-1] + uiMinCUWidth; uiTempX++; |
---|
| 331 | } |
---|
| 332 | for ( i = 1; i < uiNumPartInHeight; i++ ) |
---|
| 333 | { |
---|
| 334 | memcpy(uiTempX, uiTempX-uiNumPartInWidth, sizeof(UInt)*uiNumPartInWidth); |
---|
| 335 | uiTempX += uiNumPartInWidth; |
---|
| 336 | } |
---|
| 337 | for ( i = 1; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
| 338 | { |
---|
| 339 | uiTempY[i] = ( i / uiNumPartInWidth ) * uiMinCUWidth; |
---|
| 340 | } |
---|
[1200] | 341 | } |
---|
| 342 | const Int g_quantScales[SCALING_LIST_REM_NUM] = |
---|
[2] | 343 | { |
---|
[56] | 344 | 26214,23302,20560,18396,16384,14564 |
---|
[1200] | 345 | }; |
---|
| 346 | const Int g_invQuantScales[SCALING_LIST_REM_NUM] = |
---|
[2] | 347 | { |
---|
[56] | 348 | 40,45,51,57,64,72 |
---|
[2] | 349 | }; |
---|
[1200] | 350 | //-------------------------------------------------------------------------------------------------- |
---|
| 351 | //structures |
---|
| 352 | #define DEFINE_DST4x4_MATRIX(a,b,c,d) \ |
---|
| 353 | { \ |
---|
| 354 | { a, b, c, d }, \ |
---|
| 355 | { c, c, 0, -c }, \ |
---|
| 356 | { d, -a, -c, b }, \ |
---|
| 357 | { b, -d, c, -a }, \ |
---|
| 358 | } |
---|
| 359 | #define DEFINE_DCT4x4_MATRIX(a,b,c) \ |
---|
| 360 | { \ |
---|
| 361 | { a, a, a, a}, \ |
---|
| 362 | { b, c, -c, -b}, \ |
---|
| 363 | { a, -a, -a, a}, \ |
---|
| 364 | { c, -b, b, -c} \ |
---|
| 365 | } |
---|
| 366 | #define DEFINE_DCT8x8_MATRIX(a,b,c,d,e,f,g) \ |
---|
| 367 | { \ |
---|
| 368 | { a, a, a, a, a, a, a, a}, \ |
---|
| 369 | { d, e, f, g, -g, -f, -e, -d}, \ |
---|
| 370 | { b, c, -c, -b, -b, -c, c, b}, \ |
---|
| 371 | { e, -g, -d, -f, f, d, g, -e}, \ |
---|
| 372 | { a, -a, -a, a, a, -a, -a, a}, \ |
---|
| 373 | { f, -d, g, e, -e, -g, d, -f}, \ |
---|
| 374 | { c, -b, b, -c, -c, b, -b, c}, \ |
---|
| 375 | { g, -f, e, -d, d, -e, f, -g} \ |
---|
| 376 | } |
---|
| 377 | #define DEFINE_DCT16x16_MATRIX(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) \ |
---|
| 378 | { \ |
---|
| 379 | { a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a}, \ |
---|
| 380 | { h, i, j, k, l, m, n, o, -o, -n, -m, -l, -k, -j, -i, -h}, \ |
---|
| 381 | { d, e, f, g, -g, -f, -e, -d, -d, -e, -f, -g, g, f, e, d}, \ |
---|
| 382 | { i, l, o, -m, -j, -h, -k, -n, n, k, h, j, m, -o, -l, -i}, \ |
---|
| 383 | { b, c, -c, -b, -b, -c, c, b, b, c, -c, -b, -b, -c, c, b}, \ |
---|
| 384 | { j, o, -k, -i, -n, l, h, m, -m, -h, -l, n, i, k, -o, -j}, \ |
---|
| 385 | { e, -g, -d, -f, f, d, g, -e, -e, g, d, f, -f, -d, -g, e}, \ |
---|
| 386 | { k, -m, -i, o, h, n, -j, -l, l, j, -n, -h, -o, i, m, -k}, \ |
---|
| 387 | { a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a}, \ |
---|
| 388 | { l, -j, -n, h, -o, -i, m, k, -k, -m, i, o, -h, n, j, -l}, \ |
---|
| 389 | { f, -d, g, e, -e, -g, d, -f, -f, d, -g, -e, e, g, -d, f}, \ |
---|
| 390 | { m, -h, l, n, -i, k, o, -j, j, -o, -k, i, -n, -l, h, -m}, \ |
---|
| 391 | { c, -b, b, -c, -c, b, -b, c, c, -b, b, -c, -c, b, -b, c}, \ |
---|
| 392 | { n, -k, h, -j, m, o, -l, i, -i, l, -o, -m, j, -h, k, -n}, \ |
---|
| 393 | { g, -f, e, -d, d, -e, f, -g, -g, f, -e, d, -d, e, -f, g}, \ |
---|
| 394 | { o, -n, m, -l, k, -j, i, -h, h, -i, j, -k, l, -m, n, -o} \ |
---|
| 395 | } |
---|
| 396 | #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) \ |
---|
| 397 | { \ |
---|
| 398 | { 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}, \ |
---|
| 399 | { 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}, \ |
---|
| 400 | { 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}, \ |
---|
| 401 | { 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}, \ |
---|
| 402 | { 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}, \ |
---|
| 403 | { 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}, \ |
---|
| 404 | { 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}, \ |
---|
| 405 | { 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}, \ |
---|
| 406 | { 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}, \ |
---|
| 407 | { 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}, \ |
---|
| 408 | { 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}, \ |
---|
| 409 | { 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}, \ |
---|
| 410 | { 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}, \ |
---|
| 411 | { 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}, \ |
---|
| 412 | { 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}, \ |
---|
| 413 | { 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}, \ |
---|
| 414 | { 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}, \ |
---|
| 415 | { 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}, \ |
---|
| 416 | { 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}, \ |
---|
| 417 | { 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}, \ |
---|
| 418 | { 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}, \ |
---|
| 419 | { 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}, \ |
---|
| 420 | { 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}, \ |
---|
| 421 | { 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}, \ |
---|
| 422 | { 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}, \ |
---|
| 423 | { 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}, \ |
---|
| 424 | { 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}, \ |
---|
| 425 | { 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}, \ |
---|
| 426 | { 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}, \ |
---|
| 427 | { 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}, \ |
---|
| 428 | { 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}, \ |
---|
| 429 | { 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} \ |
---|
| 430 | } |
---|
| 431 | //-------------------------------------------------------------------------------------------------- |
---|
| 432 | //coefficients |
---|
| 433 | #if RExt__HIGH_PRECISION_FORWARD_TRANSFORM |
---|
| 434 | const TMatrixCoeff g_aiT4 [TRANSFORM_NUMBER_OF_DIRECTIONS][4][4] = |
---|
[2] | 435 | { |
---|
[1200] | 436 | DEFINE_DCT4x4_MATRIX (16384, 21266, 9224), |
---|
| 437 | DEFINE_DCT4x4_MATRIX ( 64, 83, 36) |
---|
[2] | 438 | }; |
---|
[1200] | 439 | const TMatrixCoeff g_aiT8 [TRANSFORM_NUMBER_OF_DIRECTIONS][8][8] = |
---|
[2] | 440 | { |
---|
[1200] | 441 | DEFINE_DCT8x8_MATRIX (16384, 21266, 9224, 22813, 19244, 12769, 4563), |
---|
| 442 | DEFINE_DCT8x8_MATRIX ( 64, 83, 36, 89, 75, 50, 18) |
---|
[2] | 443 | }; |
---|
[1200] | 444 | const TMatrixCoeff g_aiT16[TRANSFORM_NUMBER_OF_DIRECTIONS][16][16] = |
---|
[2] | 445 | { |
---|
[1200] | 446 | DEFINE_DCT16x16_MATRIX(16384, 21266, 9224, 22813, 19244, 12769, 4563, 23120, 22063, 20450, 17972, 14642, 11109, 6446, 2316), |
---|
| 447 | DEFINE_DCT16x16_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9) |
---|
[2] | 448 | }; |
---|
[1200] | 449 | const TMatrixCoeff g_aiT32[TRANSFORM_NUMBER_OF_DIRECTIONS][32][32] = |
---|
[2] | 450 | { |
---|
[1200] | 451 | 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), |
---|
| 452 | 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) |
---|
[2] | 453 | }; |
---|
[1200] | 454 | const TMatrixCoeff g_as_DST_MAT_4[TRANSFORM_NUMBER_OF_DIRECTIONS][4][4] = |
---|
[2] | 455 | { |
---|
[1200] | 456 | DEFINE_DST4x4_MATRIX( 7424, 14081, 18893, 21505), |
---|
| 457 | DEFINE_DST4x4_MATRIX( 29, 55, 74, 84) |
---|
[2] | 458 | }; |
---|
[1200] | 459 | #else |
---|
| 460 | const TMatrixCoeff g_aiT4 [TRANSFORM_NUMBER_OF_DIRECTIONS][4][4] = |
---|
[2] | 461 | { |
---|
[1200] | 462 | DEFINE_DCT4x4_MATRIX ( 64, 83, 36), |
---|
| 463 | DEFINE_DCT4x4_MATRIX ( 64, 83, 36) |
---|
[2] | 464 | }; |
---|
[1200] | 465 | const TMatrixCoeff g_aiT8 [TRANSFORM_NUMBER_OF_DIRECTIONS][8][8] = |
---|
| 466 | { |
---|
| 467 | DEFINE_DCT8x8_MATRIX ( 64, 83, 36, 89, 75, 50, 18), |
---|
| 468 | DEFINE_DCT8x8_MATRIX ( 64, 83, 36, 89, 75, 50, 18) |
---|
| 469 | }; |
---|
| 470 | const TMatrixCoeff g_aiT16[TRANSFORM_NUMBER_OF_DIRECTIONS][16][16] = |
---|
| 471 | { |
---|
| 472 | DEFINE_DCT16x16_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9), |
---|
| 473 | DEFINE_DCT16x16_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9) |
---|
| 474 | }; |
---|
| 475 | const TMatrixCoeff g_aiT32[TRANSFORM_NUMBER_OF_DIRECTIONS][32][32] = |
---|
| 476 | { |
---|
| 477 | 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), |
---|
| 478 | 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) |
---|
| 479 | }; |
---|
| 480 | const TMatrixCoeff g_as_DST_MAT_4[TRANSFORM_NUMBER_OF_DIRECTIONS][4][4] = |
---|
| 481 | { |
---|
| 482 | DEFINE_DST4x4_MATRIX( 29, 55, 74, 84), |
---|
| 483 | DEFINE_DST4x4_MATRIX( 29, 55, 74, 84) |
---|
| 484 | }; |
---|
| 485 | #endif |
---|
| 486 | //-------------------------------------------------------------------------------------------------- |
---|
| 487 | #undef DEFINE_DST4x4_MATRIX |
---|
| 488 | #undef DEFINE_DCT4x4_MATRIX |
---|
| 489 | #undef DEFINE_DCT8x8_MATRIX |
---|
| 490 | #undef DEFINE_DCT16x16_MATRIX |
---|
| 491 | #undef DEFINE_DCT32x32_MATRIX |
---|
| 492 | //-------------------------------------------------------------------------------------------------- |
---|
| 493 | const UChar g_aucChromaScale[NUM_CHROMA_FORMAT][chromaQPMappingTableSize]= |
---|
| 494 | { |
---|
| 495 | //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 |
---|
| 496 | { 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 }, |
---|
| 497 | { 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 }, |
---|
| 498 | { 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 }, |
---|
| 499 | { 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 } |
---|
| 500 | }; |
---|
[2] | 501 | // ==================================================================================================================== |
---|
[1200] | 502 | // Intra prediction |
---|
[2] | 503 | // ==================================================================================================================== |
---|
[1200] | 504 | const UChar g_aucIntraModeNumFast_UseMPM[MAX_CU_DEPTH] = |
---|
[2] | 505 | { |
---|
| 506 | 3, // 2x2 |
---|
| 507 | 8, // 4x4 |
---|
| 508 | 8, // 8x8 |
---|
[1200] | 509 | 3, // 16x16 |
---|
| 510 | 3, // 32x32 |
---|
| 511 | 3 // 64x64 |
---|
[2] | 512 | }; |
---|
[1200] | 513 | const UChar g_aucIntraModeNumFast_NotUseMPM[MAX_CU_DEPTH] = |
---|
[2] | 514 | { |
---|
| 515 | 3, // 2x2 |
---|
| 516 | 9, // 4x4 |
---|
| 517 | 9, // 8x8 |
---|
| 518 | 4, // 16x16 33 |
---|
| 519 | 4, // 32x32 33 |
---|
[655] | 520 | 5 // 64x64 33 |
---|
[2] | 521 | }; |
---|
[1200] | 522 | const UChar g_chroma422IntraAngleMappingTable[NUM_INTRA_MODE] = |
---|
| 523 | //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 |
---|
| 524 | { 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}; |
---|
[872] | 525 | #if H_3D_DIM_DMM |
---|
[56] | 526 | // ==================================================================================================================== |
---|
[608] | 527 | // Depth coding modes |
---|
[56] | 528 | // ==================================================================================================================== |
---|
[608] | 529 | const WedgeResolution g_dmmWedgeResolution[6] = |
---|
[2] | 530 | { |
---|
[608] | 531 | HALF_PEL, // 4x4 |
---|
| 532 | HALF_PEL, // 8x8 |
---|
| 533 | FULL_PEL, // 16x16 |
---|
[1039] | 534 | FULL_PEL, // 32x32 |
---|
| 535 | FULL_PEL, // 64x64 |
---|
| 536 | FULL_PEL // 128x128 |
---|
[2] | 537 | }; |
---|
[608] | 538 | const UChar g_dmm1TabIdxBits[6] = |
---|
| 539 | { //2x2 4x4 8x8 16x16 32x32 64x64 |
---|
[1124] | 540 | 0, 7, 10, 9, 9, 13 }; |
---|
[608] | 541 | const UChar g_dmm3IntraTabIdxBits[6] = |
---|
| 542 | { //2x2 4x4 8x8 16x16 32x32 64x64 |
---|
| 543 | 0, 4, 7, 8, 8, 0 }; |
---|
[1039] | 544 | Bool g_wedgePattern[32*32]; |
---|
[608] | 545 | extern std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; |
---|
| 546 | extern std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; |
---|
| 547 | extern std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; |
---|
[2] | 548 | #endif |
---|
| 549 | // ==================================================================================================================== |
---|
[56] | 550 | // Misc. |
---|
[2] | 551 | // ==================================================================================================================== |
---|
| 552 | Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; |
---|
| 553 | #if ENC_DEC_TRACE |
---|
[1200] | 554 | FILE* g_hTrace = NULL; // Set to NULL to open up a file. Set to stdout to use the current output |
---|
[2] | 555 | const Bool g_bEncDecTraceEnable = true; |
---|
| 556 | const Bool g_bEncDecTraceDisable = false; |
---|
[1200] | 557 | Bool g_HLSTraceEnable = false; |
---|
[2] | 558 | Bool g_bJustDoIt = false; |
---|
| 559 | UInt64 g_nSymbolCounter = 0; |
---|
[608] | 560 | #if H_MV_ENC_DEC_TRAC |
---|
[1066] | 561 | Bool g_traceCU = false; |
---|
| 562 | Bool g_tracePU = false; |
---|
| 563 | Bool g_traceTU = false; |
---|
[1179] | 564 | Bool g_disableNumbering = false; |
---|
[608] | 565 | Bool g_disableHLSTrace = false; |
---|
[1179] | 566 | UInt64 g_stopAtCounter = 937234; |
---|
[622] | 567 | Bool g_traceCopyBack = false; |
---|
| 568 | Bool g_decTraceDispDer = false; |
---|
| 569 | Bool g_decTraceMvFromMerge = false; |
---|
[964] | 570 | Bool g_decTracePicOutput = false; |
---|
[1200] | 571 | Bool g_stopAtPos = false; |
---|
| 572 | Bool g_outputPos = false; |
---|
[1179] | 573 | Bool g_traceCameraParameters = false; |
---|
[1200] | 574 | Bool g_encNumberOfWrittenBits = false; |
---|
[2] | 575 | #endif |
---|
[608] | 576 | #endif |
---|
[2] | 577 | // ==================================================================================================================== |
---|
| 578 | // Scanning order & context model mapping |
---|
| 579 | // ==================================================================================================================== |
---|
| 580 | // scanning order table |
---|
[1200] | 581 | UInt* g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][ MAX_CU_DEPTH ][ MAX_CU_DEPTH ]; |
---|
| 582 | const UInt ctxIndMap4x4[4*4] = |
---|
[2] | 583 | { |
---|
[1200] | 584 | 0, 1, 4, 5, |
---|
| 585 | 2, 3, 4, 5, |
---|
| 586 | 6, 6, 8, 8, |
---|
| 587 | 7, 7, 8, 8 |
---|
[2] | 588 | }; |
---|
[1200] | 589 | const UInt g_uiMinInGroup[ LAST_SIGNIFICANT_GROUPS ] = {0,1,2,3,4,6,8,12,16,24}; |
---|
| 590 | 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}; |
---|
| 591 | const Char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] = |
---|
[56] | 592 | { |
---|
| 593 | { |
---|
[1200] | 594 | "INTRA4X4_LUMA", |
---|
| 595 | "INTRA4X4_CHROMAU", |
---|
| 596 | "INTRA4X4_CHROMAV", |
---|
| 597 | "INTER4X4_LUMA", |
---|
| 598 | "INTER4X4_CHROMAU", |
---|
| 599 | "INTER4X4_CHROMAV" |
---|
| 600 | }, |
---|
[56] | 601 | { |
---|
[1200] | 602 | "INTRA8X8_LUMA", |
---|
| 603 | "INTRA8X8_CHROMAU", |
---|
| 604 | "INTRA8X8_CHROMAV", |
---|
| 605 | "INTER8X8_LUMA", |
---|
| 606 | "INTER8X8_CHROMAU", |
---|
| 607 | "INTER8X8_CHROMAV" |
---|
| 608 | }, |
---|
[56] | 609 | { |
---|
[1200] | 610 | "INTRA16X16_LUMA", |
---|
| 611 | "INTRA16X16_CHROMAU", |
---|
| 612 | "INTRA16X16_CHROMAV", |
---|
| 613 | "INTER16X16_LUMA", |
---|
| 614 | "INTER16X16_CHROMAU", |
---|
| 615 | "INTER16X16_CHROMAV" |
---|
| 616 | }, |
---|
[56] | 617 | { |
---|
[1200] | 618 | "INTRA32X32_LUMA", |
---|
| 619 | "INTRA32X32_CHROMAU_FROM16x16_CHROMAU", |
---|
| 620 | "INTRA32X32_CHROMAV_FROM16x16_CHROMAV", |
---|
| 621 | "INTER32X32_LUMA", |
---|
| 622 | "INTER32X32_CHROMAU_FROM16x16_CHROMAU", |
---|
| 623 | "INTER32X32_CHROMAV_FROM16x16_CHROMAV" |
---|
| 624 | }, |
---|
| 625 | }; |
---|
| 626 | const Char *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] = |
---|
| 627 | { |
---|
[608] | 628 | { |
---|
[1200] | 629 | }, |
---|
[608] | 630 | { |
---|
[1200] | 631 | }, |
---|
[2] | 632 | { |
---|
[1200] | 633 | "INTRA16X16_LUMA_DC", |
---|
| 634 | "INTRA16X16_CHROMAU_DC", |
---|
| 635 | "INTRA16X16_CHROMAV_DC", |
---|
| 636 | "INTER16X16_LUMA_DC", |
---|
| 637 | "INTER16X16_CHROMAU_DC", |
---|
| 638 | "INTER16X16_CHROMAV_DC" |
---|
| 639 | }, |
---|
[56] | 640 | { |
---|
[1200] | 641 | "INTRA32X32_LUMA_DC", |
---|
| 642 | "INTRA32X32_CHROMAU_DC_FROM16x16_CHROMAU", |
---|
| 643 | "INTRA32X32_CHROMAV_DC_FROM16x16_CHROMAV", |
---|
| 644 | "INTER32X32_LUMA_DC", |
---|
| 645 | "INTER32X32_CHROMAU_DC_FROM16x16_CHROMAU", |
---|
| 646 | "INTER32X32_CHROMAV_DC_FROM16x16_CHROMAV" |
---|
| 647 | }, |
---|
| 648 | }; |
---|
| 649 | const Int g_quantTSDefault4x4[4*4] = |
---|
[2] | 650 | { |
---|
[608] | 651 | 16,16,16,16, |
---|
| 652 | 16,16,16,16, |
---|
| 653 | 16,16,16,16, |
---|
| 654 | 16,16,16,16 |
---|
[2] | 655 | }; |
---|
[1200] | 656 | const Int g_quantIntraDefault8x8[8*8] = |
---|
[56] | 657 | { |
---|
| 658 | 16,16,16,16,17,18,21,24, |
---|
| 659 | 16,16,16,16,17,19,22,25, |
---|
| 660 | 16,16,17,18,20,22,25,29, |
---|
| 661 | 16,16,18,21,24,27,31,36, |
---|
| 662 | 17,17,20,24,30,35,41,47, |
---|
| 663 | 18,19,22,27,35,44,54,65, |
---|
| 664 | 21,22,25,31,41,54,70,88, |
---|
| 665 | 24,25,29,36,47,65,88,115 |
---|
| 666 | }; |
---|
[1200] | 667 | const Int g_quantInterDefault8x8[8*8] = |
---|
[56] | 668 | { |
---|
| 669 | 16,16,16,16,17,18,20,24, |
---|
| 670 | 16,16,16,17,18,20,24,25, |
---|
| 671 | 16,16,17,18,20,24,25,28, |
---|
| 672 | 16,17,18,20,24,25,28,33, |
---|
| 673 | 17,18,20,24,25,28,33,41, |
---|
| 674 | 18,20,24,25,28,33,41,54, |
---|
| 675 | 20,24,25,28,33,41,54,71, |
---|
| 676 | 24,25,28,33,41,54,71,91 |
---|
| 677 | }; |
---|
[1200] | 678 | const UInt g_scalingListSize [SCALING_LIST_SIZE_NUM] = {16,64,256,1024}; |
---|
| 679 | const UInt g_scalingListSizeX [SCALING_LIST_SIZE_NUM] = { 4, 8, 16, 32}; |
---|
[608] | 680 | #if H_MV_ENC_DEC_TRAC |
---|
| 681 | #if ENC_DEC_TRACE |
---|
[1200] | 682 | Void tracePSHeader( const Char* psName, Int layerId ) |
---|
| 683 | { |
---|
| 684 | if ( !g_disableHLSTrace ) |
---|
| 685 | { |
---|
| 686 | fprintf( g_hTrace, "=========== "); |
---|
| 687 | fprintf( g_hTrace, "%s", psName ); |
---|
| 688 | fprintf( g_hTrace, " Layer %d ===========", layerId ); |
---|
| 689 | fprintf( g_hTrace, "\n" ); |
---|
| 690 | fflush ( g_hTrace ); |
---|
| 691 | } |
---|
| 692 | } |
---|
[872] | 693 | Void stopAtPos( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight ) |
---|
| 694 | { |
---|
| 695 | if ( g_outputPos ) |
---|
| 696 | { |
---|
| 697 | std::cout << "POC\t" << poc |
---|
| 698 | << "\tLayerId\t" << layerId |
---|
| 699 | << "\tCuPelX\t" << cuPelX |
---|
| 700 | << "\tCuPelY\t" << cuPelY |
---|
| 701 | << "\tCuWidth\t" << cuWidth |
---|
| 702 | << "\tCuHeight\t" << cuHeight |
---|
| 703 | << std::endl; |
---|
| 704 | } |
---|
| 705 | Bool stopFlag = false; |
---|
[1179] | 706 | if ( g_stopAtPos && poc == 0 && layerId == 2 ) |
---|
[872] | 707 | { |
---|
| 708 | Bool stopAtCU = true; |
---|
| 709 | if ( stopAtCU ) // Stop at CU with specific size |
---|
| 710 | { |
---|
[1179] | 711 | stopFlag = ( cuPelX == 0 ) && ( cuPelY == 0 ) && ( cuWidth == 8 ) && ( cuHeight == 8 ); |
---|
[872] | 712 | } |
---|
| 713 | else |
---|
| 714 | { // Stop at specific position |
---|
| 715 | Int xPos = 888; |
---|
| 716 | Int yPos = 248; |
---|
| 717 | Int cuPelXEnd = cuPelX + cuWidth - 1; |
---|
| 718 | Int cuPelYEnd = cuPelY + cuHeight - 1; |
---|
| 719 | stopFlag = (cuPelX <= xPos ) && (cuPelXEnd >= xPos ) && (cuPelY <= yPos ) && (cuPelYEnd >= yPos ); |
---|
| 720 | } |
---|
| 721 | } |
---|
| 722 | if ( stopFlag ) |
---|
| 723 | { // Set breakpoint here. |
---|
| 724 | std::cout << "Stop position. Break point here." << std::endl; |
---|
| 725 | } |
---|
| 726 | } |
---|
[738] | 727 | Void writeToTraceFile( const Char* symbolName, Int val, Bool doIt ) |
---|
[608] | 728 | { |
---|
| 729 | if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt ) |
---|
| 730 | { |
---|
| 731 | if ( g_stopAtCounter == g_nSymbolCounter ) |
---|
| 732 | { |
---|
| 733 | std::cout << "Break point here." << std::endl; |
---|
| 734 | } |
---|
[1179] | 735 | if ( !g_disableNumbering ) |
---|
| 736 | { |
---|
| 737 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
| 738 | } |
---|
[608] | 739 | fprintf( g_hTrace, "%-50s : %d\n", symbolName, val ); |
---|
| 740 | fflush ( g_hTrace ); |
---|
| 741 | g_nSymbolCounter++; |
---|
| 742 | } |
---|
| 743 | } |
---|
[738] | 744 | Void writeToTraceFile( const Char* symbolName, Bool doIt ) |
---|
[608] | 745 | { |
---|
| 746 | if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt ) |
---|
| 747 | { |
---|
| 748 | fprintf( g_hTrace, "%s", symbolName ); |
---|
| 749 | fflush ( g_hTrace ); |
---|
| 750 | g_nSymbolCounter++; |
---|
| 751 | } |
---|
| 752 | } |
---|
| 753 | #endif |
---|
| 754 | #endif |
---|
| 755 | #if H_3D_DIM_DMM |
---|
| 756 | std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; |
---|
| 757 | std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; |
---|
| 758 | std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; |
---|
[622] | 759 | Void initWedgeLists( Bool initNodeList ) |
---|
[2] | 760 | { |
---|
[608] | 761 | if( !g_dmmWedgeLists.empty() ) return; |
---|
[1039] | 762 | for( UInt ui = g_aucConvertToBit[DIM_MIN_SIZE]; ui < (g_aucConvertToBit[DIM_MAX_SIZE]); ui++ ) |
---|
[2] | 763 | { |
---|
[608] | 764 | UInt uiWedgeBlockSize = ((UInt)DIM_MIN_SIZE)<<ui; |
---|
[2] | 765 | std::vector<TComWedgelet> acWedgeList; |
---|
| 766 | std::vector<TComWedgeRef> acWedgeRefList; |
---|
[608] | 767 | createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_dmmWedgeResolution[ui] ); |
---|
| 768 | g_dmmWedgeLists.push_back( acWedgeList ); |
---|
| 769 | g_dmmWedgeRefLists.push_back( acWedgeRefList ); |
---|
[622] | 770 | if( initNodeList ) |
---|
| 771 | { |
---|
[655] | 772 | // create WedgeNodeList |
---|
| 773 | std::vector<TComWedgeNode> acWedgeNodeList; |
---|
| 774 | for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ ) |
---|
[189] | 775 | { |
---|
[655] | 776 | if( acWedgeList[uiPos].getIsCoarse() ) |
---|
| 777 | { |
---|
| 778 | TComWedgeNode cWedgeNode; |
---|
| 779 | cWedgeNode.setPatternIdx( uiPos ); |
---|
[608] | 780 | UInt uiRefPos = 0; |
---|
| 781 | for( Int iOffS = -1; iOffS <= 1; iOffS++ ) |
---|
[189] | 782 | { |
---|
[608] | 783 | for( Int iOffE = -1; iOffE <= 1; iOffE++ ) |
---|
| 784 | { |
---|
| 785 | if( iOffS == 0 && iOffE == 0 ) { continue; } |
---|
| 786 | Int iSx = (Int)acWedgeList[uiPos].getStartX(); |
---|
| 787 | Int iSy = (Int)acWedgeList[uiPos].getStartY(); |
---|
| 788 | Int iEx = (Int)acWedgeList[uiPos].getEndX(); |
---|
| 789 | Int iEy = (Int)acWedgeList[uiPos].getEndY(); |
---|
| 790 | switch( acWedgeList[uiPos].getOri() ) |
---|
| 791 | { |
---|
| 792 | case( 0 ): { iSx += iOffS; iEy += iOffE; } break; |
---|
| 793 | case( 1 ): { iSy += iOffS; iEx -= iOffE; } break; |
---|
| 794 | case( 2 ): { iSx -= iOffS; iEy -= iOffE; } break; |
---|
| 795 | case( 3 ): { iSy -= iOffS; iEx += iOffE; } break; |
---|
| 796 | case( 4 ): { iSx += iOffS; iEx += iOffE; } break; |
---|
| 797 | case( 5 ): { iSy += iOffS; iEy += iOffE; } break; |
---|
| 798 | default: assert( 0 ); |
---|
| 799 | } |
---|
| 800 | for( UInt k = 0; k < acWedgeRefList.size(); k++ ) |
---|
[189] | 801 | { |
---|
[608] | 802 | if( iSx == (Int)acWedgeRefList[k].getStartX() && |
---|
[655] | 803 | iSy == (Int)acWedgeRefList[k].getStartY() && |
---|
| 804 | iEx == (Int)acWedgeRefList[k].getEndX() && |
---|
| 805 | iEy == (Int)acWedgeRefList[k].getEndY() ) |
---|
[189] | 806 | { |
---|
[608] | 807 | if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() ) |
---|
| 808 | { |
---|
| 809 | Bool bNew = true; |
---|
| 810 | for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } } |
---|
| 811 | if( bNew ) |
---|
| 812 | { |
---|
| 813 | cWedgeNode.setRefineIdx( acWedgeRefList[k].getRefIdx(), uiRefPos ); |
---|
| 814 | uiRefPos++; |
---|
| 815 | break; |
---|
| 816 | } |
---|
[189] | 817 | } |
---|
| 818 | } |
---|
| 819 | } |
---|
| 820 | } |
---|
| 821 | } |
---|
[655] | 822 | acWedgeNodeList.push_back( cWedgeNode ); |
---|
[189] | 823 | } |
---|
| 824 | } |
---|
[655] | 825 | g_dmmWedgeNodeLists.push_back( acWedgeNodeList ); |
---|
[189] | 826 | } |
---|
[2] | 827 | } |
---|
| 828 | } |
---|
| 829 | Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes ) |
---|
| 830 | { |
---|
| 831 | assert( uiWidth == uiHeight ); |
---|
[1179] | 832 | Int posStart = 0, posEnd = 0; |
---|
[2] | 833 | UInt uiBlockSize = 0; |
---|
| 834 | switch( eWedgeRes ) |
---|
| 835 | { |
---|
| 836 | case( FULL_PEL ): { uiBlockSize = uiWidth; break; } |
---|
| 837 | case( HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; } |
---|
| 838 | } |
---|
| 839 | TComWedgelet cTempWedgelet( uiWidth, uiHeight ); |
---|
| 840 | for( UInt uiOri = 0; uiOri < 6; uiOri++ ) |
---|
| 841 | { |
---|
[1179] | 842 | posEnd = (Int) racWedgeList.size(); |
---|
| 843 | if (uiOri == 0 || uiOri == 4) |
---|
| 844 | { |
---|
[1124] | 845 | for( Int iK = 0; iK < uiBlockSize; iK += (uiWidth>=16 ?2:1)) |
---|
| 846 | { |
---|
| 847 | for( Int iL = 0; iL < uiBlockSize; iL += ((uiWidth>=16 && uiOri<4)?2:1) ) |
---|
| 848 | { |
---|
[1179] | 849 | Int xS = iK; |
---|
| 850 | Int yS = 0; |
---|
| 851 | Int xE = (uiOri == 0) ? 0 : iL; |
---|
| 852 | Int yE = (uiOri == 0) ? iL : uiBlockSize - 1; |
---|
| 853 | cTempWedgelet.setWedgelet( xS, yS, xE, yE, uiOri, eWedgeRes, ((iL%2)==0 && (iK%2)==0) ); |
---|
[1124] | 854 | addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList ); |
---|
| 855 | } |
---|
| 856 | } |
---|
[1179] | 857 | } |
---|
| 858 | else |
---|
| 859 | { |
---|
| 860 | for (Int pos = posStart; pos < posEnd; pos++) |
---|
| 861 | { |
---|
| 862 | cTempWedgelet.generateWedgePatternByRotate(racWedgeList[pos], uiOri); |
---|
| 863 | addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList ); |
---|
| 864 | } |
---|
| 865 | } |
---|
| 866 | posStart = posEnd; |
---|
[56] | 867 | } |
---|
| 868 | } |
---|
| 869 | Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList ) |
---|
| 870 | { |
---|
| 871 | Bool bValid = cWedgelet.checkNotPlain(); |
---|
| 872 | if( bValid ) |
---|
| 873 | { |
---|
| 874 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
| 875 | { |
---|
| 876 | if( cWedgelet.checkIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
| 877 | { |
---|
| 878 | TComWedgeRef cWedgeRef; |
---|
| 879 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
| 880 | racWedgeRefList.push_back( cWedgeRef ); |
---|
| 881 | bValid = false; |
---|
| 882 | return; |
---|
[2] | 883 | } |
---|
| 884 | } |
---|
| 885 | } |
---|
[56] | 886 | if( bValid ) |
---|
| 887 | { |
---|
| 888 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
| 889 | { |
---|
| 890 | if( cWedgelet.checkInvIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
| 891 | { |
---|
| 892 | TComWedgeRef cWedgeRef; |
---|
| 893 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
| 894 | racWedgeRefList.push_back( cWedgeRef ); |
---|
| 895 | bValid = false; |
---|
| 896 | return; |
---|
| 897 | } |
---|
| 898 | } |
---|
| 899 | } |
---|
| 900 | if( bValid ) |
---|
| 901 | { |
---|
[608] | 902 | cWedgelet.findClosestAngle(); |
---|
[56] | 903 | racWedgeList.push_back( cWedgelet ); |
---|
| 904 | TComWedgeRef cWedgeRef; |
---|
| 905 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), (UInt)(racWedgeList.size()-1) ); |
---|
| 906 | racWedgeRefList.push_back( cWedgeRef ); |
---|
| 907 | } |
---|
[2] | 908 | } |
---|
[608] | 909 | #endif //H_3D_DIM_DMM |
---|
[56] | 910 | //! \} |
---|