-
Notifications
You must be signed in to change notification settings - Fork 47
/
hardware_frames_context.go
64 lines (52 loc) · 2.05 KB
/
hardware_frames_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
63
64
package astiav
//#include <libavcodec/avcodec.h>
import "C"
import (
"unsafe"
)
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html
type HardwareFramesContext struct {
c *C.struct_AVBufferRef
}
func newHardwareFramesContextFromC(c *C.struct_AVBufferRef) *HardwareFramesContext {
if c == nil {
return nil
}
return &HardwareFramesContext{c: c}
}
// https://ffmpeg.org/doxygen/7.0/hwcontext_8c.html#ac45a7c039eb4e084b692f69ff5f2e217
func AllocHardwareFramesContext(hdc *HardwareDeviceContext) *HardwareFramesContext {
return newHardwareFramesContextFromC(C.av_hwframe_ctx_alloc(hdc.c))
}
func (hfc *HardwareFramesContext) Free() {
if hfc.c != nil {
C.av_buffer_unref(&hfc.c)
}
}
func (hfc *HardwareFramesContext) data() *C.AVHWFramesContext {
return (*C.AVHWFramesContext)(unsafe.Pointer((hfc.c.data)))
}
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html#a9e6f29d0f744930cdd0e8bdff8771520
func (hfc *HardwareFramesContext) SetWidth(width int) {
hfc.data().width = C.int(width)
}
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html#ae61bbe1d8645a0c573085e29f1d0a58f
func (hfc *HardwareFramesContext) SetHeight(height int) {
hfc.data().height = C.int(height)
}
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html#a045bc1713932804f6ceef170a5578e0e
func (hfc *HardwareFramesContext) SetHardwarePixelFormat(format PixelFormat) {
hfc.data().format = C.enum_AVPixelFormat(format)
}
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html#a663a9aceca97aa7b2426c9aba6543e4a
func (hfc *HardwareFramesContext) SetSoftwarePixelFormat(swFormat PixelFormat) {
hfc.data().sw_format = C.enum_AVPixelFormat(swFormat)
}
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html#a9c3a94dcd9c96e19059b56a6bae9c764
func (hfc *HardwareFramesContext) SetInitialPoolSize(initialPoolSize int) {
hfc.data().initial_pool_size = C.int(initialPoolSize)
}
// https://ffmpeg.org/doxygen/7.0/hwcontext_8c.html#a66a7e1ebc7e459ce07d3de6639ac7e38
func (hfc *HardwareFramesContext) Initialize() error {
return newError(C.av_hwframe_ctx_init(hfc.c))
}