Do not recreate already initialized codecs

GFX and SurfaceBits commands share a common codec backend.
Recreating all codec context on GFX initialization will break
clients that are decoding SurfaceBits codec while having the GFX
channel initialized.

(cherry picked from commit 91a6ac131370c48a742b8bcc58ad188bb7ed60f8)
This commit is contained in:
Armin Novak 2021-02-05 11:06:23 +01:00 committed by akallabeth
parent 176893e6da
commit 377c61648f
2 changed files with 8 additions and 11 deletions

View File

@ -29,7 +29,7 @@
BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags, UINT32 width, UINT32 height)
{
if ((flags & FREERDP_CODEC_INTERLEAVED))
if ((flags & FREERDP_CODEC_INTERLEAVED) && !codecs->interleaved)
{
bitmap_interleaved_context_free(codecs->interleaved);
@ -40,7 +40,7 @@ BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags, UINT32 width
}
}
if ((flags & FREERDP_CODEC_PLANAR))
if ((flags & FREERDP_CODEC_PLANAR) && !codecs->planar)
{
freerdp_bitmap_planar_context_free(codecs->planar);
@ -51,7 +51,7 @@ BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags, UINT32 width
}
}
if ((flags & FREERDP_CODEC_NSCODEC))
if ((flags & FREERDP_CODEC_NSCODEC) && !codecs->nsc)
{
nsc_context_free(codecs->nsc);
@ -62,7 +62,7 @@ BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags, UINT32 width
}
}
if ((flags & FREERDP_CODEC_REMOTEFX))
if ((flags & FREERDP_CODEC_REMOTEFX) && !codecs->rfx)
{
rfx_context_free(codecs->rfx);
@ -73,7 +73,7 @@ BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags, UINT32 width
}
}
if ((flags & FREERDP_CODEC_CLEARCODEC))
if ((flags & FREERDP_CODEC_CLEARCODEC) && !codecs->clear)
{
clear_context_free(codecs->clear);
@ -84,11 +84,11 @@ BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags, UINT32 width
}
}
if (flags & FREERDP_CODEC_ALPHACODEC)
if ((flags & FREERDP_CODEC_ALPHACODEC))
{
}
if ((flags & FREERDP_CODEC_PROGRESSIVE))
if ((flags & FREERDP_CODEC_PROGRESSIVE) && !codecs->progressive)
{
progressive_context_free(codecs->progressive);
@ -100,7 +100,7 @@ BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags, UINT32 width
}
#ifdef WITH_GFX_H264
if ((flags & (FREERDP_CODEC_AVC420 | FREERDP_CODEC_AVC444)))
if ((flags & (FREERDP_CODEC_AVC420 | FREERDP_CODEC_AVC444)) && !codecs->h264)
{
h264_context_free(codecs->h264);

View File

@ -1475,9 +1475,6 @@ BOOL gdi_graphics_pipeline_init_ex(rdpGdi* gdi, RdpgfxClientContext* gfx,
return FALSE;
context = gdi->context;
freerdp_client_codecs_prepare(context->codecs, FREERDP_CODEC_ALL,
context->settings->DesktopWidth,
context->settings->DesktopHeight);
gdi->gfx = gfx;
gfx->custom = (void*)gdi;