Fixed clear codec reset and test cases.

This commit is contained in:
Armin Novak 2018-09-19 14:10:50 +02:00
parent 712a39898c
commit 7e8d128fc6
2 changed files with 30 additions and 29 deletions

View File

@ -878,7 +878,10 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
{
WLog_ERR(TAG, "vBarEntry->count %"PRIu32" != vBarHeight %"PRIu32"", vBarEntry->count,
vBarHeight);
return FALSE;
vBarEntry->count = vBarHeight;
if (!resize_vbar_entry(clear, vBarEntry))
return FALSE;
}
nXDstRel = nXDst + xStart;
@ -1182,13 +1185,6 @@ BOOL clear_context_reset(CLEAR_CONTEXT* clear)
return FALSE;
clear->seqNumber = 0;
clear->VBarStorageCursor = 0;
clear->ShortVBarStorageCursor = 0;
if (clear->nsc)
nsc_context_reset(clear->nsc, clear->nsc->width, clear->nsc->height);
memset(clear->TempBuffer, 0, clear->TempSize);
return TRUE;
}
CLEAR_CONTEXT* clear_context_new(BOOL Compressor)

View File

@ -3,8 +3,13 @@
#include <freerdp/codec/clear.h>
static const BYTE TEST_CLEAR_EXAMPLE_1[] = "\x03\xc3\x11\x00";
/* [MS-RDPEGFX] 4.1.1.1 Example 1 */
static const BYTE PREPARE_CLEAR_EXAMPLE_1[] =
"\x03\xc3\x11\x00";
static const BYTE TEST_CLEAR_EXAMPLE_1[] =
"\x03\xc3\x11\x00";
/* [MS-RDPEGFX] 4.1.1.1 Example 2 */
static const BYTE TEST_CLEAR_EXAMPLE_2[] =
"\x00\x0d\x00\x00\x00\x00\x00\x00\x00\x00\x82\x00\x00\x00\x00\x00"
"\x00\x00\x4e\x00\x11\x00\x75\x00\x00\x00\x02\x0e\xff\xff\xff\x00"
@ -16,6 +21,7 @@ static const BYTE TEST_CLEAR_EXAMPLE_2[] =
"\x01\x00\x00\x4a\x0a\x00\x09\x00\x01\x00\x00\x47\x05\x00\x01\x01"
"\x1c\x00\x01\x00\x11\x4c\x11\x4c\x11\x4c\x00\x47\x0d\x4d\x00\x4d";
/* [MS-RDPEGFX] 4.1.1.1 Example 3 */
static const BYTE TEST_CLEAR_EXAMPLE_3[] =
"\x00\xdf\x0e\x00\x00\x00\x8b\x00\x00\x00\x00\x00\x00\x00\xfe\xfe"
"\xfe\xff\x80\x05\xff\xff\xff\x40\xfe\xfe\xfe\x40\x00\x00\x3f\x00"
@ -29,6 +35,7 @@ static const BYTE TEST_CLEAR_EXAMPLE_3[] =
"\xd0\xba\xd0\xbb\xd0\xbc\xd0\xbd\xd0\xbe\xd0\xbf\xd0\xc0\xd0\xc1"
"\xd0\xc2\xd0\xc3\xd0\xc4\xd0";
/* [MS-RDPEGFX] 4.1.1.1 Example 4 */
static const BYTE TEST_CLEAR_EXAMPLE_4[] =
"\x01\x0b\x78\x00\x00\x00\x00\x00\x46\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x06\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x0f\xff\xff\xff"
@ -38,48 +45,46 @@ static const BYTE TEST_CLEAR_EXAMPLE_4[] =
"\x49\x91\x4a\x91\x1b\x91";
static BOOL test_ClearDecompressExample(UINT32 nr, const BYTE* pSrcData,
static BOOL test_ClearDecompressExample(UINT32 nr, UINT32 width, UINT32 height,
const BYTE* pSrcData,
const UINT32 SrcSize)
{
BOOL rc = FALSE;
int status;
BYTE pDstData[65536];
BYTE* pDstData = calloc(width * height, 4);
CLEAR_CONTEXT* clear = clear_context_new(FALSE);
if (!clear)
return FALSE;
if (!clear || !pDstData)
goto fail;
status = clear_decompress(clear, pSrcData, SrcSize, 128, 128,
pDstData, PIXEL_FORMAT_XRGB32, 0, 1, 1, 128, 128,
status = clear_decompress(clear, pSrcData, SrcSize, width, height,
pDstData, PIXEL_FORMAT_XRGB32, 0, 1, 1, width, height,
NULL);
printf("clear_decompress example %"PRIu32" status: %d\n", nr, status);
fflush(stdout);
rc = (status == 0);
fail:
clear_context_free(clear);
#if 0
if (status != 0)
return FALSE;
#else
fprintf(stderr, "%s: TODO Test %"PRIu32" not working!!!\n", __FUNCTION__, nr);
#endif
return TRUE;
free(pDstData);
return rc;
}
int TestFreeRDPCodecClear(int argc, char* argv[])
{
if (!test_ClearDecompressExample(1, TEST_CLEAR_EXAMPLE_1,
/* Example 1 needs a filled glyph cache
if (!test_ClearDecompressExample(1, 8, 9, TEST_CLEAR_EXAMPLE_1,
sizeof(TEST_CLEAR_EXAMPLE_1)))
return -1;
if (!test_ClearDecompressExample(2, TEST_CLEAR_EXAMPLE_2,
*/
if (!test_ClearDecompressExample(2, 78, 17, TEST_CLEAR_EXAMPLE_2,
sizeof(TEST_CLEAR_EXAMPLE_2)))
return -1;
if (!test_ClearDecompressExample(3, TEST_CLEAR_EXAMPLE_3,
if (!test_ClearDecompressExample(3, 64, 24, TEST_CLEAR_EXAMPLE_3,
sizeof(TEST_CLEAR_EXAMPLE_3)))
return -1;
if (!test_ClearDecompressExample(4, TEST_CLEAR_EXAMPLE_4,
if (!test_ClearDecompressExample(4, 7, 15, TEST_CLEAR_EXAMPLE_4,
sizeof(TEST_CLEAR_EXAMPLE_4)))
return -1;