mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 16:37:04 +08:00
Replace timer-based SMA with a timer-less implementation
This commit is contained in:
@@ -3,23 +3,23 @@ package parse
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/prep/average"
|
||||
"github.com/datarhei/core/v16/math/average"
|
||||
)
|
||||
|
||||
type averager struct {
|
||||
fps *average.SlidingWindow
|
||||
pps *average.SlidingWindow
|
||||
bitrate *average.SlidingWindow
|
||||
fps *average.SMA
|
||||
pps *average.SMA
|
||||
bitrate *average.SMA
|
||||
}
|
||||
|
||||
func (a *averager) init(window, granularity time.Duration) {
|
||||
a.fps, _ = average.New(window, granularity)
|
||||
a.pps, _ = average.New(window, granularity)
|
||||
a.bitrate, _ = average.New(window, granularity)
|
||||
a.fps, _ = average.NewSMA(window, granularity)
|
||||
a.pps, _ = average.NewSMA(window, granularity)
|
||||
a.bitrate, _ = average.NewSMA(window, granularity)
|
||||
}
|
||||
|
||||
func (a *averager) stop() {
|
||||
a.fps.Stop()
|
||||
a.pps.Stop()
|
||||
a.bitrate.Stop()
|
||||
a.fps.Reset()
|
||||
a.pps.Reset()
|
||||
a.bitrate.Reset()
|
||||
}
|
||||
|
Reference in New Issue
Block a user