[all] added new format version field to frame header

This commit is contained in:
Geoffrey McRae
2020-10-12 18:52:37 +11:00
parent 6650e58a4a
commit b2961c7939
7 changed files with 126 additions and 89 deletions

View File

@@ -375,6 +375,10 @@ static int frameThread(void * unused)
LGMP_STATUS status;
PLGMPClientQueue queue;
uint32_t formatVer = 0;
bool formatValid = false;
LG_RendererFormat lgrFormat;
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
lgWaitEvent(e_startup, TIMEOUT_INFINITE);
if (state.state != APP_STATE_RUNNING)
@@ -421,56 +425,61 @@ static int frameThread(void * unused)
KVMFRFrame * frame = (KVMFRFrame *)msg.mem;
// setup the renderer format with the frame format details
LG_RendererFormat lgrFormat;
lgrFormat.type = frame->type;
lgrFormat.width = frame->width;
lgrFormat.height = frame->height;
lgrFormat.stride = frame->stride;
lgrFormat.pitch = frame->pitch;
size_t dataSize;
bool error = false;
switch(frame->type)
if (!formatValid || frame->formatVer != formatVer)
{
case FRAME_TYPE_RGBA:
case FRAME_TYPE_BGRA:
case FRAME_TYPE_RGBA10:
dataSize = lgrFormat.height * lgrFormat.pitch;
lgrFormat.bpp = 32;
break;
// setup the renderer format with the frame format details
lgrFormat.type = frame->type;
lgrFormat.width = frame->width;
lgrFormat.height = frame->height;
lgrFormat.stride = frame->stride;
lgrFormat.pitch = frame->pitch;
case FRAME_TYPE_RGBA16F:
dataSize = lgrFormat.height * lgrFormat.pitch;
lgrFormat.bpp = 64;
break;
size_t dataSize;
bool error = false;
switch(frame->type)
{
case FRAME_TYPE_RGBA:
case FRAME_TYPE_BGRA:
case FRAME_TYPE_RGBA10:
dataSize = lgrFormat.height * lgrFormat.pitch;
lgrFormat.bpp = 32;
break;
case FRAME_TYPE_YUV420:
dataSize = lgrFormat.height * lgrFormat.width;
dataSize += (dataSize / 4) * 2;
lgrFormat.bpp = 12;
break;
case FRAME_TYPE_RGBA16F:
dataSize = lgrFormat.height * lgrFormat.pitch;
lgrFormat.bpp = 64;
break;
default:
DEBUG_ERROR("Unsupported frameType");
error = true;
case FRAME_TYPE_YUV420:
dataSize = lgrFormat.height * lgrFormat.width;
dataSize += (dataSize / 4) * 2;
lgrFormat.bpp = 12;
break;
default:
DEBUG_ERROR("Unsupported frameType");
error = true;
break;
}
if (error)
{
lgmpClientMessageDone(queue);
state.state = APP_STATE_SHUTDOWN;
break;
}
formatValid = true;
formatVer = frame->formatVer;
}
if (error)
if (lgrFormat.width != state.srcSize.x || lgrFormat.height != state.srcSize.y)
{
lgmpClientMessageDone(queue);
state.state = APP_STATE_SHUTDOWN;
break;
}
if (frame->width != state.srcSize.x || frame->height != state.srcSize.y)
{
state.srcSize.x = frame->width;
state.srcSize.y = frame->height;
state.srcSize.x = lgrFormat.width;
state.srcSize.y = lgrFormat.height;
state.haveSrcSize = true;
if (params.autoResize)
SDL_SetWindowSize(state.window, frame->width, frame->height);
SDL_SetWindowSize(state.window, lgrFormat.width, lgrFormat.height);
updatePositionInfo();
}