Ticket #871: HM-9.0-dev_rev3097_no_zigzag_nsqt_scans.patch
File HM-9.0-dev_rev3097_no_zigzag_nsqt_scans.patch, 12.7 KB (added by joel, 11 years ago) |
---|
-
Lib/TLibCommon/TComDataCU.cpp
3745 3745 3746 3746 if ( !bIsIntra ) 3747 3747 { 3748 uiScanIdx = SCAN_ ZIGZAG;3748 uiScanIdx = SCAN_DIAG; 3749 3749 return uiScanIdx; 3750 3750 } 3751 3751 … … 3763 3763 if ( bIsLuma ) 3764 3764 { 3765 3765 uiDirMode = getLumaIntraDir(uiAbsPartIdx); 3766 uiScanIdx = SCAN_ ZIGZAG;3766 uiScanIdx = SCAN_DIAG; 3767 3767 if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size 3768 3768 { 3769 uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? 1 : (abs((Int)uiDirMode - HOR_IDX) < 5 ? 2 : 0);3769 uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); 3770 3770 } 3771 3771 } 3772 3772 else … … 3781 3781 // get luma mode from upper-left corner of current CU 3782 3782 uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); 3783 3783 } 3784 uiScanIdx = SCAN_ ZIGZAG;3784 uiScanIdx = SCAN_DIAG; 3785 3785 if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size 3786 3786 { 3787 uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? 1 : (abs((Int)uiDirMode - HOR_IDX) < 5 ? 2 : 0);3787 uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); 3788 3788 } 3789 3789 } 3790 3790 -
Lib/TLibCommon/TComRom.cpp
68 68 g_auiSigLastScan[0][i] = new UInt[ c*c ]; 69 69 g_auiSigLastScan[1][i] = new UInt[ c*c ]; 70 70 g_auiSigLastScan[2][i] = new UInt[ c*c ]; 71 g_auiSigLastScan[3][i] = new UInt[ c*c ]; 72 initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], g_auiSigLastScan[3][i], c, c, i); 71 initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], c, c, i); 73 72 74 73 c <<= 1; 75 74 } … … 84 83 delete[] g_auiSigLastScan[0][i]; 85 84 delete[] g_auiSigLastScan[1][i]; 86 85 delete[] g_auiSigLastScan[2][i]; 87 delete[] g_auiSigLastScan[3][i];88 86 } 89 87 } 90 88 … … 386 384 // ==================================================================================================================== 387 385 388 386 // scanning order table 389 UInt* g_auiSigLastScan[ 4][ MAX_CU_DEPTH ];387 UInt* g_auiSigLastScan[ 3 ][ MAX_CU_DEPTH ]; 390 388 391 const UInt g_sigLastScan8x8[ 4][ 4 ] =389 const UInt g_sigLastScan8x8[ 3 ][ 4 ] = 392 390 { 393 {0, 1, 2, 3},394 {0, 1, 2, 3},395 391 {0, 2, 1, 3}, 392 {0, 1, 2, 3}, 396 393 {0, 2, 1, 3} 397 394 }; 398 395 UInt g_sigLastScanCG32x32[ 64 ]; … … 411 408 8, 7, 6, 5, 4 412 409 }; 413 410 414 Void initSigLastScan(UInt* pBuff Z, UInt* pBuffH, UInt* pBuffV, UInt* pBuffD, Int iWidth, Int iHeight, Int iDepth)411 Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight, Int iDepth) 415 412 { 416 413 const UInt uiNumScanPos = UInt( iWidth * iWidth ); 417 414 UInt uiNextScanPos = 0; -
Lib/TLibCommon/TComRom.h
61 61 62 62 Void initROM(); 63 63 Void destroyROM(); 64 Void initSigLastScan(UInt* pBuff Z, UInt* pBuffH, UInt* pBuffV, UInt* pBuffD, Int iWidth, Int iHeight, Int iDepth);64 Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight, Int iDepth); 65 65 // ==================================================================================================================== 66 66 // Data structure related table & variable 67 67 // ==================================================================================================================== … … 122 122 // Scanning order & context mapping table 123 123 // ==================================================================================================================== 124 124 125 extern UInt* g_auiSigLastScan[ 4][ MAX_CU_DEPTH ]; // raster index from scanning index (zigzag, hor, ver, diag)125 extern UInt* g_auiSigLastScan[ 3 ][ MAX_CU_DEPTH ]; // raster index from scanning index (diag, hor, ver) 126 126 127 127 extern const UInt g_uiGroupIdx[ 32 ]; 128 128 extern const UInt g_uiMinInGroup[ 10 ]; … … 130 130 extern const UInt g_auiGoRiceRange[5]; //!< maximum value coded with Rice codes 131 131 extern const UInt g_auiGoRicePrefixLen[5]; //!< prefix length for each maximum value 132 132 133 extern const UInt g_sigLastScan8x8[ 4][ 4 ]; //!< coefficient group scan order for 8x8 TUs133 extern const UInt g_sigLastScan8x8[ 3 ][ 4 ]; //!< coefficient group scan order for 8x8 TUs 134 134 extern UInt g_sigLastScanCG32x32[ 64 ]; 135 135 136 136 // ==================================================================================================================== -
Lib/TLibCommon/TComTrQuant.cpp
1028 1028 const UInt log2BlockSize = g_aucConvertToBit[ iWidth ] + 2; 1029 1029 1030 1030 UInt scanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, iWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); 1031 if (scanIdx == SCAN_ZIGZAG)1032 {1033 scanIdx = SCAN_DIAG;1034 }1035 1036 1031 const UInt *scan = g_auiSigLastScan[ scanIdx ][ log2BlockSize - 1 ]; 1037 1032 1038 1033 Int deltaU[32*32] ; … … 1540 1535 Int iAddC = 1 << (iQBitsC-1); 1541 1536 #endif 1542 1537 UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); 1543 if (uiScanIdx == SCAN_ZIGZAG)1544 {1545 // Map value zigzag to diagonal scan1546 uiScanIdx = SCAN_DIAG;1547 }1548 Int blockType = uiLog2BlkSize;1549 1538 1550 1539 #if ADAPTIVE_QP_SELECTION 1551 1540 memset(piArlDstCoeff, 0, sizeof(Int) * uiMaxNumCoeff); … … 1658 1647 { 1659 1648 UInt uiPosY = uiBlkPos >> uiLog2BlkSize; 1660 1649 UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlkSize ); 1661 UShort uiCtxSig = getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );1650 UShort uiCtxSig = getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlkSize, uiWidth, uiHeight, eTType ); 1662 1651 uiLevel = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ], 1663 1652 lLevelDouble, uiMaxAbsLevel, uiCtxSig, uiOneCtx, uiAbsCtx, uiGoRiceParam, 1664 1653 c1Idx, c2Idx, iQBits, dTemp, 0 ); … … 2058 2047 * \param patternSigCtx pattern for current coefficient group 2059 2048 * \param posX column of current scan position 2060 2049 * \param posY row of current scan position 2061 * \param blockType log2 value of block size if square block, or 4 otherwise2050 * \param log2BlockSize log2 value of block size (square block) 2062 2051 * \param width width of the block 2063 2052 * \param height height of the block 2064 2053 * \param textureType texture type (TEXT_LUMA...) … … 2069 2058 UInt scanIdx, 2070 2059 Int posX, 2071 2060 Int posY, 2072 Int blockType,2061 Int log2BlockSize, 2073 2062 Int width 2074 2063 ,Int height 2075 2064 ,TextType textureType … … 2088 2077 return 0; 2089 2078 } 2090 2079 2091 if ( blockType == 2 )2080 if ( log2BlockSize == 2 ) 2092 2081 { 2093 2082 return ctxIndMap[ 4 * posY + posX ]; 2094 2083 } 2095 2084 2096 Int offset = blockType == 3 ? (scanIdx==SCAN_DIAG ? 9 : 15) : (textureType == TEXT_LUMA ? 21 : 12);2085 Int offset = log2BlockSize == 3 ? (scanIdx==SCAN_DIAG ? 9 : 15) : (textureType == TEXT_LUMA ? 21 : 12); 2097 2086 2098 2087 Int posXinSubset = posX-((posX>>2)<<2); 2099 2088 Int posYinSubset = posY-((posY>>2)<<2); -
Lib/TLibCommon/TComTrQuant.h
169 169 UInt scanIdx, 170 170 Int posX, 171 171 Int posY, 172 Int blockType,172 Int log2BlkSize, 173 173 Int width 174 174 ,Int height 175 175 ,TextType textureType -
Lib/TLibCommon/TypeDef.h
509 509 /// coefficient scanning type used in ACS 510 510 enum COEFF_SCAN_TYPE 511 511 { 512 SCAN_ZIGZAG = 0, ///< typical zigzag scan 513 SCAN_HOR, ///< horizontal first scan 514 SCAN_VER, ///< vertical first scan 515 SCAN_DIAG ///< up-right diagonal scan 512 SCAN_DIAG = 0, ///< up-right diagonal scan 513 SCAN_HOR, ///< horizontal first scan 514 SCAN_VER ///< vertical first scan 516 515 }; 517 516 518 517 namespace Profile -
Lib/TLibDecoder/TDecSbac.cpp
1076 1076 const UInt uiMaxNumCoeff = uiWidth * uiHeight; 1077 1077 const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; 1078 1078 UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); 1079 Int blockType = uiLog2BlockSize;1080 if (uiWidth != uiHeight)1081 {1082 uiScanIdx = SCAN_DIAG;1083 blockType = 4;1084 }1085 1079 1086 1080 //===== decode last significant ===== 1087 1081 UInt uiPosLastX, uiPosLastY; … … 1090 1084 pcCoef[ uiBlkPosLast ] = 1; 1091 1085 1092 1086 //===== decode significance flags ===== 1093 UInt uiScanPosLast = uiBlkPosLast; 1094 if (uiScanIdx == SCAN_ZIGZAG) 1095 { 1096 // Map zigzag to diagonal scan 1097 uiScanIdx = SCAN_DIAG; 1098 } 1099 const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ]; 1087 UInt uiScanPosLast = uiBlkPosLast; 1088 const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ]; 1100 1089 for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) 1101 1090 { 1102 1091 UInt uiBlkPos = scan[ uiScanPosLast ]; … … 1188 1177 { 1189 1178 if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) 1190 1179 { 1191 uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );1180 uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, uiWidth, uiHeight, eTType ); 1192 1181 m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); 1193 1182 } 1194 1183 else -
Lib/TLibEncoder/TEncSbac.cpp
1131 1131 eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); 1132 1132 1133 1133 //----- encode significance map ----- 1134 const UInt uiLog2BlockSize 1134 const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; 1135 1135 UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); 1136 if (uiScanIdx == SCAN_ZIGZAG)1137 {1138 // Map zigzag to diagonal scan1139 uiScanIdx = SCAN_DIAG;1140 }1141 Int blockType = uiLog2BlockSize;1142 if (uiWidth != uiHeight)1143 {1144 uiScanIdx = SCAN_DIAG;1145 blockType = 4;1146 }1147 1148 1136 const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize - 1 ]; 1149 1137 1150 1138 Bool beValid; … … 1259 1247 uiSig = (pcCoef[ uiBlkPos ] != 0); 1260 1248 if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) 1261 1249 { 1262 uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );1250 uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, uiWidth, uiHeight, eTType ); 1263 1251 m_pcBinIf->encodeBin( uiSig, baseCtx[ uiCtxSig ] ); 1264 1252 } 1265 1253 if( uiSig )