bugfix: PESTsToUInt
This commit is contained in:
parent
02ec81cd7a
commit
b929b7a5eb
@ -74,6 +74,7 @@ func readSamples(filename string, ch chan Sample) {
|
||||
stream := findOrCreateStream(header.PID)
|
||||
r := bytes.NewReader(payload)
|
||||
lr := &io.LimitedReader{R: r, N: int64(len(payload))}
|
||||
|
||||
if header.PayloadUnitStart {
|
||||
stream.Data = bytes.Buffer{}
|
||||
if stream.Header, err = ts.ReadPESHeader(lr); err != nil {
|
||||
@ -81,6 +82,7 @@ func readSamples(filename string, ch chan Sample) {
|
||||
}
|
||||
stream.PCR = header.PCR
|
||||
}
|
||||
|
||||
if _, err = io.CopyN(&stream.Data, lr, lr.N); err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -533,8 +533,7 @@ func ReadPESHeader(r io.Reader) (res *PESHeader, err error) {
|
||||
self.PTS = PESUIntToTs(v)
|
||||
|
||||
if DebugReader {
|
||||
fmt.Printf("pes: pts %x=>%x %f\n",
|
||||
v, self.PTS, float64(self.PTS)/90000)
|
||||
fmt.Printf("pes: pts %d %f\n", self.PTS, float64(self.PTS)/90000)
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,7 +544,7 @@ func ReadPESHeader(r io.Reader) (res *PESHeader, err error) {
|
||||
}
|
||||
self.DTS = PESUIntToTs(v)
|
||||
if DebugReader {
|
||||
fmt.Printf("pes: dts %d\n", self.PTS)
|
||||
fmt.Printf("pes: dts %d %f\n", self.DTS, float64(self.DTS)/90000)
|
||||
}
|
||||
}
|
||||
|
||||
|
2
ts.go
2
ts.go
@ -74,7 +74,7 @@ func PESUIntToTs(v uint64) (ts uint64) {
|
||||
|
||||
func PESTsToUInt(ts uint64) (v uint64) {
|
||||
// 0010 PTS 32..30 1 PTS 29..15 1 PTS 14..00 1
|
||||
return ((ts>>30)&0x7)<<33 | ((ts>>15)&0x7fff)<<17 | (v&0x7fff)<<1 | 0x100010001
|
||||
return ((ts>>30)&0x7)<<33 | ((ts>>15)&0x7fff)<<17 | (ts&0x7fff)<<1 | 0x100010001
|
||||
}
|
||||
|
||||
func UIntToPCR(v uint64) uint64 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user