[host] linux: fix compilation (untested)

This commit is contained in:
Geoffrey McRae 2023-11-09 18:26:16 +11:00
parent 174b51b144
commit 7a30736ac4
2 changed files with 26 additions and 17 deletions

View File

@ -50,7 +50,8 @@ struct xcb
LGThread * pointerThread; LGThread * pointerThread;
unsigned int width; unsigned int width;
unsigned int height; unsigned int height, dataHeight;
unsigned int pitch;
int mouseX, mouseY, mouseHotX, mouseHotY; int mouseX, mouseY, mouseHotX, mouseHotY;
@ -131,6 +132,7 @@ static bool xcb_init(void)
this->xcbScreen = iter.data; this->xcbScreen = iter.data;
this->width = iter.data->width_in_pixels; this->width = iter.data->width_in_pixels;
this->height = iter.data->height_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); DEBUG_INFO("Frame Size : %u x %u", this->width, this->height);
this->seg = xcb_generate_id(this->xcb); this->seg = xcb_generate_id(this->xcb);
@ -269,14 +271,18 @@ static CaptureResult xcb_waitFrame(CaptureFrame * frame,
{ {
lgWaitEvent(this->frameEvent, TIMEOUT_INFINITE); 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->screenWidth = this->width;
frame->screenHeight = this->height; frame->screenHeight = this->height;
frame->dataWidth = this->width;
frame->dataHeight = this->dataHeight;
frame->frameWidth = this->width; frame->frameWidth = this->width;
frame->frameHeight = min(maxHeight, this->height); frame->frameHeight = this->height;
frame->truncated = maxHeight < this->height; frame->truncated = maxHeight < this->height;
frame->pitch = this->width * 4; frame->pitch = this->pitch;
frame->stride = this->width; frame->stride = this->width;
frame->format = CAPTURE_FMT_BGRA; frame->format = CAPTURE_FMT_BGRA;
frame->rotation = CAPTURE_ROT_0; frame->rotation = CAPTURE_ROT_0;
@ -284,8 +290,7 @@ static CaptureResult xcb_waitFrame(CaptureFrame * frame,
return CAPTURE_RESULT_OK; return CAPTURE_RESULT_OK;
} }
static CaptureResult xcb_getFrame(FrameBuffer * frame, static CaptureResult xcb_getFrame(FrameBuffer * frame, int frameIndex)
const unsigned int height, int frameIndex)
{ {
DEBUG_ASSERT(this); DEBUG_ASSERT(this);
DEBUG_ASSERT(this->initialized); DEBUG_ASSERT(this->initialized);
@ -298,7 +303,7 @@ static CaptureResult xcb_getFrame(FrameBuffer * frame,
return CAPTURE_RESULT_ERROR; return CAPTURE_RESULT_ERROR;
} }
framebuffer_write(frame, this->data, this->width * height * 4); framebuffer_write(frame, this->data, this->pitch);
free(img); free(img);
this->hasFrame = false; this->hasFrame = false;

View File

@ -47,7 +47,7 @@ struct pipewire
bool stop; bool stop;
bool hasFormat; bool hasFormat;
bool formatChanged; bool formatChanged;
int width, height; int width, height, dataHeight, pitch;
CaptureFormat format; CaptureFormat format;
bool hdr; bool hdr;
bool hdrPQ; bool hdrPQ;
@ -192,6 +192,9 @@ static void streamParamChangedCallback(void * opaque, uint32_t id,
SPA_VIDEO_FORMAT_RGBA_F16); SPA_VIDEO_FORMAT_RGBA_F16);
this->hdrPQ = true; // this is assumed and untested 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) if (this->hasFormat)
{ {
this->formatChanged = true; this->formatChanged = true;
@ -427,8 +430,8 @@ static CaptureResult pipewire_waitFrame(CaptureFrame * frame,
if (this->stop) if (this->stop)
return CAPTURE_RESULT_REINIT; return CAPTURE_RESULT_REINIT;
const int bpp = this->format == CAPTURE_FMT_RGBA16F ? 8 : 4; const unsigned int maxHeight = maxFrameSize / this->pitch;
const unsigned int maxHeight = maxFrameSize / (this->width * bpp); this->dataHeight = min(maxHeight, this->height);
frame->formatVer = this->formatVer; frame->formatVer = this->formatVer;
frame->format = this->format; frame->format = this->format;
@ -436,10 +439,12 @@ static CaptureResult pipewire_waitFrame(CaptureFrame * frame,
frame->hdrPQ = this->hdrPQ; frame->hdrPQ = this->hdrPQ;
frame->screenWidth = this->width; frame->screenWidth = this->width;
frame->screenHeight = this->height; frame->screenHeight = this->height;
frame->dataWidth = this->width;
frame->dataHeight = this->dataHeight;
frame->frameWidth = this->width; frame->frameWidth = this->width;
frame->frameHeight = min(maxHeight, this->height); frame->frameHeight = this->height;
frame->truncated = maxHeight < this->height; frame->truncated = maxHeight < this->dataHeight;
frame->pitch = this->width * bpp; frame->pitch = this->pitch;
frame->stride = this->width; frame->stride = this->width;
frame->rotation = CAPTURE_ROT_0; frame->rotation = CAPTURE_ROT_0;
@ -449,14 +454,13 @@ static CaptureResult pipewire_waitFrame(CaptureFrame * frame,
return CAPTURE_RESULT_OK; return CAPTURE_RESULT_OK;
} }
static CaptureResult pipewire_getFrame(FrameBuffer * frame, static CaptureResult pipewire_getFrame(FrameBuffer * frame, int frameIndex)
const unsigned int height, int frameIndex)
{ {
if (this->stop || !this->frameData) if (this->stop || !this->frameData)
return CAPTURE_RESULT_REINIT; return CAPTURE_RESULT_REINIT;
const int bpp = this->format == CAPTURE_FMT_RGBA16F ? 8 : 4; framebuffer_write(frame, this->frameData,
framebuffer_write(frame, this->frameData, height * this->width * bpp); this->dataHeight * this->pitch);
pw_thread_loop_accept(this->threadLoop); pw_thread_loop_accept(this->threadLoop);
return CAPTURE_RESULT_OK; return CAPTURE_RESULT_OK;