forked from asticode/go-astiav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_context.go
62 lines (52 loc) · 1.49 KB
/
filter_context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package astiav
//#cgo pkg-config: libavfilter libavutil
//#include <libavfilter/avfilter.h>
//#include <libavfilter/buffersink.h>
//#include <libavfilter/buffersrc.h>
//#include <libavutil/frame.h>
import "C"
import "unsafe"
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L67
type FilterContext struct {
c *C.struct_AVFilterContext
}
func newFilterContext() *FilterContext {
return &FilterContext{}
}
func (fc *FilterContext) Free() {
C.avfilter_free(fc.c)
}
func (fc *FilterContext) BuffersrcAddFrame(f *Frame, fs BuffersrcFlags) error {
var cf *C.struct_AVFrame
if f != nil {
cf = f.c
}
return newError(C.av_buffersrc_add_frame_flags(fc.c, cf, C.int(fs)))
}
func (fc *FilterContext) BuffersinkGetFrame(f *Frame, fs BuffersinkFlags) error {
var cf *C.struct_AVFrame
if f != nil {
cf = f.c
}
return newError(C.av_buffersink_get_frame_flags(fc.c, cf, C.int(fs)))
}
func (fc *FilterContext) NbInputs() int {
return int(fc.c.nb_inputs)
}
func (fc *FilterContext) NbOutputs() int {
return int(fc.c.nb_outputs)
}
func (fc *FilterContext) Inputs() (ls []*FilterLink) {
lcs := (*[maxArraySize](*C.struct_AVFilterLink))(unsafe.Pointer(fc.c.inputs))
for i := 0; i < fc.NbInputs(); i++ {
ls = append(ls, newFilterLinkFromC(lcs[i]))
}
return
}
func (fc *FilterContext) Outputs() (ls []*FilterLink) {
lcs := (*[maxArraySize](*C.struct_AVFilterLink))(unsafe.Pointer(fc.c.outputs))
for i := 0; i < fc.NbOutputs(); i++ {
ls = append(ls, newFilterLinkFromC(lcs[i]))
}
return
}