Ignore:
Timestamp:
8 Feb 2014, 00:23:11 (10 years ago)
Author:
tech
Message:

Merged HM 13.0. (No yet checked).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp

    r833 r837  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5151Void TEncEntropy::encodeSliceHeader ( TComSlice* pcSlice )
    5252{
    53   if (pcSlice->getSPS()->getUseSAO())
    54   {
    55     SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();
    56     pcSlice->setSaoEnabledFlag     (saoParam->bSaoFlag[0]);
    57     {
    58       pcSlice->setSaoEnabledFlagChroma   (saoParam->bSaoFlag[1]);
    59     }
    60   }
    61 
    6253  m_pcEntropyCoderIf->codeSliceHeader( pcSlice );
    6354  return;
     
    787778}
    788779
    789 /** Encode SAO Offset
    790  * \param  saoLcuParam SAO LCU paramters
    791  */
    792 Void TEncEntropy::encodeSaoOffset(SaoLcuParam* saoLcuParam, UInt compIdx)
    793 {
    794   UInt uiSymbol;
    795   Int i;
    796 
    797   uiSymbol = saoLcuParam->typeIdx + 1;
    798   if (compIdx!=2)
    799   {
    800     m_pcEntropyCoderIf->codeSaoTypeIdx(uiSymbol);
    801   }
    802   if (uiSymbol)
    803   {
    804     if (saoLcuParam->typeIdx < 4 && compIdx != 2)
    805     {
    806       saoLcuParam->subTypeIdx = saoLcuParam->typeIdx;
    807     }
    808     Int bitDepth = compIdx ? g_bitDepthC : g_bitDepthY;
    809     Int offsetTh = 1 << min(bitDepth - 5,5);
    810     if( saoLcuParam->typeIdx == SAO_BO )
    811     {
    812       for( i=0; i< saoLcuParam->length; i++)
    813       {
    814         UInt absOffset = ( (saoLcuParam->offset[i] < 0) ? -saoLcuParam->offset[i] : saoLcuParam->offset[i]);
    815         m_pcEntropyCoderIf->codeSaoMaxUvlc(absOffset, offsetTh-1);
    816       } 
    817       for( i=0; i< saoLcuParam->length; i++)
    818       {
    819         if (saoLcuParam->offset[i] != 0)
    820         {
    821           UInt sign = (saoLcuParam->offset[i] < 0) ? 1 : 0 ;
    822           m_pcEntropyCoderIf->codeSAOSign(sign);
    823         }
    824       }
    825       uiSymbol = (UInt) (saoLcuParam->subTypeIdx);
    826       m_pcEntropyCoderIf->codeSaoUflc(5, uiSymbol);
    827     }
    828     else if( saoLcuParam->typeIdx < 4 )
    829     {
    830       m_pcEntropyCoderIf->codeSaoMaxUvlc( saoLcuParam->offset[0], offsetTh-1);
    831       m_pcEntropyCoderIf->codeSaoMaxUvlc( saoLcuParam->offset[1], offsetTh-1);
    832       m_pcEntropyCoderIf->codeSaoMaxUvlc(-saoLcuParam->offset[2], offsetTh-1);
    833       m_pcEntropyCoderIf->codeSaoMaxUvlc(-saoLcuParam->offset[3], offsetTh-1);
    834       if (compIdx!=2)
    835       {
    836         uiSymbol = (UInt) (saoLcuParam->subTypeIdx);
    837         m_pcEntropyCoderIf->codeSaoUflc(2, uiSymbol);
    838       }
    839     }
    840   }
    841 }
    842 
    843 /** Encode SAO unit interleaving
    844 * \param  rx
    845 * \param  ry
    846 * \param  pSaoParam
    847 * \param  pcCU
    848 * \param  iCUAddrInSlice
    849 * \param  iCUAddrUpInSlice
    850 * \param  bLFCrossSliceBoundaryFlag
    851  */
    852 Void TEncEntropy::encodeSaoUnitInterleaving(Int compIdx, Bool saoFlag, Int rx, Int ry, SaoLcuParam* saoLcuParam, Int cuAddrInSlice, Int cuAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp)
    853 {
    854   if (saoFlag)
    855   {
    856     if (rx>0 && cuAddrInSlice!=0 && allowMergeLeft)
    857     {
    858       m_pcEntropyCoderIf->codeSaoMerge(saoLcuParam->mergeLeftFlag);
    859     }
    860     else
    861     {
    862       saoLcuParam->mergeLeftFlag = 0;
    863     }
    864     if (saoLcuParam->mergeLeftFlag == 0)
    865     {
    866       if ( (ry > 0) && (cuAddrUpInSlice>=0) && allowMergeUp )
    867       {
    868         m_pcEntropyCoderIf->codeSaoMerge(saoLcuParam->mergeUpFlag);
    869       }
    870       else
    871       {
    872         saoLcuParam->mergeUpFlag = 0;
    873       }
    874       if (!saoLcuParam->mergeUpFlag)
    875       {
    876         encodeSaoOffset(saoLcuParam, compIdx);
    877       }
    878     }
    879   }
    880 }
    881 
    882780Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize )
    883781{
     
    900798}
    901799
    902 #if H_3D_INTER_SDC
    903 #if QC_SDC_UNIFY_G0130
    904 Void TEncEntropy::encodeDeltaDC  ( TComDataCU* pcCU, UInt absPartIdx )
    905 {
    906   m_pcEntropyCoderIf->codeDeltaDC( pcCU, absPartIdx );
    907 }
    908 
    909 Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    910 {
    911   if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) ||
    912     ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getVpsDepthModesFlag( pcCU->getSlice()->getLayerIdInVps() ) ) )
    913   {
    914     return;
    915   }
    916 
    917 #if SEC_INTER_SDC_G0101
    918   if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
    919 #else
    920   if( !pcCU->getSlice()->getIsDepth() || ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N ) || pcCU->isSkipped( uiAbsPartIdx ) )
    921 #endif
    922   {
    923     return;
    924   }
    925 
    926 #if SEC_INTER_SDC_G0101
    927   assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
    928 #else
    929   assert( ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
    930 #endif
    931 
    932   if( bRD )
    933   {
    934     uiAbsPartIdx = 0;
    935   }
    936 
    937   m_pcEntropyCoderIf->codeSDCFlag( pcCU, uiAbsPartIdx );
    938 }
    939 #else
    940 Void TEncEntropy::encodeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    941 {
    942   if( !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) )
    943   {
    944     return;
    945   }
    946 
    947   if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( uiAbsPartIdx ) || pcCU->isSkipped( uiAbsPartIdx ) )
    948   {
    949     return;
    950   }
    951 
    952   if( bRD )
    953   {
    954     uiAbsPartIdx = 0;
    955   }
    956 
    957   m_pcEntropyCoderIf->codeInterSDCFlag( pcCU, uiAbsPartIdx );
    958 }
    959 
    960 Void TEncEntropy::encodeInterSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    961 {
    962   if( !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) )
    963   {
    964     return;
    965   }
    966 
    967   if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( uiAbsPartIdx ) || !pcCU->getInterSDCFlag( uiAbsPartIdx ) )
    968   {
    969     return;
    970   }
    971 
    972   if( bRD )
    973   {
    974     uiAbsPartIdx = 0;
    975   }
    976 
    977   // number of segments depends on prediction mode for INTRA
    978   UInt uiNumSegments = ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ? 1 : ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 );
    979 
    980   // encode residual data for each segment
    981   for( UInt uiSeg = 0; uiSeg < uiNumSegments; uiSeg++ )
    982   {
    983     m_pcEntropyCoderIf->codeInterSDCResidualData( pcCU, uiAbsPartIdx, uiSeg );
    984   }
    985 }
    986 #endif
    987 #endif
    988 #if H_3D_DBBP
    989 Void TEncEntropy::encodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    990 {
    991   if( bRD )
    992   {
    993     uiAbsPartIdx = 0;
    994   }
    995   m_pcEntropyCoderIf->codeDBBPFlag( pcCU, uiAbsPartIdx );
    996 }
    997 #endif
    998 
    999800//! \}
Note: See TracChangeset for help on using the changeset viewer.