[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 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, 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 | // g_auiFrameScanXY[ g_aucConvertToBit[ transformSize ] ]: zigzag scan array for transformSize |
---|
| 65 | c=2; |
---|
| 66 | for ( i=0; i<MAX_CU_DEPTH; i++ ) |
---|
| 67 | { |
---|
| 68 | g_auiFrameScanXY[ i ] = new UInt[ c*c ]; |
---|
| 69 | g_auiFrameScanX [ i ] = new UInt[ c*c ]; |
---|
| 70 | g_auiFrameScanY [ i ] = new UInt[ c*c ]; |
---|
| 71 | initFrameScanXY( g_auiFrameScanXY[i], g_auiFrameScanX[i], g_auiFrameScanY[i], c, c ); |
---|
| 72 | g_auiSigLastScan[0][i] = new UInt[ c*c ]; |
---|
| 73 | g_auiSigLastScan[1][i] = new UInt[ c*c ]; |
---|
| 74 | g_auiSigLastScan[2][i] = new UInt[ c*c ]; |
---|
[56] | 75 | g_auiSigLastScan[3][i] = new UInt[ c*c ]; |
---|
| 76 | initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], g_auiSigLastScan[3][i], c, c, i); |
---|
[2] | 77 | |
---|
| 78 | c <<= 1; |
---|
| 79 | } |
---|
[56] | 80 | |
---|
| 81 | g_sigScanNSQT[0] = new UInt[ 64 ]; // 4x16 |
---|
| 82 | g_sigScanNSQT[1] = new UInt[ 256 ]; // 8x32 |
---|
| 83 | g_sigScanNSQT[2] = new UInt[ 64 ]; // 16x4 |
---|
| 84 | g_sigScanNSQT[3] = new UInt[ 256 ]; // 32x8 |
---|
| 85 | |
---|
| 86 | static int diagScanX[ 16 ] = |
---|
| 87 | { |
---|
| 88 | 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 3, 2, 3, 3 |
---|
| 89 | }; |
---|
| 90 | static int diagScanY[ 16 ] = |
---|
| 91 | { |
---|
| 92 | 0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 3, 2, 3 |
---|
| 93 | }; |
---|
| 94 | |
---|
| 95 | Int j; |
---|
| 96 | // 4x16 scan |
---|
| 97 | for (i = 0; i < 4; i++) |
---|
| 98 | { |
---|
| 99 | for (j = 0; j < 16; j++) |
---|
| 100 | { |
---|
| 101 | g_sigScanNSQT[ 0 ][ 16 * i + j ] = 16 * i + 4 * diagScanY[ j ] + diagScanX[ j ]; |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | // 8x32 scan |
---|
| 106 | for (i = 0; i < 16; i++) |
---|
| 107 | { |
---|
| 108 | Int x = g_sigCGScanNSQT[ 1 ][ i ] & 1; |
---|
| 109 | Int y = g_sigCGScanNSQT[ 1 ][ i ] >> 1; |
---|
| 110 | |
---|
| 111 | for (j = 0; j < 16; j++) |
---|
| 112 | { |
---|
| 113 | g_sigScanNSQT[ 1 ][ 16 * i + j ] = 32 * y + 4 * x + 8 * diagScanY[ j ] + diagScanX[ j ]; |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | // 16x4 scan |
---|
| 118 | for (i = 0; i < 4; i++) |
---|
| 119 | { |
---|
| 120 | for (j = 0; j < 16; j++) |
---|
| 121 | { |
---|
| 122 | g_sigScanNSQT[ 2 ][ 16 * i + j ] = 4 * i + 16 * diagScanY[ j ] + diagScanX[ j ]; |
---|
| 123 | } |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | // 32x8 scan |
---|
| 127 | for (i = 0; i < 16; i++) |
---|
| 128 | { |
---|
| 129 | Int x = g_sigCGScanNSQT[ 3 ][ i ] & 7; |
---|
| 130 | Int y = g_sigCGScanNSQT[ 3 ][ i ] >> 3; |
---|
| 131 | |
---|
| 132 | for (j = 0; j < 16; j++) |
---|
| 133 | { |
---|
| 134 | g_sigScanNSQT[ 3 ][ 16 * i + j ] = 128 * y + 4 * x + 32 * diagScanY[ j ] + diagScanX[ j ]; |
---|
| 135 | } |
---|
| 136 | } |
---|
[2] | 137 | } |
---|
| 138 | |
---|
| 139 | Void destroyROM() |
---|
| 140 | { |
---|
| 141 | Int i; |
---|
| 142 | |
---|
| 143 | for ( i=0; i<MAX_CU_DEPTH; i++ ) |
---|
| 144 | { |
---|
| 145 | delete[] g_auiFrameScanXY[i]; |
---|
| 146 | delete[] g_auiFrameScanX [i]; |
---|
| 147 | delete[] g_auiFrameScanY [i]; |
---|
| 148 | delete[] g_auiSigLastScan[0][i]; |
---|
| 149 | delete[] g_auiSigLastScan[1][i]; |
---|
| 150 | delete[] g_auiSigLastScan[2][i]; |
---|
[56] | 151 | delete[] g_auiSigLastScan[3][i]; |
---|
[2] | 152 | } |
---|
[56] | 153 | for (i = 0; i < 4; i++) |
---|
| 154 | { |
---|
| 155 | delete[] g_sigScanNSQT[ i ]; |
---|
| 156 | } |
---|
[2] | 157 | |
---|
[5] | 158 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[2] | 159 | if ( !g_aacWedgeLists.empty() ) |
---|
| 160 | { |
---|
| 161 | for ( UInt ui = 0; ui < g_aacWedgeLists.size(); ui++ ) |
---|
| 162 | { |
---|
| 163 | g_aacWedgeLists[ui].clear(); |
---|
| 164 | } |
---|
| 165 | g_aacWedgeLists.clear(); |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | if ( !g_aacWedgeRefLists.empty() ) |
---|
| 169 | { |
---|
| 170 | for ( UInt ui = 0; ui < g_aacWedgeRefLists.size(); ui++ ) |
---|
| 171 | { |
---|
| 172 | g_aacWedgeRefLists[ui].clear(); |
---|
| 173 | } |
---|
| 174 | g_aacWedgeRefLists.clear(); |
---|
| 175 | } |
---|
| 176 | #endif |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | // ==================================================================================================================== |
---|
| 180 | // Data structure related table & variable |
---|
| 181 | // ==================================================================================================================== |
---|
| 182 | |
---|
| 183 | UInt g_uiMaxCUWidth = MAX_CU_SIZE; |
---|
| 184 | UInt g_uiMaxCUHeight = MAX_CU_SIZE; |
---|
| 185 | UInt g_uiMaxCUDepth = MAX_CU_DEPTH; |
---|
| 186 | UInt g_uiAddCUDepth = 0; |
---|
| 187 | |
---|
| 188 | UInt g_auiZscanToRaster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 189 | UInt g_auiRasterToZscan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 190 | UInt g_auiRasterToPelX [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 191 | UInt g_auiRasterToPelY [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
[56] | 192 | UInt g_motionRefer [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
[2] | 193 | |
---|
[56] | 194 | UInt g_auiPUOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5}; |
---|
[2] | 195 | |
---|
| 196 | Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ) |
---|
| 197 | { |
---|
| 198 | Int iStride = 1 << ( iMaxDepth - 1 ); |
---|
| 199 | |
---|
| 200 | if ( iDepth == iMaxDepth ) |
---|
| 201 | { |
---|
| 202 | rpuiCurrIdx[0] = uiStartVal; |
---|
| 203 | rpuiCurrIdx++; |
---|
| 204 | } |
---|
| 205 | else |
---|
| 206 | { |
---|
| 207 | Int iStep = iStride >> iDepth; |
---|
| 208 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal, rpuiCurrIdx ); |
---|
| 209 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep, rpuiCurrIdx ); |
---|
| 210 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride, rpuiCurrIdx ); |
---|
| 211 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride+iStep, rpuiCurrIdx ); |
---|
| 212 | } |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
| 216 | { |
---|
| 217 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
| 218 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
| 219 | |
---|
| 220 | UInt uiNumPartInWidth = (UInt)uiMaxCUWidth / uiMinCUWidth; |
---|
| 221 | UInt uiNumPartInHeight = (UInt)uiMaxCUHeight / uiMinCUHeight; |
---|
| 222 | |
---|
| 223 | for ( UInt i = 0; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
| 224 | { |
---|
| 225 | g_auiRasterToZscan[ g_auiZscanToRaster[i] ] = i; |
---|
| 226 | } |
---|
| 227 | } |
---|
| 228 | |
---|
[56] | 229 | /** generate motion data compression mapping table |
---|
| 230 | * \param uiMaxCUWidth, width of LCU |
---|
| 231 | * \param uiMaxCUHeight, hight of LCU |
---|
| 232 | * \param uiMaxDepth, max depth of LCU |
---|
| 233 | * \returns Void |
---|
| 234 | */ |
---|
| 235 | Void initMotionReferIdx ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
| 236 | { |
---|
| 237 | Int minCUWidth = (Int)uiMaxCUWidth >> ( (Int)uiMaxDepth - 1 ); |
---|
| 238 | Int minCUHeight = (Int)uiMaxCUHeight >> ( (Int)uiMaxDepth - 1 ); |
---|
| 239 | |
---|
| 240 | Int numPartInWidth = (Int)uiMaxCUWidth / (Int)minCUWidth; |
---|
| 241 | Int numPartInHeight = (Int)uiMaxCUHeight / (Int)minCUHeight; |
---|
| 242 | |
---|
| 243 | for ( Int i = 0; i < numPartInWidth*numPartInHeight; i++ ) |
---|
| 244 | { |
---|
| 245 | g_motionRefer[i] = i; |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | Int compressionNum = 2; |
---|
| 249 | |
---|
| 250 | for ( Int i = numPartInWidth*(numPartInHeight-1); i < numPartInWidth*numPartInHeight; i += compressionNum*2) |
---|
| 251 | { |
---|
| 252 | for ( Int j = 1; j < compressionNum; j++ ) |
---|
| 253 | { |
---|
| 254 | g_motionRefer[g_auiRasterToZscan[i+j]] = g_auiRasterToZscan[i]; |
---|
| 255 | } |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | for ( Int i = numPartInWidth*(numPartInHeight-1)+compressionNum*2-1; i < numPartInWidth*numPartInHeight; i += compressionNum*2) |
---|
| 259 | { |
---|
| 260 | for ( Int j = 1; j < compressionNum; j++ ) |
---|
| 261 | { |
---|
| 262 | g_motionRefer[g_auiRasterToZscan[i-j]] = g_auiRasterToZscan[i]; |
---|
| 263 | } |
---|
| 264 | } |
---|
| 265 | } |
---|
| 266 | |
---|
[2] | 267 | Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
| 268 | { |
---|
| 269 | UInt i; |
---|
| 270 | |
---|
| 271 | UInt* uiTempX = &g_auiRasterToPelX[0]; |
---|
| 272 | UInt* uiTempY = &g_auiRasterToPelY[0]; |
---|
| 273 | |
---|
| 274 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
| 275 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
| 276 | |
---|
| 277 | UInt uiNumPartInWidth = uiMaxCUWidth / uiMinCUWidth; |
---|
| 278 | UInt uiNumPartInHeight = uiMaxCUHeight / uiMinCUHeight; |
---|
| 279 | |
---|
| 280 | uiTempX[0] = 0; uiTempX++; |
---|
| 281 | for ( i = 1; i < uiNumPartInWidth; i++ ) |
---|
| 282 | { |
---|
| 283 | uiTempX[0] = uiTempX[-1] + uiMinCUWidth; uiTempX++; |
---|
| 284 | } |
---|
| 285 | for ( i = 1; i < uiNumPartInHeight; i++ ) |
---|
| 286 | { |
---|
| 287 | memcpy(uiTempX, uiTempX-uiNumPartInWidth, sizeof(UInt)*uiNumPartInWidth); |
---|
| 288 | uiTempX += uiNumPartInWidth; |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | for ( i = 1; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
| 292 | { |
---|
| 293 | uiTempY[i] = ( i / uiNumPartInWidth ) * uiMinCUWidth; |
---|
| 294 | } |
---|
| 295 | }; |
---|
| 296 | |
---|
| 297 | |
---|
[56] | 298 | Int g_quantScales[6] = |
---|
[2] | 299 | { |
---|
[56] | 300 | 26214,23302,20560,18396,16384,14564 |
---|
| 301 | }; |
---|
[2] | 302 | |
---|
[56] | 303 | Int g_invQuantScales[6] = |
---|
[2] | 304 | { |
---|
[56] | 305 | 40,45,51,57,64,72 |
---|
[2] | 306 | }; |
---|
| 307 | |
---|
[56] | 308 | const short g_aiT4[4][4] = |
---|
[2] | 309 | { |
---|
[56] | 310 | { 64, 64, 64, 64}, |
---|
| 311 | { 83, 36,-36,-83}, |
---|
| 312 | { 64,-64,-64, 64}, |
---|
| 313 | { 36,-83, 83,-36} |
---|
[2] | 314 | }; |
---|
| 315 | |
---|
[56] | 316 | const short g_aiT8[8][8] = |
---|
[2] | 317 | { |
---|
[56] | 318 | { 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
| 319 | { 89, 75, 50, 18,-18,-50,-75,-89}, |
---|
| 320 | { 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
| 321 | { 75,-18,-89,-50, 50, 89, 18,-75}, |
---|
| 322 | { 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
| 323 | { 50,-89, 18, 75,-75,-18, 89,-50}, |
---|
| 324 | { 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
| 325 | { 18,-50, 75,-89, 89,-75, 50,-18} |
---|
[2] | 326 | }; |
---|
| 327 | |
---|
[56] | 328 | const short g_aiT16[16][16] = |
---|
[2] | 329 | { |
---|
[56] | 330 | { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
| 331 | { 90, 87, 80, 70, 57, 43, 25, 9, -9,-25,-43,-57,-70,-80,-87,-90}, |
---|
| 332 | { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89}, |
---|
| 333 | { 87, 57, 9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87}, |
---|
| 334 | { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
| 335 | { 80, 9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80}, |
---|
| 336 | { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75}, |
---|
| 337 | { 70,-43,-87, 9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70}, |
---|
| 338 | { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
| 339 | { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87, 9,-90, 25, 80,-57}, |
---|
| 340 | { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50}, |
---|
| 341 | { 43,-90, 57, 25,-87, 70, 9,-80, 80, -9,-70, 87,-25,-57, 90,-43}, |
---|
| 342 | { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
| 343 | { 25,-70, 90,-80, 43, 9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25}, |
---|
| 344 | { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18}, |
---|
| 345 | { 9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9} |
---|
[2] | 346 | }; |
---|
| 347 | |
---|
[56] | 348 | const short g_aiT32[32][32] = |
---|
[2] | 349 | { |
---|
[56] | 350 | { 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}, |
---|
| 351 | { 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}, |
---|
| 352 | { 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}, |
---|
| 353 | { 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}, |
---|
| 354 | { 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}, |
---|
| 355 | { 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}, |
---|
| 356 | { 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}, |
---|
| 357 | { 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}, |
---|
| 358 | { 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}, |
---|
| 359 | { 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}, |
---|
| 360 | { 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}, |
---|
| 361 | { 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}, |
---|
| 362 | { 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}, |
---|
| 363 | { 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}, |
---|
| 364 | { 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}, |
---|
| 365 | { 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}, |
---|
| 366 | { 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}, |
---|
| 367 | { 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}, |
---|
| 368 | { 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}, |
---|
| 369 | { 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}, |
---|
| 370 | { 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}, |
---|
| 371 | { 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}, |
---|
| 372 | { 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}, |
---|
| 373 | { 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}, |
---|
| 374 | { 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}, |
---|
| 375 | { 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}, |
---|
| 376 | { 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}, |
---|
| 377 | { 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}, |
---|
| 378 | { 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}, |
---|
| 379 | { 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}, |
---|
| 380 | { 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}, |
---|
| 381 | { 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] | 382 | }; |
---|
| 383 | |
---|
| 384 | const UChar g_aucChromaScale[52]= |
---|
| 385 | { |
---|
| 386 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11, |
---|
| 387 | 12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27, |
---|
| 388 | 28,29,29,30,31,32,32,33,34,34,35,35,36,36,37,37, |
---|
| 389 | 37,38,38,38,39,39,39,39 |
---|
| 390 | }; |
---|
| 391 | |
---|
| 392 | |
---|
| 393 | // Mode-Dependent DCT/DST |
---|
| 394 | const short g_as_DST_MAT_4 [4][4]= |
---|
| 395 | { |
---|
| 396 | {29, 55, 74, 84}, |
---|
| 397 | {74, 74, 0 , -74}, |
---|
| 398 | {84, -29, -74, 55}, |
---|
| 399 | {55, -84, 74, -29}, |
---|
| 400 | }; |
---|
[56] | 401 | |
---|
| 402 | #if !LOGI_INTRA_NAME_3MPM |
---|
[2] | 403 | // Mapping each Unified Directional Intra prediction direction to DCT/DST transform |
---|
| 404 | // 0 implies use DCT, 1 implies DST |
---|
[56] | 405 | |
---|
| 406 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 407 | const UChar g_aucDCTDSTMode_Vert[NUM_INTRA_MODE+NUM_DMM_MODE] = |
---|
[5] | 408 | #else |
---|
[2] | 409 | const UChar g_aucDCTDSTMode_Vert[NUM_INTRA_MODE] = |
---|
[5] | 410 | #endif |
---|
[56] | 411 | { //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 |
---|
| 412 | 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 |
---|
[5] | 413 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
[56] | 414 | , 0, 0, 0, 0, 0, 0, 0, 0 |
---|
[5] | 415 | #elif HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[56] | 416 | , 0, 0, 0, 0 |
---|
[2] | 417 | #endif |
---|
| 418 | }; |
---|
[56] | 419 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 420 | const UChar g_aucDCTDSTMode_Hor[NUM_INTRA_MODE+NUM_DMM_MODE] = |
---|
[5] | 421 | #else |
---|
[2] | 422 | const UChar g_aucDCTDSTMode_Hor[NUM_INTRA_MODE] = |
---|
[5] | 423 | #endif |
---|
[56] | 424 | { //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 |
---|
| 425 | 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 |
---|
[5] | 426 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
[56] | 427 | , 0, 0, 0, 0, 0, 0, 0, 0 |
---|
[5] | 428 | #elif HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[56] | 429 | , 0, 0, 0, 0 |
---|
[2] | 430 | #endif |
---|
| 431 | }; |
---|
[56] | 432 | #endif |
---|
[2] | 433 | |
---|
| 434 | |
---|
| 435 | // ==================================================================================================================== |
---|
| 436 | // ADI |
---|
| 437 | // ==================================================================================================================== |
---|
| 438 | |
---|
| 439 | #if FAST_UDI_USE_MPM |
---|
| 440 | const UChar g_aucIntraModeNumFast[7] = |
---|
| 441 | { |
---|
| 442 | 3, // 2x2 |
---|
| 443 | 8, // 4x4 |
---|
| 444 | 8, // 8x8 |
---|
| 445 | 3, // 16x16 |
---|
| 446 | 3, // 32x32 |
---|
| 447 | 3, // 64x64 |
---|
| 448 | 3 // 128x128 |
---|
| 449 | }; |
---|
| 450 | #else // FAST_UDI_USE_MPM |
---|
| 451 | const UChar g_aucIntraModeNumFast[7] = |
---|
| 452 | { |
---|
| 453 | 3, // 2x2 |
---|
| 454 | 9, // 4x4 |
---|
| 455 | 9, // 8x8 |
---|
| 456 | 4, // 16x16 33 |
---|
| 457 | 4, // 32x32 33 |
---|
| 458 | 5, // 64x64 33 |
---|
| 459 | 4 // 128x128 33 |
---|
| 460 | }; |
---|
| 461 | #endif // FAST_UDI_USE_MPM |
---|
| 462 | |
---|
| 463 | // chroma |
---|
| 464 | |
---|
| 465 | const UChar g_aucConvertTxtTypeToIdx[4] = { 0, 1, 1, 2 }; |
---|
| 466 | |
---|
[56] | 467 | #if !LOGI_INTRA_NAME_3MPM |
---|
[2] | 468 | // ==================================================================================================================== |
---|
| 469 | // Angular Intra prediction |
---|
| 470 | // ==================================================================================================================== |
---|
| 471 | |
---|
| 472 | // g_aucAngIntraModeOrder |
---|
| 473 | // Indexing this array with the mode indicated in the bitstream |
---|
| 474 | // gives a logical index used in the prediction functions. |
---|
| 475 | const UChar g_aucAngIntraModeOrder[NUM_INTRA_MODE] = |
---|
| 476 | { // ModeOrder LogicalOrderInPredFunctions |
---|
[56] | 477 | 34, // PLANAR_IDX PLANAR PLANAR |
---|
[2] | 478 | 9, // 0 VER DC |
---|
| 479 | 25, // 1 HOR VER-8 (diagonal from top-left to bottom-right = HOR-8) |
---|
| 480 | 0, // 2 DC VER-7 |
---|
[56] | 481 | 1, // 4 VER-8 VER-6 |
---|
| 482 | 5, // 5 VER-4 VER-5 |
---|
| 483 | 13, // 6 VER+4 VER-4 |
---|
| 484 | 17, // 7 VER+8 VER-3 |
---|
| 485 | 21, // 8 HOR-4 VER-2 |
---|
| 486 | 29, // 9 HOR+4 VER-1 |
---|
| 487 | 33, // 10 HOR+8 VER |
---|
| 488 | 3, // 11 VER-6 VER+1 |
---|
| 489 | 7, // 12 VER-2 VER+2 |
---|
| 490 | 11, // 13 VER+2 VER+3 |
---|
| 491 | 15, // 14 VER+6 VER+4 |
---|
| 492 | 19, // 15 HOR-6 VER+5 |
---|
| 493 | 23, // 16 HOR-2 VER+6 |
---|
| 494 | 27, // 17 HOR+2 VER+7 |
---|
| 495 | 31, // 18 HOR+6 VER+8 |
---|
| 496 | 2, // 19 VER-7 HOR-7 |
---|
| 497 | 4, // 20 VER-5 HOR-6 |
---|
| 498 | 6, // 21 VER-3 HOR-5 |
---|
| 499 | 8, // 22 VER-1 HOR-4 |
---|
| 500 | 10, // 23 VER+1 HOR-3 |
---|
| 501 | 12, // 24 VER+3 HOR-2 |
---|
| 502 | 14, // 25 VER+5 HOR-1 |
---|
| 503 | 16, // 26 VER+7 HOR |
---|
| 504 | 18, // 27 HOR-7 HOR+1 |
---|
| 505 | 20, // 28 HOR-5 HOR+2 |
---|
| 506 | 22, // 29 HOR-3 HOR+3 |
---|
| 507 | 24, // 30 HOR-1 HOR+4 |
---|
| 508 | 26, // 31 HOR+1 HOR+5 |
---|
| 509 | 28, // 32 HOR+3 HOR+6 |
---|
| 510 | 30, // 33 HOR+5 HOR+7 |
---|
| 511 | 32, // 34 HOR+7 HOR+8 |
---|
| 512 | 0, // LM_CHROMA_IDX |
---|
[2] | 513 | }; |
---|
| 514 | |
---|
| 515 | const UChar g_aucIntraModeNumAng[7] = |
---|
| 516 | { |
---|
[56] | 517 | 4, // 2x2 |
---|
| 518 | 18, // 4x4 |
---|
| 519 | 35, // 8x8 |
---|
| 520 | 35, // 16x16 |
---|
| 521 | 35, // 32x32 |
---|
| 522 | 35, // 64x64 |
---|
| 523 | 6 // 128x128 |
---|
[2] | 524 | }; |
---|
| 525 | |
---|
| 526 | const UChar g_aucIntraModeBitsAng[7] = |
---|
| 527 | { |
---|
| 528 | 2, // 2x2 3 1+1 |
---|
| 529 | 5, // 4x4 17 4+1 |
---|
| 530 | 6, // 8x8 34 5+esc |
---|
| 531 | 6, // 16x16 34 5+esc |
---|
| 532 | 6, // 32x32 34 5+esc |
---|
[56] | 533 | 6, // 64x64 34 5+esc |
---|
[2] | 534 | 3 // 128x128 5 2+1 |
---|
| 535 | }; |
---|
[56] | 536 | #endif |
---|
[2] | 537 | |
---|
[56] | 538 | // ==================================================================================================================== |
---|
| 539 | // Bit-depth |
---|
| 540 | // ==================================================================================================================== |
---|
[2] | 541 | |
---|
[56] | 542 | UInt g_uiBitDepth = 8; // base bit-depth |
---|
| 543 | UInt g_uiBitIncrement = 0; // increments |
---|
| 544 | UInt g_uiIBDI_MAX = 255; // max. value after IBDI |
---|
| 545 | UInt g_uiBASE_MAX = 255; // max. value before IBDI |
---|
| 546 | |
---|
| 547 | UInt g_uiPCMBitDepthLuma = 8; // PCM bit-depth |
---|
| 548 | UInt g_uiPCMBitDepthChroma = 8; // PCM bit-depth |
---|
| 549 | |
---|
| 550 | // ==================================================================================================================== |
---|
| 551 | // Depth model modes |
---|
| 552 | // ==================================================================================================================== |
---|
[5] | 553 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[56] | 554 | Int g_iDeltaDCsQuantOffset = 0; |
---|
| 555 | |
---|
[2] | 556 | const WedgeResolution g_aeWedgeResolutionList[5] = |
---|
| 557 | { |
---|
| 558 | HALF_PEL, // 4x4 |
---|
| 559 | HALF_PEL, // 8x8 |
---|
| 560 | FULL_PEL, // 16x16 |
---|
| 561 | DOUBLE_PEL, // 32x32 |
---|
| 562 | DOUBLE_PEL // 64x64 |
---|
| 563 | }; |
---|
| 564 | |
---|
| 565 | const UChar g_aucWedgeFullBitsListIdx[7] = |
---|
| 566 | { |
---|
| 567 | 0, // 2x2 |
---|
| 568 | 7, // 4x4 WedgeListSize[ HALF_PEL] 86 |
---|
| 569 | 10, // 8x8 WedgeListSize[ HALF_PEL] 782 |
---|
| 570 | 11, // 16x16 WedgeListSize[ FULL_PEL] 1394 |
---|
| 571 | 11, // 32x32 WedgeListSize[DOUBLE_PEL] 1503 |
---|
| 572 | 13, // 64x64 WedgeListSize[DOUBLE_PEL] 6079 |
---|
| 573 | 0 // 128x128 |
---|
| 574 | }; |
---|
| 575 | |
---|
| 576 | const UChar g_aucIntraSizeIdxToWedgeSize[7] = |
---|
| 577 | { |
---|
| 578 | 2, |
---|
| 579 | 4, |
---|
| 580 | 8, |
---|
| 581 | 16, |
---|
| 582 | 32, |
---|
| 583 | 64, |
---|
[56] | 584 | 128 |
---|
[2] | 585 | }; |
---|
| 586 | #endif |
---|
| 587 | |
---|
| 588 | // ==================================================================================================================== |
---|
[56] | 589 | // Misc. |
---|
[2] | 590 | // ==================================================================================================================== |
---|
| 591 | |
---|
| 592 | Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; |
---|
| 593 | |
---|
| 594 | #if ENC_DEC_TRACE |
---|
| 595 | FILE* g_hTrace = NULL; |
---|
| 596 | const Bool g_bEncDecTraceEnable = true; |
---|
| 597 | const Bool g_bEncDecTraceDisable = false; |
---|
| 598 | Bool g_bJustDoIt = false; |
---|
| 599 | UInt64 g_nSymbolCounter = 0; |
---|
| 600 | #endif |
---|
| 601 | // ==================================================================================================================== |
---|
| 602 | // Scanning order & context model mapping |
---|
| 603 | // ==================================================================================================================== |
---|
| 604 | |
---|
| 605 | // scanning order table |
---|
| 606 | UInt* g_auiFrameScanXY[ MAX_CU_DEPTH ]; |
---|
| 607 | UInt* g_auiFrameScanX [ MAX_CU_DEPTH ]; |
---|
| 608 | UInt* g_auiFrameScanY [ MAX_CU_DEPTH ]; |
---|
[56] | 609 | UInt* g_auiSigLastScan[4][ MAX_CU_DEPTH ]; |
---|
| 610 | UInt *g_sigScanNSQT[ 4 ]; // scan for non-square partitions |
---|
| 611 | UInt g_sigCGScanNSQT[ 4 ][ 16 ] = |
---|
| 612 | { |
---|
| 613 | { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
---|
| 614 | { 0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15 }, |
---|
| 615 | { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
---|
| 616 | { 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15 } |
---|
| 617 | }; |
---|
[2] | 618 | |
---|
[56] | 619 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 620 | const UInt g_sigLastScan8x8[ 4 ][ 4 ] = |
---|
[2] | 621 | { |
---|
[56] | 622 | {0, 1, 2, 3}, |
---|
| 623 | {0, 1, 2, 3}, |
---|
| 624 | {0, 1, 2, 3}, |
---|
| 625 | {0, 2, 1, 3} |
---|
[2] | 626 | }; |
---|
[56] | 627 | UInt g_sigLastScanCG32x32[ 64 ]; |
---|
| 628 | #endif |
---|
[2] | 629 | |
---|
[56] | 630 | UInt* g_auiNonSquareSigLastScan[ 4 ]; |
---|
| 631 | |
---|
| 632 | const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24}; |
---|
| 633 | 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}; |
---|
| 634 | #if LAST_CTX_REDUCTION |
---|
| 635 | const UInt g_uiLastCtx[ 28 ] = |
---|
[2] | 636 | { |
---|
[56] | 637 | 0, 1, 2, 2, // 4x4 4 |
---|
| 638 | 3, 4, 5, 5, 2, 2, // 8x8 6 |
---|
| 639 | 6, 7, 8, 8, 9, 9, 2, 2, // 16x16 8 |
---|
| 640 | 10, 11, 12, 12, 13, 13, 14, 14, 2, 2 // 32x32 10 |
---|
[2] | 641 | }; |
---|
[56] | 642 | #else |
---|
| 643 | const UInt g_uiLastCtx[ 28 ] = |
---|
| 644 | { |
---|
| 645 | 0, 1, 2, 2, // 4x4 4 |
---|
| 646 | 3, 4, 5, 5, 6, 6, // 8x8 6 |
---|
| 647 | 7, 8, 9, 9, 10, 10, 11, 11, // 16x16 8 |
---|
| 648 | 12, 13, 14, 14, 15, 15, 16, 16, 17, 17 // 32x32 10 |
---|
| 649 | }; |
---|
[2] | 650 | #endif |
---|
| 651 | |
---|
[56] | 652 | // Rice parameters for absolute transform levels |
---|
| 653 | #if EIGHT_BITS_RICE_CODE |
---|
| 654 | const UInt g_auiGoRiceRange[5] = |
---|
| 655 | { |
---|
| 656 | 7, 14, 26, 46, 78 |
---|
| 657 | }; |
---|
[2] | 658 | |
---|
[56] | 659 | const UInt g_auiGoRicePrefixLen[5] = |
---|
| 660 | { |
---|
| 661 | 8, 7, 6, 5, 4 |
---|
| 662 | }; |
---|
| 663 | #else |
---|
[2] | 664 | const UInt g_auiGoRiceRange[4] = |
---|
| 665 | { |
---|
| 666 | 7, 20, 42, 70 |
---|
| 667 | }; |
---|
| 668 | |
---|
| 669 | const UInt g_auiGoRicePrefixLen[4] = |
---|
| 670 | { |
---|
[56] | 671 | 8, 10, 10, 8 |
---|
[2] | 672 | }; |
---|
[56] | 673 | #endif |
---|
[2] | 674 | |
---|
[56] | 675 | #if EIGHT_BITS_RICE_CODE |
---|
| 676 | const UInt g_aauiGoRiceUpdate[5][24] = |
---|
| 677 | { |
---|
| 678 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 679 | { |
---|
| 680 | 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
| 681 | }, |
---|
| 682 | { |
---|
| 683 | 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
| 684 | }, |
---|
| 685 | { |
---|
| 686 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
| 687 | }, |
---|
| 688 | { |
---|
| 689 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
| 690 | }, |
---|
| 691 | { |
---|
| 692 | 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 |
---|
| 693 | } |
---|
| 694 | #else |
---|
| 695 | { |
---|
| 696 | 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
| 697 | }, |
---|
| 698 | { |
---|
| 699 | 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
| 700 | }, |
---|
| 701 | { |
---|
| 702 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
| 703 | }, |
---|
| 704 | { |
---|
| 705 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
| 706 | }, |
---|
| 707 | { |
---|
| 708 | 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 |
---|
| 709 | } |
---|
| 710 | #endif |
---|
| 711 | }; |
---|
| 712 | #else |
---|
[2] | 713 | const UInt g_aauiGoRiceUpdate[4][16] = |
---|
| 714 | { |
---|
[56] | 715 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
[2] | 716 | { |
---|
[56] | 717 | 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, |
---|
[2] | 718 | }, |
---|
[56] | 719 | { |
---|
| 720 | 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, |
---|
| 721 | }, |
---|
| 722 | { |
---|
| 723 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, |
---|
| 724 | }, |
---|
| 725 | { |
---|
| 726 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, |
---|
| 727 | } |
---|
| 728 | #else |
---|
[2] | 729 | { |
---|
[56] | 730 | 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 |
---|
[2] | 731 | }, |
---|
| 732 | { |
---|
[56] | 733 | 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 |
---|
[2] | 734 | }, |
---|
| 735 | { |
---|
[56] | 736 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 |
---|
| 737 | }, |
---|
| 738 | { |
---|
[2] | 739 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 |
---|
| 740 | } |
---|
[56] | 741 | #endif |
---|
[2] | 742 | }; |
---|
| 743 | #endif |
---|
| 744 | |
---|
| 745 | // initialize g_auiFrameScanXY |
---|
| 746 | Void initFrameScanXY( UInt* pBuff, UInt* pBuffX, UInt* pBuffY, Int iWidth, Int iHeight ) |
---|
| 747 | { |
---|
| 748 | Int x, y, c = 0; |
---|
| 749 | |
---|
| 750 | // starting point |
---|
| 751 | pBuffX[ c ] = 0; |
---|
| 752 | pBuffY[ c ] = 0; |
---|
| 753 | pBuff[ c++ ] = 0; |
---|
| 754 | |
---|
| 755 | // loop |
---|
| 756 | x=1; y=0; |
---|
| 757 | while (1) |
---|
| 758 | { |
---|
| 759 | // decrease loop |
---|
| 760 | while ( x>=0 ) |
---|
| 761 | { |
---|
| 762 | if ( x >= 0 && x < iWidth && y >= 0 && y < iHeight ) |
---|
| 763 | { |
---|
| 764 | pBuffX[ c ] = x; |
---|
| 765 | pBuffY[ c ] = y; |
---|
| 766 | pBuff[ c++ ] = x+y*iWidth; |
---|
| 767 | } |
---|
| 768 | x--; y++; |
---|
| 769 | } |
---|
| 770 | x=0; |
---|
| 771 | |
---|
| 772 | // increase loop |
---|
| 773 | while ( y>=0 ) |
---|
| 774 | { |
---|
| 775 | if ( x >= 0 && x < iWidth && y >= 0 && y < iHeight ) |
---|
| 776 | { |
---|
| 777 | pBuffX[ c ] = x; |
---|
| 778 | pBuffY[ c ] = y; |
---|
| 779 | pBuff[ c++ ] = x+y*iWidth; |
---|
| 780 | } |
---|
| 781 | x++; y--; |
---|
| 782 | } |
---|
| 783 | y=0; |
---|
| 784 | |
---|
| 785 | // termination condition |
---|
| 786 | if ( c >= iWidth*iHeight ) break; |
---|
[56] | 787 | } |
---|
| 788 | } |
---|
| 789 | |
---|
| 790 | Void initSigLastScan(UInt* pBuffZ, UInt* pBuffH, UInt* pBuffV, UInt* pBuffD, Int iWidth, Int iHeight, Int iDepth) |
---|
| 791 | { |
---|
| 792 | const UInt uiNumScanPos = UInt( iWidth * iWidth ); |
---|
| 793 | UInt uiNextScanPos = 0; |
---|
| 794 | |
---|
| 795 | if( iWidth < 16 ) |
---|
| 796 | { |
---|
| 797 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 798 | UInt* pBuffTemp = pBuffD; |
---|
| 799 | if( iWidth == 8 ) |
---|
| 800 | { |
---|
| 801 | pBuffTemp = g_sigLastScanCG32x32; |
---|
[2] | 802 | } |
---|
[56] | 803 | #endif |
---|
| 804 | for( UInt uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ ) |
---|
| 805 | { |
---|
| 806 | int iPrimDim = int( uiScanLine ); |
---|
| 807 | int iScndDim = 0; |
---|
| 808 | while( iPrimDim >= iWidth ) |
---|
| 809 | { |
---|
| 810 | iScndDim++; |
---|
| 811 | iPrimDim--; |
---|
| 812 | } |
---|
| 813 | while( iPrimDim >= 0 && iScndDim < iWidth ) |
---|
| 814 | { |
---|
| 815 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 816 | pBuffTemp[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ; |
---|
| 817 | #else |
---|
| 818 | pBuffD[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ; |
---|
| 819 | #endif |
---|
| 820 | uiNextScanPos++; |
---|
| 821 | iScndDim++; |
---|
| 822 | iPrimDim--; |
---|
| 823 | } |
---|
| 824 | } |
---|
| 825 | } |
---|
| 826 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 827 | if( iWidth > 4 ) |
---|
| 828 | #else |
---|
| 829 | else |
---|
| 830 | #endif |
---|
| 831 | { |
---|
| 832 | UInt uiNumBlkSide = iWidth >> 2; |
---|
| 833 | UInt uiNumBlks = uiNumBlkSide * uiNumBlkSide; |
---|
| 834 | UInt log2Blk = g_aucConvertToBit[ uiNumBlkSide ] + 1; |
---|
| 835 | |
---|
| 836 | for( UInt uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ ) |
---|
| 837 | { |
---|
| 838 | uiNextScanPos = 0; |
---|
| 839 | UInt initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ]; |
---|
| 840 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 841 | if( iWidth == 32 ) |
---|
| 842 | { |
---|
| 843 | initBlkPos = g_sigLastScanCG32x32[ uiBlk ]; |
---|
| 844 | } |
---|
| 845 | #endif |
---|
| 846 | UInt offsetY = initBlkPos / uiNumBlkSide; |
---|
| 847 | UInt offsetX = initBlkPos - offsetY * uiNumBlkSide; |
---|
| 848 | UInt offsetD = 4 * ( offsetX + offsetY * iWidth ); |
---|
| 849 | UInt offsetScan = 16 * uiBlk; |
---|
| 850 | for( UInt uiScanLine = 0; uiNextScanPos < 16; uiScanLine++ ) |
---|
| 851 | { |
---|
| 852 | int iPrimDim = int( uiScanLine ); |
---|
| 853 | int iScndDim = 0; |
---|
| 854 | while( iPrimDim >= 4 ) |
---|
| 855 | { |
---|
| 856 | iScndDim++; |
---|
| 857 | iPrimDim--; |
---|
| 858 | } |
---|
| 859 | while( iPrimDim >= 0 && iScndDim < 4 ) |
---|
| 860 | { |
---|
| 861 | pBuffD[ uiNextScanPos + offsetScan ] = iPrimDim * iWidth + iScndDim + offsetD; |
---|
| 862 | uiNextScanPos++; |
---|
| 863 | iScndDim++; |
---|
| 864 | iPrimDim--; |
---|
| 865 | } |
---|
| 866 | } |
---|
| 867 | } |
---|
| 868 | } |
---|
[2] | 869 | |
---|
[56] | 870 | memcpy(pBuffZ, g_auiFrameScanXY[iDepth], sizeof(UInt)*iWidth*iHeight); |
---|
| 871 | |
---|
| 872 | UInt uiCnt = 0; |
---|
| 873 | for(Int iY=0; iY < iHeight; iY++) |
---|
[2] | 874 | { |
---|
[56] | 875 | for(Int iX=0; iX < iWidth; iX++) |
---|
[2] | 876 | { |
---|
[56] | 877 | pBuffH[uiCnt] = iY*iWidth + iX; |
---|
| 878 | uiCnt ++; |
---|
[2] | 879 | } |
---|
| 880 | } |
---|
[56] | 881 | |
---|
| 882 | uiCnt = 0; |
---|
| 883 | for(Int iX=0; iX < iWidth; iX++) |
---|
| 884 | { |
---|
| 885 | for(Int iY=0; iY < iHeight; iY++) |
---|
| 886 | { |
---|
| 887 | pBuffV[uiCnt] = iY*iWidth + iX; |
---|
| 888 | uiCnt ++; |
---|
| 889 | } |
---|
| 890 | } |
---|
[2] | 891 | } |
---|
| 892 | |
---|
[56] | 893 | Void initNonSquareSigLastScan(UInt* pBuffZ, UInt uiWidth, UInt uiHeight) |
---|
[2] | 894 | { |
---|
| 895 | |
---|
[56] | 896 | Int x, y, c = 0; |
---|
[2] | 897 | |
---|
[56] | 898 | // starting point |
---|
| 899 | pBuffZ[ c++ ] = 0; |
---|
| 900 | |
---|
| 901 | // loop |
---|
| 902 | if ( uiWidth > uiHeight ) |
---|
| 903 | { |
---|
| 904 | x=0; y=1; |
---|
| 905 | while (1) |
---|
[2] | 906 | { |
---|
[56] | 907 | // increase loop |
---|
| 908 | while ( y>=0 ) |
---|
[2] | 909 | { |
---|
[56] | 910 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
| 911 | { |
---|
| 912 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
| 913 | } |
---|
| 914 | x++; |
---|
| 915 | y--; |
---|
[2] | 916 | } |
---|
[56] | 917 | y=0; |
---|
| 918 | |
---|
| 919 | // decrease loop |
---|
| 920 | while ( x>=0 ) |
---|
| 921 | { |
---|
| 922 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
| 923 | { |
---|
| 924 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
| 925 | } |
---|
| 926 | x--; |
---|
| 927 | y++; |
---|
| 928 | } |
---|
| 929 | x=0; |
---|
| 930 | |
---|
| 931 | // termination condition |
---|
| 932 | if ( c >= uiWidth * uiHeight ) |
---|
| 933 | break; |
---|
[2] | 934 | } |
---|
[56] | 935 | } |
---|
| 936 | else |
---|
| 937 | { |
---|
| 938 | x=1; y=0; |
---|
| 939 | while (1) |
---|
[2] | 940 | { |
---|
[56] | 941 | // increase loop |
---|
| 942 | while ( x>=0 ) |
---|
[2] | 943 | { |
---|
[56] | 944 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
| 945 | { |
---|
| 946 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
| 947 | } |
---|
| 948 | x--; |
---|
| 949 | y++; |
---|
[2] | 950 | } |
---|
[56] | 951 | x=0; |
---|
| 952 | |
---|
| 953 | // decrease loop |
---|
| 954 | while ( y>=0 ) |
---|
| 955 | { |
---|
| 956 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
| 957 | { |
---|
| 958 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
| 959 | } |
---|
| 960 | x++; |
---|
| 961 | y--; |
---|
| 962 | } |
---|
| 963 | y=0; |
---|
| 964 | |
---|
| 965 | // termination condition |
---|
| 966 | if ( c >= uiWidth * uiHeight ) |
---|
| 967 | break; |
---|
[2] | 968 | } |
---|
[56] | 969 | } |
---|
[2] | 970 | } |
---|
| 971 | |
---|
[56] | 972 | #if SCALING_LIST |
---|
| 973 | Int g_quantIntraDefault4x4[16] = |
---|
[2] | 974 | { |
---|
[56] | 975 | 16,16,17,21, |
---|
| 976 | 16,17,20,25, |
---|
| 977 | 17,20,30,41, |
---|
| 978 | 21,25,41,70 |
---|
[2] | 979 | }; |
---|
[56] | 980 | Int g_quantInterDefault4x4[16] = |
---|
| 981 | { |
---|
| 982 | 16,16,17,21, |
---|
| 983 | 16,17,21,24, |
---|
| 984 | 17,21,24,36, |
---|
| 985 | 21,24,36,57 |
---|
| 986 | }; |
---|
| 987 | |
---|
| 988 | Int g_quantIntraDefault8x8[64] = |
---|
| 989 | { |
---|
| 990 | 16,16,16,16,17,18,21,24, |
---|
| 991 | 16,16,16,16,17,19,22,25, |
---|
| 992 | 16,16,17,18,20,22,25,29, |
---|
| 993 | 16,16,18,21,24,27,31,36, |
---|
| 994 | 17,17,20,24,30,35,41,47, |
---|
| 995 | 18,19,22,27,35,44,54,65, |
---|
| 996 | 21,22,25,31,41,54,70,88, |
---|
| 997 | 24,25,29,36,47,65,88,115 |
---|
| 998 | }; |
---|
| 999 | |
---|
| 1000 | Int g_quantInterDefault8x8[64] = |
---|
| 1001 | { |
---|
| 1002 | 16,16,16,16,17,18,20,24, |
---|
| 1003 | 16,16,16,17,18,20,24,25, |
---|
| 1004 | 16,16,17,18,20,24,25,28, |
---|
| 1005 | 16,17,18,20,24,25,28,33, |
---|
| 1006 | 17,18,20,24,25,28,33,41, |
---|
| 1007 | 18,20,24,25,28,33,41,54, |
---|
| 1008 | 20,24,25,28,33,41,54,71, |
---|
| 1009 | 24,25,28,33,41,54,71,91 |
---|
| 1010 | }; |
---|
| 1011 | #else |
---|
| 1012 | Int g_quantIntraDefault4x4[16] = |
---|
| 1013 | { |
---|
| 1014 | 6,13,20,28, |
---|
| 1015 | 13,20,28,32, |
---|
| 1016 | 20,28,32,37, |
---|
| 1017 | 28,32,37,42 |
---|
| 1018 | }; |
---|
| 1019 | Int g_quantInterDefault4x4[16] = |
---|
| 1020 | { |
---|
| 1021 | 10,14,20,24, |
---|
| 1022 | 14,20,24,27, |
---|
| 1023 | 20,24,27,30, |
---|
| 1024 | 24,27,30,34 |
---|
| 1025 | }; |
---|
| 1026 | |
---|
| 1027 | Int g_quantIntraDefault8x8[64] = |
---|
| 1028 | { |
---|
| 1029 | 6,10,13,16,18,23,25,27, |
---|
| 1030 | 10,11,16,18,23,25,27,29, |
---|
| 1031 | 13,16,18,23,25,27,29,31, |
---|
| 1032 | 16,18,23,25,27,29,31,33, |
---|
| 1033 | 18,23,25,27,29,31,33,36, |
---|
| 1034 | 23,25,27,29,31,33,36,38, |
---|
| 1035 | 25,27,29,31,33,36,38,40, |
---|
| 1036 | 27,29,31,33,36,38,40,42 |
---|
| 1037 | }; |
---|
| 1038 | |
---|
| 1039 | Int g_quantInterDefault8x8[64] = |
---|
| 1040 | { |
---|
| 1041 | 9,13,15,17,19,21,22,24, |
---|
| 1042 | 13,13,17,19,21,22,24,25, |
---|
| 1043 | 15,17,19,21,22,24,25,27, |
---|
| 1044 | 17,19,21,22,24,25,27,28, |
---|
| 1045 | 19,21,22,24,25,27,28,30, |
---|
| 1046 | 21,22,24,25,27,28,30,32, |
---|
| 1047 | 22,24,25,27,28,30,32,33, |
---|
| 1048 | 24,25,27,28,30,32,33,35 |
---|
| 1049 | }; |
---|
| 1050 | |
---|
| 1051 | Int g_quantIntraDefault16x16[256] = |
---|
| 1052 | { |
---|
| 1053 | 16,16,16,16,16,16,16,16,17,17,18,19,21,22,24,27, |
---|
| 1054 | 16,16,16,16,16,16,16,16,17,18,18,20,21,23,25,27, |
---|
| 1055 | 16,16,16,16,16,16,16,17,17,18,19,20,22,23,25,28, |
---|
| 1056 | 16,16,16,16,16,16,17,17,18,19,20,21,23,25,27,29, |
---|
| 1057 | 16,16,16,16,17,17,18,19,20,21,22,23,25,27,29,31, |
---|
| 1058 | 16,16,16,16,17,18,19,20,22,23,24,26,27,29,32,34, |
---|
| 1059 | 16,16,16,17,18,19,21,23,24,25,27,29,31,33,36,39, |
---|
| 1060 | 16,16,17,17,19,20,23,25,27,29,31,33,35,38,41,44, |
---|
| 1061 | 17,17,17,18,20,22,24,27,30,32,35,38,41,44,47,51, |
---|
| 1062 | 17,18,18,19,21,23,25,29,32,36,40,43,47,51,55,60, |
---|
| 1063 | 18,18,19,20,22,24,27,31,35,40,44,49,54,59,65,70, |
---|
| 1064 | 19,20,20,21,23,26,29,33,38,43,49,56,62,69,75,82, |
---|
| 1065 | 21,21,22,23,25,27,31,35,41,47,54,62,70,79,88,97, |
---|
| 1066 | 22,23,23,25,27,29,33,38,44,51,59,69,79,90,101,113, |
---|
| 1067 | 24,25,25,27,29,32,36,41,47,55,65,75,88,101,115,130, |
---|
| 1068 | 27,27,28,29,31,34,39,44,51,60,70,82,97,113,130,149 |
---|
| 1069 | }; |
---|
| 1070 | |
---|
| 1071 | Int g_quantInterDefault16x16[256] = |
---|
| 1072 | { |
---|
| 1073 | 16,16,16,16,16,16,16,16,17,17,18,19,20,21,22,27, |
---|
| 1074 | 16,16,16,16,16,16,16,17,17,18,19,20,21,22,27,27, |
---|
| 1075 | 16,16,16,16,16,16,17,17,18,19,20,21,22,27,27,28, |
---|
| 1076 | 16,16,16,16,16,17,17,18,19,20,21,22,27,27,28,29, |
---|
| 1077 | 16,16,16,16,17,17,18,19,20,21,22,27,27,28,29,30, |
---|
| 1078 | 16,16,16,17,17,18,19,20,21,22,27,27,28,29,30,32, |
---|
| 1079 | 16,16,17,17,18,19,20,21,22,27,27,28,29,30,32,36, |
---|
| 1080 | 16,17,17,18,19,20,21,22,27,27,28,29,30,32,36,40, |
---|
| 1081 | 17,17,18,19,20,21,22,27,27,28,29,30,32,36,40,45, |
---|
| 1082 | 17,18,19,20,21,22,27,27,28,29,30,32,36,40,45,52, |
---|
| 1083 | 18,19,20,21,22,27,27,28,29,30,32,36,40,45,52,59, |
---|
| 1084 | 19,20,21,22,27,27,28,29,30,32,36,40,45,52,59,68, |
---|
| 1085 | 20,21,22,27,27,28,29,30,32,36,40,45,52,59,68,79, |
---|
| 1086 | 21,22,27,27,28,29,30,32,36,40,45,52,59,68,79,91, |
---|
| 1087 | 22,27,27,28,29,30,32,36,40,45,52,59,68,79,91,103, |
---|
| 1088 | 27,27,28,29,30,32,36,40,45,52,59,68,79,91,103,117 |
---|
| 1089 | }; |
---|
| 1090 | |
---|
| 1091 | Int g_quantIntraDefault32x32[1024] = |
---|
| 1092 | { |
---|
| 1093 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,27,28, |
---|
| 1094 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,23,23,24,25,27,28, |
---|
| 1095 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,18,19,20,20,21,22,23,24,25,26,27,28, |
---|
| 1096 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,21,22,23,24,25,26,27,28, |
---|
| 1097 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,20,21,22,23,23,24,25,26,28,29, |
---|
| 1098 | 16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,18,19,19,20,21,21,22,23,24,25,26,27,28,30, |
---|
| 1099 | 16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,18,18,19,19,20,20,21,21,22,23,24,25,26,27,28,29,30, |
---|
| 1100 | 16,16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,19,19,20,20,21,21,22,23,24,25,26,27,28,29,30,31, |
---|
| 1101 | 16,16,16,16,16,16,16,16,17,17,17,18,18,18,19,19,20,20,21,21,22,22,23,24,25,26,27,28,29,30,31,33, |
---|
| 1102 | 16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,20,20,21,22,22,23,23,24,25,26,27,28,29,30,31,33,34, |
---|
| 1103 | 16,16,16,16,16,16,16,17,17,18,18,19,19,20,20,21,22,22,23,23,24,25,26,26,27,28,29,30,32,33,34,36, |
---|
| 1104 | 16,16,16,16,16,16,17,17,18,18,19,20,20,21,21,22,23,23,24,25,25,26,27,28,29,30,31,32,33,35,36,38, |
---|
| 1105 | 16,16,16,16,16,16,17,17,18,19,19,20,21,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,36,37,39,40, |
---|
| 1106 | 16,16,16,16,16,17,17,18,18,19,20,21,22,23,24,24,25,26,27,28,29,30,31,32,33,34,35,37,38,39,41,43, |
---|
| 1107 | 16,16,16,16,17,17,17,18,19,20,20,21,23,24,25,26,27,28,29,30,31,32,33,34,35,36,38,39,41,42,44,46, |
---|
| 1108 | 16,16,17,17,17,17,18,18,19,20,21,22,23,24,26,27,28,29,31,32,33,34,35,37,38,39,41,42,44,45,47,49, |
---|
| 1109 | 17,17,17,17,17,18,18,19,20,20,22,23,24,25,27,28,30,31,32,34,35,36,38,39,41,42,44,45,47,49,51,53, |
---|
| 1110 | 17,17,17,17,18,18,19,19,20,21,22,23,25,26,28,29,31,33,34,36,37,39,41,42,44,45,47,49,51,53,55,57, |
---|
| 1111 | 17,17,18,18,18,18,19,20,21,22,23,24,25,27,29,31,32,34,36,38,40,42,43,45,47,49,51,53,55,57,60,62, |
---|
| 1112 | 18,18,18,18,19,19,20,20,21,22,23,25,26,28,30,32,34,36,38,40,42,44,46,48,51,53,55,57,60,62,65,67, |
---|
| 1113 | 18,18,18,19,19,19,20,21,22,23,24,25,27,29,31,33,35,37,40,42,44,47,49,52,54,57,59,62,65,67,70,73, |
---|
| 1114 | 19,19,19,19,20,20,21,21,22,23,25,26,28,30,32,34,36,39,42,44,47,50,52,55,58,61,64,67,70,73,76,79, |
---|
| 1115 | 19,19,20,20,20,21,21,22,23,24,26,27,29,31,33,35,38,41,43,46,49,52,56,59,62,65,69,72,75,79,82,86, |
---|
| 1116 | 20,20,20,21,21,21,22,23,24,25,26,28,30,32,34,37,39,42,45,48,52,55,59,62,66,70,74,77,81,85,89,93, |
---|
| 1117 | 21,21,21,21,22,22,23,24,25,26,27,29,31,33,35,38,41,44,47,51,54,58,62,66,70,74,79,83,88,92,97,101, |
---|
| 1118 | 22,22,22,22,23,23,24,25,26,27,28,30,32,34,36,39,42,45,49,53,57,61,65,70,74,79,84,89,94,99,104,110, |
---|
| 1119 | 22,23,23,23,23,24,25,26,27,28,29,31,33,35,38,41,44,47,51,55,59,64,69,74,79,84,90,95,101,107,113,119, |
---|
| 1120 | 23,23,24,24,24,25,26,27,28,29,30,32,34,37,39,42,45,49,53,57,62,67,72,77,83,89,95,101,108,114,121,128, |
---|
| 1121 | 24,24,25,25,25,26,27,28,29,30,32,33,36,38,41,44,47,51,55,60,65,70,75,81,88,94,101,108,115,122,130,138, |
---|
| 1122 | 25,25,26,26,26,27,28,29,30,31,33,35,37,39,42,45,49,53,57,62,67,73,79,85,92,99,107,114,122,131,139,148, |
---|
| 1123 | 27,27,27,27,28,28,29,30,31,33,34,36,39,41,44,47,51,55,60,65,70,76,82,89,97,104,113,121,130,139,149,159, |
---|
| 1124 | 28,28,28,28,29,30,30,31,33,34,36,38,40,43,46,49,53,57,62,67,73,79,86,93,101,110,119,128,138,148,159,170 |
---|
| 1125 | }; |
---|
| 1126 | |
---|
| 1127 | Int g_quantInterDefault32x32[1024] = |
---|
| 1128 | { |
---|
| 1129 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28, |
---|
| 1130 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28, |
---|
| 1131 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28, |
---|
| 1132 | 16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28, |
---|
| 1133 | 16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29, |
---|
| 1134 | 16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30, |
---|
| 1135 | 16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30, |
---|
| 1136 | 16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31, |
---|
| 1137 | 16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32, |
---|
| 1138 | 16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33, |
---|
| 1139 | 16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34, |
---|
| 1140 | 16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35, |
---|
| 1141 | 16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36, |
---|
| 1142 | 16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38, |
---|
| 1143 | 16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40, |
---|
| 1144 | 16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42, |
---|
| 1145 | 17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45, |
---|
| 1146 | 17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48, |
---|
| 1147 | 17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52, |
---|
| 1148 | 18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56, |
---|
| 1149 | 18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60, |
---|
| 1150 | 19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64, |
---|
| 1151 | 19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69, |
---|
| 1152 | 20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74, |
---|
| 1153 | 21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80, |
---|
| 1154 | 22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87, |
---|
| 1155 | 22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94, |
---|
| 1156 | 23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101, |
---|
| 1157 | 24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108, |
---|
| 1158 | 25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108,115, |
---|
| 1159 | 26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108,115,123, |
---|
| 1160 | 28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108,115,123,131 |
---|
| 1161 | }; |
---|
[2] | 1162 | #endif |
---|
[56] | 1163 | UInt g_scalingListSize [4] = {16,64,256,1024}; |
---|
| 1164 | UInt g_scalingListSizeX [4] = { 4, 8, 16, 32}; |
---|
| 1165 | UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2}; |
---|
| 1166 | Int g_eTTable[4] = {0,3,1,2}; |
---|
[2] | 1167 | |
---|
[5] | 1168 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[56] | 1169 | std::vector< std::vector<TComWedgelet> > g_aacWedgeLists; |
---|
| 1170 | std::vector< std::vector<TComWedgeRef> > g_aacWedgeRefLists; |
---|
[2] | 1171 | |
---|
| 1172 | Void initWedgeLists() |
---|
| 1173 | { |
---|
| 1174 | for( UInt ui = g_aucConvertToBit[DMM_WEDGEMODEL_MIN_SIZE]; ui < (g_aucConvertToBit[DMM_WEDGEMODEL_MAX_SIZE]+1); ui++ ) |
---|
| 1175 | { |
---|
| 1176 | UInt uiWedgeBlockSize = ((UInt)DMM_WEDGEMODEL_MIN_SIZE)<<ui; |
---|
| 1177 | std::vector<TComWedgelet> acWedgeList; |
---|
| 1178 | std::vector<TComWedgeRef> acWedgeRefList; |
---|
| 1179 | createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_aeWedgeResolutionList[ui] ); |
---|
| 1180 | g_aacWedgeLists.push_back( acWedgeList ); |
---|
| 1181 | g_aacWedgeRefLists.push_back( acWedgeRefList ); |
---|
| 1182 | } |
---|
| 1183 | return; |
---|
| 1184 | } |
---|
| 1185 | |
---|
| 1186 | Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes ) |
---|
| 1187 | { |
---|
| 1188 | assert( uiWidth == uiHeight ); |
---|
| 1189 | |
---|
[77] | 1190 | UChar uhStartX = 0, uhStartY = 0, uhEndX = 0, uhEndY = 0; |
---|
| 1191 | Int iStepStartX = 0, iStepStartY = 0, iStepEndX = 0, iStepEndY = 0; |
---|
[56] | 1192 | |
---|
[2] | 1193 | UInt uiBlockSize = 0; |
---|
| 1194 | switch( eWedgeRes ) |
---|
| 1195 | { |
---|
| 1196 | case( DOUBLE_PEL ): { uiBlockSize = (uiWidth>>1); break; } |
---|
| 1197 | case( FULL_PEL ): { uiBlockSize = uiWidth; break; } |
---|
| 1198 | case( HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; } |
---|
| 1199 | } |
---|
| 1200 | |
---|
| 1201 | TComWedgelet cTempWedgelet( uiWidth, uiHeight ); |
---|
| 1202 | for( UInt uiOri = 0; uiOri < 6; uiOri++ ) |
---|
| 1203 | { |
---|
| 1204 | // init the edge line parameters for each of the 6 wedgelet types |
---|
| 1205 | switch( uiOri ) |
---|
| 1206 | { |
---|
| 1207 | case( 0 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = +1; iStepStartY = 0; iStepEndX = 0; iStepEndY = +1; break; } |
---|
| 1208 | case( 1 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = (uiBlockSize-1); uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = -1; iStepEndY = 0; break; } |
---|
| 1209 | case( 2 ): { uhStartX = (uiBlockSize-1); uhStartY = (uiBlockSize-1); uhEndX = (uiBlockSize-1); uhEndY = (uiBlockSize-1); iStepStartX = -1; iStepStartY = 0; iStepEndX = 0; iStepEndY = -1; break; } |
---|
| 1210 | case( 3 ): { uhStartX = 0; uhStartY = (uiBlockSize-1); uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = 0; iStepStartY = -1; iStepEndX = +1; iStepEndY = 0; break; } |
---|
| 1211 | case( 4 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = +1; iStepStartY = 0; iStepEndX = +1; iStepEndY = 0; break; } |
---|
| 1212 | case( 5 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = 0; iStepEndY = +1; break; } |
---|
| 1213 | } |
---|
| 1214 | |
---|
| 1215 | for( Int iK = 0; iK < uiBlockSize; iK++ ) |
---|
| 1216 | { |
---|
| 1217 | for( Int iL = 0; iL < uiBlockSize; iL++ ) |
---|
[56] | 1218 | { |
---|
[2] | 1219 | cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes ); |
---|
[56] | 1220 | addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList ); |
---|
| 1221 | } |
---|
| 1222 | } |
---|
| 1223 | } |
---|
| 1224 | } |
---|
[2] | 1225 | |
---|
[56] | 1226 | Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList ) |
---|
| 1227 | { |
---|
| 1228 | Bool bValid = cWedgelet.checkNotPlain(); |
---|
| 1229 | if( bValid ) |
---|
| 1230 | { |
---|
| 1231 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
| 1232 | { |
---|
| 1233 | if( cWedgelet.checkIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
| 1234 | { |
---|
| 1235 | TComWedgeRef cWedgeRef; |
---|
| 1236 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
| 1237 | racWedgeRefList.push_back( cWedgeRef ); |
---|
| 1238 | bValid = false; |
---|
| 1239 | return; |
---|
[2] | 1240 | } |
---|
| 1241 | } |
---|
| 1242 | } |
---|
[56] | 1243 | if( bValid ) |
---|
| 1244 | { |
---|
| 1245 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
| 1246 | { |
---|
| 1247 | if( cWedgelet.checkInvIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
| 1248 | { |
---|
| 1249 | TComWedgeRef cWedgeRef; |
---|
| 1250 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
| 1251 | racWedgeRefList.push_back( cWedgeRef ); |
---|
| 1252 | bValid = false; |
---|
| 1253 | return; |
---|
| 1254 | } |
---|
| 1255 | } |
---|
| 1256 | } |
---|
| 1257 | if( bValid ) |
---|
| 1258 | { |
---|
| 1259 | racWedgeList.push_back( cWedgelet ); |
---|
| 1260 | TComWedgeRef cWedgeRef; |
---|
| 1261 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), (UInt)(racWedgeList.size()-1) ); |
---|
| 1262 | racWedgeRefList.push_back( cWedgeRef ); |
---|
| 1263 | } |
---|
[2] | 1264 | } |
---|
| 1265 | #endif |
---|
[56] | 1266 | |
---|
| 1267 | //! \} |
---|