コード例 #1
0
ファイル: TEncEntropy.go プロジェクト: hanjinze/GoHM
func (this *TEncEntropy) encodeSaoOffset(saoLcuParam *TLibCommon.SaoLcuParam, compIdx uint) {
	var uiSymbol uint
	var i int

	uiSymbol = uint(saoLcuParam.TypeIdx) + 1
	if compIdx != 2 {
		this.m_pcEntropyCoderIf.codeSaoTypeIdx(uiSymbol)
	}
	if uiSymbol != 0 {
		if saoLcuParam.TypeIdx < 4 && compIdx != 2 {
			saoLcuParam.SubTypeIdx = saoLcuParam.TypeIdx
		}
		var bitDepth int
		if compIdx != 0 {
			bitDepth = TLibCommon.G_bitDepthC
		} else {
			bitDepth = TLibCommon.G_bitDepthY
		}
		offsetTh := 1 << uint(TLibCommon.MIN(int(bitDepth-5), int(5)).(int))
		if saoLcuParam.TypeIdx == TLibCommon.SAO_BO {
			for i = 0; i < saoLcuParam.Length; i++ {
				var absOffset int
				if saoLcuParam.Offset[i] < 0 {
					absOffset = -saoLcuParam.Offset[i]
				} else {
					absOffset = saoLcuParam.Offset[i]
				}
				this.m_pcEntropyCoderIf.codeSaoMaxUvlc(uint(absOffset), uint(offsetTh-1))
			}
			for i = 0; i < saoLcuParam.Length; i++ {
				if saoLcuParam.Offset[i] != 0 {
					var sign uint
					if saoLcuParam.Offset[i] < 0 {
						sign = 1
					} else {
						sign = 0
					}
					this.m_pcEntropyCoderIf.codeSAOSign(sign)
				}
			}
			uiSymbol = uint(saoLcuParam.SubTypeIdx)
			this.m_pcEntropyCoderIf.codeSaoUflc(5, uiSymbol)
		} else if saoLcuParam.TypeIdx < 4 {
			this.m_pcEntropyCoderIf.codeSaoMaxUvlc(uint(saoLcuParam.Offset[0]), uint(offsetTh-1))
			this.m_pcEntropyCoderIf.codeSaoMaxUvlc(uint(saoLcuParam.Offset[1]), uint(offsetTh-1))
			this.m_pcEntropyCoderIf.codeSaoMaxUvlc(uint(-saoLcuParam.Offset[2]), uint(offsetTh-1))
			this.m_pcEntropyCoderIf.codeSaoMaxUvlc(uint(-saoLcuParam.Offset[3]), uint(offsetTh-1))
			if compIdx != 2 {
				uiSymbol = uint(saoLcuParam.SubTypeIdx)
				this.m_pcEntropyCoderIf.codeSaoUflc(2, uiSymbol)
			}
		}
	}
}
コード例 #2
0
ファイル: TEncRateCtrl.go プロジェクト: hanjinze/GoHM
func (this *TEncRCGOP) xEstGOPTargetBits(encRCSeq *TEncRCSeq, GOPSize int) int {
	realInfluencePicture := TLibCommon.MIN(g_RCSmoothWindowSize, encRCSeq.getFramesLeft()).(int)
	averageTargetBitsPerPic := int(encRCSeq.getTargetBits() / int64(encRCSeq.getTotalFrames()))
	currentTargetBitsPerPic := int((int64(encRCSeq.getBitsLeft()) - int64(averageTargetBitsPerPic)*(int64(encRCSeq.getFramesLeft())-int64(realInfluencePicture))) / int64(realInfluencePicture))
	targetBits := currentTargetBitsPerPic * GOPSize

	if targetBits < 200 {
		targetBits = 200 // at least allocate 200 bits for one GOP
	}

	return targetBits
}