コード例 #1
0
ファイル: TDecGop.go プロジェクト: nacore/GoHM
func (this *TDecGop) DecompressSlice(pcBitstream *TLibCommon.TComInputBitstream, rpcPic *TLibCommon.TComPic, pTraceFile io.Writer) {
	pcSlice := rpcPic.GetSlice(rpcPic.GetCurrSliceIdx())
	// Table of extracted substreams.
	// These must be deallocated AND their internal fifos, too.
	//TComInputBitstream **ppcSubstreams = NULL;

	//-- For time output for each slice
	iBeforeTime := time.Now()

	uiStartCUAddr := pcSlice.GetSliceSegmentCurStartCUAddr()

	uiSliceStartCuAddr := pcSlice.GetSliceCurStartCUAddr()
	if uiSliceStartCuAddr == uiStartCUAddr {
		l := len(this.m_sliceStartCUAddress)
		this.m_sliceStartCUAddress[l] = int(uiSliceStartCuAddr)
		//this.m_sliceStartCUAddress.PushBack(uiSliceStartCuAddr);
	}

	this.m_pcSbacDecoder.Init(this.m_pcBinCABAC) //(TDecBinIf*)
	this.m_pcEntropyDecoder.SetEntropyDecoder(this.m_pcSbacDecoder)
	this.m_pcEntropyDecoder.SetTraceFile(pTraceFile)

	var uiNumSubstreams uint

	if pcSlice.GetPPS().GetEntropyCodingSyncEnabledFlag() {
		uiNumSubstreams = uint(pcSlice.GetNumEntryPointOffsets() + 1)
	} else {
		uiNumSubstreams = uint(pcSlice.GetPPS().GetNumSubstreams())
	}

	// init each couple {EntropyDecoder, Substream}
	puiSubstreamSizes := pcSlice.GetSubstreamSizes()
	ppcSubstreams := make([]*TLibCommon.TComInputBitstream, uiNumSubstreams)
	this.m_pcSbacDecoders = make([]*TDecSbac, uiNumSubstreams)
	this.m_pcBinCABACs = make([]*TDecBinCabac, uiNumSubstreams)
	for ui := uint(0); ui < uiNumSubstreams; ui++ {
		this.m_pcSbacDecoders[ui] = NewTDecSbac()
		this.m_pcBinCABACs[ui] = NewTDecBinCabac()
		this.m_pcSbacDecoders[ui].Init(this.m_pcBinCABACs[ui])
		if ui+1 < uiNumSubstreams {
			ppcSubstreams[ui] = pcBitstream.ExtractSubstream(puiSubstreamSizes[ui])
		} else {
			ppcSubstreams[ui] = pcBitstream.ExtractSubstream(pcBitstream.GetNumBitsLeft())
		}
	}

	for ui := uint(0); ui+1 < uiNumSubstreams; ui++ {
		this.m_pcEntropyDecoder.SetEntropyDecoder(this.m_pcSbacDecoders[uiNumSubstreams-1-ui])
		this.m_pcEntropyDecoder.SetTraceFile(pTraceFile)
		this.m_pcEntropyDecoder.SetBitstream(ppcSubstreams[uiNumSubstreams-1-ui])
		this.m_pcEntropyDecoder.ResetEntropy(pcSlice)
	}

	this.m_pcEntropyDecoder.SetEntropyDecoder(this.m_pcSbacDecoder)
	this.m_pcEntropyDecoder.SetTraceFile(pTraceFile)
	this.m_pcEntropyDecoder.SetBitstream(ppcSubstreams[0])
	this.m_pcEntropyDecoder.ResetEntropy(pcSlice)

	if uiSliceStartCuAddr == uiStartCUAddr {
		l := len(this.m_LFCrossSliceBoundaryFlag)
		this.m_LFCrossSliceBoundaryFlag[l] = pcSlice.GetLFCrossSliceBoundaryFlag()
		//this.m_LFCrossSliceBoundaryFlag.PushBack( pcSlice.GetLFCrossSliceBoundaryFlag());
	}
	this.m_pcSbacDecoders[0].Load(this.m_pcSbacDecoder)
	this.m_pcSliceDecoder.DecompressSlice(ppcSubstreams, rpcPic, this.m_pcSbacDecoder, this.m_pcSbacDecoders)
	this.m_pcEntropyDecoder.SetBitstream(ppcSubstreams[uiNumSubstreams-1])
	// deallocate all created substreams, including internal buffers.
	/*for ui := uint(0); ui < uiNumSubstreams; ui++ {
	    ppcSubstreams[ui]->deleteFifo();
	    delete ppcSubstreams[ui];
	  }
	  delete[] ppcSubstreams;
	  delete[] m_pcSbacDecoders;
	  delete[] m_pcBinCABACs;
	*/
	this.m_pcSbacDecoders = nil
	this.m_pcBinCABACs = nil

	lAfterTime := time.Now()
	this.m_dDecTime += lAfterTime.Sub(iBeforeTime)
}