mirror of
https://github.com/harshabose/transcode.git
synced 2025-10-09 20:30:04 +08:00
first-commit
This commit is contained in:
@@ -1 +1,43 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/asticode/go-astiav"
|
||||
)
|
||||
|
||||
type framePool struct {
|
||||
pool sync.Pool
|
||||
}
|
||||
|
||||
func (pool *framePool) Get() *astiav.Frame {
|
||||
frame, ok := pool.pool.Get().(*astiav.Frame)
|
||||
|
||||
if frame == nil || !ok {
|
||||
return astiav.AllocFrame()
|
||||
}
|
||||
return frame
|
||||
}
|
||||
|
||||
func (pool *framePool) Put(frame *astiav.Frame) {
|
||||
if frame == nil {
|
||||
return
|
||||
}
|
||||
|
||||
frame.Unref()
|
||||
pool.pool.Put(frame)
|
||||
}
|
||||
|
||||
func (pool *framePool) Release() {
|
||||
for {
|
||||
frame, ok := pool.pool.Get().(*astiav.Frame)
|
||||
if frame == nil {
|
||||
break
|
||||
}
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
frame.Free()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user