install go2rtc on bob

This commit is contained in:
2026-04-04 19:36:14 +02:00
parent f0b56e63d1
commit ccf88187b8
537 changed files with 69213 additions and 0 deletions
+143
View File
@@ -0,0 +1,143 @@
package bits
type Reader struct {
EOF bool // if end of buffer raised during reading
buf []byte // total buf
byte byte // current byte
bits byte // bits left in byte
pos int // current pos in buf
}
func NewReader(b []byte) *Reader {
return &Reader{buf: b}
}
//goland:noinspection GoStandardMethods
func (r *Reader) ReadByte() byte {
if r.bits != 0 {
return r.ReadBits8(8)
}
if r.pos >= len(r.buf) {
r.EOF = true
return 0
}
b := r.buf[r.pos]
r.pos++
return b
}
func (r *Reader) ReadUint16() uint16 {
if r.bits != 0 {
return r.ReadBits16(16)
}
return uint16(r.ReadByte())<<8 | uint16(r.ReadByte())
}
func (r *Reader) ReadUint24() uint32 {
if r.bits != 0 {
return r.ReadBits(24)
}
return uint32(r.ReadByte())<<16 | uint32(r.ReadByte())<<8 | uint32(r.ReadByte())
}
func (r *Reader) ReadUint32() uint32 {
if r.bits != 0 {
return r.ReadBits(32)
}
return uint32(r.ReadByte())<<24 | uint32(r.ReadByte())<<16 | uint32(r.ReadByte())<<8 | uint32(r.ReadByte())
}
func (r *Reader) ReadBit() byte {
if r.bits == 0 {
r.byte = r.ReadByte()
r.bits = 7
} else {
r.bits--
}
return (r.byte >> r.bits) & 0b1
}
func (r *Reader) ReadBits(n byte) (res uint32) {
for i := n - 1; i != 255; i-- {
res |= uint32(r.ReadBit()) << i
}
return
}
func (r *Reader) ReadBits8(n byte) (res uint8) {
for i := n - 1; i != 255; i-- {
res |= r.ReadBit() << i
}
return
}
func (r *Reader) ReadBits16(n byte) (res uint16) {
for i := n - 1; i != 255; i-- {
res |= uint16(r.ReadBit()) << i
}
return
}
func (r *Reader) ReadBits64(n byte) (res uint64) {
for i := n - 1; i != 255; i-- {
res |= uint64(r.ReadBit()) << i
}
return
}
func (r *Reader) ReadFloat32() float64 {
i := r.ReadUint16()
f := r.ReadUint16()
return float64(i) + float64(f)/65536
}
func (r *Reader) ReadBytes(n int) (b []byte) {
if r.bits == 0 {
if r.pos+n > len(r.buf) {
r.EOF = true
return nil
}
b = r.buf[r.pos : r.pos+n]
r.pos += n
} else {
b = make([]byte, n)
for i := 0; i < n; i++ {
b[i] = r.ReadByte()
}
}
return
}
// ReadUEGolomb - ReadExponentialGolomb (unsigned)
func (r *Reader) ReadUEGolomb() uint32 {
var size byte
for size = 0; size < 32; size++ {
if b := r.ReadBit(); b != 0 || r.EOF {
break
}
}
return r.ReadBits(size) + (1 << size) - 1
}
// ReadSEGolomb - ReadSignedExponentialGolomb
func (r *Reader) ReadSEGolomb() int32 {
if b := r.ReadUEGolomb(); b%2 == 0 {
return -int32(b / 2)
} else {
return int32((b + 1) / 2)
}
}
func (r *Reader) Left() []byte {
return r.buf[r.pos:]
}
func (r *Reader) Pos() (int, byte) {
return r.pos - 1, r.bits
}
@@ -0,0 +1,95 @@
package bits
type Writer struct {
buf []byte // total buf
byte *byte // pointer to current byte
bits byte // bits left in byte
}
func NewWriter(buf []byte) *Writer {
return &Writer{buf: buf}
}
//goland:noinspection GoStandardMethods
func (w *Writer) WriteByte(b byte) {
if w.bits != 0 {
w.WriteBits8(b, 8)
}
w.buf = append(w.buf, b)
}
func (w *Writer) WriteBit(b byte) {
if w.bits == 0 {
w.buf = append(w.buf, 0)
w.byte = &w.buf[len(w.buf)-1]
w.bits = 7
} else {
w.bits--
}
*w.byte |= (b & 1) << w.bits
}
func (w *Writer) WriteBits(v uint32, n byte) {
for i := n - 1; i != 255; i-- {
w.WriteBit(byte(v>>i) & 0b1)
}
}
func (w *Writer) WriteBits16(v uint16, n byte) {
for i := n - 1; i != 255; i-- {
w.WriteBit(byte(v>>i) & 0b1)
}
}
func (w *Writer) WriteBits8(v, n byte) {
for i := n - 1; i != 255; i-- {
w.WriteBit((v >> i) & 0b1)
}
}
func (w *Writer) WriteAllBits(bit, n byte) {
for i := byte(0); i < n; i++ {
w.WriteBit(bit)
}
}
func (w *Writer) WriteBool(b bool) {
if b {
w.WriteBit(1)
} else {
w.WriteBit(0)
}
}
func (w *Writer) WriteUint16(v uint16) {
if w.bits != 0 {
w.WriteBits16(v, 16)
}
w.buf = append(w.buf, byte(v>>8), byte(v))
}
func (w *Writer) WriteBytes(bytes ...byte) {
if w.bits != 0 {
for _, b := range bytes {
w.WriteByte(b)
}
}
w.buf = append(w.buf, bytes...)
}
func (w *Writer) Bytes() []byte {
return w.buf
}
func (w *Writer) Len() int {
return len(w.buf)
}
func (w *Writer) Reset() {
w.buf = w.buf[:0]
w.bits = 0
}