Exemplo n.º 1
0
func (this *TDecEntropy) DecodeCoeff(pcCU *TLibCommon.TComDataCU, uiAbsPartIdx, uiDepth, uiWidth, uiHeight uint, bCodeDQP *bool) {
	uiMinCoeffSize := pcCU.GetPic().GetMinCUWidth() * pcCU.GetPic().GetMinCUHeight()
	uiLumaOffset := uiMinCoeffSize * uiAbsPartIdx
	uiChromaOffset := uiLumaOffset >> 2

	if !pcCU.IsIntra(uiAbsPartIdx) {
		uiQtRootCbf := uint(1)
		if !(pcCU.GetPartitionSize1(uiAbsPartIdx) == TLibCommon.SIZE_2Nx2N && pcCU.GetMergeFlag1(uiAbsPartIdx)) {
			this.m_pcEntropyDecoderIf.ParseQtRootCbf(uiAbsPartIdx, &uiQtRootCbf)
		}
		if uiQtRootCbf == 0 {
			pcCU.SetCbfSubParts(0, 0, 0, uiAbsPartIdx, uiDepth)
			pcCU.SetTrIdxSubParts(0, uiAbsPartIdx, uiDepth)
			return
		}

	}
	this.xDecodeTransform(pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP)
}
Exemplo n.º 2
0
func (this *TEncEntropy) encodeCoeff(pcCU *TLibCommon.TComDataCU, uiAbsPartIdx, uiDepth, uiWidth, uiHeight uint, bCodeDQP *bool) {
	uiMinCoeffSize := pcCU.GetPic().GetMinCUWidth() * pcCU.GetPic().GetMinCUHeight()
	uiLumaOffset := uiMinCoeffSize * uiAbsPartIdx
	uiChromaOffset := uiLumaOffset >> 2

	if pcCU.IsIntra(uiAbsPartIdx) {
		/*DTRACE_CABAC_VL( g_nSymbolCounter++ )*/
		this.m_pcEntropyCoderIf.DTRACE_CABAC_T("\tdecodeTransformIdx()\tCUDepth=")
		this.m_pcEntropyCoderIf.DTRACE_CABAC_V(uiDepth)
		this.m_pcEntropyCoderIf.DTRACE_CABAC_T("\n")
	} else {
		if !(pcCU.GetMergeFlag1(uiAbsPartIdx) && pcCU.GetPartitionSize1(uiAbsPartIdx) == TLibCommon.SIZE_2Nx2N) {
			this.m_pcEntropyCoderIf.codeQtRootCbf(pcCU, uiAbsPartIdx)
		}
		if !pcCU.GetQtRootCbf(uiAbsPartIdx) {
			return
		}
	}

	this.xEncodeTransform(pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP)
}
Exemplo n.º 3
0
func (this *TEncEntropy) encodePUWise(pcCU *TLibCommon.TComDataCU, uiAbsPartIdx uint, bRD bool) { //= false );
	if bRD {
		uiAbsPartIdx = 0
	}

	ePartSize := pcCU.GetPartitionSize1(uiAbsPartIdx)
	var uiNumPU uint
	if ePartSize == TLibCommon.SIZE_2Nx2N {
		uiNumPU = 1
	} else if ePartSize == TLibCommon.SIZE_NxN {
		uiNumPU = 4
	} else {
		uiNumPU = 2
	}
	uiDepth := uint(pcCU.GetDepth1(uiAbsPartIdx))
	//fmt.Printf("ePartSize=%d\n",ePartSize);
	uiPUOffset := (TLibCommon.G_auiPUOffset[uint(ePartSize)] << ((pcCU.GetSlice().GetSPS().GetMaxCUDepth() - uiDepth) << 1)) >> 4

	uiSubPartIdx := uiAbsPartIdx
	for uiPartIdx := uint(0); uiPartIdx < uiNumPU; uiPartIdx++ {
		this.encodeMergeFlag(pcCU, uiSubPartIdx)
		if pcCU.GetMergeFlag1(uiSubPartIdx) {
			this.encodeMergeIndex(pcCU, uiSubPartIdx, false)
		} else {
			this.encodeInterDirPU(pcCU, uiSubPartIdx)
			for uiRefListIdx := 0; uiRefListIdx < 2; uiRefListIdx++ {
				if pcCU.GetSlice().GetNumRefIdx(TLibCommon.RefPicList(uiRefListIdx)) > 0 {
					this.encodeRefFrmIdxPU(pcCU, uiSubPartIdx, TLibCommon.RefPicList(uiRefListIdx))
					this.encodeMvdPU(pcCU, uiSubPartIdx, TLibCommon.RefPicList(uiRefListIdx))
					this.encodeMVPIdxPU(pcCU, uiSubPartIdx, TLibCommon.RefPicList(uiRefListIdx))
				}
			}
		}
		uiSubPartIdx += uiPUOffset
	}

	return
}
Exemplo n.º 4
0
func (this *TDecEntropy) DecodePUWise(pcCU *TLibCommon.TComDataCU, uiAbsPartIdx, uiDepth uint, pcSubCU *TLibCommon.TComDataCU) {
	ePartSize := pcCU.GetPartitionSize1(uiAbsPartIdx)
	var uiNumPU uint
	if ePartSize == TLibCommon.SIZE_2Nx2N {
		uiNumPU = 1
	} else if ePartSize == TLibCommon.SIZE_NxN {
		uiNumPU = 4
	} else {
		uiNumPU = 2
	}

	uiPUOffset := (TLibCommon.G_auiPUOffset[uint(ePartSize)] << ((pcCU.GetSlice().GetSPS().GetMaxCUDepth() - uiDepth) << 1)) >> 4

	var cMvFieldNeighbours [TLibCommon.MRG_MAX_NUM_CANDS << 1]TLibCommon.TComMvField // double length for mv of both lists
	var uhInterDirNeighbours [TLibCommon.MRG_MAX_NUM_CANDS]byte

	for ui := uint(0); ui < pcCU.GetSlice().GetMaxNumMergeCand(); ui++ {
		uhInterDirNeighbours[ui] = 0
	}
	numValidMergeCand := 0
	isMerged := false

	pcSubCU.CopyInterPredInfoFrom(pcCU, uiAbsPartIdx, TLibCommon.REF_PIC_LIST_0)
	pcSubCU.CopyInterPredInfoFrom(pcCU, uiAbsPartIdx, TLibCommon.REF_PIC_LIST_1)
	uiSubPartIdx := uiAbsPartIdx
	for uiPartIdx := uint(0); uiPartIdx < uiNumPU; uiPartIdx++ {
		this.DecodeMergeFlag(pcCU, uiSubPartIdx, uiDepth, uiPartIdx)
		if pcCU.GetMergeFlag1(uiSubPartIdx) {
			this.DecodeMergeIndex(pcCU, uiPartIdx, uiSubPartIdx, uiDepth)
			uiMergeIndex := pcCU.GetMergeIndex1(uiSubPartIdx)
			if pcCU.GetSlice().GetPPS().GetLog2ParallelMergeLevelMinus2() != 0 && ePartSize != TLibCommon.SIZE_2Nx2N && pcSubCU.GetWidth1(0) <= 8 {
				pcSubCU.SetPartSizeSubParts(TLibCommon.SIZE_2Nx2N, 0, uiDepth)
				if !isMerged {
					pcSubCU.GetInterMergeCandidates(0, 0, cMvFieldNeighbours[:], uhInterDirNeighbours[:], &numValidMergeCand, -1)
					isMerged = true
				}
				pcSubCU.SetPartSizeSubParts(ePartSize, 0, uiDepth)
			} else {
				uiMergeIndex = pcCU.GetMergeIndex1(uiSubPartIdx)
				pcSubCU.GetInterMergeCandidates(uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours[:], uhInterDirNeighbours[:], &numValidMergeCand, int(uiMergeIndex))
			}
			pcCU.SetInterDirSubParts(uint(uhInterDirNeighbours[uiMergeIndex]), uiSubPartIdx, uiPartIdx, uiDepth)

			cTmpMv := TLibCommon.NewTComMv(0, 0)
			for uiRefListIdx := 0; uiRefListIdx < 2; uiRefListIdx++ {
				if pcCU.GetSlice().GetNumRefIdx(TLibCommon.RefPicList(uiRefListIdx)) > 0 {
					pcCU.SetMVPIdxSubParts(0, TLibCommon.RefPicList(uiRefListIdx), uiSubPartIdx, uiPartIdx, uiDepth)
					pcCU.SetMVPNumSubParts(0, TLibCommon.RefPicList(uiRefListIdx), uiSubPartIdx, uiPartIdx, uiDepth)
					pcCU.GetCUMvField(TLibCommon.RefPicList(uiRefListIdx)).SetAllMvd(*cTmpMv, ePartSize, int(uiSubPartIdx), uiDepth, int(uiPartIdx))
					pcCU.GetCUMvField(TLibCommon.RefPicList(uiRefListIdx)).SetAllMvField(&cMvFieldNeighbours[2*int(uiMergeIndex)+uiRefListIdx], ePartSize, int(uiSubPartIdx), uiDepth, int(uiPartIdx))
				}
			}
		} else {
			this.DecodeInterDirPU(pcCU, uiSubPartIdx, uiDepth, uiPartIdx)
			for uiRefListIdx := 0; uiRefListIdx < 2; uiRefListIdx++ {
				if pcCU.GetSlice().GetNumRefIdx(TLibCommon.RefPicList(uiRefListIdx)) > 0 {
					//fmt.Printf("%d \n",uiRefListIdx);
					this.DecodeRefFrmIdxPU(pcCU, uiSubPartIdx, uiDepth, uiPartIdx, TLibCommon.RefPicList(uiRefListIdx))
					this.DecodeMvdPU(pcCU, uiSubPartIdx, uiDepth, uiPartIdx, TLibCommon.RefPicList(uiRefListIdx))
					this.DecodeMVPIdxPU(pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, TLibCommon.RefPicList(uiRefListIdx))
				}
			}
		}
		if (pcCU.GetInterDir1(uiSubPartIdx) == 3) && pcSubCU.IsBipredRestriction(uiPartIdx) {
			pcCU.GetCUMvField(TLibCommon.REF_PIC_LIST_1).SetAllMv(*TLibCommon.NewTComMv(0, 0), ePartSize, int(uiSubPartIdx), uiDepth, int(uiPartIdx))
			pcCU.GetCUMvField(TLibCommon.REF_PIC_LIST_1).SetAllRefIdx(-1, ePartSize, int(uiSubPartIdx), uiDepth, int(uiPartIdx))
			pcCU.SetInterDirSubParts(1, uiSubPartIdx, uiPartIdx, uiDepth)
		}

		uiSubPartIdx += uiPUOffset
	}
	return
}