Changeset 838 in 3DVCSoftware


Ignore:
Timestamp:
8 Feb 2014, 01:07:38 (10 years ago)
Author:
tech
Message:

Further fixes.

Location:
branches/HTM-10.0rc1-dev0/source
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-10.0rc1-dev0/source/App/TAppDecoder/TAppDecTop.cpp

    r837 r838  
    279279          bitstreamFile.seekg(location-streamoff(3));
    280280          bytestream.reset();
    281 #if ENC_DEC_TRACE
    282281#if H_MV_ENC_DEC_TRAC
    283282          const Bool resetCounter = false;
     
    290289            g_disableHLSTrace = true;     // Trancing of second parsing of SH is not carried out
    291290          }         
    292 #else
    293           g_nSymbolCounter = symCount;
    294 #endif
    295291#endif
    296292        }
  • branches/HTM-10.0rc1-dev0/source/App/TAppEncoder/TAppEncCfg.cpp

    r837 r838  
    444444  ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs")
    445445  ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs")
     446#if H_MV 
    446447  // Coding structure parameters
    447 #if H_MV 
    448448  ("IntraPeriod,-ip",         m_iIntraPeriod,std::vector<Int>(1,-1), "Intra period in frames, (-1: only first frame), per layer")
    449449#else
     450  // Coding structure paramters
    450451("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
    451452#endif
     
    629630
    630631  ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS")
    631   ("CUTransquantBypassFlagValue", m_CUTransquantBypassFlagValue, false, "Fixed cu_transquant_bypass_flag value, when transquant_bypass_enable_flag is enabled")
     632  ("CUTransquantBypassFlagForce", m_CUTransquantBypassFlagForce, false, "Force transquant bypass mode, when transquant_bypass_enable_flag is enabled")
    632633  ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
    633634  ("StrongIntraSmoothing,-sis",      m_useStrongIntraSmoothing,           true, "Enable strong intra smoothing for 32x32 blocks")
     
    23612362  printf("IBD:%d ", g_bitDepthY > m_inputBitDepthY || g_bitDepthC > m_inputBitDepthC);
    23622363  printf("HAD:%d ", m_bUseHADME           );
    2363   printf("SRD:%d ", m_bUseSBACRD          );
    23642364  printf("RDQ:%d ", m_useRDOQ            );
    23652365  printf("RDQTS:%d ", m_useRDOQTS        );
  • branches/HTM-10.0rc1-dev0/source/App/TAppEncoder/TAppEncCfg.h

    r837 r838  
    286286
    287287  // coding tools (encoder-only parameters)
    288   Bool      m_bUseSBACRD;                                     ///< flag for using RD optimization based on SBAC
    289288  Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
    290289  Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
     
    385384  UInt       m_depthMADPred;
    386385#endif
    387 #else
    388   Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
    389   Int       m_targetBitrate;                                 ///< target bitrate
    390   Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
    391 
    392 #if KWU_RC_VIEWRC_E0227
    393   vector<Int>     m_viewTargetBits;
    394   Bool      m_viewWiseRateCtrl;                              ///< Flag for using view-wise rate control
    395 #endif
    396 #if KWU_RC_MADPRED_E0227
    397   UInt       m_depthMADPred;
    398 #endif
    399 #endif
    400386  Int       m_useScalingListId;                               ///< using quantization matrix
    401387  Char*     m_scalingListFile;                                ///< quantization matrix file name
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibCommon/TComPic.cpp

    r837 r838  
    111111  memcpy(m_numReorderPics, numReorderPics, MAX_TLAYER*sizeof(Int));
    112112
    113   /* initialize the texture to depth reference status */
    114113#if H_3D_FCO
     114/* initialize the texture to depth reference status */
    115115  for (int j=0; j<2; j++)
    116116  {
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibCommon/TComPic.h

    r837 r838  
    192192  Window&       getDefDisplayWindow()   { return m_defaultDisplayWindow; }
    193193
     194  Bool          getSAOMergeAvailability(Int currAddr, Int mergeAddr);
    194195
    195196  /* field coding parameters*/
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibCommon/TComPicSym.cpp

    r837 r838  
    123123    m_puiInverseCUOrderMap[i] = i;
    124124  }
     125
     126  m_saoBlkParams = new SAOBlkParam[m_uiNumCUsInFrame];
    125127}
    126128
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibCommon/TComRom.cpp

    r837 r838  
    327327UInt g_uiPCMBitDepthChroma   = 8;    // PCM bit-depth
    328328
     329#if H_3D_DIM_DMM
    329330// ====================================================================================================================
    330331// Depth coding modes
    331332// ====================================================================================================================
    332 #if H_3D_DIM_DMM
    333333const WedgeResolution g_dmmWedgeResolution[6] =
    334334{
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibCommon/TComTrQuant.h

    r837 r838  
    150150
    151151#if RDOQ_CHROMA_LAMBDA
     152  Void setLambdas ( const Double lambdas[3] ) { for (Int component = 0; component < 3; component++) m_lambdas[component] = lambdas[component]; }
    152153  Void setLambda(Double dLambdaLuma, Double dLambdaChroma) { m_dLambdaLuma = dLambdaLuma; m_dLambdaChroma = dLambdaChroma; }
    153154  Void selectLambda(TextType eTType) { m_dLambda = (eTType == TEXT_LUMA) ? m_lambdas[0] : ((eTType == TEXT_CHROMA_U) ? m_lambdas[1] : m_lambdas[2]); }
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibCommon/TypeDef.h

    r837 r838  
    551551};
    552552
     553enum SAOComponentIdx
     554{
     555  SAO_Y =0,
     556  SAO_Cb,
     557  SAO_Cr,
     558  NUM_SAO_COMPONENTS
     559};
    553560
    554561enum SAOMode //mode
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibDecoder/TDecSbac.cpp

    r837 r838  
    234234#endif
    235235  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    236   m_cCUAMPSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );
    237236  m_cCUPredModeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
    238237  m_cCUIntraPredSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE );
     
    20162015}
    20172016
     2017Void TDecSbac::parseSaoSign(UInt& val)
    20182018{
    20192019  m_pcTDecBinIf->decodeBinEP ( val );
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncCavlc.h

    r837 r838  
    120120 
    121121  Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
     122  Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false){printf("only supported in CABAC"); assert(0); exit(-1);}
    122123  Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx );
    123124  Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncCu.cpp

    r837 r838  
    423423  m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
    424424
    425   // variables for fast encoder decision
    426425#if H_3D_QTLPC 
    427426  Bool    bTrySplit     = true;
     
    623622          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );//by Competition for inter_2Nx2N
    624623#else
    625           xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bIsLosslessMode  );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );//by Competition for inter_2Nx2N
     624          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
     625          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N
    626626#endif
    627627#if H_3D_VSP
     
    651651            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    652652#else
    653             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
     653          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
     654          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    654655#endif
    655656#if H_3D_VSP
     
    18761877          rpcTempCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, 0, 0, uhDepth );
    18771878#endif
    1878 
    18791879#if MTK_DDD_G0063
    18801880          if( rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getViewIndex() != 0 && iDDDCand == uiMergeCand )
     
    18881888          }
    18891889#endif
    1890 
    18911890#if H_3D_SPIVMP
    18921891          rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth);
     
    18961895            Int iWidth = rpcTempCU->getWidth(0);
    18971896            Int iHeight = rpcTempCU->getHeight(0);
    1898 
    18991897            Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    1900 
    19011898            rpcTempCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    1902 
    19031899            for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    19041900            {
     
    19181914            Int width, height;
    19191915            rpcTempCU->getPartIndexAndSize( 0, partAddr, width, height );
    1920 
    19211916            if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
    19221917            {
     
    19371932              rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    19381933            }
    1939 
    19401934            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
    19411935          }
    19421936          else
    1943 #endif
    19441937          {
     1938#endif
    19451939            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
    19461940            rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    19471941            rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
     1942#if NTT_STORE_SPDV_VSP_G0148
    19481943          }
     1944#endif
    19491945       // do MC
    19501946       m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncEntropy.h

    r837 r838  
    127127  virtual Void codeCoeffNxN      ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0;
    128128  virtual Void codeTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, TextType eTType ) = 0;
     129  virtual Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false)    =0;
    129130  virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) = 0;
    130131 
     
    227228 
    228229  Void estimateBit             ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType);
     230  Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);}
    229231  static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize );
    230232
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncRateCtrl.cpp

    r837 r838  
    16601660}
    16611661
    1662 #else
    1663 
    1664 #define ADJUSTMENT_FACTOR       0.60
    1665 #define HIGH_QSTEP_THRESHOLD    9.5238
    1666 #define HIGH_QSTEP_ALPHA        4.9371
    1667 #define HIGH_QSTEP_BETA         0.0922
    1668 #define LOW_QSTEP_ALPHA         16.7429
    1669 #define LOW_QSTEP_BETA          -1.1494
    1670 
    1671 #define MAD_PRED_Y1             1.0
    1672 #define MAD_PRED_Y2             0.0
    1673 
    1674 enum MAD_HISOTRY {
    1675   MAD_PPPrevious = 0,
    1676   MAD_PPrevious  = 1,
    1677   MAD_Previous   = 2
    1678 };
    1679 
    1680 Void    MADLinearModel::initMADLinearModel()
    1681 {
    1682   m_activeOn = false;
    1683   m_paramY1  = 1.0;
    1684   m_paramY2  = 0.0;
    1685   m_costMADs[0] = m_costMADs[1] = m_costMADs[2] = 0.0;
    1686 }
    1687 
    1688 Double  MADLinearModel::getMAD()
    1689 {
    1690   Double costPredMAD = m_paramY1 * m_costMADs[MAD_Previous] + m_paramY2;
    1691 
    1692   if(costPredMAD < 0)
    1693   {
    1694     costPredMAD = m_costMADs[MAD_Previous];
    1695     m_paramY1   = MAD_PRED_Y1;
    1696     m_paramY2   = MAD_PRED_Y2;
    1697   }
    1698   return costPredMAD;
    1699 }
    1700 
    1701 Void    MADLinearModel::updateMADLiearModel()
    1702 {
    1703   Double dNewY1 = ((m_costMADs[MAD_Previous] - m_costMADs[MAD_PPrevious]) / (m_costMADs[MAD_PPrevious] - m_costMADs[MAD_PPPrevious]));
    1704   Double dNewY2 =  (m_costMADs[MAD_Previous] - (dNewY1*m_costMADs[MAD_PPrevious]));
    1705  
    1706   m_paramY1 = 0.70+0.20*m_paramY1+ 0.10*dNewY1;
    1707   m_paramY2 =      0.20*m_paramY2+ 0.10*dNewY2;
    1708 }
    1709 
    1710 Void    MADLinearModel::updateMADHistory(Double dMAD)
    1711 {
    1712   m_costMADs[MAD_PPPrevious] = m_costMADs[MAD_PPrevious];
    1713   m_costMADs[MAD_PPrevious ] = m_costMADs[MAD_Previous ];
    1714   m_costMADs[MAD_Previous  ] = dMAD;
    1715   m_activeOn = (m_costMADs[MAD_Previous  ] && m_costMADs[MAD_PPrevious ] && m_costMADs[MAD_PPPrevious]);
    1716 }
    1717 
    1718 
    1719 Void    PixelBaseURQQuadraticModel::initPixelBaseQuadraticModel()
    1720 {
    1721   m_paramHighX1 = HIGH_QSTEP_ALPHA;
    1722   m_paramHighX2 = HIGH_QSTEP_BETA;
    1723   m_paramLowX1  = LOW_QSTEP_ALPHA;
    1724   m_paramLowX2  = LOW_QSTEP_BETA;
    1725 }
    1726 
    1727 Int     PixelBaseURQQuadraticModel::getQP(Int qp, Int targetBits, Int numberOfPixels, Double costPredMAD)
    1728 {
    1729   Double qStep;
    1730   Double bppPerMAD = (Double)(targetBits/(numberOfPixels*costPredMAD));
    1731  
    1732   if(xConvertQP2QStep(qp) >= HIGH_QSTEP_THRESHOLD)
    1733   {
    1734     qStep = 1/( sqrt((bppPerMAD/m_paramHighX1)+((m_paramHighX2*m_paramHighX2)/(4*m_paramHighX1*m_paramHighX1))) - (m_paramHighX2/(2*m_paramHighX1)));
    1735   }
    1736   else
    1737   {
    1738     qStep = 1/( sqrt((bppPerMAD/m_paramLowX1)+((m_paramLowX2*m_paramLowX2)/(4*m_paramLowX1*m_paramLowX1))) - (m_paramLowX2/(2*m_paramLowX1)));
    1739   }
    1740  
    1741   return xConvertQStep2QP(qStep);
    1742 }
    1743 
    1744 Void    PixelBaseURQQuadraticModel::updatePixelBasedURQQuadraticModel (Int qp, Int bits, Int numberOfPixels, Double costMAD)
    1745 {
    1746   Double qStep     = xConvertQP2QStep(qp);
    1747   Double invqStep = (1/qStep);
    1748   Double paramNewX1, paramNewX2;
    1749  
    1750   if(qStep >= HIGH_QSTEP_THRESHOLD)
    1751   {
    1752     paramNewX2    = (((bits/(numberOfPixels*costMAD))-(23.3772*invqStep*invqStep))/((1-200*invqStep)*invqStep));
    1753     paramNewX1    = (23.3772-200*paramNewX2);
    1754     m_paramHighX1 = 0.70*HIGH_QSTEP_ALPHA + 0.20 * m_paramHighX1 + 0.10 * paramNewX1;
    1755     m_paramHighX2 = 0.70*HIGH_QSTEP_BETA  + 0.20 * m_paramHighX2 + 0.10 * paramNewX2;
    1756   }
    1757   else
    1758   {
    1759     paramNewX2   = (((bits/(numberOfPixels*costMAD))-(5.8091*invqStep*invqStep))/((1-9.5455*invqStep)*invqStep));
    1760     paramNewX1   = (5.8091-9.5455*paramNewX2);
    1761     m_paramLowX1 = 0.90*LOW_QSTEP_ALPHA + 0.09 * m_paramLowX1 + 0.01 * paramNewX1;
    1762     m_paramLowX2 = 0.90*LOW_QSTEP_BETA  + 0.09 * m_paramLowX2 + 0.01 * paramNewX2;
    1763   }
    1764 }
    1765 
    1766 Bool    PixelBaseURQQuadraticModel::checkUpdateAvailable(Int qpReference )
    1767 {
    1768   Double qStep = xConvertQP2QStep(qpReference);
    1769 
    1770   if (qStep > xConvertQP2QStep(MAX_QP)
    1771     ||qStep < xConvertQP2QStep(MIN_QP) )
    1772   {
    1773     return false;
    1774   }
    1775 
    1776   return true;
    1777 }
    1778 
    1779 Double  PixelBaseURQQuadraticModel::xConvertQP2QStep(Int qp )
    1780 {
    1781   Int i;
    1782   Double qStep;
    1783   static const Double mapQP2QSTEP[6] = { 0.625, 0.703, 0.797, 0.891, 1.000, 1.125 };
    1784 
    1785   qStep = mapQP2QSTEP[qp % 6];
    1786   for( i=0; i<(qp/6); i++)
    1787   {
    1788     qStep *= 2;
    1789   }
    1790 
    1791   return qStep;
    1792 }
    1793 
    1794 Int     PixelBaseURQQuadraticModel::xConvertQStep2QP(Double qStep )
    1795 {
    1796   Int per = 0, rem = 0;
    1797 
    1798   if( qStep < xConvertQP2QStep(MIN_QP))
    1799   {
    1800     return MIN_QP;
    1801   }
    1802   else if (qStep > xConvertQP2QStep(MAX_QP) )
    1803   {
    1804     return MAX_QP;
    1805   }
    1806 
    1807   while( qStep > xConvertQP2QStep(5) )
    1808   {
    1809     qStep /= 2.0;
    1810     per++;
    1811   }
    1812 
    1813   if (qStep <= 0.625)
    1814   {
    1815     rem = 0;
    1816   }
    1817   else if (qStep <= 0.703)
    1818   {
    1819     rem = 1;
    1820   }
    1821   else if (qStep <= 0.797)
    1822   {
    1823     rem = 2;
    1824   }
    1825   else if (qStep <= 0.891)
    1826   {
    1827     rem = 3;
    1828   }
    1829   else if (qStep <= 1.000)
    1830   {
    1831     rem = 4;
    1832   }
    1833   else
    1834   {
    1835     rem = 5;
    1836   }
    1837   return (per * 6 + rem);
    1838 }
    1839 
    1840 
    1841 Void  TEncRateCtrl::create(Int sizeIntraPeriod, Int sizeGOP, Int frameRate, Int targetKbps, Int qp, Int numLCUInBasicUnit, Int sourceWidth, Int sourceHeight, Int maxCUWidth, Int maxCUHeight)
    1842 {
    1843   Int leftInHeight, leftInWidth;
    1844 
    1845   m_sourceWidthInLCU         = (sourceWidth  / maxCUWidth  ) + (( sourceWidth  %  maxCUWidth ) ? 1 : 0);
    1846   m_sourceHeightInLCU        = (sourceHeight / maxCUHeight) + (( sourceHeight %  maxCUHeight) ? 1 : 0); 
    1847   m_isLowdelay               = (sizeIntraPeriod == -1) ? true : false;
    1848 
    1849   m_prevBitrate              = ( targetKbps << 10 );  // in units of 1,024 bps
    1850   m_currBitrate              = ( targetKbps << 10 );
    1851 
    1852   m_frameRate                = frameRate;
    1853   m_refFrameNum              = m_isLowdelay ? (sizeGOP) : (sizeGOP>>1);
    1854   m_nonRefFrameNum           = sizeGOP-m_refFrameNum;
    1855   m_sizeGOP                  = sizeGOP;
    1856   m_numOfPixels              = ((sourceWidth*sourceHeight*3)>>1);
    1857   m_indexGOP                 = 0;
    1858   m_indexFrame               = 0;
    1859   m_indexLCU                 = 0;
    1860   m_indexUnit                = 0;
    1861   m_indexRefFrame            = 0;
    1862   m_indexNonRefFrame         = 0;
    1863   m_occupancyVB              = 0;
    1864   m_initialOVB               = 0;
    1865   m_targetBufLevel           = 0;
    1866   m_initialTBL               = 0;
    1867   m_occupancyVBInFrame       = 0;
    1868   m_remainingBitsInGOP       = (m_currBitrate*sizeGOP/m_frameRate);
    1869   m_remainingBitsInFrame     = 0;
    1870   m_numUnitInFrame           = m_sourceWidthInLCU*m_sourceHeightInLCU;
    1871   m_cMADLinearModel.        initMADLinearModel();
    1872   m_cPixelURQQuadraticModel.initPixelBaseQuadraticModel();
    1873 
    1874   m_costRefAvgWeighting      = 0.0;
    1875   m_costNonRefAvgWeighting   = 0.0;
    1876   m_costAvgbpp               = 0.0; 
    1877   m_activeUnitLevelOn        = false;
    1878 
    1879   m_pcFrameData              = new FrameData   [sizeGOP+1];         initFrameData(qp);
    1880   m_pcLCUData                = new LCUData     [m_numUnitInFrame];  initUnitData (qp);
    1881 
    1882   for(Int i = 0, addressUnit = 0; i < m_sourceHeightInLCU*maxCUHeight; i += maxCUHeight) 
    1883   {
    1884     leftInHeight = sourceHeight - i;
    1885     leftInHeight = min(leftInHeight, maxCUHeight);
    1886     for(Int j = 0; j < m_sourceWidthInLCU*maxCUWidth; j += maxCUWidth, addressUnit++)
    1887     {
    1888       leftInWidth = sourceWidth - j;
    1889       leftInWidth = min(leftInWidth, maxCUWidth);
    1890       m_pcLCUData[addressUnit].m_widthInPixel = leftInWidth;
    1891       m_pcLCUData[addressUnit].m_heightInPixel= leftInHeight;
    1892       m_pcLCUData[addressUnit].m_pixels       = ((leftInHeight*leftInWidth*3)>>1);
    1893     }
    1894   }
    1895 }
    1896 
    1897 Void  TEncRateCtrl::destroy()
    1898 {
    1899   if(m_pcFrameData)
    1900   {
    1901     delete [] m_pcFrameData;
    1902     m_pcFrameData = NULL;
    1903   }
    1904   if(m_pcLCUData)
    1905   {
    1906     delete [] m_pcLCUData;
    1907     m_pcLCUData = NULL;
    1908   }
    1909 }
    1910 
    1911 Void  TEncRateCtrl::initFrameData   (Int qp)
    1912 {
    1913   for(Int i = 0 ; i <= m_sizeGOP; i++)
    1914   {
    1915     m_pcFrameData[i].m_isReferenced = false;
    1916     m_pcFrameData[i].m_costMAD      = 0.0;
    1917     m_pcFrameData[i].m_bits         = 0;
    1918     m_pcFrameData[i].m_qp           = qp;
    1919   }
    1920 }
    1921 
    1922 Void  TEncRateCtrl::initUnitData    (Int qp)
    1923 {
    1924   for(Int i = 1 ; i < m_numUnitInFrame; i++)
    1925   {
    1926     m_pcLCUData[i].m_qp            = qp;
    1927     m_pcLCUData[i].m_bits          = 0;
    1928     m_pcLCUData[i].m_pixels        = 0;
    1929     m_pcLCUData[i].m_widthInPixel  = 0;
    1930     m_pcLCUData[i].m_heightInPixel = 0;
    1931     m_pcLCUData[i].m_costMAD       = 0.0;
    1932   }
    1933 }
    1934 
    1935 Int  TEncRateCtrl::getFrameQP(Bool isReferenced, Int POC)
    1936 {
    1937   Int numofReferenced = 0;
    1938   Int finalQP = 0;
    1939   FrameData* pcFrameData;
    1940 
    1941   m_indexPOCInGOP = (POC%m_sizeGOP) == 0 ? m_sizeGOP : (POC%m_sizeGOP);
    1942   pcFrameData     = &m_pcFrameData[m_indexPOCInGOP];
    1943    
    1944   if(m_indexFrame != 0)
    1945   {
    1946     if(isReferenced)
    1947     {
    1948       Double gamma = m_isLowdelay ? 0.5 : 0.25;
    1949       Double beta  = m_isLowdelay ? 0.9 : 0.6;
    1950       Int    numRemainingRefFrames  = m_refFrameNum    - m_indexRefFrame;
    1951       Int    numRemainingNRefFrames = m_nonRefFrameNum - m_indexNonRefFrame;
    1952      
    1953       Double targetBitsOccupancy  = (m_currBitrate/(Double)m_frameRate) + gamma*(m_targetBufLevel-m_occupancyVB - (m_initialOVB/(Double)m_frameRate));
    1954       Double targetBitsLeftBudget = ((m_costRefAvgWeighting*m_remainingBitsInGOP)/((m_costRefAvgWeighting*numRemainingRefFrames)+(m_costNonRefAvgWeighting*numRemainingNRefFrames)));
    1955 
    1956       m_targetBits = (Int)(beta * targetBitsLeftBudget + (1-beta) * targetBitsOccupancy);
    1957  
    1958       if(m_targetBits <= 0 || m_remainingBitsInGOP <= 0)
    1959       {
    1960         finalQP = m_pcFrameData[m_indexPrevPOCInGOP].m_qp + 2;
    1961       }
    1962       else
    1963       {
    1964         Double costPredMAD   = m_cMADLinearModel.getMAD();
    1965         Int    qpLowerBound = m_pcFrameData[m_indexPrevPOCInGOP].m_qp-2;
    1966         Int    qpUpperBound = m_pcFrameData[m_indexPrevPOCInGOP].m_qp+2;
    1967         finalQP = m_cPixelURQQuadraticModel.getQP(m_pcFrameData[m_indexPrevPOCInGOP].m_qp, m_targetBits, m_numOfPixels, costPredMAD);
    1968         finalQP = max(qpLowerBound, min(qpUpperBound, finalQP));
    1969         m_activeUnitLevelOn    = true;
    1970         m_remainingBitsInFrame = m_targetBits;
    1971         m_costAvgbpp           = (m_targetBits/(Double)m_numOfPixels);
    1972       }
    1973 
    1974       m_indexRefFrame++;
    1975     }
    1976     else
    1977     {
    1978       Int bwdQP = m_pcFrameData[m_indexPOCInGOP-1].m_qp;
    1979       Int fwdQP = m_pcFrameData[m_indexPOCInGOP+1].m_qp;
    1980        
    1981       if( (fwdQP+bwdQP) == m_pcFrameData[m_indexPOCInGOP-1].m_qp
    1982         ||(fwdQP+bwdQP) == m_pcFrameData[m_indexPOCInGOP+1].m_qp)
    1983       {
    1984         finalQP = (fwdQP+bwdQP);
    1985       }
    1986       else if(bwdQP != fwdQP)
    1987       {
    1988         finalQP = ((bwdQP+fwdQP+2)>>1);
    1989       }
    1990       else
    1991       {
    1992         finalQP = bwdQP+2;
    1993       }
    1994       m_indexNonRefFrame++;
    1995     }
    1996   }
    1997   else
    1998   {
    1999     Int lastQPminus2 = m_pcFrameData[0].m_qp - 2;
    2000     Int lastQPplus2  = m_pcFrameData[0].m_qp + 2;
    2001 
    2002     for(Int idx = 1; idx <= m_sizeGOP; idx++)
    2003     {
    2004       if(m_pcFrameData[idx].m_isReferenced)
    2005       {
    2006         finalQP += m_pcFrameData[idx].m_qp;
    2007         numofReferenced++;
    2008       }
    2009     }
    2010    
    2011     finalQP = (numofReferenced == 0) ? m_pcFrameData[0].m_qp : ((finalQP + (1<<(numofReferenced>>1)))/numofReferenced);
    2012     finalQP = max( lastQPminus2, min( lastQPplus2, finalQP));
    2013 
    2014     Double costAvgFrameBits = m_remainingBitsInGOP/(Double)m_sizeGOP;
    2015     Int    bufLevel  = m_occupancyVB + m_initialOVB;
    2016 
    2017     if(abs(bufLevel) > costAvgFrameBits)
    2018     {
    2019       if(bufLevel < 0)
    2020       {
    2021         finalQP -= 2;
    2022       }
    2023       else
    2024       {
    2025         finalQP += 2;
    2026       }
    2027     }
    2028     m_indexRefFrame++;
    2029   }
    2030   finalQP = max(MIN_QP, min(MAX_QP, finalQP));
    2031 
    2032   for(Int indexLCU = 0 ; indexLCU < m_numUnitInFrame; indexLCU++)
    2033   {
    2034     m_pcLCUData[indexLCU].m_qp = finalQP;
    2035   }
    2036 
    2037   pcFrameData->m_isReferenced = isReferenced;
    2038   pcFrameData->m_qp           = finalQP;
    2039 
    2040   return finalQP;
    2041 }
    2042 
    2043 Bool  TEncRateCtrl::calculateUnitQP ()
    2044 {
    2045   if(!m_activeUnitLevelOn || m_indexLCU == 0)
    2046   {
    2047     return false;
    2048   }
    2049   Int upperQPBound, lowerQPBound, finalQP;
    2050   Int    colQP        = m_pcLCUData[m_indexLCU].m_qp;
    2051   Double colMAD       = m_pcLCUData[m_indexLCU].m_costMAD;
    2052   Double budgetInUnit = m_pcLCUData[m_indexLCU].m_pixels*m_costAvgbpp;
    2053 
    2054 
    2055   Int targetBitsOccupancy = (Int)(budgetInUnit - (m_occupancyVBInFrame/(m_numUnitInFrame-m_indexUnit)));
    2056   Int targetBitsLeftBudget= (Int)((m_remainingBitsInFrame*m_pcLCUData[m_indexLCU].m_pixels)/(Double)(m_numOfPixels-m_codedPixels));
    2057   Int targetBits = (targetBitsLeftBudget>>1) + (targetBitsOccupancy>>1);
    2058  
    2059 
    2060   if( m_indexLCU >= m_sourceWidthInLCU)
    2061   {
    2062     upperQPBound = ( (m_pcLCUData[m_indexLCU-1].m_qp + m_pcLCUData[m_indexLCU - m_sourceWidthInLCU].m_qp)>>1) + MAX_DELTA_QP;
    2063     lowerQPBound = ( (m_pcLCUData[m_indexLCU-1].m_qp + m_pcLCUData[m_indexLCU - m_sourceWidthInLCU].m_qp)>>1) - MAX_DELTA_QP;
    2064   }
    2065   else
    2066   {
    2067     upperQPBound = m_pcLCUData[m_indexLCU-1].m_qp + MAX_DELTA_QP;
    2068     lowerQPBound = m_pcLCUData[m_indexLCU-1].m_qp - MAX_DELTA_QP;
    2069   }
    2070 
    2071   if(targetBits < 0)
    2072   {
    2073     finalQP = m_pcLCUData[m_indexLCU-1].m_qp + 1;
    2074   }
    2075   else
    2076   {
    2077     finalQP = m_cPixelURQQuadraticModel.getQP(colQP, targetBits, m_pcLCUData[m_indexLCU].m_pixels, colMAD);
    2078   }
    2079  
    2080   finalQP = max(lowerQPBound, min(upperQPBound, finalQP));
    2081   m_pcLCUData[m_indexLCU].m_qp = max(MIN_QP, min(MAX_QP, finalQP));
    2082  
    2083   return true;
    2084 }
    2085 
    2086 Void  TEncRateCtrl::updateRCGOPStatus()
    2087 {
    2088   m_remainingBitsInGOP = ((m_currBitrate/m_frameRate)*m_sizeGOP) - m_occupancyVB;
    2089  
    2090   FrameData cFrameData = m_pcFrameData[m_sizeGOP];
    2091   initFrameData();
    2092 
    2093   m_pcFrameData[0]   = cFrameData;
    2094   m_indexGOP++;
    2095   m_indexFrame       = 0;
    2096   m_indexRefFrame    = 0;
    2097   m_indexNonRefFrame = 0;
    2098 }
    2099 
    2100 Void  TEncRateCtrl::updataRCFrameStatus(Int frameBits, SliceType eSliceType)
    2101 {
    2102   FrameData* pcFrameData = &m_pcFrameData[m_indexPOCInGOP];
    2103   Int occupancyBits;
    2104   Double adjustmentBits;
    2105 
    2106   m_remainingBitsInGOP = m_remainingBitsInGOP + ( ((m_currBitrate-m_prevBitrate)/m_frameRate)*(m_sizeGOP-m_indexFrame) ) - frameBits;
    2107   occupancyBits        = (Int)((Double)frameBits - (m_currBitrate/(Double)m_frameRate));
    2108  
    2109   if( (occupancyBits < 0) && (m_initialOVB > 0) )
    2110   {
    2111     adjustmentBits = xAdjustmentBits(occupancyBits, m_initialOVB );
    2112 
    2113     if(m_initialOVB < 0)
    2114     {
    2115       adjustmentBits = m_initialOVB;
    2116       occupancyBits += (Int)adjustmentBits;
    2117       m_initialOVB   =  0;
    2118     }
    2119   }
    2120   else if( (occupancyBits > 0) && (m_initialOVB < 0) )
    2121   {
    2122     adjustmentBits = xAdjustmentBits(m_initialOVB, occupancyBits );
    2123    
    2124     if(occupancyBits < 0)
    2125     {
    2126       adjustmentBits = occupancyBits;
    2127       m_initialOVB  += (Int)adjustmentBits;
    2128       occupancyBits  =  0;
    2129     }
    2130   }
    2131 
    2132   if(m_indexGOP == 0)
    2133   {
    2134     m_initialOVB = occupancyBits;
    2135   }
    2136   else
    2137   {
    2138     m_occupancyVB= m_occupancyVB + occupancyBits;
    2139   }
    2140 
    2141   if(pcFrameData->m_isReferenced)
    2142   {
    2143     m_costRefAvgWeighting  = ((pcFrameData->m_bits*pcFrameData->m_qp)/8.0) + (7.0*(m_costRefAvgWeighting)/8.0);
    2144 
    2145     if(m_indexFrame == 0)
    2146     {
    2147       m_initialTBL = m_targetBufLevel  = (frameBits - (m_currBitrate/m_frameRate));
    2148     }
    2149     else
    2150     {
    2151       Int distance = (m_costNonRefAvgWeighting == 0) ? 0 : 1;
    2152       m_targetBufLevel =  m_targetBufLevel
    2153                             - (m_initialTBL/(m_refFrameNum-1))
    2154                             + (Int)((m_costRefAvgWeighting*(distance+1)*m_currBitrate)/(m_frameRate*(m_costRefAvgWeighting+(m_costNonRefAvgWeighting*distance))))
    2155                             - (m_currBitrate/m_frameRate);
    2156     }
    2157 
    2158     if(m_cMADLinearModel.IsUpdateAvailable())
    2159     {
    2160       m_cMADLinearModel.updateMADLiearModel();
    2161     }
    2162 
    2163     if(eSliceType != I_SLICE &&
    2164        m_cPixelURQQuadraticModel.checkUpdateAvailable(pcFrameData->m_qp))
    2165     {
    2166       m_cPixelURQQuadraticModel.updatePixelBasedURQQuadraticModel(pcFrameData->m_qp, pcFrameData->m_bits, m_numOfPixels, pcFrameData->m_costMAD);
    2167     }
    2168   }
    2169   else
    2170   {
    2171     m_costNonRefAvgWeighting = ((pcFrameData->m_bits*pcFrameData->m_qp)/8.0) + (7.0*(m_costNonRefAvgWeighting)/8.0);
    2172   }
    2173 
    2174   m_indexFrame++;
    2175   m_indexLCU             = 0;
    2176   m_indexUnit            = 0;
    2177   m_occupancyVBInFrame   = 0;
    2178   m_remainingBitsInFrame = 0;
    2179   m_codedPixels          = 0;
    2180   m_activeUnitLevelOn    = false;
    2181   m_costAvgbpp           = 0.0;
    2182 }
    2183 Void  TEncRateCtrl::updataRCUnitStatus ()
    2184 {
    2185   if(!m_activeUnitLevelOn || m_indexLCU == 0)
    2186   {
    2187     return;
    2188   }
    2189 
    2190   m_codedPixels  += m_pcLCUData[m_indexLCU-1].m_pixels;
    2191   m_remainingBitsInFrame = m_remainingBitsInFrame - m_pcLCUData[m_indexLCU-1].m_bits;
    2192   m_occupancyVBInFrame   = (Int)(m_occupancyVBInFrame + m_pcLCUData[m_indexLCU-1].m_bits - m_pcLCUData[m_indexLCU-1].m_pixels*m_costAvgbpp);
    2193 
    2194   if( m_cPixelURQQuadraticModel.checkUpdateAvailable(m_pcLCUData[m_indexLCU-1].m_qp) )
    2195   {
    2196     m_cPixelURQQuadraticModel.updatePixelBasedURQQuadraticModel(m_pcLCUData[m_indexLCU-1].m_qp, m_pcLCUData[m_indexLCU-1].m_bits, m_pcLCUData[m_indexLCU-1].m_pixels, m_pcLCUData[m_indexLCU-1].m_costMAD);
    2197   }
    2198 
    2199   m_indexUnit++;
    2200 }
    2201 
    2202 Void  TEncRateCtrl::updateFrameData(UInt64 actualFrameBits)
    2203 {
    2204   Double costMAD = 0.0;
    2205  
    2206   for(Int i = 0; i < m_numUnitInFrame; i++)
    2207   {
    2208     costMAD    += m_pcLCUData[i].m_costMAD;
    2209   }
    2210  
    2211   m_pcFrameData[m_indexPOCInGOP].m_costMAD = (costMAD/(Double)m_numUnitInFrame);
    2212   m_pcFrameData[m_indexPOCInGOP].m_bits    = (Int)actualFrameBits;
    2213  
    2214   if(m_pcFrameData[m_indexPOCInGOP].m_isReferenced)
    2215   {
    2216     m_indexPrevPOCInGOP = m_indexPOCInGOP;
    2217     m_cMADLinearModel.updateMADHistory(m_pcFrameData[m_indexPOCInGOP].m_costMAD);
    2218   }
    2219 }
    2220 
    2221 Void  TEncRateCtrl::updateLCUData(TComDataCU* pcCU, UInt64 actualLCUBits, Int qp)
    2222 {
    2223   Int     x, y;
    2224   Double  costMAD = 0.0;
    2225 
    2226   Pel*  pOrg   = pcCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
    2227   Pel*  pRec   = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), 0);
    2228   Int   stride = pcCU->getPic()->getStride();
    2229 
    2230   Int   width  = m_pcLCUData[m_indexLCU].m_widthInPixel;
    2231   Int   height = m_pcLCUData[m_indexLCU].m_heightInPixel;
    2232 
    2233   for( y = 0; y < height; y++ )
    2234   {
    2235     for( x = 0; x < width; x++ )
    2236     {
    2237       costMAD += abs( pOrg[x] - pRec[x] );
    2238     }
    2239     pOrg += stride;
    2240     pRec += stride;
    2241   }
    2242   m_pcLCUData[m_indexLCU  ].m_qp      = qp;
    2243   m_pcLCUData[m_indexLCU  ].m_costMAD = (costMAD /(Double)(width*height));
    2244   m_pcLCUData[m_indexLCU++].m_bits    = (Int)actualLCUBits;
    2245 }
    2246 
    2247 
    2248 #if KWU_RC_MADPRED_E0227
    2249 Void  TEncRateCtrl::updateLCUDataEnhancedView(TComDataCU* pcCU, UInt64 uiBits, Int qp, Double basePos, Double curPos, Double focalLen, Double znear, Double zfar, Int direction)
    2250 {
    2251   Int     x, y;
    2252   Double dMAD = 0.0;
    2253   Int Sum = 0;
    2254   Double SAD = 0.0;
    2255 
    2256   Pel*  pOrg    = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
    2257   Pel*  pRec    = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), 0);
    2258   Pel*  pDep    = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
    2259   Int   iStride = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getStride();
    2260 
    2261   Int   width  = m_pcLCUData[m_indexLCU].m_widthInPixel;
    2262   Int   height = m_pcLCUData[m_indexLCU].m_heightInPixel;
    2263 
    2264   for( y = 0 ; y < pcCU->getSlice()->getSPS()->getMaxCUHeight() ; y+=8)
    2265   {
    2266     for( x = 0 ; x < pcCU->getSlice()->getSPS()->getMaxCUWidth() ; x+=8)
    2267     {
    2268       Sum += pDep[x];
    2269     }
    2270     pDep += iStride;
    2271   }
    2272 
    2273   Double AvgDepth = (Double)Sum/((pcCU->getSlice()->getSPS()->getMaxCUHeight()/8)*(pcCU->getSlice()->getSPS()->getMaxCUWidth()/8));
    2274   Double fL = focalLen * abs( basePos - curPos );
    2275   Double z  = abs( 1.0 / znear - 1.0 / zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / zfar);
    2276   Int   disparity = (Int)(direction*fL * z);
    2277   Int shift = DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthY-8);
    2278   Int disp = disparity;
    2279 
    2280   for( y = 0; y < height; y++ )
    2281   {
    2282     for( x = 0; x < width; x++ )
    2283     {
    2284       SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)]
    2285       - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)] )>>shift;
    2286     }
    2287     pOrg += iStride;
    2288     pRec += iStride;
    2289   }
    2290   m_pcLCUData[m_indexLCU].m_qp   = qp;
    2291   m_pcLCUData[m_indexLCU].m_costMAD  = (SAD /(Double)(width*height));
    2292   m_pcLCUData[m_indexLCU].m_bits = (Int)uiBits;
    2293 }
    2294 #endif
    2295 
    2296 
    2297 Double TEncRateCtrl::xAdjustmentBits(Int& reductionBits, Int& compensationBits)
    2298 {
    2299   Double adjustment  = ADJUSTMENT_FACTOR*reductionBits;
    2300   reductionBits     -= (Int)adjustment;
    2301   compensationBits  += (Int)adjustment;
    2302 
    2303   return adjustment;
    2304 }
    2305 
    2306 #endif
    2307 
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncRateCtrl.h

    r837 r838  
    326326  TRCLCU* m_LCUs;
    327327  Int m_picActualHeaderBits;    // only SH and potential APS
    328 #if !M0036_RC_IMPROVEMENT
    329   Double m_totalMAD;
    330 #endif
    331328  Double m_totalCostIntra;
    332329  Double m_remainingCostIntra;
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncSbac.cpp

    r837 r838  
    21292129  {
    21302130    m_pcBinIf->encodeBin( 1, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) );
    2131     m_pcBinIf->encodeBinEP( uiCode <= 4 ? 1 : 0 );
     2131    m_pcBinIf->encodeBinEP( uiCode == 1 ? 0 : 1 );
    21322132  }
    21332133}
     
    23322332}
    23332333
     2334Void TEncSbac::codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled)
     2335{
     2336  UInt uiSymbol;
     2337  if(!sliceEnabled)
     2338  {
     2339    assert(ctbParam.modeIdc == SAO_MODE_OFF);
     2340    return;
     2341  }
     2342
     2343  //type
     2344  if(compIdx == SAO_Y || compIdx == SAO_Cb)
     2345  {
     2346    //sao_type_idx_luma or sao_type_idx_chroma
     2347    if(ctbParam.modeIdc == SAO_MODE_OFF)
     2348    {
     2349      uiSymbol =0;
     2350    }
     2351    else if(ctbParam.typeIdc == SAO_TYPE_BO) //BO
     2352    {
     2353      uiSymbol = 1;
     2354    }
     2355    else
     2356    {
     2357      assert(ctbParam.typeIdc < SAO_TYPE_START_BO); //EO
     2358      uiSymbol = 2;
     2359    }
     2360    codeSaoTypeIdx(uiSymbol);
     2361  }
     2362
     2363  if(ctbParam.modeIdc == SAO_MODE_NEW)
     2364  {
     2365    Int numClasses = (ctbParam.typeIdc == SAO_TYPE_BO)?4:NUM_SAO_EO_CLASSES;
     2366    Int offset[4];
     2367    Int k=0;
     2368    for(Int i=0; i< numClasses; i++)
     2369    {
     2370      if(ctbParam.typeIdc != SAO_TYPE_BO && i == SAO_CLASS_EO_PLAIN)
     2371      {
     2372        continue;
     2373      }
     2374      Int classIdx = (ctbParam.typeIdc == SAO_TYPE_BO)?(  (ctbParam.typeAuxInfo+i)% NUM_SAO_BO_CLASSES   ):i;
     2375      offset[k] = ctbParam.offset[classIdx];
     2376      k++;
     2377    }
     2378
     2379    for(Int i=0; i< 4; i++)
     2380    {
     2381      codeSaoMaxUvlc((offset[i]<0)?(-offset[i]):(offset[i]),  g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs
     2382    }
     2383
     2384
     2385    if(ctbParam.typeIdc == SAO_TYPE_BO)
     2386    {
     2387      for(Int i=0; i< 4; i++)
     2388      {
     2389        if(offset[i] != 0)
     2390        {
     2391          codeSAOSign((offset[i]< 0)?1:0);
     2392        }
     2393      }
     2394
     2395      codeSaoUflc(NUM_SAO_BO_CLASSES_LOG2, ctbParam.typeAuxInfo ); //sao_band_position
     2396    }
     2397    else //EO
     2398    {
     2399      if(compIdx == SAO_Y || compIdx == SAO_Cb)
     2400      {
     2401        assert(ctbParam.typeIdc - SAO_TYPE_START_EO >=0);
     2402        codeSaoUflc(NUM_SAO_EO_TYPES_LOG2, ctbParam.typeIdc - SAO_TYPE_START_EO ); //sao_eo_class_luma or sao_eo_class_chroma
     2403      }
     2404    }
     2405
     2406  }
     2407}
     2408
     2409
     2410Void TEncSbac::codeSAOBlkParam(SAOBlkParam& saoBlkParam
     2411                              , Bool* sliceEnabled
     2412                              , Bool leftMergeAvail
     2413                              , Bool aboveMergeAvail
     2414                              , Bool onlyEstMergeInfo // = false
     2415                              )
     2416{
     2417
     2418  Bool isLeftMerge = false;
     2419  Bool isAboveMerge= false;
     2420
     2421  if(leftMergeAvail)
     2422  {
     2423    isLeftMerge = ((saoBlkParam[SAO_Y].modeIdc == SAO_MODE_MERGE) && (saoBlkParam[SAO_Y].typeIdc == SAO_MERGE_LEFT));
     2424    codeSaoMerge( isLeftMerge?1:0  ); //sao_merge_left_flag
     2425  }
     2426
     2427  if( aboveMergeAvail && !isLeftMerge)
     2428  {
     2429    isAboveMerge = ((saoBlkParam[SAO_Y].modeIdc == SAO_MODE_MERGE) && (saoBlkParam[SAO_Y].typeIdc == SAO_MERGE_ABOVE));
     2430    codeSaoMerge( isAboveMerge?1:0  ); //sao_merge_left_flag
     2431  }
     2432
     2433  if(onlyEstMergeInfo)
     2434  {
     2435    return; //only for RDO
     2436  }
     2437
     2438  if(!isLeftMerge && !isAboveMerge) //not merge mode
     2439  {
     2440    for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     2441    {
     2442      codeSAOOffsetParam(compIdx, saoBlkParam[compIdx], sliceEnabled[compIdx]);
     2443    }
     2444  }
     2445}
     2446
    23342447#if H_3D_INTER_SDC
    23352448#if QC_SDC_UNIFY_G0130
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncSearch.cpp

    r837 r838  
    726726  Pel*  piRefPos;
    727727  Int iRefStride = m_filteredBlock[0][0].getStride();
    728 #if NS_HAD
    729   m_pcRdCost->setDistParam( pcPatternKey, m_filteredBlock[0][0].getLumaAddr(), iRefStride, 1, m_cDistParam, m_pcEncCfg->getUseHADME(), m_pcEncCfg->getUseNSQT() );
    730 #else
    731728  m_pcRdCost->setDistParam( pcPatternKey, m_filteredBlock[0][0].getLumaAddr(), iRefStride, 1, m_cDistParam, m_pcEncCfg->getUseHADME() );
    732 #endif
    733729 
    734730  const TComMv* pcMvRefine = (iFrac == 2 ? s_acMvRefineH : s_acMvRefineQ);
     
    39503946      }
    39513947      else
    3952 #endif
    3953       {
     3948      {
     3949#endif
    39543950        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    39553951        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    39563952      }
    3957 
     3953#if NTT_STORE_SPDV_VSP_G0148
     3954}
     3955#endif
    39583956#if H_3D_VSP && !NTT_STORE_SPDV_VSP_G0148
    39593957      pcCU->setVSPFlagSubParts( vspFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
     
    55975595    {
    55985596#endif
    5599 #if WEIGHTED_CHROMA_DISTORTION
    56005597    uiDistortion = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight      )
    56015598    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_U )
    56025599    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_V );
    5603 #else
    5604     uiDistortion = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight      )
    5605     + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1 )
    5606     + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1 );
    5607 #endif
    5608 
    56095600#if H_3D_VSO // MIgnore
    56105601    }
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncSlice.cpp

    r837 r838  
    564564  m_pcRdCost->setCrDistortionWeight(weight[1]);
    565565
     566  const Double lambdaArray[3] = {lambda, (lambda / weight[0]), (lambda / weight[1])};
    566567
    567568#if RDOQ_CHROMA_LAMBDA
Note: See TracChangeset for help on using the changeset viewer.