[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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[608] | 6 | * Copyright (c) 2010-2013, 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 | |
---|
| 34 | /** \file TComRom.cpp |
---|
| 35 | \brief global variables & functions |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TComRom.h" |
---|
| 39 | #include <memory.h> |
---|
| 40 | #include <stdlib.h> |
---|
| 41 | #include <stdio.h> |
---|
| 42 | // ==================================================================================================================== |
---|
| 43 | // Initialize / destroy functions |
---|
| 44 | // ==================================================================================================================== |
---|
| 45 | |
---|
[56] | 46 | //! \ingroup TLibCommon |
---|
| 47 | //! \{ |
---|
| 48 | |
---|
[2] | 49 | // initialize ROM variables |
---|
| 50 | Void initROM() |
---|
| 51 | { |
---|
| 52 | Int i, c; |
---|
| 53 | |
---|
| 54 | // g_aucConvertToBit[ x ]: log2(x/4), if x=4 -> 0, x=8 -> 1, x=16 -> 2, ... |
---|
| 55 | ::memset( g_aucConvertToBit, -1, sizeof( g_aucConvertToBit ) ); |
---|
| 56 | c=0; |
---|
| 57 | for ( i=4; i<MAX_CU_SIZE; i*=2 ) |
---|
| 58 | { |
---|
| 59 | g_aucConvertToBit[ i ] = c; |
---|
| 60 | c++; |
---|
| 61 | } |
---|
| 62 | g_aucConvertToBit[ i ] = c; |
---|
| 63 | |
---|
| 64 | c=2; |
---|
| 65 | for ( i=0; i<MAX_CU_DEPTH; i++ ) |
---|
| 66 | { |
---|
| 67 | g_auiSigLastScan[0][i] = new UInt[ c*c ]; |
---|
| 68 | g_auiSigLastScan[1][i] = new UInt[ c*c ]; |
---|
| 69 | g_auiSigLastScan[2][i] = new UInt[ c*c ]; |
---|
[608] | 70 | initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], c, c); |
---|
[2] | 71 | |
---|
| 72 | c <<= 1; |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | Void destroyROM() |
---|
| 77 | { |
---|
[608] | 78 | for (Int i=0; i<MAX_CU_DEPTH; i++ ) |
---|
[2] | 79 | { |
---|
| 80 | delete[] g_auiSigLastScan[0][i]; |
---|
| 81 | delete[] g_auiSigLastScan[1][i]; |
---|
| 82 | delete[] g_auiSigLastScan[2][i]; |
---|
| 83 | } |
---|
| 84 | |
---|
[608] | 85 | #if H_3D_DIM_DMM |
---|
| 86 | if( !g_dmmWedgeLists.empty() ) |
---|
[2] | 87 | { |
---|
[608] | 88 | for( UInt ui = 0; ui < g_dmmWedgeLists.size(); ui++ ) { g_dmmWedgeLists[ui].clear(); } |
---|
| 89 | g_dmmWedgeLists.clear(); |
---|
[2] | 90 | } |
---|
[608] | 91 | if( !g_dmmWedgeRefLists.empty() ) |
---|
[2] | 92 | { |
---|
[608] | 93 | for( UInt ui = 0; ui < g_dmmWedgeRefLists.size(); ui++ ) { g_dmmWedgeRefLists[ui].clear(); } |
---|
| 94 | g_dmmWedgeRefLists.clear(); |
---|
[2] | 95 | } |
---|
[296] | 96 | |
---|
[608] | 97 | if( !g_dmmWedgeNodeLists.empty() ) |
---|
[189] | 98 | { |
---|
[608] | 99 | for( UInt ui = 0; ui < g_dmmWedgeNodeLists.size(); ui++ ) { g_dmmWedgeNodeLists[ui].clear(); } |
---|
| 100 | g_dmmWedgeNodeLists.clear(); |
---|
[189] | 101 | } |
---|
[2] | 102 | #endif |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | // ==================================================================================================================== |
---|
| 106 | // Data structure related table & variable |
---|
| 107 | // ==================================================================================================================== |
---|
| 108 | |
---|
| 109 | UInt g_uiMaxCUWidth = MAX_CU_SIZE; |
---|
| 110 | UInt g_uiMaxCUHeight = MAX_CU_SIZE; |
---|
| 111 | UInt g_uiMaxCUDepth = MAX_CU_DEPTH; |
---|
| 112 | UInt g_uiAddCUDepth = 0; |
---|
| 113 | UInt g_auiZscanToRaster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 114 | UInt g_auiRasterToZscan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 115 | UInt g_auiRasterToPelX [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 116 | UInt g_auiRasterToPelY [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 117 | |
---|
[56] | 118 | UInt g_auiPUOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5}; |
---|
[2] | 119 | |
---|
| 120 | Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ) |
---|
| 121 | { |
---|
| 122 | Int iStride = 1 << ( iMaxDepth - 1 ); |
---|
| 123 | |
---|
| 124 | if ( iDepth == iMaxDepth ) |
---|
| 125 | { |
---|
| 126 | rpuiCurrIdx[0] = uiStartVal; |
---|
| 127 | rpuiCurrIdx++; |
---|
| 128 | } |
---|
| 129 | else |
---|
| 130 | { |
---|
| 131 | Int iStep = iStride >> iDepth; |
---|
| 132 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal, rpuiCurrIdx ); |
---|
| 133 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep, rpuiCurrIdx ); |
---|
| 134 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride, rpuiCurrIdx ); |
---|
| 135 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride+iStep, rpuiCurrIdx ); |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
| 140 | { |
---|
| 141 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
| 142 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
| 143 | |
---|
| 144 | UInt uiNumPartInWidth = (UInt)uiMaxCUWidth / uiMinCUWidth; |
---|
| 145 | UInt uiNumPartInHeight = (UInt)uiMaxCUHeight / uiMinCUHeight; |
---|
| 146 | |
---|
| 147 | for ( UInt i = 0; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
| 148 | { |
---|
| 149 | g_auiRasterToZscan[ g_auiZscanToRaster[i] ] = i; |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
| 154 | { |
---|
| 155 | UInt i; |
---|
| 156 | |
---|
| 157 | UInt* uiTempX = &g_auiRasterToPelX[0]; |
---|
| 158 | UInt* uiTempY = &g_auiRasterToPelY[0]; |
---|
| 159 | |
---|
| 160 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
| 161 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
| 162 | |
---|
| 163 | UInt uiNumPartInWidth = uiMaxCUWidth / uiMinCUWidth; |
---|
| 164 | UInt uiNumPartInHeight = uiMaxCUHeight / uiMinCUHeight; |
---|
| 165 | |
---|
| 166 | uiTempX[0] = 0; uiTempX++; |
---|
| 167 | for ( i = 1; i < uiNumPartInWidth; i++ ) |
---|
| 168 | { |
---|
| 169 | uiTempX[0] = uiTempX[-1] + uiMinCUWidth; uiTempX++; |
---|
| 170 | } |
---|
| 171 | for ( i = 1; i < uiNumPartInHeight; i++ ) |
---|
| 172 | { |
---|
| 173 | memcpy(uiTempX, uiTempX-uiNumPartInWidth, sizeof(UInt)*uiNumPartInWidth); |
---|
| 174 | uiTempX += uiNumPartInWidth; |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | for ( i = 1; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
| 178 | { |
---|
| 179 | uiTempY[i] = ( i / uiNumPartInWidth ) * uiMinCUWidth; |
---|
| 180 | } |
---|
| 181 | }; |
---|
| 182 | |
---|
| 183 | |
---|
[56] | 184 | Int g_quantScales[6] = |
---|
[2] | 185 | { |
---|
[56] | 186 | 26214,23302,20560,18396,16384,14564 |
---|
| 187 | }; |
---|
[2] | 188 | |
---|
[56] | 189 | Int g_invQuantScales[6] = |
---|
[2] | 190 | { |
---|
[56] | 191 | 40,45,51,57,64,72 |
---|
[2] | 192 | }; |
---|
| 193 | |
---|
[608] | 194 | const Short g_aiT4[4][4] = |
---|
[2] | 195 | { |
---|
[56] | 196 | { 64, 64, 64, 64}, |
---|
| 197 | { 83, 36,-36,-83}, |
---|
| 198 | { 64,-64,-64, 64}, |
---|
| 199 | { 36,-83, 83,-36} |
---|
[2] | 200 | }; |
---|
| 201 | |
---|
[608] | 202 | const Short g_aiT8[8][8] = |
---|
[2] | 203 | { |
---|
[56] | 204 | { 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
| 205 | { 89, 75, 50, 18,-18,-50,-75,-89}, |
---|
| 206 | { 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
| 207 | { 75,-18,-89,-50, 50, 89, 18,-75}, |
---|
| 208 | { 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
| 209 | { 50,-89, 18, 75,-75,-18, 89,-50}, |
---|
| 210 | { 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
| 211 | { 18,-50, 75,-89, 89,-75, 50,-18} |
---|
[2] | 212 | }; |
---|
| 213 | |
---|
[608] | 214 | const Short g_aiT16[16][16] = |
---|
[2] | 215 | { |
---|
[56] | 216 | { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
| 217 | { 90, 87, 80, 70, 57, 43, 25, 9, -9,-25,-43,-57,-70,-80,-87,-90}, |
---|
| 218 | { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89}, |
---|
| 219 | { 87, 57, 9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87}, |
---|
| 220 | { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
| 221 | { 80, 9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80}, |
---|
| 222 | { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75}, |
---|
| 223 | { 70,-43,-87, 9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70}, |
---|
| 224 | { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
| 225 | { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87, 9,-90, 25, 80,-57}, |
---|
| 226 | { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50}, |
---|
| 227 | { 43,-90, 57, 25,-87, 70, 9,-80, 80, -9,-70, 87,-25,-57, 90,-43}, |
---|
| 228 | { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
| 229 | { 25,-70, 90,-80, 43, 9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25}, |
---|
| 230 | { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18}, |
---|
| 231 | { 9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9} |
---|
[2] | 232 | }; |
---|
| 233 | |
---|
[608] | 234 | const Short g_aiT32[32][32] = |
---|
[2] | 235 | { |
---|
[56] | 236 | { 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}, |
---|
| 237 | { 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}, |
---|
| 238 | { 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}, |
---|
| 239 | { 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}, |
---|
| 240 | { 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}, |
---|
| 241 | { 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}, |
---|
| 242 | { 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}, |
---|
| 243 | { 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}, |
---|
| 244 | { 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}, |
---|
| 245 | { 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}, |
---|
| 246 | { 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}, |
---|
| 247 | { 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}, |
---|
| 248 | { 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}, |
---|
| 249 | { 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}, |
---|
| 250 | { 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}, |
---|
| 251 | { 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}, |
---|
| 252 | { 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}, |
---|
| 253 | { 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}, |
---|
| 254 | { 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}, |
---|
| 255 | { 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}, |
---|
| 256 | { 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}, |
---|
| 257 | { 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}, |
---|
| 258 | { 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}, |
---|
| 259 | { 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}, |
---|
| 260 | { 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}, |
---|
| 261 | { 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}, |
---|
| 262 | { 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}, |
---|
| 263 | { 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}, |
---|
| 264 | { 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}, |
---|
| 265 | { 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}, |
---|
| 266 | { 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}, |
---|
| 267 | { 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} |
---|
[2] | 268 | }; |
---|
| 269 | |
---|
[608] | 270 | const UChar g_aucChromaScale[58]= |
---|
[2] | 271 | { |
---|
[608] | 272 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, |
---|
| 273 | 17,18,19,20,21,22,23,24,25,26,27,28,29,29,30,31,32, |
---|
| 274 | 33,33,34,34,35,35,36,36,37,37,38,39,40,41,42,43,44, |
---|
| 275 | 45,46,47,48,49,50,51 |
---|
[2] | 276 | }; |
---|
| 277 | |
---|
| 278 | |
---|
| 279 | // Mode-Dependent DCT/DST |
---|
[608] | 280 | const Short g_as_DST_MAT_4 [4][4]= |
---|
[2] | 281 | { |
---|
| 282 | {29, 55, 74, 84}, |
---|
| 283 | {74, 74, 0 , -74}, |
---|
| 284 | {84, -29, -74, 55}, |
---|
| 285 | {55, -84, 74, -29}, |
---|
| 286 | }; |
---|
[56] | 287 | |
---|
| 288 | |
---|
[2] | 289 | // ==================================================================================================================== |
---|
| 290 | // ADI |
---|
| 291 | // ==================================================================================================================== |
---|
| 292 | |
---|
| 293 | #if FAST_UDI_USE_MPM |
---|
| 294 | const UChar g_aucIntraModeNumFast[7] = |
---|
| 295 | { |
---|
| 296 | 3, // 2x2 |
---|
| 297 | 8, // 4x4 |
---|
| 298 | 8, // 8x8 |
---|
| 299 | 3, // 16x16 |
---|
| 300 | 3, // 32x32 |
---|
| 301 | 3, // 64x64 |
---|
| 302 | 3 // 128x128 |
---|
| 303 | }; |
---|
| 304 | #else // FAST_UDI_USE_MPM |
---|
| 305 | const UChar g_aucIntraModeNumFast[7] = |
---|
| 306 | { |
---|
| 307 | 3, // 2x2 |
---|
| 308 | 9, // 4x4 |
---|
| 309 | 9, // 8x8 |
---|
| 310 | 4, // 16x16 33 |
---|
| 311 | 4, // 32x32 33 |
---|
| 312 | 5, // 64x64 33 |
---|
| 313 | 4 // 128x128 33 |
---|
| 314 | }; |
---|
| 315 | #endif // FAST_UDI_USE_MPM |
---|
| 316 | |
---|
| 317 | // chroma |
---|
| 318 | |
---|
| 319 | const UChar g_aucConvertTxtTypeToIdx[4] = { 0, 1, 1, 2 }; |
---|
| 320 | |
---|
| 321 | |
---|
[56] | 322 | // ==================================================================================================================== |
---|
| 323 | // Bit-depth |
---|
| 324 | // ==================================================================================================================== |
---|
[2] | 325 | |
---|
[608] | 326 | Int g_bitDepthY = 8; |
---|
| 327 | Int g_bitDepthC = 8; |
---|
[56] | 328 | |
---|
| 329 | UInt g_uiPCMBitDepthLuma = 8; // PCM bit-depth |
---|
| 330 | UInt g_uiPCMBitDepthChroma = 8; // PCM bit-depth |
---|
| 331 | |
---|
| 332 | // ==================================================================================================================== |
---|
[608] | 333 | // Depth coding modes |
---|
[56] | 334 | // ==================================================================================================================== |
---|
[608] | 335 | #if H_3D_DIM_DMM |
---|
| 336 | const WedgeResolution g_dmmWedgeResolution[6] = |
---|
[2] | 337 | { |
---|
[608] | 338 | HALF_PEL, // 4x4 |
---|
| 339 | HALF_PEL, // 8x8 |
---|
| 340 | FULL_PEL, // 16x16 |
---|
| 341 | DOUBLE_PEL, // 32x32 |
---|
| 342 | DOUBLE_PEL, // 64x64 |
---|
| 343 | DOUBLE_PEL // 128x128 |
---|
[2] | 344 | }; |
---|
| 345 | |
---|
[608] | 346 | const UChar g_dmm1TabIdxBits[6] = |
---|
| 347 | { //2x2 4x4 8x8 16x16 32x32 64x64 |
---|
| 348 | 0, 7, 10, 11, 11, 13 }; |
---|
[622] | 349 | #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX |
---|
[608] | 350 | const UChar g_dmm3IntraTabIdxBits[6] = |
---|
| 351 | { //2x2 4x4 8x8 16x16 32x32 64x64 |
---|
| 352 | 0, 4, 7, 8, 8, 0 }; |
---|
| 353 | #else |
---|
| 354 | const UChar g_dmm3IntraTabIdxBits[6] = |
---|
| 355 | { //2x2 4x4 8x8 16x16 32x32 64x64 |
---|
| 356 | 0, 6, 9, 9, 9, 0 }; |
---|
[296] | 357 | #endif |
---|
| 358 | |
---|
[608] | 359 | extern std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; |
---|
| 360 | extern std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; |
---|
| 361 | extern std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; |
---|
[2] | 362 | #endif |
---|
| 363 | |
---|
| 364 | // ==================================================================================================================== |
---|
[56] | 365 | // Misc. |
---|
[2] | 366 | // ==================================================================================================================== |
---|
| 367 | |
---|
| 368 | Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; |
---|
| 369 | |
---|
| 370 | #if ENC_DEC_TRACE |
---|
| 371 | FILE* g_hTrace = NULL; |
---|
| 372 | const Bool g_bEncDecTraceEnable = true; |
---|
| 373 | const Bool g_bEncDecTraceDisable = false; |
---|
[608] | 374 | Bool g_HLSTraceEnable = true; |
---|
[2] | 375 | Bool g_bJustDoIt = false; |
---|
| 376 | UInt64 g_nSymbolCounter = 0; |
---|
[608] | 377 | #if H_MV_ENC_DEC_TRAC |
---|
| 378 | Bool g_traceCU = true; |
---|
| 379 | Bool g_tracePU = true; |
---|
| 380 | Bool g_traceTU = true; |
---|
| 381 | Bool g_disableHLSTrace = false; |
---|
[622] | 382 | UInt64 g_stopAtCounter = 48; |
---|
| 383 | Bool g_traceCopyBack = false; |
---|
| 384 | Bool g_decTraceDispDer = false; |
---|
| 385 | Bool g_decTraceMvFromMerge = false; |
---|
[2] | 386 | #endif |
---|
[608] | 387 | #endif |
---|
[2] | 388 | // ==================================================================================================================== |
---|
| 389 | // Scanning order & context model mapping |
---|
| 390 | // ==================================================================================================================== |
---|
| 391 | |
---|
| 392 | // scanning order table |
---|
[608] | 393 | UInt* g_auiSigLastScan[ 3 ][ MAX_CU_DEPTH ]; |
---|
[2] | 394 | |
---|
[608] | 395 | const UInt g_sigLastScan8x8[ 3 ][ 4 ] = |
---|
[2] | 396 | { |
---|
[608] | 397 | {0, 2, 1, 3}, |
---|
[56] | 398 | {0, 1, 2, 3}, |
---|
| 399 | {0, 2, 1, 3} |
---|
[2] | 400 | }; |
---|
[56] | 401 | UInt g_sigLastScanCG32x32[ 64 ]; |
---|
[2] | 402 | |
---|
[56] | 403 | const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24}; |
---|
| 404 | 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}; |
---|
[2] | 405 | |
---|
[56] | 406 | // Rice parameters for absolute transform levels |
---|
| 407 | const UInt g_auiGoRiceRange[5] = |
---|
| 408 | { |
---|
| 409 | 7, 14, 26, 46, 78 |
---|
| 410 | }; |
---|
[2] | 411 | |
---|
[56] | 412 | const UInt g_auiGoRicePrefixLen[5] = |
---|
| 413 | { |
---|
| 414 | 8, 7, 6, 5, 4 |
---|
| 415 | }; |
---|
[2] | 416 | |
---|
[608] | 417 | Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight) |
---|
[56] | 418 | { |
---|
| 419 | const UInt uiNumScanPos = UInt( iWidth * iWidth ); |
---|
| 420 | UInt uiNextScanPos = 0; |
---|
| 421 | |
---|
| 422 | if( iWidth < 16 ) |
---|
| 423 | { |
---|
| 424 | UInt* pBuffTemp = pBuffD; |
---|
| 425 | if( iWidth == 8 ) |
---|
| 426 | { |
---|
| 427 | pBuffTemp = g_sigLastScanCG32x32; |
---|
[2] | 428 | } |
---|
[56] | 429 | for( UInt uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ ) |
---|
| 430 | { |
---|
[608] | 431 | Int iPrimDim = Int( uiScanLine ); |
---|
| 432 | Int iScndDim = 0; |
---|
[56] | 433 | while( iPrimDim >= iWidth ) |
---|
| 434 | { |
---|
| 435 | iScndDim++; |
---|
| 436 | iPrimDim--; |
---|
| 437 | } |
---|
| 438 | while( iPrimDim >= 0 && iScndDim < iWidth ) |
---|
| 439 | { |
---|
| 440 | pBuffTemp[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ; |
---|
| 441 | uiNextScanPos++; |
---|
| 442 | iScndDim++; |
---|
| 443 | iPrimDim--; |
---|
| 444 | } |
---|
| 445 | } |
---|
| 446 | } |
---|
| 447 | if( iWidth > 4 ) |
---|
| 448 | { |
---|
| 449 | UInt uiNumBlkSide = iWidth >> 2; |
---|
| 450 | UInt uiNumBlks = uiNumBlkSide * uiNumBlkSide; |
---|
| 451 | UInt log2Blk = g_aucConvertToBit[ uiNumBlkSide ] + 1; |
---|
| 452 | |
---|
| 453 | for( UInt uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ ) |
---|
| 454 | { |
---|
| 455 | uiNextScanPos = 0; |
---|
| 456 | UInt initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ]; |
---|
| 457 | if( iWidth == 32 ) |
---|
| 458 | { |
---|
| 459 | initBlkPos = g_sigLastScanCG32x32[ uiBlk ]; |
---|
| 460 | } |
---|
| 461 | UInt offsetY = initBlkPos / uiNumBlkSide; |
---|
| 462 | UInt offsetX = initBlkPos - offsetY * uiNumBlkSide; |
---|
| 463 | UInt offsetD = 4 * ( offsetX + offsetY * iWidth ); |
---|
| 464 | UInt offsetScan = 16 * uiBlk; |
---|
| 465 | for( UInt uiScanLine = 0; uiNextScanPos < 16; uiScanLine++ ) |
---|
| 466 | { |
---|
[608] | 467 | Int iPrimDim = Int( uiScanLine ); |
---|
| 468 | Int iScndDim = 0; |
---|
[56] | 469 | while( iPrimDim >= 4 ) |
---|
| 470 | { |
---|
| 471 | iScndDim++; |
---|
| 472 | iPrimDim--; |
---|
| 473 | } |
---|
| 474 | while( iPrimDim >= 0 && iScndDim < 4 ) |
---|
| 475 | { |
---|
| 476 | pBuffD[ uiNextScanPos + offsetScan ] = iPrimDim * iWidth + iScndDim + offsetD; |
---|
| 477 | uiNextScanPos++; |
---|
| 478 | iScndDim++; |
---|
| 479 | iPrimDim--; |
---|
| 480 | } |
---|
| 481 | } |
---|
| 482 | } |
---|
| 483 | } |
---|
[2] | 484 | |
---|
[608] | 485 | UInt uiCnt = 0; |
---|
| 486 | if( iWidth > 2 ) |
---|
| 487 | { |
---|
| 488 | UInt numBlkSide = iWidth >> 2; |
---|
| 489 | for(Int blkY=0; blkY < numBlkSide; blkY++) |
---|
| 490 | { |
---|
| 491 | for(Int blkX=0; blkX < numBlkSide; blkX++) |
---|
| 492 | { |
---|
| 493 | UInt offset = blkY * 4 * iWidth + blkX * 4; |
---|
| 494 | for(Int y=0; y < 4; y++) |
---|
| 495 | { |
---|
| 496 | for(Int x=0; x < 4; x++) |
---|
| 497 | { |
---|
| 498 | pBuffH[uiCnt] = y*iWidth + x + offset; |
---|
| 499 | uiCnt ++; |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | } |
---|
| 503 | } |
---|
[56] | 504 | |
---|
[608] | 505 | uiCnt = 0; |
---|
| 506 | for(Int blkX=0; blkX < numBlkSide; blkX++) |
---|
| 507 | { |
---|
| 508 | for(Int blkY=0; blkY < numBlkSide; blkY++) |
---|
| 509 | { |
---|
| 510 | UInt offset = blkY * 4 * iWidth + blkX * 4; |
---|
| 511 | for(Int x=0; x < 4; x++) |
---|
| 512 | { |
---|
| 513 | for(Int y=0; y < 4; y++) |
---|
| 514 | { |
---|
| 515 | pBuffV[uiCnt] = y*iWidth + x + offset; |
---|
| 516 | uiCnt ++; |
---|
| 517 | } |
---|
| 518 | } |
---|
| 519 | } |
---|
| 520 | } |
---|
| 521 | } |
---|
| 522 | else |
---|
| 523 | { |
---|
[56] | 524 | for(Int iY=0; iY < iHeight; iY++) |
---|
[2] | 525 | { |
---|
[56] | 526 | for(Int iX=0; iX < iWidth; iX++) |
---|
[2] | 527 | { |
---|
[56] | 528 | pBuffH[uiCnt] = iY*iWidth + iX; |
---|
| 529 | uiCnt ++; |
---|
[2] | 530 | } |
---|
| 531 | } |
---|
[56] | 532 | |
---|
| 533 | uiCnt = 0; |
---|
| 534 | for(Int iX=0; iX < iWidth; iX++) |
---|
| 535 | { |
---|
| 536 | for(Int iY=0; iY < iHeight; iY++) |
---|
| 537 | { |
---|
| 538 | pBuffV[uiCnt] = iY*iWidth + iX; |
---|
| 539 | uiCnt ++; |
---|
| 540 | } |
---|
| 541 | } |
---|
| 542 | } |
---|
[2] | 543 | } |
---|
| 544 | |
---|
[608] | 545 | Int g_quantTSDefault4x4[16] = |
---|
[2] | 546 | { |
---|
[608] | 547 | 16,16,16,16, |
---|
| 548 | 16,16,16,16, |
---|
| 549 | 16,16,16,16, |
---|
| 550 | 16,16,16,16 |
---|
[2] | 551 | }; |
---|
[56] | 552 | |
---|
| 553 | Int g_quantIntraDefault8x8[64] = |
---|
| 554 | { |
---|
| 555 | 16,16,16,16,17,18,21,24, |
---|
| 556 | 16,16,16,16,17,19,22,25, |
---|
| 557 | 16,16,17,18,20,22,25,29, |
---|
| 558 | 16,16,18,21,24,27,31,36, |
---|
| 559 | 17,17,20,24,30,35,41,47, |
---|
| 560 | 18,19,22,27,35,44,54,65, |
---|
| 561 | 21,22,25,31,41,54,70,88, |
---|
| 562 | 24,25,29,36,47,65,88,115 |
---|
| 563 | }; |
---|
| 564 | |
---|
| 565 | Int g_quantInterDefault8x8[64] = |
---|
| 566 | { |
---|
| 567 | 16,16,16,16,17,18,20,24, |
---|
| 568 | 16,16,16,17,18,20,24,25, |
---|
| 569 | 16,16,17,18,20,24,25,28, |
---|
| 570 | 16,17,18,20,24,25,28,33, |
---|
| 571 | 17,18,20,24,25,28,33,41, |
---|
| 572 | 18,20,24,25,28,33,41,54, |
---|
| 573 | 20,24,25,28,33,41,54,71, |
---|
| 574 | 24,25,28,33,41,54,71,91 |
---|
| 575 | }; |
---|
| 576 | UInt g_scalingListSize [4] = {16,64,256,1024}; |
---|
| 577 | UInt g_scalingListSizeX [4] = { 4, 8, 16, 32}; |
---|
| 578 | UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2}; |
---|
| 579 | Int g_eTTable[4] = {0,3,1,2}; |
---|
[2] | 580 | |
---|
[608] | 581 | #if H_MV_ENC_DEC_TRAC |
---|
| 582 | #if ENC_DEC_TRACE |
---|
| 583 | Void writeToTraceFile( Char* symbolName, Int val, Bool doIt ) |
---|
| 584 | { |
---|
| 585 | if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt ) |
---|
| 586 | { |
---|
| 587 | if ( g_stopAtCounter == g_nSymbolCounter ) |
---|
| 588 | { |
---|
| 589 | std::cout << "Break point here." << std::endl; |
---|
| 590 | } |
---|
| 591 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
| 592 | fprintf( g_hTrace, "%-50s : %d\n", symbolName, val ); |
---|
| 593 | fflush ( g_hTrace ); |
---|
| 594 | g_nSymbolCounter++; |
---|
| 595 | } |
---|
| 596 | } |
---|
[2] | 597 | |
---|
[608] | 598 | Void writeToTraceFile( Char* symbolName, Bool doIt ) |
---|
| 599 | { |
---|
| 600 | if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt ) |
---|
| 601 | { |
---|
| 602 | fprintf( g_hTrace, "%s", symbolName ); |
---|
| 603 | fflush ( g_hTrace ); |
---|
| 604 | g_nSymbolCounter++; |
---|
| 605 | } |
---|
| 606 | } |
---|
| 607 | |
---|
| 608 | #endif |
---|
| 609 | #endif |
---|
| 610 | #if H_3D_DIM_DMM |
---|
| 611 | std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; |
---|
| 612 | std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; |
---|
| 613 | std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; |
---|
[189] | 614 | std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3; |
---|
| 615 | |
---|
[622] | 616 | #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX |
---|
| 617 | Void initWedgeLists( Bool initNodeList ) |
---|
| 618 | #else |
---|
[608] | 619 | Void initWedgeLists( Bool initRefinements ) |
---|
[622] | 620 | #endif |
---|
[2] | 621 | { |
---|
[608] | 622 | if( !g_dmmWedgeLists.empty() ) return; |
---|
| 623 | |
---|
| 624 | for( UInt ui = g_aucConvertToBit[DIM_MIN_SIZE]; ui < (g_aucConvertToBit[DIM_MAX_SIZE]+1); ui++ ) |
---|
[2] | 625 | { |
---|
[608] | 626 | UInt uiWedgeBlockSize = ((UInt)DIM_MIN_SIZE)<<ui; |
---|
[2] | 627 | std::vector<TComWedgelet> acWedgeList; |
---|
| 628 | std::vector<TComWedgeRef> acWedgeRefList; |
---|
[608] | 629 | createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_dmmWedgeResolution[ui] ); |
---|
| 630 | g_dmmWedgeLists.push_back( acWedgeList ); |
---|
| 631 | g_dmmWedgeRefLists.push_back( acWedgeRefList ); |
---|
[189] | 632 | |
---|
[622] | 633 | #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX |
---|
| 634 | if( initNodeList ) |
---|
| 635 | { |
---|
| 636 | #endif |
---|
[189] | 637 | // create WedgeNodeList |
---|
| 638 | std::vector<TComWedgeNode> acWedgeNodeList; |
---|
| 639 | for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ ) |
---|
| 640 | { |
---|
| 641 | if( acWedgeList[uiPos].getIsCoarse() ) |
---|
| 642 | { |
---|
| 643 | TComWedgeNode cWedgeNode; |
---|
| 644 | cWedgeNode.setPatternIdx( uiPos ); |
---|
| 645 | |
---|
[622] | 646 | #if !LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX |
---|
[608] | 647 | if( initRefinements ) |
---|
[189] | 648 | { |
---|
[622] | 649 | #endif |
---|
[608] | 650 | UInt uiRefPos = 0; |
---|
| 651 | for( Int iOffS = -1; iOffS <= 1; iOffS++ ) |
---|
[189] | 652 | { |
---|
[608] | 653 | for( Int iOffE = -1; iOffE <= 1; iOffE++ ) |
---|
| 654 | { |
---|
| 655 | if( iOffS == 0 && iOffE == 0 ) { continue; } |
---|
[189] | 656 | |
---|
[608] | 657 | Int iSx = (Int)acWedgeList[uiPos].getStartX(); |
---|
| 658 | Int iSy = (Int)acWedgeList[uiPos].getStartY(); |
---|
| 659 | Int iEx = (Int)acWedgeList[uiPos].getEndX(); |
---|
| 660 | Int iEy = (Int)acWedgeList[uiPos].getEndY(); |
---|
[189] | 661 | |
---|
[608] | 662 | switch( acWedgeList[uiPos].getOri() ) |
---|
| 663 | { |
---|
| 664 | case( 0 ): { iSx += iOffS; iEy += iOffE; } break; |
---|
| 665 | case( 1 ): { iSy += iOffS; iEx -= iOffE; } break; |
---|
| 666 | case( 2 ): { iSx -= iOffS; iEy -= iOffE; } break; |
---|
| 667 | case( 3 ): { iSy -= iOffS; iEx += iOffE; } break; |
---|
| 668 | case( 4 ): { iSx += iOffS; iEx += iOffE; } break; |
---|
| 669 | case( 5 ): { iSy += iOffS; iEy += iOffE; } break; |
---|
| 670 | default: assert( 0 ); |
---|
| 671 | } |
---|
[189] | 672 | |
---|
[608] | 673 | for( UInt k = 0; k < acWedgeRefList.size(); k++ ) |
---|
[189] | 674 | { |
---|
[608] | 675 | if( iSx == (Int)acWedgeRefList[k].getStartX() && |
---|
| 676 | iSy == (Int)acWedgeRefList[k].getStartY() && |
---|
| 677 | iEx == (Int)acWedgeRefList[k].getEndX() && |
---|
| 678 | iEy == (Int)acWedgeRefList[k].getEndY() ) |
---|
[189] | 679 | { |
---|
[608] | 680 | if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() ) |
---|
| 681 | { |
---|
| 682 | Bool bNew = true; |
---|
| 683 | for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } } |
---|
[189] | 684 | |
---|
[608] | 685 | if( bNew ) |
---|
| 686 | { |
---|
| 687 | cWedgeNode.setRefineIdx( acWedgeRefList[k].getRefIdx(), uiRefPos ); |
---|
| 688 | uiRefPos++; |
---|
| 689 | break; |
---|
| 690 | } |
---|
[189] | 691 | } |
---|
| 692 | } |
---|
| 693 | } |
---|
| 694 | } |
---|
| 695 | } |
---|
[622] | 696 | #if !LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX |
---|
[189] | 697 | } |
---|
[622] | 698 | #endif |
---|
[189] | 699 | acWedgeNodeList.push_back( cWedgeNode ); |
---|
| 700 | } |
---|
| 701 | } |
---|
[608] | 702 | g_dmmWedgeNodeLists.push_back( acWedgeNodeList ); |
---|
[622] | 703 | #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX |
---|
[2] | 704 | } |
---|
[622] | 705 | #endif |
---|
| 706 | } |
---|
[2] | 707 | return; |
---|
| 708 | } |
---|
| 709 | |
---|
| 710 | Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes ) |
---|
| 711 | { |
---|
| 712 | assert( uiWidth == uiHeight ); |
---|
| 713 | |
---|
[77] | 714 | UChar uhStartX = 0, uhStartY = 0, uhEndX = 0, uhEndY = 0; |
---|
| 715 | Int iStepStartX = 0, iStepStartY = 0, iStepEndX = 0, iStepEndY = 0; |
---|
[56] | 716 | |
---|
[2] | 717 | UInt uiBlockSize = 0; |
---|
| 718 | switch( eWedgeRes ) |
---|
| 719 | { |
---|
| 720 | case( DOUBLE_PEL ): { uiBlockSize = (uiWidth>>1); break; } |
---|
| 721 | case( FULL_PEL ): { uiBlockSize = uiWidth; break; } |
---|
| 722 | case( HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; } |
---|
| 723 | } |
---|
| 724 | |
---|
| 725 | TComWedgelet cTempWedgelet( uiWidth, uiHeight ); |
---|
| 726 | for( UInt uiOri = 0; uiOri < 6; uiOri++ ) |
---|
| 727 | { |
---|
| 728 | // init the edge line parameters for each of the 6 wedgelet types |
---|
| 729 | switch( uiOri ) |
---|
| 730 | { |
---|
| 731 | case( 0 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = +1; iStepStartY = 0; iStepEndX = 0; iStepEndY = +1; break; } |
---|
| 732 | case( 1 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = (uiBlockSize-1); uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = -1; iStepEndY = 0; break; } |
---|
| 733 | case( 2 ): { uhStartX = (uiBlockSize-1); uhStartY = (uiBlockSize-1); uhEndX = (uiBlockSize-1); uhEndY = (uiBlockSize-1); iStepStartX = -1; iStepStartY = 0; iStepEndX = 0; iStepEndY = -1; break; } |
---|
| 734 | case( 3 ): { uhStartX = 0; uhStartY = (uiBlockSize-1); uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = 0; iStepStartY = -1; iStepEndX = +1; iStepEndY = 0; break; } |
---|
| 735 | case( 4 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = +1; iStepStartY = 0; iStepEndX = +1; iStepEndY = 0; break; } |
---|
| 736 | case( 5 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = 0; iStepEndY = +1; break; } |
---|
| 737 | } |
---|
| 738 | |
---|
| 739 | for( Int iK = 0; iK < uiBlockSize; iK++ ) |
---|
| 740 | { |
---|
| 741 | for( Int iL = 0; iL < uiBlockSize; iL++ ) |
---|
[56] | 742 | { |
---|
[189] | 743 | cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes, ((iL%2)==0 && (iK%2)==0) ); |
---|
[56] | 744 | addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList ); |
---|
| 745 | } |
---|
| 746 | } |
---|
| 747 | } |
---|
[608] | 748 | |
---|
[189] | 749 | UInt uiThrSz = DMM3_SIMPLIFY_TR; |
---|
| 750 | std::vector< std::vector<UInt> > auiWdgListSz; |
---|
| 751 | for( Int idxM=2; idxM<=34 ; idxM++) |
---|
| 752 | { |
---|
| 753 | std::vector<UInt> auiWdgList; |
---|
| 754 | for( Int idxW=0; idxW<racWedgeList.size(); idxW++) |
---|
| 755 | { |
---|
| 756 | UInt uiAbsDiff = abs(idxM-(Int)racWedgeList[idxW].getAng()); |
---|
| 757 | if( uiAbsDiff <= uiThrSz ) |
---|
| 758 | { |
---|
| 759 | auiWdgList.push_back(idxW); |
---|
| 760 | } |
---|
| 761 | } |
---|
| 762 | auiWdgListSz.push_back(auiWdgList); |
---|
| 763 | } |
---|
| 764 | g_aauiWdgLstM3.push_back(auiWdgListSz); |
---|
[56] | 765 | } |
---|
[2] | 766 | |
---|
[56] | 767 | Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList ) |
---|
| 768 | { |
---|
| 769 | Bool bValid = cWedgelet.checkNotPlain(); |
---|
| 770 | if( bValid ) |
---|
| 771 | { |
---|
| 772 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
| 773 | { |
---|
| 774 | if( cWedgelet.checkIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
| 775 | { |
---|
| 776 | TComWedgeRef cWedgeRef; |
---|
| 777 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
| 778 | racWedgeRefList.push_back( cWedgeRef ); |
---|
| 779 | bValid = false; |
---|
| 780 | return; |
---|
[2] | 781 | } |
---|
| 782 | } |
---|
| 783 | } |
---|
[56] | 784 | if( bValid ) |
---|
| 785 | { |
---|
| 786 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
| 787 | { |
---|
| 788 | if( cWedgelet.checkInvIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
| 789 | { |
---|
| 790 | TComWedgeRef cWedgeRef; |
---|
| 791 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
| 792 | racWedgeRefList.push_back( cWedgeRef ); |
---|
| 793 | bValid = false; |
---|
| 794 | return; |
---|
| 795 | } |
---|
| 796 | } |
---|
| 797 | } |
---|
| 798 | if( bValid ) |
---|
| 799 | { |
---|
[608] | 800 | cWedgelet.findClosestAngle(); |
---|
[56] | 801 | racWedgeList.push_back( cWedgelet ); |
---|
| 802 | TComWedgeRef cWedgeRef; |
---|
| 803 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), (UInt)(racWedgeList.size()-1) ); |
---|
| 804 | racWedgeRefList.push_back( cWedgeRef ); |
---|
| 805 | } |
---|
[2] | 806 | } |
---|
[608] | 807 | #endif //H_3D_DIM_DMM |
---|
[56] | 808 | |
---|
| 809 | //! \} |
---|