[2] | 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 |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
| 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. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 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 | */ |
---|
| 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 | |
---|
| 46 | //! \ingroup TLibCommon |
---|
| 47 | //! \{ |
---|
| 48 | |
---|
| 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 | #if !REMOVE_ZIGZAG_SCAN |
---|
| 69 | g_auiFrameScanXY[ i ] = new UInt[ c*c ]; |
---|
| 70 | g_auiFrameScanX [ i ] = new UInt[ c*c ]; |
---|
| 71 | g_auiFrameScanY [ i ] = new UInt[ c*c ]; |
---|
| 72 | initFrameScanXY( g_auiFrameScanXY[i], g_auiFrameScanX[i], g_auiFrameScanY[i], c, c ); |
---|
| 73 | #endif |
---|
| 74 | g_auiSigLastScan[0][i] = new UInt[ c*c ]; |
---|
| 75 | g_auiSigLastScan[1][i] = new UInt[ c*c ]; |
---|
| 76 | g_auiSigLastScan[2][i] = new UInt[ c*c ]; |
---|
| 77 | g_auiSigLastScan[3][i] = new UInt[ c*c ]; |
---|
| 78 | initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], g_auiSigLastScan[3][i], c, c, i); |
---|
| 79 | |
---|
| 80 | c <<= 1; |
---|
| 81 | } |
---|
| 82 | #if !REMOVE_NSQT |
---|
| 83 | g_sigScanNSQT[0] = new UInt[ 64 ]; // 4x16 |
---|
| 84 | g_sigScanNSQT[1] = new UInt[ 256 ]; // 8x32 |
---|
| 85 | g_sigScanNSQT[2] = new UInt[ 64 ]; // 16x4 |
---|
| 86 | g_sigScanNSQT[3] = new UInt[ 256 ]; // 32x8 |
---|
| 87 | |
---|
| 88 | static int diagScanX[ 16 ] = |
---|
| 89 | { |
---|
| 90 | 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 3, 2, 3, 3 |
---|
| 91 | }; |
---|
| 92 | static int diagScanY[ 16 ] = |
---|
| 93 | { |
---|
| 94 | 0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 3, 2, 3 |
---|
| 95 | }; |
---|
| 96 | |
---|
| 97 | Int j; |
---|
| 98 | // 4x16 scan |
---|
| 99 | for (i = 0; i < 4; i++) |
---|
| 100 | { |
---|
| 101 | for (j = 0; j < 16; j++) |
---|
| 102 | { |
---|
| 103 | g_sigScanNSQT[ 0 ][ 16 * i + j ] = 16 * i + 4 * diagScanY[ j ] + diagScanX[ j ]; |
---|
| 104 | } |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | // 8x32 scan |
---|
| 108 | for (i = 0; i < 16; i++) |
---|
| 109 | { |
---|
| 110 | Int x = g_sigCGScanNSQT[ 1 ][ i ] & 1; |
---|
| 111 | Int y = g_sigCGScanNSQT[ 1 ][ i ] >> 1; |
---|
| 112 | |
---|
| 113 | for (j = 0; j < 16; j++) |
---|
| 114 | { |
---|
| 115 | g_sigScanNSQT[ 1 ][ 16 * i + j ] = 32 * y + 4 * x + 8 * diagScanY[ j ] + diagScanX[ j ]; |
---|
| 116 | } |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | // 16x4 scan |
---|
| 120 | for (i = 0; i < 4; i++) |
---|
| 121 | { |
---|
| 122 | for (j = 0; j < 16; j++) |
---|
| 123 | { |
---|
| 124 | g_sigScanNSQT[ 2 ][ 16 * i + j ] = 4 * i + 16 * diagScanY[ j ] + diagScanX[ j ]; |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | // 32x8 scan |
---|
| 129 | for (i = 0; i < 16; i++) |
---|
| 130 | { |
---|
| 131 | Int x = g_sigCGScanNSQT[ 3 ][ i ] & 7; |
---|
| 132 | Int y = g_sigCGScanNSQT[ 3 ][ i ] >> 3; |
---|
| 133 | |
---|
| 134 | for (j = 0; j < 16; j++) |
---|
| 135 | { |
---|
| 136 | g_sigScanNSQT[ 3 ][ 16 * i + j ] = 128 * y + 4 * x + 32 * diagScanY[ j ] + diagScanX[ j ]; |
---|
| 137 | } |
---|
| 138 | } |
---|
| 139 | #endif |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | Void destroyROM() |
---|
| 143 | { |
---|
| 144 | Int i; |
---|
| 145 | |
---|
| 146 | for ( i=0; i<MAX_CU_DEPTH; i++ ) |
---|
| 147 | { |
---|
| 148 | #if !REMOVE_ZIGZAG_SCAN |
---|
| 149 | delete[] g_auiFrameScanXY[i]; |
---|
| 150 | delete[] g_auiFrameScanX [i]; |
---|
| 151 | delete[] g_auiFrameScanY [i]; |
---|
| 152 | #endif |
---|
| 153 | delete[] g_auiSigLastScan[0][i]; |
---|
| 154 | delete[] g_auiSigLastScan[1][i]; |
---|
| 155 | delete[] g_auiSigLastScan[2][i]; |
---|
| 156 | delete[] g_auiSigLastScan[3][i]; |
---|
| 157 | } |
---|
| 158 | #if !REMOVE_NSQT |
---|
| 159 | for (i = 0; i < 4; i++) |
---|
| 160 | { |
---|
| 161 | delete[] g_sigScanNSQT[ i ]; |
---|
| 162 | } |
---|
| 163 | #endif |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | // ==================================================================================================================== |
---|
| 167 | // Data structure related table & variable |
---|
| 168 | // ==================================================================================================================== |
---|
| 169 | |
---|
| 170 | UInt g_uiMaxCUWidth = MAX_CU_SIZE; |
---|
| 171 | UInt g_uiMaxCUHeight = MAX_CU_SIZE; |
---|
| 172 | UInt g_uiMaxCUDepth = MAX_CU_DEPTH; |
---|
| 173 | UInt g_uiAddCUDepth = 0; |
---|
| 174 | UInt g_auiZscanToRaster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 175 | UInt g_auiRasterToZscan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 176 | UInt g_auiRasterToPelX [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 177 | UInt g_auiRasterToPelY [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 178 | UInt g_motionRefer [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
| 179 | |
---|
| 180 | UInt g_auiPUOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5}; |
---|
| 181 | |
---|
| 182 | Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ) |
---|
| 183 | { |
---|
| 184 | Int iStride = 1 << ( iMaxDepth - 1 ); |
---|
| 185 | |
---|
| 186 | if ( iDepth == iMaxDepth ) |
---|
| 187 | { |
---|
| 188 | rpuiCurrIdx[0] = uiStartVal; |
---|
| 189 | rpuiCurrIdx++; |
---|
| 190 | } |
---|
| 191 | else |
---|
| 192 | { |
---|
| 193 | Int iStep = iStride >> iDepth; |
---|
| 194 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal, rpuiCurrIdx ); |
---|
| 195 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep, rpuiCurrIdx ); |
---|
| 196 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride, rpuiCurrIdx ); |
---|
| 197 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride+iStep, rpuiCurrIdx ); |
---|
| 198 | } |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
| 202 | { |
---|
| 203 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
| 204 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
| 205 | |
---|
| 206 | UInt uiNumPartInWidth = (UInt)uiMaxCUWidth / uiMinCUWidth; |
---|
| 207 | UInt uiNumPartInHeight = (UInt)uiMaxCUHeight / uiMinCUHeight; |
---|
| 208 | |
---|
| 209 | for ( UInt i = 0; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
| 210 | { |
---|
| 211 | g_auiRasterToZscan[ g_auiZscanToRaster[i] ] = i; |
---|
| 212 | } |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | /** generate motion data compression mapping table |
---|
| 216 | * \param uiMaxCUWidth, width of LCU |
---|
| 217 | * \param uiMaxCUHeight, hight of LCU |
---|
| 218 | * \param uiMaxDepth, max depth of LCU |
---|
| 219 | * \returns Void |
---|
| 220 | */ |
---|
| 221 | Void initMotionReferIdx ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
| 222 | { |
---|
| 223 | Int minSUWidth = (Int)uiMaxCUWidth >> ( (Int)uiMaxDepth - 1 ); |
---|
| 224 | Int minSUHeight = (Int)uiMaxCUHeight >> ( (Int)uiMaxDepth - 1 ); |
---|
| 225 | |
---|
| 226 | Int numPartInWidth = (Int)uiMaxCUWidth / (Int)minSUWidth; |
---|
| 227 | Int numPartInHeight = (Int)uiMaxCUHeight / (Int)minSUHeight; |
---|
| 228 | |
---|
| 229 | for ( Int i = 0; i < numPartInWidth*numPartInHeight; i++ ) |
---|
| 230 | { |
---|
| 231 | g_motionRefer[i] = i; |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | UInt maxCUDepth = g_uiMaxCUDepth - ( g_uiAddCUDepth - 1); |
---|
| 235 | Int minCUWidth = (Int)uiMaxCUWidth >> ( (Int)maxCUDepth - 1); |
---|
| 236 | |
---|
| 237 | if(!(minCUWidth == 8 && minSUWidth == 4)) //check if Minimum PU width == 4 |
---|
| 238 | { |
---|
| 239 | return; |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | Int compressionNum = 2; |
---|
| 243 | |
---|
| 244 | for ( Int i = numPartInWidth*(numPartInHeight-1); i < numPartInWidth*numPartInHeight; i += compressionNum*2) |
---|
| 245 | { |
---|
| 246 | for ( Int j = 1; j < compressionNum; j++ ) |
---|
| 247 | { |
---|
| 248 | g_motionRefer[g_auiRasterToZscan[i+j]] = g_auiRasterToZscan[i]; |
---|
| 249 | } |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | for ( Int i = numPartInWidth*(numPartInHeight-1)+compressionNum*2-1; i < numPartInWidth*numPartInHeight; i += compressionNum*2) |
---|
| 253 | { |
---|
| 254 | for ( Int j = 1; j < compressionNum; j++ ) |
---|
| 255 | { |
---|
| 256 | g_motionRefer[g_auiRasterToZscan[i-j]] = g_auiRasterToZscan[i]; |
---|
| 257 | } |
---|
| 258 | } |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
| 262 | { |
---|
| 263 | UInt i; |
---|
| 264 | |
---|
| 265 | UInt* uiTempX = &g_auiRasterToPelX[0]; |
---|
| 266 | UInt* uiTempY = &g_auiRasterToPelY[0]; |
---|
| 267 | |
---|
| 268 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
| 269 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
| 270 | |
---|
| 271 | UInt uiNumPartInWidth = uiMaxCUWidth / uiMinCUWidth; |
---|
| 272 | UInt uiNumPartInHeight = uiMaxCUHeight / uiMinCUHeight; |
---|
| 273 | |
---|
| 274 | uiTempX[0] = 0; uiTempX++; |
---|
| 275 | for ( i = 1; i < uiNumPartInWidth; i++ ) |
---|
| 276 | { |
---|
| 277 | uiTempX[0] = uiTempX[-1] + uiMinCUWidth; uiTempX++; |
---|
| 278 | } |
---|
| 279 | for ( i = 1; i < uiNumPartInHeight; i++ ) |
---|
| 280 | { |
---|
| 281 | memcpy(uiTempX, uiTempX-uiNumPartInWidth, sizeof(UInt)*uiNumPartInWidth); |
---|
| 282 | uiTempX += uiNumPartInWidth; |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | for ( i = 1; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
| 286 | { |
---|
| 287 | uiTempY[i] = ( i / uiNumPartInWidth ) * uiMinCUWidth; |
---|
| 288 | } |
---|
| 289 | }; |
---|
| 290 | |
---|
| 291 | |
---|
| 292 | Int g_quantScales[6] = |
---|
| 293 | { |
---|
| 294 | 26214,23302,20560,18396,16384,14564 |
---|
| 295 | }; |
---|
| 296 | |
---|
| 297 | Int g_invQuantScales[6] = |
---|
| 298 | { |
---|
| 299 | 40,45,51,57,64,72 |
---|
| 300 | }; |
---|
| 301 | |
---|
| 302 | const short g_aiT4[4][4] = |
---|
| 303 | { |
---|
| 304 | { 64, 64, 64, 64}, |
---|
| 305 | { 83, 36,-36,-83}, |
---|
| 306 | { 64,-64,-64, 64}, |
---|
| 307 | { 36,-83, 83,-36} |
---|
| 308 | }; |
---|
| 309 | |
---|
| 310 | const short g_aiT8[8][8] = |
---|
| 311 | { |
---|
| 312 | { 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
| 313 | { 89, 75, 50, 18,-18,-50,-75,-89}, |
---|
| 314 | { 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
| 315 | { 75,-18,-89,-50, 50, 89, 18,-75}, |
---|
| 316 | { 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
| 317 | { 50,-89, 18, 75,-75,-18, 89,-50}, |
---|
| 318 | { 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
| 319 | { 18,-50, 75,-89, 89,-75, 50,-18} |
---|
| 320 | }; |
---|
| 321 | |
---|
| 322 | const short g_aiT16[16][16] = |
---|
| 323 | { |
---|
| 324 | { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
| 325 | { 90, 87, 80, 70, 57, 43, 25, 9, -9,-25,-43,-57,-70,-80,-87,-90}, |
---|
| 326 | { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89}, |
---|
| 327 | { 87, 57, 9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87}, |
---|
| 328 | { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
| 329 | { 80, 9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80}, |
---|
| 330 | { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75}, |
---|
| 331 | { 70,-43,-87, 9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70}, |
---|
| 332 | { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
| 333 | { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87, 9,-90, 25, 80,-57}, |
---|
| 334 | { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50}, |
---|
| 335 | { 43,-90, 57, 25,-87, 70, 9,-80, 80, -9,-70, 87,-25,-57, 90,-43}, |
---|
| 336 | { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
| 337 | { 25,-70, 90,-80, 43, 9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25}, |
---|
| 338 | { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18}, |
---|
| 339 | { 9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9} |
---|
| 340 | }; |
---|
| 341 | |
---|
| 342 | const short g_aiT32[32][32] = |
---|
| 343 | { |
---|
| 344 | { 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}, |
---|
| 345 | { 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}, |
---|
| 346 | { 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}, |
---|
| 347 | { 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}, |
---|
| 348 | { 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}, |
---|
| 349 | { 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}, |
---|
| 350 | { 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}, |
---|
| 351 | { 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}, |
---|
| 352 | { 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}, |
---|
| 353 | { 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}, |
---|
| 354 | { 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}, |
---|
| 355 | { 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}, |
---|
| 356 | { 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}, |
---|
| 357 | { 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}, |
---|
| 358 | { 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}, |
---|
| 359 | { 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}, |
---|
| 360 | { 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}, |
---|
| 361 | { 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}, |
---|
| 362 | { 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}, |
---|
| 363 | { 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}, |
---|
| 364 | { 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}, |
---|
| 365 | { 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}, |
---|
| 366 | { 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}, |
---|
| 367 | { 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}, |
---|
| 368 | { 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}, |
---|
| 369 | { 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}, |
---|
| 370 | { 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}, |
---|
| 371 | { 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}, |
---|
| 372 | { 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}, |
---|
| 373 | { 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}, |
---|
| 374 | { 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}, |
---|
| 375 | { 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} |
---|
| 376 | }; |
---|
| 377 | |
---|
| 378 | #if CHROMA_QP_EXTENSION |
---|
| 379 | const UChar g_aucChromaScale[58]= |
---|
| 380 | { |
---|
| 381 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, |
---|
| 382 | 17,18,19,20,21,22,23,24,25,26,27,28,29,29,30,31,32, |
---|
| 383 | 33,33,34,34,35,35,36,36,37,37,38,39,40,41,42,43,44, |
---|
| 384 | 45,46,47,48,49,50,51 |
---|
| 385 | }; |
---|
| 386 | #else |
---|
| 387 | const UChar g_aucChromaScale[52]= |
---|
| 388 | { |
---|
| 389 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11, |
---|
| 390 | 12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27, |
---|
| 391 | 28,29,29,30,31,32,32,33,34,34,35,35,36,36,37,37, |
---|
| 392 | 37,38,38,38,39,39,39,39 |
---|
| 393 | }; |
---|
| 394 | #endif |
---|
| 395 | |
---|
| 396 | |
---|
| 397 | // Mode-Dependent DCT/DST |
---|
| 398 | const short g_as_DST_MAT_4 [4][4]= |
---|
| 399 | { |
---|
| 400 | {29, 55, 74, 84}, |
---|
| 401 | {74, 74, 0 , -74}, |
---|
| 402 | {84, -29, -74, 55}, |
---|
| 403 | {55, -84, 74, -29}, |
---|
| 404 | }; |
---|
| 405 | |
---|
| 406 | |
---|
| 407 | // ==================================================================================================================== |
---|
| 408 | // ADI |
---|
| 409 | // ==================================================================================================================== |
---|
| 410 | |
---|
| 411 | #if FAST_UDI_USE_MPM |
---|
| 412 | const UChar g_aucIntraModeNumFast[7] = |
---|
| 413 | { |
---|
| 414 | 3, // 2x2 |
---|
| 415 | 8, // 4x4 |
---|
| 416 | 8, // 8x8 |
---|
| 417 | 3, // 16x16 |
---|
| 418 | 3, // 32x32 |
---|
| 419 | 3, // 64x64 |
---|
| 420 | 3 // 128x128 |
---|
| 421 | }; |
---|
| 422 | #else // FAST_UDI_USE_MPM |
---|
| 423 | const UChar g_aucIntraModeNumFast[7] = |
---|
| 424 | { |
---|
| 425 | 3, // 2x2 |
---|
| 426 | 9, // 4x4 |
---|
| 427 | 9, // 8x8 |
---|
| 428 | 4, // 16x16 33 |
---|
| 429 | 4, // 32x32 33 |
---|
| 430 | 5, // 64x64 33 |
---|
| 431 | 4 // 128x128 33 |
---|
| 432 | }; |
---|
| 433 | #endif // FAST_UDI_USE_MPM |
---|
| 434 | |
---|
| 435 | // chroma |
---|
| 436 | |
---|
| 437 | const UChar g_aucConvertTxtTypeToIdx[4] = { 0, 1, 1, 2 }; |
---|
| 438 | |
---|
| 439 | |
---|
| 440 | // ==================================================================================================================== |
---|
| 441 | // Bit-depth |
---|
| 442 | // ==================================================================================================================== |
---|
| 443 | |
---|
| 444 | UInt g_uiBitDepth = 8; // base bit-depth |
---|
| 445 | UInt g_uiBitIncrement = 0; // increments |
---|
| 446 | UInt g_uiIBDI_MAX = 255; // max. value after IBDI |
---|
| 447 | UInt g_uiBASE_MAX = 255; // max. value before IBDI |
---|
| 448 | |
---|
| 449 | UInt g_uiPCMBitDepthLuma = 8; // PCM bit-depth |
---|
| 450 | UInt g_uiPCMBitDepthChroma = 8; // PCM bit-depth |
---|
| 451 | |
---|
| 452 | // ==================================================================================================================== |
---|
| 453 | // Misc. |
---|
| 454 | // ==================================================================================================================== |
---|
| 455 | |
---|
| 456 | Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; |
---|
| 457 | |
---|
| 458 | #if ENC_DEC_TRACE |
---|
| 459 | FILE* g_hTrace = NULL; |
---|
| 460 | const Bool g_bEncDecTraceEnable = true; |
---|
| 461 | const Bool g_bEncDecTraceDisable = false; |
---|
| 462 | Bool g_HLSTraceEnable = true; |
---|
| 463 | Bool g_bJustDoIt = false; |
---|
| 464 | UInt64 g_nSymbolCounter = 0; |
---|
| 465 | #endif |
---|
| 466 | // ==================================================================================================================== |
---|
| 467 | // Scanning order & context model mapping |
---|
| 468 | // ==================================================================================================================== |
---|
| 469 | |
---|
| 470 | // scanning order table |
---|
| 471 | #if !REMOVE_ZIGZAG_SCAN |
---|
| 472 | UInt* g_auiFrameScanXY[ MAX_CU_DEPTH ]; |
---|
| 473 | UInt* g_auiFrameScanX [ MAX_CU_DEPTH ]; |
---|
| 474 | UInt* g_auiFrameScanY [ MAX_CU_DEPTH ]; |
---|
| 475 | #endif |
---|
| 476 | UInt* g_auiSigLastScan[4][ MAX_CU_DEPTH ]; |
---|
| 477 | #if !REMOVE_NSQT |
---|
| 478 | UInt *g_sigScanNSQT[ 4 ]; // scan for non-square partitions |
---|
| 479 | UInt g_sigCGScanNSQT[ 4 ][ 16 ] = |
---|
| 480 | { |
---|
| 481 | { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
---|
| 482 | { 0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15 }, |
---|
| 483 | { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
---|
| 484 | { 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15 } |
---|
| 485 | }; |
---|
| 486 | #endif |
---|
| 487 | |
---|
| 488 | const UInt g_sigLastScan8x8[ 4 ][ 4 ] = |
---|
| 489 | { |
---|
| 490 | {0, 1, 2, 3}, |
---|
| 491 | {0, 1, 2, 3}, |
---|
| 492 | #if REMOVAL_8x2_2x8_CG |
---|
| 493 | {0, 2, 1, 3}, |
---|
| 494 | #else |
---|
| 495 | {0, 1, 2, 3}, |
---|
| 496 | #endif |
---|
| 497 | {0, 2, 1, 3} |
---|
| 498 | }; |
---|
| 499 | UInt g_sigLastScanCG32x32[ 64 ]; |
---|
| 500 | |
---|
| 501 | UInt* g_auiNonSquareSigLastScan[ 4 ]; |
---|
| 502 | |
---|
| 503 | const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24}; |
---|
| 504 | 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}; |
---|
| 505 | |
---|
| 506 | // Rice parameters for absolute transform levels |
---|
| 507 | const UInt g_auiGoRiceRange[5] = |
---|
| 508 | { |
---|
| 509 | 7, 14, 26, 46, 78 |
---|
| 510 | }; |
---|
| 511 | |
---|
| 512 | const UInt g_auiGoRicePrefixLen[5] = |
---|
| 513 | { |
---|
| 514 | 8, 7, 6, 5, 4 |
---|
| 515 | }; |
---|
| 516 | |
---|
| 517 | #if !REMOVE_ZIGZAG_SCAN |
---|
| 518 | // initialize g_auiFrameScanXY |
---|
| 519 | Void initFrameScanXY( UInt* pBuff, UInt* pBuffX, UInt* pBuffY, Int iWidth, Int iHeight ) |
---|
| 520 | { |
---|
| 521 | Int x, y, c = 0; |
---|
| 522 | |
---|
| 523 | // starting point |
---|
| 524 | pBuffX[ c ] = 0; |
---|
| 525 | pBuffY[ c ] = 0; |
---|
| 526 | pBuff[ c++ ] = 0; |
---|
| 527 | |
---|
| 528 | // loop |
---|
| 529 | x=1; y=0; |
---|
| 530 | while (1) |
---|
| 531 | { |
---|
| 532 | // decrease loop |
---|
| 533 | while ( x>=0 ) |
---|
| 534 | { |
---|
| 535 | if ( x >= 0 && x < iWidth && y >= 0 && y < iHeight ) |
---|
| 536 | { |
---|
| 537 | pBuffX[ c ] = x; |
---|
| 538 | pBuffY[ c ] = y; |
---|
| 539 | pBuff[ c++ ] = x+y*iWidth; |
---|
| 540 | } |
---|
| 541 | x--; y++; |
---|
| 542 | } |
---|
| 543 | x=0; |
---|
| 544 | |
---|
| 545 | // increase loop |
---|
| 546 | while ( y>=0 ) |
---|
| 547 | { |
---|
| 548 | if ( x >= 0 && x < iWidth && y >= 0 && y < iHeight ) |
---|
| 549 | { |
---|
| 550 | pBuffX[ c ] = x; |
---|
| 551 | pBuffY[ c ] = y; |
---|
| 552 | pBuff[ c++ ] = x+y*iWidth; |
---|
| 553 | } |
---|
| 554 | x++; y--; |
---|
| 555 | } |
---|
| 556 | y=0; |
---|
| 557 | |
---|
| 558 | // termination condition |
---|
| 559 | if ( c >= iWidth*iHeight ) break; |
---|
| 560 | } |
---|
| 561 | } |
---|
| 562 | #endif |
---|
| 563 | |
---|
| 564 | Void initSigLastScan(UInt* pBuffZ, UInt* pBuffH, UInt* pBuffV, UInt* pBuffD, Int iWidth, Int iHeight, Int iDepth) |
---|
| 565 | { |
---|
| 566 | const UInt uiNumScanPos = UInt( iWidth * iWidth ); |
---|
| 567 | UInt uiNextScanPos = 0; |
---|
| 568 | |
---|
| 569 | if( iWidth < 16 ) |
---|
| 570 | { |
---|
| 571 | UInt* pBuffTemp = pBuffD; |
---|
| 572 | if( iWidth == 8 ) |
---|
| 573 | { |
---|
| 574 | pBuffTemp = g_sigLastScanCG32x32; |
---|
| 575 | } |
---|
| 576 | for( UInt uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ ) |
---|
| 577 | { |
---|
| 578 | int iPrimDim = int( uiScanLine ); |
---|
| 579 | int iScndDim = 0; |
---|
| 580 | while( iPrimDim >= iWidth ) |
---|
| 581 | { |
---|
| 582 | iScndDim++; |
---|
| 583 | iPrimDim--; |
---|
| 584 | } |
---|
| 585 | while( iPrimDim >= 0 && iScndDim < iWidth ) |
---|
| 586 | { |
---|
| 587 | pBuffTemp[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ; |
---|
| 588 | uiNextScanPos++; |
---|
| 589 | iScndDim++; |
---|
| 590 | iPrimDim--; |
---|
| 591 | } |
---|
| 592 | } |
---|
| 593 | } |
---|
| 594 | if( iWidth > 4 ) |
---|
| 595 | { |
---|
| 596 | UInt uiNumBlkSide = iWidth >> 2; |
---|
| 597 | UInt uiNumBlks = uiNumBlkSide * uiNumBlkSide; |
---|
| 598 | UInt log2Blk = g_aucConvertToBit[ uiNumBlkSide ] + 1; |
---|
| 599 | |
---|
| 600 | for( UInt uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ ) |
---|
| 601 | { |
---|
| 602 | uiNextScanPos = 0; |
---|
| 603 | UInt initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ]; |
---|
| 604 | if( iWidth == 32 ) |
---|
| 605 | { |
---|
| 606 | initBlkPos = g_sigLastScanCG32x32[ uiBlk ]; |
---|
| 607 | } |
---|
| 608 | UInt offsetY = initBlkPos / uiNumBlkSide; |
---|
| 609 | UInt offsetX = initBlkPos - offsetY * uiNumBlkSide; |
---|
| 610 | UInt offsetD = 4 * ( offsetX + offsetY * iWidth ); |
---|
| 611 | UInt offsetScan = 16 * uiBlk; |
---|
| 612 | for( UInt uiScanLine = 0; uiNextScanPos < 16; uiScanLine++ ) |
---|
| 613 | { |
---|
| 614 | int iPrimDim = int( uiScanLine ); |
---|
| 615 | int iScndDim = 0; |
---|
| 616 | while( iPrimDim >= 4 ) |
---|
| 617 | { |
---|
| 618 | iScndDim++; |
---|
| 619 | iPrimDim--; |
---|
| 620 | } |
---|
| 621 | while( iPrimDim >= 0 && iScndDim < 4 ) |
---|
| 622 | { |
---|
| 623 | pBuffD[ uiNextScanPos + offsetScan ] = iPrimDim * iWidth + iScndDim + offsetD; |
---|
| 624 | uiNextScanPos++; |
---|
| 625 | iScndDim++; |
---|
| 626 | iPrimDim--; |
---|
| 627 | } |
---|
| 628 | } |
---|
| 629 | } |
---|
| 630 | } |
---|
| 631 | |
---|
| 632 | #if !REMOVE_ZIGZAG_SCAN |
---|
| 633 | memcpy(pBuffZ, g_auiFrameScanXY[iDepth], sizeof(UInt)*iWidth*iHeight); |
---|
| 634 | #endif |
---|
| 635 | |
---|
| 636 | UInt uiCnt = 0; |
---|
| 637 | #if REMOVAL_8x2_2x8_CG |
---|
| 638 | if( iWidth > 2 ) |
---|
| 639 | { |
---|
| 640 | UInt numBlkSide = iWidth >> 2; |
---|
| 641 | for(Int blkY=0; blkY < numBlkSide; blkY++) |
---|
| 642 | { |
---|
| 643 | for(Int blkX=0; blkX < numBlkSide; blkX++) |
---|
| 644 | { |
---|
| 645 | UInt offset = blkY * 4 * iWidth + blkX * 4; |
---|
| 646 | for(Int y=0; y < 4; y++) |
---|
| 647 | { |
---|
| 648 | for(Int x=0; x < 4; x++) |
---|
| 649 | { |
---|
| 650 | pBuffH[uiCnt] = y*iWidth + x + offset; |
---|
| 651 | uiCnt ++; |
---|
| 652 | } |
---|
| 653 | } |
---|
| 654 | } |
---|
| 655 | } |
---|
| 656 | |
---|
| 657 | uiCnt = 0; |
---|
| 658 | for(Int blkX=0; blkX < numBlkSide; blkX++) |
---|
| 659 | { |
---|
| 660 | for(Int blkY=0; blkY < numBlkSide; blkY++) |
---|
| 661 | { |
---|
| 662 | UInt offset = blkY * 4 * iWidth + blkX * 4; |
---|
| 663 | for(Int x=0; x < 4; x++) |
---|
| 664 | { |
---|
| 665 | for(Int y=0; y < 4; y++) |
---|
| 666 | { |
---|
| 667 | pBuffV[uiCnt] = y*iWidth + x + offset; |
---|
| 668 | uiCnt ++; |
---|
| 669 | } |
---|
| 670 | } |
---|
| 671 | } |
---|
| 672 | } |
---|
| 673 | } |
---|
| 674 | else |
---|
| 675 | { |
---|
| 676 | #endif |
---|
| 677 | for(Int iY=0; iY < iHeight; iY++) |
---|
| 678 | { |
---|
| 679 | for(Int iX=0; iX < iWidth; iX++) |
---|
| 680 | { |
---|
| 681 | pBuffH[uiCnt] = iY*iWidth + iX; |
---|
| 682 | uiCnt ++; |
---|
| 683 | } |
---|
| 684 | } |
---|
| 685 | |
---|
| 686 | uiCnt = 0; |
---|
| 687 | for(Int iX=0; iX < iWidth; iX++) |
---|
| 688 | { |
---|
| 689 | for(Int iY=0; iY < iHeight; iY++) |
---|
| 690 | { |
---|
| 691 | pBuffV[uiCnt] = iY*iWidth + iX; |
---|
| 692 | uiCnt ++; |
---|
| 693 | } |
---|
| 694 | } |
---|
| 695 | #if REMOVAL_8x2_2x8_CG |
---|
| 696 | } |
---|
| 697 | #endif |
---|
| 698 | } |
---|
| 699 | |
---|
| 700 | Void initNonSquareSigLastScan(UInt* pBuffZ, UInt uiWidth, UInt uiHeight) |
---|
| 701 | { |
---|
| 702 | |
---|
| 703 | Int x, y, c = 0; |
---|
| 704 | |
---|
| 705 | // starting point |
---|
| 706 | pBuffZ[ c++ ] = 0; |
---|
| 707 | |
---|
| 708 | // loop |
---|
| 709 | if ( uiWidth > uiHeight ) |
---|
| 710 | { |
---|
| 711 | x=0; y=1; |
---|
| 712 | while (1) |
---|
| 713 | { |
---|
| 714 | // increase loop |
---|
| 715 | while ( y>=0 ) |
---|
| 716 | { |
---|
| 717 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
| 718 | { |
---|
| 719 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
| 720 | } |
---|
| 721 | x++; |
---|
| 722 | y--; |
---|
| 723 | } |
---|
| 724 | y=0; |
---|
| 725 | |
---|
| 726 | // decrease loop |
---|
| 727 | while ( x>=0 ) |
---|
| 728 | { |
---|
| 729 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
| 730 | { |
---|
| 731 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
| 732 | } |
---|
| 733 | x--; |
---|
| 734 | y++; |
---|
| 735 | } |
---|
| 736 | x=0; |
---|
| 737 | |
---|
| 738 | // termination condition |
---|
| 739 | if ( c >= uiWidth * uiHeight ) |
---|
| 740 | { |
---|
| 741 | break; |
---|
| 742 | } |
---|
| 743 | } |
---|
| 744 | } |
---|
| 745 | else |
---|
| 746 | { |
---|
| 747 | x=1; y=0; |
---|
| 748 | while (1) |
---|
| 749 | { |
---|
| 750 | // increase loop |
---|
| 751 | while ( x>=0 ) |
---|
| 752 | { |
---|
| 753 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
| 754 | { |
---|
| 755 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
| 756 | } |
---|
| 757 | x--; |
---|
| 758 | y++; |
---|
| 759 | } |
---|
| 760 | x=0; |
---|
| 761 | |
---|
| 762 | // decrease loop |
---|
| 763 | while ( y>=0 ) |
---|
| 764 | { |
---|
| 765 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
| 766 | { |
---|
| 767 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
| 768 | } |
---|
| 769 | x++; |
---|
| 770 | y--; |
---|
| 771 | } |
---|
| 772 | y=0; |
---|
| 773 | |
---|
| 774 | // termination condition |
---|
| 775 | if ( c >= uiWidth * uiHeight ) |
---|
| 776 | { |
---|
| 777 | break; |
---|
| 778 | } |
---|
| 779 | } |
---|
| 780 | } |
---|
| 781 | } |
---|
| 782 | |
---|
| 783 | Int g_quantIntraDefault4x4[16] = |
---|
| 784 | { |
---|
| 785 | 16,16,17,21, |
---|
| 786 | 16,17,20,25, |
---|
| 787 | 17,20,30,41, |
---|
| 788 | 21,25,41,70 |
---|
| 789 | }; |
---|
| 790 | Int g_quantInterDefault4x4[16] = |
---|
| 791 | { |
---|
| 792 | 16,16,17,21, |
---|
| 793 | 16,17,21,24, |
---|
| 794 | 17,21,24,36, |
---|
| 795 | 21,24,36,57 |
---|
| 796 | }; |
---|
| 797 | #if TS_FLAT_QUANTIZATION_MATRIX |
---|
| 798 | Int g_quantTSDefault4x4[16] = |
---|
| 799 | { |
---|
| 800 | 16,16,16,16, |
---|
| 801 | 16,16,16,16, |
---|
| 802 | 16,16,16,16, |
---|
| 803 | 16,16,16,16 |
---|
| 804 | }; |
---|
| 805 | #endif |
---|
| 806 | |
---|
| 807 | Int g_quantIntraDefault8x8[64] = |
---|
| 808 | { |
---|
| 809 | 16,16,16,16,17,18,21,24, |
---|
| 810 | 16,16,16,16,17,19,22,25, |
---|
| 811 | 16,16,17,18,20,22,25,29, |
---|
| 812 | 16,16,18,21,24,27,31,36, |
---|
| 813 | 17,17,20,24,30,35,41,47, |
---|
| 814 | 18,19,22,27,35,44,54,65, |
---|
| 815 | 21,22,25,31,41,54,70,88, |
---|
| 816 | 24,25,29,36,47,65,88,115 |
---|
| 817 | }; |
---|
| 818 | |
---|
| 819 | Int g_quantInterDefault8x8[64] = |
---|
| 820 | { |
---|
| 821 | 16,16,16,16,17,18,20,24, |
---|
| 822 | 16,16,16,17,18,20,24,25, |
---|
| 823 | 16,16,17,18,20,24,25,28, |
---|
| 824 | 16,17,18,20,24,25,28,33, |
---|
| 825 | 17,18,20,24,25,28,33,41, |
---|
| 826 | 18,20,24,25,28,33,41,54, |
---|
| 827 | 20,24,25,28,33,41,54,71, |
---|
| 828 | 24,25,28,33,41,54,71,91 |
---|
| 829 | }; |
---|
| 830 | UInt g_scalingListSize [4] = {16,64,256,1024}; |
---|
| 831 | UInt g_scalingListSizeX [4] = { 4, 8, 16, 32}; |
---|
| 832 | UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2}; |
---|
| 833 | Int g_eTTable[4] = {0,3,1,2}; |
---|
| 834 | |
---|
| 835 | //! \} |
---|