mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-12 10:19:09 +08:00
improve yuv
This commit is contained in:
parent
6656a8cdbf
commit
604dcd6748
@ -239,7 +239,7 @@ export default class Connection {
|
||||
|
||||
draw(frame: any) {
|
||||
this._draw?.(frame);
|
||||
// globals.I420ToABGR(frame);
|
||||
// globals.I420ToARGB(frame);
|
||||
}
|
||||
|
||||
close() {
|
||||
|
@ -41,7 +41,7 @@ export function pushEvent(name, payload) {
|
||||
}
|
||||
|
||||
export function draw(frame) {
|
||||
currentFrame = I420ToABGR(frame);
|
||||
currentFrame = I420ToARGB(frame);
|
||||
}
|
||||
|
||||
export function setConn(conn) {
|
||||
@ -282,7 +282,7 @@ window.init = async () => {
|
||||
|
||||
let yPtr, yPtrLen, uPtr, uPtrLen, vPtr, vPtrLen, outPtr, outPtrLen;
|
||||
// let testSpeed = [0, 0];
|
||||
export function I420ToABGR(yb) {
|
||||
export function I420ToARGB(yb) {
|
||||
if (!wasmExports) return;
|
||||
// testSpeed[0] += 1;
|
||||
const tm0 = new Date().getTime();
|
||||
@ -318,8 +318,8 @@ export function I420ToABGR(yb) {
|
||||
outPtr = malloc(n);
|
||||
}
|
||||
// const res = wasmExports.I420ToARGB(yPtr, yb.y.stride, uPtr, yb.u.stride, vPtr, yb.v.stride, outPtr, w * 4, w, h);
|
||||
// const res = wasmExports.AVX_YUV_to_RGB(outPtr, yPtr, uPtr, vPtr, w, h);
|
||||
const res = wasmExports.yuv420_rgb24_std(w, h, yPtr, uPtr, vPtr, yb.y.stride, yb.v.stride, outPtr, w * 4, 0);
|
||||
const res = wasmExports.AVX_YUV_to_RGBA(outPtr, yPtr, uPtr, vPtr, w, h);
|
||||
// const res = wasmExports.yuv420_rgb24_std(w, h, yPtr, uPtr, vPtr, yb.y.stride, yb.v.stride, outPtr, w * 4, 0);
|
||||
const out = HEAPU8.slice(outPtr, outPtr + n);
|
||||
/*
|
||||
testSpeed[1] += new Date().getTime() - tm0;
|
||||
|
22
yuv-to-rgb.c
22
yuv-to-rgb.c
@ -24,7 +24,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define ZOF_TAB 65536
|
||||
#define ZOF_RGB 3
|
||||
|
||||
static int T1[ZOF_TAB], T2[ZOF_TAB], T3[ZOF_TAB], T4[ZOF_TAB];
|
||||
static int initialized;
|
||||
@ -46,19 +45,16 @@ static int foo;
|
||||
static int frame;
|
||||
|
||||
void
|
||||
AVX_YUV_to_RGB(unsigned char *dst, unsigned short *src, int width, int height) {
|
||||
AVX_YUV_to_RGBA(unsigned char *dst, unsigned char *y, unsigned char* u, unsigned char* v, int width, int height) {
|
||||
int r, g, b;
|
||||
unsigned short *y, *u, *v, *uline, *vline;
|
||||
unsigned char *uline, *vline;
|
||||
int w, h;
|
||||
|
||||
if (initialized == 0) {
|
||||
initialized = !0;
|
||||
build_tables();
|
||||
}
|
||||
// Setup pointers to the Y, U, V planes
|
||||
y = src;
|
||||
u = src + (width * height);
|
||||
v = u + (width * height) / 4; // Each chroma does 4 pixels in 4:2:0
|
||||
int half_width = width / 2;
|
||||
// Loop the image, taking into account sub-sample for the chroma channels
|
||||
for (h = 0; h < height; h++) {
|
||||
uline = u;
|
||||
@ -67,18 +63,18 @@ AVX_YUV_to_RGB(unsigned char *dst, unsigned short *src, int width, int height) {
|
||||
r = *y + T1[*vline];
|
||||
g = *y + T2[*vline] + T3[*uline];
|
||||
b = *y + T4[*uline];
|
||||
dst[0] = clamp(r); // 16-bit to 8-bit, chuck precision
|
||||
dst[1] = clamp(g);
|
||||
dst[2] = clamp(b);
|
||||
dst += ZOF_RGB;
|
||||
*dst++ = clamp(r); // 16-bit to 8-bit, chuck precision
|
||||
*dst++ = clamp(g);
|
||||
*dst++ = clamp(b);
|
||||
*dst++ = 255;
|
||||
if (w & 0x01) {
|
||||
uline++;
|
||||
vline++;
|
||||
}
|
||||
}
|
||||
if (h & 0x01) {
|
||||
u += width / 2;
|
||||
v += width / 2;
|
||||
u += half_width;
|
||||
v += half_width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user