change float64->float32
This commit is contained in:
parent
bfcfd605e6
commit
97f2cceb2c
11
demuxer.go
11
demuxer.go
@ -2,8 +2,8 @@ package ts
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/nareix/av"
|
||||
"github.com/nareix/av/pktqueue"
|
||||
"github.com/nareix/codec/aacparser"
|
||||
@ -41,7 +41,7 @@ func (self *Demuxer) Streams() (streams []av.CodecData, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (self *Demuxer) CurrentTime() (time float64) {
|
||||
func (self *Demuxer) CurrentTime() (time float32) {
|
||||
if self.pktque != nil {
|
||||
time = self.pktque.CurrentTime()
|
||||
}
|
||||
@ -158,9 +158,9 @@ func (self *Stream) payloadEnd() (err error) {
|
||||
IsKeyFrame: self.tshdr.RandomAccessIndicator,
|
||||
Data: payload,
|
||||
}
|
||||
time := float64(dts)/float64(PTS_HZ)
|
||||
time := float32(dts) / float32(PTS_HZ)
|
||||
if pts != dts {
|
||||
pkt.CompositionTime = float64(pts-dts)/float64(PTS_HZ)
|
||||
pkt.CompositionTime = float32(pts-dts) / float32(PTS_HZ)
|
||||
}
|
||||
self.demuxer.pktque.WriteTimePacket(self.idx, time, pkt)
|
||||
self.demuxer.gotpkt = true
|
||||
@ -188,7 +188,7 @@ func (self *Stream) payloadEnd() (err error) {
|
||||
var sps, pps []byte
|
||||
for _, nalu := range nalus {
|
||||
if len(nalu) > 0 {
|
||||
naltype := nalu[0]&0x1f
|
||||
naltype := nalu[0] & 0x1f
|
||||
if naltype == 7 {
|
||||
sps = nalu
|
||||
} else if naltype == 8 {
|
||||
@ -237,4 +237,3 @@ func (self *Stream) handleTSPacket(header TSHeader, tspacket []byte) (err error)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ func ReadTSHeader(r io.Reader) (self TSHeader, err error) {
|
||||
// clock is 27MHz
|
||||
self.PCR = UIntToPCR(v)
|
||||
if DebugReader {
|
||||
fmt.Fprintf(DebugOutput, "ts: PCR %d %f\n", self.PCR, float64(self.PCR)/PCR_HZ)
|
||||
fmt.Fprintf(DebugOutput, "ts: PCR %d %f\n", self.PCR, float32(self.PCR)/PCR_HZ)
|
||||
}
|
||||
}
|
||||
|
||||
@ -572,7 +572,7 @@ func ReadPESHeader(r io.Reader) (res *PESHeader, err error) {
|
||||
self.PTS = PESUIntToTs(v)
|
||||
|
||||
if DebugReader {
|
||||
fmt.Fprintf(DebugOutput, "pes: pts %d %f\n", self.PTS, float64(self.PTS)/float64(PTS_HZ))
|
||||
fmt.Fprintf(DebugOutput, "pes: pts %d %f\n", self.PTS, float32(self.PTS)/float32(PTS_HZ))
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,7 +583,7 @@ func ReadPESHeader(r io.Reader) (res *PESHeader, err error) {
|
||||
}
|
||||
self.DTS = PESUIntToTs(v)
|
||||
if DebugReader {
|
||||
fmt.Fprintf(DebugOutput, "pes: dts %d %f\n", self.DTS, float64(self.DTS)/float64(PTS_HZ))
|
||||
fmt.Fprintf(DebugOutput, "pes: dts %d %f\n", self.DTS, float32(self.DTS)/float32(PTS_HZ))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,13 +25,13 @@ type Stream struct {
|
||||
|
||||
idx int
|
||||
pkt av.Packet
|
||||
time float64
|
||||
time float32
|
||||
}
|
||||
|
||||
func timeToPesTs(time float64) uint64 {
|
||||
func timeToPesTs(time float32) uint64 {
|
||||
return uint64(time*PTS_HZ) + PTS_HZ
|
||||
}
|
||||
|
||||
func timeToPCR(time float64) uint64 {
|
||||
func timeToPCR(time float32) uint64 {
|
||||
return uint64(time*PCR_HZ) + PCR_HZ
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user