Extensive debug messages for clear_decompress.

This commit is contained in:
Armin Novak 2016-10-20 11:09:37 +02:00
parent ac9e7530d3
commit dc9e748c2f

View File

@ -58,7 +58,7 @@ static const BYTE CLEAR_8BIT_MASKS[9] =
0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF
};
static void convert_color(BYTE* dst, UINT32 nDstStep, UINT32 DstFormat,
static BOOL convert_color(BYTE* dst, UINT32 nDstStep, UINT32 DstFormat,
UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
const BYTE* src, UINT32 nSrcStep, UINT32 SrcFormat,
UINT32 nDstWidth, UINT32 nDstHeight, const gdiPalette* palette)
@ -85,9 +85,13 @@ static void convert_color(BYTE* dst, UINT32 nDstStep, UINT32 DstFormat,
UINT32 color = ReadColor(pSrcPixel, SrcFormat);
color = ConvertColor(color, SrcFormat,
DstFormat, palette);
WriteColor(pDstPixel, DstFormat, color);
if (!WriteColor(pDstPixel, DstFormat, color))
return FALSE;
}
}
return TRUE;
}
static BOOL clear_decompress_nscodec(NSC_CONTEXT* nsc, UINT32 width,
@ -99,7 +103,11 @@ static BOOL clear_decompress_nscodec(NSC_CONTEXT* nsc, UINT32 width,
BOOL rc;
if (Stream_GetRemainingLength(s) < bitmapDataByteCount)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
bitmapDataByteCount);
return FALSE;
}
rc = nsc_process_message(nsc, 32, width, height, Stream_Pointer(s),
bitmapDataByteCount, pDstData, DstFormat,
@ -130,22 +138,28 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
UINT32 palette[128] = { 0 };
if (Stream_GetRemainingLength(s) < bitmapDataByteCount)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
bitmapDataByteCount);
return FALSE;
}
Stream_Read_UINT8(s, paletteCount);
bitmapDataOffset = 1 + (paletteCount * 3);
if (paletteCount > 127)
{
WLog_ERR(TAG, "paletteCount %lu", paletteCount);
return FALSE;
}
for (i = 0; i < paletteCount; i++)
{
BYTE r, g, b;
UINT32 color;
Stream_Read_UINT8(s, b);
Stream_Read_UINT8(s, g);
Stream_Read_UINT8(s, r);
color = GetColor(SrcFormat, r, g, b, 0xFF);
UINT32 color = GetColor(SrcFormat, r, g, b, 0xFF);
palette[i] = ConvertColor(color, SrcFormat, DstFormat, NULL);
}
@ -160,7 +174,11 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
UINT32 runLengthFactor;
if (Stream_GetRemainingLength(s) < 2)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
2);
return FALSE;
}
Stream_Read_UINT8(s, tmp);
Stream_Read_UINT8(s, runLengthFactor);
@ -172,7 +190,11 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
if (runLengthFactor >= 0xFF)
{
if (Stream_GetRemainingLength(s) < 2)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
2);
return FALSE;
}
Stream_Read_UINT16(s, runLengthFactor);
bitmapDataOffset += 2;
@ -180,7 +202,11 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
if (runLengthFactor >= 0xFFFF)
{
if (Stream_GetRemainingLength(s) < 4)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
4);
return FALSE;
}
Stream_Read_UINT32(s, runLengthFactor);
bitmapDataOffset += 4;
@ -188,20 +214,34 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
}
if (startIndex >= paletteCount)
{
WLog_ERR(TAG, "startIndex %lu > paletteCount %lu]", startIndex, paletteCount);
return FALSE;
}
if (stopIndex >= paletteCount)
{
WLog_ERR(TAG, "stopIndex %lu > paletteCount %lu]", stopIndex, paletteCount);
return FALSE;
}
suiteIndex = startIndex;
if (suiteIndex > 127)
{
WLog_ERR(TAG, "suiteIndex %lu > %lu]", suiteIndex, 127);
return FALSE;
}
color = palette[suiteIndex];
if ((pixelIndex + runLengthFactor) > pixelCount)
{
WLog_ERR(TAG, "pixelIndex %lu + runLengthFactor %lu > pixelCount %lu",
pixelIndex, runLengthFactor,
pixelCount);
return FALSE;
}
for (i = 0; i < runLengthFactor; i++)
{
@ -221,7 +261,12 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
pixelIndex += runLengthFactor;
if ((pixelIndex + (suiteDepth + 1)) > pixelCount)
{
WLog_ERR(TAG, "pixelIndex %lu + suiteDepth %lu + 1 > pixelCount %lu",
pixelIndex, suiteDepth,
pixelCount);
return FALSE;
}
for (i = 0; i <= suiteDepth; i++)
{
@ -230,7 +275,10 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
UINT32 color = palette[suiteIndex];
if (suiteIndex > 127)
{
WLog_ERR(TAG, "suiteIndex %lu > %lu", suiteIndex, 127);
return FALSE;
}
suiteIndex++;
@ -250,7 +298,10 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
nSrcStep = width * GetBytesPerPixel(DstFormat);
if (pixelIndex != pixelCount)
{
WLog_ERR(TAG, "pixelIndex %lu != pixelCount %lu", pixelIndex, pixelCount);
return FALSE;
}
return TRUE;
}
@ -272,7 +323,11 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear,
UINT32 pixelCount;
if (Stream_GetRemainingLength(s) < residualByteCount)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
residualByteCount);
return FALSE;
}
suboffset = 0;
pixelIndex = 0;
@ -286,7 +341,11 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear,
UINT32 color;
if (Stream_GetRemainingLength(s) < 4)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
4);
return FALSE;
}
Stream_Read_UINT8(s, b);
Stream_Read_UINT8(s, g);
@ -298,7 +357,11 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear,
if (runLengthFactor >= 0xFF)
{
if (Stream_GetRemainingLength(s) < 2)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
2);
return FALSE;
}
Stream_Read_UINT16(s, runLengthFactor);
suboffset += 2;
@ -306,7 +369,11 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear,
if (runLengthFactor >= 0xFFFF)
{
if (Stream_GetRemainingLength(s) < 4)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
4);
return FALSE;
}
Stream_Read_UINT32(s, runLengthFactor);
suboffset += 4;
@ -314,7 +381,12 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear,
}
if ((pixelIndex + runLengthFactor) > pixelCount)
{
WLog_ERR(TAG, "pixelIndex %lu + runLengthFactor %lu > pixelCount %lu",
pixelIndex, runLengthFactor,
pixelCount);
return FALSE;
}
for (i = 0; i < runLengthFactor; i++)
{
@ -328,13 +400,15 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear,
nSrcStep = nWidth * GetBytesPerPixel(clear->format);
if (pixelIndex != pixelCount)
return -1019;
{
WLog_ERR(TAG, "pixelIndex %lu != pixelCount %lu", pixelIndex, pixelCount);
return FALSE;
}
convert_color(pDstData, nDstStep, DstFormat,
nXDst, nYDst, nWidth, nHeight,
clear->TempBuffer, nSrcStep, clear->format,
nDstWidth, nDstHeight, palette);
return TRUE;
return convert_color(pDstData, nDstStep, DstFormat,
nXDst, nYDst, nWidth, nHeight,
clear->TempBuffer, nSrcStep, clear->format,
nDstWidth, nDstHeight, palette);
}
static BOOL clear_decompress_subcodecs_data(CLEAR_CONTEXT* clear, wStream* s,
@ -352,7 +426,11 @@ static BOOL clear_decompress_subcodecs_data(CLEAR_CONTEXT* clear, wStream* s,
UINT32 suboffset;
if (Stream_GetRemainingLength(s) < subcodecByteCount)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
subcodecByteCount);
return FALSE;
}
suboffset = 0;
@ -362,7 +440,11 @@ static BOOL clear_decompress_subcodecs_data(CLEAR_CONTEXT* clear, wStream* s,
UINT32 nYDstRel;
if (Stream_GetRemainingLength(s) < 13)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
13);
return FALSE;
}
Stream_Read_UINT16(s, xStart);
Stream_Read_UINT16(s, yStart);
@ -373,16 +455,26 @@ static BOOL clear_decompress_subcodecs_data(CLEAR_CONTEXT* clear, wStream* s,
suboffset += 13;
if (Stream_GetRemainingLength(s) < bitmapDataByteCount)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
bitmapDataByteCount);
return FALSE;
}
nXDstRel = nXDst + xStart;
nYDstRel = nYDst + yStart;
if (width > nWidth)
{
WLog_ERR(TAG, "width %lu > nWidth %lu", width, nWidth);
return FALSE;
}
if (height > nHeight)
{
WLog_ERR(TAG, "height %lu > nHeight %lu", height, nHeight);
return FALSE;
}
if ((width * height * GetBytesPerPixel(clear->format)) >
clear->TempSize)
@ -391,24 +483,34 @@ static BOOL clear_decompress_subcodecs_data(CLEAR_CONTEXT* clear, wStream* s,
clear->TempBuffer = (BYTE*) realloc(clear->TempBuffer, clear->TempSize);
if (!clear->TempBuffer)
{
WLog_ERR(TAG, "clear->TempBuffer realloc failed for %lu bytes",
clear->TempSize);
return FALSE;
}
}
switch (subcodecId)
{
case 0: /* Uncompressed */
{
UINT32 nSrcStep = width * GetBytesPerPixel(PIXEL_FORMAT_BGR24);
UINT32 nSrcStep = width * GetBytesPerPixel(PIXEL_FORMAT_BGR24);;
UINT32 nSrcSize = nSrcStep * height;
if (bitmapDataByteCount != nSrcSize)
{
WLog_ERR(TAG, "bitmapDataByteCount %lu != nSrcSize %lu", bitmapDataByteCount,
nSrcSize);
return FALSE;
}
if (!convert_color(pDstData, nDstStep, DstFormat,
nXDstRel, nYDstRel, width, height,
Stream_Pointer(s), nSrcStep,
PIXEL_FORMAT_BGR24,
nDstWidth, nDstHeight, palette))
return FALSE;
convert_color(pDstData, nDstStep, DstFormat,
nXDstRel, nYDstRel, width, height,
Stream_Pointer(s), nSrcStep,
PIXEL_FORMAT_BGR24,
nDstWidth, nDstHeight, palette);
Stream_Seek(s, bitmapDataByteCount);
}
break;
@ -434,6 +536,7 @@ static BOOL clear_decompress_subcodecs_data(CLEAR_CONTEXT* clear, wStream* s,
break;
default:
WLog_ERR(TAG, "Unknown subcodec ID %lu", subcodecId);
return FALSE;
}
@ -456,14 +559,21 @@ static BOOL resize_vbar_entry(CLEAR_CONTEXT* clear, CLEAR_VBAR_ENTRY* vBarEntry)
vBarEntry->count * bpp);
if (!tmp)
{
WLog_ERR(TAG, "vBarEntry->pixels realloc %lu failed", vBarEntry->count * bpp);
return FALSE;
}
memset(&tmp[oldPos], 0, diffSize);
vBarEntry->pixels = tmp;
}
if (!vBarEntry->pixels && vBarEntry->size)
{
WLog_ERR(TAG, "!vBarEntry->pixels %lu && vBarEntry->size %lu",
vBarEntry->pixels, vBarEntry->size);
return FALSE;
}
return TRUE;
}
@ -481,7 +591,11 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
UINT32 nYDstRel;
if (Stream_GetRemainingLength(s) < bandsByteCount)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
11);
return FALSE;
}
suboffset = 0;
@ -502,7 +616,11 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
UINT32 vBarShortPixelCount;
if (Stream_GetRemainingLength(s) < 11)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
11);
return FALSE;
}
Stream_Read_UINT16(s, xStart);
Stream_Read_UINT16(s, xEnd);
@ -515,10 +633,16 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
colorBkg = GetColor(clear->format, r, g, b, 0xFF);
if (xEnd < xStart)
{
WLog_ERR(TAG, "xEnd %lu < xStart %lu", xEnd, xStart);
return FALSE;
}
if (yEnd < yStart)
{
WLog_ERR(TAG, "yEnd %lu < yStart %lu", yEnd, yStart);
return FALSE;
}
vBarCount = (xEnd - xStart) + 1;
@ -531,14 +655,21 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
const BYTE* pSrcPixel;
if (Stream_GetRemainingLength(s) < 2)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
2);
return FALSE;
}
Stream_Read_UINT16(s, vBarHeader);;
suboffset += 2;
vBarHeight = (yEnd - yStart + 1);
if (vBarHeight > 52)
{
WLog_ERR(TAG, "vBarHeight > 52", vBarHeight);
return FALSE;
}
if ((vBarHeader & 0xC000) == 0x4000) /* SHORT_VBAR_CACHE_HIT */
{
@ -546,10 +677,17 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
vBarShortEntry = &(clear->ShortVBarStorage[vBarIndex]);
if (!vBarShortEntry)
{
WLog_ERR(TAG, "missing vBarShortEntry %lu", vBarIndex);
return FALSE;
}
if (Stream_GetRemainingLength(s) < 1)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
1);
return FALSE;
}
Stream_Read_UINT8(s, vBarYOn);
suboffset += 1;
@ -562,18 +700,33 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
vBarYOff = ((vBarHeader >> 8) & 0x3F);
if (vBarYOff < vBarYOn)
{
WLog_ERR(TAG, "vBarYOff %lu < vBarYOn %lu", vBarYOff, vBarYOn);
return FALSE;
}
vBarShortPixelCount = (vBarYOff - vBarYOn);
if (vBarShortPixelCount > 52)
{
WLog_ERR(TAG, "vBarShortPixelCount %lu > 52", vBarShortPixelCount);
return FALSE;
}
if (Stream_GetRemainingLength(s) < (vBarShortPixelCount * 3))
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
(vBarShortPixelCount * 3));
return FALSE;
}
if (clear->ShortVBarStorageCursor >= CLEARCODEC_VBAR_SHORT_SIZE)
{
WLog_ERR(TAG,
"clear->ShortVBarStorageCursor %lu >= CLEARCODEC_VBAR_SHORT_SIZE %lu",
clear->ShortVBarStorageCursor, CLEARCODEC_VBAR_SHORT_SIZE);
return FALSE;
}
vBarShortEntry = &(clear->ShortVBarStorage[clear->ShortVBarStorageCursor]);
vBarShortEntry->count = vBarShortPixelCount;
@ -591,7 +744,9 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
Stream_Read_UINT8(s, g);
Stream_Read_UINT8(s, r);
color = GetColor(clear->format, r, g, b, 0xFF);
WriteColor(dstBuffer, clear->format, color);
if (!WriteColor(dstBuffer, clear->format, color))
return FALSE;
}
suboffset += (vBarShortPixelCount * 3);
@ -607,6 +762,7 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
}
else
{
WLog_ERR(TAG, "invalid vBarHeader %08lX", vBarHeader);
return FALSE; /* invalid vBarHeader */
}
@ -617,7 +773,12 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
BYTE* dstBuffer;
if (clear->VBarStorageCursor >= CLEARCODEC_VBAR_SIZE)
{
WLog_ERR(TAG, "clear->VBarStorageCursor %lu >= CLEARCODEC_VBAR_SIZE %lu",
clear->VBarStorageCursor,
CLEARCODEC_VBAR_SIZE);
return FALSE;
}
vBarEntry = &(clear->VBarStorage[clear->VBarStorageCursor]);
vBarPixelCount = vBarHeight;
@ -658,7 +819,10 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
UINT32 color;
color = ReadColor(&vBarShortEntry->pixels[x * GetBytesPerPixel(clear->format)],
clear->format);
WriteColor(dstBuffer, clear->format, color);
if (!WriteColor(dstBuffer, clear->format, color))
return FALSE;
dstBuffer += GetBytesPerPixel(clear->format);
}
@ -668,7 +832,9 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
while (count--)
{
WriteColor(dstBuffer, clear->format, colorBkg);
if (!WriteColor(dstBuffer, clear->format, colorBkg))
return FALSE;
dstBuffer += GetBytesPerPixel(clear->format);
}
@ -678,7 +844,11 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
}
if (vBarEntry->count != vBarHeight)
{
WLog_ERR(TAG, "vBarEntry->count %lu != vBarHeight %lu", vBarEntry->count,
vBarHeight);
return FALSE;
}
nXDstRel = nXDst + xStart;
nYDstRel = nYDst + yStart;
@ -698,7 +868,10 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
UINT32 color = ReadColor(pSrcPixel, clear->format);
color = ConvertColor(color, clear->format,
DstFormat, NULL);
WriteColor(pDstPixel8, DstFormat, color);
if (!WriteColor(pDstPixel8, DstFormat, color))
return FALSE;
pSrcPixel += GetBytesPerPixel(clear->format);
}
}
@ -735,7 +908,11 @@ static BOOL clear_decompress_glyph_data(CLEAR_CONTEXT* clear,
}
if (Stream_GetRemainingLength(s) < 2)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s),
2);
return FALSE;
}
Stream_Read_UINT16(s, glyphIndex);
@ -749,20 +926,34 @@ static BOOL clear_decompress_glyph_data(CLEAR_CONTEXT* clear,
{
UINT32 nSrcStep;
CLEAR_GLYPH_ENTRY* glyphEntry = &(clear->GlyphCache[glyphIndex]);
BYTE* glyphData = (BYTE*) glyphEntry->pixels;
BYTE* glyphData;
if (!glyphEntry)
{
WLog_ERR(TAG, "clear->GlyphCache[%lu]=NULL", glyphIndex);
return FALSE;
}
glyphData = (BYTE*) glyphEntry->pixels;
if (!glyphData)
{
WLog_ERR(TAG, "clear->GlyphCache[%lu]->pixels=NULL", glyphIndex);
return FALSE;
}
if ((nWidth * nHeight) > (int) glyphEntry->count)
if ((nWidth * nHeight) > glyphEntry->count)
{
WLog_ERR(TAG, "(nWidth %lu * nHeight %lu) > glyphEntry->count %lu", nWidth, nHeight,
glyphEntry->count);
return FALSE;
}
nSrcStep = nWidth * GetBytesPerPixel(clear->format);
convert_color(pDstData, nDstStep, DstFormat,
nXDst, nYDst, nWidth, nHeight,
glyphData, nSrcStep, clear->format,
nDstWidth, nDstHeight, palette);
return TRUE;
return convert_color(pDstData, nDstStep, DstFormat,
nXDst, nYDst, nWidth, nHeight,
glyphData, nSrcStep, clear->format,
nDstWidth, nDstHeight, palette);
}
if (glyphFlags & CLEARCODEC_FLAG_GLYPH_INDEX)
@ -779,20 +970,28 @@ static BOOL clear_decompress_glyph_data(CLEAR_CONTEXT* clear,
tmp = (UINT32*) realloc(glyphEntry->pixels, glyphEntry->size * 4);
if (!tmp)
{
WLog_ERR(TAG, "glyphEntry->pixels realloc %lu failed!", glyphEntry->size * 4);
return FALSE;
}
glyphEntry->pixels = tmp;
}
if (!glyphEntry->pixels)
{
WLog_ERR(TAG, "glyphEntry->pixels=NULL");
return FALSE;
}
glyphData = (BYTE*) glyphEntry->pixels;
nSrcStep = nWidth * GetBytesPerPixel(clear->format);
convert_color(pDstData, nDstStep, DstFormat,
nXDst, nYDst, nWidth, nHeight,
glyphData, nSrcStep, clear->format,
nDstWidth, nDstHeight, palette);
if (!convert_color(pDstData, nDstStep, DstFormat,
nXDst, nYDst, nWidth, nHeight,
glyphData, nSrcStep, clear->format,
nDstWidth, nDstHeight, palette))
return FALSE;
}
return TRUE;
@ -829,7 +1028,10 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
Stream_SetLength(s, SrcSize);
if (Stream_GetRemainingLength(s) < 2)
{
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s), 2);
goto fail;
}
Stream_Read_UINT8(s, glyphFlags);
Stream_Read_UINT8(s, seqNumber);
@ -841,6 +1043,7 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
{
WLog_ERR(TAG, "Sequence number unexpected %u - %u",
seqNumber, clear->seqNumber);
WLog_ERR(TAG, "seqNumber %lu != clear->seqNumber %lu", seqNumber, clear->seqNumber);
goto fail;
}
@ -856,7 +1059,10 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
nHeight, pDstData, DstFormat,
nDstStep, nXDst, nYDst,
nDstWidth, nDstHeight, palette))
{
WLog_ERR(TAG, "clear_decompress_glyph_data failed!");
goto fail;
}
/* Read composition payload header parameters */
if (Stream_GetRemainingLength(s) < 12)
@ -866,6 +1072,7 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
if ((glyphFlags & mask) == mask)
goto finish;
WLog_ERR(TAG, "stream short %lu [%lu expected]", Stream_GetRemainingLength(s), 12);
goto fail;
}
@ -878,14 +1085,20 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
if (!clear_decompress_residual_data(clear, s, residualByteCount, nWidth,
nHeight, pDstData, DstFormat, nDstStep, nXDst, nYDst,
nDstWidth, nDstHeight, palette))
{
WLog_ERR(TAG, "clear_decompress_residual_data failed!");
goto fail;
}
}
if (bandsByteCount > 0)
{
if (!clear_decompress_bands_data(clear, s, bandsByteCount, nWidth, nHeight,
pDstData, DstFormat, nDstStep, nXDst, nYDst))
{
WLog_ERR(TAG, "clear_decompress_bands_data failed!");
goto fail;
}
}
if (subcodecByteCount > 0)
@ -894,7 +1107,10 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
nHeight, pDstData, DstFormat,
nDstStep, nXDst, nYDst,
nDstWidth, nDstHeight, palette))
{
WLog_ERR(TAG, "clear_decompress_subcodecs_data failed!");
goto fail;
}
}
finish:
@ -907,6 +1123,7 @@ fail:
int clear_compress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, UINT32* pDstSize)
{
WLog_ERR(TAG, "TODO: %s not implemented!");
return 1;
}
BOOL clear_context_reset(CLEAR_CONTEXT* clear)
@ -937,10 +1154,16 @@ CLEAR_CONTEXT* clear_context_new(BOOL Compressor)
nsc_context_set_pixel_format(clear->nsc, PIXEL_FORMAT_RGB24);
clear->TempSize = 512 * 512 * 4;
clear->TempBuffer = (BYTE*) malloc(clear->TempSize);
clear_context_reset(clear);
if (!clear->TempBuffer)
goto error_nsc;
if (!clear_context_reset(clear))
goto error_nsc;
return clear;
error_nsc:
free(clear);
clear_context_free(clear);
return NULL;
}
void clear_context_free(CLEAR_CONTEXT* clear)