Skip to content

Commit

Permalink
Clear codec internal format: keep API compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
akallabeth committed Dec 12, 2016
1 parent 39b08eb commit 1a149e5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions include/freerdp/codec/clear.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct _CLEAR_GLYPH_ENTRY
{
UINT32 size;
UINT32 count;
BYTE* pixels;
UINT32* pixels;
};
typedef struct _CLEAR_GLYPH_ENTRY CLEAR_GLYPH_ENTRY;

Expand Down Expand Up @@ -83,7 +83,7 @@ FREERDP_API INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,

FREERDP_API BOOL clear_context_reset(CLEAR_CONTEXT* clear);

FREERDP_API CLEAR_CONTEXT* clear_context_new(BOOL Compressor, UINT32 format);
FREERDP_API CLEAR_CONTEXT* clear_context_new(BOOL Compressor);
FREERDP_API void clear_context_free(CLEAR_CONTEXT* clear);

#ifdef __cplusplus
Expand Down
23 changes: 18 additions & 5 deletions libfreerdp/codec/clear.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ static BOOL clear_decompress_glyph_data(CLEAR_CONTEXT* clear,
return FALSE;
}

glyphEntry->pixels = tmp;
glyphEntry->pixels = (UINT32*)tmp;
}

if (!glyphEntry->pixels)
Expand All @@ -984,14 +984,23 @@ static BOOL clear_decompress_glyph_data(CLEAR_CONTEXT* clear,
}

if (ppGlyphData)
*ppGlyphData = glyphEntry->pixels;
*ppGlyphData = (BYTE*)glyphEntry->pixels;

return TRUE;
}

return TRUE;
}

static INLINE BOOL updateContextFormat(CLEAR_CONTEXT* clear, UINT32 DstFormat)
{
if (!clear || !clear->nsc)
return FALSE;

clear->format = DstFormat;
return nsc_context_set_pixel_format(clear->nsc, DstFormat);
}

INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
UINT32 SrcSize, UINT32 nWidth, UINT32 nHeight,
BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
Expand Down Expand Up @@ -1029,6 +1038,9 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
goto fail;
}

if (!updateContextFormat(clear, DstFormat))
goto fail;

Stream_Read_UINT8(s, glyphFlags);
Stream_Read_UINT8(s, seqNumber);

Expand Down Expand Up @@ -1140,7 +1152,7 @@ BOOL clear_context_reset(CLEAR_CONTEXT* clear)
clear->ShortVBarStorageCursor = 0;
return TRUE;
}
CLEAR_CONTEXT* clear_context_new(BOOL Compressor, UINT32 format)
CLEAR_CONTEXT* clear_context_new(BOOL Compressor)
{
CLEAR_CONTEXT* clear;
clear = (CLEAR_CONTEXT*) calloc(1, sizeof(CLEAR_CONTEXT));
Expand All @@ -1150,12 +1162,13 @@ CLEAR_CONTEXT* clear_context_new(BOOL Compressor, UINT32 format)

clear->Compressor = Compressor;
clear->nsc = nsc_context_new();
clear->format = format;

if (!clear->nsc)
goto error_nsc;

nsc_context_set_pixel_format(clear->nsc, format);
if (!updateContextFormat(clear, PIXEL_FORMAT_BGRX32))
goto error_nsc;

clear->TempSize = 512 * 512 * 4;
clear->TempBuffer = (BYTE*) malloc(clear->TempSize);

Expand Down
2 changes: 1 addition & 1 deletion libfreerdp/codec/test/TestFreeRDPCodecClear.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static BOOL test_ClearDecompressExample(UINT32 nr, const BYTE* pSrcData,
{
int status;
BYTE pDstData[16384];
CLEAR_CONTEXT* clear = clear_context_new(FALSE, PIXEL_FORMAT_BGRA32);
CLEAR_CONTEXT* clear = clear_context_new(FALSE);

if (!clear)
return FALSE;
Expand Down
5 changes: 1 addition & 4 deletions libfreerdp/core/codecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "rdp.h"

#include <freerdp/codecs.h>
#include <freerdp/gdi/gdi.h>

#define TAG FREERDP_TAG("core.codecs")

Expand Down Expand Up @@ -69,9 +68,7 @@ BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags,

if ((flags & FREERDP_CODEC_CLEARCODEC) && !codecs->clear)
{
const UINT32 format = codecs->context->gdi->dstFormat;

if (!(codecs->clear = clear_context_new(FALSE, format)))
if (!(codecs->clear = clear_context_new(FALSE)))
{
WLog_ERR(TAG, "Failed to create clear codec context");
return FALSE;
Expand Down

0 comments on commit 1a149e5

Please sign in to comment.