aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorBiSaXa <1669855+BiSaXa@users.noreply.github.com>2022-08-27 21:17:06 +0300
committerBiSaXa <1669855+BiSaXa@users.noreply.github.com>2022-08-27 21:17:06 +0300
commit2e51abad509a6663f1cc15da91a263ff7b8e1513 (patch)
tree2a3238661ead91740df80ec63b93c632120b073f /utils
parentsome stuff before i realized i need my own bitreader library (diff)
downloadsdp.go-2e51abad509a6663f1cc15da91a263ff7b8e1513.tar.gz
sdp.go-2e51abad509a6663f1cc15da91a263ff7b8e1513.tar.bz2
sdp.go-2e51abad509a6663f1cc15da91a263ff7b8e1513.zip
it's a mess
Diffstat (limited to 'utils')
-rw-r--r--utils/utils.go31
1 files changed, 9 insertions, 22 deletions
diff --git a/utils/utils.go b/utils/utils.go
index 77e87af..6db28b0 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -4,10 +4,19 @@ import (
4 "encoding/binary" 4 "encoding/binary"
5 "log" 5 "log"
6 "math" 6 "math"
7 "math/bits"
7 "os" 8 "os"
8 "unsafe" 9 "unsafe"
9) 10)
10 11
12func ReverseByteArrayValues(byteArr []byte, size int) []byte {
13 arr := make([]byte, size)
14 for index, byteValue := range byteArr {
15 arr[index] = bits.Reverse8(byteValue)
16 }
17 return arr
18}
19
11func ReadByteFromFile(file *os.File, size int32) []byte { 20func ReadByteFromFile(file *os.File, size int32) []byte {
12 tmp := make([]byte, size) 21 tmp := make([]byte, size)
13 file.Read(tmp) 22 file.Read(tmp)
@@ -20,28 +29,6 @@ func CheckError(e error) {
20 } 29 }
21} 30}
22 31
23/*
24github.com/32bitkid/bitreader
25
26 func ReadBitsWithFirstBitCheckFromFile(file *os.File) (byteArr []byte, err error) {
27 arr := make([]byte, 4)
28 reader := bitreader.NewReader(file)
29 n := 0
30 state, err := reader.Read1()
31 if err != nil || state == true {
32 return nil, fmt.Errorf("ERR or VAL in BIT CHECK")
33 }
34 n += 1
35 if n == 0 {
36 val, err := reader.Read32(32)
37 if err != nil {
38 return nil, fmt.Errorf("ERR or VAL in BIT CHECK")
39 }
40 binary.LittleEndian.PutUint32(arr, val)
41 }
42 return arr, nil
43 }
44*/
45func IntFromBytes(byteArr []byte) uint32 { 32func IntFromBytes(byteArr []byte) uint32 {
46 int := binary.LittleEndian.Uint32(byteArr) 33 int := binary.LittleEndian.Uint32(byteArr)
47 return int 34 return int