init: 自 zomaintain/backend/rdplib 平移独立成库; module path 从上游 github.com/nakagami/grdp 改为 git.zeroonesoft.cn/golib/rdplib
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
//go:build amd64
|
||||
|
||||
package pdu
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// ycoCgToBGRANoSub converts Y, Co, Cg planes to BGRA using SSE2.
|
||||
// count = total pixel count. shift = colorLossLevel - 1.
|
||||
// Alpha is always 0xFF (caller handles non-0xFF alpha separately).
|
||||
func ycoCgToBGRANoSub(pixels []byte, yPlane, coPlane, cgPlane []byte, count int, shift uint8) {
|
||||
count8 := count &^ 7
|
||||
if count8 > 0 {
|
||||
ycoCgToBGRASSE2(
|
||||
unsafe.Pointer(&pixels[0]),
|
||||
unsafe.Pointer(&yPlane[0]),
|
||||
unsafe.Pointer(&coPlane[0]),
|
||||
unsafe.Pointer(&cgPlane[0]),
|
||||
count8, int(shift),
|
||||
)
|
||||
}
|
||||
for i := count8; i < count; i++ {
|
||||
yVal := int16(yPlane[i])
|
||||
coVal := int16(int8(byte(int16(coPlane[i]) << shift)))
|
||||
cgVal := int16(int8(byte(int16(cgPlane[i]) << shift)))
|
||||
off := i * 4
|
||||
pixels[off] = clampByte(yVal - coVal - cgVal)
|
||||
pixels[off+1] = clampByte(yVal + cgVal)
|
||||
pixels[off+2] = clampByte(yVal + coVal - cgVal)
|
||||
pixels[off+3] = 0xFF
|
||||
}
|
||||
}
|
||||
|
||||
//go:noescape
|
||||
func ycoCgToBGRASSE2(pixels, yPlane, coPlane, cgPlane unsafe.Pointer, count, shift int)
|
||||
Reference in New Issue
Block a user