From c239306d8214eae7f9c04d5d56cc11b45797b8e1 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 29 Dec 2017 21:20:51 +1100 Subject: [PATCH] [client] initial support for compressed frames --- client/lg-renderer.h | 18 +++++++++++++----- client/main.c | 9 +++++---- client/renderers/opengl.c | 24 ++++++++++++++++++------ 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/client/lg-renderer.h b/client/lg-renderer.h index 44875855..ca8fe775 100644 --- a/client/lg-renderer.h +++ b/client/lg-renderer.h @@ -63,13 +63,21 @@ typedef struct LG_RendererParams } LG_RendererParams; +typedef enum LG_RendererComp +{ + LG_COMPRESSION_NONE, + LG_COMPRESSION_H264 +} +LG_RendererComp; + typedef struct LG_RendererFormat { - unsigned int width; // image width - unsigned int height; // image height - unsigned int stride; // scanline width - unsigned int pitch; // scanline bytes - unsigned int bpp; // bits per pixel + LG_RendererComp comp; // compression format + unsigned int width; // image width + unsigned int height; // image height + unsigned int stride; // scanline width (zero if compresed) + unsigned int pitch; // scanline bytes (or compressed size) + unsigned int bpp; // bits per pixel (zero if compressed) } LG_RendererFormat; diff --git a/client/main.c b/client/main.c index 95f86aec..dbdf0bd4 100644 --- a/client/main.c +++ b/client/main.c @@ -309,7 +309,6 @@ int frameThread(void * unused) header.detail.frame.type >= FRAME_TYPE_MAX || header.detail.frame.width == 0 || header.detail.frame.height == 0 || - header.detail.frame.stride == 0 || header.detail.frame.pitch == 0 || header.detail.frame.dataPos == 0 || header.detail.frame.dataPos > state.shmSize || @@ -329,11 +328,13 @@ int frameThread(void * unused) switch(header.detail.frame.type) { case FRAME_TYPE_ARGB: - lgrFormat.bpp = 32; + lgrFormat.comp = LG_COMPRESSION_NONE; + lgrFormat.bpp = 32; break; - case FRAME_TYPE_RGB: - lgrFormat.bpp = 24; + case FRAME_TYPE_H264: + lgrFormat.comp = LG_COMPRESSION_H264; + lgrFormat.bpp = 0; break; default: diff --git a/client/renderers/opengl.c b/client/renderers/opengl.c index 9117c248..93c978d7 100644 --- a/client/renderers/opengl.c +++ b/client/renderers/opengl.c @@ -265,7 +265,13 @@ bool opengl_on_frame_event(void * opaque, const LG_RendererFormat format, const return true; } - if (!this->configured || memcmp(&this->format, &format, sizeof(LG_RendererFormat)) != 0) + if (!this->configured || + this->format.comp != format.comp || + this->format.width != format.width || + this->format.height != format.height || + this->format.stride != format.stride || + this->format.bpp != format.bpp + ) { memcpy(&this->format, &format, sizeof(LG_RendererFormat)); this->reconfigure = true; @@ -543,14 +549,20 @@ static bool configure(struct Inst * this, SDL_Window *window) return false; } - // assume 24 and 32 bit formats are RGB and RGBA - switch(this->format.bpp) + switch(this->format.comp) { - case 24: - this->intFormat = GL_RGB8; - this->vboFormat = GL_BGR; + case LG_COMPRESSION_NONE: break; + case LG_COMPRESSION_H264: + DEBUG_INFO("h264 not supported yet"); + LG_UNLOCK(this->formatLock); + return false; + } + + // assume 32 bit formats are BGRA + switch(this->format.bpp) + { case 32: this->intFormat = GL_RGBA8; this->vboFormat = GL_BGRA;