Added filter thread methods

This commit is contained in:
Quentin Renard
2024-05-21 10:10:26 +02:00
parent e0a9bdbd45
commit 33d572de98
5 changed files with 26 additions and 5 deletions

View File

@@ -6,10 +6,10 @@ import "C"
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/codec.h#L460
type CodecHardwareConfig struct {
c *C.AVCodecHWConfig
c *C.struct_AVCodecHWConfig
}
func newCodecHardwareConfigFromC(c *C.AVCodecHWConfig) CodecHardwareConfig {
func newCodecHardwareConfigFromC(c *C.struct_AVCodecHWConfig) CodecHardwareConfig {
return CodecHardwareConfig{c: c}
}

View File

@@ -43,6 +43,22 @@ func (g *FilterGraph) Class() *Class {
return newClassFromC(unsafe.Pointer(g.c))
}
func (g *FilterGraph) ThreadCount() int {
return int(g.c.nb_threads)
}
func (g *FilterGraph) SetThreadCount(threadCount int) {
g.c.nb_threads = C.int(threadCount)
}
func (g *FilterGraph) ThreadType() ThreadType {
return ThreadType(g.c.thread_type)
}
func (g *FilterGraph) SetThreadType(t ThreadType) {
g.c.thread_type = C.int(t)
}
type FilterArgs map[string]string
func (args FilterArgs) String() string {

View File

@@ -17,6 +17,10 @@ func TestFilterGraph(t *testing.T) {
cl := fg.Class()
require.NotNil(t, cl)
require.Equal(t, "AVFilterGraph", cl.Name())
fg.SetThreadCount(2)
require.Equal(t, 2, fg.ThreadCount())
fg.SetThreadType(ThreadTypeSlice)
require.Equal(t, ThreadTypeSlice, fg.ThreadType())
bufferSink := FindFilterByName("buffersink")
require.NotNil(t, bufferSink)

View File

@@ -10,7 +10,7 @@ import (
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/hwcontext.h#L61
type HardwareDeviceContext struct {
c *C.AVBufferRef
c *C.struct_AVBufferRef
}
func CreateHardwareDeviceContext(t HardwareDeviceType, device string, options *Dictionary) (*HardwareDeviceContext, error) {

View File

@@ -8,6 +8,7 @@ type ThreadType int
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/avcodec.h#L1451
const (
ThreadTypeFrame = ThreadType(C.FF_THREAD_FRAME)
ThreadTypeSlice = ThreadType(C.FF_THREAD_SLICE)
ThreadTypeFrame = ThreadType(C.FF_THREAD_FRAME)
ThreadTypeSlice = ThreadType(C.FF_THREAD_SLICE)
ThreadTypeUndefined = ThreadType(0)
)