Changeset 595 in SHVCSoftware for trunk/source/Lib/TLibEncoder
- Timestamp:
- 2 Feb 2014, 06:01:53 (11 years ago)
- Location:
- trunk
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/SHM-5.0-dev merged: 591,593-594
- Property svn:mergeinfo changed
-
trunk/source
- Property svn:mergeinfo changed
/branches/SHM-5.0-dev/source merged: 593
- Property svn:mergeinfo changed
-
trunk/source/Lib/TLibEncoder/AnnexBwrite.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/NALwrite.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/NALwrite.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/SEIwrite.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 87 87 fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n"); 88 88 break; 89 case SEI::SOP_DESCRIPTION: 90 fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); 91 break; 92 case SEI::SCALABLE_NESTING: 93 fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); 94 break; 95 #if SVC_EXTENSION 89 96 #if LAYERS_NOT_PRESENT_SEI 90 97 case SEI::LAYERS_NOT_PRESENT: … … 92 99 break; 93 100 #endif 94 case SEI::SOP_DESCRIPTION:95 fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");96 break;97 101 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 98 102 case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: … … 105 109 break; 106 110 #endif 107 case SEI::SCALABLE_NESTING: 108 fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); 109 break; 111 #endif //SVC_EXTENSION 110 112 default: 111 113 fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); … … 155 157 xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei)); 156 158 break; 159 case SEI::SOP_DESCRIPTION: 160 xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei)); 161 break; 162 case SEI::SCALABLE_NESTING: 163 xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps); 164 break; 165 #if SVC_EXTENSION 157 166 #if LAYERS_NOT_PRESENT_SEI 158 167 case SEI::LAYERS_NOT_PRESENT: … … 160 169 break; 161 170 #endif 162 case SEI::SOP_DESCRIPTION:163 xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));164 break;165 171 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 166 172 case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: … … 173 179 break; 174 180 #endif 175 case SEI::SCALABLE_NESTING: 176 xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps); 177 break; 181 #endif //SVC_EXTENSION 178 182 default: 179 183 assert(!"Unhandled SEI message"); … … 337 341 if( !hrd->getSubPicCpbParamsPresentFlag() ) 338 342 { 339 WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "rap_cpb_params_present_flag" ); 343 WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "irap_cpb_params_present_flag" ); 344 } 345 if( sei.m_rapCpbParamsPresentFlag ) 346 { 347 WRITE_CODE( sei.m_cpbDelayOffset, hrd->getCpbRemovalDelayLengthMinus1() + 1, "cpb_delay_offset" ); 348 WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1() + 1, "dpb_delay_offset" ); 340 349 } 341 350 WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag"); 342 351 WRITE_CODE( sei.m_auCpbRemovalDelayDelta - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_delta_minus1" ); 343 if( sei.m_rapCpbParamsPresentFlag )344 {345 WRITE_CODE( sei.m_cpbDelayOffset, hrd->getCpbRemovalDelayLengthMinus1() + 1, "cpb_delay_offset" );346 WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1() + 1, "dpb_delay_offset" );347 }348 352 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 349 353 { … … 546 550 } 547 551 548 #if LAYERS_NOT_PRESENT_SEI549 Void SEIWriter::xWriteSEILayersNotPresent(const SEILayersNotPresent& sei)550 {551 WRITE_UVLC( sei.m_activeVpsId, "lp_sei_active_vps_id" );552 for (UInt i = 0; i < sei.m_vpsMaxLayers; i++)553 {554 WRITE_FLAG( sei.m_layerNotPresentFlag[i], "layer_not_present_flag" );555 }556 xWriteByteAlign();557 }558 #endif559 560 552 Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei) 561 553 { … … 578 570 xWriteByteAlign(); 579 571 } 572 573 Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps) 574 { 575 WRITE_FLAG( sei.m_bitStreamSubsetFlag, "bitstream_subset_flag" ); 576 WRITE_FLAG( sei.m_nestingOpFlag, "nesting_op_flag " ); 577 if (sei.m_nestingOpFlag) 578 { 579 WRITE_FLAG( sei.m_defaultOpFlag, "default_op_flag" ); 580 WRITE_UVLC( sei.m_nestingNumOpsMinus1, "nesting_num_ops" ); 581 for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++) 582 { 583 WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" ); 584 WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3, "nesting_max_temporal_id" ); 585 WRITE_UVLC( sei.m_nestingOpIdx[i], "nesting_op_idx" ); 586 } 587 } 588 else 589 { 590 WRITE_FLAG( sei.m_allLayersFlag, "all_layers_flag" ); 591 if (!sei.m_allLayersFlag) 592 { 593 WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" ); 594 WRITE_UVLC( sei.m_nestingNumLayersMinus1, "nesting_num_layers" ); 595 for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) 596 { 597 WRITE_CODE( sei.m_nestingLayerId[i], 6, "nesting_layer_id" ); 598 } 599 } 600 } 601 602 // byte alignment 603 while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) 604 { 605 WRITE_FLAG( 0, "nesting_zero_bit" ); 606 } 607 608 // write nested SEI messages 609 for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++) 610 { 611 writeSEImessage(bs, *(*it), sps); 612 } 613 } 614 615 Void SEIWriter::xWriteByteAlign() 616 { 617 if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0) 618 { 619 WRITE_FLAG( 1, "bit_equal_to_one" ); 620 while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) 621 { 622 WRITE_FLAG( 0, "bit_equal_to_zero" ); 623 } 624 } 625 }; 626 627 #if SVC_EXTENSION 628 #if LAYERS_NOT_PRESENT_SEI 629 Void SEIWriter::xWriteSEILayersNotPresent(const SEILayersNotPresent& sei) 630 { 631 WRITE_UVLC( sei.m_activeVpsId, "lp_sei_active_vps_id" ); 632 for (UInt i = 0; i < sei.m_vpsMaxLayers; i++) 633 { 634 WRITE_FLAG( sei.m_layerNotPresentFlag[i], "layer_not_present_flag" ); 635 } 636 xWriteByteAlign(); 637 } 638 #endif 580 639 581 640 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI … … 634 693 } 635 694 #endif 636 Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps) 637 { 638 WRITE_FLAG( sei.m_bitStreamSubsetFlag, "bitstream_subset_flag" ); 639 WRITE_FLAG( sei.m_nestingOpFlag, "nesting_op_flag " ); 640 if (sei.m_nestingOpFlag) 641 { 642 WRITE_FLAG( sei.m_defaultOpFlag, "default_op_flag" ); 643 WRITE_UVLC( sei.m_nestingNumOpsMinus1, "nesting_num_ops" ); 644 for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++) 645 { 646 WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" ); 647 WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3, "nesting_max_temporal_id" ); 648 WRITE_UVLC( sei.m_nestingOpIdx[i], "nesting_op_idx" ); 649 } 650 } 651 else 652 { 653 WRITE_FLAG( sei.m_allLayersFlag, "all_layers_flag" ); 654 if (!sei.m_allLayersFlag) 655 { 656 WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" ); 657 WRITE_UVLC( sei.m_nestingNumLayersMinus1, "nesting_num_layers" ); 658 for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) 659 { 660 WRITE_CODE( sei.m_nestingLayerId[i], 6, "nesting_layer_id" ); 661 } 662 } 663 } 664 665 // byte alignment 666 while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) 667 { 668 WRITE_FLAG( 0, "nesting_zero_bit" ); 669 } 670 671 // write nested SEI messages 672 for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++) 673 { 674 writeSEImessage(bs, *(*it), sps); 675 } 676 } 677 678 Void SEIWriter::xWriteByteAlign() 679 { 680 if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0) 681 { 682 WRITE_FLAG( 1, "bit_equal_to_one" ); 683 while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) 684 { 685 WRITE_FLAG( 0, "bit_equal_to_zero" ); 686 } 687 } 688 }; 695 #endif //SVC_EXTENSION 689 696 690 697 //! \} -
trunk/source/Lib/TLibEncoder/SEIwrite.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 64 64 Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei); 65 65 Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei); 66 Void xWriteSEISOPDescription(const SEISOPDescription& sei); 67 Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps); 68 Void xWriteByteAlign(); 69 #if SVC_EXTENSION 66 70 #if LAYERS_NOT_PRESENT_SEI 67 71 Void xWriteSEILayersNotPresent(const SEILayersNotPresent& sei); 68 72 #endif 69 Void xWriteSEISOPDescription(const SEISOPDescription& sei);70 73 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 71 74 Void xWriteSEIInterLayerConstrainedTileSets(const SEIInterLayerConstrainedTileSets& sei); … … 74 77 Void xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei); 75 78 #endif 76 Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps); 77 Void xWriteByteAlign(); 79 #endif //SVC_EXTENSION 78 80 }; 79 81 -
trunk/source/Lib/TLibEncoder/SyntaxElementWriter.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/SyntaxElementWriter.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncAnalyze.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncAnalyze.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncBinCoder.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncBinCoderCABAC.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 579 579 } 580 580 WRITE_FLAG( pcSPS->getTMVPFlagsPresent() ? 1 : 0, "sps_temporal_mvp_enable_flag" ); 581 581 582 WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(), "sps_strong_intra_smoothing_enable_flag" ); 582 583 … … 1733 1734 WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "slice_sao_luma_flag" ); 1734 1735 #if AUXILIARY_PICTURES 1735 if (pcSlice->getChromaFormatIdc() != CHROMA_400) 1736 { 1737 #endif 1738 #if HM_CLEANUP_SAO 1736 if (pcSlice->getChromaFormatIdc() != CHROMA_400) 1737 #endif 1739 1738 WRITE_FLAG( pcSlice->getSaoEnabledFlagChroma(), "slice_sao_chroma_flag" ); 1740 #else1741 {1742 SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();1743 WRITE_FLAG( saoParam->bSaoFlag[1], "slice_sao_chroma_flag" );1744 }1745 #endif1746 #if AUXILIARY_PICTURES1747 }1748 #endif1749 1739 } 1750 1740 } -
trunk/source/Lib/TLibEncoder/TEncCavlc.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 88 88 UInt getCoeffCost () { return m_uiCoeffCost; } 89 89 Void codeVPS ( TComVPS* pcVPS ); 90 #if VPS_EXTNS91 Void codeVPSExtension ( TComVPS* pcVPS );92 #endif93 94 #if VPS_VUI95 Void codeVPSVUI (TComVPS *vps);96 #endif97 #if REPN_FORMAT_IN_VPS98 Void codeRepFormat ( RepFormat *repFormat );99 #endif100 #if VPS_DPB_SIZE_TABLE101 Void codeVpsDpbSizeTable (TComVPS *vps);102 #endif103 90 Void codeVUI ( TComVUI *pcVUI, TComSPS* pcSPS ); 104 91 Void codeSPS ( TComSPS* pcSPS ); 105 #if SPS_EXTENSION106 Void codeSPSExtension ( TComSPS* pcSPS );107 #endif108 92 Void codePPS ( TComPPS* pcPPS ); 109 93 Void codeSliceHeader ( TComSlice* pcSlice ); … … 116 100 117 101 Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ); 118 #if HM_CLEANUP_SAO119 102 Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false){printf("only supported in CABAC"); assert(0); exit(-1);} 120 #else121 Void codeSAOSign ( UInt code ) { printf("Not supported\n"); assert (0); }122 Void codeSaoMaxUvlc ( UInt code, UInt maxSymbol ){printf("Not supported\n"); assert (0);}123 Void codeSaoMerge ( UInt uiCode ){printf("Not supported\n"); assert (0);}124 Void codeSaoTypeIdx ( UInt uiCode ){printf("Not supported\n"); assert (0);}125 Void codeSaoUflc ( UInt uiLength, UInt uiCode ){ assert(uiCode < 32); printf("Not supported\n"); assert (0);}126 #endif127 103 Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ); 128 104 Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); … … 165 141 Void codeDFSvlc ( Int iCode, const Char *pSymbolName ); 166 142 143 #if SPS_EXTENSION 144 Void codeSPSExtension ( TComSPS* pcSPS ); 145 #if VPS_EXTNS 146 Void codeVPSExtension ( TComVPS* pcVPS ); 147 #endif 148 #if VPS_VUI 149 Void codeVPSVUI (TComVPS *vps); 150 #endif 151 #if REPN_FORMAT_IN_VPS 152 Void codeRepFormat ( RepFormat *repFormat ); 153 #endif 154 #if VPS_DPB_SIZE_TABLE 155 Void codeVpsDpbSizeTable (TComVPS *vps); 156 #endif 157 #endif //SVC_EXTENSION 158 167 159 }; 168 160 -
trunk/source/Lib/TLibEncoder/TEncCfg.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 91 91 92 92 std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry); //input 93 94 #if REPN_FORMAT_IN_VPS95 struct RepFormatCfg96 {97 Int m_chromaFormatIdc;98 Bool m_separateColourPlaneFlag;99 Int m_picWidthInLumaSamples;100 Int m_picHeightInLumaSamples;101 Int m_bitDepthLuma;102 Int m_bitDepthChroma;103 RepFormatCfg()104 : m_chromaFormatIdc (CHROMA_420)105 , m_separateColourPlaneFlag (0)106 , m_picWidthInLumaSamples (352)107 , m_picHeightInLumaSamples (288)108 , m_bitDepthLuma (8)109 , m_bitDepthChroma (8)110 {}111 };112 std::istringstream &operator>>(std::istringstream &in, RepFormatCfg &repFormatCfg);113 #endif114 115 93 //! \ingroup TLibEncoder 116 94 //! \{ … … 162 140 Int m_maxTempLayer; ///< Max temporal layer 163 141 Bool m_useAMP; 164 #if VPS_EXTN_DIRECT_REF_LAYERS165 Int m_numDirectRefLayers;166 Int m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];167 168 Int m_numActiveRefLayers;169 Int m_predLayerId[MAX_VPS_LAYER_ID_PLUS1];170 Int m_numSamplePredRefLayers;171 Int m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];172 Int m_numMotionPredRefLayers;173 Int m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];174 Bool m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];175 Bool m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];176 #endif177 #if N0120_MAX_TID_REF_CFG178 Int m_maxTidIlRefPicsPlus1;179 #endif180 142 //======= Transform ============= 181 143 UInt m_uiQuadtreeTULog2MaxSize; … … 194 156 Int m_maxNumOffsetsPerPic; 195 157 Bool m_saoLcuBoundary; 196 #if !HM_CLEANUP_SAO197 Bool m_saoLcuBasedOptimization;198 #endif199 //====== Lossless ========200 Bool m_useLossless;201 158 //====== Motion search ======== 202 159 Int m_iFastSearch; // 0:Full search 1:Diamond 2:PMVFAST … … 210 167 Int m_chromaCbQpOffset; // Chroma Cb QP Offset (0:default) 211 168 Int m_chromaCrQpOffset; // Chroma Cr Qp Offset (0:default) 212 #if AUXILIARY_PICTURES213 ChromaFormat m_chromaFormatIDC;214 #endif215 169 216 170 #if ADAPTIVE_QP_SELECTION … … 222 176 223 177 //====== Tool list ======== 224 Bool m_bUseSBACRD;225 178 Bool m_bUseASR; 226 179 Bool m_bUseHADME; … … 233 186 Bool m_bUseCbfFastMode; 234 187 Bool m_useEarlySkipDetection; 235 #if FAST_INTRA_SHVC236 Bool m_useFastIntraScalable;237 #endif238 188 Bool m_useTransformSkip; 239 189 Bool m_useTransformSkipFast; … … 305 255 Int m_gradualDecodingRefreshInfoEnabled; 306 256 Int m_decodingUnitInfoSEIEnabled; 307 #if LAYERS_NOT_PRESENT_SEI308 Int m_layersNotPresentSEIEnabled;309 #endif310 257 Int m_SOPDescriptionSEIEnabled; 311 258 Int m_scalableNestingSEIEnabled; 312 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI313 Bool m_interLayerConstrainedTileSetsSEIEnabled;314 UInt m_ilNumSetsInMessage;315 Bool m_skippedTileSetPresentFlag;316 UInt m_topLeftTileIndex[1024];317 UInt m_bottomRightTileIndex[1024];318 UInt m_ilcIdc[1024];319 #endif320 259 //====== Weighted Prediction ======== 321 260 Bool m_useWeightedPred; //< Use of Weighting Prediction (P_SLICE) … … 335 274 Bool m_RCForceIntraQP; 336 275 Bool m_TransquantBypassEnableFlag; ///< transquant_bypass_enable_flag setting in PPS. 337 Bool m_CUTransquantBypassFlag Value; ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.276 Bool m_CUTransquantBypassFlagForce; ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true. 338 277 #if SVC_EXTENSION 339 static TComVPS 278 static TComVPS m_cVPS; 340 279 #else 341 280 TComVPS m_cVPS; … … 391 330 Bool m_crossLayerBLAFlag; 392 331 #endif 393 #endif 332 #if VPS_EXTN_DIRECT_REF_LAYERS 333 Int m_numDirectRefLayers; 334 Int m_refLayerId[MAX_VPS_LAYER_ID_PLUS1]; 335 336 Int m_numActiveRefLayers; 337 Int m_predLayerId[MAX_VPS_LAYER_ID_PLUS1]; 338 Int m_numSamplePredRefLayers; 339 Int m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; 340 Int m_numMotionPredRefLayers; 341 Int m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; 342 Bool m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; 343 Bool m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; 344 #endif 345 #if N0120_MAX_TID_REF_CFG 346 Int m_maxTidIlRefPicsPlus1; 347 #endif 348 #if AUXILIARY_PICTURES 349 ChromaFormat m_chromaFormatIDC; 350 #endif 351 #if FAST_INTRA_SHVC 352 Bool m_useFastIntraScalable; 353 #endif 354 #if LAYERS_NOT_PRESENT_SEI 355 Int m_layersNotPresentSEIEnabled; 356 #endif 357 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 358 Bool m_interLayerConstrainedTileSetsSEIEnabled; 359 UInt m_ilNumSetsInMessage; 360 Bool m_skippedTileSetPresentFlag; 361 UInt m_topLeftTileIndex[1024]; 362 UInt m_bottomRightTileIndex[1024]; 363 UInt m_ilcIdc[1024]; 364 #endif 365 #endif //SVC_EXTENSION 394 366 395 367 public: … … 437 409 Bool getMaxTempLayer () { return m_maxTempLayer; } 438 410 Void setMaxTempLayer ( Int maxTempLayer ) { m_maxTempLayer = maxTempLayer; } 439 #if VPS_EXTN_DIRECT_REF_LAYERS440 Int getNumDirectRefLayers () { return m_numDirectRefLayers; }441 Void setNumDirectRefLayers (Int num) { m_numDirectRefLayers = num; }442 443 Int getRefLayerId (Int i) { return m_refLayerId[i]; }444 Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; }445 446 Int getNumActiveRefLayers () { return m_numActiveRefLayers; }447 Void setNumActiveRefLayers (Int num) { m_numActiveRefLayers = num; }448 449 Int getPredLayerId (Int i) { return m_predLayerId[i]; }450 Void setPredLayerId (Int i, Int refLayerId) { m_predLayerId[i] = refLayerId; }451 452 Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; }453 Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; }454 455 Int getSamplePredRefLayerId (Int i) { return m_samplePredRefLayerId[i]; }456 Void setSamplePredRefLayerId (Int i, Int refLayerId) { m_samplePredRefLayerId[i] = refLayerId; }457 458 Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; }459 Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; }460 461 Int getMotionPredRefLayerId (Int i) { return m_motionPredRefLayerId[i]; }462 Void setMotionPredRefLayerId (Int i, Int refLayerId) { m_motionPredRefLayerId[i] = refLayerId; }463 464 Bool getSamplePredEnabledFlag (Int i) { return m_samplePredEnabledFlag[i]; }465 Void setSamplePredEnabledFlag (Int i,Bool flag) { m_samplePredEnabledFlag[i] = flag; }466 467 Bool getMotionPredEnabledFlag (Int i) { return m_motionPredEnabledFlag[i]; }468 Void setMotionPredEnabledFlag (Int i,Bool flag) { m_motionPredEnabledFlag[i] = flag; }469 #endif470 #if N0120_MAX_TID_REF_CFG471 Int getMaxTidIlRefPicsPlus1 () { return m_maxTidIlRefPicsPlus1; }472 Void setMaxTidIlRefPicsPlus1 (Int num) { m_maxTidIlRefPicsPlus1 = num; }473 #endif474 411 //======== Transform ============= 475 412 Void setQuadtreeTULog2MaxSize ( UInt u ) { m_uiQuadtreeTULog2MaxSize = u; } … … 508 445 Void setQPAdaptationRange ( Int i ) { m_iQPAdaptationRange = i; } 509 446 510 //====== Lossless ========511 Void setUseLossless (Bool b ) { m_useLossless = b; }512 447 //====== Sequence ======== 513 448 Int getFrameRate () { return m_iFrameRate; } … … 552 487 Bool getUseAdaptiveQP () { return m_bUseAdaptiveQP; } 553 488 Int getQPAdaptationRange () { return m_iQPAdaptationRange; } 554 //====== Lossless ========555 Bool getUseLossless () { return m_useLossless; }556 489 557 490 //==== Tool list ======== 558 Void setUseSBACRD ( Bool b ) { m_bUseSBACRD = b; }559 491 Void setUseASR ( Bool b ) { m_bUseASR = b; } 560 492 Void setUseHADME ( Bool b ) { m_bUseHADME = b; } … … 567 499 Void setUseCbfFastMode ( Bool b ) { m_bUseCbfFastMode = b; } 568 500 Void setUseEarlySkipDetection ( Bool b ) { m_useEarlySkipDetection = b; } 569 #if FAST_INTRA_SHVC570 Void setUseFastIntraScalable ( Bool b ) { m_useFastIntraScalable = b; }571 #endif572 501 Void setUseConstrainedIntraPred ( Bool b ) { m_bUseConstrainedIntraPred = b; } 573 502 Void setPCMInputBitDepthFlag ( Bool b ) { m_bPCMInputBitDepthFlag = b; } … … 578 507 Void setdQPs ( Int* p ) { m_aidQP = p; } 579 508 Void setDeltaQpRD ( UInt u ) {m_uiDeltaQpRD = u; } 580 Bool getUseSBACRD () { return m_bUseSBACRD; }581 509 Bool getUseASR () { return m_bUseASR; } 582 510 Bool getUseHADME () { return m_bUseHADME; } … … 589 517 Bool getUseCbfFastMode () { return m_bUseCbfFastMode; } 590 518 Bool getUseEarlySkipDetection () { return m_useEarlySkipDetection; } 591 #if FAST_INTRA_SHVC592 Bool getUseFastIntraScalable () { return m_useFastIntraScalable; }593 #endif594 519 Bool getUseConstrainedIntraPred () { return m_bUseConstrainedIntraPred; } 595 520 Bool getPCMInputBitDepthFlag () { return m_bPCMInputBitDepthFlag; } … … 625 550 Void setSaoLcuBoundary (Bool val) { m_saoLcuBoundary = val; } 626 551 Bool getSaoLcuBoundary () { return m_saoLcuBoundary; } 627 #if !HM_CLEANUP_SAO628 Void setSaoLcuBasedOptimization (Bool val) { m_saoLcuBasedOptimization = val; }629 Bool getSaoLcuBasedOptimization () { return m_saoLcuBasedOptimization; }630 #endif631 552 Void setLFCrossTileBoundaryFlag ( Bool val ) { m_loopFilterAcrossTilesEnabledFlag = val; } 632 553 Bool getLFCrossTileBoundaryFlag () { return m_loopFilterAcrossTilesEnabledFlag; } … … 748 669 Void setDecodingUnitInfoSEIEnabled(Int b) { m_decodingUnitInfoSEIEnabled = b; } 749 670 Int getDecodingUnitInfoSEIEnabled() { return m_decodingUnitInfoSEIEnabled; } 750 #if LAYERS_NOT_PRESENT_SEI751 Void setLayersNotPresentSEIEnabled(Int b) { m_layersNotPresentSEIEnabled = b; }752 Int getLayersNotPresentSEIEnabled() { return m_layersNotPresentSEIEnabled; }753 #endif754 671 Void setSOPDescriptionSEIEnabled(Int b) { m_SOPDescriptionSEIEnabled = b; } 755 672 Int getSOPDescriptionSEIEnabled() { return m_SOPDescriptionSEIEnabled; } 756 673 Void setScalableNestingSEIEnabled(Int b) { m_scalableNestingSEIEnabled = b; } 757 674 Int getScalableNestingSEIEnabled() { return m_scalableNestingSEIEnabled; } 758 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI759 Void setInterLayerConstrainedTileSetsSEIEnabled(Bool b) { m_interLayerConstrainedTileSetsSEIEnabled = b; }760 Bool getInterLayerConstrainedTileSetsSEIEnabled() { return m_interLayerConstrainedTileSetsSEIEnabled; }761 Void setIlNumSetsInMessage(UInt b) { m_ilNumSetsInMessage = b; }762 Int getIlNumSetsInMessage() { return m_ilNumSetsInMessage; }763 Void setSkippedTileSetPresentFlag(Bool b) { m_skippedTileSetPresentFlag = b; }764 Bool getSkippedTileSetPresentFlag() { return m_skippedTileSetPresentFlag; }765 Void setTopLeftTileIndex(UInt *b)766 {767 for (UInt i = 0; i < m_ilNumSetsInMessage; i++)768 {769 m_topLeftTileIndex[i] = b[i];770 }771 }772 UInt getTopLeftTileIndex(UInt b) { return m_topLeftTileIndex[b]; }773 Void setBottomRightTileIndex(UInt *b)774 {775 for (UInt i = 0; i < m_ilNumSetsInMessage; i++)776 {777 m_bottomRightTileIndex[i] = b[i];778 }779 }780 UInt getBottomRightTileIndex(UInt b) { return m_bottomRightTileIndex[b]; }781 Void setIlcIdc(UInt *b)782 {783 for (UInt i = 0; i < m_ilNumSetsInMessage; i++)784 {785 m_ilcIdc[i] = b[i];786 }787 }788 UInt getIlcIdc(UInt b) { return m_ilcIdc[b]; }789 #endif790 675 Void setUseWP ( Bool b ) { m_useWeightedPred = b; } 791 676 Void setWPBiPred ( Bool b ) { m_useWeightedBiPred = b; } … … 820 705 Bool getTransquantBypassEnableFlag() { return m_TransquantBypassEnableFlag; } 821 706 Void setTransquantBypassEnableFlag(Bool flag) { m_TransquantBypassEnableFlag = flag; } 822 Bool getCUTransquantBypassFlag Value() { return m_CUTransquantBypassFlagValue; }823 Void setCUTransquantBypassFlag Value(Bool flag) { m_CUTransquantBypassFlagValue = flag; }707 Bool getCUTransquantBypassFlagForceValue() { return m_CUTransquantBypassFlagForce; } 708 Void setCUTransquantBypassFlagForceValue(Bool flag) { m_CUTransquantBypassFlagForce = flag; } 824 709 Void setVPS(TComVPS *p) { m_cVPS = *p; } 825 710 TComVPS *getVPS() { return &m_cVPS; } … … 934 819 Void setCrossLayerBLAFlag(Bool b) { m_crossLayerBLAFlag = b; } 935 820 #endif 821 #if FAST_INTRA_SHVC 822 Bool getUseFastIntraScalable () { return m_useFastIntraScalable; } 823 Void setUseFastIntraScalable ( Bool b ) { m_useFastIntraScalable = b; } 824 #endif 825 #if VPS_EXTN_DIRECT_REF_LAYERS 826 Int getNumDirectRefLayers () { return m_numDirectRefLayers; } 827 Void setNumDirectRefLayers (Int num) { m_numDirectRefLayers = num; } 828 829 Int getRefLayerId (Int i) { return m_refLayerId[i]; } 830 Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } 831 832 Int getNumActiveRefLayers () { return m_numActiveRefLayers; } 833 Void setNumActiveRefLayers (Int num) { m_numActiveRefLayers = num; } 834 835 Int getPredLayerId (Int i) { return m_predLayerId[i]; } 836 Void setPredLayerId (Int i, Int refLayerId) { m_predLayerId[i] = refLayerId; } 837 838 Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; } 839 Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; } 840 841 Int getSamplePredRefLayerId (Int i) { return m_samplePredRefLayerId[i]; } 842 Void setSamplePredRefLayerId (Int i, Int refLayerId) { m_samplePredRefLayerId[i] = refLayerId; } 843 844 Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; } 845 Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; } 846 847 Int getMotionPredRefLayerId (Int i) { return m_motionPredRefLayerId[i]; } 848 Void setMotionPredRefLayerId (Int i, Int refLayerId) { m_motionPredRefLayerId[i] = refLayerId; } 849 850 Bool getSamplePredEnabledFlag (Int i) { return m_samplePredEnabledFlag[i]; } 851 Void setSamplePredEnabledFlag (Int i,Bool flag) { m_samplePredEnabledFlag[i] = flag; } 852 853 Bool getMotionPredEnabledFlag (Int i) { return m_motionPredEnabledFlag[i]; } 854 Void setMotionPredEnabledFlag (Int i,Bool flag) { m_motionPredEnabledFlag[i] = flag; } 855 #endif 856 #if N0120_MAX_TID_REF_CFG 857 Int getMaxTidIlRefPicsPlus1 () { return m_maxTidIlRefPicsPlus1; } 858 Void setMaxTidIlRefPicsPlus1 (Int num) { m_maxTidIlRefPicsPlus1 = num; } 859 #endif 860 #if LAYERS_NOT_PRESENT_SEI 861 Void setLayersNotPresentSEIEnabled(Int b) { m_layersNotPresentSEIEnabled = b; } 862 Int getLayersNotPresentSEIEnabled() { return m_layersNotPresentSEIEnabled; } 863 #endif 864 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 865 Void setInterLayerConstrainedTileSetsSEIEnabled(Bool b) { m_interLayerConstrainedTileSetsSEIEnabled = b; } 866 Bool getInterLayerConstrainedTileSetsSEIEnabled() { return m_interLayerConstrainedTileSetsSEIEnabled; } 867 Void setIlNumSetsInMessage(UInt b) { m_ilNumSetsInMessage = b; } 868 Int getIlNumSetsInMessage() { return m_ilNumSetsInMessage; } 869 Void setSkippedTileSetPresentFlag(Bool b) { m_skippedTileSetPresentFlag = b; } 870 Bool getSkippedTileSetPresentFlag() { return m_skippedTileSetPresentFlag; } 871 Void setTopLeftTileIndex(UInt *b) 872 { 873 for (UInt i = 0; i < m_ilNumSetsInMessage; i++) 874 { 875 m_topLeftTileIndex[i] = b[i]; 876 } 877 } 878 UInt getTopLeftTileIndex(UInt b) { return m_topLeftTileIndex[b]; } 879 Void setBottomRightTileIndex(UInt *b) 880 { 881 for (UInt i = 0; i < m_ilNumSetsInMessage; i++) 882 { 883 m_bottomRightTileIndex[i] = b[i]; 884 } 885 } 886 UInt getBottomRightTileIndex(UInt b) { return m_bottomRightTileIndex[b]; } 887 Void setIlcIdc(UInt *b) 888 { 889 for (UInt i = 0; i < m_ilNumSetsInMessage; i++) 890 { 891 m_ilcIdc[i] = b[i]; 892 } 893 } 894 UInt getIlcIdc(UInt b) { return m_ilcIdc[b]; } 895 #endif 936 896 #endif 937 897 }; 938 898 899 #if SVC_EXTENSION 900 #if REPN_FORMAT_IN_VPS 901 struct RepFormatCfg 902 { 903 Int m_chromaFormatIdc; 904 Bool m_separateColourPlaneFlag; 905 Int m_picWidthInLumaSamples; 906 Int m_picHeightInLumaSamples; 907 Int m_bitDepthLuma; 908 Int m_bitDepthChroma; 909 RepFormatCfg() 910 : m_chromaFormatIdc (CHROMA_420) 911 , m_separateColourPlaneFlag (0) 912 , m_picWidthInLumaSamples (352) 913 , m_picHeightInLumaSamples (288) 914 , m_bitDepthLuma (8) 915 , m_bitDepthChroma (8) 916 {} 917 }; 918 std::istringstream &operator>>(std::istringstream &in, RepFormatCfg &repFormatCfg); 919 #endif 920 #endif //SVC_EXTENSION 921 939 922 //! \} 940 923 -
trunk/source/Lib/TLibEncoder/TEncCu.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 223 223 m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder(); 224 224 225 m_bUseSBACRD = pcEncTop->getUseSBACRD();226 225 m_pcRateCtrl = pcEncTop->getRateCtrl(); 227 226 } … … 394 393 Int iMaxQP; 395 394 Bool isAddLowestQP = false; 396 #if REPN_FORMAT_IN_VPS397 Int lowestQP = -rpcTempCU->getSlice()->getQpBDOffsetY();398 #else399 Int lowestQP = -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY();400 #endif401 395 402 396 if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) … … 409 403 iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); 410 404 iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); 411 #endif 412 if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) 413 { 414 isAddLowestQP = true; 415 iMinQP = iMinQP - 1; 416 } 405 #endif 417 406 } 418 407 else … … 426 415 iMinQP = m_pcRateCtrl->getRCQP(); 427 416 iMaxQP = m_pcRateCtrl->getRCQP(); 417 } 418 419 // transquant-bypass (TQB) processing loop variable initialisation --- 420 421 const Int lowestQP = iMinQP; // For TQB, use this QP which is the lowest non TQB QP tested (rather than QP'=0) - that way delta QPs are smaller, and TQB can be tested at all CU levels. 422 423 if ( (rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) ) 424 { 425 isAddLowestQP = true; // mark that the first iteration is to cost TQB mode. 426 iMinQP = iMinQP - 1; // increase loop variable range by 1, to allow testing of TQB mode along with other QPs 427 if ( m_pcEncCfg->getCUTransquantBypassFlagForceValue() ) 428 { 429 iMaxQP = iMinQP; 430 } 428 431 } 429 432 … … 443 446 if (m_pcEncCfg->getSkipPictureAtArcSwitch() && m_pcEncCfg->getAdaptiveResolutionChange() > 0 && pcSlice->getLayerId() == 1 && pcSlice->getPOC() == m_pcEncCfg->getAdaptiveResolutionChange()) 444 447 { 445 rpcTempCU->initEstData( uiDepth, iBaseQP ); 448 Int iQP = iBaseQP; 449 const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP); 450 451 if( bIsLosslessMode ) 452 { 453 iQP = lowestQP; 454 } 455 456 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 446 457 447 458 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode, true ); … … 466 477 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 467 478 { 468 if (isAddLowestQP && (iQP == iMinQP)) 479 const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP); 480 481 if (bIsLosslessMode) 469 482 { 470 483 iQP = lowestQP; 471 484 } 472 485 473 rpcTempCU->initEstData( uiDepth, iQP );486 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 474 487 475 488 // do inter modes, SKIP and 2Nx2N … … 483 496 if(m_pcEncCfg->getUseEarlySkipDetection()) 484 497 { 485 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP );//by Competition for inter_2Nx2N 498 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); 499 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N 486 500 } 487 501 // SKIP 488 502 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N 489 rpcTempCU->initEstData( uiDepth, iQP );503 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 490 504 491 505 #if (ENCODER_FAST_MODE == 2) … … 496 510 { 497 511 // 2Nx2N, NxN 498 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP ); 512 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); 513 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 499 514 if(m_pcEncCfg->getUseCbfFastMode()) 500 515 { … … 507 522 } 508 523 509 if ( isAddLowestQP && (iQP == lowestQP))524 if (bIsLosslessMode) 510 525 { 511 526 iQP = iMinQP; … … 517 532 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 518 533 { 519 if (isAddLowestQP && (iQP == iMinQP)) 534 const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP); 535 536 if (bIsLosslessMode) 520 537 { 521 538 iQP = lowestQP; 522 539 } 523 rpcTempCU->initEstData( uiDepth, iQP );540 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 524 541 525 542 // do inter modes, NxN, 2NxN, and Nx2N … … 536 553 { 537 554 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 538 rpcTempCU->initEstData( uiDepth, iQP );555 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 539 556 } 540 557 } … … 544 561 { 545 562 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N ); 546 rpcTempCU->initEstData( uiDepth, iQP );563 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 547 564 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) 548 565 { … … 553 570 { 554 571 xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN ); 555 rpcTempCU->initEstData( uiDepth, iQP );572 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 556 573 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN) 557 574 { … … 581 598 { 582 599 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); 583 rpcTempCU->initEstData( uiDepth, iQP );600 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 584 601 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) 585 602 { … … 590 607 { 591 608 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); 592 rpcTempCU->initEstData( uiDepth, iQP );609 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 593 610 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) 594 611 { … … 603 620 { 604 621 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true ); 605 rpcTempCU->initEstData( uiDepth, iQP );622 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 606 623 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) 607 624 { … … 612 629 { 613 630 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true ); 614 rpcTempCU->initEstData( uiDepth, iQP );631 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 615 632 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) 616 633 { … … 627 644 { 628 645 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); 629 rpcTempCU->initEstData( uiDepth, iQP );646 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 630 647 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) 631 648 { … … 636 653 { 637 654 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); 638 rpcTempCU->initEstData( uiDepth, iQP );655 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 639 656 } 640 657 } … … 645 662 { 646 663 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true ); 647 rpcTempCU->initEstData( uiDepth, iQP );664 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 648 665 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) 649 666 { … … 654 671 { 655 672 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true ); 656 rpcTempCU->initEstData( uiDepth, iQP );673 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 657 674 } 658 675 } … … 661 678 #else 662 679 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); 663 rpcTempCU->initEstData( uiDepth, iQP );680 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 664 681 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); 665 rpcTempCU->initEstData( uiDepth, iQP );682 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 666 683 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); 667 rpcTempCU->initEstData( uiDepth, iQP );684 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 668 685 669 686 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); 670 rpcTempCU->initEstData( uiDepth, iQP );687 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 671 688 672 689 #endif … … 691 708 { 692 709 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); 693 rpcTempCU->initEstData( uiDepth, iQP);710 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 694 711 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) 695 712 { … … 697 714 { 698 715 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN ); 699 rpcTempCU->initEstData( uiDepth, iQP);716 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 700 717 } 701 718 } … … 712 729 { 713 730 xCheckIntraPCM (rpcBestCU, rpcTempCU); 714 rpcTempCU->initEstData( uiDepth, iQP );731 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 715 732 } 716 733 } … … 725 742 { 726 743 xCheckRDCostILRUni( rpcBestCU, rpcTempCU, pcSlice->getInterLayerPredLayerIdc(refLayer)); 727 rpcTempCU->initEstData( uiDepth, iQP );744 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 728 745 } 729 746 } 730 747 #endif 731 748 732 if ( isAddLowestQP && (iQP == lowestQP))749 if (bIsLosslessMode) 733 750 { 734 751 iQP = iMinQP; … … 740 757 m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true ); 741 758 rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits 742 if(m_pcEncCfg->getUseSBACRD())743 {744 759 rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 745 }746 760 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 747 761 … … 778 792 iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); 779 793 iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); 780 #endif 781 if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) 782 { 783 isAddLowestQP = true; 784 iMinQP = iMinQP - 1; 785 } 794 #endif 786 795 } 787 796 else if( (g_uiMaxCUWidth>>uiDepth) > rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) … … 810 819 iMaxQP = m_pcRateCtrl->getRCQP(); 811 820 } 821 822 if ( m_pcEncCfg->getCUTransquantBypassFlagForceValue() ) 823 { 824 iMaxQP = iMinQP; // If all blocks are forced into using transquant bypass, do not loop here. 825 } 826 812 827 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 813 828 { 814 if (isAddLowestQP && (iQP == iMinQP)) 815 { 816 iQP = lowestQP; 817 } 818 rpcTempCU->initEstData( uiDepth, iQP ); 829 const Bool bIsLosslessMode = false; // False at this level. Next level down may set it to true. 830 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 819 831 820 832 // further split … … 837 849 #endif 838 850 { 839 if ( m_bUseSBACRD )851 if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer 840 852 { 841 if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer 842 { 843 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 844 } 845 else 846 { 847 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 848 } 853 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 854 } 855 else 856 { 857 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 849 858 } 850 859 … … 878 887 879 888 rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits 880 if(m_pcEncCfg->getUseSBACRD()) 881 { 882 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 883 } 889 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 884 890 } 885 891 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); … … 913 919 m_pcEntropyCoder->encodeQP( rpcTempCU, uiTargetPartIdx, false ); 914 920 rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits 915 if(m_pcEncCfg->getUseSBACRD()) 916 { 917 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 918 } 921 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 919 922 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 920 923 #endif … … 930 933 } 931 934 932 if( m_bUseSBACRD ) 933 { 934 m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 935 } 935 m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 936 936 937 Bool isEndOfSlice = rpcBestCU->getSlice()->getSliceMode()==FIXED_NUMBER_OF_BYTES 937 938 && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceArgument()<<3); … … 944 945 xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth); // RD compare current larger prediction 945 946 } // with sub partitioned prediction. 946 if (isAddLowestQP && (iQP == lowestQP))947 {948 iQP = iMinQP;949 }950 947 } 951 948 … … 1334 1331 UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; 1335 1332 Int numValidMergeCand = 0; 1333 const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0); 1336 1334 1337 1335 for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui ) … … 1341 1339 UChar uhDepth = rpcTempCU->getDepth( 0 ); 1342 1340 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level 1343 rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );1344 1341 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); 1345 1342 … … 1385 1382 // set MC parameters 1386 1383 rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth ); // interprets depth relative to LCU level 1387 rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );1384 rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag, 0, uhDepth ); 1388 1385 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level 1389 1386 rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level … … 1415 1412 xCheckDQP( rpcTempCU ); 1416 1413 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); 1417 rpcTempCU->initEstData( uhDepth, orgQP );1414 rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag ); 1418 1415 1419 1416 if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip ) … … 1478 1475 rpcTempCU->setPartSizeSubParts ( ePartSize, 0, uhDepth ); 1479 1476 rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); 1480 rpcTempCU->setCUTransquantBypassSubParts ( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );1481 1477 1482 1478 #if AMP_MRG … … 1509 1505 rpcTempCU->setPartSizeSubParts( eSize, 0, uiDepth ); 1510 1506 rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); 1511 rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uiDepth );1512 1507 1513 1508 Bool bSeparateLumaChroma = true; // choose estimation mode … … 1539 1534 setdQPFlag( bCodeDQP ); 1540 1535 1541 if( m_bUseSBACRD )m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);1536 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 1542 1537 1543 1538 rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); 1544 if(m_pcEncCfg->getUseSBACRD()) 1545 { 1546 rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1547 } 1539 rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1548 1540 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1549 1541 … … 1570 1562 rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); 1571 1563 rpcTempCU->setTrIdxSubParts ( 0, 0, uiDepth ); 1572 rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uiDepth );1573 1564 1574 1565 m_pcPredSearch->IPCMSearch( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth]); 1575 1566 1576 if( m_bUseSBACRD )m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);1567 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 1577 1568 1578 1569 m_pcEntropyCoder->resetBits(); … … 1586 1577 m_pcEntropyCoder->encodeIPCMInfo ( rpcTempCU, 0, true ); 1587 1578 1588 if( m_bUseSBACRD )m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);1579 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 1589 1580 1590 1581 rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); 1591 if(m_pcEncCfg->getUseSBACRD()) 1592 { 1593 rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1594 } 1582 rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1595 1583 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1596 1584 … … 1627 1615 pcCU = NULL; 1628 1616 1629 if( m_bUseSBACRD )// store temp best CI for next CU coding1630 1617 // store temp best CI for next CU coding 1618 m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); 1631 1619 } 1632 1620 } … … 1644 1632 m_pcEntropyCoder->encodeQP( pcCU, 0, false ); 1645 1633 pcCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits 1646 if(m_pcEncCfg->getUseSBACRD()) 1647 { 1648 pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1649 } 1634 pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1650 1635 pcCU->getTotalCost() = m_pcRdCost->calcRdCost( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); 1651 1636 #endif … … 1795 1780 } 1796 1781 1782 /** Collect ARL statistics from one LCU 1783 * \param pcCU 1784 */ 1785 Void TEncCu::xLcuCollectARLStats(TComDataCU* rpcCU ) 1786 { 1787 Double cSum[ LEVEL_RANGE + 1 ]; //: the sum of DCT coefficients corresponding to datatype and quantization output 1788 UInt numSamples[ LEVEL_RANGE + 1 ]; //: the number of coefficients corresponding to datatype and quantization output 1789 1790 TCoeff* pCoeffY = rpcCU->getCoeffY(); 1791 Int* pArlCoeffY = rpcCU->getArlCoeffY(); 1792 1793 UInt uiMinCUWidth = g_uiMaxCUWidth >> g_uiMaxCUDepth; 1794 UInt uiMinNumCoeffInCU = 1 << uiMinCUWidth; 1795 1796 memset( cSum, 0, sizeof( Double )*(LEVEL_RANGE+1) ); 1797 memset( numSamples, 0, sizeof( UInt )*(LEVEL_RANGE+1) ); 1798 1799 // Collect stats to cSum[][] and numSamples[][] 1800 for(Int i = 0; i < rpcCU->getTotalNumPart(); i ++ ) 1801 { 1802 UInt uiTrIdx = rpcCU->getTransformIdx(i); 1803 1804 if(rpcCU->getPredictionMode(i) == MODE_INTER) 1805 if( rpcCU->getCbf( i, TEXT_LUMA, uiTrIdx ) ) 1806 { 1807 xTuCollectARLStats(pCoeffY, pArlCoeffY, uiMinNumCoeffInCU, cSum, numSamples); 1808 }//Note that only InterY is processed. QP rounding is based on InterY data only. 1809 1810 pCoeffY += uiMinNumCoeffInCU; 1811 pArlCoeffY += uiMinNumCoeffInCU; 1812 } 1813 1814 for(Int u=1; u<LEVEL_RANGE;u++) 1815 { 1816 m_pcTrQuant->getSliceSumC()[u] += cSum[ u ] ; 1817 m_pcTrQuant->getSliceNSamples()[u] += numSamples[ u ] ; 1818 } 1819 m_pcTrQuant->getSliceSumC()[LEVEL_RANGE] += cSum[ LEVEL_RANGE ] ; 1820 m_pcTrQuant->getSliceNSamples()[LEVEL_RANGE] += numSamples[ LEVEL_RANGE ] ; 1821 } 1822 #endif 1823 1824 #if SVC_EXTENSION 1797 1825 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 1798 1826 Bool TEncCu::xCheckTileSetConstraint( TComDataCU*& rpcCU ) … … 1861 1889 #endif 1862 1890 1863 /** Collect ARL statistics from one LCU1864 * \param pcCU1865 */1866 Void TEncCu::xLcuCollectARLStats(TComDataCU* rpcCU )1867 {1868 Double cSum[ LEVEL_RANGE + 1 ]; //: the sum of DCT coefficients corresponding to datatype and quantization output1869 UInt numSamples[ LEVEL_RANGE + 1 ]; //: the number of coefficients corresponding to datatype and quantization output1870 1871 TCoeff* pCoeffY = rpcCU->getCoeffY();1872 Int* pArlCoeffY = rpcCU->getArlCoeffY();1873 1874 UInt uiMinCUWidth = g_uiMaxCUWidth >> g_uiMaxCUDepth;1875 UInt uiMinNumCoeffInCU = 1 << uiMinCUWidth;1876 1877 memset( cSum, 0, sizeof( Double )*(LEVEL_RANGE+1) );1878 memset( numSamples, 0, sizeof( UInt )*(LEVEL_RANGE+1) );1879 1880 // Collect stats to cSum[][] and numSamples[][]1881 for(Int i = 0; i < rpcCU->getTotalNumPart(); i ++ )1882 {1883 UInt uiTrIdx = rpcCU->getTransformIdx(i);1884 1885 if(rpcCU->getPredictionMode(i) == MODE_INTER)1886 if( rpcCU->getCbf( i, TEXT_LUMA, uiTrIdx ) )1887 {1888 xTuCollectARLStats(pCoeffY, pArlCoeffY, uiMinNumCoeffInCU, cSum, numSamples);1889 }//Note that only InterY is processed. QP rounding is based on InterY data only.1890 1891 pCoeffY += uiMinNumCoeffInCU;1892 pArlCoeffY += uiMinNumCoeffInCU;1893 }1894 1895 for(Int u=1; u<LEVEL_RANGE;u++)1896 {1897 m_pcTrQuant->getSliceSumC()[u] += cSum[ u ] ;1898 m_pcTrQuant->getSliceNSamples()[u] += numSamples[ u ] ;1899 }1900 m_pcTrQuant->getSliceSumC()[LEVEL_RANGE] += cSum[ LEVEL_RANGE ] ;1901 m_pcTrQuant->getSliceNSamples()[LEVEL_RANGE] += numSamples[ LEVEL_RANGE ] ;1902 }1903 #endif1904 1905 1891 #if (ENCODER_FAST_MODE) 1906 1892 Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt refLayerId) … … 1913 1899 rpcTempCU->setPartSizeSubParts ( SIZE_2Nx2N, 0, uhDepth ); //2Nx2N 1914 1900 rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); 1915 rpcTempCU->setCUTransquantBypassSubParts ( m_pcEncCfg->getCUTransquantBypassFlag Value(), 0, uhDepth );1901 rpcTempCU->setCUTransquantBypassSubParts ( m_pcEncCfg->getCUTransquantBypassFlagForceValue(), 0, uhDepth ); 1916 1902 Bool exitILR = m_pcPredSearch->predInterSearchILRUni( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], refLayerId ); 1917 1903 if(!exitILR) … … 1926 1912 } 1927 1913 #endif 1914 #endif //SVC_EXTENSION 1928 1915 //! \} -
trunk/source/Lib/TLibEncoder/TEncCu.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 89 89 TComRdCost* m_pcRdCost; 90 90 91 #if SVC_EXTENSION92 TEncTop** m_ppcTEncTop;93 #endif94 95 91 TEncEntropy* m_pcEntropyCoder; 96 92 TEncCavlc* m_pcCavlcCoder; … … 101 97 TEncSbac*** m_pppcRDSbacCoder; 102 98 TEncSbac* m_pcRDGoOnSbacCoder; 103 Bool m_bUseSBACRD;104 99 TEncRateCtrl* m_pcRateCtrl; 105 100 101 #if SVC_EXTENSION 102 TEncTop** m_ppcTEncTop; 106 103 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 107 104 Bool m_disableILP; 108 105 #endif 106 #endif //SVC_EXTENSION 109 107 public: 110 108 /// copy parameters from encoder class … … 148 146 #endif 149 147 Void xCheckRDCostIntra ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize ); 150 #if ENCODER_FAST_MODE151 Void xCheckRDCostILRUni ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId);152 #endif153 148 Void xCheckDQP ( TComDataCU* pcCU ); 154 149 … … 167 162 #endif 168 163 169 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI170 Bool xCheckTileSetConstraint( TComDataCU*& rpcCU );171 Void xVerifyTileSetConstraint( TComDataCU*& rpcCU );172 #endif173 174 164 #if AMP_ENC_SPEEDUP 175 165 #if AMP_MRG … … 180 170 #endif 181 171 172 Void xFillPCMBuffer ( TComDataCU*& pCU, TComYuv* pOrgYuv ); 173 182 174 #if SVC_EXTENSION 183 175 TEncTop* getLayerEnc(UInt LayerId) {return m_ppcTEncTop[LayerId]; } 184 #endif 185 186 Void xFillPCMBuffer ( TComDataCU*& pCU, TComYuv* pOrgYuv ); 176 #if ENCODER_FAST_MODE 177 Void xCheckRDCostILRUni ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId); 178 #endif 179 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 180 Bool xCheckTileSetConstraint( TComDataCU*& rpcCU ); 181 Void xVerifyTileSetConstraint( TComDataCU*& rpcCU ); 182 #endif 183 #endif //SVC_EXTENSION 187 184 }; 188 185 -
trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 51 51 Void TEncEntropy::encodeSliceHeader ( TComSlice* pcSlice ) 52 52 { 53 #if !HM_CLEANUP_SAO54 if (pcSlice->getSPS()->getUseSAO())55 {56 SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();57 pcSlice->setSaoEnabledFlag (saoParam->bSaoFlag[0]);58 {59 pcSlice->setSaoEnabledFlagChroma (saoParam->bSaoFlag[1]);60 }61 }62 #endif63 53 m_pcEntropyCoderIf->codeSliceHeader( pcSlice ); 64 54 return; … … 639 629 } 640 630 641 #if !HM_CLEANUP_SAO642 /** Encode SAO Offset643 * \param saoLcuParam SAO LCU paramters644 */645 Void TEncEntropy::encodeSaoOffset(SaoLcuParam* saoLcuParam, UInt compIdx)646 {647 UInt uiSymbol;648 Int i;649 650 uiSymbol = saoLcuParam->typeIdx + 1;651 if (compIdx!=2)652 {653 m_pcEntropyCoderIf->codeSaoTypeIdx(uiSymbol);654 }655 if (uiSymbol)656 {657 if (saoLcuParam->typeIdx < 4 && compIdx != 2)658 {659 saoLcuParam->subTypeIdx = saoLcuParam->typeIdx;660 }661 Int bitDepth = compIdx ? g_bitDepthC : g_bitDepthY;662 Int offsetTh = 1 << min(bitDepth - 5,5);663 if( saoLcuParam->typeIdx == SAO_BO )664 {665 for( i=0; i< saoLcuParam->length; i++)666 {667 UInt absOffset = ( (saoLcuParam->offset[i] < 0) ? -saoLcuParam->offset[i] : saoLcuParam->offset[i]);668 m_pcEntropyCoderIf->codeSaoMaxUvlc(absOffset, offsetTh-1);669 }670 for( i=0; i< saoLcuParam->length; i++)671 {672 if (saoLcuParam->offset[i] != 0)673 {674 UInt sign = (saoLcuParam->offset[i] < 0) ? 1 : 0 ;675 m_pcEntropyCoderIf->codeSAOSign(sign);676 }677 }678 uiSymbol = (UInt) (saoLcuParam->subTypeIdx);679 m_pcEntropyCoderIf->codeSaoUflc(5, uiSymbol);680 }681 else if( saoLcuParam->typeIdx < 4 )682 {683 m_pcEntropyCoderIf->codeSaoMaxUvlc( saoLcuParam->offset[0], offsetTh-1);684 m_pcEntropyCoderIf->codeSaoMaxUvlc( saoLcuParam->offset[1], offsetTh-1);685 m_pcEntropyCoderIf->codeSaoMaxUvlc(-saoLcuParam->offset[2], offsetTh-1);686 m_pcEntropyCoderIf->codeSaoMaxUvlc(-saoLcuParam->offset[3], offsetTh-1);687 if (compIdx!=2)688 {689 uiSymbol = (UInt) (saoLcuParam->subTypeIdx);690 m_pcEntropyCoderIf->codeSaoUflc(2, uiSymbol);691 }692 }693 }694 }695 696 /** Encode SAO unit interleaving697 * \param rx698 * \param ry699 * \param pSaoParam700 * \param pcCU701 * \param iCUAddrInSlice702 * \param iCUAddrUpInSlice703 * \param bLFCrossSliceBoundaryFlag704 */705 Void TEncEntropy::encodeSaoUnitInterleaving(Int compIdx, Bool saoFlag, Int rx, Int ry, SaoLcuParam* saoLcuParam, Int cuAddrInSlice, Int cuAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp)706 {707 if (saoFlag)708 {709 if (rx>0 && cuAddrInSlice!=0 && allowMergeLeft)710 {711 m_pcEntropyCoderIf->codeSaoMerge(saoLcuParam->mergeLeftFlag);712 }713 else714 {715 saoLcuParam->mergeLeftFlag = 0;716 }717 if (saoLcuParam->mergeLeftFlag == 0)718 {719 if ( (ry > 0) && (cuAddrUpInSlice>=0) && allowMergeUp )720 {721 m_pcEntropyCoderIf->codeSaoMerge(saoLcuParam->mergeUpFlag);722 }723 else724 {725 saoLcuParam->mergeUpFlag = 0;726 }727 if (!saoLcuParam->mergeUpFlag)728 {729 encodeSaoOffset(saoLcuParam, compIdx);730 }731 }732 }733 }734 735 #endif736 737 631 Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ) 738 632 { -
trunk/source/Lib/TLibEncoder/TEncEntropy.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 105 105 virtual Void codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0; 106 106 virtual Void codeTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, TextType eTType ) = 0; 107 #if HM_CLEANUP_SAO108 107 virtual Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false) =0; 109 #else110 virtual Void codeSAOSign ( UInt code ) = 0;111 virtual Void codeSaoMaxUvlc ( UInt code, UInt maxSymbol ) = 0;112 virtual Void codeSaoMerge ( UInt uiCode ) = 0;113 virtual Void codeSaoTypeIdx ( UInt uiCode) = 0;114 virtual Void codeSaoUflc ( UInt uiLength, UInt uiCode ) = 0;115 #endif116 108 virtual Void estBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) = 0; 117 109 … … 192 184 193 185 Void estimateBit ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType); 194 #if HM_CLEANUP_SAO195 186 Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);} 196 #else197 Void encodeSaoOffset(SaoLcuParam* saoLcuParam, UInt compIdx);198 Void encodeSaoUnitInterleaving(Int compIdx, Bool saoFlag, Int rx, Int ry, SaoLcuParam* saoLcuParam, Int cuAddrInSlice, Int cuAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp);199 #endif200 187 static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ); 201 188 -
trunk/source/Lib/TLibEncoder/TEncGOP.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 96 96 xResetNonNestedSEIPresentFlags(); 97 97 xResetNestedSEIPresentFlags(); 98 #if FIX1172 99 m_associatedIRAPType = NAL_UNIT_CODED_SLICE_IDR_N_LP; 100 m_associatedIRAPPOC = 0; 101 #endif 98 102 #if SVC_UPSAMPLING 99 103 m_pcPredSearch = NULL; … … 167 171 } 168 172 169 #if LAYERS_NOT_PRESENT_SEI170 SEILayersNotPresent* TEncGOP::xCreateSEILayersNotPresent ()171 {172 UInt i = 0;173 SEILayersNotPresent *seiLayersNotPresent = new SEILayersNotPresent();174 seiLayersNotPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId();175 seiLayersNotPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers();176 for ( ; i < seiLayersNotPresent->m_vpsMaxLayers; i++)177 {178 seiLayersNotPresent->m_layerNotPresentFlag[i] = true;179 }180 for ( ; i < MAX_LAYERS; i++)181 {182 seiLayersNotPresent->m_layerNotPresentFlag[i] = false;183 }184 return seiLayersNotPresent;185 }186 #endif187 173 188 174 SEIFramePacking* TEncGOP::xCreateSEIFramePacking() … … 307 293 } 308 294 309 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI310 SEIInterLayerConstrainedTileSets* TEncGOP::xCreateSEIInterLayerConstrainedTileSets()311 {312 SEIInterLayerConstrainedTileSets *seiInterLayerConstrainedTileSets = new SEIInterLayerConstrainedTileSets();313 seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag = false;314 seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag = false;315 if (!seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag)316 {317 seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 = m_pcCfg->getIlNumSetsInMessage() - 1;318 if (seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1)319 {320 seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = m_pcCfg->getSkippedTileSetPresentFlag();321 }322 else323 {324 seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = false;325 }326 seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 += seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag ? 1 : 0;327 for (UInt i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++)328 {329 seiInterLayerConstrainedTileSets->m_ilctsId[i] = i;330 seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i] = 0;331 for( UInt j = 0; j <= seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i]; j++)332 {333 seiInterLayerConstrainedTileSets->m_ilTopLeftTileIndex[i][j] = m_pcCfg->getTopLeftTileIndex(i);334 seiInterLayerConstrainedTileSets->m_ilBottomRightTileIndex[i][j] = m_pcCfg->getBottomRightTileIndex(i);335 }336 seiInterLayerConstrainedTileSets->m_ilcIdc[i] = m_pcCfg->getIlcIdc(i);337 if (seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag)338 {339 seiInterLayerConstrainedTileSets->m_ilExactSampleValueMatchFlag[i] = false;340 }341 }342 }343 344 return seiInterLayerConstrainedTileSets;345 }346 #endif347 348 295 Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps) 349 296 { … … 362 309 m_activeParameterSetSEIPresentInAU = true; 363 310 } 364 365 #if LAYERS_NOT_PRESENT_SEI366 if(m_pcCfg->getLayersNotPresentSEIEnabled())367 {368 SEILayersNotPresent *sei = xCreateSEILayersNotPresent ();369 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);370 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);371 writeRBSPTrailingBits(nalu.m_Bitstream);372 accessUnit.push_back(new NALUnitEBSP(nalu));373 delete sei;374 }375 #endif376 311 377 312 if(m_pcCfg->getFramePackingArrangementSEIEnabled()) … … 408 343 delete sei; 409 344 } 345 346 #if SVC_EXTENSION 347 #if LAYERS_NOT_PRESENT_SEI 348 if(m_pcCfg->getLayersNotPresentSEIEnabled()) 349 { 350 SEILayersNotPresent *sei = xCreateSEILayersNotPresent (); 351 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 352 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps); 353 writeRBSPTrailingBits(nalu.m_Bitstream); 354 accessUnit.push_back(new NALUnitEBSP(nalu)); 355 delete sei; 356 } 357 #endif 358 410 359 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 411 360 if(m_pcCfg->getInterLayerConstrainedTileSetsSEIEnabled()) … … 421 370 } 422 371 #endif 372 #endif //SVC_EXTENSION 423 373 } 424 374 … … 547 497 #endif 548 498 549 if( getNalUnitType(pocCurr, m_iLastIDR ) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP )499 if( getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 550 500 { 551 501 m_iLastIDR = pocCurr; … … 554 504 accessUnitsInGOP.push_back(AccessUnit()); 555 505 AccessUnit& accessUnit = accessUnitsInGOP.back(); 556 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField 506 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField); 557 507 558 508 // Slice data initialization … … 571 521 pcSlice->getPic()->setField(isField); 572 522 523 #if SVC_EXTENSION 573 524 #if POC_RESET_FLAG 574 525 if( !pcSlice->getPocResetFlag() ) // For picture that are not reset, we should adjust the value of POC calculated from the configuration files. … … 636 587 #endif 637 588 #if O0149_CROSS_LAYER_BLA_FLAG 638 if( m_layerId == 0 && (getNalUnitType(pocCurr, m_iLastIDR ) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP) )589 if( m_layerId == 0 && (getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_N_LP) ) 639 590 { 640 591 pcSlice->setCrossLayerBLAFlag(m_pcEncTop->getCrossLayerBLAFlag()); … … 693 644 } 694 645 #endif 646 #endif //SVC_EXTENSION 695 647 696 648 pcSlice->setLastIDR(m_iLastIDR); … … 760 712 pcSlice->setDefaultScalingList (); 761 713 } 762 763 714 pcSlice->getScalingList()->checkDcOfMatrix(); 764 715 m_pcEncTop->getSPS()->setScalingListPresentFlag(pcSlice->checkDefaultScalingList()); … … 782 733 pcSlice->setSliceType(P_SLICE); 783 734 } 735 if(pcSlice->getSliceType()==B_SLICE&&m_pcCfg->getGOPEntry(iGOPid).m_sliceType=='I') 736 { 737 pcSlice->setSliceType(I_SLICE); 738 } 739 784 740 // Set the nal unit type 785 pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR ));741 pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR, isField)); 786 742 #if SVC_EXTENSION 787 743 if (m_layerId > 0) … … 953 909 m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid); 954 910 pcSlice->getRPS()->setNumberOfLongtermPictures(0); 911 #if FIX1172 912 if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 913 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 914 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP 915 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL 916 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP 917 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // IRAP picture 918 { 919 m_associatedIRAPType = pcSlice->getNalUnitType(); 920 m_associatedIRAPPOC = pocCurr; 921 } 922 pcSlice->setAssociatedIRAPType(m_associatedIRAPType); 923 pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC); 924 #endif 955 925 956 926 if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) || (pcSlice->isIRAP())) … … 960 930 pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS()); 961 931 962 if(pcSlice->getTLayer() > 0) 932 if(pcSlice->getTLayer() > 0 933 && !( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N // Check if not a leading picture 934 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R 935 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N 936 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R ) 937 ) 963 938 { 964 939 if(pcSlice->isTemporalLayerSwitchingPoint(rcListPic) || pcSlice->getSPS()->getTemporalIdNestingFlag()) … … 1633 1608 1634 1609 // SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas 1635 #if HM_CLEANUP_SAO1636 1610 if( pcSlice->getSPS()->getUseSAO() && m_pcCfg->getSaoLcuBoundary() ) 1637 1611 { 1638 1612 m_pcSAO->getPreDBFStatistics(pcPic); 1639 1613 } 1640 #else1641 if( m_pcCfg->getSaoLcuBasedOptimization() && m_pcCfg->getSaoLcuBoundary() )1642 {1643 m_pcSAO->resetStats();1644 m_pcSAO->calcSaoStatsCu_BeforeDblk( pcPic );1645 }1646 #endif1647 1614 //-- Loop filter 1648 1615 Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); … … 1654 1621 m_pcLoopFilter->loopFilterPic( pcPic ); 1655 1622 1656 #if !HM_CLEANUP_SAO1657 pcSlice = pcPic->getSlice(0);1658 if(pcSlice->getSPS()->getUseSAO())1659 {1660 std::vector<Bool> LFCrossSliceBoundaryFlag;1661 for(Int s=0; s< uiNumSlices; s++)1662 {1663 LFCrossSliceBoundaryFlag.push_back( ((uiNumSlices==1)?true:pcPic->getSlice(s)->getLFCrossSliceBoundaryFlag()) );1664 }1665 m_storedStartCUAddrForEncodingSlice.resize(uiNumSlices+1);1666 pcPic->createNonDBFilterInfo(m_storedStartCUAddrForEncodingSlice, 0, &LFCrossSliceBoundaryFlag ,pcPic->getPicSym()->getNumTiles() ,bLFCrossTileBoundary);1667 }1668 1669 1670 pcSlice = pcPic->getSlice(0);1671 1672 if(pcSlice->getSPS()->getUseSAO())1673 {1674 m_pcSAO->createPicSaoInfo(pcPic);1675 }1676 #endif1677 1623 /////////////////////////////////////////////////////////////////////////////////////////////////// File writing 1678 1624 // Set entropy coder … … 1792 1738 { 1793 1739 SOPcurrPOC += deltaPOC; 1794 SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR );1740 SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR, isField); 1795 1741 SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId; 1796 1742 SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j); … … 2257 2203 m_pcEntropyCoder->resetEntropy(); 2258 2204 m_pcEntropyCoder->setBitstream( m_pcBitCounter ); 2259 #if HM_CLEANUP_SAO2260 2205 Bool sliceEnabled[NUM_SAO_COMPONENTS]; 2261 2206 m_pcSAO->initRDOCabacCoder(m_pcEncTop->getRDGoOnSbacCoder(), pcSlice); … … 2276 2221 pcPic->getSlice(s)->setSaoEnabledFlagChroma(sliceEnabled[SAO_Cb]); 2277 2222 } 2278 #else2279 m_pcSAO->startSaoEnc(pcPic, m_pcEntropyCoder, m_pcEncTop->getRDSbacCoder(), m_pcEncTop->getRDGoOnSbacCoder());2280 SAOParam& cSaoParam = *pcSlice->getPic()->getPicSym()->getSaoParam();2281 2282 #if SAO_ENCODING_CHOICE2283 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdas()[TEXT_LUMA], pcPic->getSlice(0)->getLambdas()[TEXT_CHROMA], pcPic->getSlice(0)->getDepth());2284 #else2285 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma());2286 #endif2287 m_pcSAO->endSaoEnc();2288 m_pcSAO->PCMLFDisableProcess(pcPic);2289 #endif2290 2223 } 2291 #if !HM_CLEANUP_SAO2292 #if SAO_RDO2293 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice );2294 #endif2295 #endif2296 2224 processingState = ENCODE_SLICE; 2297 #if !HM_CLEANUP_SAO2298 #if HIGHER_LAYER_IRAP_SKIP_FLAG2299 if ( ( m_pcEncTop->getSkipPictureAtArcSwitch() && m_pcEncTop->getAdaptiveResolutionChange() > 0 && pcSlice->getLayerId() == 1 && pcSlice->getPOC() == m_pcEncTop->getAdaptiveResolutionChange()) )2300 {2301 pcSlice->getPic()->getPicSym()->getSaoParam()->bSaoFlag[0]=0;2302 pcSlice->getPic()->getPicSym()->getSaoParam()->bSaoFlag[1]=0;2303 }2304 #endif2305 for(Int s=0; s< uiNumSlices; s++)2306 {2307 if (pcSlice->getSPS()->getUseSAO())2308 {2309 pcPic->getSlice(s)->setSaoEnabledFlag((pcSlice->getPic()->getPicSym()->getSaoParam()->bSaoFlag[0]==1)?true:false);2310 }2311 }2312 #endif2313 2225 } 2314 2226 break; … … 2321 2233 } 2322 2234 } // end iteration over slices 2323 #if !HM_CLEANUP_SAO2324 if(pcSlice->getSPS()->getUseSAO())2325 {2326 if(pcSlice->getSPS()->getUseSAO())2327 {2328 m_pcSAO->destroyPicSaoInfo();2329 }2330 pcPic->destroyNonDBFilterInfo();2331 }2332 #endif2333 2235 pcPic->compressMotion(); 2334 2236 … … 2402 2304 2403 2305 //In case of field coding, compute the interlaced PSNR for both fields 2404 if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff)))2306 if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff)) && (pcPic->getPOC()%m_iGopSize != 1)) 2405 2307 { 2406 2308 //get complementary top field … … 2414 2316 xCalculateInterlacedAddPSNR(pcPicTop, pcPic, pcPicTop->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime ); 2415 2317 } 2318 else if (isField && pcPic->getPOC()!= 0 && (pcPic->getPOC()%m_iGopSize == 0)) 2319 { 2320 //get complementary bottom field 2321 TComPic* pcPicBottom; 2322 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 2323 while ((*iterPic)->getPOC() != pcPic->getPOC()+1) 2324 { 2325 iterPic ++; 2326 } 2327 pcPicBottom = *(iterPic); 2328 xCalculateInterlacedAddPSNR(pcPic, pcPicBottom, pcPic->getPicYuvRec(), pcPicBottom->getPicYuvRec(), accessUnit, dEncTime ); 2329 } 2416 2330 2417 2331 if (digestStr) … … 2717 2631 m_pcEntropyCoder->resetEntropy (); 2718 2632 m_pcEntropyCoder->setBitstream ( m_pcBitCounter ); 2719 #if !HM_CLEANUP_SAO2720 pcSlice = pcPic->getSlice(0);2721 if(pcSlice->getSPS()->getUseSAO())2722 {2723 std::vector<Bool> LFCrossSliceBoundaryFlag(1, true);2724 std::vector<Int> sliceStartAddress;2725 sliceStartAddress.push_back(0);2726 sliceStartAddress.push_back(pcPic->getNumCUsInFrame()* pcPic->getNumPartInCU());2727 pcPic->createNonDBFilterInfo(sliceStartAddress, 0, &LFCrossSliceBoundaryFlag);2728 }2729 2730 if( pcSlice->getSPS()->getUseSAO())2731 {2732 pcPic->destroyNonDBFilterInfo();2733 }2734 #endif2735 2633 m_pcEntropyCoder->resetEntropy (); 2736 2634 ruiBits += m_pcEntropyCoder->getNumberOfWrittenBits(); … … 3303 3201 * This function checks the configuration and returns the appropriate nal_unit_type for the picture. 3304 3202 */ 3305 NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR )3203 NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR, Bool isField) 3306 3204 { 3307 3205 if (pocCurr == 0) … … 3309 3207 return NAL_UNIT_CODED_SLICE_IDR_W_RADL; 3310 3208 } 3311 if ( pocCurr% m_pcCfg->getIntraPeriod() == 0)3209 if ((pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0) 3312 3210 { 3313 3211 if (m_pcCfg->getDecodingRefreshType() == 1) … … 3532 3430 return seiStartPos; 3533 3431 } 3534 3535 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI3536 Void TEncGOP::xBuildTileSetsMap(TComPicSym* picSym)3537 {3538 Int numCUs = picSym->getFrameWidthInCU() * picSym->getFrameHeightInCU();3539 3540 for (Int i = 0; i < numCUs; i++)3541 {3542 picSym->setTileSetIdxMap(i, -1, 0, false);3543 }3544 3545 for (Int i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++)3546 {3547 TComTile* topLeftTile = picSym->getTComTile(m_pcCfg->getTopLeftTileIndex(i));3548 TComTile* bottomRightTile = picSym->getTComTile(m_pcCfg->getBottomRightTileIndex(i));3549 Int tileSetLeftEdgePosInCU = topLeftTile->getRightEdgePosInCU() - topLeftTile->getTileWidth() + 1;3550 Int tileSetRightEdgePosInCU = bottomRightTile->getRightEdgePosInCU();3551 Int tileSetTopEdgePosInCU = topLeftTile->getBottomEdgePosInCU() - topLeftTile->getTileHeight() + 1;3552 Int tileSetBottomEdgePosInCU = bottomRightTile->getBottomEdgePosInCU();3553 assert(tileSetLeftEdgePosInCU < tileSetRightEdgePosInCU && tileSetTopEdgePosInCU < tileSetBottomEdgePosInCU);3554 for (Int j = tileSetTopEdgePosInCU; j <= tileSetBottomEdgePosInCU; j++)3555 {3556 for (Int k = tileSetLeftEdgePosInCU; k <= tileSetRightEdgePosInCU; k++)3557 {3558 picSym->setTileSetIdxMap(j * picSym->getFrameWidthInCU() + k, i, m_pcCfg->getIlcIdc(i), false);3559 }3560 }3561 }3562 3563 if (m_pcCfg->getSkippedTileSetPresentFlag())3564 {3565 Int skippedTileSetIdx = m_pcCfg->getIlNumSetsInMessage();3566 for (Int i = 0; i < numCUs; i++)3567 {3568 if (picSym->getTileSetIdxMap(i) < 0)3569 {3570 picSym->setTileSetIdxMap(i, skippedTileSetIdx, 0, true);3571 }3572 }3573 }3574 }3575 #endif3576 3432 3577 3433 Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices ) … … 3698 3554 free(rowSAD); 3699 3555 } 3556 #if SVC_EXTENSION 3557 #if LAYERS_NOT_PRESENT_SEI 3558 SEILayersNotPresent* TEncGOP::xCreateSEILayersNotPresent () 3559 { 3560 UInt i = 0; 3561 SEILayersNotPresent *seiLayersNotPresent = new SEILayersNotPresent(); 3562 seiLayersNotPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId(); 3563 seiLayersNotPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers(); 3564 for ( ; i < seiLayersNotPresent->m_vpsMaxLayers; i++) 3565 { 3566 seiLayersNotPresent->m_layerNotPresentFlag[i] = true; 3567 } 3568 for ( ; i < MAX_LAYERS; i++) 3569 { 3570 seiLayersNotPresent->m_layerNotPresentFlag[i] = false; 3571 } 3572 return seiLayersNotPresent; 3573 } 3574 #endif 3575 3576 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 3577 SEIInterLayerConstrainedTileSets* TEncGOP::xCreateSEIInterLayerConstrainedTileSets() 3578 { 3579 SEIInterLayerConstrainedTileSets *seiInterLayerConstrainedTileSets = new SEIInterLayerConstrainedTileSets(); 3580 seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag = false; 3581 seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag = false; 3582 if (!seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag) 3583 { 3584 seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 = m_pcCfg->getIlNumSetsInMessage() - 1; 3585 if (seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1) 3586 { 3587 seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = m_pcCfg->getSkippedTileSetPresentFlag(); 3588 } 3589 else 3590 { 3591 seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = false; 3592 } 3593 seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 += seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag ? 1 : 0; 3594 for (UInt i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++) 3595 { 3596 seiInterLayerConstrainedTileSets->m_ilctsId[i] = i; 3597 seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i] = 0; 3598 for( UInt j = 0; j <= seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i]; j++) 3599 { 3600 seiInterLayerConstrainedTileSets->m_ilTopLeftTileIndex[i][j] = m_pcCfg->getTopLeftTileIndex(i); 3601 seiInterLayerConstrainedTileSets->m_ilBottomRightTileIndex[i][j] = m_pcCfg->getBottomRightTileIndex(i); 3602 } 3603 seiInterLayerConstrainedTileSets->m_ilcIdc[i] = m_pcCfg->getIlcIdc(i); 3604 if (seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag) 3605 { 3606 seiInterLayerConstrainedTileSets->m_ilExactSampleValueMatchFlag[i] = false; 3607 } 3608 } 3609 } 3610 3611 return seiInterLayerConstrainedTileSets; 3612 } 3613 3614 Void TEncGOP::xBuildTileSetsMap(TComPicSym* picSym) 3615 { 3616 Int numCUs = picSym->getFrameWidthInCU() * picSym->getFrameHeightInCU(); 3617 3618 for (Int i = 0; i < numCUs; i++) 3619 { 3620 picSym->setTileSetIdxMap(i, -1, 0, false); 3621 } 3622 3623 for (Int i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++) 3624 { 3625 TComTile* topLeftTile = picSym->getTComTile(m_pcCfg->getTopLeftTileIndex(i)); 3626 TComTile* bottomRightTile = picSym->getTComTile(m_pcCfg->getBottomRightTileIndex(i)); 3627 Int tileSetLeftEdgePosInCU = topLeftTile->getRightEdgePosInCU() - topLeftTile->getTileWidth() + 1; 3628 Int tileSetRightEdgePosInCU = bottomRightTile->getRightEdgePosInCU(); 3629 Int tileSetTopEdgePosInCU = topLeftTile->getBottomEdgePosInCU() - topLeftTile->getTileHeight() + 1; 3630 Int tileSetBottomEdgePosInCU = bottomRightTile->getBottomEdgePosInCU(); 3631 assert(tileSetLeftEdgePosInCU < tileSetRightEdgePosInCU && tileSetTopEdgePosInCU < tileSetBottomEdgePosInCU); 3632 for (Int j = tileSetTopEdgePosInCU; j <= tileSetBottomEdgePosInCU; j++) 3633 { 3634 for (Int k = tileSetLeftEdgePosInCU; k <= tileSetRightEdgePosInCU; k++) 3635 { 3636 picSym->setTileSetIdxMap(j * picSym->getFrameWidthInCU() + k, i, m_pcCfg->getIlcIdc(i), false); 3637 } 3638 } 3639 } 3640 3641 if (m_pcCfg->getSkippedTileSetPresentFlag()) 3642 { 3643 Int skippedTileSetIdx = m_pcCfg->getIlNumSetsInMessage(); 3644 for (Int i = 0; i < numCUs; i++) 3645 { 3646 if (picSym->getTileSetIdxMap(i) < 0) 3647 { 3648 picSym->setTileSetIdxMap(i, skippedTileSetIdx, 0, true); 3649 } 3650 } 3651 } 3652 } 3653 #endif 3654 #endif //SVC_EXTENSION 3655 3700 3656 //! \} -
trunk/source/Lib/TLibEncoder/TEncGOP.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 83 83 Bool m_bFirst; 84 84 85 #if SVC_EXTENSION86 UInt m_layerId;87 #endif88 89 85 // Access channel 90 86 TEncTop* m_pcEncTop; … … 92 88 TEncSlice* m_pcSliceEncoder; 93 89 TComList<TComPic*>* m_pcListPic; 94 95 #if SVC_EXTENSION96 TEncTop** m_ppcTEncTop;97 #if SVC_UPSAMPLING98 TEncSearch* m_pcPredSearch; ///< encoder search class99 #endif100 #endif101 90 102 91 TEncEntropy* m_pcEntropyCoder; … … 120 109 std::vector<Int> m_storedStartCUAddrForEncodingSlice; 121 110 std::vector<Int> m_storedStartCUAddrForEncodingSliceSegment; 111 #if FIX1172 112 NalUnitType m_associatedIRAPType; 113 Int m_associatedIRAPPOC; 114 #endif 122 115 123 116 std::vector<Int> m_vRVM_RP; … … 132 125 Bool m_nestedBufferingPeriodSEIPresentInAU; 133 126 Bool m_nestedPictureTimingSEIPresentInAU; 127 128 #if SVC_EXTENSION 129 UInt m_layerId; 130 TEncTop** m_ppcTEncTop; 131 #if SVC_UPSAMPLING 132 TEncSearch* m_pcPredSearch; ///< encoder search class 133 #endif 134 #endif 135 134 136 public: 135 137 TEncGOP(); … … 162 164 163 165 TEncSlice* getSliceEncoder() { return m_pcSliceEncoder; } 164 NalUnitType getNalUnitType( Int pocCurr, Int lastIdr );166 NalUnitType getNalUnitType( Int pocCurr, Int lastIdr, Bool isField ); 165 167 Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& ); 166 168 protected: … … 181 183 182 184 SEIActiveParameterSets* xCreateSEIActiveParameterSets (TComSPS *sps); 183 #if LAYERS_NOT_PRESENT_SEI184 SEILayersNotPresent* xCreateSEILayersNotPresent ();185 #endif186 185 SEIFramePacking* xCreateSEIFramePacking(); 187 186 SEIDisplayOrientation* xCreateSEIDisplayOrientation(); 188 187 189 188 SEIToneMappingInfo* xCreateSEIToneMappingInfo(); 190 191 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI192 SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets();193 #endif194 189 195 190 Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps); … … 206 201 m_nestedPictureTimingSEIPresentInAU = false; 207 202 } 203 Void dblMetric( TComPic* pcPic, UInt uiNumSlices ); 204 205 #if SVC_EXTENSION 206 #if LAYERS_NOT_PRESENT_SEI 207 SEILayersNotPresent* xCreateSEILayersNotPresent (); 208 #endif 208 209 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 209 210 Void xBuildTileSetsMap(TComPicSym* picSym); 210 #endif 211 Void dblMetric( TComPic* pcPic, UInt uiNumSlices ); 211 SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets(); 212 #endif 213 #endif //SVC_EXTENSION 212 214 };// END CLASS DEFINITION TEncGOP 213 215 -
trunk/source/Lib/TLibEncoder/TEncPic.cpp
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncPic.h
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncPreanalyzer.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncPreanalyzer.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncRateCtrl.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncRateCtrl.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 46 46 47 47 48 #if HM_CLEANUP_SAO49 50 48 /** rounding with IBDI 51 49 * \param x … … 259 257 TComPicYuv* orgYuv= pPic->getPicYuvOrg(); 260 258 TComPicYuv* resYuv= pPic->getPicYuvRec(); 261 m_la bmda[SAO_Y]= lambdas[0]; m_labmda[SAO_Cb]= lambdas[1]; m_labmda[SAO_Cr]= lambdas[2];259 m_lambda[SAO_Y]= lambdas[0]; m_lambda[SAO_Cb]= lambdas[1]; m_lambda[SAO_Cr]= lambdas[2]; 262 260 TComPicYuv* srcYuv = m_tempPicYuv; 263 261 resYuv->copyToPic(srcYuv); … … 509 507 if( quantOffsets[classIdx] != 0 ) //iterative adjustment only when derived offset is not zero 510 508 { 511 quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_la bmda[compIdx], quantOffsets[classIdx], statData.count[classIdx], statData.diff[classIdx], shift, m_offsetStepLog2[compIdx], classDist , classCost , offsetTh );509 quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_lambda[compIdx], quantOffsets[classIdx], statData.count[classIdx], statData.diff[classIdx], shift, m_offsetStepLog2[compIdx], classDist , classCost , offsetTh ); 512 510 } 513 511 } … … 523 521 for(Int classIdx=0; classIdx< NUM_SAO_BO_CLASSES; classIdx++) 524 522 { 525 costBOClasses[classIdx]= m_la bmda[compIdx];523 costBOClasses[classIdx]= m_lambda[compIdx]; 526 524 if( quantOffsets[classIdx] != 0 ) //iterative adjustment only when derived offset is not zero 527 525 { 528 quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_la bmda[compIdx], quantOffsets[classIdx], statData.count[classIdx], statData.diff[classIdx], shift, m_offsetStepLog2[compIdx], distBOClasses[classIdx], costBOClasses[classIdx], offsetTh );526 quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_lambda[compIdx], quantOffsets[classIdx], statData.count[classIdx], statData.diff[classIdx], shift, m_offsetStepLog2[compIdx], distBOClasses[classIdx], costBOClasses[classIdx], offsetTh ); 529 527 } 530 528 } … … 572 570 { 573 571 Double minCost, cost; 574 Int rate, minRate; 572 Int rate; 573 UInt previousWrittenBits; 575 574 Int64 dist[NUM_SAO_COMPONENTS], modeDist[NUM_SAO_COMPONENTS]; 576 575 SAOOffset testOffset[NUM_SAO_COMPONENTS]; … … 592 591 m_pcRDGoOnSbacCoder->resetBits(); 593 592 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, modeParam[compIdx], sliceEnabled[compIdx]); 594 minRate= m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();595 593 modeDist[compIdx] = 0; 596 minCost= m_la bmda[compIdx]*((Double)minRate);594 minCost= m_lambda[compIdx]*((Double)m_pcRDGoOnSbacCoder->getNumberOfWrittenBits()); 597 595 m_pcRDGoOnSbacCoder->store(cabacCoderRDO[SAO_CABACSTATE_BLK_TEMP]); 598 596 if(sliceEnabled[compIdx]) … … 617 615 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, testOffset[compIdx], sliceEnabled[compIdx]); 618 616 rate = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 619 cost = (Double)dist[compIdx] + m_la bmda[compIdx]*((Double)rate);617 cost = (Double)dist[compIdx] + m_lambda[compIdx]*((Double)rate); 620 618 if(cost < minCost) 621 619 { 622 620 minCost = cost; 623 minRate = rate;624 621 modeDist[compIdx] = dist[compIdx]; 625 622 modeParam[compIdx]= testOffset[compIdx]; … … 632 629 633 630 //------ chroma --------// 634 assert(m_labmda[SAO_Cb] == m_labmda[SAO_Cr]);635 Double chromaLambda = m_labmda[SAO_Cb];636 631 //"off" case as initial cost 632 cost = 0; 633 previousWrittenBits = 0; 637 634 m_pcRDGoOnSbacCoder->resetBits(); 638 modeParam[SAO_Cb].modeIdc = SAO_MODE_OFF; 639 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cb, modeParam[SAO_Cb], sliceEnabled[SAO_Cb]); 640 modeParam[SAO_Cr].modeIdc = SAO_MODE_OFF; 641 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cr, modeParam[SAO_Cr], sliceEnabled[SAO_Cr]); 642 minRate= m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 643 modeDist[SAO_Cb] = modeDist[SAO_Cr]= 0; 644 minCost= chromaLambda*((Double)minRate); 635 for (Int component = SAO_Cb; component < NUM_SAO_COMPONENTS; component++) 636 { 637 modeParam[component].modeIdc = SAO_MODE_OFF; 638 modeDist [component] = 0; 639 640 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(component, modeParam[component], sliceEnabled[component]); 641 642 const UInt currentWrittenBits = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 643 cost += m_lambda[component] * (currentWrittenBits - previousWrittenBits); 644 previousWrittenBits = currentWrittenBits; 645 } 646 647 minCost = cost; 645 648 646 649 //doesn't need to store cabac status here since the whole CTU parameters will be re-encoded at the end of this function … … 648 651 for(Int typeIdc=0; typeIdc< NUM_SAO_NEW_TYPES; typeIdc++) 649 652 { 653 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]); 654 m_pcRDGoOnSbacCoder->resetBits(); 655 previousWrittenBits = 0; 656 cost = 0; 657 650 658 for(compIdx= SAO_Cb; compIdx< NUM_SAO_COMPONENTS; compIdx++) 651 659 { … … 663 671 invertQuantOffsets(compIdx, typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, testOffset[compIdx].offset); 664 672 dist[compIdx]= getDistortion(ctu, compIdx, typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, blkStats[ctu][compIdx][typeIdc]); 665 } 666 667 //get rate 668 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]); 669 m_pcRDGoOnSbacCoder->resetBits(); 670 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cb, testOffset[SAO_Cb], sliceEnabled[SAO_Cb]); 671 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cr, testOffset[SAO_Cr], sliceEnabled[SAO_Cr]); 672 rate = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 673 674 cost = (Double)(dist[SAO_Cb]+ dist[SAO_Cr]) + chromaLambda*((Double)rate); 673 674 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, testOffset[compIdx], sliceEnabled[compIdx]); 675 676 const UInt currentWrittenBits = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 677 cost += dist[compIdx] + (m_lambda[compIdx] * (currentWrittenBits - previousWrittenBits)); 678 previousWrittenBits = currentWrittenBits; 679 } 680 675 681 if(cost < minCost) 676 682 { 677 683 minCost = cost; 678 minRate = rate;679 modeDist[SAO_Cb] = dist[SAO_Cb];680 modeDist[SAO_Cr] = dist[SAO_Cr];681 modeParam[SAO_Cb]= testOffset[SAO_Cb];682 modeParam[SAO_Cr]= testOffset[SAO_Cr];684 for(compIdx= SAO_Cb; compIdx< NUM_SAO_COMPONENTS; compIdx++) 685 { 686 modeDist [compIdx] = dist [compIdx]; 687 modeParam[compIdx] = testOffset[compIdx]; 688 } 683 689 } 684 690 } … … 686 692 687 693 //----- re-gen rate & normalized cost----// 688 modeNormCost = (Double)modeDist[SAO_Y]/m_labmda[SAO_Y]; 689 modeNormCost += (Double)(modeDist[SAO_Cb]+ modeDist[SAO_Cr])/chromaLambda; 694 modeNormCost = 0; 695 for(UInt component = SAO_Y; component < NUM_SAO_COMPONENTS; component++) 696 { 697 modeNormCost += (Double)modeDist[component] / m_lambda[component]; 698 } 690 699 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[inCabacLabel]); 691 700 m_pcRDGoOnSbacCoder->resetBits(); … … 724 733 //offsets have been reconstructed. Don't call inversed quantization function. 725 734 normDist += (((Double)getDistortion(ctu, compIdx, mergedOffsetParam.typeIdc, mergedOffsetParam.typeAuxInfo, mergedOffsetParam.offset, blkStats[ctu][compIdx][mergedOffsetParam.typeIdc])) 726 /m_la bmda[compIdx]735 /m_lambda[compIdx] 727 736 ); 728 737 } … … 1304 1313 } 1305 1314 1306 #else1307 1308 1309 1310 TEncSampleAdaptiveOffset::TEncSampleAdaptiveOffset()1311 {1312 m_pcEntropyCoder = NULL;1313 m_pppcRDSbacCoder = NULL;1314 m_pcRDGoOnSbacCoder = NULL;1315 m_pppcBinCoderCABAC = NULL;1316 m_iCount = NULL;1317 m_iOffset = NULL;1318 m_iOffsetOrg = NULL;1319 m_iRate = NULL;1320 m_iDist = NULL;1321 m_dCost = NULL;1322 m_dCostPartBest = NULL;1323 m_iDistOrg = NULL;1324 m_iTypePartBest = NULL;1325 #if SAO_ENCODING_CHOICE_CHROMA1326 m_depthSaoRate[0][0] = 0;1327 m_depthSaoRate[0][1] = 0;1328 m_depthSaoRate[0][2] = 0;1329 m_depthSaoRate[0][3] = 0;1330 m_depthSaoRate[1][0] = 0;1331 m_depthSaoRate[1][1] = 0;1332 m_depthSaoRate[1][2] = 0;1333 m_depthSaoRate[1][3] = 0;1334 #endif1335 }1336 TEncSampleAdaptiveOffset::~TEncSampleAdaptiveOffset()1337 {1338 1339 }1340 // ====================================================================================================================1341 // Constants1342 // ====================================================================================================================1343 1344 1345 // ====================================================================================================================1346 // Tables1347 // ====================================================================================================================1348 1349 inline Double xRoundIbdi2(Int bitDepth, Double x)1350 {1351 return ((x)>0) ? (Int)(((Int)(x)+(1<<(bitDepth-8-1)))/(1<<(bitDepth-8))) : ((Int)(((Int)(x)-(1<<(bitDepth-8-1)))/(1<<(bitDepth-8))));1352 }1353 1354 /** rounding with IBDI1355 * \param x1356 */1357 inline Double xRoundIbdi(Int bitDepth, Double x)1358 {1359 return (bitDepth > 8 ? xRoundIbdi2(bitDepth, (x)) : ((x)>=0 ? ((Int)((x)+0.5)) : ((Int)((x)-0.5)))) ;1360 }1361 1362 1363 1364 /** process SAO for one partition1365 * \param *psQTPart, iPartIdx, dLambda1366 */1367 Void TEncSampleAdaptiveOffset::rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda, Int yCbCr)1368 {1369 Int iTypeIdx;1370 Int iNumTotalType = MAX_NUM_SAO_TYPE;1371 SAOQTPart* pOnePart = &(psQTPart[iPartIdx]);1372 1373 Int64 iEstDist;1374 Int iClassIdx;1375 Int uiShift = 2 * DISTORTION_PRECISION_ADJUSTMENT((yCbCr == 0 ? g_bitDepthY : g_bitDepthC)-8);1376 UInt uiDepth = pOnePart->PartLevel;1377 1378 m_iDistOrg [iPartIdx] = 0;1379 1380 Double bestRDCostTableBo = MAX_DOUBLE;1381 Int bestClassTableBo = 0;1382 Int currentDistortionTableBo[MAX_NUM_SAO_CLASS];1383 Double currentRdCostTableBo[MAX_NUM_SAO_CLASS];1384 1385 Int addr;1386 Int allowMergeLeft;1387 Int allowMergeUp;1388 Int frameWidthInCU = m_pcPic->getFrameWidthInCU();1389 SaoLcuParam saoLcuParamRdo;1390 1391 for (iTypeIdx=-1; iTypeIdx<iNumTotalType; iTypeIdx++)1392 {1393 if( m_bUseSBACRD )1394 {1395 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);1396 m_pcRDGoOnSbacCoder->resetBits();1397 }1398 else1399 {1400 m_pcEntropyCoder->resetEntropy();1401 m_pcEntropyCoder->resetBits();1402 }1403 1404 iEstDist = 0;1405 1406 if (iTypeIdx == -1)1407 {1408 for (Int ry = pOnePart->StartCUY; ry<= pOnePart->EndCUY; ry++)1409 {1410 for (Int rx = pOnePart->StartCUX; rx <= pOnePart->EndCUX; rx++)1411 {1412 addr = ry * frameWidthInCU + rx;1413 1414 // get bits for iTypeIdx = -11415 allowMergeLeft = 1;1416 allowMergeUp = 1;1417 if (rx != 0)1418 {1419 // check tile id and slice id1420 if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-1) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-1)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))1421 {1422 allowMergeLeft = 0;1423 }1424 }1425 if (ry!=0)1426 {1427 if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-m_iNumCuInWidth) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-m_iNumCuInWidth)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))1428 {1429 allowMergeUp = 0;1430 }1431 }1432 1433 // reset1434 resetSaoUnit(&saoLcuParamRdo);1435 1436 // set merge flag1437 saoLcuParamRdo.mergeUpFlag = 1;1438 saoLcuParamRdo.mergeLeftFlag = 1;1439 1440 if (ry == pOnePart->StartCUY)1441 {1442 saoLcuParamRdo.mergeUpFlag = 0;1443 }1444 1445 if (rx == pOnePart->StartCUX)1446 {1447 saoLcuParamRdo.mergeLeftFlag = 0;1448 }1449 1450 m_pcEntropyCoder->encodeSaoUnitInterleaving(yCbCr, 1, rx, ry, &saoLcuParamRdo, 1, 1, allowMergeLeft, allowMergeUp);1451 1452 }1453 }1454 }1455 1456 if (iTypeIdx>=0)1457 {1458 iEstDist = estSaoTypeDist(iPartIdx, iTypeIdx, uiShift, dLambda, currentDistortionTableBo, currentRdCostTableBo);1459 if( iTypeIdx == SAO_BO )1460 {1461 // Estimate Best Position1462 Double currentRDCost = 0.0;1463 1464 for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++)1465 {1466 currentRDCost = 0.0;1467 for(UInt uj = i; uj < i+SAO_BO_LEN; uj++)1468 {1469 currentRDCost += currentRdCostTableBo[uj];1470 }1471 1472 if( currentRDCost < bestRDCostTableBo)1473 {1474 bestRDCostTableBo = currentRDCost;1475 bestClassTableBo = i;1476 }1477 }1478 1479 // Re code all Offsets1480 // Code Center1481 for(iClassIdx = bestClassTableBo; iClassIdx < bestClassTableBo+SAO_BO_LEN; iClassIdx++)1482 {1483 iEstDist += currentDistortionTableBo[iClassIdx];1484 }1485 }1486 1487 for (Int ry = pOnePart->StartCUY; ry<= pOnePart->EndCUY; ry++)1488 {1489 for (Int rx = pOnePart->StartCUX; rx <= pOnePart->EndCUX; rx++)1490 {1491 addr = ry * frameWidthInCU + rx;1492 1493 // get bits for iTypeIdx = -11494 allowMergeLeft = 1;1495 allowMergeUp = 1;1496 if (rx != 0)1497 {1498 // check tile id and slice id1499 if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-1) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-1)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))1500 {1501 allowMergeLeft = 0;1502 }1503 }1504 if (ry!=0)1505 {1506 if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-m_iNumCuInWidth) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-m_iNumCuInWidth)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))1507 {1508 allowMergeUp = 0;1509 }1510 }1511 1512 // reset1513 resetSaoUnit(&saoLcuParamRdo);1514 1515 // set merge flag1516 saoLcuParamRdo.mergeUpFlag = 1;1517 saoLcuParamRdo.mergeLeftFlag = 1;1518 1519 if (ry == pOnePart->StartCUY)1520 {1521 saoLcuParamRdo.mergeUpFlag = 0;1522 }1523 1524 if (rx == pOnePart->StartCUX)1525 {1526 saoLcuParamRdo.mergeLeftFlag = 0;1527 }1528 1529 // set type and offsets1530 saoLcuParamRdo.typeIdx = iTypeIdx;1531 saoLcuParamRdo.subTypeIdx = (iTypeIdx==SAO_BO)?bestClassTableBo:0;1532 saoLcuParamRdo.length = m_iNumClass[iTypeIdx];1533 for (iClassIdx = 0; iClassIdx < saoLcuParamRdo.length; iClassIdx++)1534 {1535 saoLcuParamRdo.offset[iClassIdx] = (Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx+saoLcuParamRdo.subTypeIdx+1];1536 }1537 1538 m_pcEntropyCoder->encodeSaoUnitInterleaving(yCbCr, 1, rx, ry, &saoLcuParamRdo, 1, 1, allowMergeLeft, allowMergeUp);1539 1540 }1541 }1542 1543 m_iDist[iPartIdx][iTypeIdx] = iEstDist;1544 m_iRate[iPartIdx][iTypeIdx] = m_pcEntropyCoder->getNumberOfWrittenBits();1545 1546 m_dCost[iPartIdx][iTypeIdx] = (Double)((Double)m_iDist[iPartIdx][iTypeIdx] + dLambda * (Double) m_iRate[iPartIdx][iTypeIdx]);1547 1548 if(m_dCost[iPartIdx][iTypeIdx] < m_dCostPartBest[iPartIdx])1549 {1550 m_iDistOrg [iPartIdx] = 0;1551 m_dCostPartBest[iPartIdx] = m_dCost[iPartIdx][iTypeIdx];1552 m_iTypePartBest[iPartIdx] = iTypeIdx;1553 if( m_bUseSBACRD )1554 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] );1555 }1556 }1557 else1558 {1559 if(m_iDistOrg[iPartIdx] < m_dCostPartBest[iPartIdx] )1560 {1561 m_dCostPartBest[iPartIdx] = (Double) m_iDistOrg[iPartIdx] + m_pcEntropyCoder->getNumberOfWrittenBits()*dLambda ;1562 m_iTypePartBest[iPartIdx] = -1;1563 if( m_bUseSBACRD )1564 {1565 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] );1566 }1567 }1568 }1569 }1570 1571 pOnePart->bProcessed = true;1572 pOnePart->bSplit = false;1573 pOnePart->iMinDist = m_iTypePartBest[iPartIdx] >= 0 ? m_iDist[iPartIdx][m_iTypePartBest[iPartIdx]] : m_iDistOrg[iPartIdx];1574 pOnePart->iMinRate = (Int) (m_iTypePartBest[iPartIdx] >= 0 ? m_iRate[iPartIdx][m_iTypePartBest[iPartIdx]] : 0);1575 pOnePart->dMinCost = pOnePart->iMinDist + dLambda * pOnePart->iMinRate;1576 pOnePart->iBestType = m_iTypePartBest[iPartIdx];1577 if (pOnePart->iBestType != -1)1578 {1579 // pOnePart->bEnableFlag = 1;1580 pOnePart->iLength = m_iNumClass[pOnePart->iBestType];1581 Int minIndex = 0;1582 if( pOnePart->iBestType == SAO_BO )1583 {1584 pOnePart->subTypeIdx = bestClassTableBo;1585 minIndex = pOnePart->subTypeIdx;1586 }1587 for (Int i=0; i< pOnePart->iLength ; i++)1588 {1589 pOnePart->iOffset[i] = (Int) m_iOffset[iPartIdx][pOnePart->iBestType][minIndex+i+1];1590 }1591 1592 }1593 else1594 {1595 // pOnePart->bEnableFlag = 0;1596 pOnePart->iLength = 0;1597 }1598 }1599 1600 /** Run partition tree disable1601 */1602 Void TEncSampleAdaptiveOffset::disablePartTree(SAOQTPart *psQTPart, Int iPartIdx)1603 {1604 SAOQTPart* pOnePart= &(psQTPart[iPartIdx]);1605 pOnePart->bSplit = false;1606 pOnePart->iLength = 0;1607 pOnePart->iBestType = -1;1608 1609 if (pOnePart->PartLevel < m_uiMaxSplitLevel)1610 {1611 for (Int i=0; i<NUM_DOWN_PART; i++)1612 {1613 disablePartTree(psQTPart, pOnePart->DownPartsIdx[i]);1614 }1615 }1616 }1617 1618 /** Run quadtree decision function1619 * \param iPartIdx, pcPicOrg, pcPicDec, pcPicRest, &dCostFinal1620 */1621 Void TEncSampleAdaptiveOffset::runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda, Int yCbCr)1622 {1623 SAOQTPart* pOnePart = &(psQTPart[iPartIdx]);1624 1625 UInt uiDepth = pOnePart->PartLevel;1626 UInt uhNextDepth = uiDepth+1;1627 1628 if (iPartIdx == 0)1629 {1630 dCostFinal = 0;1631 }1632 1633 //SAO for this part1634 if(!pOnePart->bProcessed)1635 {1636 rdoSaoOnePart (psQTPart, iPartIdx, dLambda, yCbCr);1637 }1638 1639 //SAO for sub 4 parts1640 if (pOnePart->PartLevel < iMaxLevel)1641 {1642 Double dCostNotSplit = dLambda + pOnePart->dMinCost;1643 Double dCostSplit = dLambda;1644 1645 for (Int i=0; i< NUM_DOWN_PART ;i++)1646 {1647 if( m_bUseSBACRD )1648 {1649 if ( 0 == i) //initialize RD with previous depth buffer1650 {1651 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);1652 }1653 else1654 {1655 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]);1656 }1657 }1658 runQuadTreeDecision(psQTPart, pOnePart->DownPartsIdx[i], dCostFinal, iMaxLevel, dLambda, yCbCr);1659 dCostSplit += dCostFinal;1660 if( m_bUseSBACRD )1661 {1662 m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_TEMP_BEST]);1663 }1664 }1665 1666 if(dCostSplit < dCostNotSplit)1667 {1668 dCostFinal = dCostSplit;1669 pOnePart->bSplit = true;1670 pOnePart->iLength = 0;1671 pOnePart->iBestType = -1;1672 if( m_bUseSBACRD )1673 {1674 m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]);1675 }1676 }1677 else1678 {1679 dCostFinal = dCostNotSplit;1680 pOnePart->bSplit = false;1681 for (Int i=0; i<NUM_DOWN_PART; i++)1682 {1683 disablePartTree(psQTPart, pOnePart->DownPartsIdx[i]);1684 }1685 if( m_bUseSBACRD )1686 {1687 m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);1688 }1689 }1690 }1691 else1692 {1693 dCostFinal = pOnePart->dMinCost;1694 }1695 }1696 1697 /** delete allocated memory of TEncSampleAdaptiveOffset class.1698 */1699 Void TEncSampleAdaptiveOffset::destroyEncBuffer()1700 {1701 for (Int i=0;i<m_iNumTotalParts;i++)1702 {1703 for (Int j=0;j<MAX_NUM_SAO_TYPE;j++)1704 {1705 if (m_iCount [i][j])1706 {1707 delete [] m_iCount [i][j];1708 }1709 if (m_iOffset[i][j])1710 {1711 delete [] m_iOffset[i][j];1712 }1713 if (m_iOffsetOrg[i][j])1714 {1715 delete [] m_iOffsetOrg[i][j];1716 }1717 }1718 if (m_iRate[i])1719 {1720 delete [] m_iRate[i];1721 }1722 if (m_iDist[i])1723 {1724 delete [] m_iDist[i];1725 }1726 if (m_dCost[i])1727 {1728 delete [] m_dCost[i];1729 }1730 if (m_iCount [i])1731 {1732 delete [] m_iCount [i];1733 }1734 if (m_iOffset[i])1735 {1736 delete [] m_iOffset[i];1737 }1738 if (m_iOffsetOrg[i])1739 {1740 delete [] m_iOffsetOrg[i];1741 }1742 1743 }1744 if (m_iDistOrg)1745 {1746 delete [] m_iDistOrg ; m_iDistOrg = NULL;1747 }1748 if (m_dCostPartBest)1749 {1750 delete [] m_dCostPartBest ; m_dCostPartBest = NULL;1751 }1752 if (m_iTypePartBest)1753 {1754 delete [] m_iTypePartBest ; m_iTypePartBest = NULL;1755 }1756 if (m_iRate)1757 {1758 delete [] m_iRate ; m_iRate = NULL;1759 }1760 if (m_iDist)1761 {1762 delete [] m_iDist ; m_iDist = NULL;1763 }1764 if (m_dCost)1765 {1766 delete [] m_dCost ; m_dCost = NULL;1767 }1768 if (m_iCount)1769 {1770 delete [] m_iCount ; m_iCount = NULL;1771 }1772 if (m_iOffset)1773 {1774 delete [] m_iOffset ; m_iOffset = NULL;1775 }1776 if (m_iOffsetOrg)1777 {1778 delete [] m_iOffsetOrg ; m_iOffsetOrg = NULL;1779 }1780 Int numLcu = m_iNumCuInWidth * m_iNumCuInHeight;1781 1782 for (Int i=0;i<numLcu;i++)1783 {1784 for (Int j=0;j<3;j++)1785 {1786 for (Int k=0;k<MAX_NUM_SAO_TYPE;k++)1787 {1788 if (m_count_PreDblk [i][j][k])1789 {1790 delete [] m_count_PreDblk [i][j][k];1791 }1792 if (m_offsetOrg_PreDblk[i][j][k])1793 {1794 delete [] m_offsetOrg_PreDblk[i][j][k];1795 }1796 }1797 if (m_count_PreDblk [i][j])1798 {1799 delete [] m_count_PreDblk [i][j];1800 }1801 if (m_offsetOrg_PreDblk[i][j])1802 {1803 delete [] m_offsetOrg_PreDblk[i][j];1804 }1805 }1806 if (m_count_PreDblk [i])1807 {1808 delete [] m_count_PreDblk [i];1809 }1810 if (m_offsetOrg_PreDblk[i])1811 {1812 delete [] m_offsetOrg_PreDblk[i];1813 }1814 }1815 if (m_count_PreDblk)1816 {1817 delete [] m_count_PreDblk ; m_count_PreDblk = NULL;1818 }1819 if (m_offsetOrg_PreDblk)1820 {1821 delete [] m_offsetOrg_PreDblk ; m_offsetOrg_PreDblk = NULL;1822 }1823 1824 Int iMaxDepth = 4;1825 Int iDepth;1826 for ( iDepth = 0; iDepth < iMaxDepth+1; iDepth++ )1827 {1828 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )1829 {1830 delete m_pppcRDSbacCoder[iDepth][iCIIdx];1831 delete m_pppcBinCoderCABAC[iDepth][iCIIdx];1832 }1833 }1834 1835 for ( iDepth = 0; iDepth < iMaxDepth+1; iDepth++ )1836 {1837 delete [] m_pppcRDSbacCoder[iDepth];1838 delete [] m_pppcBinCoderCABAC[iDepth];1839 }1840 1841 delete [] m_pppcRDSbacCoder;1842 delete [] m_pppcBinCoderCABAC;1843 }1844 1845 /** create Encoder Buffer for SAO1846 * \param1847 */1848 Void TEncSampleAdaptiveOffset::createEncBuffer()1849 {1850 m_iDistOrg = new Int64 [m_iNumTotalParts];1851 m_dCostPartBest = new Double [m_iNumTotalParts];1852 m_iTypePartBest = new Int [m_iNumTotalParts];1853 1854 m_iRate = new Int64* [m_iNumTotalParts];1855 m_iDist = new Int64* [m_iNumTotalParts];1856 m_dCost = new Double*[m_iNumTotalParts];1857 1858 m_iCount = new Int64 **[m_iNumTotalParts];1859 m_iOffset = new Int64 **[m_iNumTotalParts];1860 m_iOffsetOrg = new Int64 **[m_iNumTotalParts];1861 1862 for (Int i=0;i<m_iNumTotalParts;i++)1863 {1864 m_iRate[i] = new Int64 [MAX_NUM_SAO_TYPE];1865 m_iDist[i] = new Int64 [MAX_NUM_SAO_TYPE];1866 m_dCost[i] = new Double [MAX_NUM_SAO_TYPE];1867 1868 m_iCount [i] = new Int64 *[MAX_NUM_SAO_TYPE];1869 m_iOffset[i] = new Int64 *[MAX_NUM_SAO_TYPE];1870 m_iOffsetOrg[i] = new Int64 *[MAX_NUM_SAO_TYPE];1871 1872 for (Int j=0;j<MAX_NUM_SAO_TYPE;j++)1873 {1874 m_iCount [i][j] = new Int64 [MAX_NUM_SAO_CLASS];1875 m_iOffset[i][j] = new Int64 [MAX_NUM_SAO_CLASS];1876 m_iOffsetOrg[i][j]= new Int64 [MAX_NUM_SAO_CLASS];1877 }1878 }1879 Int numLcu = m_iNumCuInWidth * m_iNumCuInHeight;1880 m_count_PreDblk = new Int64 ***[numLcu];1881 m_offsetOrg_PreDblk = new Int64 ***[numLcu];1882 for (Int i=0; i<numLcu; i++)1883 {1884 m_count_PreDblk[i] = new Int64 **[3];1885 m_offsetOrg_PreDblk[i] = new Int64 **[3];1886 1887 for (Int j=0;j<3;j++)1888 {1889 m_count_PreDblk [i][j] = new Int64 *[MAX_NUM_SAO_TYPE];1890 m_offsetOrg_PreDblk[i][j] = new Int64 *[MAX_NUM_SAO_TYPE];1891 1892 for (Int k=0;k<MAX_NUM_SAO_TYPE;k++)1893 {1894 m_count_PreDblk [i][j][k] = new Int64 [MAX_NUM_SAO_CLASS];1895 m_offsetOrg_PreDblk[i][j][k]= new Int64 [MAX_NUM_SAO_CLASS];1896 }1897 }1898 }1899 1900 Int iMaxDepth = 4;1901 m_pppcRDSbacCoder = new TEncSbac** [iMaxDepth+1];1902 #if FAST_BIT_EST1903 m_pppcBinCoderCABAC = new TEncBinCABACCounter** [iMaxDepth+1];1904 #else1905 m_pppcBinCoderCABAC = new TEncBinCABAC** [iMaxDepth+1];1906 #endif1907 1908 for ( Int iDepth = 0; iDepth < iMaxDepth+1; iDepth++ )1909 {1910 m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM];1911 #if FAST_BIT_EST1912 m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM];1913 #else1914 m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM];1915 #endif1916 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )1917 {1918 m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac;1919 #if FAST_BIT_EST1920 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter;1921 #else1922 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC;1923 #endif1924 m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] );1925 }1926 }1927 }1928 1929 /** Start SAO encoder1930 * \param pcPic, pcEntropyCoder, pppcRDSbacCoder, pcRDGoOnSbacCoder1931 */1932 Void TEncSampleAdaptiveOffset::startSaoEnc( TComPic* pcPic, TEncEntropy* pcEntropyCoder, TEncSbac*** pppcRDSbacCoder, TEncSbac* pcRDGoOnSbacCoder)1933 {1934 m_bUseSBACRD = true;1935 m_pcPic = pcPic;1936 m_pcEntropyCoder = pcEntropyCoder;1937 1938 m_pcRDGoOnSbacCoder = pcRDGoOnSbacCoder;1939 m_pcEntropyCoder->setEntropyCoder(m_pcRDGoOnSbacCoder, pcPic->getSlice(0));1940 m_pcEntropyCoder->resetEntropy();1941 m_pcEntropyCoder->resetBits();1942 1943 if( m_bUseSBACRD )1944 {1945 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_NEXT_BEST]);1946 m_pppcRDSbacCoder[0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_NEXT_BEST]);1947 }1948 }1949 1950 /** End SAO encoder1951 */1952 Void TEncSampleAdaptiveOffset::endSaoEnc()1953 {1954 m_pcPic = NULL;1955 m_pcEntropyCoder = NULL;1956 }1957 1958 inline Int xSign(Int x)1959 {1960 return ((x >> 31) | ((Int)( (((UInt) -x)) >> 31)));1961 }1962 1963 /** Calculate SAO statistics for non-cross-slice or non-cross-tile processing1964 * \param pRecStart to-be-filtered block buffer pointer1965 * \param pOrgStart original block buffer pointer1966 * \param stride picture buffer stride1967 * \param ppStat statistics buffer1968 * \param ppCount counter buffer1969 * \param width block width1970 * \param height block height1971 * \param pbBorderAvail availabilities of block border pixels1972 */1973 Void TEncSampleAdaptiveOffset::calcSaoStatsBlock( Pel* pRecStart, Pel* pOrgStart, Int stride, Int64** ppStats, Int64** ppCount, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr)1974 {1975 Int64 *stats, *count;1976 Int classIdx, posShift, startX, endX, startY, endY, signLeft,signRight,signDown,signDown1;1977 Pel *pOrg, *pRec;1978 UInt edgeType;1979 Int x, y;1980 Pel *pTableBo = (iYCbCr==0)?m_lumaTableBo:m_chromaTableBo;1981 1982 //--------- Band offset-----------//1983 stats = ppStats[SAO_BO];1984 count = ppCount[SAO_BO];1985 pOrg = pOrgStart;1986 pRec = pRecStart;1987 for (y=0; y< height; y++)1988 {1989 for (x=0; x< width; x++)1990 {1991 classIdx = pTableBo[pRec[x]];1992 if (classIdx)1993 {1994 stats[classIdx] += (pOrg[x] - pRec[x]);1995 count[classIdx] ++;1996 }1997 }1998 pOrg += stride;1999 pRec += stride;2000 }2001 //---------- Edge offset 0--------------//2002 stats = ppStats[SAO_EO_0];2003 count = ppCount[SAO_EO_0];2004 pOrg = pOrgStart;2005 pRec = pRecStart;2006 2007 2008 startX = (pbBorderAvail[SGU_L]) ? 0 : 1;2009 endX = (pbBorderAvail[SGU_R]) ? width : (width -1);2010 for (y=0; y< height; y++)2011 {2012 signLeft = xSign(pRec[startX] - pRec[startX-1]);2013 for (x=startX; x< endX; x++)2014 {2015 signRight = xSign(pRec[x] - pRec[x+1]);2016 edgeType = signRight + signLeft + 2;2017 signLeft = -signRight;2018 2019 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2020 count[m_auiEoTable[edgeType]] ++;2021 }2022 pRec += stride;2023 pOrg += stride;2024 }2025 2026 //---------- Edge offset 1--------------//2027 stats = ppStats[SAO_EO_1];2028 count = ppCount[SAO_EO_1];2029 pOrg = pOrgStart;2030 pRec = pRecStart;2031 2032 startY = (pbBorderAvail[SGU_T]) ? 0 : 1;2033 endY = (pbBorderAvail[SGU_B]) ? height : height-1;2034 if (!pbBorderAvail[SGU_T])2035 {2036 pRec += stride;2037 pOrg += stride;2038 }2039 2040 for (x=0; x< width; x++)2041 {2042 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride]);2043 }2044 for (y=startY; y<endY; y++)2045 {2046 for (x=0; x< width; x++)2047 {2048 signDown = xSign(pRec[x] - pRec[x+stride]);2049 edgeType = signDown + m_iUpBuff1[x] + 2;2050 m_iUpBuff1[x] = -signDown;2051 2052 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2053 count[m_auiEoTable[edgeType]] ++;2054 }2055 pOrg += stride;2056 pRec += stride;2057 }2058 //---------- Edge offset 2--------------//2059 stats = ppStats[SAO_EO_2];2060 count = ppCount[SAO_EO_2];2061 pOrg = pOrgStart;2062 pRec = pRecStart;2063 2064 posShift= stride + 1;2065 2066 startX = (pbBorderAvail[SGU_L]) ? 0 : 1 ;2067 endX = (pbBorderAvail[SGU_R]) ? width : (width-1);2068 2069 //prepare 2nd line upper sign2070 pRec += stride;2071 for (x=startX; x< endX+1; x++)2072 {2073 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x- posShift]);2074 }2075 2076 //1st line2077 pRec -= stride;2078 if(pbBorderAvail[SGU_TL])2079 {2080 x= 0;2081 edgeType = xSign(pRec[x] - pRec[x- posShift]) - m_iUpBuff1[x+1] + 2;2082 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2083 count[m_auiEoTable[edgeType]] ++;2084 }2085 if(pbBorderAvail[SGU_T])2086 {2087 for(x= 1; x< endX; x++)2088 {2089 edgeType = xSign(pRec[x] - pRec[x- posShift]) - m_iUpBuff1[x+1] + 2;2090 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2091 count[m_auiEoTable[edgeType]] ++;2092 }2093 }2094 pRec += stride;2095 pOrg += stride;2096 2097 //middle lines2098 for (y= 1; y< height-1; y++)2099 {2100 for (x=startX; x<endX; x++)2101 {2102 signDown1 = xSign(pRec[x] - pRec[x+ posShift]) ;2103 edgeType = signDown1 + m_iUpBuff1[x] + 2;2104 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2105 count[m_auiEoTable[edgeType]] ++;2106 2107 m_iUpBufft[x+1] = -signDown1;2108 }2109 m_iUpBufft[startX] = xSign(pRec[stride+startX] - pRec[startX-1]);2110 2111 ipSwap = m_iUpBuff1;2112 m_iUpBuff1 = m_iUpBufft;2113 m_iUpBufft = ipSwap;2114 2115 pRec += stride;2116 pOrg += stride;2117 }2118 2119 //last line2120 if(pbBorderAvail[SGU_B])2121 {2122 for(x= startX; x< width-1; x++)2123 {2124 edgeType = xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2;2125 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2126 count[m_auiEoTable[edgeType]] ++;2127 }2128 }2129 if(pbBorderAvail[SGU_BR])2130 {2131 x= width -1;2132 edgeType = xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2;2133 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2134 count[m_auiEoTable[edgeType]] ++;2135 }2136 2137 //---------- Edge offset 3--------------//2138 2139 stats = ppStats[SAO_EO_3];2140 count = ppCount[SAO_EO_3];2141 pOrg = pOrgStart;2142 pRec = pRecStart;2143 2144 posShift = stride - 1;2145 startX = (pbBorderAvail[SGU_L]) ? 0 : 1;2146 endX = (pbBorderAvail[SGU_R]) ? width : (width -1);2147 2148 //prepare 2nd line upper sign2149 pRec += stride;2150 for (x=startX-1; x< endX; x++)2151 {2152 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x- posShift]);2153 }2154 2155 2156 //first line2157 pRec -= stride;2158 if(pbBorderAvail[SGU_T])2159 {2160 for(x= startX; x< width -1; x++)2161 {2162 edgeType = xSign(pRec[x] - pRec[x- posShift]) -m_iUpBuff1[x-1] + 2;2163 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2164 count[m_auiEoTable[edgeType]] ++;2165 }2166 }2167 if(pbBorderAvail[SGU_TR])2168 {2169 x= width-1;2170 edgeType = xSign(pRec[x] - pRec[x- posShift]) -m_iUpBuff1[x-1] + 2;2171 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2172 count[m_auiEoTable[edgeType]] ++;2173 }2174 pRec += stride;2175 pOrg += stride;2176 2177 //middle lines2178 for (y= 1; y< height-1; y++)2179 {2180 for(x= startX; x< endX; x++)2181 {2182 signDown1 = xSign(pRec[x] - pRec[x+ posShift]) ;2183 edgeType = signDown1 + m_iUpBuff1[x] + 2;2184 2185 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2186 count[m_auiEoTable[edgeType]] ++;2187 m_iUpBuff1[x-1] = -signDown1;2188 2189 }2190 m_iUpBuff1[endX-1] = xSign(pRec[endX-1 + stride] - pRec[endX]);2191 2192 pRec += stride;2193 pOrg += stride;2194 }2195 2196 //last line2197 if(pbBorderAvail[SGU_BL])2198 {2199 x= 0;2200 edgeType = xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2;2201 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2202 count[m_auiEoTable[edgeType]] ++;2203 2204 }2205 if(pbBorderAvail[SGU_B])2206 {2207 for(x= 1; x< endX; x++)2208 {2209 edgeType = xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2;2210 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);2211 count[m_auiEoTable[edgeType]] ++;2212 }2213 }2214 }2215 2216 /** Calculate SAO statistics for current LCU2217 * \param iAddr, iPartIdx, iYCbCr2218 */2219 Void TEncSampleAdaptiveOffset::calcSaoStatsCu(Int iAddr, Int iPartIdx, Int iYCbCr)2220 {2221 if(!m_bUseNIF)2222 {2223 calcSaoStatsCuOrg( iAddr, iPartIdx, iYCbCr);2224 }2225 else2226 {2227 Int64** ppStats = m_iOffsetOrg[iPartIdx];2228 Int64** ppCount = m_iCount [iPartIdx];2229 2230 //parameters2231 Int isChroma = (iYCbCr != 0)? 1:0;2232 Int stride = (iYCbCr != 0)?(m_pcPic->getCStride()):(m_pcPic->getStride());2233 Pel* pPicOrg = getPicYuvAddr (m_pcPic->getPicYuvOrg(), iYCbCr);2234 Pel* pPicRec = getPicYuvAddr(m_pcYuvTmp, iYCbCr);2235 2236 std::vector<NDBFBlockInfo>& vFilterBlocks = *(m_pcPic->getCU(iAddr)->getNDBFilterBlocks());2237 2238 //variables2239 UInt xPos, yPos, width, height;2240 Bool* pbBorderAvail;2241 UInt posOffset;2242 2243 for(Int i=0; i< vFilterBlocks.size(); i++)2244 {2245 xPos = vFilterBlocks[i].posX >> isChroma;2246 yPos = vFilterBlocks[i].posY >> isChroma;2247 width = vFilterBlocks[i].width >> isChroma;2248 height = vFilterBlocks[i].height >> isChroma;2249 pbBorderAvail = vFilterBlocks[i].isBorderAvailable;2250 2251 posOffset = (yPos* stride) + xPos;2252 2253 calcSaoStatsBlock(pPicRec+ posOffset, pPicOrg+ posOffset, stride, ppStats, ppCount,width, height, pbBorderAvail, iYCbCr);2254 }2255 }2256 2257 }2258 2259 /** Calculate SAO statistics for current LCU without non-crossing slice2260 * \param iAddr, iPartIdx, iYCbCr2261 */2262 Void TEncSampleAdaptiveOffset::calcSaoStatsCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr)2263 {2264 Int x,y;2265 TComDataCU *pTmpCu = m_pcPic->getCU(iAddr);2266 TComSPS *pTmpSPS = m_pcPic->getSlice(0)->getSPS();2267 2268 Pel* pOrg;2269 Pel* pRec;2270 Int iStride;2271 Int iLcuHeight = pTmpSPS->getMaxCUHeight();2272 Int iLcuWidth = pTmpSPS->getMaxCUWidth();2273 UInt uiLPelX = pTmpCu->getCUPelX();2274 UInt uiTPelY = pTmpCu->getCUPelY();2275 UInt uiRPelX;2276 UInt uiBPelY;2277 Int64* iStats;2278 Int64* iCount;2279 Int iClassIdx;2280 Int iPicWidthTmp;2281 Int iPicHeightTmp;2282 Int iStartX;2283 Int iStartY;2284 Int iEndX;2285 Int iEndY;2286 Pel* pTableBo = (iYCbCr==0)?m_lumaTableBo:m_chromaTableBo;2287 2288 Int iIsChroma = (iYCbCr!=0)? 1:0;2289 Int numSkipLine = iIsChroma? 2:4;2290 if (m_saoLcuBasedOptimization == 0)2291 {2292 numSkipLine = 0;2293 }2294 2295 Int numSkipLineRight = iIsChroma? 3:5;2296 if (m_saoLcuBasedOptimization == 0)2297 {2298 numSkipLineRight = 0;2299 }2300 2301 iPicWidthTmp = m_iPicWidth >> iIsChroma;2302 iPicHeightTmp = m_iPicHeight >> iIsChroma;2303 iLcuWidth = iLcuWidth >> iIsChroma;2304 iLcuHeight = iLcuHeight >> iIsChroma;2305 uiLPelX = uiLPelX >> iIsChroma;2306 uiTPelY = uiTPelY >> iIsChroma;2307 uiRPelX = uiLPelX + iLcuWidth ;2308 uiBPelY = uiTPelY + iLcuHeight ;2309 uiRPelX = uiRPelX > iPicWidthTmp ? iPicWidthTmp : uiRPelX;2310 uiBPelY = uiBPelY > iPicHeightTmp ? iPicHeightTmp : uiBPelY;2311 iLcuWidth = uiRPelX - uiLPelX;2312 iLcuHeight = uiBPelY - uiTPelY;2313 2314 iStride = (iYCbCr == 0)? m_pcPic->getStride(): m_pcPic->getCStride();2315 2316 //if(iSaoType == BO_0 || iSaoType == BO_1)2317 {2318 if( m_saoLcuBasedOptimization && m_saoLcuBoundary )2319 {2320 numSkipLine = iIsChroma? 1:3;2321 numSkipLineRight = iIsChroma? 2:4;2322 }2323 iStats = m_iOffsetOrg[iPartIdx][SAO_BO];2324 iCount = m_iCount [iPartIdx][SAO_BO];2325 2326 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);2327 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);2328 2329 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth : iLcuWidth-numSkipLineRight;2330 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight : iLcuHeight-numSkipLine;2331 for (y=0; y<iEndY; y++)2332 {2333 for (x=0; x<iEndX; x++)2334 {2335 iClassIdx = pTableBo[pRec[x]];2336 if (iClassIdx)2337 {2338 iStats[iClassIdx] += (pOrg[x] - pRec[x]);2339 iCount[iClassIdx] ++;2340 }2341 }2342 pOrg += iStride;2343 pRec += iStride;2344 }2345 2346 }2347 Int iSignLeft;2348 Int iSignRight;2349 Int iSignDown;2350 Int iSignDown1;2351 Int iSignDown2;2352 2353 UInt uiEdgeType;2354 2355 //if (iSaoType == EO_0 || iSaoType == EO_1 || iSaoType == EO_2 || iSaoType == EO_3)2356 {2357 //if (iSaoType == EO_0)2358 {2359 if( m_saoLcuBasedOptimization && m_saoLcuBoundary )2360 {2361 numSkipLine = iIsChroma? 1:3;2362 numSkipLineRight = iIsChroma? 3:5;2363 }2364 iStats = m_iOffsetOrg[iPartIdx][SAO_EO_0];2365 iCount = m_iCount [iPartIdx][SAO_EO_0];2366 2367 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);2368 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);2369 2370 iStartX = (uiLPelX == 0) ? 1 : 0;2371 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth-numSkipLineRight;2372 for (y=0; y<iLcuHeight-numSkipLine; y++)2373 {2374 iSignLeft = xSign(pRec[iStartX] - pRec[iStartX-1]);2375 for (x=iStartX; x< iEndX; x++)2376 {2377 iSignRight = xSign(pRec[x] - pRec[x+1]);2378 uiEdgeType = iSignRight + iSignLeft + 2;2379 iSignLeft = -iSignRight;2380 2381 iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);2382 iCount[m_auiEoTable[uiEdgeType]] ++;2383 }2384 pOrg += iStride;2385 pRec += iStride;2386 }2387 }2388 2389 //if (iSaoType == EO_1)2390 {2391 if( m_saoLcuBasedOptimization && m_saoLcuBoundary )2392 {2393 numSkipLine = iIsChroma? 2:4;2394 numSkipLineRight = iIsChroma? 2:4;2395 }2396 iStats = m_iOffsetOrg[iPartIdx][SAO_EO_1];2397 iCount = m_iCount [iPartIdx][SAO_EO_1];2398 2399 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);2400 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);2401 2402 iStartY = (uiTPelY == 0) ? 1 : 0;2403 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth : iLcuWidth-numSkipLineRight;2404 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine;2405 if (uiTPelY == 0)2406 {2407 pOrg += iStride;2408 pRec += iStride;2409 }2410 2411 for (x=0; x< iLcuWidth; x++)2412 {2413 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-iStride]);2414 }2415 for (y=iStartY; y<iEndY; y++)2416 {2417 for (x=0; x<iEndX; x++)2418 {2419 iSignDown = xSign(pRec[x] - pRec[x+iStride]);2420 uiEdgeType = iSignDown + m_iUpBuff1[x] + 2;2421 m_iUpBuff1[x] = -iSignDown;2422 2423 iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);2424 iCount[m_auiEoTable[uiEdgeType]] ++;2425 }2426 pOrg += iStride;2427 pRec += iStride;2428 }2429 }2430 //if (iSaoType == EO_2)2431 {2432 if( m_saoLcuBasedOptimization && m_saoLcuBoundary )2433 {2434 numSkipLine = iIsChroma? 2:4;2435 numSkipLineRight = iIsChroma? 3:5;2436 }2437 iStats = m_iOffsetOrg[iPartIdx][SAO_EO_2];2438 iCount = m_iCount [iPartIdx][SAO_EO_2];2439 2440 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);2441 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);2442 2443 iStartX = (uiLPelX == 0) ? 1 : 0;2444 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth-numSkipLineRight;2445 2446 iStartY = (uiTPelY == 0) ? 1 : 0;2447 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine;2448 if (uiTPelY == 0)2449 {2450 pOrg += iStride;2451 pRec += iStride;2452 }2453 2454 for (x=iStartX; x<iEndX; x++)2455 {2456 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-iStride-1]);2457 }2458 for (y=iStartY; y<iEndY; y++)2459 {2460 iSignDown2 = xSign(pRec[iStride+iStartX] - pRec[iStartX-1]);2461 for (x=iStartX; x<iEndX; x++)2462 {2463 iSignDown1 = xSign(pRec[x] - pRec[x+iStride+1]) ;2464 uiEdgeType = iSignDown1 + m_iUpBuff1[x] + 2;2465 m_iUpBufft[x+1] = -iSignDown1;2466 iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);2467 iCount[m_auiEoTable[uiEdgeType]] ++;2468 }2469 m_iUpBufft[iStartX] = iSignDown2;2470 ipSwap = m_iUpBuff1;2471 m_iUpBuff1 = m_iUpBufft;2472 m_iUpBufft = ipSwap;2473 2474 pRec += iStride;2475 pOrg += iStride;2476 }2477 }2478 //if (iSaoType == EO_3 )2479 {2480 if( m_saoLcuBasedOptimization && m_saoLcuBoundary )2481 {2482 numSkipLine = iIsChroma? 2:4;2483 numSkipLineRight = iIsChroma? 3:5;2484 }2485 iStats = m_iOffsetOrg[iPartIdx][SAO_EO_3];2486 iCount = m_iCount [iPartIdx][SAO_EO_3];2487 2488 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);2489 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);2490 2491 iStartX = (uiLPelX == 0) ? 1 : 0;2492 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth-numSkipLineRight;2493 2494 iStartY = (uiTPelY == 0) ? 1 : 0;2495 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine;2496 if (iStartY == 1)2497 {2498 pOrg += iStride;2499 pRec += iStride;2500 }2501 2502 for (x=iStartX-1; x<iEndX; x++)2503 {2504 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-iStride+1]);2505 }2506 2507 for (y=iStartY; y<iEndY; y++)2508 {2509 for (x=iStartX; x<iEndX; x++)2510 {2511 iSignDown1 = xSign(pRec[x] - pRec[x+iStride-1]) ;2512 uiEdgeType = iSignDown1 + m_iUpBuff1[x] + 2;2513 m_iUpBuff1[x-1] = -iSignDown1;2514 iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);2515 iCount[m_auiEoTable[uiEdgeType]] ++;2516 }2517 m_iUpBuff1[iEndX-1] = xSign(pRec[iEndX-1 + iStride] - pRec[iEndX]);2518 2519 pRec += iStride;2520 pOrg += iStride;2521 }2522 }2523 }2524 }2525 2526 2527 Void TEncSampleAdaptiveOffset::calcSaoStatsCu_BeforeDblk( TComPic* pcPic )2528 {2529 Int addr, yCbCr;2530 Int x,y;2531 TComSPS *pTmpSPS = pcPic->getSlice(0)->getSPS();2532 2533 Pel* pOrg;2534 Pel* pRec;2535 Int stride;2536 Int lcuHeight = pTmpSPS->getMaxCUHeight();2537 Int lcuWidth = pTmpSPS->getMaxCUWidth();2538 UInt rPelX;2539 UInt bPelY;2540 Int64* stats;2541 Int64* count;2542 Int classIdx;2543 Int picWidthTmp = 0;2544 Int picHeightTmp = 0;2545 Int startX;2546 Int startY;2547 Int endX;2548 Int endY;2549 Int firstX, firstY;2550 2551 Int idxY;2552 Int idxX;2553 Int frameHeightInCU = m_iNumCuInHeight;2554 Int frameWidthInCU = m_iNumCuInWidth;2555 Int j, k;2556 2557 Int isChroma;2558 Int numSkipLine, numSkipLineRight;2559 2560 UInt lPelX, tPelY;2561 TComDataCU *pTmpCu;2562 Pel* pTableBo;2563 2564 for (idxY = 0; idxY< frameHeightInCU; idxY++)2565 {2566 for (idxX = 0; idxX< frameWidthInCU; idxX++)2567 {2568 lcuHeight = pTmpSPS->getMaxCUHeight();2569 lcuWidth = pTmpSPS->getMaxCUWidth();2570 addr = idxX + frameWidthInCU*idxY;2571 pTmpCu = pcPic->getCU(addr);2572 lPelX = pTmpCu->getCUPelX();2573 tPelY = pTmpCu->getCUPelY();2574 for( yCbCr = 0; yCbCr < 3; yCbCr++ )2575 {2576 isChroma = (yCbCr!=0)? 1:0;2577 2578 for ( j=0;j<MAX_NUM_SAO_TYPE;j++)2579 {2580 for ( k=0;k< MAX_NUM_SAO_CLASS;k++)2581 {2582 m_count_PreDblk [addr][yCbCr][j][k] = 0;2583 m_offsetOrg_PreDblk[addr][yCbCr][j][k] = 0;2584 }2585 }2586 if( yCbCr == 0 )2587 {2588 picWidthTmp = m_iPicWidth;2589 picHeightTmp = m_iPicHeight;2590 }2591 else if( yCbCr == 1 )2592 {2593 picWidthTmp = m_iPicWidth >> isChroma;2594 picHeightTmp = m_iPicHeight >> isChroma;2595 lcuWidth = lcuWidth >> isChroma;2596 lcuHeight = lcuHeight >> isChroma;2597 lPelX = lPelX >> isChroma;2598 tPelY = tPelY >> isChroma;2599 }2600 rPelX = lPelX + lcuWidth ;2601 bPelY = tPelY + lcuHeight ;2602 rPelX = rPelX > picWidthTmp ? picWidthTmp : rPelX;2603 bPelY = bPelY > picHeightTmp ? picHeightTmp : bPelY;2604 lcuWidth = rPelX - lPelX;2605 lcuHeight = bPelY - tPelY;2606 2607 stride = (yCbCr == 0)? pcPic->getStride(): pcPic->getCStride();2608 pTableBo = (yCbCr==0)?m_lumaTableBo:m_chromaTableBo;2609 2610 //if(iSaoType == BO)2611 2612 numSkipLine = isChroma? 1:3;2613 numSkipLineRight = isChroma? 2:4;2614 2615 stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_BO];2616 count = m_count_PreDblk[addr][yCbCr][SAO_BO];2617 2618 pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr);2619 pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr);2620 2621 startX = (rPelX == picWidthTmp) ? lcuWidth : lcuWidth-numSkipLineRight;2622 startY = (bPelY == picHeightTmp) ? lcuHeight : lcuHeight-numSkipLine;2623 2624 for (y=0; y<lcuHeight; y++)2625 {2626 for (x=0; x<lcuWidth; x++)2627 {2628 if( x < startX && y < startY )2629 continue;2630 2631 classIdx = pTableBo[pRec[x]];2632 if (classIdx)2633 {2634 stats[classIdx] += (pOrg[x] - pRec[x]);2635 count[classIdx] ++;2636 }2637 }2638 pOrg += stride;2639 pRec += stride;2640 }2641 2642 Int signLeft;2643 Int signRight;2644 Int signDown;2645 Int signDown1;2646 Int signDown2;2647 2648 UInt uiEdgeType;2649 2650 //if (iSaoType == EO_0)2651 2652 numSkipLine = isChroma? 1:3;2653 numSkipLineRight = isChroma? 3:5;2654 2655 stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_0];2656 count = m_count_PreDblk[addr][yCbCr][SAO_EO_0];2657 2658 pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr);2659 pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr);2660 2661 startX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth-numSkipLineRight;2662 startY = (bPelY == picHeightTmp) ? lcuHeight : lcuHeight-numSkipLine;2663 firstX = (lPelX == 0) ? 1 : 0;2664 endX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth;2665 2666 for (y=0; y<lcuHeight; y++)2667 {2668 signLeft = xSign(pRec[firstX] - pRec[firstX-1]);2669 for (x=firstX; x< endX; x++)2670 {2671 signRight = xSign(pRec[x] - pRec[x+1]);2672 uiEdgeType = signRight + signLeft + 2;2673 signLeft = -signRight;2674 2675 if( x < startX && y < startY )2676 continue;2677 2678 stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);2679 count[m_auiEoTable[uiEdgeType]] ++;2680 }2681 pOrg += stride;2682 pRec += stride;2683 }2684 2685 //if (iSaoType == EO_1)2686 2687 numSkipLine = isChroma? 2:4;2688 numSkipLineRight = isChroma? 2:4;2689 2690 stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_1];2691 count = m_count_PreDblk[addr][yCbCr][SAO_EO_1];2692 2693 pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr);2694 pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr);2695 2696 startX = (rPelX == picWidthTmp) ? lcuWidth : lcuWidth-numSkipLineRight;2697 startY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight-numSkipLine;2698 firstY = (tPelY == 0) ? 1 : 0;2699 endY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight;2700 if (firstY == 1)2701 {2702 pOrg += stride;2703 pRec += stride;2704 }2705 2706 for (x=0; x< lcuWidth; x++)2707 {2708 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride]);2709 }2710 for (y=firstY; y<endY; y++)2711 {2712 for (x=0; x<lcuWidth; x++)2713 {2714 signDown = xSign(pRec[x] - pRec[x+stride]);2715 uiEdgeType = signDown + m_iUpBuff1[x] + 2;2716 m_iUpBuff1[x] = -signDown;2717 2718 if( x < startX && y < startY )2719 continue;2720 2721 stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);2722 count[m_auiEoTable[uiEdgeType]] ++;2723 }2724 pOrg += stride;2725 pRec += stride;2726 }2727 2728 //if (iSaoType == EO_2)2729 2730 numSkipLine = isChroma? 2:4;2731 numSkipLineRight = isChroma? 3:5;2732 2733 stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_2];2734 count = m_count_PreDblk[addr][yCbCr][SAO_EO_2];2735 2736 pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr);2737 pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr);2738 2739 startX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth-numSkipLineRight;2740 startY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight-numSkipLine;2741 firstX = (lPelX == 0) ? 1 : 0;2742 firstY = (tPelY == 0) ? 1 : 0;2743 endX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth;2744 endY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight;2745 if (firstY == 1)2746 {2747 pOrg += stride;2748 pRec += stride;2749 }2750 2751 for (x=firstX; x<endX; x++)2752 {2753 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride-1]);2754 }2755 for (y=firstY; y<endY; y++)2756 {2757 signDown2 = xSign(pRec[stride+startX] - pRec[startX-1]);2758 for (x=firstX; x<endX; x++)2759 {2760 signDown1 = xSign(pRec[x] - pRec[x+stride+1]) ;2761 uiEdgeType = signDown1 + m_iUpBuff1[x] + 2;2762 m_iUpBufft[x+1] = -signDown1;2763 2764 if( x < startX && y < startY )2765 continue;2766 2767 stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);2768 count[m_auiEoTable[uiEdgeType]] ++;2769 }2770 m_iUpBufft[firstX] = signDown2;2771 ipSwap = m_iUpBuff1;2772 m_iUpBuff1 = m_iUpBufft;2773 m_iUpBufft = ipSwap;2774 2775 pRec += stride;2776 pOrg += stride;2777 }2778 2779 //if (iSaoType == EO_3)2780 2781 numSkipLine = isChroma? 2:4;2782 numSkipLineRight = isChroma? 3:5;2783 2784 stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_3];2785 count = m_count_PreDblk[addr][yCbCr][SAO_EO_3];2786 2787 pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr);2788 pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr);2789 2790 startX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth-numSkipLineRight;2791 startY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight-numSkipLine;2792 firstX = (lPelX == 0) ? 1 : 0;2793 firstY = (tPelY == 0) ? 1 : 0;2794 endX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth;2795 endY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight;2796 if (firstY == 1)2797 {2798 pOrg += stride;2799 pRec += stride;2800 }2801 2802 for (x=firstX-1; x<endX; x++)2803 {2804 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride+1]);2805 }2806 2807 for (y=firstY; y<endY; y++)2808 {2809 for (x=firstX; x<endX; x++)2810 {2811 signDown1 = xSign(pRec[x] - pRec[x+stride-1]) ;2812 uiEdgeType = signDown1 + m_iUpBuff1[x] + 2;2813 m_iUpBuff1[x-1] = -signDown1;2814 2815 if( x < startX && y < startY )2816 continue;2817 2818 stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);2819 count[m_auiEoTable[uiEdgeType]] ++;2820 }2821 m_iUpBuff1[endX-1] = xSign(pRec[endX-1 + stride] - pRec[endX]);2822 2823 pRec += stride;2824 pOrg += stride;2825 }2826 }2827 }2828 }2829 }2830 2831 2832 /** get SAO statistics2833 * \param *psQTPart, iYCbCr2834 */2835 Void TEncSampleAdaptiveOffset::getSaoStats(SAOQTPart *psQTPart, Int iYCbCr)2836 {2837 Int iLevelIdx, iPartIdx, iTypeIdx, iClassIdx;2838 Int i;2839 Int iNumTotalType = MAX_NUM_SAO_TYPE;2840 Int LcuIdxX;2841 Int LcuIdxY;2842 Int iAddr;2843 Int iFrameWidthInCU = m_pcPic->getFrameWidthInCU();2844 Int iDownPartIdx;2845 Int iPartStart;2846 Int iPartEnd;2847 SAOQTPart* pOnePart;2848 2849 if (m_uiMaxSplitLevel == 0)2850 {2851 iPartIdx = 0;2852 pOnePart = &(psQTPart[iPartIdx]);2853 for (LcuIdxY = pOnePart->StartCUY; LcuIdxY<= pOnePart->EndCUY; LcuIdxY++)2854 {2855 for (LcuIdxX = pOnePart->StartCUX; LcuIdxX<= pOnePart->EndCUX; LcuIdxX++)2856 {2857 iAddr = LcuIdxY*iFrameWidthInCU + LcuIdxX;2858 calcSaoStatsCu(iAddr, iPartIdx, iYCbCr);2859 }2860 }2861 }2862 else2863 {2864 for(iPartIdx=m_aiNumCulPartsLevel[m_uiMaxSplitLevel-1]; iPartIdx<m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; iPartIdx++)2865 {2866 pOnePart = &(psQTPart[iPartIdx]);2867 for (LcuIdxY = pOnePart->StartCUY; LcuIdxY<= pOnePart->EndCUY; LcuIdxY++)2868 {2869 for (LcuIdxX = pOnePart->StartCUX; LcuIdxX<= pOnePart->EndCUX; LcuIdxX++)2870 {2871 iAddr = LcuIdxY*iFrameWidthInCU + LcuIdxX;2872 calcSaoStatsCu(iAddr, iPartIdx, iYCbCr);2873 }2874 }2875 }2876 for (iLevelIdx = m_uiMaxSplitLevel-1; iLevelIdx>=0; iLevelIdx-- )2877 {2878 iPartStart = (iLevelIdx > 0) ? m_aiNumCulPartsLevel[iLevelIdx-1] : 0;2879 iPartEnd = m_aiNumCulPartsLevel[iLevelIdx];2880 2881 for(iPartIdx = iPartStart; iPartIdx < iPartEnd; iPartIdx++)2882 {2883 pOnePart = &(psQTPart[iPartIdx]);2884 for (i=0; i< NUM_DOWN_PART; i++)2885 {2886 iDownPartIdx = pOnePart->DownPartsIdx[i];2887 for (iTypeIdx=0; iTypeIdx<iNumTotalType; iTypeIdx++)2888 {2889 for (iClassIdx=0; iClassIdx< (iTypeIdx < SAO_BO ? m_iNumClass[iTypeIdx] : SAO_MAX_BO_CLASSES) +1; iClassIdx++)2890 {2891 m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx] += m_iOffsetOrg[iDownPartIdx][iTypeIdx][iClassIdx];2892 m_iCount [iPartIdx][iTypeIdx][iClassIdx] += m_iCount [iDownPartIdx][iTypeIdx][iClassIdx];2893 }2894 }2895 }2896 }2897 }2898 }2899 }2900 2901 /** reset offset statistics2902 * \param2903 */2904 Void TEncSampleAdaptiveOffset::resetStats()2905 {2906 for (Int i=0;i<m_iNumTotalParts;i++)2907 {2908 m_dCostPartBest[i] = MAX_DOUBLE;2909 m_iTypePartBest[i] = -1;2910 m_iDistOrg[i] = 0;2911 for (Int j=0;j<MAX_NUM_SAO_TYPE;j++)2912 {2913 m_iDist[i][j] = 0;2914 m_iRate[i][j] = 0;2915 m_dCost[i][j] = 0;2916 for (Int k=0;k<MAX_NUM_SAO_CLASS;k++)2917 {2918 m_iCount [i][j][k] = 0;2919 m_iOffset[i][j][k] = 0;2920 m_iOffsetOrg[i][j][k] = 0;2921 }2922 }2923 }2924 }2925 2926 /** Sample adaptive offset process2927 * \param pcSaoParam2928 * \param dLambdaLuma2929 * \param dLambdaChroma2930 */2931 #if SAO_ENCODING_CHOICE2932 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambdaLuma, Double dLambdaChroma, Int depth)2933 #else2934 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambdaLuma, Double dLambdaChroma)2935 #endif2936 {2937 if(m_bUseNIF)2938 {2939 m_pcPic->getPicYuvRec()->copyToPic(m_pcYuvTmp);2940 }2941 2942 m_uiSaoBitIncreaseY = max(g_bitDepthY - 10, 0);2943 m_uiSaoBitIncreaseC = max(g_bitDepthC - 10, 0);2944 m_iOffsetThY = 1 << min(g_bitDepthY - 5, 5);2945 m_iOffsetThC = 1 << min(g_bitDepthC - 5, 5);2946 resetSAOParam(pcSaoParam);2947 if( !m_saoLcuBasedOptimization || !m_saoLcuBoundary )2948 {2949 resetStats();2950 }2951 Double dCostFinal = 0;2952 if ( m_saoLcuBasedOptimization)2953 {2954 #if SAO_ENCODING_CHOICE2955 rdoSaoUnitAll(pcSaoParam, dLambdaLuma, dLambdaChroma, depth);2956 #else2957 rdoSaoUnitAll(pcSaoParam, dLambdaLuma, dLambdaChroma);2958 #endif2959 }2960 else2961 {2962 pcSaoParam->bSaoFlag[0] = 1;2963 pcSaoParam->bSaoFlag[1] = 0;2964 dCostFinal = 0;2965 Double lambdaRdo = dLambdaLuma;2966 resetStats();2967 getSaoStats(pcSaoParam->psSaoPart[0], 0);2968 runQuadTreeDecision(pcSaoParam->psSaoPart[0], 0, dCostFinal, m_uiMaxSplitLevel, lambdaRdo, 0);2969 pcSaoParam->bSaoFlag[0] = dCostFinal < 0 ? 1:0;2970 if(pcSaoParam->bSaoFlag[0])2971 {2972 convertQT2SaoUnit(pcSaoParam, 0, 0);2973 assignSaoUnitSyntax(pcSaoParam->saoLcuParam[0], pcSaoParam->psSaoPart[0], pcSaoParam->oneUnitFlag[0], 0);2974 }2975 }2976 if (pcSaoParam->bSaoFlag[0])2977 {2978 processSaoUnitAll( pcSaoParam->saoLcuParam[0], pcSaoParam->oneUnitFlag[0], 0);2979 }2980 if (pcSaoParam->bSaoFlag[1])2981 {2982 processSaoUnitAll( pcSaoParam->saoLcuParam[1], pcSaoParam->oneUnitFlag[1], 1);2983 processSaoUnitAll( pcSaoParam->saoLcuParam[2], pcSaoParam->oneUnitFlag[2], 2);2984 }2985 }2986 /** Check merge SAO unit2987 * \param saoUnitCurr current SAO unit2988 * \param saoUnitCheck SAO unit tobe check2989 * \param dir direction2990 */2991 Void TEncSampleAdaptiveOffset::checkMerge(SaoLcuParam * saoUnitCurr, SaoLcuParam * saoUnitCheck, Int dir)2992 {2993 Int i ;2994 Int countDiff = 0;2995 if (saoUnitCurr->partIdx != saoUnitCheck->partIdx)2996 {2997 if (saoUnitCurr->typeIdx !=-1)2998 {2999 if (saoUnitCurr->typeIdx == saoUnitCheck->typeIdx)3000 {3001 for (i=0;i<saoUnitCurr->length;i++)3002 {3003 countDiff += (saoUnitCurr->offset[i] != saoUnitCheck->offset[i]);3004 }3005 countDiff += (saoUnitCurr->subTypeIdx != saoUnitCheck->subTypeIdx);3006 if (countDiff ==0)3007 {3008 saoUnitCurr->partIdx = saoUnitCheck->partIdx;3009 if (dir == 1)3010 {3011 saoUnitCurr->mergeUpFlag = 1;3012 saoUnitCurr->mergeLeftFlag = 0;3013 }3014 else3015 {3016 saoUnitCurr->mergeUpFlag = 0;3017 saoUnitCurr->mergeLeftFlag = 1;3018 }3019 }3020 }3021 }3022 else3023 {3024 if (saoUnitCurr->typeIdx == saoUnitCheck->typeIdx)3025 {3026 saoUnitCurr->partIdx = saoUnitCheck->partIdx;3027 if (dir == 1)3028 {3029 saoUnitCurr->mergeUpFlag = 1;3030 saoUnitCurr->mergeLeftFlag = 0;3031 }3032 else3033 {3034 saoUnitCurr->mergeUpFlag = 0;3035 saoUnitCurr->mergeLeftFlag = 1;3036 }3037 }3038 }3039 }3040 }3041 /** Assign SAO unit syntax from picture-based algorithm3042 * \param saoLcuParam SAO LCU parameters3043 * \param saoPart SAO part3044 * \param oneUnitFlag SAO one unit flag3045 * \param iYCbCr color component Index3046 */3047 Void TEncSampleAdaptiveOffset::assignSaoUnitSyntax(SaoLcuParam* saoLcuParam, SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr)3048 {3049 if (saoPart->bSplit == 0)3050 {3051 oneUnitFlag = 1;3052 }3053 else3054 {3055 Int i,j, addr, addrUp, addrLeft, idx, idxUp, idxLeft, idxCount;3056 3057 oneUnitFlag = 0;3058 3059 idxCount = -1;3060 saoLcuParam[0].mergeUpFlag = 0;3061 saoLcuParam[0].mergeLeftFlag = 0;3062 3063 for (j=0;j<m_iNumCuInHeight;j++)3064 {3065 for (i=0;i<m_iNumCuInWidth;i++)3066 {3067 addr = i + j*m_iNumCuInWidth;3068 addrLeft = (addr%m_iNumCuInWidth == 0) ? -1 : addr - 1;3069 addrUp = (addr<m_iNumCuInWidth) ? -1 : addr - m_iNumCuInWidth;3070 idx = saoLcuParam[addr].partIdxTmp;3071 idxLeft = (addrLeft == -1) ? -1 : saoLcuParam[addrLeft].partIdxTmp;3072 idxUp = (addrUp == -1) ? -1 : saoLcuParam[addrUp].partIdxTmp;3073 3074 if(idx!=idxLeft && idx!=idxUp)3075 {3076 saoLcuParam[addr].mergeUpFlag = 0; idxCount++;3077 saoLcuParam[addr].mergeLeftFlag = 0;3078 saoLcuParam[addr].partIdx = idxCount;3079 }3080 else if (idx==idxLeft)3081 {3082 saoLcuParam[addr].mergeUpFlag = 1;3083 saoLcuParam[addr].mergeLeftFlag = 1;3084 saoLcuParam[addr].partIdx = saoLcuParam[addrLeft].partIdx;3085 }3086 else if (idx==idxUp)3087 {3088 saoLcuParam[addr].mergeUpFlag = 1;3089 saoLcuParam[addr].mergeLeftFlag = 0;3090 saoLcuParam[addr].partIdx = saoLcuParam[addrUp].partIdx;3091 }3092 if (addrUp != -1)3093 {3094 checkMerge(&saoLcuParam[addr], &saoLcuParam[addrUp], 1);3095 }3096 if (addrLeft != -1)3097 {3098 checkMerge(&saoLcuParam[addr], &saoLcuParam[addrLeft], 0);3099 }3100 }3101 }3102 }3103 }3104 /** rate distortion optimization of all SAO units3105 * \param saoParam SAO parameters3106 * \param lambda3107 * \param lambdaChroma3108 */3109 #if SAO_ENCODING_CHOICE3110 Void TEncSampleAdaptiveOffset::rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth)3111 #else3112 Void TEncSampleAdaptiveOffset::rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma)3113 #endif3114 {3115 3116 Int idxY;3117 Int idxX;3118 Int frameHeightInCU = saoParam->numCuInHeight;3119 Int frameWidthInCU = saoParam->numCuInWidth;3120 Int j, k;3121 Int addr = 0;3122 Int addrUp = -1;3123 Int addrLeft = -1;3124 Int compIdx = 0;3125 SaoLcuParam mergeSaoParam[3][2];3126 Double compDistortion[3];3127 3128 saoParam->bSaoFlag[0] = true;3129 #if AUXILIARY_PICTURES3130 saoParam->bSaoFlag[1] = m_pcPic->getChromaFormat() == CHROMA_400 ? false : true;3131 #else3132 saoParam->bSaoFlag[1] = true;3133 #endif3134 saoParam->oneUnitFlag[0] = false;3135 saoParam->oneUnitFlag[1] = false;3136 saoParam->oneUnitFlag[2] = false;3137 3138 #if SAO_ENCODING_CHOICE3139 #if SAO_ENCODING_CHOICE_CHROMA3140 Int numNoSao[2];3141 numNoSao[0] = 0;// Luma3142 numNoSao[1] = 0;// Chroma3143 if( depth > 0 && m_depthSaoRate[0][depth-1] > SAO_ENCODING_RATE )3144 {3145 saoParam->bSaoFlag[0] = false;3146 }3147 if( depth > 0 && m_depthSaoRate[1][depth-1] > SAO_ENCODING_RATE_CHROMA )3148 {3149 saoParam->bSaoFlag[1] = false;3150 }3151 #else3152 Int numNoSao = 0;3153 3154 if( depth > 0 && m_depth0SaoRate > SAO_ENCODING_RATE )3155 {3156 saoParam->bSaoFlag[0] = false;3157 saoParam->bSaoFlag[1] = false;3158 }3159 #endif3160 #endif3161 3162 for (idxY = 0; idxY< frameHeightInCU; idxY++)3163 {3164 for (idxX = 0; idxX< frameWidthInCU; idxX++)3165 {3166 addr = idxX + frameWidthInCU*idxY;3167 addrUp = addr < frameWidthInCU ? -1:idxX + frameWidthInCU*(idxY-1);3168 addrLeft = idxX == 0 ? -1:idxX-1 + frameWidthInCU*idxY;3169 Int allowMergeLeft = 1;3170 Int allowMergeUp = 1;3171 UInt rate;3172 Double bestCost, mergeCost;3173 if (idxX!=0)3174 {3175 // check tile id and slice id3176 if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-1) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-1)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))3177 {3178 allowMergeLeft = 0;3179 }3180 }3181 else3182 {3183 allowMergeLeft = 0;3184 }3185 if (idxY!=0)3186 {3187 if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-m_iNumCuInWidth) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-m_iNumCuInWidth)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))3188 {3189 allowMergeUp = 0;3190 }3191 }3192 else3193 {3194 allowMergeUp = 0;3195 }3196 3197 compDistortion[0] = 0;3198 compDistortion[1] = 0;3199 compDistortion[2] = 0;3200 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);3201 if (allowMergeLeft)3202 {3203 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0);3204 }3205 if (allowMergeUp)3206 {3207 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0);3208 }3209 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_TEMP_BEST] );3210 // reset stats Y, Cb, Cr3211 for ( compIdx=0;compIdx<3;compIdx++)3212 {3213 for ( j=0;j<MAX_NUM_SAO_TYPE;j++)3214 {3215 for ( k=0;k< MAX_NUM_SAO_CLASS;k++)3216 {3217 m_iOffset [compIdx][j][k] = 0;3218 if( m_saoLcuBasedOptimization && m_saoLcuBoundary ){3219 m_iCount [compIdx][j][k] = m_count_PreDblk [addr][compIdx][j][k];3220 m_iOffsetOrg[compIdx][j][k] = m_offsetOrg_PreDblk[addr][compIdx][j][k];3221 }3222 else3223 {3224 m_iCount [compIdx][j][k] = 0;3225 m_iOffsetOrg[compIdx][j][k] = 0;3226 }3227 }3228 }3229 saoParam->saoLcuParam[compIdx][addr].typeIdx = -1;3230 saoParam->saoLcuParam[compIdx][addr].mergeUpFlag = 0;3231 saoParam->saoLcuParam[compIdx][addr].mergeLeftFlag = 0;3232 saoParam->saoLcuParam[compIdx][addr].subTypeIdx = 0;3233 #if SAO_ENCODING_CHOICE3234 if( (compIdx ==0 && saoParam->bSaoFlag[0])|| (compIdx >0 && saoParam->bSaoFlag[1]) )3235 #endif3236 {3237 calcSaoStatsCu(addr, compIdx, compIdx);3238 3239 }3240 }3241 saoComponentParamDist(allowMergeLeft, allowMergeUp, saoParam, addr, addrUp, addrLeft, 0, lambda, &mergeSaoParam[0][0], &compDistortion[0]);3242 sao2ChromaParamDist(allowMergeLeft, allowMergeUp, saoParam, addr, addrUp, addrLeft, lambdaChroma, &mergeSaoParam[1][0], &mergeSaoParam[2][0], &compDistortion[0]);3243 if( saoParam->bSaoFlag[0] || saoParam->bSaoFlag[1] )3244 {3245 // Cost of new SAO_params3246 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);3247 m_pcRDGoOnSbacCoder->resetBits();3248 if (allowMergeLeft)3249 {3250 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0);3251 }3252 if (allowMergeUp)3253 {3254 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0);3255 }3256 for ( compIdx=0;compIdx<3;compIdx++)3257 {3258 if( (compIdx ==0 && saoParam->bSaoFlag[0]) || (compIdx >0 && saoParam->bSaoFlag[1]))3259 {3260 m_pcEntropyCoder->encodeSaoOffset(&saoParam->saoLcuParam[compIdx][addr], compIdx);3261 }3262 }3263 3264 rate = m_pcEntropyCoder->getNumberOfWrittenBits();3265 bestCost = compDistortion[0] + (Double)rate;3266 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);3267 3268 // Cost of Merge3269 for(Int mergeUp=0; mergeUp<2; ++mergeUp)3270 {3271 if ( (allowMergeLeft && (mergeUp==0)) || (allowMergeUp && (mergeUp==1)) )3272 {3273 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);3274 m_pcRDGoOnSbacCoder->resetBits();3275 if (allowMergeLeft)3276 {3277 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(1-mergeUp);3278 }3279 if ( allowMergeUp && (mergeUp==1) )3280 {3281 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(1);3282 }3283 3284 rate = m_pcEntropyCoder->getNumberOfWrittenBits();3285 mergeCost = compDistortion[mergeUp+1] + (Double)rate;3286 if (mergeCost < bestCost)3287 {3288 bestCost = mergeCost;3289 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);3290 for ( compIdx=0;compIdx<3;compIdx++)3291 {3292 mergeSaoParam[compIdx][mergeUp].mergeLeftFlag = 1-mergeUp;3293 mergeSaoParam[compIdx][mergeUp].mergeUpFlag = mergeUp;3294 if( (compIdx==0 && saoParam->bSaoFlag[0]) || (compIdx>0 && saoParam->bSaoFlag[1]))3295 {3296 copySaoUnit(&saoParam->saoLcuParam[compIdx][addr], &mergeSaoParam[compIdx][mergeUp] );3297 }3298 }3299 }3300 }3301 }3302 #if SAO_ENCODING_CHOICE3303 #if SAO_ENCODING_CHOICE_CHROMA3304 if( saoParam->saoLcuParam[0][addr].typeIdx == -1)3305 {3306 numNoSao[0]++;3307 }3308 if( saoParam->saoLcuParam[1][addr].typeIdx == -1)3309 {3310 numNoSao[1]+=2;3311 }3312 #else3313 for ( compIdx=0;compIdx<3;compIdx++)3314 {3315 if( depth == 0 && saoParam->saoLcuParam[compIdx][addr].typeIdx == -1)3316 {3317 numNoSao++;3318 }3319 }3320 #endif3321 #endif3322 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);3323 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_CURR_BEST]);3324 }3325 }3326 }3327 #if SAO_ENCODING_CHOICE3328 #if SAO_ENCODING_CHOICE_CHROMA3329 if( !saoParam->bSaoFlag[0])3330 {3331 m_depthSaoRate[0][depth] = 1.0;3332 }3333 else3334 {3335 m_depthSaoRate[0][depth] = numNoSao[0]/((Double) frameHeightInCU*frameWidthInCU);3336 }3337 if( !saoParam->bSaoFlag[1])3338 {3339 m_depthSaoRate[1][depth] = 1.0;3340 }3341 else3342 {3343 m_depthSaoRate[1][depth] = numNoSao[1]/((Double) frameHeightInCU*frameWidthInCU*2);3344 }3345 #else3346 if( depth == 0)3347 {3348 // update SAO Rate3349 m_depth0SaoRate = numNoSao/((Double) frameHeightInCU*frameWidthInCU*3);3350 }3351 #endif3352 #endif3353 3354 }3355 /** rate distortion optimization of SAO unit3356 * \param saoParam SAO parameters3357 * \param addr address3358 * \param addrUp above address3359 * \param addrLeft left address3360 * \param yCbCr color component index3361 * \param lambda3362 */3363 inline Int64 TEncSampleAdaptiveOffset::estSaoTypeDist(Int compIdx, Int typeIdx, Int shift, Double lambda, Int *currentDistortionTableBo, Double *currentRdCostTableBo)3364 {3365 Int64 estDist = 0;3366 Int classIdx;3367 Int bitDepth = (compIdx==0) ? g_bitDepthY : g_bitDepthC;3368 Int saoBitIncrease = (compIdx==0) ? m_uiSaoBitIncreaseY : m_uiSaoBitIncreaseC;3369 Int saoOffsetTh = (compIdx==0) ? m_iOffsetThY : m_iOffsetThC;3370 3371 for(classIdx=1; classIdx < ( (typeIdx < SAO_BO) ? m_iNumClass[typeIdx]+1 : SAO_MAX_BO_CLASSES+1); classIdx++)3372 {3373 if( typeIdx == SAO_BO)3374 {3375 currentDistortionTableBo[classIdx-1] = 0;3376 currentRdCostTableBo[classIdx-1] = lambda;3377 }3378 if(m_iCount [compIdx][typeIdx][classIdx])3379 {3380 m_iOffset[compIdx][typeIdx][classIdx] = (Int64) xRoundIbdi(bitDepth, (Double)(m_iOffsetOrg[compIdx][typeIdx][classIdx]<<(bitDepth-8)) / (Double)(m_iCount [compIdx][typeIdx][classIdx]<<saoBitIncrease));3381 m_iOffset[compIdx][typeIdx][classIdx] = Clip3(-saoOffsetTh+1, saoOffsetTh-1, (Int)m_iOffset[compIdx][typeIdx][classIdx]);3382 if (typeIdx < 4)3383 {3384 if ( m_iOffset[compIdx][typeIdx][classIdx]<0 && classIdx<3 )3385 {3386 m_iOffset[compIdx][typeIdx][classIdx] = 0;3387 }3388 if ( m_iOffset[compIdx][typeIdx][classIdx]>0 && classIdx>=3)3389 {3390 m_iOffset[compIdx][typeIdx][classIdx] = 0;3391 }3392 }3393 m_iOffset[compIdx][typeIdx][classIdx] = estIterOffset( typeIdx, classIdx, lambda, m_iOffset[compIdx][typeIdx][classIdx], m_iCount [compIdx][typeIdx][classIdx], m_iOffsetOrg[compIdx][typeIdx][classIdx], shift, saoBitIncrease, currentDistortionTableBo, currentRdCostTableBo, saoOffsetTh );3394 }3395 else3396 {3397 m_iOffsetOrg[compIdx][typeIdx][classIdx] = 0;3398 m_iOffset[compIdx][typeIdx][classIdx] = 0;3399 }3400 if( typeIdx != SAO_BO )3401 {3402 estDist += estSaoDist( m_iCount [compIdx][typeIdx][classIdx], m_iOffset[compIdx][typeIdx][classIdx] << saoBitIncrease, m_iOffsetOrg[compIdx][typeIdx][classIdx], shift);3403 }3404 3405 }3406 return estDist;3407 }3408 3409 inline Int64 TEncSampleAdaptiveOffset::estSaoDist(Int64 count, Int64 offset, Int64 offsetOrg, Int shift)3410 {3411 return (( count*offset*offset-offsetOrg*offset*2 ) >> shift);3412 }3413 inline Int64 TEncSampleAdaptiveOffset::estIterOffset(Int typeIdx, Int classIdx, Double lambda, Int64 offsetInput, Int64 count, Int64 offsetOrg, Int shift, Int bitIncrease, Int *currentDistortionTableBo, Double *currentRdCostTableBo, Int offsetTh )3414 {3415 //Clean up, best_q_offset.3416 Int64 iterOffset, tempOffset;3417 Int64 tempDist, tempRate;3418 Double tempCost, tempMinCost;3419 Int64 offsetOutput = 0;3420 iterOffset = offsetInput;3421 // Assuming sending quantized value 0 results in zero offset and sending the value zero needs 1 bit. entropy coder can be used to measure the exact rate here.3422 tempMinCost = lambda;3423 while (iterOffset != 0)3424 {3425 // Calculate the bits required for signalling the offset3426 tempRate = (typeIdx == SAO_BO) ? (abs((Int)iterOffset)+2) : (abs((Int)iterOffset)+1);3427 if (abs((Int)iterOffset)==offsetTh-1)3428 {3429 tempRate --;3430 }3431 // Do the dequntization before distorion calculation3432 tempOffset = iterOffset << bitIncrease;3433 tempDist = estSaoDist( count, tempOffset, offsetOrg, shift);3434 tempCost = ((Double)tempDist + lambda * (Double) tempRate);3435 if(tempCost < tempMinCost)3436 {3437 tempMinCost = tempCost;3438 offsetOutput = iterOffset;3439 if(typeIdx == SAO_BO)3440 {3441 currentDistortionTableBo[classIdx-1] = (Int) tempDist;3442 currentRdCostTableBo[classIdx-1] = tempCost;3443 }3444 }3445 iterOffset = (iterOffset > 0) ? (iterOffset-1):(iterOffset+1);3446 }3447 return offsetOutput;3448 }3449 3450 3451 Void TEncSampleAdaptiveOffset::saoComponentParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda, SaoLcuParam *compSaoParam, Double *compDistortion)3452 {3453 Int typeIdx;3454 3455 Int64 estDist;3456 Int classIdx;3457 Int shift = 2 * DISTORTION_PRECISION_ADJUSTMENT(((yCbCr==0)?g_bitDepthY:g_bitDepthC)-8);3458 Int64 bestDist;3459 3460 SaoLcuParam* saoLcuParam = &(saoParam->saoLcuParam[yCbCr][addr]);3461 SaoLcuParam* saoLcuParamNeighbor = NULL;3462 3463 resetSaoUnit(saoLcuParam);3464 resetSaoUnit(&compSaoParam[0]);3465 resetSaoUnit(&compSaoParam[1]);3466 3467 3468 Double dCostPartBest = MAX_DOUBLE;3469 3470 Double bestRDCostTableBo = MAX_DOUBLE;3471 Int bestClassTableBo = 0;3472 Int currentDistortionTableBo[MAX_NUM_SAO_CLASS];3473 Double currentRdCostTableBo[MAX_NUM_SAO_CLASS];3474 3475 3476 SaoLcuParam saoLcuParamRdo;3477 Double estRate = 0;3478 3479 resetSaoUnit(&saoLcuParamRdo);3480 3481 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);3482 m_pcRDGoOnSbacCoder->resetBits();3483 m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo, yCbCr);3484 3485 dCostPartBest = m_pcEntropyCoder->getNumberOfWrittenBits()*lambda ;3486 copySaoUnit(saoLcuParam, &saoLcuParamRdo );3487 bestDist = 0;3488 3489 3490 3491 for (typeIdx=0; typeIdx<MAX_NUM_SAO_TYPE; typeIdx++)3492 {3493 estDist = estSaoTypeDist(yCbCr, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo);3494 3495 if( typeIdx == SAO_BO )3496 {3497 // Estimate Best Position3498 Double currentRDCost = 0.0;3499 3500 for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++)3501 {3502 currentRDCost = 0.0;3503 for(UInt uj = i; uj < i+SAO_BO_LEN; uj++)3504 {3505 currentRDCost += currentRdCostTableBo[uj];3506 }3507 3508 if( currentRDCost < bestRDCostTableBo)3509 {3510 bestRDCostTableBo = currentRDCost;3511 bestClassTableBo = i;3512 }3513 }3514 3515 // Re code all Offsets3516 // Code Center3517 estDist = 0;3518 for(classIdx = bestClassTableBo; classIdx < bestClassTableBo+SAO_BO_LEN; classIdx++)3519 {3520 estDist += currentDistortionTableBo[classIdx];3521 }3522 }3523 resetSaoUnit(&saoLcuParamRdo);3524 saoLcuParamRdo.length = m_iNumClass[typeIdx];3525 saoLcuParamRdo.typeIdx = typeIdx;3526 saoLcuParamRdo.mergeLeftFlag = 0;3527 saoLcuParamRdo.mergeUpFlag = 0;3528 saoLcuParamRdo.subTypeIdx = (typeIdx == SAO_BO) ? bestClassTableBo : 0;3529 for (classIdx = 0; classIdx < saoLcuParamRdo.length; classIdx++)3530 {3531 saoLcuParamRdo.offset[classIdx] = (Int)m_iOffset[yCbCr][typeIdx][classIdx+saoLcuParamRdo.subTypeIdx+1];3532 }3533 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);3534 m_pcRDGoOnSbacCoder->resetBits();3535 m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo, yCbCr);3536 3537 estRate = m_pcEntropyCoder->getNumberOfWrittenBits();3538 m_dCost[yCbCr][typeIdx] = (Double)((Double)estDist + lambda * (Double) estRate);3539 3540 if(m_dCost[yCbCr][typeIdx] < dCostPartBest)3541 {3542 dCostPartBest = m_dCost[yCbCr][typeIdx];3543 copySaoUnit(saoLcuParam, &saoLcuParamRdo );3544 bestDist = estDist;3545 }3546 }3547 compDistortion[0] += ((Double)bestDist/lambda);3548 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);3549 m_pcEntropyCoder->encodeSaoOffset(saoLcuParam, yCbCr);3550 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_TEMP_BEST] );3551 3552 3553 // merge left or merge up3554 3555 for (Int idxNeighbor=0;idxNeighbor<2;idxNeighbor++)3556 {3557 saoLcuParamNeighbor = NULL;3558 if (allowMergeLeft && addrLeft>=0 && idxNeighbor ==0)3559 {3560 saoLcuParamNeighbor = &(saoParam->saoLcuParam[yCbCr][addrLeft]);3561 }3562 else if (allowMergeUp && addrUp>=0 && idxNeighbor ==1)3563 {3564 saoLcuParamNeighbor = &(saoParam->saoLcuParam[yCbCr][addrUp]);3565 }3566 if (saoLcuParamNeighbor!=NULL)3567 {3568 estDist = 0;3569 typeIdx = saoLcuParamNeighbor->typeIdx;3570 if (typeIdx>=0)3571 {3572 Int mergeBandPosition = (typeIdx == SAO_BO)?saoLcuParamNeighbor->subTypeIdx:0;3573 Int merge_iOffset;3574 for(classIdx = 0; classIdx < m_iNumClass[typeIdx]; classIdx++)3575 {3576 merge_iOffset = saoLcuParamNeighbor->offset[classIdx];3577 estDist += estSaoDist(m_iCount [yCbCr][typeIdx][classIdx+mergeBandPosition+1], merge_iOffset, m_iOffsetOrg[yCbCr][typeIdx][classIdx+mergeBandPosition+1], shift);3578 }3579 }3580 else3581 {3582 estDist = 0;3583 }3584 3585 copySaoUnit(&compSaoParam[idxNeighbor], saoLcuParamNeighbor );3586 compSaoParam[idxNeighbor].mergeUpFlag = idxNeighbor;3587 compSaoParam[idxNeighbor].mergeLeftFlag = !idxNeighbor;3588 3589 compDistortion[idxNeighbor+1] += ((Double)estDist/lambda);3590 }3591 }3592 }3593 Void TEncSampleAdaptiveOffset::sao2ChromaParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Double lambda, SaoLcuParam *crSaoParam, SaoLcuParam *cbSaoParam, Double *distortion)3594 {3595 Int typeIdx;3596 3597 Int64 estDist[2];3598 Int classIdx;3599 Int shift = 2 * DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthC-8);3600 Int64 bestDist = 0;3601 3602 SaoLcuParam* saoLcuParam[2] = {&(saoParam->saoLcuParam[1][addr]), &(saoParam->saoLcuParam[2][addr])};3603 SaoLcuParam* saoLcuParamNeighbor[2] = {NULL, NULL};3604 SaoLcuParam* saoMergeParam[2][2];3605 saoMergeParam[0][0] = &crSaoParam[0];3606 saoMergeParam[0][1] = &crSaoParam[1];3607 saoMergeParam[1][0] = &cbSaoParam[0];3608 saoMergeParam[1][1] = &cbSaoParam[1];3609 3610 resetSaoUnit(saoLcuParam[0]);3611 resetSaoUnit(saoLcuParam[1]);3612 resetSaoUnit(saoMergeParam[0][0]);3613 resetSaoUnit(saoMergeParam[0][1]);3614 resetSaoUnit(saoMergeParam[1][0]);3615 resetSaoUnit(saoMergeParam[1][1]);3616 3617 3618 Double costPartBest = MAX_DOUBLE;3619 3620 Double bestRDCostTableBo;3621 Int bestClassTableBo[2] = {0, 0};3622 Int currentDistortionTableBo[MAX_NUM_SAO_CLASS];3623 Double currentRdCostTableBo[MAX_NUM_SAO_CLASS];3624 3625 SaoLcuParam saoLcuParamRdo[2];3626 Double estRate = 0;3627 3628 resetSaoUnit(&saoLcuParamRdo[0]);3629 resetSaoUnit(&saoLcuParamRdo[1]);3630 3631 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);3632 m_pcRDGoOnSbacCoder->resetBits();3633 m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo[0], 1);3634 m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo[1], 2);3635 3636 costPartBest = m_pcEntropyCoder->getNumberOfWrittenBits()*lambda ;3637 copySaoUnit(saoLcuParam[0], &saoLcuParamRdo[0] );3638 copySaoUnit(saoLcuParam[1], &saoLcuParamRdo[1] );3639 3640 for (typeIdx=0; typeIdx<MAX_NUM_SAO_TYPE; typeIdx++)3641 {3642 if( typeIdx == SAO_BO )3643 {3644 // Estimate Best Position3645 for(Int compIdx = 0; compIdx < 2; compIdx++)3646 {3647 Double currentRDCost = 0.0;3648 bestRDCostTableBo = MAX_DOUBLE;3649 estDist[compIdx] = estSaoTypeDist(compIdx+1, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo);3650 for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++)3651 {3652 currentRDCost = 0.0;3653 for(UInt uj = i; uj < i+SAO_BO_LEN; uj++)3654 {3655 currentRDCost += currentRdCostTableBo[uj];3656 }3657 3658 if( currentRDCost < bestRDCostTableBo)3659 {3660 bestRDCostTableBo = currentRDCost;3661 bestClassTableBo[compIdx] = i;3662 }3663 }3664 3665 // Re code all Offsets3666 // Code Center3667 estDist[compIdx] = 0;3668 for(classIdx = bestClassTableBo[compIdx]; classIdx < bestClassTableBo[compIdx]+SAO_BO_LEN; classIdx++)3669 {3670 estDist[compIdx] += currentDistortionTableBo[classIdx];3671 }3672 }3673 }3674 else3675 {3676 estDist[0] = estSaoTypeDist(1, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo);3677 estDist[1] = estSaoTypeDist(2, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo);3678 }3679 3680 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);3681 m_pcRDGoOnSbacCoder->resetBits();3682 3683 for(Int compIdx = 0; compIdx < 2; compIdx++)3684 {3685 resetSaoUnit(&saoLcuParamRdo[compIdx]);3686 saoLcuParamRdo[compIdx].length = m_iNumClass[typeIdx];3687 saoLcuParamRdo[compIdx].typeIdx = typeIdx;3688 saoLcuParamRdo[compIdx].mergeLeftFlag = 0;3689 saoLcuParamRdo[compIdx].mergeUpFlag = 0;3690 saoLcuParamRdo[compIdx].subTypeIdx = (typeIdx == SAO_BO) ? bestClassTableBo[compIdx] : 0;3691 for (classIdx = 0; classIdx < saoLcuParamRdo[compIdx].length; classIdx++)3692 {3693 saoLcuParamRdo[compIdx].offset[classIdx] = (Int)m_iOffset[compIdx+1][typeIdx][classIdx+saoLcuParamRdo[compIdx].subTypeIdx+1];3694 }3695 3696 m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo[compIdx], compIdx+1);3697 }3698 estRate = m_pcEntropyCoder->getNumberOfWrittenBits();3699 m_dCost[1][typeIdx] = (Double)((Double)(estDist[0] + estDist[1]) + lambda * (Double) estRate);3700 3701 if(m_dCost[1][typeIdx] < costPartBest)3702 {3703 costPartBest = m_dCost[1][typeIdx];3704 copySaoUnit(saoLcuParam[0], &saoLcuParamRdo[0] );3705 copySaoUnit(saoLcuParam[1], &saoLcuParamRdo[1] );3706 bestDist = (estDist[0]+estDist[1]);3707 }3708 }3709 3710 distortion[0] += ((Double)bestDist/lambda);3711 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);3712 m_pcEntropyCoder->encodeSaoOffset(saoLcuParam[0], 1);3713 m_pcEntropyCoder->encodeSaoOffset(saoLcuParam[1], 2);3714 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_TEMP_BEST] );3715 3716 // merge left or merge up3717 3718 for (Int idxNeighbor=0;idxNeighbor<2;idxNeighbor++)3719 {3720 for(Int compIdx = 0; compIdx < 2; compIdx++)3721 {3722 saoLcuParamNeighbor[compIdx] = NULL;3723 if (allowMergeLeft && addrLeft>=0 && idxNeighbor ==0)3724 {3725 saoLcuParamNeighbor[compIdx] = &(saoParam->saoLcuParam[compIdx+1][addrLeft]);3726 }3727 else if (allowMergeUp && addrUp>=0 && idxNeighbor ==1)3728 {3729 saoLcuParamNeighbor[compIdx] = &(saoParam->saoLcuParam[compIdx+1][addrUp]);3730 }3731 if (saoLcuParamNeighbor[compIdx]!=NULL)3732 {3733 estDist[compIdx] = 0;3734 typeIdx = saoLcuParamNeighbor[compIdx]->typeIdx;3735 if (typeIdx>=0)3736 {3737 Int mergeBandPosition = (typeIdx == SAO_BO)?saoLcuParamNeighbor[compIdx]->subTypeIdx:0;3738 Int merge_iOffset;3739 for(classIdx = 0; classIdx < m_iNumClass[typeIdx]; classIdx++)3740 {3741 merge_iOffset = saoLcuParamNeighbor[compIdx]->offset[classIdx];3742 estDist[compIdx] += estSaoDist(m_iCount [compIdx+1][typeIdx][classIdx+mergeBandPosition+1], merge_iOffset, m_iOffsetOrg[compIdx+1][typeIdx][classIdx+mergeBandPosition+1], shift);3743 }3744 }3745 else3746 {3747 estDist[compIdx] = 0;3748 }3749 3750 copySaoUnit(saoMergeParam[compIdx][idxNeighbor], saoLcuParamNeighbor[compIdx] );3751 saoMergeParam[compIdx][idxNeighbor]->mergeUpFlag = idxNeighbor;3752 saoMergeParam[compIdx][idxNeighbor]->mergeLeftFlag = !idxNeighbor;3753 distortion[idxNeighbor+1] += ((Double)estDist[compIdx]/lambda);3754 }3755 }3756 }3757 }3758 3759 #endif3760 3761 1315 //! \} -
trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 54 54 // ==================================================================================================================== 55 55 56 #if HM_CLEANUP_SAO57 56 enum SAOCabacStateLablesRDO //CABAC state labels 58 57 { … … 146 145 TEncSbac* m_pcRDGoOnSbacCoder; 147 146 TEncBinCABACCounter** m_pppcBinCoderCABAC; 148 Double m_la bmda[NUM_SAO_COMPONENTS];147 Double m_lambda[NUM_SAO_COMPONENTS]; 149 148 150 149 //statistics … … 159 158 Int m_skipLinesB[NUM_SAO_COMPONENTS][NUM_SAO_NEW_TYPES]; 160 159 }; 161 #else162 163 164 class TEncSampleAdaptiveOffset : public TComSampleAdaptiveOffset165 {166 private:167 TEncEntropy* m_pcEntropyCoder;168 TEncSbac*** m_pppcRDSbacCoder; ///< for CABAC169 TEncSbac* m_pcRDGoOnSbacCoder;170 #if FAST_BIT_EST171 TEncBinCABACCounter*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation172 #else173 TEncBinCABAC*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation174 #endif175 176 Int64 ***m_iCount; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];177 Int64 ***m_iOffset; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];178 Int64 ***m_iOffsetOrg; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];179 Int64 ****m_count_PreDblk; //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];180 Int64 ****m_offsetOrg_PreDblk; //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];181 Int64 **m_iRate; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];182 Int64 **m_iDist; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];183 Double **m_dCost; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];184 Double *m_dCostPartBest; //[MAX_NUM_SAO_PART];185 Int64 *m_iDistOrg; //[MAX_NUM_SAO_PART];186 Int *m_iTypePartBest; //[MAX_NUM_SAO_PART];187 Int m_iOffsetThY;188 Int m_iOffsetThC;189 Bool m_bUseSBACRD;190 #if SAO_ENCODING_CHOICE191 #if SAO_ENCODING_CHOICE_CHROMA192 Double m_depthSaoRate[2][4];193 #else194 Double m_depth0SaoRate;195 #endif196 #endif197 198 public:199 TEncSampleAdaptiveOffset ();200 virtual ~TEncSampleAdaptiveOffset();201 202 Void startSaoEnc( TComPic* pcPic, TEncEntropy* pcEntropyCoder, TEncSbac*** pppcRDSbacCoder, TEncSbac* pcRDGoOnSbacCoder);203 Void endSaoEnc();204 Void resetStats();205 #if SAO_ENCODING_CHOICE206 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma, Int depth);207 #else208 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma);209 #endif210 211 Void runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda, Int yCbCr);212 Void rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda, Int yCbCr);213 214 Void disablePartTree(SAOQTPart *psQTPart, Int iPartIdx);215 Void getSaoStats(SAOQTPart *psQTPart, Int iYCbCr);216 Void calcSaoStatsCu(Int iAddr, Int iPartIdx, Int iYCbCr);217 Void calcSaoStatsBlock( Pel* pRecStart, Pel* pOrgStart, Int stride, Int64** ppStats, Int64** ppCount, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr);218 Void calcSaoStatsCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr);219 Void calcSaoStatsCu_BeforeDblk( TComPic* pcPic );220 Void destroyEncBuffer();221 Void createEncBuffer();222 Void assignSaoUnitSyntax(SaoLcuParam* saoLcuParam, SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr);223 Void checkMerge(SaoLcuParam * lcuParamCurr,SaoLcuParam * lcuParamCheck, Int dir);224 #if SAO_ENCODING_CHOICE225 Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth);226 #else227 Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma);228 #endif229 Void saoComponentParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda, SaoLcuParam *compSaoParam, Double *distortion);230 Void sao2ChromaParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Double lambda, SaoLcuParam *crSaoParam, SaoLcuParam *cbSaoParam, Double *distortion);231 inline Int64 estSaoDist(Int64 count, Int64 offset, Int64 offsetOrg, Int shift);232 inline Int64 estIterOffset(Int typeIdx, Int classIdx, Double lambda, Int64 offsetInput, Int64 count, Int64 offsetOrg, Int shift, Int bitIncrease, Int *currentDistortionTableBo, Double *currentRdCostTableBo, Int offsetTh );233 inline Int64 estSaoTypeDist(Int compIdx, Int typeIdx, Int shift, Double lambda, Int *currentDistortionTableBo, Double *currentRdCostTableBo);234 Void setMaxNumOffsetsPerPic(Int iVal) {m_maxNumOffsetsPerPic = iVal; }235 Int getMaxNumOffsetsPerPic() {return m_maxNumOffsetsPerPic; }236 };237 #endif238 160 //! \} 239 161 -
trunk/source/Lib/TLibEncoder/TEncSbac.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 78 78 , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 79 79 , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 80 , m_cCUAMPSCModel ( 1, 1, NUM_CU_AMP_CTX , m_contextModels + m_numContextModels, m_numContextModels)81 80 , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 82 81 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 112 111 m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT); 113 112 m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); 114 m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );115 113 m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); 116 114 m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); … … 166 164 curCost += m_cCUMergeIdxExtSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT); 167 165 curCost += m_cCUPartSizeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_PART_SIZE ); 168 curCost += m_cCUAMPSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_CU_AMP_POS );169 166 curCost += m_cCUPredModeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_PRED_MODE ); 170 167 curCost += m_cCUIntraPredSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); … … 215 212 m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT); 216 213 m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); 217 m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );218 214 m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); 219 215 m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); … … 442 438 if (eSize == SIZE_2NxN) 443 439 { 444 m_pcBinIf->encodeBin(1, m_cCU AMPSCModel.get( 0, 0, 0));440 m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 445 441 } 446 442 else 447 443 { 448 m_pcBinIf->encodeBin(0, m_cCU AMPSCModel.get( 0, 0, 0 ));444 m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 449 445 m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1)); 450 446 } … … 466 462 if (eSize == SIZE_Nx2N) 467 463 { 468 m_pcBinIf->encodeBin(1, m_cCU AMPSCModel.get( 0, 0, 0));464 m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 469 465 } 470 466 else 471 467 { 472 m_pcBinIf->encodeBin(0, m_cCU AMPSCModel.get( 0, 0, 0));468 m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 473 469 m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1)); 474 470 } … … 1393 1389 { 1394 1390 m_pcBinIf->encodeBin( 1, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); 1395 #if HM_CLEANUP_SAO1396 1391 m_pcBinIf->encodeBinEP( uiCode == 1 ? 0 : 1 ); 1397 #else1398 m_pcBinIf->encodeBinEP( uiCode <= 4 ? 1 : 0 );1399 #endif1400 1392 } 1401 1393 } … … 1600 1592 } 1601 1593 1602 #if HM_CLEANUP_SAO1603 1594 Void TEncSbac::codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled) 1604 1595 { … … 1713 1704 } 1714 1705 } 1715 #endif1716 1706 1717 1707 //! \} -
trunk/source/Lib/TLibEncoder/TEncSbac.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 104 104 Void codeScalingList ( TComScalingList* /*scalingList*/ ){ assert (0); return;}; 105 105 106 #if HM_CLEANUP_SAO107 106 Void codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled); 108 107 Void codeSAOBlkParam(SAOBlkParam& saoBlkParam … … 112 111 , Bool onlyEstMergeInfo = false 113 112 ); 114 #endif115 113 116 114 private: … … 208 206 ContextModel3DBuffer m_cMVPIdxSCModel; 209 207 210 ContextModel3DBuffer m_cCUAMPSCModel;211 208 ContextModel3DBuffer m_cSaoMergeSCModel; 212 209 ContextModel3DBuffer m_cSaoTypeIdxSCModel; -
trunk/source/Lib/TLibEncoder/TEncSearch.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 199 199 m_pppcRDSbacCoder = pppcRDSbacCoder; 200 200 m_pcRDGoOnSbacCoder = pcRDGoOnSbacCoder; 201 202 m_bUseSBACRD = pppcRDSbacCoder ? true : false;203 201 204 202 for (Int iDir = 0; iDir < 2; iDir++) … … 1125 1123 { 1126 1124 Int scalingListType = 0 + g_eTTable[(Int)TEXT_LUMA]; 1127 assert(scalingListType < 6);1125 assert(scalingListType < SCALING_LIST_NUM); 1128 1126 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); 1129 1127 } … … 1318 1316 { 1319 1317 Int scalingListType = 0 + g_eTTable[(Int)eText]; 1320 assert(scalingListType < 6);1318 assert(scalingListType < SCALING_LIST_NUM); 1321 1319 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); 1322 1320 } … … 1424 1422 checkTransformSkip &= (widthTransformSkip == 4 && heightTransformSkip == 4); 1425 1423 checkTransformSkip &= (!pcCU->getCUTransquantBypass(0)); 1426 checkTransformSkip &= (!((pcCU->getQP( 0 ) == 0) && (pcCU->getSlice()->getSPS()->getUseLossless())));1427 1424 if ( m_pcEncCfg->getUseTransformSkipFast() ) 1428 1425 { … … 1434 1431 { 1435 1432 //----- store original entropy coding status ----- 1436 if( m_bUseSBACRD) 1437 { 1438 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 1439 } 1433 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 1434 1440 1435 UInt singleDistYTmp = 0; 1441 1436 UInt singleDistCTmp = 0; … … 1503 1498 { 1504 1499 xStoreIntraResultQT(pcCU, uiTrDepth, uiAbsPartIdx,bLumaOnly ); 1505 if( m_bUseSBACRD) 1506 { 1507 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 1508 } 1500 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 1509 1501 } 1510 1502 } … … 1529 1521 } 1530 1522 } 1531 if(m_bUseSBACRD) 1532 { 1533 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 1534 } 1535 } 1523 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 1524 } 1536 1525 1537 1526 if( !bLumaOnly ) … … 1558 1547 pcCU ->setTransformSkipSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiFullDepth ); 1559 1548 //----- store original entropy coding status ----- 1560 if( m_bUseSBACRD &&bCheckSplit )1549 if( bCheckSplit ) 1561 1550 { 1562 1551 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); … … 1595 1584 { 1596 1585 //----- store full entropy coding status, load original entropy coding status ----- 1597 if( m_bUseSBACRD ) 1598 { 1599 if( bCheckFull ) 1600 { 1601 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_TEST ] ); 1602 m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 1603 } 1604 else 1605 { 1606 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 1607 } 1608 } 1586 if( bCheckFull ) 1587 { 1588 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_TEST ] ); 1589 m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 1590 } 1591 else 1592 { 1593 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 1594 } 1595 1609 1596 //----- code splitted block ----- 1610 1597 Double dSplitCost = 0.0; … … 1647 1634 } 1648 1635 //----- restore context states ----- 1649 if( m_bUseSBACRD ) 1650 { 1651 m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 1652 } 1636 m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 1637 1653 1638 //----- determine rate and r-d cost ----- 1654 1639 UInt uiSplitBits = xGetIntraBitsQT( pcCU, uiTrDepth, uiAbsPartIdx, true, !bLumaOnly, false ); … … 1665 1650 } 1666 1651 //----- set entropy coding status ----- 1667 if( m_bUseSBACRD ) 1668 { 1669 m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_TEST ] ); 1670 } 1671 1652 m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_TEST ] ); 1653 1672 1654 //--- set transform index and Cbf values --- 1673 1655 pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiFullDepth ); … … 2194 2176 { 2195 2177 //use RDO to decide whether Cr/Cb takes TS 2196 if( m_bUseSBACRD ) 2197 { 2198 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[uiFullDepth][CI_QT_TRAFO_ROOT] ); 2199 } 2178 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[uiFullDepth][CI_QT_TRAFO_ROOT] ); 2200 2179 2201 2180 for(Int chromaId = 0; chromaId < 2; chromaId ++) … … 2239 2218 2240 2219 if(singleCostTmp < dSingleCost) 2220 { 2221 dSingleCost = singleCostTmp; 2222 singleDistC = singleDistCTmp; 2223 bestModeId = chromaModeId; 2224 singleCbfC = singleCbfCTmp; 2225 2226 if(bestModeId == firstCheckId) 2241 2227 { 2242 dSingleCost = singleCostTmp; 2243 singleDistC = singleDistCTmp; 2244 bestModeId = chromaModeId; 2245 singleCbfC = singleCbfCTmp; 2246 2247 if(bestModeId == firstCheckId) 2248 { 2249 xStoreIntraResultChromaQT(pcCU, uiTrDepth, uiAbsPartIdx,chromaId); 2250 if( m_bUseSBACRD) 2251 { 2252 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 2253 } 2254 } 2255 } 2256 if(chromaModeId == firstCheckId) 2257 { 2258 m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 2228 xStoreIntraResultChromaQT(pcCU, uiTrDepth, uiAbsPartIdx,chromaId); 2229 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 2259 2230 } 2260 2231 } 2261 2262 if(bestModeId == firstCheckId) 2232 if(chromaModeId == firstCheckId) 2263 2233 { 2264 xLoadIntraResultChromaQT(pcCU, uiTrDepth, uiAbsPartIdx,chromaId); 2265 pcCU->setCbfSubParts ( singleCbfC << uiTrDepth, (TextType)(chromaId + 2), uiAbsPartIdx, pcCU->getDepth(0) + actualTrDepth ); 2266 if(m_bUseSBACRD) 2267 { 2268 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 2269 } 2234 m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 2270 2235 } 2271 pcCU ->setTransformSkipSubParts( bestModeId, (TextType)(chromaId + 2), uiAbsPartIdx, pcCU->getDepth( 0 ) + actualTrDepth ); 2272 ruiDist += singleDistC; 2273 2274 if(chromaId == 0) 2275 { 2276 if( m_bUseSBACRD ) 2277 { 2278 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[uiFullDepth][CI_QT_TRAFO_ROOT] ); 2279 } 2280 } 2281 } 2236 } 2237 2238 if(bestModeId == firstCheckId) 2239 { 2240 xLoadIntraResultChromaQT(pcCU, uiTrDepth, uiAbsPartIdx,chromaId); 2241 pcCU->setCbfSubParts ( singleCbfC << uiTrDepth, (TextType)(chromaId + 2), uiAbsPartIdx, pcCU->getDepth(0) + actualTrDepth ); 2242 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 2243 } 2244 pcCU ->setTransformSkipSubParts( bestModeId, (TextType)(chromaId + 2), uiAbsPartIdx, pcCU->getDepth( 0 ) + actualTrDepth ); 2245 ruiDist += singleDistC; 2246 2247 if(chromaId == 0) 2248 { 2249 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[uiFullDepth][CI_QT_TRAFO_ROOT] ); 2250 } 2251 } 2282 2252 } 2283 2253 else … … 2575 2545 2576 2546 // set context models 2577 if( m_bUseSBACRD ) 2578 { 2579 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 2580 } 2547 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 2581 2548 2582 2549 // determine residual for partition … … 2640 2607 2641 2608 // set context models 2642 if( m_bUseSBACRD ) 2643 { 2644 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 2645 } 2609 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 2646 2610 2647 2611 // determine residual for partition … … 2770 2734 2771 2735 //===== reset context models ===== 2772 if(m_bUseSBACRD) 2773 { 2774 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 2775 } 2736 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 2776 2737 2777 2738 //===== set distortion (rate and r-d costs are determined later) ===== … … 2805 2766 { 2806 2767 //----- restore context models ----- 2807 if( m_bUseSBACRD ) 2808 { 2809 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 2810 } 2768 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 2811 2769 2812 2770 //----- chroma coding ----- … … 2814 2772 pcCU->setChromIntraDirSubParts ( uiModeList[uiMode], 0, uiDepth ); 2815 2773 xRecurIntraChromaCodingQT ( pcCU, 0, 0, pcOrgYuv, pcPredYuv, pcResiYuv, uiDist ); 2816 if( m_bUseSBACRD &&pcCU->getSlice()->getPPS()->getUseTransformSkip() )2774 if( pcCU->getSlice()->getPPS()->getUseTransformSkip() ) 2817 2775 { 2818 2776 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); … … 2846 2804 2847 2805 //----- restore context models ----- 2848 if( m_bUseSBACRD ) 2849 { 2850 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 2851 } 2806 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 2852 2807 } 2853 2808 … … 3005 2960 dCost = m_pcRdCost->calcRdCost( uiBits, uiDistortion ); 3006 2961 3007 if(m_bUseSBACRD) 3008 { 3009 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 3010 } 2962 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 3011 2963 3012 2964 pcCU->getTotalBits() = uiBits; … … 4574 4526 + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(), rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(), pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_V ); 4575 4527 4576 if( m_bUseSBACRD ) 4577 { 4578 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST]); 4579 } 4528 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST]); 4580 4529 4581 4530 m_pcEntropyCoder->resetBits(); … … 4592 4541 pcCU->getTotalCost() = m_pcRdCost->calcRdCost( uiBits, uiDistortion ); 4593 4542 4594 if( m_bUseSBACRD ) 4595 { 4596 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_TEMP_BEST]); 4597 } 4543 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_TEMP_BEST]); 4598 4544 4599 4545 pcCU->setCbfSubParts( 0, 0, 0, 0, pcCU->getDepth( 0 ) ); … … 4631 4577 uiBits = 0; 4632 4578 uiDistortion = 0; 4633 if( m_bUseSBACRD ) 4634 { 4635 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_CURR_BEST ] ); 4636 } 4579 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_CURR_BEST ] ); 4637 4580 4638 4581 UInt uiZeroDistortion = 0; … … 4668 4611 } 4669 4612 4670 if( m_bUseSBACRD ) 4671 { 4672 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] ); 4673 } 4613 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] ); 4674 4614 #if 0 // check 4675 4615 { … … 4677 4617 m_pcEntropyCoder->encodeCoeff( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0) ); 4678 4618 const UInt uiBitsForCoeff = m_pcEntropyCoder->getNumberOfWrittenBits(); 4679 if( m_bUseSBACRD ) 4680 { 4681 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] ); 4682 } 4619 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] ); 4683 4620 if( uiBitsForCoeff != uiBits ) 4684 4621 assert( 0 ); … … 4729 4666 dCostBest = dCost; 4730 4667 qpBest = qp; 4731 if( m_bUseSBACRD ) 4732 { 4733 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] ); 4734 } 4668 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] ); 4735 4669 } 4736 4670 } … … 4740 4674 if( qpMin != qpMax && qpBest != qpMax ) 4741 4675 { 4742 if( m_bUseSBACRD ) 4743 { 4744 assert( 0 ); // check 4745 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] ); 4746 } 4676 assert( 0 ); // check 4677 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] ); 4678 4747 4679 // copy best cbf and trIdx to pcCU 4748 4680 const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (pcCU->getDepth(0) << 1); … … 4824 4756 UInt uiBestTransformMode[3] = {0}; 4825 4757 4826 if( m_bUseSBACRD ) 4827 { 4828 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 4829 } 4758 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 4830 4759 4831 4760 if( bCheckFull ) … … 4965 4894 4966 4895 Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA]; 4967 assert(scalingListType < 6);4896 assert(scalingListType < SCALING_LIST_NUM); 4968 4897 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only 4969 4898 … … 5038 4967 5039 4968 Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_U]; 5040 assert(scalingListType < 6);4969 assert(scalingListType < SCALING_LIST_NUM); 5041 4970 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrU, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrU, trWidthC, trHeightC, scalingListType ); 5042 4971 … … 5108 5037 5109 5038 Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_V]; 5110 assert(scalingListType < 6);5039 assert(scalingListType < SCALING_LIST_NUM); 5111 5040 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrV, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrV, trWidthC, trHeightC, scalingListType ); 5112 5041 … … 5192 5121 } 5193 5122 5194 if( m_bUseSBACRD ) 5195 { 5196 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5197 } 5123 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5198 5124 5199 5125 pcCU->setTransformSkipSubParts ( 1, TEXT_LUMA, uiAbsPartIdx, uiDepth ); … … 5234 5160 5235 5161 Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA]; 5236 assert(scalingListType < 6);5162 assert(scalingListType < SCALING_LIST_NUM); 5237 5163 5238 5164 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcCoeffCurrY, trWidth, trHeight, scalingListType, true ); … … 5292 5218 } 5293 5219 5294 if( m_bUseSBACRD ) 5295 { 5296 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5297 } 5220 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5298 5221 5299 5222 pcCU->setTransformSkipSubParts ( 1, TEXT_CHROMA_U, uiAbsPartIdx, pcCU->getDepth(0)+uiTrModeC ); … … 5345 5268 5346 5269 Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_U]; 5347 assert(scalingListType < 6);5270 assert(scalingListType < SCALING_LIST_NUM); 5348 5271 5349 5272 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrU, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrU, trWidthC, trHeightC, scalingListType, true ); … … 5387 5310 5388 5311 Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_V]; 5389 assert(scalingListType < 6);5312 assert(scalingListType < SCALING_LIST_NUM); 5390 5313 5391 5314 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrV, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrV, trWidthC, trHeightC, scalingListType, true ); … … 5423 5346 } 5424 5347 5425 if( m_bUseSBACRD ) 5426 { 5427 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5428 } 5429 5348 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5430 5349 m_pcEntropyCoder->resetBits(); 5431 5350 … … 5460 5379 if( bCheckSplit ) 5461 5380 { 5462 if( m_bUseSBACRD &&bCheckFull )5381 if( bCheckFull ) 5463 5382 { 5464 5383 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_TEST ] ); … … 5492 5411 } 5493 5412 5494 if( m_bUseSBACRD ) 5495 { 5496 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5497 } 5413 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5498 5414 m_pcEntropyCoder->resetBits(); 5499 5415 … … 5523 5439 } 5524 5440 assert( bCheckFull ); 5525 if( m_bUseSBACRD ) 5526 { 5527 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_TEST ] ); 5528 } 5441 5442 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_TEST ] ); 5529 5443 } 5530 5444 rdCost += dSingleCost; … … 5717 5631 UInt TEncSearch::xModeBitsIntra( TComDataCU* pcCU, UInt uiMode, UInt uiPU, UInt uiPartOffset, UInt uiDepth, UInt uiInitTrDepth ) 5718 5632 { 5719 if( m_bUseSBACRD ) 5720 { 5721 // Reload only contexts required for coding intra mode information 5722 m_pcRDGoOnSbacCoder->loadIntraDirModeLuma( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 5723 } 5633 // Reload only contexts required for coding intra mode information 5634 m_pcRDGoOnSbacCoder->loadIntraDirModeLuma( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 5724 5635 5725 5636 pcCU->setLumaIntraDirSubParts ( uiMode, uiPartOffset, uiDepth + uiInitTrDepth ); … … 6037 5948 } 6038 5949 5950 #if SVC_EXTENSION 6039 5951 #if REF_IDX_ME_ZEROMV 6040 5952 Void TEncSearch::xPatternSearchFracDIFMv0(TComDataCU* pcCU, … … 6205 6117 } 6206 6118 #endif 6119 #endif //SVC_EXTENSION 6207 6120 6208 6121 //! \} -
trunk/source/Lib/TLibEncoder/TEncSearch.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 97 97 TEncCfg* m_pcEncCfg; 98 98 99 #if SVC_EXTENSION100 TEncTop** m_ppcTEncTop;101 #endif102 103 99 // interface to classes 104 100 TComTrQuant* m_pcTrQuant; … … 118 114 TEncSbac*** m_pppcRDSbacCoder; 119 115 TEncSbac* m_pcRDGoOnSbacCoder; 120 Bool m_bUseSBACRD;121 116 DistParam m_cDistParam; 122 117 … … 130 125 UInt m_auiMVPIdxCost[AMVP_MAX_NUM_CANDS+1][AMVP_MAX_NUM_CANDS+1]; //th array bounds 131 126 127 #if SVC_EXTENSION 128 TEncTop** m_ppcTEncTop; 132 129 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 133 130 Bool m_disableILP; 134 131 #endif 132 #endif //SVC_EXTENAION 135 133 136 134 public: … … 207 205 ); 208 206 209 #if (ENCODER_FAST_MODE)210 Bool predInterSearchILRUni ( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId );211 #endif212 213 207 /// encode residual and compute rd-cost for inter mode 214 208 Void encodeResAndCalcRdInterCU( TComDataCU* pcCU, … … 226 220 Void IPCMSearch (TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv ); 227 221 222 #if SVC_EXTENSION 223 #if (ENCODER_FAST_MODE) 224 Bool predInterSearchILRUni ( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId ); 225 #endif 228 226 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 229 227 Void setDisableILP(Bool a) {m_disableILP = a;} 230 228 #endif 229 #endif //SVC_EXTENSION 231 230 232 231 protected: … … 453 452 ,Bool biPred 454 453 ); 454 455 Void xExtDIFUpSamplingH( TComPattern* pcPattern, Bool biPred ); 456 Void xExtDIFUpSamplingQ( TComPattern* pcPatternKey, TComMv halfPelRef, Bool biPred ); 457 458 // ------------------------------------------------------------------------------------------------------------------- 459 // T & Q & Q-1 & T-1 460 // ------------------------------------------------------------------------------------------------------------------- 461 462 Void xEncodeResidualQT( TComDataCU* pcCU, UInt uiAbsPartIdx, const UInt uiDepth, Bool bSubdivAndCbf, TextType eType ); 463 Void xEstimateResidualQT( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx, UInt absTUPartIdx,TComYuv* pcResi, const UInt uiDepth, Double &rdCost, UInt &ruiBits, UInt &ruiDist, UInt *puiZeroDist ); 464 Void xSetResidualQTData( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx,UInt absTUPartIdx, TComYuv* pcResi, UInt uiDepth, Bool bSpatial ); 465 466 UInt xModeBitsIntra ( TComDataCU* pcCU, UInt uiMode, UInt uiPU, UInt uiPartOffset, UInt uiDepth, UInt uiInitTrDepth ); 467 UInt xUpdateCandList( UInt uiMode, Double uiCost, UInt uiFastCandNum, UInt * CandModeList, Double * CandCostList ); 468 469 // ------------------------------------------------------------------------------------------------------------------- 470 // compute symbol bits 471 // ------------------------------------------------------------------------------------------------------------------- 472 473 Void xAddSymbolBitsInter ( TComDataCU* pcCU, 474 UInt uiQp, 475 UInt uiTrMode, 476 UInt& ruiBits, 477 TComYuv*& rpcYuvRec, 478 TComYuv* pcYuvPred, 479 TComYuv*& rpcYuvResi ); 480 481 Void setWpScalingDistParam( TComDataCU* pcCU, Int iRefIdx, RefPicList eRefPicListCur ); 482 inline Void setDistParamComp( UInt uiComp ) { m_cDistParam.uiComp = uiComp; } 483 484 #if SVC_EXTENSION 455 485 #if REF_IDX_ME_ZEROMV 456 486 Void xPatternSearchFracDIFMv0 ( TComDataCU* pcCU, … … 464 494 Bool biPred ); 465 495 #endif 466 Void xExtDIFUpSamplingH( TComPattern* pcPattern, Bool biPred ); 467 Void xExtDIFUpSamplingQ( TComPattern* pcPatternKey, TComMv halfPelRef, Bool biPred ); 468 469 // ------------------------------------------------------------------------------------------------------------------- 470 // T & Q & Q-1 & T-1 471 // ------------------------------------------------------------------------------------------------------------------- 472 473 Void xEncodeResidualQT( TComDataCU* pcCU, UInt uiAbsPartIdx, const UInt uiDepth, Bool bSubdivAndCbf, TextType eType ); 474 Void xEstimateResidualQT( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx, UInt absTUPartIdx,TComYuv* pcResi, const UInt uiDepth, Double &rdCost, UInt &ruiBits, UInt &ruiDist, UInt *puiZeroDist ); 475 Void xSetResidualQTData( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx,UInt absTUPartIdx, TComYuv* pcResi, UInt uiDepth, Bool bSpatial ); 476 477 UInt xModeBitsIntra ( TComDataCU* pcCU, UInt uiMode, UInt uiPU, UInt uiPartOffset, UInt uiDepth, UInt uiInitTrDepth ); 478 UInt xUpdateCandList( UInt uiMode, Double uiCost, UInt uiFastCandNum, UInt * CandModeList, Double * CandCostList ); 479 480 // ------------------------------------------------------------------------------------------------------------------- 481 // compute symbol bits 482 // ------------------------------------------------------------------------------------------------------------------- 483 484 Void xAddSymbolBitsInter ( TComDataCU* pcCU, 485 UInt uiQp, 486 UInt uiTrMode, 487 UInt& ruiBits, 488 TComYuv*& rpcYuvRec, 489 TComYuv* pcYuvPred, 490 TComYuv*& rpcYuvResi ); 491 492 Void setWpScalingDistParam( TComDataCU* pcCU, Int iRefIdx, RefPicList eRefPicListCur ); 493 inline Void setDistParamComp( UInt uiComp ) { m_cDistParam.uiComp = uiComp; } 494 496 #endif //SVC_EXTENSION 497 495 498 };// END CLASS DEFINITION TEncSearch 496 499 -
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 254 254 255 255 eSliceType=B_SLICE; 256 eSliceType = (pocLast == 0 || pocCurr% m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;256 eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType; 257 257 258 258 rpcSlice->setSliceType ( eSliceType ); … … 280 280 { 281 281 #if REPN_FORMAT_IN_VPS 282 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->get SPS()->getUseLossless())))282 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->getPPS()->getTransquantBypassEnableFlag()))) 283 283 #else 284 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->get SPS()->getUseLossless())))284 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getPPS()->getTransquantBypassEnableFlag()))) 285 285 #endif 286 286 { … … 423 423 #if HB_LAMBDA_FOR_LDC 424 424 // restore original slice type 425 eSliceType = (pocLast == 0 || pocCurr% m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;425 eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType; 426 426 427 427 #if SVC_EXTENSION … … 785 785 786 786 // set entropy coder 787 if( m_pcCfg->getUseSBACRD() ) 788 { 789 m_pcSbacCoder->init( m_pcBinCABAC ); 790 m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice ); 791 m_pcEntropyCoder->resetEntropy (); 792 m_pppcRDSbacCoder[0][CI_CURR_BEST]->load(m_pcSbacCoder); 793 pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf(); 794 pppcRDSbacCoder->setBinCountingEnableFlag( false ); 795 pppcRDSbacCoder->setBinsCoded( 0 ); 796 } 797 else 798 { 799 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice ); 800 m_pcEntropyCoder->resetEntropy (); 801 m_pcEntropyCoder->setBitstream ( m_pcBitCounter ); 802 } 803 787 m_pcSbacCoder->init( m_pcBinCABAC ); 788 m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice ); 789 m_pcEntropyCoder->resetEntropy (); 790 m_pppcRDSbacCoder[0][CI_CURR_BEST]->load(m_pcSbacCoder); 791 pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf(); 792 pppcRDSbacCoder->setBinCountingEnableFlag( false ); 793 pppcRDSbacCoder->setBinsCoded( 0 ); 794 804 795 //------------------------------------------------------------------------------ 805 796 // Weighted Prediction parameters estimation. … … 854 845 UInt uiTilesAcross = 0; 855 846 856 if( m_pcCfg->getUseSBACRD() ) 857 { 858 iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); 859 uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1; 860 delete[] m_pcBufferSbacCoders; 861 delete[] m_pcBufferBinCoderCABACs; 862 m_pcBufferSbacCoders = new TEncSbac [uiTilesAcross]; 863 m_pcBufferBinCoderCABACs = new TEncBinCABAC[uiTilesAcross]; 864 for (Int ui = 0; ui < uiTilesAcross; ui++) 865 { 866 m_pcBufferSbacCoders[ui].init( &m_pcBufferBinCoderCABACs[ui] ); 867 } 868 for (UInt ui = 0; ui < uiTilesAcross; ui++) 869 { 870 m_pcBufferSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); //init. state 871 } 872 873 for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) //init all sbac coders for RD optimization 874 { 875 ppppcRDSbacCoders[ui][0][CI_CURR_BEST]->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); 876 } 877 } 878 //if( m_pcCfg->getUseSBACRD() ) 879 { 880 delete[] m_pcBufferLowLatSbacCoders; 881 delete[] m_pcBufferLowLatBinCoderCABACs; 882 m_pcBufferLowLatSbacCoders = new TEncSbac [uiTilesAcross]; 883 m_pcBufferLowLatBinCoderCABACs = new TEncBinCABAC[uiTilesAcross]; 884 for (Int ui = 0; ui < uiTilesAcross; ui++) 885 { 886 m_pcBufferLowLatSbacCoders[ui].init( &m_pcBufferLowLatBinCoderCABACs[ui] ); 887 } 888 for (UInt ui = 0; ui < uiTilesAcross; ui++) 889 m_pcBufferLowLatSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); //init. state 890 } 847 iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); 848 uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1; 849 delete[] m_pcBufferSbacCoders; 850 delete[] m_pcBufferBinCoderCABACs; 851 m_pcBufferSbacCoders = new TEncSbac [uiTilesAcross]; 852 m_pcBufferBinCoderCABACs = new TEncBinCABAC[uiTilesAcross]; 853 for (Int ui = 0; ui < uiTilesAcross; ui++) 854 { 855 m_pcBufferSbacCoders[ui].init( &m_pcBufferBinCoderCABACs[ui] ); 856 } 857 for (UInt ui = 0; ui < uiTilesAcross; ui++) 858 { 859 m_pcBufferSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); //init. state 860 } 861 862 for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) //init all sbac coders for RD optimization 863 { 864 ppppcRDSbacCoders[ui][0][CI_CURR_BEST]->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); 865 } 866 867 delete[] m_pcBufferLowLatSbacCoders; 868 delete[] m_pcBufferLowLatBinCoderCABACs; 869 m_pcBufferLowLatSbacCoders = new TEncSbac [uiTilesAcross]; 870 m_pcBufferLowLatBinCoderCABACs = new TEncBinCABAC[uiTilesAcross]; 871 for (Int ui = 0; ui < uiTilesAcross; ui++) 872 { 873 m_pcBufferLowLatSbacCoders[ui].init( &m_pcBufferLowLatBinCoderCABACs[ui] ); 874 } 875 for (UInt ui = 0; ui < uiTilesAcross; ui++) 876 m_pcBufferLowLatSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); //init. state 877 891 878 UInt uiWidthInLCUs = rpcPic->getPicSym()->getFrameWidthInCU(); 892 879 //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU(); … … 944 931 945 932 // inherit from TR if necessary, select substream to use. 946 if( m_pcCfg->getUseSBACRD() ) 947 { 948 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in? 949 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); 950 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 951 //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr(); 952 uiCol = uiCUAddr % uiWidthInLCUs; 953 uiLin = uiCUAddr / uiWidthInLCUs; 954 if (pcSlice->getPPS()->getNumSubstreams() > 1) 955 { 956 // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. 957 Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); 958 uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)*iNumSubstreamsPerTile 959 + uiLin%iNumSubstreamsPerTile; 933 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in? 934 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); 935 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 936 //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr(); 937 uiCol = uiCUAddr % uiWidthInLCUs; 938 uiLin = uiCUAddr / uiWidthInLCUs; 939 if (pcSlice->getPPS()->getNumSubstreams() > 1) 940 { 941 // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. 942 Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); 943 uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)*iNumSubstreamsPerTile 944 + uiLin%iNumSubstreamsPerTile; 945 } 946 else 947 { 948 // dependent tiles => substreams are "per frame". 949 uiSubStrm = uiLin % iNumSubstreams; 950 } 951 if ( ((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 952 { 953 // We'll sync if the TR is available. 954 TComDataCU *pcCUUp = pcCU->getCUAbove(); 955 UInt uiWidthInCU = rpcPic->getFrameWidthInCU(); 956 UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1); 957 TComDataCU *pcCUTR = NULL; 958 if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU) ) 959 { 960 pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 ); 961 } 962 if ( ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 963 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) || 964 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))) 965 ) 966 ) 967 { 968 // TR not available. 960 969 } 961 970 else 962 971 { 963 // dependent tiles => substreams are "per frame". 964 uiSubStrm = uiLin % iNumSubstreams; 965 } 966 if ( ((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 967 { 968 // We'll sync if the TR is available. 969 TComDataCU *pcCUUp = pcCU->getCUAbove(); 970 UInt uiWidthInCU = rpcPic->getFrameWidthInCU(); 971 UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1); 972 TComDataCU *pcCUTR = NULL; 973 if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU) ) 974 { 975 pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 ); 976 } 977 if ( ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 978 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) || 979 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))) 980 ) 981 ) 982 { 983 // TR not available. 984 } 985 else 986 { 987 // TR is available, we use it. 988 ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->loadContexts( &m_pcBufferSbacCoders[uiTileCol] ); 989 } 990 } 991 m_pppcRDSbacCoder[0][CI_CURR_BEST]->load( ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST] ); //this load is used to simplify the code 992 } 972 // TR is available, we use it. 973 ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->loadContexts( &m_pcBufferSbacCoders[uiTileCol] ); 974 } 975 } 976 m_pppcRDSbacCoder[0][CI_CURR_BEST]->load( ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST] ); //this load is used to simplify the code 993 977 994 978 // reset the entropy coder … … 1008 992 m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice ); 1009 993 } 1010 // if RD based on SBAC is used 1011 if( m_pcCfg->getUseSBACRD() ) 1012 { 1013 // set go-on entropy coder 1014 m_pcEntropyCoder->setEntropyCoder ( m_pcRDGoOnSbacCoder, pcSlice ); 1015 m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] ); 1016 1017 ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true); 1018 1019 Double oldLambda = m_pcRdCost->getLambda(); 1020 if ( m_pcCfg->getUseRateCtrl() ) 1021 { 1022 Int estQP = pcSlice->getSliceQp(); 1023 Double estLambda = -1.0; 1024 Double bpp = -1.0; 1025 1026 if ( ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE && m_pcCfg->getForceIntraQP() ) || !m_pcCfg->getLCULevelRC() ) 994 995 // set go-on entropy coder 996 m_pcEntropyCoder->setEntropyCoder ( m_pcRDGoOnSbacCoder, pcSlice ); 997 m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] ); 998 999 ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true); 1000 1001 Double oldLambda = m_pcRdCost->getLambda(); 1002 if ( m_pcCfg->getUseRateCtrl() ) 1003 { 1004 Int estQP = pcSlice->getSliceQp(); 1005 Double estLambda = -1.0; 1006 Double bpp = -1.0; 1007 1008 if ( ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE && m_pcCfg->getForceIntraQP() ) || !m_pcCfg->getLCULevelRC() ) 1009 { 1010 estQP = pcSlice->getSliceQp(); 1011 } 1012 else 1013 { 1014 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType()); 1015 if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE) 1027 1016 { 1028 est QP = pcSlice->getSliceQp();1017 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambdaAndQP(bpp, pcSlice->getSliceQp(), &estQP); 1029 1018 } 1030 1019 else 1031 1020 { 1032 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType()); 1033 if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE) 1034 { 1035 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambdaAndQP(bpp, pcSlice->getSliceQp(), &estQP); 1036 } 1037 else 1038 { 1039 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp ); 1040 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() ); 1041 } 1021 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp ); 1022 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() ); 1023 } 1042 1024 1043 1025 #if REPN_FORMAT_IN_VPS … … 1056 1038 m_pcTrQuant->setLambda( estLambda ); 1057 1039 #endif 1040 } 1041 1042 m_pcRateCtrl->setRCQP( estQP ); 1043 pcCU->getSlice()->setSliceQpBase( estQP ); 1044 } 1045 1046 // run CU encoder 1047 m_pcCuEncoder->compressCU( pcCU ); 1048 1049 // restore entropy coder to an initial stage 1050 m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST], pcSlice ); 1051 m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] ); 1052 m_pcCuEncoder->setBitCounter( &pcBitCounters[uiSubStrm] ); 1053 m_pcBitCounter = &pcBitCounters[uiSubStrm]; 1054 pppcRDSbacCoder->setBinCountingEnableFlag( true ); 1055 m_pcBitCounter->resetBits(); 1056 pppcRDSbacCoder->setBinsCoded( 0 ); 1057 m_pcCuEncoder->encodeCU( pcCU ); 1058 1059 pppcRDSbacCoder->setBinCountingEnableFlag( false ); 1060 if (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_BYTES && ( ( pcSlice->getSliceBits() + m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3) 1061 { 1062 pcSlice->setNextSlice( true ); 1063 break; 1064 } 1065 if (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES && pcSlice->getSliceSegmentBits()+m_pcEntropyCoder->getNumberOfWrittenBits() > (m_pcCfg->getSliceSegmentArgument() << 3) &&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getSliceSegmentCurEndCUAddr()) 1066 { 1067 pcSlice->setNextSliceSegment( true ); 1068 break; 1069 } 1070 1071 ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_CURR_BEST] ); 1072 //Store probabilties of second LCU in line into buffer 1073 if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro()) 1074 { 1075 m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]); 1076 } 1077 1078 if ( m_pcCfg->getUseRateCtrl() ) 1079 { 1080 1081 Int actualQP = g_RCInvalidQPValue; 1082 Double actualLambda = m_pcRdCost->getLambda(); 1083 Int actualBits = pcCU->getTotalBits(); 1084 Int numberOfEffectivePixels = 0; 1085 for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ ) 1086 { 1087 if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) ) 1088 { 1089 numberOfEffectivePixels = numberOfEffectivePixels + 16; 1090 break; 1058 1091 } 1059 1060 m_pcRateCtrl->setRCQP( estQP ); 1061 pcCU->getSlice()->setSliceQpBase( estQP ); 1062 } 1063 1064 // run CU encoder 1065 m_pcCuEncoder->compressCU( pcCU ); 1066 1067 // restore entropy coder to an initial stage 1068 m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST], pcSlice ); 1069 m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] ); 1070 m_pcCuEncoder->setBitCounter( &pcBitCounters[uiSubStrm] ); 1071 m_pcBitCounter = &pcBitCounters[uiSubStrm]; 1072 pppcRDSbacCoder->setBinCountingEnableFlag( true ); 1073 m_pcBitCounter->resetBits(); 1074 pppcRDSbacCoder->setBinsCoded( 0 ); 1075 m_pcCuEncoder->encodeCU( pcCU ); 1076 1077 pppcRDSbacCoder->setBinCountingEnableFlag( false ); 1078 if (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_BYTES && ( ( pcSlice->getSliceBits() + m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3) 1079 { 1080 pcSlice->setNextSlice( true ); 1081 break; 1082 } 1083 if (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES && pcSlice->getSliceSegmentBits()+m_pcEntropyCoder->getNumberOfWrittenBits() > (m_pcCfg->getSliceSegmentArgument() << 3) &&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getSliceSegmentCurEndCUAddr()) 1084 { 1085 pcSlice->setNextSliceSegment( true ); 1086 break; 1087 } 1088 if( m_pcCfg->getUseSBACRD() ) 1089 { 1090 ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_CURR_BEST] ); 1091 1092 //Store probabilties of second LCU in line into buffer 1093 if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro()) 1094 { 1095 m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]); 1096 } 1097 } 1098 1099 if ( m_pcCfg->getUseRateCtrl() ) 1100 { 1101 1102 Int actualQP = g_RCInvalidQPValue; 1103 Double actualLambda = m_pcRdCost->getLambda(); 1104 Int actualBits = pcCU->getTotalBits(); 1105 Int numberOfEffectivePixels = 0; 1106 for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ ) 1107 { 1108 if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) ) 1109 { 1110 numberOfEffectivePixels = numberOfEffectivePixels + 16; 1111 break; 1112 } 1113 } 1114 1115 if ( numberOfEffectivePixels == 0 ) 1116 { 1117 actualQP = g_RCInvalidQPValue; 1118 } 1119 else 1120 { 1121 actualQP = pcCU->getQP( 0 ); 1122 } 1123 m_pcRdCost->setLambda(oldLambda); 1124 1125 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, 1126 pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() ); 1127 } 1128 } 1129 // other case: encodeCU is not called 1130 else 1131 { 1132 m_pcCuEncoder->compressCU( pcCU ); 1133 m_pcCuEncoder->encodeCU( pcCU ); 1134 if (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_BYTES && ( ( pcSlice->getSliceBits()+ m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3) 1135 { 1136 pcSlice->setNextSlice( true ); 1137 break; 1138 } 1139 if (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES && pcSlice->getSliceSegmentBits()+ m_pcEntropyCoder->getNumberOfWrittenBits()> m_pcCfg->getSliceSegmentArgument()<<3 &&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getSliceSegmentCurEndCUAddr()) 1140 { 1141 pcSlice->setNextSliceSegment( true ); 1142 break; 1143 } 1092 } 1093 1094 if ( numberOfEffectivePixels == 0 ) 1095 { 1096 actualQP = g_RCInvalidQPValue; 1097 } 1098 else 1099 { 1100 actualQP = pcCU->getQP( 0 ); 1101 } 1102 m_pcRdCost->setLambda(oldLambda); 1103 1104 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, 1105 pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() ); 1144 1106 } 1145 1107 … … 1151 1113 { 1152 1114 pcSlice->setNextSlice( true ); 1115 } 1116 if(m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_BYTES || m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES) 1117 { 1118 if(pcSlice->getSliceCurEndCUAddr()<=pcSlice->getSliceSegmentCurEndCUAddr()) 1119 { 1120 pcSlice->setNextSlice( true ); 1121 } 1122 else 1123 { 1124 pcSlice->setNextSliceSegment( true ); 1125 } 1153 1126 } 1154 1127 if( depSliceSegmentsEnabled ) … … 1269 1242 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap(++uiEncCUOrder) ) 1270 1243 { 1271 if( m_pcCfg->getUseSBACRD() ) 1272 { 1273 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in? 1274 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); 1275 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 1276 //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr(); 1277 uiCol = uiCUAddr % uiWidthInLCUs; 1278 uiLin = uiCUAddr / uiWidthInLCUs; 1279 if (pcSlice->getPPS()->getNumSubstreams() > 1) 1280 { 1281 // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. 1282 Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); 1283 uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)*iNumSubstreamsPerTile 1284 + uiLin%iNumSubstreamsPerTile; 1244 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in? 1245 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); 1246 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 1247 //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr(); 1248 uiCol = uiCUAddr % uiWidthInLCUs; 1249 uiLin = uiCUAddr / uiWidthInLCUs; 1250 if (pcSlice->getPPS()->getNumSubstreams() > 1) 1251 { 1252 // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. 1253 Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); 1254 uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)*iNumSubstreamsPerTile 1255 + uiLin%iNumSubstreamsPerTile; 1256 } 1257 else 1258 { 1259 // dependent tiles => substreams are "per frame". 1260 uiSubStrm = uiLin % iNumSubstreams; 1261 } 1262 1263 m_pcEntropyCoder->setBitstream( &pcSubstreams[uiSubStrm] ); 1264 // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line. 1265 if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 1266 { 1267 // We'll sync if the TR is available. 1268 TComDataCU *pcCUUp = rpcPic->getCU( uiCUAddr )->getCUAbove(); 1269 UInt uiWidthInCU = rpcPic->getFrameWidthInCU(); 1270 UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1); 1271 TComDataCU *pcCUTR = NULL; 1272 if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU) ) 1273 { 1274 pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 ); 1275 } 1276 if ( (true/*bEnforceSliceRestriction*/ && 1277 ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 1278 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) || 1279 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))) 1280 )) 1281 ) 1282 { 1283 // TR not available. 1285 1284 } 1286 1285 else 1287 1286 { 1288 // dependent tiles => substreams are "per frame". 1289 uiSubStrm = uiLin % iNumSubstreams; 1290 } 1291 1292 m_pcEntropyCoder->setBitstream( &pcSubstreams[uiSubStrm] ); 1293 // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line. 1294 if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 1295 { 1296 // We'll sync if the TR is available. 1297 TComDataCU *pcCUUp = rpcPic->getCU( uiCUAddr )->getCUAbove(); 1298 UInt uiWidthInCU = rpcPic->getFrameWidthInCU(); 1299 UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1); 1300 TComDataCU *pcCUTR = NULL; 1301 if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU) ) 1302 { 1303 pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 ); 1304 } 1305 if ( (true/*bEnforceSliceRestriction*/ && 1306 ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 1307 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) || 1308 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))) 1309 )) 1310 ) 1311 { 1312 // TR not available. 1313 } 1314 else 1315 { 1316 // TR is available, we use it. 1317 pcSbacCoders[uiSubStrm].loadContexts( &m_pcBufferSbacCoders[uiTileCol] ); 1318 } 1319 } 1320 m_pcSbacCoder->load(&pcSbacCoders[uiSubStrm]); //this load is used to simplify the code (avoid to change all the call to m_pcSbacCoder) 1321 } 1287 // TR is available, we use it. 1288 pcSbacCoders[uiSubStrm].loadContexts( &m_pcBufferSbacCoders[uiTileCol] ); 1289 } 1290 } 1291 m_pcSbacCoder->load(&pcSbacCoders[uiSubStrm]); //this load is used to simplify the code (avoid to change all the call to m_pcSbacCoder) 1292 1322 1293 // reset the entropy coder 1323 1294 if( uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr() && // must be first CU of tile … … 1360 1331 1361 1332 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 1362 #if HM_CLEANUP_SAO1363 1333 if ( pcSlice->getSPS()->getUseSAO() ) 1364 1334 { … … 1389 1359 } 1390 1360 } 1391 #else1392 if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) )1393 {1394 SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();1395 Int iNumCuInWidth = saoParam->numCuInWidth;1396 Int iCUAddrInSlice = uiCUAddr - rpcPic->getPicSym()->getCUOrderMap(pcSlice->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU());1397 Int iCUAddrUpInSlice = iCUAddrInSlice - iNumCuInWidth;1398 Int rx = uiCUAddr % iNumCuInWidth;1399 Int ry = uiCUAddr / iNumCuInWidth;1400 Int allowMergeLeft = 1;1401 Int allowMergeUp = 1;1402 if (rx!=0)1403 {1404 if (rpcPic->getPicSym()->getTileIdxMap(uiCUAddr-1) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))1405 {1406 allowMergeLeft = 0;1407 }1408 }1409 if (ry!=0)1410 {1411 if (rpcPic->getPicSym()->getTileIdxMap(uiCUAddr-iNumCuInWidth) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))1412 {1413 allowMergeUp = 0;1414 }1415 }1416 Int addr = pcCU->getAddr();1417 allowMergeLeft = allowMergeLeft && (rx>0) && (iCUAddrInSlice!=0);1418 allowMergeUp = allowMergeUp && (ry>0) && (iCUAddrUpInSlice>=0);1419 if( saoParam->bSaoFlag[0] || saoParam->bSaoFlag[1] )1420 {1421 Int mergeLeft = saoParam->saoLcuParam[0][addr].mergeLeftFlag;1422 Int mergeUp = saoParam->saoLcuParam[0][addr].mergeUpFlag;1423 if (allowMergeLeft)1424 {1425 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeLeft);1426 }1427 else1428 {1429 mergeLeft = 0;1430 }1431 if(mergeLeft == 0)1432 {1433 if (allowMergeUp)1434 {1435 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeUp);1436 }1437 else1438 {1439 mergeUp = 0;1440 }1441 if(mergeUp == 0)1442 {1443 for (Int compIdx=0;compIdx<3;compIdx++)1444 {1445 if( (compIdx == 0 && saoParam->bSaoFlag[0]) || (compIdx > 0 && saoParam->bSaoFlag[1]))1446 {1447 m_pcEntropyCoder->encodeSaoOffset(&saoParam->saoLcuParam[compIdx][addr], compIdx);1448 }1449 }1450 }1451 }1452 }1453 }1454 else if (pcSlice->getSPS()->getUseSAO())1455 {1456 Int addr = pcCU->getAddr();1457 SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();1458 for (Int cIdx=0; cIdx<3; cIdx++)1459 {1460 SaoLcuParam *saoLcuParam = &(saoParam->saoLcuParam[cIdx][addr]);1461 if ( ((cIdx == 0) && !pcSlice->getSaoEnabledFlag()) || ((cIdx == 1 || cIdx == 2) && !pcSlice->getSaoEnabledFlagChroma()))1462 {1463 saoLcuParam->mergeUpFlag = 0;1464 saoLcuParam->mergeLeftFlag = 0;1465 saoLcuParam->subTypeIdx = 0;1466 saoLcuParam->typeIdx = -1;1467 saoLcuParam->offset[0] = 0;1468 saoLcuParam->offset[1] = 0;1469 saoLcuParam->offset[2] = 0;1470 saoLcuParam->offset[3] = 0;1471 }1472 }1473 }1474 #endif1475 1361 1476 1362 #if ENC_DEC_TRACE … … 1489 1375 g_bJustDoIt = g_bEncDecTraceDisable; 1490 1376 #endif 1491 if( m_pcCfg->getUseSBACRD() ) 1492 { 1493 pcSbacCoders[uiSubStrm].load(m_pcSbacCoder); //load back status of the entropy coder after encoding the LCU into relevant bitstream entropy coder 1494 1495 1496 //Store probabilties of second LCU in line into buffer 1497 if ( (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro()) 1498 { 1499 m_pcBufferSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] ); 1500 } 1377 pcSbacCoders[uiSubStrm].load(m_pcSbacCoder); //load back status of the entropy coder after encoding the LCU into relevant bitstream entropy coder 1378 //Store probabilties of second LCU in line into buffer 1379 if ( (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro()) 1380 { 1381 m_pcBufferSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] ); 1501 1382 } 1502 1383 } … … 1870 1751 } 1871 1752 1753 #if SVC_EXTENSION 1872 1754 #if JCTVC_M0259_LAMBDAREFINEMENT 1873 1755 Double TEncSlice::xCalEnhLambdaFactor( Double deltaQP , Double beta ) … … 1888 1770 } 1889 1771 #endif 1772 #endif //SVC_EXTENSION 1890 1773 //! \} -
trunk/source/Lib/TLibEncoder/TEncSlice.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 65 65 // encoder configuration 66 66 TEncCfg* m_pcCfg; ///< encoder configuration class 67 68 #if SVC_EXTENSION69 TEncTop** m_ppcTEncTop;70 #endif71 67 72 68 // pictures … … 107 103 UInt m_uiSliceIdx; 108 104 std::vector<TEncSbac*> CTXMem; 105 106 #if SVC_EXTENSION 107 TEncTop** m_ppcTEncTop; 108 #endif 109 109 110 public: 110 111 TEncSlice(); … … 152 153 Double xGetQPValueAccordingToLambda ( Double lambda ); 153 154 155 #if SVC_EXTENSION 154 156 #if JCTVC_M0259_LAMBDAREFINEMENT 155 private:156 157 Double xCalEnhLambdaFactor( Double deltaQP , Double beta ); 157 158 #endif 159 #endif //SVC_EXTENSION 158 160 }; 159 161 -
trunk/source/Lib/TLibEncoder/TEncTop.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 129 129 if (m_bUseSAO) 130 130 { 131 #if HM_CLEANUP_SAO132 131 #if AUXILIARY_PICTURES 133 132 m_cEncSAO.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); … … 140 139 m_cEncSAO.createEncData(); 141 140 #endif 142 #else143 m_cEncSAO.setSaoLcuBoundary(getSaoLcuBoundary());144 m_cEncSAO.setSaoLcuBasedOptimization(getSaoLcuBasedOptimization());145 m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic());146 m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight );147 m_cEncSAO.createEncBuffer();148 #endif149 141 } 150 142 #if ADAPTIVE_QP_SELECTION … … 161 153 g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList ); 162 154 } 163 // if SBAC-based RD optimization is used 164 if( m_bUseSBACRD ) 165 { 166 m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1]; 155 156 m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1]; 167 157 #if FAST_BIT_EST 168 169 #else 170 171 #endif 172 173 174 175 158 m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1]; 159 #else 160 m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1]; 161 #endif 162 163 for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 164 { 165 m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM]; 176 166 #if FAST_BIT_EST 177 178 #else 179 180 #endif 181 182 183 184 167 m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM]; 168 #else 169 m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM]; 170 #endif 171 172 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 173 { 174 m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac; 185 175 #if FAST_BIT_EST 186 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; 187 #else 188 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; 189 #endif 190 m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); 191 } 176 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; 177 #else 178 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; 179 #endif 180 m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); 192 181 } 193 182 } … … 226 215 m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] ); 227 216 } 228 if( m_bUseSBACRD ) 229 { 230 m_ppppcRDSbacCoders = new TEncSbac*** [iNumSubstreams]; 231 m_ppppcBinCodersCABAC = new TEncBinCABAC***[iNumSubstreams]; 232 for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) 233 { 234 m_ppppcRDSbacCoders[ui] = new TEncSbac** [g_uiMaxCUDepth+1]; 235 m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1]; 236 237 for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 238 { 239 m_ppppcRDSbacCoders[ui][iDepth] = new TEncSbac* [CI_NUM]; 240 m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM]; 241 242 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 243 { 244 m_ppppcRDSbacCoders [ui][iDepth][iCIIdx] = new TEncSbac; 245 m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC; 246 m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] ); 247 } 217 218 m_ppppcRDSbacCoders = new TEncSbac*** [iNumSubstreams]; 219 m_ppppcBinCodersCABAC = new TEncBinCABAC***[iNumSubstreams]; 220 for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) 221 { 222 m_ppppcRDSbacCoders[ui] = new TEncSbac** [g_uiMaxCUDepth+1]; 223 m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1]; 224 225 for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 226 { 227 m_ppppcRDSbacCoders[ui][iDepth] = new TEncSbac* [CI_NUM]; 228 m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM]; 229 230 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 231 { 232 m_ppppcRDSbacCoders [ui][iDepth][iCIIdx] = new TEncSbac; 233 m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC; 234 m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] ); 248 235 } 249 236 } … … 259 246 if (m_cSPS.getUseSAO()) 260 247 { 261 #if HM_CLEANUP_SAO262 248 m_cEncSAO.destroyEncData(); 263 249 m_cEncSAO.destroy(); 264 #else265 m_cEncSAO.destroy();266 m_cEncSAO.destroyEncBuffer();267 #endif268 250 } 269 251 m_cLoopFilter. destroy(); 270 252 m_cRateCtrl. destroy(); 271 // SBAC RD 272 if( m_bUseSBACRD ) 273 { 274 Int iDepth; 253 254 Int iDepth; 255 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 256 { 257 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 258 { 259 delete m_pppcRDSbacCoder[iDepth][iCIIdx]; 260 delete m_pppcBinCoderCABAC[iDepth][iCIIdx]; 261 } 262 } 263 264 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 265 { 266 delete [] m_pppcRDSbacCoder[iDepth]; 267 delete [] m_pppcBinCoderCABAC[iDepth]; 268 } 269 270 delete [] m_pppcRDSbacCoder; 271 delete [] m_pppcBinCoderCABAC; 272 273 for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ ) 274 { 275 275 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 276 276 { 277 277 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 278 278 { 279 delete m_ppp cRDSbacCoder[iDepth][iCIIdx];280 delete m_ppp cBinCoderCABAC[iDepth][iCIIdx];281 } 282 } 283 279 delete m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]; 280 delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx]; 281 } 282 } 283 284 284 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 285 285 { 286 delete [] m_pppcRDSbacCoder[iDepth]; 287 delete [] m_pppcBinCoderCABAC[iDepth]; 288 } 289 290 delete [] m_pppcRDSbacCoder; 291 delete [] m_pppcBinCoderCABAC; 292 293 for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ ) 294 { 295 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 296 { 297 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 298 { 299 delete m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]; 300 delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx]; 301 } 302 } 303 304 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 305 { 306 delete [] m_ppppcRDSbacCoders [ui][iDepth]; 307 delete [] m_ppppcBinCodersCABAC[ui][iDepth]; 308 } 309 delete[] m_ppppcRDSbacCoders [ui]; 310 delete[] m_ppppcBinCodersCABAC[ui]; 311 } 312 delete[] m_ppppcRDSbacCoders; 313 delete[] m_ppppcBinCodersCABAC; 314 } 286 delete [] m_ppppcRDSbacCoders [ui][iDepth]; 287 delete [] m_ppppcBinCodersCABAC[ui][iDepth]; 288 } 289 delete[] m_ppppcRDSbacCoders [ui]; 290 delete[] m_ppppcBinCodersCABAC[ui]; 291 } 292 delete[] m_ppppcRDSbacCoders; 293 delete[] m_ppppcBinCodersCABAC; 315 294 delete[] m_pcSbacCoders; 316 295 delete[] m_pcBinCoderCABACs; … … 525 504 TComPic *pcTopField; 526 505 xGetNewPicBuffer( pcTopField ); 527 #if !HM_CLEANUP_SAO528 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO);529 #endif530 506 pcTopField->setReconMark (false); 531 507 … … 568 544 TComPic* pcBottomField; 569 545 xGetNewPicBuffer( pcBottomField ); 570 #if !HM_CLEANUP_SAO571 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO);572 #endif573 546 pcBottomField->setReconMark (false); 574 547 … … 652 625 TComPic *pcTopField; 653 626 xGetNewPicBuffer( pcTopField ); 654 #if !HM_CLEANUP_SAO655 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO);656 #endif657 627 pcTopField->setReconMark (false); 658 628 … … 706 676 TComPic* pcBottomField; 707 677 xGetNewPicBuffer( pcBottomField ); 708 #if !HM_CLEANUP_SAO709 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO);710 #endif711 678 pcBottomField->setReconMark (false); 712 679 … … 912 879 #endif 913 880 } 914 #if !HM_CLEANUP_SAO915 if (getUseSAO())916 {917 rpcPic->getPicSym()->allocSaoParam(&m_cEncSAO);918 }919 #endif920 881 m_cListPic.pushBack( rpcPic ); 921 882 } … … 1001 962 1002 963 m_cSPS.setTMVPFlagsPresent(false); 1003 m_cSPS.setUseLossless ( m_useLossless );1004 964 1005 965 m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); … … 1038 998 m_cSPS.setMaxTLayers( m_maxTempLayer ); 1039 999 m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false ); 1040 for ( i = 0; i < m _cSPS.getMaxTLayers(); i++ )1000 for ( i = 0; i < min(m_cSPS.getMaxTLayers(),(UInt) MAX_TLAYER); i++ ) 1041 1001 { 1042 1002 m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); … … 1098 1058 Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; 1099 1059 1100 #if REPN_FORMAT_IN_VPS 1101 Int lowestQP; 1102 #if O0096_REP_FORMAT_INDEX 1103 if( m_layerId == 0 ) 1104 { 1105 lowestQP = - m_cSPS.getQpBDOffsetY(); 1106 } 1107 else 1108 { 1109 lowestQP = - (m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_cSPS.getUpdateRepFormatFlag() ? m_cSPS.getUpdateRepFormatIndex() : m_layerId ) )->getBitDepthVpsLuma() - 8) * 6; 1110 } 1111 #else 1112 if( m_layerId == 0 || m_cSPS.getUpdateRepFormatFlag() ) 1113 { 1114 lowestQP = - m_cSPS.getQpBDOffsetY(); 1115 } 1116 else 1117 { 1118 lowestQP = - (m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsLuma() - 8) * 6; 1119 } 1120 #endif 1121 #else 1122 Int lowestQP = - m_cSPS.getQpBDOffsetY(); 1123 #endif 1124 1125 if(getUseLossless()) 1126 { 1127 if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) ) 1128 { 1129 bUseDQP = false; 1130 } 1131 else 1132 { 1133 bUseDQP = true; 1134 } 1135 } 1136 else 1137 { 1138 if(bUseDQP == false) 1139 { 1140 if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) 1141 { 1142 bUseDQP = true; 1143 } 1144 } 1060 if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) 1061 { 1062 bUseDQP = true; 1145 1063 } 1146 1064 -
trunk/source/Lib/TLibEncoder/TEncTop.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 73 73 UInt m_uiNumAllPicCoded; ///< number of coded pictures 74 74 TComList<TComPic*> m_cListPic; ///< dynamic list of pictures 75 #if SVC_EXTENSION 76 static Int m_iSPSIdCnt; ///< next Id number for SPS 77 static Int m_iPPSIdCnt; ///< next Id number for PPS 78 #if AVC_SYNTAX 79 fstream* m_pBLSyntaxFile; 80 #endif 81 #endif 82 75 83 76 // encoder search 84 77 TEncSearch m_cSearch; ///< encoder search class … … 130 123 131 124 #if SVC_EXTENSION 132 125 static Int m_iSPSIdCnt; ///< next Id number for SPS 126 static Int m_iPPSIdCnt; ///< next Id number for PPS 127 #if AVC_SYNTAX 128 fstream* m_pBLSyntaxFile; 129 #endif 133 130 TEncTop** m_ppcTEncTop; 134 131 TEncTop* getLayerEnc(UInt layer) { return m_ppcTEncTop[layer]; } … … 163 160 Void xInitRPS (Bool isFieldCoding); ///< initialize PPS from encoder options 164 161 #if SVC_EXTENSION 165 Void xInitILRP();162 Void xInitILRP(); 166 163 #endif 167 164 public: … … 210 207 Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid ); 211 208 TComScalingList* getScalingList () { return &m_scalingList; } 209 // ------------------------------------------------------------------------------------------------------------------- 210 // encoder function 211 // ------------------------------------------------------------------------------------------------------------------- 212 213 /// encode several number of pictures until end-of-sequence 212 214 #if SVC_EXTENSION 213 215 Void setLayerEnc(TEncTop** p) {m_ppcTEncTop = p;} … … 224 226 #endif 225 227 Window& getScaledRefLayerWindow(Int x) { return m_scaledRefLayerWindow[x]; } 226 #endif //SVC_EXTENSION227 228 // -------------------------------------------------------------------------------------------------------------------229 // encoder function230 // -------------------------------------------------------------------------------------------------------------------231 232 /// encode several number of pictures until end-of-sequence233 #if SVC_EXTENSION234 228 TComPic** getIlpList() { return m_cIlpPic; } 235 229 #if REF_IDX_MFM … … 281 275 282 276 #endif // __TENCTOP__ 277 -
trunk/source/Lib/TLibEncoder/WeightPredAnalysis.cpp
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/WeightPredAnalysis.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 *
Note: See TracChangeset for help on using the changeset viewer.