mirror of
https://github.com/asticode/go-astiav.git
synced 2025-10-05 16:16:50 +08:00
31 lines
586 B
Go
31 lines
586 B
Go
package astiav
|
|
|
|
//#cgo pkg-config: libavutil
|
|
//#include <libavutil/display.h>
|
|
import "C"
|
|
import (
|
|
"encoding/binary"
|
|
"fmt"
|
|
"unsafe"
|
|
)
|
|
|
|
type DisplayMatrix [9]uint32
|
|
|
|
func NewDisplayMatrixFromBytes(b []byte) (m DisplayMatrix, err error) {
|
|
// Check length
|
|
if len(b) < 36 {
|
|
err = fmt.Errorf("astiav: invalid length %d < 36", len(b))
|
|
return
|
|
}
|
|
|
|
// Loop
|
|
for idx := 0; idx < 9; idx++ {
|
|
m[idx] = binary.BigEndian.Uint32(b[idx*4 : (idx+1)*4])
|
|
}
|
|
return
|
|
}
|
|
|
|
func (m DisplayMatrix) Rotation() float64 {
|
|
return float64(C.av_display_rotation_get((*C.int32_t)(unsafe.Pointer(&m[0]))))
|
|
}
|