From 984676299135bdab590acfaa00067902b319ecfb Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 13 Jan 2020 19:17:09 +1100 Subject: [PATCH] [all] align the frame data to the page boundary --- VERSION | 2 +- c-host/src/app.c | 6 +++++- client/src/main.c | 2 +- common/include/common/KVMFR.h | 1 + obs/lg.c | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 486a2539..2fde6818 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-92-g0d29527758+1 \ No newline at end of file +B1-94-g17df1ebc6b+1 \ No newline at end of file diff --git a/c-host/src/app.c b/c-host/src/app.c index b1b5a208..2147792f 100644 --- a/c-host/src/app.c +++ b/c-host/src/app.c @@ -109,6 +109,7 @@ static int frameThread(void * opaque) bool repeatFrame = false; int frameIndex = 0; CaptureFrame frame = { 0 }; + const long pageSize = sysinfo_getPageSize(); (void)frameIndex; (void)repeatFrame; @@ -182,9 +183,12 @@ static int frameThread(void * opaque) fi->height = frame.height; fi->stride = frame.stride; fi->pitch = frame.pitch; + fi->offset = pageSize - sizeof(FrameBuffer); frameValid = true; - FrameBuffer fb = (FrameBuffer)(fi + 1); + // put the framebuffer on the border of the next page + // this is to allow for aligned DMA transfers by the receiver + FrameBuffer fb = (FrameBuffer)(((uint8_t*)fi) + fi->offset); framebuffer_prepare(fb); /* we post and then get the frame, this is intentional! */ diff --git a/client/src/main.c b/client/src/main.c index e97bce0f..e3afe4c3 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -440,7 +440,7 @@ static int frameThread(void * unused) updatePositionInfo(); } - FrameBuffer fb = (FrameBuffer)(frame + 1); + FrameBuffer fb = (FrameBuffer)(((uint8_t*)frame) + frame->offset); if (!state.lgr->on_frame_event(state.lgrData, lgrFormat, fb)) { DEBUG_ERROR("renderer on frame event returned failure"); diff --git a/common/include/common/KVMFR.h b/common/include/common/KVMFR.h index 3b39420a..f01064c3 100644 --- a/common/include/common/KVMFR.h +++ b/common/include/common/KVMFR.h @@ -60,5 +60,6 @@ typedef struct KVMFRFrame uint32_t height; // the height uint32_t stride; // the row stride (zero if compressed data) uint32_t pitch; // the row pitch (stride in bytes or the compressed frame size) + uint32_t offset; // offset from the start of this header to the FrameBuffer header } KVMFRFrame; \ No newline at end of file diff --git a/obs/lg.c b/obs/lg.c index f541fd30..edd87068 100644 --- a/obs/lg.c +++ b/obs/lg.c @@ -164,7 +164,7 @@ static void lgVideoTick(void * data, float seconds) } } - FrameBuffer fb = (FrameBuffer)(frame + 1); + FrameBuffer fb = (FrameBuffer)(((uint8_t*)frame) + frame->offset); uint8_t *texData; uint32_t linesize;