Changeset 1285 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibCommon


Ignore:
Timestamp:
17 Jul 2015, 00:55:34 (10 years ago)
Author:
seregin
Message:

port rev 4320 (g_maxTrDynamicRange)

Location:
branches/SHM-dev/source/Lib/TLibCommon
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/Lib/TLibCommon/TComChromaFormat.h

    r1259 r1285  
    163163//------------------------------------------------
    164164
    165 static inline Int getTransformShift(const ChannelType type, const UInt uiLog2TrSize)
     165static inline Int getTransformShift(const ChannelType type, const UInt uiLog2TrSize, const Int maxLog2TrDynamicRange)
    166166{
    167167#if O0043_BEST_EFFORT_DECODING
    168   return g_maxTrDynamicRange[type] - g_bitDepthInStream[type] - uiLog2TrSize;
     168  return maxLog2TrDynamicRange - g_bitDepthInStream[type] - uiLog2TrSize;
    169169#else
    170   return g_maxTrDynamicRange[type] - g_bitDepth[type] - uiLog2TrSize;
     170  return maxLog2TrDynamicRange - g_bitDepth[type] - uiLog2TrSize;
    171171#endif
    172172}
  • branches/SHM-dev/source/Lib/TLibCommon/TComRom.cpp

    r1284 r1285  
    322322  }
    323323}
    324 
    325 Int g_maxTrDynamicRange[MAX_NUM_CHANNEL_TYPE];
    326324
    327325Int g_quantScales[SCALING_LIST_REM_NUM] =
  • branches/SHM-dev/source/Lib/TLibCommon/TComRom.h

    r1284 r1285  
    9797#define SCALE_BITS                 15 // Inherited from TMuC, pressumably for fractional bit estimates in RDOQ
    9898
    99 extern Int g_maxTrDynamicRange[MAX_NUM_CHANNEL_TYPE];
    100 
    10199#define SQRT2                      11585
    102100#define SQRT2_SHIFT                13
  • branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h

    r1273 r1285  
    14801480  Int                    getBitDepth(ChannelType type) const                                             { return m_uiBitDepth[type];                                           }
    14811481  Void                   setBitDepth(ChannelType type, Int u )                                           { m_uiBitDepth[type] = u;                                              }
     1482  Int                    getMaxLog2TrDynamicRange(ChannelType channelType) const                         { return getUseExtendedPrecision() ? std::max<Int>(15, Int(m_uiBitDepth[channelType] + 6)) : 15; }
     1483
    14821484  Int                    getDifferentialLumaChromaBitDepth() const                                       { return Int(m_uiBitDepth[CHANNEL_TYPE_LUMA]) - Int(m_uiBitDepth[CHANNEL_TYPE_CHROMA]); }
    14831485  Int                    getQpBDOffset(ChannelType type) const                                           { return m_qpBDOffset[type];                                           }
  • branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.cpp

    r1283 r1285  
    242242 *  \param uiMode is Intra Prediction mode used in Mode-Dependent DCT/DST only
    243243 */
    244 Void xTr(Int bitDepth, Pel *block, TCoeff *coeff, UInt uiStride, UInt uiTrSize, Bool useDST, const Int maxTrDynamicRange)
     244Void xTr(Int bitDepth, Pel *block, TCoeff *coeff, UInt uiStride, UInt uiTrSize, Bool useDST, const Int maxLog2TrDynamicRange)
    245245{
    246246  UInt i,j,k;
     
    273273  static const Int TRANSFORM_MATRIX_SHIFT = g_transformMatrixShift[TRANSFORM_FORWARD];
    274274
    275   const Int shift_1st = (uiLog2TrSize +  bitDepth + TRANSFORM_MATRIX_SHIFT) - maxTrDynamicRange;
     275  const Int shift_1st = (uiLog2TrSize +  bitDepth + TRANSFORM_MATRIX_SHIFT) - maxLog2TrDynamicRange;
    276276  const Int shift_2nd = uiLog2TrSize + TRANSFORM_MATRIX_SHIFT;
    277277  const Int add_1st = (shift_1st>0) ? (1<<(shift_1st-1)) : 0;
     
    315315 *  \param uiMode is Intra Prediction mode used in Mode-Dependent DCT/DST only
    316316 */
    317 Void xITr(Int bitDepth, TCoeff *coeff, Pel *block, UInt uiStride, UInt uiTrSize, Bool useDST, const Int maxTrDynamicRange)
     317Void xITr(Int bitDepth, TCoeff *coeff, Pel *block, UInt uiStride, UInt uiTrSize, Bool useDST, const Int maxLog2TrDynamicRange)
    318318{
    319319  UInt i,j,k;
     
    346346
    347347  const Int shift_1st = TRANSFORM_MATRIX_SHIFT + 1; //1 has been added to shift_1st at the expense of shift_2nd
    348   const Int shift_2nd = (TRANSFORM_MATRIX_SHIFT + maxTrDynamicRange - 1) - bitDepth;
    349   const TCoeff clipMinimum = -(1 << maxTrDynamicRange);
    350   const TCoeff clipMaximum =  (1 << maxTrDynamicRange) - 1;
     348  const Int shift_2nd = (TRANSFORM_MATRIX_SHIFT + maxLog2TrDynamicRange - 1) - bitDepth;
     349  const TCoeff clipMinimum = -(1 << maxLog2TrDynamicRange);
     350  const TCoeff clipMaximum =  (1 << maxLog2TrDynamicRange) - 1;
    351351  assert(shift_2nd>=0);
    352352  const Int add_1st = 1<<(shift_1st-1);
     
    857857
    858858/** MxN forward transform (2D)
    859 *  \param bitDepth          [in]  bit depth
    860 *  \param block             [in]  residual block
    861 *  \param coeff             [out] transform coefficients
    862 *  \param iWidth            [in]  width of transform
    863 *  \param iHeight           [in]  height of transform
    864 *  \param useDST            [in]
    865 *  \param maxTrDynamicRange [in]
     859*  \param bitDepth              [in]  bit depth
     860*  \param block                 [in]  residual block
     861*  \param coeff                 [out] transform coefficients
     862*  \param iWidth                [in]  width of transform
     863*  \param iHeight               [in]  height of transform
     864*  \param useDST                [in]
     865*  \param maxLog2TrDynamicRange [in]
    866866
    867867*/
    868 Void xTrMxN(Int bitDepth, TCoeff *block, TCoeff *coeff, Int iWidth, Int iHeight, Bool useDST, const Int maxTrDynamicRange)
     868Void xTrMxN(Int bitDepth, TCoeff *block, TCoeff *coeff, Int iWidth, Int iHeight, Bool useDST, const Int maxLog2TrDynamicRange)
    869869{
    870870  static const Int TRANSFORM_MATRIX_SHIFT = g_transformMatrixShift[TRANSFORM_FORWARD];
    871871
    872   const Int shift_1st = ((g_aucConvertToBit[iWidth] + 2) +  bitDepth + TRANSFORM_MATRIX_SHIFT) - maxTrDynamicRange;
     872  const Int shift_1st = ((g_aucConvertToBit[iWidth] + 2) +  bitDepth + TRANSFORM_MATRIX_SHIFT) - maxLog2TrDynamicRange;
    873873  const Int shift_2nd = (g_aucConvertToBit[iHeight] + 2) + TRANSFORM_MATRIX_SHIFT;
    874874
     
    925925
    926926/** MxN inverse transform (2D)
    927 *  \param bitDepth          [in]  bit depth
    928 *  \param coeff             [in]  transform coefficients
    929 *  \param block             [out] residual block
    930 *  \param iWidth            [in]  width of transform
    931 *  \param iHeight           [in]  height of transform
    932 *  \param useDST            [in]
    933 *  \param maxTrDynamicRange [in]
     927*  \param bitDepth              [in]  bit depth
     928*  \param coeff                 [in]  transform coefficients
     929*  \param block                 [out] residual block
     930*  \param iWidth                [in]  width of transform
     931*  \param iHeight               [in]  height of transform
     932*  \param useDST                [in]
     933*  \param maxLog2TrDynamicRange [in]
    934934*/
    935 Void xITrMxN(Int bitDepth, TCoeff *coeff, TCoeff *block, Int iWidth, Int iHeight, Bool useDST, const Int maxTrDynamicRange)
     935Void xITrMxN(Int bitDepth, TCoeff *coeff, TCoeff *block, Int iWidth, Int iHeight, Bool useDST, const Int maxLog2TrDynamicRange)
    936936{
    937937  static const Int TRANSFORM_MATRIX_SHIFT = g_transformMatrixShift[TRANSFORM_INVERSE];
    938938
    939939  Int shift_1st = TRANSFORM_MATRIX_SHIFT + 1; //1 has been added to shift_1st at the expense of shift_2nd
    940   Int shift_2nd = (TRANSFORM_MATRIX_SHIFT + maxTrDynamicRange - 1) - bitDepth;
    941   const TCoeff clipMinimum = -(1 << maxTrDynamicRange);
    942   const TCoeff clipMaximum =  (1 << maxTrDynamicRange) - 1;
     940  Int shift_2nd = (TRANSFORM_MATRIX_SHIFT + maxLog2TrDynamicRange - 1) - bitDepth;
     941  const TCoeff clipMinimum = -(1 << maxLog2TrDynamicRange);
     942  const TCoeff clipMaximum =  (1 << maxLog2TrDynamicRange) - 1;
    943943
    944944  assert(shift_1st >= 0);
     
    997997
    998998// To minimize the distortion only. No rate is considered.
    999 Void TComTrQuant::signBitHidingHDQ( const ComponentID compID, TCoeff* pQCoef, TCoeff* pCoef, TCoeff* deltaU, const TUEntropyCodingParameters &codingParameters )
     999Void TComTrQuant::signBitHidingHDQ( const ComponentID compID, TCoeff* pQCoef, TCoeff* pCoef, TCoeff* deltaU, const TUEntropyCodingParameters &codingParameters, const Int maxLog2TrDynamicRange )
    10001000{
    10011001  const UInt width     = codingParameters.widthInGroups  << MLS_CG_LOG2_WIDTH;
     
    10031003  const UInt groupSize = 1 << MLS_CG_SIZE;
    10041004
    1005   const TCoeff entropyCodingMinimum = -(1 << g_maxTrDynamicRange[toChannelType(compID)]);
    1006   const TCoeff entropyCodingMaximum =  (1 << g_maxTrDynamicRange[toChannelType(compID)]) - 1;
     1005  const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange);
     1006  const TCoeff entropyCodingMaximum =  (1 << maxLog2TrDynamicRange) - 1;
    10071007
    10081008  Int lastCG = -1;
     
    11541154#endif
    11551155
    1156   const Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, compID);
     1156  const Bool useTransformSkip      = pcCU->getTransformSkip(uiAbsPartIdx, compID);
     1157  const Int  maxLog2TrDynamicRange = pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID));
    11571158
    11581159  Bool useRDOQ = useTransformSkip ? m_useRDOQTS : m_useRDOQ;
     
    11701171    getTUEntropyCodingParameters(codingParameters, rTu, compID);
    11711172
    1172     const TCoeff entropyCodingMinimum = -(1 << g_maxTrDynamicRange[toChannelType(compID)]);
    1173     const TCoeff entropyCodingMaximum =  (1 << g_maxTrDynamicRange[toChannelType(compID)]) - 1;
     1173    const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange);
     1174    const TCoeff entropyCodingMaximum =  (1 << maxLog2TrDynamicRange) - 1;
    11741175
    11751176    TCoeff deltaU[MAX_TU_SIZE * MAX_TU_SIZE];
     
    11911192
    11921193    // Represents scaling through forward transform
    1193     Int iTransformShift = getTransformShift(toChannelType(compID), uiLog2TrSize);
     1194    Int iTransformShift = getTransformShift(toChannelType(compID), uiLog2TrSize, maxLog2TrDynamicRange);
    11941195    if (useTransformSkip && pcCU->getSlice()->getSPS()->getUseExtendedPrecision())
    11951196    {
     
    12411242      if(uiAbsSum >= 2) //this prevents TUs with only one coefficient of value 1 from being tested
    12421243      {
    1243         signBitHidingHDQ( compID, piQCoef, piCoef, deltaU, codingParameters ) ;
     1244        signBitHidingHDQ( compID, piQCoef, piCoef, deltaU, codingParameters, maxLog2TrDynamicRange ) ;
    12441245      }
    12451246    }
     
    12651266  const UInt                 uiLog2TrSize       = rTu.GetEquivalentLog2TrSize(compID);
    12661267  const UInt                 numSamplesInBlock  = uiWidth*uiHeight;
    1267   const TCoeff               transformMinimum   = -(1 << g_maxTrDynamicRange[toChannelType(compID)]);
    1268   const TCoeff               transformMaximum   =  (1 << g_maxTrDynamicRange[toChannelType(compID)]) - 1;
     1268  const Int                  maxLog2TrDynamicRange  = pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID));
     1269  const TCoeff               transformMinimum   = -(1 << maxLog2TrDynamicRange);
     1270  const TCoeff               transformMaximum   =  (1 << maxLog2TrDynamicRange) - 1;
    12691271  const Bool                 enableScalingLists = getUseScalingList(uiWidth, uiHeight, (pcCU->getTransformSkip(uiAbsPartIdx, compID) != 0));
    12701272  const Int                  scalingListType    = getScalingListType(pcCU->getPredictionMode(uiAbsPartIdx), compID);
     
    12751277  // Represents scaling through forward transform
    12761278  const Bool bClipTransformShiftTo0 = (pcCU->getTransformSkip(uiAbsPartIdx, compID) != 0) && pcCU->getSlice()->getSPS()->getUseExtendedPrecision();
    1277   const Int  originalTransformShift = getTransformShift(toChannelType(compID), uiLog2TrSize);
     1279  const Int  originalTransformShift = getTransformShift(toChannelType(compID), uiLog2TrSize, maxLog2TrDynamicRange);
    12781280  const Int  iTransformShift        = bClipTransformShiftTo0 ? std::max<Int>(0, originalTransformShift) : originalTransformShift;
    12791281
     
    12891291    //(sizeof(Intermediate_Int) * 8)  =              inputBitDepth    +    dequantCoefBits                   - rightShift
    12901292    const UInt             dequantCoefBits     = 1 + IQUANT_SHIFT + SCALING_LIST_BITS;
    1291     const UInt             targetInputBitDepth = std::min<UInt>((g_maxTrDynamicRange[toChannelType(compID)] + 1), (((sizeof(Intermediate_Int) * 8) + rightShift) - dequantCoefBits));
     1293    const UInt             targetInputBitDepth = std::min<UInt>((maxLog2TrDynamicRange + 1), (((sizeof(Intermediate_Int) * 8) + rightShift) - dequantCoefBits));
    12921294
    12931295    const Intermediate_Int inputMinimum        = -(1 << (targetInputBitDepth - 1));
     
    13291331    //iCoeffQ                         = Intermediate_Int((Int64(clipQCoef) * scale + iAdd) >> rightShift);
    13301332    //(sizeof(Intermediate_Int) * 8)  =                    inputBitDepth   + scaleBits      - rightShift
    1331     const UInt             targetInputBitDepth = std::min<UInt>((g_maxTrDynamicRange[toChannelType(compID)] + 1), (((sizeof(Intermediate_Int) * 8) + rightShift) - scaleBits));
     1333    const UInt             targetInputBitDepth = std::min<UInt>((maxLog2TrDynamicRange + 1), (((sizeof(Intermediate_Int) * 8) + rightShift) - scaleBits));
    13321334    const Intermediate_Int inputMinimum        = -(1 << (targetInputBitDepth - 1));
    13331335    const Intermediate_Int inputMaximum        =  (1 << (targetInputBitDepth - 1)) - 1;
     
    14411443      else
    14421444      {
    1443         xT( compID, rTu.useDST(compID), pcResidual, uiStride, m_plTempCoeff, uiWidth, uiHeight );
     1445        xT( compID, rTu.useDST(compID), pcResidual, uiStride, m_plTempCoeff, uiWidth, uiHeight, pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID)) );
    14441446      }
    14451447
     
    15711573    else
    15721574    {
    1573       xIT( compID, rTu.useDST(compID), m_plTempCoeff, pcResidual, uiStride, uiWidth, uiHeight );
     1575      xIT( compID, rTu.useDST(compID), m_plTempCoeff, pcResidual, uiStride, uiWidth, uiHeight, pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID)) );
    15741576
    15751577#if defined DEBUG_STRING
     
    18631865 *  \param iHeight transform height
    18641866 */
    1865 Void TComTrQuant::xT( const ComponentID compID, Bool useDST, Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, Int iWidth, Int iHeight )
     1867Void TComTrQuant::xT( const ComponentID compID, Bool useDST, Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange )
    18661868{
    18671869#if MATRIX_MULT
    18681870  if( iWidth == iHeight)
    18691871  {
    1870     xTr(g_bitDepth[toChannelType(compID)], piBlkResi, psCoeff, uiStride, (UInt)iWidth, useDST, g_maxTrDynamicRange[toChannelType(compID)]);
     1872    xTr(g_bitDepth[toChannelType(compID)], piBlkResi, psCoeff, uiStride, (UInt)iWidth, useDST, maxLog2TrDynamicRange);
    18711873    return;
    18721874  }
     
    18841886  }
    18851887
    1886   xTrMxN( g_bitDepth[toChannelType(compID)], block, coeff, iWidth, iHeight, useDST, g_maxTrDynamicRange[toChannelType(compID)] );
     1888  xTrMxN( g_bitDepth[toChannelType(compID)], block, coeff, iWidth, iHeight, useDST, maxLog2TrDynamicRange );
    18871889
    18881890  memcpy(psCoeff, coeff, (iWidth * iHeight * sizeof(TCoeff)));
     
    18981900 *  \param iHeight transform height
    18991901 */
    1900 Void TComTrQuant::xIT( const ComponentID compID, Bool useDST, TCoeff* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight )
     1902Void TComTrQuant::xIT( const ComponentID compID, Bool useDST, TCoeff* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange )
    19011903{
    19021904#if MATRIX_MULT
     
    19041906  {
    19051907#if O0043_BEST_EFFORT_DECODING
    1906     xITr(g_bitDepthInStream[toChannelType(compID)], plCoef, pResidual, uiStride, (UInt)iWidth, useDST, g_maxTrDynamicRange[toChannelType(compID)]);
     1908    xITr(g_bitDepthInStream[toChannelType(compID)], plCoef, pResidual, uiStride, (UInt)iWidth, useDST, maxLog2TrDynamicRange);
    19071909#else
    1908     xITr(g_bitDepth[toChannelType(compID)], plCoef, pResidual, uiStride, (UInt)iWidth, useDST, g_maxTrDynamicRange[toChannelType(compID)]);
     1910    xITr(g_bitDepth[toChannelType(compID)], plCoef, pResidual, uiStride, (UInt)iWidth, useDST, maxLog2TrDynamicRange);
    19091911#endif
    19101912    return;
     
    19181920
    19191921#if O0043_BEST_EFFORT_DECODING
    1920   xITrMxN( g_bitDepthInStream[toChannelType(compID)], coeff, block, iWidth, iHeight, useDST, g_maxTrDynamicRange[toChannelType(compID)] );
     1922  xITrMxN( g_bitDepthInStream[toChannelType(compID)], coeff, block, iWidth, iHeight, useDST, maxLog2TrDynamicRange );
    19211923#else
    1922   xITrMxN( g_bitDepth[toChannelType(compID)], coeff, block, iWidth, iHeight, useDST, g_maxTrDynamicRange[toChannelType(compID)] );
     1924  xITrMxN( g_bitDepth[toChannelType(compID)], coeff, block, iWidth, iHeight, useDST, maxLog2TrDynamicRange );
    19231925#endif
    19241926
     
    19441946  const Int width           = rect.width;
    19451947  const Int height          = rect.height;
    1946 
    1947   Int iTransformShift = getTransformShift(toChannelType(component), rTu.GetEquivalentLog2TrSize(component));
     1948  const Int maxLog2TrDynamicRange = rTu.getCU()->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(component));
     1949
     1950  Int iTransformShift = getTransformShift(toChannelType(component), rTu.GetEquivalentLog2TrSize(component), maxLog2TrDynamicRange);
    19481951  if (rTu.getCU()->getSlice()->getSPS()->getUseExtendedPrecision())
    19491952  {
     
    19911994  const Int width           = rect.width;
    19921995  const Int height          = rect.height;
    1993 
    1994   Int iTransformShift = getTransformShift(toChannelType(component), rTu.GetEquivalentLog2TrSize(component));
     1996  const Int maxLog2TrDynamicRange = rTu.getCU()->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(component));
     1997
     1998  Int iTransformShift = getTransformShift(toChannelType(component), rTu.GetEquivalentLog2TrSize(component), maxLog2TrDynamicRange);
    19951999  if (rTu.getCU()->getSlice()->getSPS()->getUseExtendedPrecision())
    19962000  {
     
    20582062
    20592063  const Bool             extendedPrecision = pcCU->getSlice()->getSPS()->getUseExtendedPrecision();
     2064  const Int              maxLog2TrDynamicRange = pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID));
    20602065
    20612066  /* for 422 chroma blocks, the effective scaling applied during transformation is not a power of 2, hence it cannot be
     
    20662071
    20672072  // Represents scaling through forward transform
    2068   Int iTransformShift            = getTransformShift(channelType, uiLog2TrSize);
     2073  Int iTransformShift            = getTransformShift(channelType, uiLog2TrSize, maxLog2TrDynamicRange);
    20692074  if ((pcCU->getTransformSkip(uiAbsPartIdx, compID) != 0) && pcCU->getSlice()->getSPS()->getUseExtendedPrecision())
    20702075  {
     
    21102115  const Double defaultErrorScale              = getErrScaleCoeffNoScalingList(scalingListType, (uiLog2TrSize-2), cQP.rem);
    21112116
    2112   const TCoeff entropyCodingMinimum = -(1 << g_maxTrDynamicRange[toChannelType(compID)]);
    2113   const TCoeff entropyCodingMaximum =  (1 << g_maxTrDynamicRange[toChannelType(compID)]) - 1;
     2117  const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange);
     2118  const TCoeff entropyCodingMaximum =  (1 << maxLog2TrDynamicRange) - 1;
    21142119
    21152120#if ADAPTIVE_QP_SELECTION
     
    28132818 * \returns cost of given absolute transform level
    28142819 */
    2815 __inline Int TComTrQuant::xGetICRate         ( UInt                            uiAbsLevel,
    2816                                                UShort                          ui16CtxNumOne,
    2817                                                UShort                          ui16CtxNumAbs,
    2818                                                UShort                          ui16AbsGoRice,
    2819                                                UInt                            c1Idx,
    2820                                                UInt                            c2Idx,
    2821                                                Bool                            useLimitedPrefixLength,
    2822                                                ChannelType                     channelType
     2820__inline Int TComTrQuant::xGetICRate         ( const UInt    uiAbsLevel,
     2821                                               const UShort  ui16CtxNumOne,
     2822                                               const UShort  ui16CtxNumAbs,
     2823                                               const UShort  ui16AbsGoRice,
     2824                                               const UInt    c1Idx,
     2825                                               const UInt    c2Idx,
     2826                                               const Bool    useLimitedPrefixLength,
     2827                                               const Int     maxLog2TrDynamicRange
    28232828                                               ) const
    28242829{
     
    28372842    else if (useLimitedPrefixLength)
    28382843    {
    2839       const UInt maximumPrefixLength = (32 - (COEF_REMAIN_BIN_REDUCTION + g_maxTrDynamicRange[channelType]));
     2844      const UInt maximumPrefixLength = (32 - (COEF_REMAIN_BIN_REDUCTION + maxLog2TrDynamicRange));
    28402845
    28412846      UInt prefixLength = 0;
     
    28472852      }
    28482853
    2849       const UInt suffixLength = (prefixLength == maximumPrefixLength) ? (g_maxTrDynamicRange[channelType] - ui16AbsGoRice) : (prefixLength + 1/*separator*/);
     2854      const UInt suffixLength = (prefixLength == maximumPrefixLength) ? (maxLog2TrDynamicRange - ui16AbsGoRice) : (prefixLength + 1/*separator*/);
    28502855
    28512856      iRate += (COEF_REMAIN_BIN_REDUCTION + prefixLength + suffixLength + ui16AbsGoRice) << 15;
     
    29812986 * \param format      chroma format
    29822987 */
    2983 Void TComTrQuant::setScalingList(TComScalingList *scalingList, const ChromaFormat format)
     2988Void TComTrQuant::setScalingList(TComScalingList *scalingList, const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE])
    29842989{
    29852990  const Int minimumQp = 0;
     
    29942999        xSetScalingListEnc(scalingList,list,size,qp,format);
    29953000        xSetScalingListDec(*scalingList,list,size,qp,format);
    2996         setErrScaleCoeff(list,size,qp);
     3001        setErrScaleCoeff(list,size,qp,maxLog2TrDynamicRange);
    29973002      }
    29983003    }
     
    30243029 * \param qp   Quantization parameter
    30253030 */
    3026 Void TComTrQuant::setErrScaleCoeff(UInt list, UInt size, Int qp)
     3031Void TComTrQuant::setErrScaleCoeff(UInt list, UInt size, Int qp, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE])
    30273032{
    30283033  const UInt uiLog2TrSize = g_aucConvertToBit[ g_scalingListSizeX[size] ] + 2;
    30293034  const ChannelType channelType = ((list == 0) || (list == MAX_NUM_COMPONENT)) ? CHANNEL_TYPE_LUMA : CHANNEL_TYPE_CHROMA;
    30303035
    3031   const Int iTransformShift = getTransformShift(channelType, uiLog2TrSize);  // Represents scaling through forward transform
     3036  const Int iTransformShift = getTransformShift(channelType, uiLog2TrSize, maxLog2TrDynamicRange[channelType]);  // Represents scaling through forward transform
    30323037
    30333038  UInt i,uiMaxNumCoeff = g_scalingListSize[size];
     
    31033108/** set flat matrix value to quantized coefficient
    31043109 */
    3105 Void TComTrQuant::setFlatScalingList(const ChromaFormat format)
     3110Void TComTrQuant::setFlatScalingList(const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE])
    31063111{
    31073112  const Int minimumQp = 0;
     
    31153120      {
    31163121        xsetFlatScalingList(list,size,qp,format);
    3117         setErrScaleCoeff(list,size,qp);
     3122        setErrScaleCoeff(list,size,qp,maxLog2TrDynamicRange);
    31183123      }
    31193124    }
     
    32503255  const UInt           uiWidth                        = rect.width;
    32513256  const UInt           uiHeight                       = rect.height;
    3252   const Int            iTransformShift                = getTransformShift(toChannelType(compID), rTu.GetEquivalentLog2TrSize(compID));
     3257  const Int            maxLog2TrDynamicRange          = pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID));
     3258  const Int            iTransformShift                = getTransformShift(toChannelType(compID), rTu.GetEquivalentLog2TrSize(compID), maxLog2TrDynamicRange);
    32533259  const Int            scalingListType                = getScalingListType(pcCU->getPredictionMode(uiAbsPartIdx), compID);
    32543260  const Bool           enableScalingLists             = getUseScalingList(uiWidth, uiHeight, true);
     
    32933299  const TCoeff quantisedCoefficient = (TCoeff((tmpLevel + iAdd ) >> iQBits)) * iSign;
    32943300
    3295   const TCoeff entropyCodingMinimum = -(1 << g_maxTrDynamicRange[toChannelType(compID)]);
    3296   const TCoeff entropyCodingMaximum =  (1 << g_maxTrDynamicRange[toChannelType(compID)]) - 1;
     3301  const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange);
     3302  const TCoeff entropyCodingMaximum =  (1 << maxLog2TrDynamicRange) - 1;
    32973303  pcCoeff[ uiPos ] = Clip3<TCoeff>( entropyCodingMinimum, entropyCodingMaximum, quantisedCoefficient );
    32983304}
     
    33083314  const Int            QP_per             = cQP.per;
    33093315  const Int            QP_rem             = cQP.rem;
    3310   const Int            iTransformShift    = getTransformShift(toChannelType(compID), rTu.GetEquivalentLog2TrSize(compID));
     3316  const Int            maxLog2TrDynamicRange = pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID));
     3317  const Int            iTransformShift    = getTransformShift(toChannelType(compID), rTu.GetEquivalentLog2TrSize(compID), maxLog2TrDynamicRange);
    33113318  const Int            scalingListType    = getScalingListType(pcCU->getPredictionMode(uiAbsPartIdx), compID);
    33123319  const Bool           enableScalingLists = getUseScalingList(uiWidth, uiHeight, true);
     
    33173324  const Int rightShift = (IQUANT_SHIFT - (iTransformShift + QP_per)) + (enableScalingLists ? LOG2_SCALING_LIST_NEUTRAL_VALUE : 0);
    33183325
    3319   const TCoeff transformMinimum = -(1 << g_maxTrDynamicRange[toChannelType(compID)]);
    3320   const TCoeff transformMaximum =  (1 << g_maxTrDynamicRange[toChannelType(compID)]) - 1;
     3326  const TCoeff transformMinimum = -(1 << maxLog2TrDynamicRange);
     3327  const TCoeff transformMaximum =  (1 << maxLog2TrDynamicRange) - 1;
    33213328
    33223329  // Dequantisation
     
    33273334  {
    33283335    const UInt             dequantCoefBits     = 1 + IQUANT_SHIFT + SCALING_LIST_BITS;
    3329     const UInt             targetInputBitDepth = std::min<UInt>((g_maxTrDynamicRange[toChannelType(compID)] + 1), (((sizeof(Intermediate_Int) * 8) + rightShift) - dequantCoefBits));
     3336    const UInt             targetInputBitDepth = std::min<UInt>((maxLog2TrDynamicRange + 1), (((sizeof(Intermediate_Int) * 8) + rightShift) - dequantCoefBits));
    33303337
    33313338    const Intermediate_Int inputMinimum        = -(1 << (targetInputBitDepth - 1));
     
    33563363    const Int scaleBits =     (IQUANT_SHIFT + 1)   ;
    33573364
    3358     const UInt             targetInputBitDepth = std::min<UInt>((g_maxTrDynamicRange[toChannelType(compID)] + 1), (((sizeof(Intermediate_Int) * 8) + rightShift) - scaleBits));
     3365    const UInt             targetInputBitDepth = std::min<UInt>((maxLog2TrDynamicRange + 1), (((sizeof(Intermediate_Int) * 8) + rightShift) - scaleBits));
    33593366    const Intermediate_Int inputMinimum        = -(1 << (targetInputBitDepth - 1));
    33603367    const Intermediate_Int inputMaximum        =  (1 << (targetInputBitDepth - 1)) - 1;
  • branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.h

    r1259 r1285  
    172172  Void initScalingList                      ();
    173173  Void destroyScalingList                   ();
    174   Void setErrScaleCoeff    ( UInt list, UInt size, Int qp );
     174  Void setErrScaleCoeff    ( UInt list, UInt size, Int qp, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] );
    175175  Double* getErrScaleCoeff              ( UInt list, UInt size, Int qp ) { return m_errScale             [size][list][qp]; };  //!< get Error Scale Coefficent
    176176  Double& getErrScaleCoeffNoScalingList ( UInt list, UInt size, Int qp ) { return m_errScaleNoScalingList[size][list][qp]; };  //!< get Error Scale Coefficent
     
    179179  Void setUseScalingList   ( Bool bUseScalingList){ m_scalingListEnabledFlag = bUseScalingList; };
    180180  Bool getUseScalingList   (const UInt width, const UInt height, const Bool isTransformSkip){ return m_scalingListEnabledFlag && (!isTransformSkip || ((width == 4) && (height == 4))); };
    181   Void setFlatScalingList  (const ChromaFormat format);
     181  Void setFlatScalingList  (const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE]);
    182182  Void xsetFlatScalingList ( UInt list, UInt size, Int qp, const ChromaFormat format);
    183183  Void xSetScalingListEnc  ( TComScalingList *scalingList, UInt list, UInt size, Int qp, const ChromaFormat format);
    184184  Void xSetScalingListDec  ( const TComScalingList &scalingList, UInt list, UInt size, Int qp, const ChromaFormat format);
    185   Void setScalingList      ( TComScalingList *scalingList, const ChromaFormat format);
     185  Void setScalingList      ( TComScalingList *scalingList, const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE]);
    186186  Void setScalingListDec   ( const TComScalingList &scalingList, const ChromaFormat format);
    187187  Void processScalingListEnc( Int *coeff, Int *quantcoeff, Int quantScales, UInt height, UInt width, UInt ratio, Int sizuNum, UInt dc);
     
    230230private:
    231231  // forward Transform
    232   Void xT   ( const ComponentID compID, Bool useDST, Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, Int iWidth, Int iHeight );
     232  Void xT   ( const ComponentID compID, Bool useDST, Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange );
    233233
    234234  // skipping Transform
    235235  Void xTransformSkip ( Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, TComTU &rTu, const ComponentID component );
    236236
    237   Void signBitHidingHDQ( const ComponentID compID, TCoeff* pQCoef, TCoeff* pCoef, TCoeff* deltaU, const TUEntropyCodingParameters &codingParameters );
     237  Void signBitHidingHDQ( const ComponentID compID, TCoeff* pQCoef, TCoeff* pCoef, TCoeff* deltaU, const TUEntropyCodingParameters &codingParameters, const Int maxLog2TrDynamicRange );
    238238
    239239  // quantization
     
    279279
    280280
    281   __inline Int xGetICRate  ( UInt   uiAbsLevel,
    282                              UShort ui16CtxNumOne,
    283                              UShort ui16CtxNumAbs,
    284                              UShort ui16AbsGoRice,
    285                              UInt   c1Idx,
    286                              UInt   c2Idx,
    287                              Bool   useLimitedPrefixLength,
    288                              ChannelType channelType
     281  __inline Int xGetICRate  ( const UInt   uiAbsLevel,
     282                             const UShort ui16CtxNumOne,
     283                             const UShort ui16CtxNumAbs,
     284                             const UShort ui16AbsGoRice,
     285                             const UInt   c1Idx,
     286                             const UInt   c2Idx,
     287                             const Bool   useLimitedPrefixLength,
     288                             const Int maxLog2TrDynamicRange
    289289                           ) const;
    290290
     
    304304
    305305  // inverse transform
    306   Void xIT    ( const ComponentID compID, Bool useDST, TCoeff* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight );
     306  Void xIT    ( const ComponentID compID, Bool useDST, TCoeff* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange );
    307307
    308308  // inverse skipping transform
Note: See TracChangeset for help on using the changeset viewer.