Skip to content

Commit

Permalink
Lazy color convert copy after hash in rdpCapture2
Browse files Browse the repository at this point in the history
  • Loading branch information
metalefty committed Apr 9, 2024
1 parent 3fa0b15 commit 57870d1
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions module/rdpCapture.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,24 @@ isShmStatusActive(enum shared_memory_status status) {
}
}

/******************************************************************************/
/* copy rects with no error checking */
static uint64_t
xxhash64_rfx_tile(const uint8_t *src, int src_stride, int x, int y, XXH64_state_t* const state)
{
int row;
uint64_t hash;
const uint8_t *s8;
s8 = src + (y * src_stride) + (x * 4);
for(row = 0; row < 64; row++)
{
XXH64_update(state, (const void*) s8, 64 * 4);
s8 += src_stride;
}
hash = XXH64_digest(state);
return hash;
}

/******************************************************************************/
static Bool
rdpCapture0(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
Expand Down Expand Up @@ -856,6 +874,7 @@ rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
uint64_t crc;
int num_crcs;
int mon_index;
XXH64_state_t* const xxh_state = XXH64_createState();

LLOGLN(10, ("rdpCapture2:"));

Expand Down Expand Up @@ -918,6 +937,7 @@ rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
}
else
{
XXH64_reset(xxh_state, XXH64_SEED);
if (rcode == rgnPART)
{
LLOGLN(10, ("rdpCapture2: rgnPART"));
Expand All @@ -926,24 +946,22 @@ rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
rdpRegionIntersect(&tile_reg, in_reg, &tile_reg);
rects = REGION_RECTS(&tile_reg);
num_rects = REGION_NUM_RECTS(&tile_reg);
crc = XXH64(rects, num_rects * sizeof(BoxRec), XXH64_SEED);
XXH64_update(xxh_state, (const void*)rects, num_rects * sizeof(BoxRec));
rdpCopyBox_a8r8g8b8_to_yuvalp(x, y,
src, src_stride,
dst, dst_stride,
rects, num_rects);
crc_dst = dst + (y << 8) * (dst_stride >> 8) + (x << 8);
XXH64_update(xxh_state, (const void*)crc_dst, 64 * 64 * 4);
crc = XXH64_digest(xxh_state);
rdpRegionUninit(&tile_reg);
}
else /* rgnIN */
{
LLOGLN(10, ("rdpCapture2: rgnIN"));
rdpCopyBox_a8r8g8b8_to_yuvalp(x, y,
src, src_stride,
dst, dst_stride,
&rect, 1);
crc = xxhash64_rfx_tile((const void*)src, src_stride, x, y, xxh_state);
}
crc_dst = dst + (y << 8) * (dst_stride >> 8) + (x << 8);
crc = XXH64(crc_dst, 64 * 64 * 4, XXH64_SEED);
crc_offset = (y / XRDP_RFX_ALIGN) * crc_stride
crc_offset = (y / XRDP_RFX_ALIGN) * crc_stride
+ (x / XRDP_RFX_ALIGN);
LLOGLN(10, ("rdpCapture2: xxhash 0x%" PRIx64 " 0x%" PRIx64,
crc, clientCon->rfx_crcs[mon_index][crc_offset]));
Expand All @@ -956,6 +974,14 @@ rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
}
else
{
/* lazily only do this if hash wasn't identical */
if (rcode != rgnPART)
{
rdpCopyBox_a8r8g8b8_to_yuvalp(x, y,
src, src_stride,
dst, dst_stride,
&rect, 1);
}
clientCon->rfx_crcs[mon_index][crc_offset] = crc;
(*out_rects)[out_rect_index] = rect;
out_rect_index++;
Expand Down

0 comments on commit 57870d1

Please sign in to comment.