-
Notifications
You must be signed in to change notification settings - Fork 47
/
frame_side_data.go
38 lines (32 loc) · 1005 Bytes
/
frame_side_data.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
package astiav
//#include <libavutil/frame.h>
import "C"
import (
"math"
"unsafe"
)
// https://ffmpeg.org/doxygen/7.0/structAVFrameSideData.html
type FrameSideData struct {
c *C.AVFrameSideData
}
func newFrameSideDataFromC(c *C.AVFrameSideData) *FrameSideData {
if c == nil {
return nil
}
return &FrameSideData{c: c}
}
// https://ffmpeg.org/doxygen/7.0/structAVFrameSideData.html#a76937ad48652a5a0cc4bff65fc6c886e
func (d *FrameSideData) Data() []byte {
return bytesFromC(func(size *C.size_t) *C.uint8_t {
*size = d.c.size
return d.c.data
})
}
// https://ffmpeg.org/doxygen/7.0/structAVFrameSideData.html#a76937ad48652a5a0cc4bff65fc6c886e
func (d *FrameSideData) SetData(b []byte) {
C.memcpy(unsafe.Pointer(d.c.data), unsafe.Pointer(&b[0]), C.size_t(math.Min(float64(len(b)), float64(d.c.size))))
}
// https://ffmpeg.org/doxygen/7.0/structAVFrameSideData.html#a07ff3499827c124591ff4bae6f68eec0
func (d *FrameSideData) Type() FrameSideDataType {
return FrameSideDataType(d.c._type)
}