Skip to content

Commit

Permalink
Switch to xxhash64 from xxhash32
Browse files Browse the repository at this point in the history
xxhash64 might be faster by the effect of hardware acceleration.
  • Loading branch information
metalefty committed Apr 3, 2024
1 parent dc448ff commit 6752bac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions module/rdpCapture.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ capture
B = (pixel >> 0) & UCHAR_MAX;

#define XXH32_SEED 0
#define XXH64_SEED 0

/******************************************************************************/
/* copy rects with no error checking */
Expand Down Expand Up @@ -852,7 +853,7 @@ rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
int dst_stride;
int crc_offset;
int crc_stride;
int crc;
uint64_t crc;
int num_crcs;
int mon_index;

Expand Down Expand Up @@ -891,7 +892,7 @@ rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
/* resize the crc list */
clientCon->num_rfx_crcs_alloc[mon_index] = num_crcs;
free(clientCon->rfx_crcs[mon_index]);
clientCon->rfx_crcs[mon_index] = g_new0(int, num_crcs);
clientCon->rfx_crcs[mon_index] = g_new0(uint64_t, num_crcs);
}

extents_rect = *rdpRegionExtents(in_reg);
Expand Down Expand Up @@ -925,7 +926,7 @@ 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 = XXH32(rects, num_rects * sizeof(BoxRec), XXH32_SEED);
crc = XXH64(rects, num_rects * sizeof(BoxRec), XXH64_SEED);
rdpCopyBox_a8r8g8b8_to_yuvalp(x, y,
src, src_stride,
dst, dst_stride,
Expand All @@ -941,10 +942,10 @@ rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
&rect, 1);
}
crc_dst = dst + (y << 8) * (dst_stride >> 8) + (x << 8);
crc = XXH32(crc_dst, 64 * 64 * 4, XXH32_SEED);
crc = XXH64(crc_dst, 64 * 64 * 4, XXH64_SEED);
crc_offset = (y / XRDP_RFX_ALIGN) * crc_stride
+ (x / XRDP_RFX_ALIGN);
LLOGLN(10, ("rdpCapture2: crc 0x%8.8x 0x%8.8x",
LLOGLN(10, ("rdpCapture2: xxhash 0x%" PRIx64 " 0x%" PRIx64,
crc, clientCon->rfx_crcs[mon_index][crc_offset]));
if (crc == clientCon->rfx_crcs[mon_index][crc_offset])
{
Expand Down
2 changes: 1 addition & 1 deletion module/rdpClientCon.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct _rdpClientCon
RegionPtr dirtyRegion;

int num_rfx_crcs_alloc[16];
int *rfx_crcs[16];
uint64_t *rfx_crcs[16];

/* true = skip drawing */
int suppress_output;
Expand Down

0 comments on commit 6752bac

Please sign in to comment.