func (this *InputNALUnit) convertPayloadToRBSP(nalUnitBuf *list.List, pcBitstream *TLibCommon.TComInputBitstream, isVclNalUnit bool) *list.List { zeroCount := 0 it_write := list.New() oldBuf := list.New() pos := uint(0) pcBitstream.ClearEmulationPreventionByteLocation() for e := nalUnitBuf.Front(); e != nil; e, pos = e.Next(), pos+1 { //assert(zeroCount < 2 || *it_read >= 0x03); it_read := e.Value.(byte) oldBuf.PushBack(it_read) if zeroCount == 2 && it_read == 0x03 { pcBitstream.PushEmulationPreventionByteLocation(pos) pos++ zeroCount = 0 e = e.Next() if e == nil { break } else { it_read = e.Value.(byte) oldBuf.PushBack(it_read) } } if it_read == 0x00 { zeroCount++ } else { zeroCount = 0 } it_write.PushBack(it_read) } //assert(zeroCount == 0); if isVclNalUnit { // Remove cabac_zero_word from payload if present n := 0 e := it_write.Back() it_read := e.Value.(byte) for it_read == 0x00 { it_write.Remove(e) n++ e = it_write.Back() if e != nil { it_read = e.Value.(byte) } else { break } } if n > 0 { fmt.Printf("\nDetected %d instances of cabac_zero_word", n/2) } } nalUnitBuf.Init() // = .resize(it_write - nalUnitBuf.begin()); for e := it_write.Front(); e != nil; e = e.Next() { it_read := e.Value.(byte) nalUnitBuf.PushBack(it_read) } return oldBuf }