diff --git a/host/platform/Linux/capture/XCB/src/xcb.c b/host/platform/Linux/capture/XCB/src/xcb.c index 86c237d8..f3db4f95 100644 --- a/host/platform/Linux/capture/XCB/src/xcb.c +++ b/host/platform/Linux/capture/XCB/src/xcb.c @@ -50,7 +50,8 @@ struct xcb LGThread * pointerThread; unsigned int width; - unsigned int height; + unsigned int height, dataHeight; + unsigned int pitch; int mouseX, mouseY, mouseHotX, mouseHotY; @@ -131,6 +132,7 @@ static bool xcb_init(void) this->xcbScreen = iter.data; this->width = iter.data->width_in_pixels; this->height = iter.data->height_in_pixels; + this->pitch = this->width * 4; DEBUG_INFO("Frame Size : %u x %u", this->width, this->height); this->seg = xcb_generate_id(this->xcb); @@ -269,14 +271,18 @@ static CaptureResult xcb_waitFrame(CaptureFrame * frame, { lgWaitEvent(this->frameEvent, TIMEOUT_INFINITE); - const unsigned int maxHeight = maxFrameSize / (this->width * 4); + const unsigned int maxHeight = maxFrameSize / this->pitch; + this->dataHeight = min(maxHeight, this->height); + frame->screenWidth = this->width; frame->screenHeight = this->height; + frame->dataWidth = this->width; + frame->dataHeight = this->dataHeight; frame->frameWidth = this->width; - frame->frameHeight = min(maxHeight, this->height); + frame->frameHeight = this->height; frame->truncated = maxHeight < this->height; - frame->pitch = this->width * 4; + frame->pitch = this->pitch; frame->stride = this->width; frame->format = CAPTURE_FMT_BGRA; frame->rotation = CAPTURE_ROT_0; @@ -284,8 +290,7 @@ static CaptureResult xcb_waitFrame(CaptureFrame * frame, return CAPTURE_RESULT_OK; } -static CaptureResult xcb_getFrame(FrameBuffer * frame, - const unsigned int height, int frameIndex) +static CaptureResult xcb_getFrame(FrameBuffer * frame, int frameIndex) { DEBUG_ASSERT(this); DEBUG_ASSERT(this->initialized); @@ -298,7 +303,7 @@ static CaptureResult xcb_getFrame(FrameBuffer * frame, return CAPTURE_RESULT_ERROR; } - framebuffer_write(frame, this->data, this->width * height * 4); + framebuffer_write(frame, this->data, this->pitch); free(img); this->hasFrame = false; diff --git a/host/platform/Linux/capture/pipewire/src/pipewire.c b/host/platform/Linux/capture/pipewire/src/pipewire.c index 25e79ff4..a6bac84f 100644 --- a/host/platform/Linux/capture/pipewire/src/pipewire.c +++ b/host/platform/Linux/capture/pipewire/src/pipewire.c @@ -47,7 +47,7 @@ struct pipewire bool stop; bool hasFormat; bool formatChanged; - int width, height; + int width, height, dataHeight, pitch; CaptureFormat format; bool hdr; bool hdrPQ; @@ -192,6 +192,9 @@ static void streamParamChangedCallback(void * opaque, uint32_t id, SPA_VIDEO_FORMAT_RGBA_F16); this->hdrPQ = true; // this is assumed and untested + const int bpp = this->format == CAPTURE_FMT_RGBA16F ? 8 : 4; + this->pitch = this->width * bpp; + if (this->hasFormat) { this->formatChanged = true; @@ -427,8 +430,8 @@ static CaptureResult pipewire_waitFrame(CaptureFrame * frame, if (this->stop) return CAPTURE_RESULT_REINIT; - const int bpp = this->format == CAPTURE_FMT_RGBA16F ? 8 : 4; - const unsigned int maxHeight = maxFrameSize / (this->width * bpp); + const unsigned int maxHeight = maxFrameSize / this->pitch; + this->dataHeight = min(maxHeight, this->height); frame->formatVer = this->formatVer; frame->format = this->format; @@ -436,10 +439,12 @@ static CaptureResult pipewire_waitFrame(CaptureFrame * frame, frame->hdrPQ = this->hdrPQ; frame->screenWidth = this->width; frame->screenHeight = this->height; + frame->dataWidth = this->width; + frame->dataHeight = this->dataHeight; frame->frameWidth = this->width; - frame->frameHeight = min(maxHeight, this->height); - frame->truncated = maxHeight < this->height; - frame->pitch = this->width * bpp; + frame->frameHeight = this->height; + frame->truncated = maxHeight < this->dataHeight; + frame->pitch = this->pitch; frame->stride = this->width; frame->rotation = CAPTURE_ROT_0; @@ -449,14 +454,13 @@ static CaptureResult pipewire_waitFrame(CaptureFrame * frame, return CAPTURE_RESULT_OK; } -static CaptureResult pipewire_getFrame(FrameBuffer * frame, - const unsigned int height, int frameIndex) +static CaptureResult pipewire_getFrame(FrameBuffer * frame, int frameIndex) { if (this->stop || !this->frameData) return CAPTURE_RESULT_REINIT; - const int bpp = this->format == CAPTURE_FMT_RGBA16F ? 8 : 4; - framebuffer_write(frame, this->frameData, height * this->width * bpp); + framebuffer_write(frame, this->frameData, + this->dataHeight * this->pitch); pw_thread_loop_accept(this->threadLoop); return CAPTURE_RESULT_OK;