Skip to content

Commit

Permalink
Fixed ClockReference for 32 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
asticode committed Jun 23, 2020
1 parent c99b9e1 commit e6d0f0d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions clock_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
// ClockReference represents a clock reference
// Base is based on a 90 kHz clock and extension is based on a 27 MHz clock
type ClockReference struct {
Base, Extension int
Base, Extension int64
}

// newClockReference builds a new clock reference
func newClockReference(base, extension int) *ClockReference {
func newClockReference(base, extension int64) *ClockReference {
return &ClockReference{
Base: base,
Extension: extension,
Expand Down
4 changes: 2 additions & 2 deletions data_pes.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func parsePTSOrDTS(i *astikit.BytesIterator) (cr *ClockReference, err error) {
err = fmt.Errorf("astits: fetching next bytes failed: %w", err)
return
}
cr = newClockReference(int(uint64(bs[0])>>1&0x7<<30|uint64(bs[1])<<22|uint64(bs[2])>>1&0x7f<<15|uint64(bs[3])<<7|uint64(bs[4])>>1&0x7f), 0)
cr = newClockReference(int64(uint64(bs[0])>>1&0x7<<30|uint64(bs[1])<<22|uint64(bs[2])>>1&0x7f<<15|uint64(bs[3])<<7|uint64(bs[4])>>1&0x7f), 0)
return
}

Expand All @@ -409,6 +409,6 @@ func parseESCR(i *astikit.BytesIterator) (cr *ClockReference, err error) {
return
}
escr := uint64(bs[0])>>3&0x7<<39 | uint64(bs[0])&0x3<<37 | uint64(bs[1])<<29 | uint64(bs[2])>>3<<24 | uint64(bs[2])&0x3<<22 | uint64(bs[3])<<14 | uint64(bs[4])>>3<<9 | uint64(bs[4])&0x3<<7 | uint64(bs[5])>>1
cr = newClockReference(int(escr>>9), int(escr&0x1ff))
cr = newClockReference(int64(escr>>9), int64(escr&0x1ff))
return
}
2 changes: 1 addition & 1 deletion packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,6 @@ func parsePCR(i *astikit.BytesIterator) (cr *ClockReference, err error) {
return
}
pcr := uint64(bs[0])<<40 | uint64(bs[1])<<32 | uint64(bs[2])<<24 | uint64(bs[3])<<16 | uint64(bs[4])<<8 | uint64(bs[5])
cr = newClockReference(int(pcr>>15), int(pcr&0x1ff))
cr = newClockReference(int64(pcr>>15), int64(pcr&0x1ff))
return
}

0 comments on commit e6d0f0d

Please sign in to comment.