Changeset 1318 in SHVCSoftware
- Timestamp:
- 21 Jul 2015, 20:19:19 (9 years ago)
- Location:
- branches/SHM-dev/source/Lib/TLibEncoder
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r1310 r1318 2406 2406 pcPic->getSlice(pcSlice->getSliceIdx())->setMvdL1ZeroFlag(pcSlice->getMvdL1ZeroFlag()); 2407 2407 2408 2408 2409 Double lambda = 0.0; 2409 2410 Int actualHeadBits = 0; … … 2411 2412 Int estimatedBits = 0; 2412 2413 Int tmpBitsBeforeWriting = 0; 2413 if ( m_pcCfg->getUseRateCtrl() ) 2414 if ( m_pcCfg->getUseRateCtrl() ) // TODO: does this work with multiple slices and slice-segments? 2414 2415 { 2415 2416 Int frameLevel = m_pcRateCtrl->getRCSeq()->getGOPID2Level( iGOPid ); … … 2438 2439 else if ( frameLevel == 0 ) // intra case, but use the model 2439 2440 { 2440 m_pcSliceEncoder->calCostSliceI(pcPic); 2441 m_pcSliceEncoder->calCostSliceI(pcPic); // TODO: This only analyses the first slice segment - what about the others? 2441 2442 2442 2443 if ( m_pcCfg->getIntraPeriod() != 1 ) // do not refine allocated bits for all intra case … … 2505 2506 { 2506 2507 m_pcSliceEncoder->precompressSlice( pcPic ); 2507 m_pcSliceEncoder->compressSlice ( pcPic );2508 m_pcSliceEncoder->compressSlice ( pcPic, false ); 2508 2509 2509 2510 const UInt curSliceSegmentEnd = pcSlice->getSliceSegmentCurEndCtuTsAddr(); -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp
r1316 r1318 639 639 printf( "\nMultiple QP optimization is not allowed when rate control is enabled." ); 640 640 assert(0); 641 return; 641 642 } 642 643 643 644 TComSlice* pcSlice = pcPic->getSlice(getSliceIdx()); 645 646 if (pcSlice->getDependentSliceSegmentFlag()) 647 { 648 // if this is a dependent slice segment, then it was optimised 649 // when analysing the entire slice. 650 return; 651 } 652 653 if (pcSlice->getSliceMode()==FIXED_NUMBER_OF_BYTES) 654 { 655 // TODO: investigate use of average cost per CTU so that this Slice Mode can be used. 656 printf( "\nUnable to optimise Slice-level QP if Slice Mode is set to FIXED_NUMBER_OF_BYTES\n" ); 657 assert(0); 658 return; 659 } 660 644 661 Double dPicRdCostBest = MAX_DOUBLE; 645 662 UInt uiQpIdxBest = 0; … … 667 684 m_pcRdCost ->setFrameLambda(dFrameLambda); 668 685 669 const UInt initialSliceQp=pcSlice->getSliceQp();670 686 // for each QP candidate 671 687 for ( UInt uiQpIdx = 0; uiQpIdx < 2 * m_pcCfg->getDeltaQpRD() + 1; uiQpIdx++ ) … … 678 694 679 695 // try compress 680 compressSlice ( pcPic ); 681 682 Double dPicRdCost; 683 UInt64 uiPicDist = m_uiPicDist; 684 // TODO: will this work if multiple slices are being used? There may not be any reconstruction data yet. 685 // Will this also be ideal if a byte-restriction is placed on the slice? 686 // - what if the last CTU was sometimes included, sometimes not, and that had all the distortion? 687 m_pcGOPEncoder->preLoopFilterPicAll( pcPic, uiPicDist ); 696 compressSlice ( pcPic, true ); 697 698 UInt64 uiPicDist = m_uiPicDist; // Distortion, as calculated by compressSlice. 699 // NOTE: This distortion is the chroma-weighted SSE distortion for the slice. 700 // Previously a standard SSE distortion was calculated (for the entire frame). 701 // Which is correct? 702 703 // TODO: Update loop filter, SAO and distortion calculation to work on one slice only. 704 // m_pcGOPEncoder->preLoopFilterPicAll( pcPic, uiPicDist ); 688 705 689 706 // compute RD cost and choose the best 690 dPicRdCost = m_pcRdCost->calcRdCost64( m_uiPicTotalBits, uiPicDist, true, DF_SSE_FRAME);707 Double dPicRdCost = m_pcRdCost->calcRdCost64( m_uiPicTotalBits, uiPicDist, true, DF_SSE_FRAME); // NOTE: Is the 'true' parameter really necessary? 691 708 692 709 if ( dPicRdCost < dPicRdCostBest ) … … 697 714 } 698 715 699 if (pcSlice->getDependentSliceSegmentFlag() && initialSliceQp!=m_piRdPicQp[uiQpIdxBest] )700 {701 // TODO: this won't work with dependent slices: they do not have their own QP.702 fprintf(stderr,"ERROR - attempt to change QP for a dependent slice-segment, having already coded the slice\n");703 assert(pcSlice->getDependentSliceSegmentFlag()==false || initialSliceQp==m_piRdPicQp[uiQpIdxBest]);704 }705 716 // set best values 706 717 pcSlice ->setSliceQp ( m_piRdPicQp [uiQpIdxBest] ); … … 711 722 } 712 723 713 Void TEncSlice::calCostSliceI(TComPic* pcPic) 724 Void TEncSlice::calCostSliceI(TComPic* pcPic) // TODO: this only analyses the first slice segment. What about the others? 714 725 { 715 726 Double iSumHadSlice = 0; … … 755 766 /** \param pcPic picture class 756 767 */ 757 Void TEncSlice::compressSlice( TComPic* pcPic ) 758 { 768 Void TEncSlice::compressSlice( TComPic* pcPic, const Bool bCompressEntireSlice ) 769 { 770 // if bCompressEntireSlice is true, then the entire slice (not slice segment) is compressed, 771 // effectively disabling the slice-segment-mode. 772 759 773 UInt startCtuTsAddr; 760 774 UInt boundingCtuTsAddr; … … 762 776 pcSlice->setSliceSegmentBits(0); 763 777 xDetermineStartAndBoundingCtuTsAddr ( startCtuTsAddr, boundingCtuTsAddr, pcPic ); 778 if (bCompressEntireSlice) 779 { 780 boundingCtuTsAddr = pcSlice->getSliceCurEndCtuTsAddr(); 781 pcSlice->setSliceSegmentCurEndCtuTsAddr(boundingCtuTsAddr); 782 } 764 783 765 784 // initialize cost values - these are used by precompressSlice (they should be parameters). … … 817 836 { 818 837 // TODO: this won't work with dependent slices: they do not have their own QP. Check fix to mask clause execution with && !(pcSlice->getDependentSliceSegmentFlag()) 819 m_pcTrQuant->clearSliceARLCnt(); 838 m_pcTrQuant->clearSliceARLCnt(); // TODO: this looks wrong for multiple slices - the results of all but the last slice will be cleared before they are used (all slices compressed, and then all slices encoded) 820 839 if(pcSlice->getSliceType()!=I_SLICE) 821 840 { … … 970 989 boundingCtuTsAddr=validEndOfSliceCtuTsAddr; 971 990 } 972 else if( pcSlice->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES && pcSlice->getSliceSegmentBits()+numberOfWrittenBits > (pcSlice->getSliceSegmentArgument()<<3))991 else if((!bCompressEntireSlice) && pcSlice->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES && pcSlice->getSliceSegmentBits()+numberOfWrittenBits > (pcSlice->getSliceSegmentArgument()<<3)) 973 992 { 974 993 pcSlice->setSliceSegmentCurEndCtuTsAddr(validEndOfSliceCtuTsAddr); … … 1225 1244 if( m_pcCfg->getUseAdaptQpSelect() ) 1226 1245 { 1227 m_pcTrQuant->storeSliceQpNext(pcSlice); 1246 m_pcTrQuant->storeSliceQpNext(pcSlice); // TODO: this will only be storing the adaptive QP state of the very last slice-segment that is not dependent in the frame... Perhaps this should be moved to the compress slice loop. 1228 1247 } 1229 1248 #endif -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.h
r1307 r1318 124 124 Void resetQP ( TComPic* pic, Int sliceQP, Double lambda ); 125 125 // compress and encode slice 126 Void precompressSlice ( TComPic* pcPic ); ///< precompress slice for multi-loop opt.127 Void compressSlice ( TComPic* pcPic 126 Void precompressSlice ( TComPic* pcPic ); ///< precompress slice for multi-loop slice-level QP opt. 127 Void compressSlice ( TComPic* pcPic, const Bool bCompressEntireSlice ); ///< analysis stage of slice 128 128 Void calCostSliceI ( TComPic* pcPic ); 129 129 Void encodeSlice ( TComPic* pcPic, TComOutputBitstream* pcSubstreams, UInt &numBinsCoded );
Note: See TracChangeset for help on using the changeset viewer.