-
Notifications
You must be signed in to change notification settings - Fork 0
/
sws_vector.go
50 lines (42 loc) · 902 Bytes
/
sws_vector.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
package avgo
/*
#cgo pkg-config: libswscale
#include "libswscale/swscale.h"
*/
import "C"
import (
"unsafe"
)
type SwsVector struct {
c *C.struct_SwsVector
}
func NewSwsVector(size int) *SwsVector {
return &SwsVector{
c: C.sws_allocVec(C.int(size)),
}
}
func (v *SwsVector) Free() {
C.sws_freeVec(v.c)
}
func NewGaussianVector(variance, quality float64) *SwsVector {
vec := C.sws_getGaussianVec(C.double(variance), C.double(quality))
if vec == nil {
return nil
}
return &SwsVector{
c: vec,
}
}
func (v *SwsVector) Scale(scalar float64) {
C.sws_scaleVec(v.c, C.double(scalar))
}
func (v *SwsVector) Normalize(height float64) {
C.sws_normalizeVec(v.c, C.double(height))
}
func (v *SwsVector) Coefficients() []float64 {
result := make([]float64, int(v.c.length))
for _, d := range unsafe.Slice(v.c.coeff, v.c.length) {
result = append(result, float64(d))
}
return result
}