Ticket #596: 14-bit-fixes-HM71rc1_560_595_596_20120628.patch
File 14-bit-fixes-HM71rc1_560_595_596_20120628.patch, 9.8 KB (added by pandrivon, 11 years ago) |
---|
-
source/Lib/TLibCommon/CommonDef.h
112 112 113 113 #define MAX_UINT 0xFFFFFFFFU ///< max. value of unsigned 32-bit integer 114 114 #define MAX_INT 2147483647 ///< max. value of signed 32-bit integer 115 #define MAX_INT64 0x7FFFFFFFFFFFFFFF ///< max. value of signed 64-bit integer 115 116 #define MAX_DOUBLE 1.7e+308 ///< max. value of double-type value 116 117 117 118 #define MIN_QP 0 -
source/Lib/TLibCommon/TComInterpolationFilter.cpp
124 124 else 125 125 { 126 126 Int shift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); 127 Short offset = IF_INTERNAL_OFFS + (1 << (shift - 1)); 127 Short offset = IF_INTERNAL_OFFS; 128 offset += shift?(1 << (shift - 1)):0; 128 129 Short maxVal = g_uiIBDI_MAX; 129 130 Short minVal = 0; 130 131 for (row = 0; row < height; row++) -
source/Lib/TLibCommon/TComTrQuant.cpp
1173 1173 #else 1174 1174 UInt uiBitDepth = g_uiBitDepth + g_uiBitIncrement; 1175 1175 #endif 1176 UInt iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize; // Represents scaling through forward transform1176 Int iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize; // Represents scaling through forward transform 1177 1177 1178 1178 Int iQBits = QUANT_SHIFT + m_cQP.m_iPer + iTransformShift; // Right shift of non-RDOQ quantizer; level = (coeff*uiQ + offset)>>q_bits 1179 1179 … … 1252 1252 #else 1253 1253 UInt uiBitDepth = g_uiBitDepth + g_uiBitIncrement; 1254 1254 #endif 1255 UInt iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize;1255 Int iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize; 1256 1256 1257 1257 iShift = QUANT_IQUANT_SHIFT - QUANT_SHIFT - iTransformShift; 1258 1258 … … 1636 1636 #else 1637 1637 UInt uiBitDepth = g_uiBitDepth + g_uiBitIncrement; 1638 1638 #endif 1639 UInt iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize; 1640 Int j,k; 1641 for (j = 0; j < height; j++) 1642 { 1643 for(k = 0; k < width; k ++) 1644 { 1645 psCoeff[j*height + k] = piBlkResi[j * uiStride + k] << iTransformShift; 1639 Int shift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize; 1640 UInt transformSkipShift; 1641 Int j,k; 1642 if(shift >= 0) 1643 { 1644 transformSkipShift = shift; 1645 for (j = 0; j < height; j++) 1646 { 1647 for(k = 0; k < width; k ++) 1648 { 1649 psCoeff[j*height + k] = piBlkResi[j * uiStride + k] << transformSkipShift; 1650 } 1646 1651 } 1647 1652 } 1653 else 1654 { 1655 //The case when uiBitDepth > 13 1656 UInt iAdd; 1657 transformSkipShift = -shift; 1658 iAdd = (1 << (transformSkipShift -1)); 1659 for (j = 0; j < height; j++) 1660 { 1661 for(k = 0; k < width; k ++) 1662 { 1663 psCoeff[j*height + k] = (piBlkResi[j * uiStride + k] + iAdd) >> transformSkipShift; 1664 } 1665 } 1666 } 1648 1667 } 1649 1668 1650 1669 /** Wrapper function between HM interface and core NxN transform skipping … … 1662 1681 #else 1663 1682 UInt uiBitDepth = g_uiBitDepth + g_uiBitIncrement; 1664 1683 #endif 1665 UInt iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize; 1666 UInt iAdd = (1 << (iTransformShift -1)); 1667 Int j,k; 1668 for ( j = 0; j < height; j++ ) 1669 { 1670 for(k = 0; k < width; k ++) 1671 { 1672 pResidual[j * uiStride + k] = (plCoef[j*width+k] + iAdd) >> iTransformShift; 1684 Int shift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize; 1685 UInt transformSkipShift; 1686 Int j,k; 1687 if(shift > 0) 1688 { 1689 UInt iAdd; 1690 transformSkipShift = shift; 1691 iAdd = (1 << (transformSkipShift -1)); 1692 for ( j = 0; j < height; j++ ) 1693 { 1694 for(k = 0; k < width; k ++) 1695 { 1696 pResidual[j * uiStride + k] = (plCoef[j*width+k] + iAdd) >> transformSkipShift; 1697 } 1673 1698 } 1674 1699 } 1700 else 1701 { 1702 //The case when uiBitDepth >= 13 1703 transformSkipShift = - shift; 1704 for ( j = 0; j < height; j++ ) 1705 { 1706 for(k = 0; k < width; k ++) 1707 { 1708 pResidual[j * uiStride + k] = plCoef[j*width+k] << transformSkipShift; 1709 } 1710 } 1711 } 1675 1712 } 1676 1713 #endif 1677 1714 … … 2127 2164 2128 2165 if( pcCU->getSlice()->getPPS()->getSignHideFlag() && uiAbsSum>=2) 2129 2166 { 2130 Int rdFactor = (Int)((Double)(g_invQuantScales[m_cQP.rem()]*g_invQuantScales[m_cQP.rem()]<<(2*m_cQP.m_iPer))/m_dLambda/16 + 0.5) ;2167 Int64 rdFactor = (Int64)((Double)((Int64)g_invQuantScales[m_cQP.rem()]*(Int64)g_invQuantScales[m_cQP.rem()]<<(2*(Int64)m_cQP.m_iPer))/m_dLambda/16 + 0.5) ; 2131 2168 #if !FIXED_SBH_THRESHOLD 2132 2169 Int tsig = pcCU->getSlice()->getPPS()->getTSIG() ; 2133 2170 #endif … … 2176 2213 if( signbit!=(absSum&0x1) ) // hide but need tune 2177 2214 { 2178 2215 // calculate the cost 2179 Int minCostInc = MAX_INT, minPos =-1, finalChange=0, curCost=MAX_INT, curChange=0; 2216 Int64 minCostInc = MAX_INT64, curCost=MAX_INT64; 2217 Int minPos =-1, finalChange=0, curChange=0; 2180 2218 2181 2219 for( n = (lastCG==1?lastNZPosInCG:SCAN_SET_SIZE-1) ; n >= 0; --n ) 2182 2220 { 2183 2221 UInt uiBlkPos = scan[ n + subPos ]; 2184 2222 if(piDstCoeff[ uiBlkPos ] != 0 ) 2185 2223 { 2186 Int costUp = rdFactor * (- deltaU[uiBlkPos] ) + rateIncUp[uiBlkPos] ;2187 Int costDown = rdFactor * (deltaU[uiBlkPos] ) + rateIncDown[uiBlkPos]2224 Int64 costUp = rdFactor * ( (Int64)- deltaU[uiBlkPos] ) + rateIncUp[uiBlkPos] ; 2225 Int64 costDown = rdFactor * ( (Int64) deltaU[uiBlkPos] ) + rateIncDown[uiBlkPos] 2188 2226 - ( abs(piDstCoeff[uiBlkPos])==1?((1<<15)+sigRateDelta[uiBlkPos]):0 ); 2189 2227 2190 2228 if(lastCG==1 && lastNZPosInCG==n && abs(piDstCoeff[uiBlkPos])==1) … … 2202 2240 curChange = -1 ; 2203 2241 if(n==firstNZPosInCG && abs(piDstCoeff[uiBlkPos])==1) 2204 2242 { 2205 curCost = MAX_INT ;2243 curCost = MAX_INT64 ; 2206 2244 } 2207 2245 else 2208 2246 { … … 2220 2258 UInt thissignbit = (plSrcCoeff[uiBlkPos]>=0?0:1); 2221 2259 if(thissignbit != signbit ) 2222 2260 { 2223 curCost = MAX_INT ;2261 curCost = MAX_INT64; 2224 2262 } 2225 2263 } 2226 2264 } -
source/Lib/TLibCommon/TComWeightPrediction.cpp
79 79 Int offset = wp0[0].offset; 80 80 Int shiftNum = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); 81 81 Int shift = wp0[0].shift + shiftNum; 82 Int round = (1<<(shift-1)) * bRound;82 Int round = shift?(1<<(shift-1)) * bRound:0; 83 83 Int w1 = wp1[0].w; 84 84 85 85 UInt iSrc0Stride = pcYuvSrc0->getStride(); … … 105 105 w0 = wp0[1].w; 106 106 offset = wp0[1].offset; 107 107 shift = wp0[1].shift + shiftNum; 108 round = (1<<(shift-1));108 round = shift?(1<<(shift-1)):0; 109 109 w1 = wp1[1].w; 110 110 111 111 iSrc0Stride = pcYuvSrc0->getCStride(); … … 132 132 w0 = wp0[2].w; 133 133 offset = wp0[2].offset; 134 134 shift = wp0[2].shift + shiftNum; 135 round = (1<<(shift-1));135 round = shift?(1<<(shift-1)):0; 136 136 w1 = wp1[2].w; 137 137 138 138 for ( y = iHeight-1; y >= 0; y-- ) … … 175 175 Int offset = wp0[0].offset; 176 176 Int shiftNum = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); 177 177 Int shift = wp0[0].shift + shiftNum; 178 Int round = (1<<(shift-1));178 Int round = shift?(1<<(shift-1)):0; 179 179 UInt iSrc0Stride = pcYuvSrc0->getStride(); 180 180 UInt iDstStride = rpcYuvDst->getStride(); 181 181 … … 197 197 w0 = wp0[1].w; 198 198 offset = wp0[1].offset; 199 199 shift = wp0[1].shift + shiftNum; 200 round = (1<<(shift-1));200 round = shift?(1<<(shift-1)):0; 201 201 202 202 iSrc0Stride = pcYuvSrc0->getCStride(); 203 203 iDstStride = rpcYuvDst->getCStride(); … … 221 221 w0 = wp0[2].w; 222 222 offset = wp0[2].offset; 223 223 shift = wp0[2].shift + shiftNum; 224 round = (1<<(shift-1));224 round = shift?(1<<(shift-1)):0; 225 225 226 226 for ( y = iHeight-1; y >= 0; y-- ) 227 227 { -
source/Lib/TLibDecoder/TDecSbac.cpp
1114 1114 return; 1115 1115 } 1116 1116 1117 UInt useT ansformSkip;1118 m_pcTDecBinIf->decodeBin( useT ansformSkip , m_cTransformSkipSCModel.get( 0, eTType? TEXT_CHROMA: TEXT_LUMA, 0 ) );1119 if(eTType!= TEXT_LUMA && uiDepth == 4)1117 UInt useTransformSkip; 1118 m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, eTType? TEXT_CHROMA: TEXT_LUMA, 0 ) ); 1119 if(eTType!= TEXT_LUMA) 1120 1120 { 1121 uiDepth --; 1121 const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - uiDepth; 1122 if(uiLog2TrafoSize == 2) 1123 { 1124 uiDepth --; 1125 } 1122 1126 } 1123 1127 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 1124 1128 DTRACE_CABAC_T("\tparseTransformSkip()"); 1125 1129 DTRACE_CABAC_T( "\tsymbol=" ) 1126 DTRACE_CABAC_V( useT ansformSkip )1130 DTRACE_CABAC_V( useTransformSkip ) 1127 1131 DTRACE_CABAC_T( "\tAddr=" ) 1128 1132 DTRACE_CABAC_V( pcCU->getAddr() ) 1129 1133 DTRACE_CABAC_T( "\tetype=" ) … … 1132 1136 DTRACE_CABAC_V( uiAbsPartIdx ) 1133 1137 DTRACE_CABAC_T( "\n" ) 1134 1138 1135 pcCU->setTransformSkipSubParts( useT ansformSkip, eTType, uiAbsPartIdx, uiDepth);1139 pcCU->setTransformSkipSubParts( useTransformSkip, eTType, uiAbsPartIdx, uiDepth); 1136 1140 } 1137 1141 #endif 1138 1142