Exemple #1
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))
			}
		}
	}
}
Exemple #2
0
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)
			}
		}
	}
}