forked from bealemm/codec
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.go
More file actions
51 lines (37 loc) · 827 Bytes
/
util.go
File metadata and controls
51 lines (37 loc) · 827 Bytes
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
/*
Golang h264,aac decoder/encoder libav wrapper
d, err = codec.NewAACEncoder()
data, err = d.Encode(samples)
d, err = codec.NewAACDecoder(aaccfg)
samples, err = d.Decode(data)
var img *image.YCbCr
d, err = codec.NewH264Encoder(640, 480)
img, err = d.Encode(img)
d, err = codec.NewH264Decoder(pps)
img, err = d.Decode(nal)
*/
package codec
import (
"unsafe"
"reflect"
/*
#cgo darwin LDFLAGS: -lavformat -lavutil -lavcodec
#include <libavutil/avutil.h>
#include <libavformat/avformat.h>
static void libav_init() {
av_register_all();
av_log_set_level(AV_LOG_DEBUG);
}
*/
"C"
)
func init() {
C.libav_init()
}
func fromCPtr(buf unsafe.Pointer, size int) (ret []uint8) {
hdr := (*reflect.SliceHeader)((unsafe.Pointer(&ret)))
hdr.Cap = size
hdr.Len = size
hdr.Data = uintptr(buf)
return
}