Ignite/frame/statistics.go
DataHoarder 6ea3e971bb
All checks were successful
continuous-integration/drone/push Build is passing
Improved libaom/libx264, proper pool, frame stats
2023-10-31 23:00:37 +01:00

86 lines
1.6 KiB
Go

package frame
import "math"
type Statistics map[string]any
const (
StatisticsKeyFramesIn = "frames_in"
StatisticsKeyFramesOut = "frames_out"
StatisticsKeyLastFrameOut = "last_frame_out"
)
func (s Statistics) FramesIn() int {
if n, ok := s[StatisticsKeyFramesIn].(int); ok {
return n
}
return -1
}
func (s Statistics) FramesOut() int {
if n, ok := s[StatisticsKeyFramesOut].(int); ok {
return n
}
return -1
}
func (s Statistics) LastFrameOut() *FrameStatistics {
if n, ok := s[StatisticsKeyLastFrameOut].(FrameStatistics); ok {
return &n
}
return nil
}
type FrameStatistics map[string]any
const (
FrameStatisticsKeyNumber = "number"
FrameStatisticsKeyPts = "pts"
FrameStatisticsKeyQuantizer = "quantizer"
FrameStatisticsKeySize = "size"
FrameStatisticsKeyIsKeyFrame = "is_key"
FrameStatisticsKeyIsIntraFrame = "is_intra"
)
func (s FrameStatistics) Number() int {
if n, ok := s[FrameStatisticsKeyNumber].(int); ok {
return n
}
return -1
}
func (s FrameStatistics) Size() int {
if n, ok := s[FrameStatisticsKeySize].(int); ok {
return n
}
return -1
}
func (s FrameStatistics) PTS() int64 {
if n, ok := s[FrameStatisticsKeyPts].(int64); ok {
return n
}
return -1
}
func (s FrameStatistics) Quantizer() float64 {
if n, ok := s[FrameStatisticsKeyQuantizer].(float64); ok {
return n
}
return math.NaN()
}
func (s FrameStatistics) IsKeyFrame() bool {
if n, ok := s[FrameStatisticsKeyIsKeyFrame].(bool); ok {
return n
}
return false
}
func (s FrameStatistics) IsIntraFrame() bool {
if n, ok := s[FrameStatisticsKeyIsIntraFrame].(bool); ok {
return n
}
return false
}