diff --git a/include/freerdp/codecs.h b/include/freerdp/codecs.h index 37661c080..744e5603e 100644 --- a/include/freerdp/codecs.h +++ b/include/freerdp/codecs.h @@ -49,7 +49,9 @@ struct rdp_codecs RFX_CONTEXT* rfx; NSC_CONTEXT* nsc; +#ifdef WITH_GFX_H264 H264_CONTEXT* h264; +#endif CLEAR_CONTEXT* clear; PROGRESSIVE_CONTEXT* progressive; BITMAP_PLANAR_CONTEXT* planar; diff --git a/include/freerdp/gdi/gfx.h b/include/freerdp/gdi/gfx.h index 24de3e0ba..a2e9b0d20 100644 --- a/include/freerdp/gdi/gfx.h +++ b/include/freerdp/gdi/gfx.h @@ -27,7 +27,9 @@ struct gdi_gfx_surface { UINT16 surfaceId; rdpCodecs* codecs; +#ifdef WITH_GFX_H264 H264_CONTEXT *h264; +#endif UINT32 width; UINT32 height; BYTE* data; diff --git a/libfreerdp/codec/h264.c b/libfreerdp/codec/h264.c index 70d615602..91dad1194 100644 --- a/libfreerdp/codec/h264.c +++ b/libfreerdp/codec/h264.c @@ -442,7 +442,7 @@ static BOOL CALLBACK h264_register_subsystems(PINIT_ONCE once, PVOID param, PVOI i++; #endif - return (i > 0); + return TRUE; } @@ -450,13 +450,22 @@ BOOL h264_context_init(H264_CONTEXT* h264) { int i; + if (!h264) + return FALSE; + + h264->subsystem = NULL; + InitOnceExecuteOnce(&subsystems_once, h264_register_subsystems, NULL, NULL); for (i = 0; i < MAX_SUBSYSTEMS; i++) { - if (subSystems[i]->Init(h264)) + const H264_CONTEXT_SUBSYSTEM* subsystem = &subSystems[i]; + if (!subsystem->Init) + break; + + if (subsystem->Init(h264)) { - h264->subsystem = subSystems[i]; + h264->subsystem = subsystem; return TRUE; } } diff --git a/libfreerdp/core/codecs.c b/libfreerdp/core/codecs.c index b07bbd36a..3812eb474 100644 --- a/libfreerdp/core/codecs.c +++ b/libfreerdp/core/codecs.c @@ -88,6 +88,7 @@ BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags, } } +#ifdef WITH_GFX_H264 if ((flags & (FREERDP_CODEC_AVC420 | FREERDP_CODEC_AVC444)) && !codecs->h264) { if (!(codecs->h264 = h264_context_new(FALSE))) @@ -96,6 +97,7 @@ BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags, return FALSE; } } +#endif return freerdp_client_codecs_reset(codecs, flags, width, height); } @@ -157,6 +159,7 @@ BOOL freerdp_client_codecs_reset(rdpCodecs* codecs, UINT32 flags, UINT32 width, } } +#ifdef WITH_GFX_H264 if (flags & (FREERDP_CODEC_AVC420 | FREERDP_CODEC_AVC444)) { if (codecs->h264) @@ -164,6 +167,7 @@ BOOL freerdp_client_codecs_reset(rdpCodecs* codecs, UINT32 flags, UINT32 width, rc &= h264_context_reset(codecs->h264, width, height); } } +#endif return rc; } @@ -196,11 +200,13 @@ void codecs_free(rdpCodecs* codecs) codecs->nsc = NULL; } +#ifdef WITH_GFX_H264 if (codecs->h264) { h264_context_free(codecs->h264); codecs->h264 = NULL; } +#endif if (codecs->clear) { diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index a78a2a152..d067ae124 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -402,6 +402,7 @@ static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi, RdpgfxClientContext* context, const RDPGFX_SURFACE_COMMAND* cmd) { +#ifdef WITH_GFX_H264 INT32 rc; UINT status = CHANNEL_RC_OK; UINT32 i; @@ -460,6 +461,9 @@ static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi, } return status; +#else + return ERROR_NOT_SUPPORTED; +#endif } /** @@ -470,6 +474,7 @@ static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi, static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context, const RDPGFX_SURFACE_COMMAND* cmd) { +#ifdef WITH_GFX_H264 INT32 rc; UINT status = CHANNEL_RC_OK; UINT32 i; @@ -547,6 +552,9 @@ static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context, free(regionRects); return status; +#else + return ERROR_NOT_SUPPORTED; +#endif } /** @@ -814,7 +822,9 @@ static UINT gdi_DeleteSurface(RdpgfxClientContext* context, if (surface) { +#ifdef WITH_GFX_H264 h264_context_free(surface->h264); +#endif region16_uninit(&surface->invalidRegion); codecs = surface->codecs; _aligned_free(surface->data);