-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.go
More file actions
29 lines (25 loc) · 789 Bytes
/
convert.go
File metadata and controls
29 lines (25 loc) · 789 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
package gdesk
/*
#cgo LDFLAGS: -lyuv
#include "vpx_wrapper.h"
*/
import "C"
import (
"reflect"
"unsafe"
)
func i420ToRgb(w, h int, src []byte) (dst []byte) {
dst = make([]byte, w*h*3)
s := unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&src)).Data)
d := unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&dst)).Data)
C.i420_to_rgb(C.int(w), C.int(h), s, d)
return
}
func nv12_to_i420(plan0, plan1 []byte, w, h int) (dst []byte) {
dst = make([]byte, h*w*12/8)
p0 := (*reflect.SliceHeader)(unsafe.Pointer(&plan0))
p1 := (*reflect.SliceHeader)(unsafe.Pointer(&plan1))
d := unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&dst)).Data)
C.nv12_to_i420(unsafe.Pointer(p0.Data), C.int(p0.Len), unsafe.Pointer(p1.Data), C.int(p1.Len), C.int(w), C.int(h), d)
return
}