forked from asticode/go-astiav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_context.go
58 lines (50 loc) · 1.52 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
package astiav
//#include <libavfilter/avfilter.h>
import "C"
import (
"unsafe"
)
// https://ffmpeg.org/doxygen/7.0/structAVFilterContext.html
type FilterContext struct {
c *C.AVFilterContext
}
func newFilterContext(c *C.AVFilterContext) *FilterContext {
if c == nil {
return nil
}
fc := &FilterContext{c: c}
classers.set(fc)
return fc
}
var _ Classer = (*FilterContext)(nil)
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga0ea7664a3ce6bb677a830698d358a179
func (fc *FilterContext) Free() {
// Make sure to clone the classer before freeing the object since
// the C free method may reset the pointer
c := newClonedClasser(fc)
C.avfilter_free(fc.c)
// Make sure to remove from classers after freeing the object since
// the C free method may use methods needing the classer
if c != nil {
classers.del(c)
}
}
// https://ffmpeg.org/doxygen/7.0/structAVFilterContext.html#a00ac82b13bb720349c138310f98874ca
func (fc *FilterContext) Class() *Class {
return newClassFromC(unsafe.Pointer(fc.c))
}
// https://ffmpeg.org/doxygen/7.0/structAVFilterContext.html#addd946fbe5af506a2b19f9ad7cb97c35
func (fc *FilterContext) SetHardwareDeviceContext(hdc *HardwareDeviceContext) {
if fc.c.hw_device_ctx != nil {
C.av_buffer_unref(&fc.c.hw_device_ctx)
}
if hdc != nil {
fc.c.hw_device_ctx = C.av_buffer_ref(hdc.c)
} else {
fc.c.hw_device_ctx = nil
}
}
// https://ffmpeg.org/doxygen/7.0/structAVFilterContext.html#a6eee53e57dddfa7cca1cade870c8a44e
func (fc *FilterContext) Filter() *Filter {
return newFilterFromC(fc.c.filter)
}