optimize remote desktop, hvnc and webcam stuff. Fix issues with webcam frames getting super slow out of nowhere because of backup. Also remove compression since we rarely use it + H264 already compresses. Most things we send either way are so small where compression just adds CPU overhead that isn't needed.

This commit is contained in:
KingKDot
2026-03-13 09:28:16 -05:00
parent 5ceea3d34c
commit 225bc9e377
10 changed files with 241 additions and 107 deletions
+16 -3
View File
@@ -4,13 +4,26 @@ import (
"bytes"
"image"
"image/jpeg"
"sync"
)
var jpegBufPool = sync.Pool{
New: func() interface{} {
b := bytes.NewBuffer(make([]byte, 0, 128*1024))
return b
},
}
func encodeJPEG(img image.Image, quality int) ([]byte, error) {
buf := bytes.Buffer{}
err := jpeg.Encode(&buf, img, &jpeg.Options{Quality: quality})
buf := jpegBufPool.Get().(*bytes.Buffer)
buf.Reset()
err := jpeg.Encode(buf, img, &jpeg.Options{Quality: quality})
if err != nil {
jpegBufPool.Put(buf)
return nil, err
}
return buf.Bytes(), nil
out := make([]byte, buf.Len())
copy(out, buf.Bytes())
jpegBufPool.Put(buf)
return out, nil
}