pktque: AVSync bugfix
This commit is contained in:
parent
8c783210d2
commit
2614fc9e9a
@ -108,7 +108,6 @@ func (self *FixTime) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoi
|
|||||||
type AVSync struct {
|
type AVSync struct {
|
||||||
MaxTimeDiff time.Duration
|
MaxTimeDiff time.Duration
|
||||||
time []time.Duration
|
time []time.Duration
|
||||||
timebase time.Duration
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *AVSync) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoidx int, audioidx int) (drop bool, err error) {
|
func (self *AVSync) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoidx int, audioidx int) (drop bool, err error) {
|
||||||
@ -120,20 +119,18 @@ func (self *AVSync) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoid
|
|||||||
}
|
}
|
||||||
|
|
||||||
start, end, correctable, correcttime := self.check(int(pkt.Idx))
|
start, end, correctable, correcttime := self.check(int(pkt.Idx))
|
||||||
time := pkt.Time - self.timebase
|
if pkt.Time >= start && pkt.Time < end {
|
||||||
if time >= start && time < end {
|
self.time[pkt.Idx] = pkt.Time
|
||||||
pkt.Time = time
|
|
||||||
self.time[pkt.Idx] = time
|
|
||||||
} else {
|
} else {
|
||||||
if correctable {
|
if correctable {
|
||||||
self.timebase = pkt.Time - correcttime
|
|
||||||
pkt.Time = correcttime
|
pkt.Time = correcttime
|
||||||
self.time[pkt.Idx] = correcttime
|
for i := range self.time {
|
||||||
|
self.time[i] = correcttime
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
drop = true
|
drop = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +147,7 @@ func (self *AVSync) check(i int) (start time.Duration, end time.Duration, correc
|
|||||||
}
|
}
|
||||||
allthesame := self.time[minidx] == self.time[maxidx]
|
allthesame := self.time[minidx] == self.time[maxidx]
|
||||||
|
|
||||||
if i == minidx {
|
if i == maxidx {
|
||||||
if allthesame {
|
if allthesame {
|
||||||
correctable = true
|
correctable = true
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user