Improving mpegts

This commit is contained in:
Unknown 2018-01-07 14:25:13 +10:30
parent 2a3f058e77
commit 484f21e4d3
3 changed files with 22 additions and 3 deletions

View File

@ -126,8 +126,27 @@ func (p *MpegTsPacket) ToByteSlice() (output []byte) {
output[1] = boolToByte(p.TEI) << 7 | boolToByte(p.PUSI) << 6 | output[1] = boolToByte(p.TEI) << 7 | boolToByte(p.PUSI) << 6 |
boolToByte(p.Priority) << 5 | byte((p.PID&0xFF00) >> 8) boolToByte(p.Priority) << 5 | byte((p.PID&0xFF00) >> 8)
output[2] = byte(p.PID & 0x00FF) output[2] = byte(p.PID & 0x00FF)
output[3] = p.TSC << 6 | (p.AFC << 4) | p.CC output[3] = p.TSC << 6 | p.AFC << 4 | p.CC
output[4] = p.AFL output[4] = p.AFL
output[5] = output[5] = boolToByte(p.DI) << 7 | boolToByte(p.RAI) << 6 | boolToByte(p.ESPI) << 5 |
return boolToByte(p.PCRF) << 4 | boolToByte(p.OPCRF) << 3 | boolToByte(p.SPF) << 2 |
boolToByte(TPDF) << 1 | boolToByte(AFEF)
currentIndex := 6
for ; p.PCRf && currentIndex < 12; currentIndex++ {
output[currentIndex] = p.PCR >> (22 - 2*currentIndex)
}
startIndex := currentIndex
for ; p.OPCRF && ( currentIndex < ( startIndex + 6 )); currentIndex++ {
output[currentIndex] = p.OPCR >> (10 - 2*(currentIndex-startIndex))
}
if p.SPF {
output[(currentIndex++)-1] = p.SC
}
if p.TPDF {
output[(currentIndex++)-1] = p.TPDL
copy(output[currentIndex:len(p.TPD)],p.TPD[:]]
currentIndex += len(p.TPD)
}
copy()
} }

BIN
revid/mpegtsCompare Executable file

Binary file not shown.

0
revid/video Normal file
View File