예제 #1
0
func TEncEntropy_countNonZeroCoeffs(pcCoef []TLibCommon.TCoeff, uiSize uint) int {
	count := 0

	for i := uint(0); i < uiSize; i++ {
		count += int(TLibCommon.B2U(pcCoef[i] != 0))
	}

	return count
}
예제 #2
0
func (this *TEncEntropy) encodeSaoUnitInterleaving(compIdx int, saoFlag bool, rx, ry int, saoLcuParam *TLibCommon.SaoLcuParam, cuAddrInSlice, cuAddrUpInSlice int, allowMergeLeft, allowMergeUp bool) {
	if saoFlag {
		if rx > 0 && cuAddrInSlice != 0 && allowMergeLeft {
			this.m_pcEntropyCoderIf.codeSaoMerge(uint(TLibCommon.B2U(saoLcuParam.MergeLeftFlag)))
		} else {
			saoLcuParam.MergeLeftFlag = false
		}
		if saoLcuParam.MergeLeftFlag == false {
			if (ry > 0) && (cuAddrUpInSlice >= 0) && allowMergeUp {
				this.m_pcEntropyCoderIf.codeSaoMerge(uint(TLibCommon.B2U(saoLcuParam.MergeUpFlag)))
			} else {
				saoLcuParam.MergeUpFlag = false
			}
			if saoLcuParam.MergeUpFlag == false {
				this.encodeSaoOffset(saoLcuParam, uint(compIdx))
			}
		}
	}
}
예제 #3
0
파일: TDecTop.go 프로젝트: hanjinze/GoHM
func (this *TDecTop) xActivateParameterSets() {
	this.m_parameterSetManagerDecoder.ApplyPS()

	pps := this.m_parameterSetManagerDecoder.GetPPS(this.m_apcSlicePilot.GetPPSId())
	//assert (pps != 0);

	sps := this.m_parameterSetManagerDecoder.GetSPS(pps.GetSPSId())
	//assert (sps != 0);
	if false == this.m_parameterSetManagerDecoder.ActivatePPS(this.m_apcSlicePilot.GetPPSId(), this.m_apcSlicePilot.GetIdrPicFlag()) {
		fmt.Printf("Parameter set activation failed!")
		//assert (0);
	}

	this.m_apcSlicePilot.SetPPS(pps)
	this.m_apcSlicePilot.SetSPS(sps)
	pps.SetSPS(sps)

	if pps.GetEntropyCodingSyncEnabledFlag() {
		pps.SetNumSubstreams(int((sps.GetPicHeightInLumaSamples()+sps.GetMaxCUHeight()-1)/sps.GetMaxCUHeight()) * (pps.GetNumColumnsMinus1() + 1))
	} else {
		pps.SetNumSubstreams(1)
	}

	pps.SetMinCuDQPSize(sps.GetMaxCUWidth() >> (pps.GetMaxCuDQPDepth()))

	for i := uint(0); i < sps.GetMaxCUDepth()-sps.GetAddCUDepth(); i++ {
		sps.SetAMPAcc(i, int(TLibCommon.B2U(sps.GetUseAMP())))
	}

	for i := sps.GetMaxCUDepth() - sps.GetAddCUDepth(); i < sps.GetMaxCUDepth(); i++ {
		sps.SetAMPAcc(i, 0)
	}

	this.m_cSAO.Destroy()
	this.m_cSAO.Create(sps.GetPicWidthInLumaSamples(), sps.GetPicHeightInLumaSamples(), sps.GetMaxCUWidth(), sps.GetMaxCUHeight())
	this.m_cLoopFilter.Create(sps.GetMaxCUDepth())
}
예제 #4
0
//private:
func (this *TDecEntropy) xDecodeTransform(pcCU *TLibCommon.TComDataCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx uint, bCodeDQP *bool) {
	var uiSubdiv uint
	uiLog2TrafoSize := uint(TLibCommon.G_aucConvertToBit[pcCU.GetSlice().GetSPS().GetMaxCUWidth()]) + 2 - uiDepth

	if uiTrIdx == 0 {
		this.m_bakAbsPartIdxCU = uiAbsPartIdx
	}
	if uiLog2TrafoSize == 2 {
		partNum := pcCU.GetPic().GetNumPartInCU() >> ((uiDepth - 1) << 1)
		if (uiAbsPartIdx % partNum) == 0 {
			this.m_uiBakAbsPartIdx = uiAbsPartIdx
			this.m_uiBakChromaOffset = offsetChroma
		}
	}
	if pcCU.GetPredictionMode1(uiAbsPartIdx) == TLibCommon.MODE_INTRA && pcCU.GetPartitionSize1(uiAbsPartIdx) == TLibCommon.SIZE_NxN && uiDepth == uint(pcCU.GetDepth1(uiAbsPartIdx)) {
		uiSubdiv = 1
	} else if (pcCU.GetSlice().GetSPS().GetQuadtreeTUMaxDepthInter() == 1) && (pcCU.GetPredictionMode1(uiAbsPartIdx) == TLibCommon.MODE_INTER) && (pcCU.GetPartitionSize1(uiAbsPartIdx) != TLibCommon.SIZE_2Nx2N) && (uiDepth == uint(pcCU.GetDepth1(uiAbsPartIdx))) {
		uiSubdiv = uint(TLibCommon.B2U(uiLog2TrafoSize > pcCU.GetQuadtreeTULog2MinSizeInCU(uiAbsPartIdx)))
	} else if uiLog2TrafoSize > pcCU.GetSlice().GetSPS().GetQuadtreeTULog2MaxSize() {
		uiSubdiv = 1
	} else if uiLog2TrafoSize == pcCU.GetSlice().GetSPS().GetQuadtreeTULog2MinSize() {
		uiSubdiv = 0
	} else if uiLog2TrafoSize == pcCU.GetQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) {
		uiSubdiv = 0
	} else {
		//assert( uiLog2TrafoSize > pcCU.GetQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
		this.m_pcEntropyDecoderIf.ParseTransformSubdivFlag(&uiSubdiv, 5-uiLog2TrafoSize)
	}

	uiTrDepth := uiDepth - uint(pcCU.GetDepth1(uiAbsPartIdx))
	{
		bFirstCbfOfCU := uiTrDepth == 0
		if bFirstCbfOfCU {
			pcCU.SetCbfSubParts4(0, TLibCommon.TEXT_CHROMA_U, uiAbsPartIdx, uiDepth)
			pcCU.SetCbfSubParts4(0, TLibCommon.TEXT_CHROMA_V, uiAbsPartIdx, uiDepth)
		}
		if bFirstCbfOfCU || uiLog2TrafoSize > 2 {
			if bFirstCbfOfCU || pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_U, uiTrDepth-1) != 0 {
				this.m_pcEntropyDecoderIf.ParseQtCbf(pcCU, uiAbsPartIdx, TLibCommon.TEXT_CHROMA_U, uiTrDepth, uiDepth)
			}
			if bFirstCbfOfCU || pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_V, uiTrDepth-1) != 0 {
				this.m_pcEntropyDecoderIf.ParseQtCbf(pcCU, uiAbsPartIdx, TLibCommon.TEXT_CHROMA_V, uiTrDepth, uiDepth)
			}
		} else {
			pcCU.SetCbfSubParts4(byte(pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_U, uiTrDepth-1)<<uiTrDepth), TLibCommon.TEXT_CHROMA_U, uiAbsPartIdx, uiDepth)
			pcCU.SetCbfSubParts4(byte(pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_V, uiTrDepth-1)<<uiTrDepth), TLibCommon.TEXT_CHROMA_V, uiAbsPartIdx, uiDepth)
		}
	}

	if uiSubdiv != 0 {
		var size uint
		width >>= 1
		height >>= 1
		size = width * height
		uiTrIdx++
		uiDepth++
		uiQPartNum := pcCU.GetPic().GetNumPartInCU() >> (uiDepth << 1)
		uiStartAbsPartIdx := uiAbsPartIdx
		uiYCbf := uint(0)
		uiUCbf := uint(0)
		uiVCbf := uint(0)

		for i := uint(0); i < 4; i++ {
			this.xDecodeTransform(pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP)
			uiYCbf |= uint(pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_LUMA, uiTrDepth+1))
			uiUCbf |= uint(pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_U, uiTrDepth+1))
			uiVCbf |= uint(pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_V, uiTrDepth+1))
			uiAbsPartIdx += uiQPartNum
			offsetLuma += size
			offsetChroma += (size >> 2)
		}

		for ui := uint(0); ui < 4*uiQPartNum; ui++ {
			pcCU.GetCbf1(TLibCommon.TEXT_LUMA)[uiStartAbsPartIdx+ui] |= byte(uiYCbf << uiTrDepth)
			pcCU.GetCbf1(TLibCommon.TEXT_CHROMA_U)[uiStartAbsPartIdx+ui] |= byte(uiUCbf << uiTrDepth)
			pcCU.GetCbf1(TLibCommon.TEXT_CHROMA_V)[uiStartAbsPartIdx+ui] |= byte(uiVCbf << uiTrDepth)
		}
	} else {
		//assert( uiDepth >= pcCU.GetDepth( uiAbsPartIdx ) );
		pcCU.SetTrIdxSubParts(uiTrDepth, uiAbsPartIdx, uiDepth)

		{
			//DTRACE_CABAC_VL( TLibCommon.G_nSymbolCounter++ );
			/*this.m_pcEntropyDecoderIf.DTRACE_CABAC_T("\tTrIdx: abspart=")
			  this.m_pcEntropyDecoderIf.DTRACE_CABAC_V(uiAbsPartIdx)
			  this.m_pcEntropyDecoderIf.DTRACE_CABAC_T("\tdepth=")
			  this.m_pcEntropyDecoderIf.DTRACE_CABAC_V(uiDepth)
			  this.m_pcEntropyDecoderIf.DTRACE_CABAC_T("\ttrdepth=")
			  this.m_pcEntropyDecoderIf.DTRACE_CABAC_V(uiTrDepth)
			  this.m_pcEntropyDecoderIf.DTRACE_CABAC_T("\n")*/
		}

		pcCU.SetCbfSubParts4(0, TLibCommon.TEXT_LUMA, uiAbsPartIdx, uiDepth)
		if pcCU.GetPredictionMode1(uiAbsPartIdx) != TLibCommon.MODE_INTRA && uiDepth == uint(pcCU.GetDepth1(uiAbsPartIdx)) && pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_U, 0) == 0 && pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_V, 0) == 0 {
			pcCU.SetCbfSubParts4(1<<uiTrDepth, TLibCommon.TEXT_LUMA, uiAbsPartIdx, uiDepth)
		} else {
			this.m_pcEntropyDecoderIf.ParseQtCbf(pcCU, uiAbsPartIdx, TLibCommon.TEXT_LUMA, uiTrDepth, uiDepth)
		}

		// transforthis.m_unit begin
		cbfY := pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_LUMA, uiTrIdx)
		cbfU := pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_U, uiTrIdx)
		cbfV := pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_V, uiTrIdx)
		if uiLog2TrafoSize == 2 {
			partNum := pcCU.GetPic().GetNumPartInCU() >> ((uiDepth - 1) << 1)
			if (uiAbsPartIdx % partNum) == (partNum - 1) {
				cbfU = pcCU.GetCbf3(this.m_uiBakAbsPartIdx, TLibCommon.TEXT_CHROMA_U, uiTrIdx)
				cbfV = pcCU.GetCbf3(this.m_uiBakAbsPartIdx, TLibCommon.TEXT_CHROMA_V, uiTrIdx)
			}
		}
		if cbfY != 0 || cbfU != 0 || cbfV != 0 {
			// dQP: only for LCU
			if pcCU.GetSlice().GetPPS().GetUseDQP() {
				if *bCodeDQP {
					this.DecodeQP(pcCU, this.m_bakAbsPartIdxCU)
					*bCodeDQP = false
				}
			}
		}
		if cbfY != 0 {
			trWidth := width
			trHeight := height
			this.m_pcEntropyDecoderIf.ParseCoeffNxN(pcCU, pcCU.GetCoeffY()[offsetLuma:], uiAbsPartIdx, trWidth, trHeight, uiDepth, TLibCommon.TEXT_LUMA)
		}
		if uiLog2TrafoSize > 2 {
			trWidth := width >> 1
			trHeight := height >> 1
			if cbfU != 0 {
				this.m_pcEntropyDecoderIf.ParseCoeffNxN(pcCU, pcCU.GetCoeffCb()[offsetChroma:], uiAbsPartIdx, trWidth, trHeight, uiDepth, TLibCommon.TEXT_CHROMA_U)
			}
			if cbfV != 0 {
				this.m_pcEntropyDecoderIf.ParseCoeffNxN(pcCU, pcCU.GetCoeffCr()[offsetChroma:], uiAbsPartIdx, trWidth, trHeight, uiDepth, TLibCommon.TEXT_CHROMA_V)
			}
		} else {
			partNum := pcCU.GetPic().GetNumPartInCU() >> ((uiDepth - 1) << 1)
			if (uiAbsPartIdx % partNum) == (partNum - 1) {
				trWidth := width
				trHeight := height
				if cbfU != 0 {
					this.m_pcEntropyDecoderIf.ParseCoeffNxN(pcCU, pcCU.GetCoeffCb()[this.m_uiBakChromaOffset:], this.m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TLibCommon.TEXT_CHROMA_U)
				}
				if cbfV != 0 {
					this.m_pcEntropyDecoderIf.ParseCoeffNxN(pcCU, pcCU.GetCoeffCr()[this.m_uiBakChromaOffset:], this.m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TLibCommon.TEXT_CHROMA_V)
				}
			}
		}
		// transform_unit end
	}
}
예제 #5
0
파일: TEncTop.go 프로젝트: nacore/GoHM
func (this *TEncTop) xInitSPS() { ///< initialize SPS from encoder options
	profileTierLevel := this.m_cSPS.GetPTL().GetGeneralPTL()
	profileTierLevel.SetLevelIdc(int(this.GetEncCfg().m_level))
	profileTierLevel.SetTierFlag(this.GetEncCfg().m_levelTier != 0)
	profileTierLevel.SetProfileIdc(int(this.GetEncCfg().m_profile))
	profileTierLevel.SetProfileCompatibilityFlag(int(this.GetEncCfg().m_profile), true)
	//#if L0046_CONSTRAINT_FLAGS
	profileTierLevel.SetProgressiveSourceFlag(this.GetEncCfg().m_progressiveSourceFlag)
	profileTierLevel.SetInterlacedSourceFlag(this.GetEncCfg().m_interlacedSourceFlag)
	profileTierLevel.SetNonPackedConstraintFlag(this.GetEncCfg().m_nonPackedConstraintFlag)
	profileTierLevel.SetFrameOnlyConstraintFlag(this.GetEncCfg().m_frameOnlyConstraintFlag)
	//#endif

	if this.GetEncCfg().m_profile == TLibCommon.PROFILE_MAIN10 && TLibCommon.G_bitDepthY == 8 && TLibCommon.G_bitDepthC == 8 {
		/* The above constraint is equal to Profile::MAIN */
		profileTierLevel.SetProfileCompatibilityFlag(TLibCommon.PROFILE_MAIN, true)
	}
	if this.GetEncCfg().m_profile == TLibCommon.PROFILE_MAIN {
		/* A Profile::MAIN10 decoder can always decode Profile::MAIN */
		profileTierLevel.SetProfileCompatibilityFlag(TLibCommon.PROFILE_MAIN10, true)
	}
	/* XXX: should Main be marked as compatible with still picture? */
	/* XXX: may be a good idea to refactor the above into a function
	 * that chooses the actual compatibility based upon options */

	this.m_cSPS.SetPicWidthInLumaSamples(uint(this.GetEncCfg().m_iSourceWidth))
	this.m_cSPS.SetPicHeightInLumaSamples(uint(this.GetEncCfg().m_iSourceHeight))
	this.m_cSPS.SetConformanceWindow(this.GetEncCfg().m_conformanceWindow)
	this.m_cSPS.SetMaxCUWidth(TLibCommon.G_uiMaxCUWidth)
	this.m_cSPS.SetMaxCUHeight(TLibCommon.G_uiMaxCUHeight)
	this.m_cSPS.SetMaxCUDepth(TLibCommon.G_uiMaxCUDepth)
	this.m_cSPS.SetMinTrDepth(0)
	this.m_cSPS.SetMaxTrDepth(1)

	this.m_cSPS.SetPCMLog2MinSize(this.GetEncCfg().m_uiPCMLog2MinSize)
	this.m_cSPS.SetUsePCM(this.GetEncCfg().m_usePCM)
	this.m_cSPS.SetPCMLog2MaxSize(this.GetEncCfg().m_pcmLog2MaxSize)

	this.m_cSPS.SetQuadtreeTULog2MaxSize(this.GetEncCfg().m_uiQuadtreeTULog2MaxSize)
	this.m_cSPS.SetQuadtreeTULog2MinSize(this.GetEncCfg().m_uiQuadtreeTULog2MinSize)
	this.m_cSPS.SetQuadtreeTUMaxDepthInter(this.GetEncCfg().m_uiQuadtreeTUMaxDepthInter)
	this.m_cSPS.SetQuadtreeTUMaxDepthIntra(this.GetEncCfg().m_uiQuadtreeTUMaxDepthIntra)

	this.m_cSPS.SetTMVPFlagsPresent(false)
	this.m_cSPS.SetUseLossless(this.GetEncCfg().m_useLossless)

	this.m_cSPS.SetMaxTrSize(1 << this.GetEncCfg().m_uiQuadtreeTULog2MaxSize)

	this.m_cSPS.SetUseLComb(this.GetEncCfg().m_bUseLComb)

	var i uint

	for i = 0; i < TLibCommon.G_uiMaxCUDepth-TLibCommon.G_uiAddCUDepth; i++ {
		this.m_cSPS.SetAMPAcc(i, int(TLibCommon.B2U(this.GetEncCfg().m_useAMP)))
		//this.m_cSPS.setAMPAcc( i, 1 );
	}

	this.m_cSPS.SetUseAMP(this.GetEncCfg().m_useAMP)

	for i = TLibCommon.G_uiMaxCUDepth - TLibCommon.G_uiAddCUDepth; i < TLibCommon.G_uiMaxCUDepth; i++ {
		this.m_cSPS.SetAMPAcc(i, 0)
	}

	this.m_cSPS.SetBitDepthY(TLibCommon.G_bitDepthY)
	this.m_cSPS.SetBitDepthC(TLibCommon.G_bitDepthC)

	this.m_cSPS.SetQpBDOffsetY(6 * (TLibCommon.G_bitDepthY - 8))
	this.m_cSPS.SetQpBDOffsetC(6 * (TLibCommon.G_bitDepthC - 8))

	this.m_cSPS.SetUseSAO(this.GetEncCfg().m_bUseSAO)

	this.m_cSPS.SetMaxTLayers(uint(this.GetEncCfg().m_maxTempLayer))
	this.m_cSPS.SetTemporalIdNestingFlag((this.GetEncCfg().m_maxTempLayer == 1))
	for i = 0; i < this.m_cSPS.GetMaxTLayers(); i++ {
		this.m_cSPS.SetMaxDecPicBuffering(uint(this.GetEncCfg().m_maxDecPicBuffering[i]), i)
		this.m_cSPS.SetNumReorderPics(this.GetEncCfg().m_numReorderPics[i], i)
	}
	this.m_cSPS.SetPCMBitDepthLuma(uint(TLibCommon.G_uiPCMBitDepthLuma))
	this.m_cSPS.SetPCMBitDepthChroma(uint(TLibCommon.G_uiPCMBitDepthChroma))
	this.m_cSPS.SetPCMFilterDisableFlag(this.GetEncCfg().m_bPCMFilterDisableFlag)
	this.m_cSPS.SetScalingListFlag(this.GetEncCfg().m_useScalingListId != 0)
	this.m_cSPS.SetUseStrongIntraSmoothing(this.GetEncCfg().m_useStrongIntraSmoothing)

	this.m_cSPS.SetVuiParametersPresentFlag(this.GetEncCfg().GetVuiParametersPresentFlag())
	if this.m_cSPS.GetVuiParametersPresentFlag() {
		pcVUI := this.m_cSPS.GetVuiParameters()
		pcVUI.SetAspectRatioInfoPresentFlag(this.GetEncCfg().GetAspectRatioIdc() != -1)
		pcVUI.SetAspectRatioIdc(this.GetEncCfg().GetAspectRatioIdc())
		pcVUI.SetSarWidth(this.GetEncCfg().GetSarWidth())
		pcVUI.SetSarHeight(this.GetEncCfg().GetSarHeight())
		pcVUI.SetOverscanInfoPresentFlag(this.GetEncCfg().GetOverscanInfoPresentFlag())
		pcVUI.SetOverscanAppropriateFlag(this.GetEncCfg().GetOverscanAppropriateFlag())
		pcVUI.SetVideoSignalTypePresentFlag(this.GetEncCfg().GetVideoSignalTypePresentFlag())
		pcVUI.SetVideoFormat(this.GetEncCfg().GetVideoFormat())
		pcVUI.SetVideoFullRangeFlag(this.GetEncCfg().GetVideoFullRangeFlag())
		pcVUI.SetColourDescriptionPresentFlag(this.GetEncCfg().GetColourDescriptionPresentFlag())
		pcVUI.SetColourPrimaries(this.GetEncCfg().GetColourPrimaries())
		pcVUI.SetTransferCharacteristics(this.GetEncCfg().GetTransferCharacteristics())
		pcVUI.SetMatrixCoefficients(this.GetEncCfg().GetMatrixCoefficients())
		pcVUI.SetChromaLocInfoPresentFlag(this.GetEncCfg().GetChromaLocInfoPresentFlag())
		pcVUI.SetChromaSampleLocTypeTopField(this.GetEncCfg().GetChromaSampleLocTypeTopField())
		pcVUI.SetChromaSampleLocTypeBottomField(this.GetEncCfg().GetChromaSampleLocTypeBottomField())
		pcVUI.SetNeutralChromaIndicationFlag(this.GetEncCfg().GetNeutralChromaIndicationFlag())
		pcVUI.SetDefaultDisplayWindow(this.GetEncCfg().GetDefaultDisplayWindow())
		pcVUI.SetFrameFieldInfoPresentFlag(this.GetEncCfg().GetFrameFieldInfoPresentFlag())
		pcVUI.SetFieldSeqFlag(false)
		pcVUI.SetHrdParametersPresentFlag(false)
		//#if L0043_TIMING_INFO
		pcVUI.GetTimingInfo().SetPocProportionalToTimingFlag(this.GetEncCfg().GetPocProportionalToTimingFlag())
		pcVUI.GetTimingInfo().SetNumTicksPocDiffOneMinus1(this.GetEncCfg().GetNumTicksPocDiffOneMinus1())
		//#else
		//    pcVUI.SetPocProportionalToTimingFlag(this.GetEncCfg().GetPocProportionalToTimingFlag());
		//    pcVUI.SetNumTicksPocDiffOneMinus1   (this.GetEncCfg().GetNumTicksPocDiffOneMinus1()   );
		//#endif
		pcVUI.SetBitstreamRestrictionFlag(this.GetEncCfg().GetBitstreamRestrictionFlag())
		pcVUI.SetTilesFixedStructureFlag(this.GetEncCfg().GetTilesFixedStructureFlag())
		pcVUI.SetMotionVectorsOverPicBoundariesFlag(this.GetEncCfg().GetMotionVectorsOverPicBoundariesFlag())
		pcVUI.SetMinSpatialSegmentationIdc(this.GetEncCfg().GetMinSpatialSegmentationIdc())
		pcVUI.SetMaxBytesPerPicDenom(this.GetEncCfg().GetMaxBytesPerPicDenom())
		pcVUI.SetMaxBitsPerMinCuDenom(this.GetEncCfg().GetMaxBitsPerMinCuDenom())
		pcVUI.SetLog2MaxMvLengthHorizontal(this.GetEncCfg().GetLog2MaxMvLengthHorizontal())
		pcVUI.SetLog2MaxMvLengthVertical(this.GetEncCfg().GetLog2MaxMvLengthVertical())
	}
}
예제 #6
0
func (this *TEncEntropy) xEncodeTransform(pcCU *TLibCommon.TComDataCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx uint, bCodeDQP *bool) {
	uiSubdiv := uint(TLibCommon.B2U(uint(pcCU.GetTransformIdx1(uiAbsPartIdx)+pcCU.GetDepth1(uiAbsPartIdx)) > uiDepth))
	uiLog2TrafoSize := uint(TLibCommon.G_aucConvertToBit[pcCU.GetSlice().GetSPS().GetMaxCUWidth()]) + 2 - uiDepth
	cbfY := pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_LUMA, uiTrIdx)
	cbfU := pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_U, uiTrIdx)
	cbfV := pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_V, uiTrIdx)

	//fmt.Print("Enter xEncodeTransform\n");// with uiSubdiv=%d, uiAbsPartIdx=%d, uiDepth=%d\n", uiSubdiv, uiAbsPartIdx, uiDepth);

	if uiTrIdx == 0 {
		this.m_bakAbsPartIdxCU = uiAbsPartIdx
	}
	if uiLog2TrafoSize == 2 {
		partNum := pcCU.GetPic().GetNumPartInCU() >> ((uiDepth - 1) << 1)
		if (uiAbsPartIdx % partNum) == 0 {
			this.m_uiBakAbsPartIdx = uiAbsPartIdx
			this.m_uiBakChromaOffset = offsetChroma
		} else if (uiAbsPartIdx % partNum) == (partNum - 1) {
			cbfU = pcCU.GetCbf3(this.m_uiBakAbsPartIdx, TLibCommon.TEXT_CHROMA_U, uiTrIdx)
			cbfV = pcCU.GetCbf3(this.m_uiBakAbsPartIdx, TLibCommon.TEXT_CHROMA_V, uiTrIdx)
		}
	}

	if pcCU.GetPredictionMode1(uiAbsPartIdx) == TLibCommon.MODE_INTRA && pcCU.GetPartitionSize1(uiAbsPartIdx) == TLibCommon.SIZE_NxN && uiDepth == uint(pcCU.GetDepth1(uiAbsPartIdx)) {
		//assert( uiSubdiv );
	} else if pcCU.GetPredictionMode1(uiAbsPartIdx) == TLibCommon.MODE_INTER && (pcCU.GetPartitionSize1(uiAbsPartIdx) != TLibCommon.SIZE_2Nx2N) && uiDepth == uint(pcCU.GetDepth1(uiAbsPartIdx)) && (pcCU.GetSlice().GetSPS().GetQuadtreeTUMaxDepthInter() == 1) {
		if uiLog2TrafoSize > pcCU.GetQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) {
			//assert( uiSubdiv );
		} else {
			//assert(!uiSubdiv );
		}
	} else if uiLog2TrafoSize > pcCU.GetSlice().GetSPS().GetQuadtreeTULog2MaxSize() {
		//assert( uiSubdiv );
	} else if uiLog2TrafoSize == pcCU.GetSlice().GetSPS().GetQuadtreeTULog2MinSize() {
		//assert( !uiSubdiv );
	} else if uiLog2TrafoSize == pcCU.GetQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) {
		//assert( !uiSubdiv );
	} else {
		//assert( uiLog2TrafoSize > pcCU.GetQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
		this.m_pcEntropyCoderIf.codeTransformSubdivFlag(uiSubdiv, 5-uiLog2TrafoSize)
	}

	uiTrDepthCurr := uiDepth - uint(pcCU.GetDepth1(uiAbsPartIdx))
	bFirstCbfOfCU := uiTrDepthCurr == 0
	if bFirstCbfOfCU || uiLog2TrafoSize > 2 {
		if bFirstCbfOfCU || pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_U, uiTrDepthCurr-1) != 0 {
			this.m_pcEntropyCoderIf.codeQtCbf(pcCU, uiAbsPartIdx, TLibCommon.TEXT_CHROMA_U, uiTrDepthCurr)
		}
		if bFirstCbfOfCU || pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_V, uiTrDepthCurr-1) != 0 {
			this.m_pcEntropyCoderIf.codeQtCbf(pcCU, uiAbsPartIdx, TLibCommon.TEXT_CHROMA_V, uiTrDepthCurr)
		}
	} else if uiLog2TrafoSize == 2 {
		//assert( pcCU.GetCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ) == pcCU.GetCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) );
		//assert( pcCU.GetCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ) == pcCU.GetCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) );
	}

	if uiSubdiv != 0 {
		var size uint
		width >>= 1
		height >>= 1
		size = width * height
		uiTrIdx++
		uiDepth++
		partNum := pcCU.GetPic().GetNumPartInCU() >> (uiDepth << 1)

		this.xEncodeTransform(pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP)

		uiAbsPartIdx += partNum
		offsetLuma += size
		offsetChroma += (size >> 2)
		this.xEncodeTransform(pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP)

		uiAbsPartIdx += partNum
		offsetLuma += size
		offsetChroma += (size >> 2)
		this.xEncodeTransform(pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP)

		uiAbsPartIdx += partNum
		offsetLuma += size
		offsetChroma += (size >> 2)
		this.xEncodeTransform(pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP)
	} else {
		/*DTRACE_CABAC_VL( g_nSymbolCounter++ );*/
		this.m_pcEntropyCoderIf.DTRACE_CABAC_T("\tTrIdx: abspart=")
		this.m_pcEntropyCoderIf.DTRACE_CABAC_V(uiAbsPartIdx)
		this.m_pcEntropyCoderIf.DTRACE_CABAC_T("\tdepth=")
		this.m_pcEntropyCoderIf.DTRACE_CABAC_V(uiDepth)
		this.m_pcEntropyCoderIf.DTRACE_CABAC_T("\ttrdepth=")
		this.m_pcEntropyCoderIf.DTRACE_CABAC_V(uint(pcCU.GetTransformIdx1(uiAbsPartIdx)))
		this.m_pcEntropyCoderIf.DTRACE_CABAC_T("\n")

		if pcCU.GetPredictionMode1(uiAbsPartIdx) != TLibCommon.MODE_INTRA && uiDepth == uint(pcCU.GetDepth1(uiAbsPartIdx)) && pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_U, 0) == 0 && pcCU.GetCbf3(uiAbsPartIdx, TLibCommon.TEXT_CHROMA_V, 0) == 0 {
			//assert( pcCU.GetCbf( uiAbsPartIdx, TLibCommon.TEXT_LUMA, 0 ) );
		} else {
			this.m_pcEntropyCoderIf.codeQtCbf(pcCU, uiAbsPartIdx, TLibCommon.TEXT_LUMA, uint(pcCU.GetTransformIdx1(uiAbsPartIdx)))
		}

		if cbfY != 0 || cbfU != 0 || cbfV != 0 {
			// dQP: only for LCU once
			if pcCU.GetSlice().GetPPS().GetUseDQP() {
				if *bCodeDQP {
					this.encodeQP(pcCU, this.m_bakAbsPartIdxCU, false)
					*bCodeDQP = false
				}
			}
		}
		if cbfY != 0 {
			trWidth := width
			trHeight := height
			this.m_pcEntropyCoderIf.codeCoeffNxN(pcCU, pcCU.GetCoeffY()[offsetLuma:], uiAbsPartIdx, trWidth, trHeight, uiDepth, TLibCommon.TEXT_LUMA)
		}
		if uiLog2TrafoSize > 2 {
			trWidth := width >> 1
			trHeight := height >> 1
			if cbfU != 0 {
				this.m_pcEntropyCoderIf.codeCoeffNxN(pcCU, pcCU.GetCoeffCb()[offsetChroma:], uiAbsPartIdx, trWidth, trHeight, uiDepth, TLibCommon.TEXT_CHROMA_U)
			}
			if cbfV != 0 {
				this.m_pcEntropyCoderIf.codeCoeffNxN(pcCU, pcCU.GetCoeffCr()[offsetChroma:], uiAbsPartIdx, trWidth, trHeight, uiDepth, TLibCommon.TEXT_CHROMA_V)
			}
		} else {
			partNum := pcCU.GetPic().GetNumPartInCU() >> ((uiDepth - 1) << 1)
			if (uiAbsPartIdx % partNum) == (partNum - 1) {
				trWidth := width
				trHeight := height
				if cbfU != 0 {
					this.m_pcEntropyCoderIf.codeCoeffNxN(pcCU, pcCU.GetCoeffCb()[this.m_uiBakChromaOffset:], this.m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TLibCommon.TEXT_CHROMA_U)
				}
				if cbfV != 0 {
					this.m_pcEntropyCoderIf.codeCoeffNxN(pcCU, pcCU.GetCoeffCr()[this.m_uiBakChromaOffset:], this.m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TLibCommon.TEXT_CHROMA_V)
				}
			}
		}
	}
	//fmt.Print("Exit xEncodeTransform\n");
}