From 5d86941b4ddc8cdde600edeb1e67b2cd85480975 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 21 Oct 2023 23:55:18 -0700 Subject: get_frames,cache_frame: reset yuv blocks once cached The existing code was assuming every frame would get cached before the next frame was collected. But that's not strictly enforced in the current architecture. Sure, the condition variable is signaled for every frame, but that doesn't guarantee the cache_frame side will wake up and actually do its thing before get_frames moves on to the next frame. There's no waiting for cache_frame to ack the signal before grabbing the next frame. So in damage-tracking mode (the default when available), there was a very real potential for lost damage, especially with higher fps rates. This commit moves the resetting of the YUV dirty blocks to the cache_frame side, only after the accumulated dirty blocks have been processed, immediately prior to releasing yuv_mutex. As a side effect, the previously get_frames-private rmdBlocksReset() has moved to rmd_yuv_utils.c and renamed to rmdYuvBlocksReset(). Some comments have been thrown in flagging the need to refactor the YUV blocks creation/maintenance - it's all very ad-hoc as-inherited, I haven't cleaned that up, and it needs it badly. Hopefully this fixes some of the lost damage I've been noticing doing 60-fps captures of programming. --- src/rmd_get_frames.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src/rmd_get_frames.c') diff --git a/src/rmd_get_frames.c b/src/rmd_get_frames.c index 2b442b5..3a9c2a3 100644 --- a/src/rmd_get_frames.c +++ b/src/rmd_get_frames.c @@ -210,14 +210,6 @@ static void rmdMoveCaptureArea( XRectangle *rect, } -static void rmdBlocksReset(unsigned int blocks_w, unsigned int blocks_h) -{ - memset(yblocks, 0, blocks_w * blocks_h * sizeof(*yblocks)); - memset(ublocks, 0, blocks_w * blocks_h * sizeof(*ublocks)); - memset(vblocks, 0, blocks_w * blocks_h * sizeof(*vblocks)); -} - - /** * Extract cache blocks from damage list * @@ -237,8 +229,6 @@ static void rmdBlocksFromList( RectArea **root, unsigned int blocks_w, unsigned int blocks_h) { - rmdBlocksReset(blocks_w, blocks_h); - for (RectArea *temp = *root; temp; temp = temp->next) { int row_start, row_end, column_start, column_end; @@ -618,7 +608,6 @@ void *rmdGetFrames(ProgData *pdata) } pthread_mutex_lock(&pdata->yuv_mutex); - rmdBlocksReset(blocks_w, blocks_h); rmdUpdateYuvBuffer( &pdata->enc_data->yuv, front_buff, back_buff, -- cgit v1.2.1