More color fixes.

This commit is contained in:
Armin Novak 2016-04-11 14:14:17 +02:00
parent df35c135d1
commit 24599af991
14 changed files with 839 additions and 1022 deletions

View File

@ -1175,15 +1175,18 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
return FALSE; return FALSE;
} }
nsc_process_message(xfc->codecs->nsc, cmd->bpp, cmd->width, cmd->height, if (!nsc_process_message(xfc->codecs->nsc, cmd->bpp, cmd->width, cmd->height,
cmd->bitmapData, cmd->bitmapDataLength); cmd->bitmapData, cmd->bitmapDataLength,
xfc->bitmap_buffer, xfc->format, 0, 0, 0, cmd->width, cmd->height))
{
xf_unlock_x11(xfc, FALSE);
return FALSE;
}
XSetFunction(xfc->display, xfc->gc, GXcopy); XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetFillStyle(xfc->display, xfc->gc, FillSolid);
pSrcData = xfc->codecs->nsc->BitmapData; pSrcData = xfc->codecs->nsc->BitmapData;
pDstData = xfc->bitmap_buffer; pDstData = xfc->bitmap_buffer;
freerdp_image_copy(pDstData, xfc->format, -1, 0, 0,
cmd->width, cmd->height, pSrcData,
PIXEL_FORMAT_BGRX32_VF, -1, 0, 0, xfc->palette);
image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
(char*) pDstData, cmd->width, cmd->height, xfc->scanline_pad, 0); (char*) pDstData, cmd->width, cmd->height, xfc->scanline_pad, 0);
XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0, XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0,

View File

@ -55,6 +55,8 @@ struct _CLEAR_CONTEXT
UINT32 seqNumber; UINT32 seqNumber;
BYTE* TempBuffer; BYTE* TempBuffer;
UINT32 TempSize; UINT32 TempSize;
UINT32 nTempStep;
UINT32 TempFormat;
UINT32 format; UINT32 format;
CLEAR_GLYPH_ENTRY GlyphCache[4000]; CLEAR_GLYPH_ENTRY GlyphCache[4000];
UINT32 VBarStorageCursor; UINT32 VBarStorageCursor;

View File

@ -644,7 +644,6 @@ static INLINE UINT32 ReadColor(const BYTE* src, UINT32 format)
case 16: case 16:
case 15: case 15:
color = ((UINT32)src[1] << 8) | src[0]; color = ((UINT32)src[1] << 8) | src[0];
color = ((color >> 11) & 0x1F) | (color & 0x7E0) | ((color & 0x1F) << 11);
break; break;
case 8: case 8:
@ -679,7 +678,6 @@ static INLINE BOOL WriteColor(BYTE* dst, UINT32 format, UINT32 color)
case 16: case 16:
case 15: case 15:
color = ((color >> 11) & 0x1F) | (color & 0x7E0) | ((color & 0x1F) << 11);
dst[1] = color >> 8; dst[1] = color >> 8;
dst[0] = color; dst[0] = color;
break; break;

View File

@ -89,7 +89,10 @@ FREERDP_API BOOL nsc_context_set_pixel_format(NSC_CONTEXT* context,
UINT32 pixel_format); UINT32 pixel_format);
FREERDP_API BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp, FREERDP_API BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
const BYTE* data, UINT32 length); const BYTE* data, UINT32 length,
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStride, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight);
FREERDP_API BOOL nsc_compose_message(NSC_CONTEXT* context, wStream* s, FREERDP_API BOOL nsc_compose_message(NSC_CONTEXT* context, wStream* s,
const BYTE* bmpdata, const BYTE* bmpdata,
UINT32 width, UINT32 height, UINT32 rowstride); UINT32 width, UINT32 height, UINT32 rowstride);

View File

@ -94,6 +94,9 @@ struct _BITMAP_PLANAR_CONTEXT
BYTE* rlePlanes[4]; BYTE* rlePlanes[4];
BYTE* rlePlanesBuffer; BYTE* rlePlanesBuffer;
BYTE* pTempData;
UINT32 nTempStep;
}; };
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -234,16 +234,19 @@ struct _PROGRESSIVE_CONTEXT
extern "C" { extern "C" {
#endif #endif
FREERDP_API int progressive_compress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize); FREERDP_API int progressive_compress(PROGRESSIVE_CONTEXT* progressive,
BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize);
FREERDP_API UINT progressive_decompress(PROGRESSIVE_CONTEXT* progressive, FREERDP_API INT32 progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
const BYTE* pSrcData, UINT32 SrcSize, const BYTE* pSrcData, UINT32 SrcSize,
BYTE* pDstData, UINT32 DstFormat, BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight, UINT16 surfaceId); UINT32 nWidth, UINT32 nHeight, UINT16 surfaceId);
FREERDP_API int progressive_create_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId, UINT32 width, UINT32 height); FREERDP_API INT32 progressive_create_surface_context(PROGRESSIVE_CONTEXT*
FREERDP_API int progressive_delete_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId); progressive, UINT16 surfaceId, UINT32 width, UINT32 height);
FREERDP_API int progressive_delete_surface_context(PROGRESSIVE_CONTEXT*
progressive, UINT16 surfaceId);
FREERDP_API BOOL progressive_context_reset(PROGRESSIVE_CONTEXT* progressive); FREERDP_API BOOL progressive_context_reset(PROGRESSIVE_CONTEXT* progressive);

View File

@ -56,9 +56,9 @@ static BYTE CLEAR_8BIT_MASKS[9] =
}; };
static void convert_color(BYTE* dst, UINT32 nDstStep, UINT32 DstFormat, static void convert_color(BYTE* dst, UINT32 nDstStep, UINT32 DstFormat,
UINT32 nXDst, UINT32 nYDst, UINT32 nXDst, UINT32 nYDst,
const BYTE* src, UINT32 nSrcStep, UINT32 SrcFormat, const BYTE* src, UINT32 nSrcStep, UINT32 SrcFormat,
UINT32 nWidth, UINT32 nHeight) UINT32 nWidth, UINT32 nHeight)
{ {
UINT32 x, y; UINT32 x, y;
@ -75,38 +75,29 @@ static void convert_color(BYTE* dst, UINT32 nDstStep, UINT32 DstFormat,
&pDstLine[(nXDst + x) * GetBytesPerPixel(DstFormat)]; &pDstLine[(nXDst + x) * GetBytesPerPixel(DstFormat)];
UINT32 color = ReadColor(pSrcPixel, SrcFormat); UINT32 color = ReadColor(pSrcPixel, SrcFormat);
color = ConvertColor(color, SrcFormat, color = ConvertColor(color, SrcFormat,
DstFormat, NULL); DstFormat, NULL);
WriteColor(pDstPixel, DstFormat, color); WriteColor(pDstPixel, DstFormat, color);
} }
} }
} }
static BOOL clear_decompress_nscodec(NSC_CONTEXT* nsc, UINT32 width, static BOOL clear_decompress_nscodec(NSC_CONTEXT* nsc, UINT32 width,
UINT32 height, UINT32 height,
const BYTE* bitmapData, UINT32 bitmapDataByteCount, const BYTE* bitmapData, UINT32 bitmapDataByteCount,
BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep, BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
UINT32 nXDstRel, UINT32 nYDstRel) UINT32 nXDstRel, UINT32 nYDstRel)
{ {
UINT32 nSrcStep; return nsc_process_message(nsc, 32, width, height, bitmapData,
bitmapDataByteCount, pDstData, DstFormat,
if (nsc_process_message(nsc, 32, width, height, bitmapData, nDstStep, nXDstRel, nYDstRel, width, height);
bitmapDataByteCount) < 0)
return FALSE;
nSrcStep = width * GetBytesPerPixel(nsc->format);
convert_color(pDstData, nDstStep, DstFormat,
nXDstRel, nYDstRel,
nsc->BitmapData, nSrcStep, nsc->format,
width, height);
return TRUE;
} }
static BOOL clear_decompress_subcode_rlex(const BYTE* bitmapData, static BOOL clear_decompress_subcode_rlex(const BYTE* bitmapData,
UINT32 bitmapDataByteCount, UINT32 bitmapDataByteCount,
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
BYTE* tmpBuffer, UINT32 nTmpBufferSize, BYTE* tmpBuffer, UINT32 nTmpBufferSize,
BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep, BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
UINT32 nXDstRel, UINT32 nYDstRel) UINT32 nXDstRel, UINT32 nYDstRel)
{ {
UINT32 i; UINT32 i;
UINT32 SrcFormat = PIXEL_FORMAT_BGR24; UINT32 SrcFormat = PIXEL_FORMAT_BGR24;
@ -132,10 +123,10 @@ static BOOL clear_decompress_subcode_rlex(const BYTE* bitmapData,
for (i = 0; i < paletteCount; i++) for (i = 0; i < paletteCount; i++)
{ {
UINT32 color = GetColor(SrcFormat, UINT32 color = GetColor(SrcFormat,
pSrcPixel8[2], pSrcPixel8[2],
pSrcPixel8[1], pSrcPixel8[1],
pSrcPixel8[0], pSrcPixel8[0],
0xFF); 0xFF);
palette[i] = color; palette[i] = color;
pSrcPixel8 += GetBytesPerPixel(SrcFormat); pSrcPixel8 += GetBytesPerPixel(SrcFormat);
} }
@ -154,7 +145,7 @@ static BOOL clear_decompress_subcode_rlex(const BYTE* bitmapData,
stopIndex = bitmapData[bitmapDataOffset] & CLEAR_8BIT_MASKS[numBits]; stopIndex = bitmapData[bitmapDataOffset] & CLEAR_8BIT_MASKS[numBits];
suiteDepth = (bitmapData[bitmapDataOffset] >> numBits) & CLEAR_8BIT_MASKS[(8 - suiteDepth = (bitmapData[bitmapDataOffset] >> numBits) & CLEAR_8BIT_MASKS[(8 -
numBits)]; numBits)];
startIndex = stopIndex - suiteDepth; startIndex = stopIndex - suiteDepth;
bitmapDataOffset++; bitmapDataOffset++;
runLengthFactor = (UINT32) bitmapData[bitmapDataOffset]; runLengthFactor = (UINT32) bitmapData[bitmapDataOffset];
@ -217,18 +208,18 @@ static BOOL clear_decompress_subcode_rlex(const BYTE* bitmapData,
return -1055; return -1055;
convert_color(pDstData, nDstStep, DstFormat, convert_color(pDstData, nDstStep, DstFormat,
nXDstRel, nYDstRel, nXDstRel, nYDstRel,
tmpBuffer, nSrcStep, SrcFormat, tmpBuffer, nSrcStep, SrcFormat,
width, height); width, height);
return TRUE; return TRUE;
} }
static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear, static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear,
const BYTE* residualData, const BYTE* residualData,
UINT32 residualByteCount, UINT32 SrcSize, UINT32 residualByteCount, UINT32 SrcSize,
UINT32 nWidth, UINT32 nHeight, UINT32 nWidth, UINT32 nHeight,
BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep, BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
UINT32 nXDst, UINT32 nYDst) UINT32 nXDst, UINT32 nYDst)
{ {
UINT32 i; UINT32 i;
UINT32 nSrcStep; UINT32 nSrcStep;
@ -264,8 +255,8 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear,
return -1015; return -1015;
color = GetColor(clear->format, residualData[suboffset + 2], color = GetColor(clear->format, residualData[suboffset + 2],
residualData[suboffset + 1], residualData[suboffset + 1],
residualData[suboffset + 0], 0xFF); residualData[suboffset + 0], 0xFF);
suboffset += 3; suboffset += 3;
runLengthFactor = residualData[suboffset]; runLengthFactor = residualData[suboffset];
suboffset++; suboffset++;
@ -306,18 +297,18 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear,
return -1019; return -1019;
convert_color(pDstData, nDstStep, DstFormat, convert_color(pDstData, nDstStep, DstFormat,
nXDst, nYDst, nXDst, nYDst,
clear->TempBuffer, nSrcStep, clear->format, clear->TempBuffer, nSrcStep, clear->format,
nWidth, nHeight); nWidth, nHeight);
return TRUE; return TRUE;
} }
static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear, static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
const BYTE* bandsData, const BYTE* bandsData,
UINT32 bandsByteCount, UINT32 SrcSize, UINT32 bandsByteCount, UINT32 SrcSize,
UINT32 nWidth, UINT32 nHeight, UINT32 nWidth, UINT32 nHeight,
BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep, BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
UINT32 nXDst, UINT32 nYDst) UINT32 nXDst, UINT32 nYDst)
{ {
UINT32 i, y; UINT32 i, y;
UINT32 count; UINT32 count;
@ -359,9 +350,9 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
yEnd = *((UINT16*) &bandsData[suboffset + 6]); yEnd = *((UINT16*) &bandsData[suboffset + 6]);
suboffset += 8; suboffset += 8;
colorBkg = GetColor(clear->format, bandsData[suboffset + 2], colorBkg = GetColor(clear->format, bandsData[suboffset + 2],
bandsData[suboffset + 1], bandsData[suboffset + 1],
bandsData[suboffset + 0], bandsData[suboffset + 0],
0xFF); 0xFF);
suboffset += 3; suboffset += 3;
if (xEnd < xStart) if (xEnd < xStart)
@ -437,8 +428,8 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
BYTE* tmp; BYTE* tmp;
vBarShortEntry->size = vBarShortEntry->count; vBarShortEntry->size = vBarShortEntry->count;
tmp = (BYTE*) realloc( tmp = (BYTE*) realloc(
vBarShortEntry->pixels, vBarShortEntry->pixels,
vBarShortEntry->count * GetBytesPerPixel(clear->format)); vBarShortEntry->count * GetBytesPerPixel(clear->format));
if (!tmp) if (!tmp)
return -1; return -1;
@ -454,10 +445,10 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
BYTE* dstBuffer = BYTE* dstBuffer =
&vBarShortEntry->pixels[y * GetBytesPerPixel(clear->format)]; &vBarShortEntry->pixels[y * GetBytesPerPixel(clear->format)];
UINT32 color = GetColor(clear->format, UINT32 color = GetColor(clear->format,
pSrcPixel8[2], pSrcPixel8[2],
pSrcPixel8[1], pSrcPixel8[1],
pSrcPixel8[0], pSrcPixel8[0],
0xFF); 0xFF);
WriteColor(dstBuffer, clear->format, color); WriteColor(dstBuffer, clear->format, color);
pSrcPixel8 += 3; pSrcPixel8 += 3;
} }
@ -499,7 +490,7 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
BYTE* tmp; BYTE* tmp;
vBarEntry->size = vBarEntry->count; vBarEntry->size = vBarEntry->count;
tmp = (BYTE*) realloc(vBarEntry->pixels, tmp = (BYTE*) realloc(vBarEntry->pixels,
vBarEntry->count * GetBytesPerPixel(clear->format)); vBarEntry->count * GetBytesPerPixel(clear->format));
if (!tmp) if (!tmp)
return -1; return -1;
@ -535,13 +526,13 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
count = (vBarPixelCount > y) ? (vBarPixelCount - y) : 0; count = (vBarPixelCount > y) ? (vBarPixelCount - y) : 0;
pSrcPixel = &vBarShortEntry->pixels[(y - vBarYOn) * GetBytesPerPixel( pSrcPixel = &vBarShortEntry->pixels[(y - vBarYOn) * GetBytesPerPixel(
clear->format)]; clear->format)];
for (x = 0; x < count; x++) for (x = 0; x < count; x++)
{ {
UINT32 color; UINT32 color;
color = ReadColor(&vBarShortEntry->pixels[x * GetBytesPerPixel(clear->format)], color = ReadColor(&vBarShortEntry->pixels[x * GetBytesPerPixel(clear->format)],
clear->format); clear->format);
WriteColor(dstBuffer, clear->format, color); WriteColor(dstBuffer, clear->format, color);
dstBuffer += GetBytesPerPixel(clear->format); dstBuffer += GetBytesPerPixel(clear->format);
} }
@ -571,10 +562,10 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
for (y = 0; y < count; y++) for (y = 0; y < count; y++)
{ {
BYTE* pDstPixel8 = &pDstData[((nYDstRel + y) * nDstStep) + BYTE* pDstPixel8 = &pDstData[((nYDstRel + y) * nDstStep) +
((nXDstRel + i) * GetBytesPerPixel(DstFormat))]; ((nXDstRel + i) * GetBytesPerPixel(DstFormat))];
UINT32 color = ReadColor(pSrcPixel, clear->format); UINT32 color = ReadColor(pSrcPixel, clear->format);
color = ConvertColor(color, clear->format, color = ConvertColor(color, clear->format,
DstFormat, NULL); DstFormat, NULL);
WriteColor(pDstPixel8, DstFormat, color); WriteColor(pDstPixel8, DstFormat, color);
pSrcPixel += GetBytesPerPixel(clear->format); pSrcPixel += GetBytesPerPixel(clear->format);
} }
@ -585,9 +576,9 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
} }
INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData, INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
UINT32 SrcSize, UINT32 SrcSize,
BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep, BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight) UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight)
{ {
BYTE seqNumber; BYTE seqNumber;
BYTE glyphFlags; BYTE glyphFlags;
@ -658,9 +649,9 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
nSrcStep = nWidth * GetBytesPerPixel(clear->format); nSrcStep = nWidth * GetBytesPerPixel(clear->format);
convert_color(pDstData, nDstStep, DstFormat, convert_color(pDstData, nDstStep, DstFormat,
nXDst, nYDst, nXDst, nYDst,
glyphData, nSrcStep, clear->format, glyphData, nSrcStep, clear->format,
nWidth, nHeight); nWidth, nHeight);
return 1; /* Finish */ return 1; /* Finish */
} }
} }
@ -677,9 +668,9 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
if (residualByteCount > 0) if (residualByteCount > 0)
{ {
if (!clear_decompress_residual_data(clear, if (!clear_decompress_residual_data(clear,
&pSrcData[offset], residualByteCount, &pSrcData[offset], residualByteCount,
SrcSize - offset, nWidth, nHeight, SrcSize - offset, nWidth, nHeight,
pDstData, DstFormat, nDstStep, nXDst, nYDst)) pDstData, DstFormat, nDstStep, nXDst, nYDst))
return -1111; return -1111;
offset += residualByteCount; offset += residualByteCount;
@ -688,9 +679,9 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
if (bandsByteCount > 0) if (bandsByteCount > 0)
{ {
if (!clear_decompress_bands_data(clear, if (!clear_decompress_bands_data(clear,
&pSrcData[offset], bandsByteCount, &pSrcData[offset], bandsByteCount,
SrcSize - offset, nWidth, nHeight, SrcSize - offset, nWidth, nHeight,
pDstData, DstFormat, nDstStep, nXDst, nYDst)) pDstData, DstFormat, nDstStep, nXDst, nYDst))
return FALSE; return FALSE;
offset += bandsByteCount; offset += bandsByteCount;
@ -762,27 +753,27 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
return -1045; return -1045;
convert_color(pDstData, nDstStep, DstFormat, convert_color(pDstData, nDstStep, DstFormat,
nXDstRel, nYDstRel, nXDstRel, nYDstRel,
bitmapData, nSrcStep, bitmapData, nSrcStep,
PIXEL_FORMAT_BGR24, PIXEL_FORMAT_BGR24,
width, height); width, height);
} }
else if (subcodecId == 1) /* NSCodec */ else if (subcodecId == 1) /* NSCodec */
{ {
if (!clear_decompress_nscodec(clear->nsc, width, height, if (!clear_decompress_nscodec(clear->nsc, width, height,
bitmapData, bitmapDataByteCount, bitmapData, bitmapDataByteCount,
pDstData, DstFormat, nDstStep, pDstData, DstFormat, nDstStep,
nXDstRel, nYDstRel)) nXDstRel, nYDstRel))
return -1046; return -1046;
} }
else if (subcodecId == 2) /* CLEARCODEC_SUBCODEC_RLEX */ else if (subcodecId == 2) /* CLEARCODEC_SUBCODEC_RLEX */
{ {
if (!clear_decompress_subcode_rlex(bitmapData, if (!clear_decompress_subcode_rlex(bitmapData,
bitmapDataByteCount, bitmapDataByteCount,
width, height, width, height,
clear->TempBuffer, clear->TempSize, clear->TempBuffer, clear->TempSize,
pDstData, DstFormat, nDstStep, pDstData, DstFormat, nDstStep,
nXDstRel, nYDstRel)) nXDstRel, nYDstRel))
return -1047; return -1047;
} }
else else
@ -820,9 +811,9 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
glyphData = (BYTE*) glyphEntry->pixels; glyphData = (BYTE*) glyphEntry->pixels;
nSrcStep = nWidth * GetBytesPerPixel(clear->format); nSrcStep = nWidth * GetBytesPerPixel(clear->format);
convert_color(pDstData, nDstStep, DstFormat, convert_color(pDstData, nDstStep, DstFormat,
nXDst, nYDst, nXDst, nYDst,
glyphData, nSrcStep, clear->format, glyphData, nSrcStep, clear->format,
nWidth, nHeight); nWidth, nHeight);
} }
if (offset != SrcSize) if (offset != SrcSize)
@ -832,7 +823,7 @@ INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
} }
int clear_compress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize, int clear_compress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, UINT32* pDstSize) BYTE** ppDstData, UINT32* pDstSize)
{ {
return 1; return 1;
} }

View File

@ -1483,7 +1483,6 @@ static BOOL avc_yuv_to_rgb(H264_CONTEXT* h264, const RECTANGLE_16* regionRects,
roi.width = width; roi.width = width;
roi.height = height; roi.height = height;
// TODO: Color format converstion support!!!
if (use444) if (use444)
{ {
if (prims->YUV444ToRGB_8u_P3AC4R( if (prims->YUV444ToRGB_8u_P3AC4R(

View File

@ -46,35 +46,25 @@ static void nsc_decode(NSC_CONTEXT* context)
{ {
UINT16 x; UINT16 x;
UINT16 y; UINT16 y;
UINT16 rw; UINT16 rw = ROUND_UP_TO(context->width, 8);
BYTE shift; BYTE shift = context->ColorLossLevel - 1; /* colorloss recovery + YCoCg shift */;
BYTE* yplane;
BYTE* coplane; BYTE* bmpdata = context->BitmapData;
BYTE* cgplane;
BYTE* aplane;
INT16 y_val;
INT16 co_val;
INT16 cg_val;
INT16 r_val;
INT16 g_val;
INT16 b_val;
BYTE* bmpdata;
bmpdata = context->BitmapData;
rw = ROUND_UP_TO(context->width, 8);
shift = context->ColorLossLevel - 1; /* colorloss recovery + YCoCg shift */
WLog_Print(context->priv->log, WLOG_DEBUG,
"NscDecode: width: %d height: %d ChromaSubsamplingLevel: %d",
context->width, context->height, context->ChromaSubsamplingLevel);
for (y = 0; y < context->height; y++) for (y = 0; y < context->height; y++)
{ {
const BYTE* yplane;
const BYTE* coplane;
const BYTE* cgplane;
const BYTE* aplane = context->priv->PlaneBuffers[3] + y * context->width; /* A */;
if (context->ChromaSubsamplingLevel) if (context->ChromaSubsamplingLevel)
{ {
yplane = context->priv->PlaneBuffers[0] + y * rw; /* Y */ yplane = context->priv->PlaneBuffers[0] + y * rw; /* Y */
coplane = context->priv->PlaneBuffers[1] + (y >> 1) * (rw >> coplane = context->priv->PlaneBuffers[1] + (y >> 1) * (rw >>
1); /* Co, supersampled */ 1); /* Co, supersampled */
cgplane = context->priv->PlaneBuffers[2] + (y >> 1) * (rw >> cgplane = context->priv->PlaneBuffers[2] + (y >> 1) * (rw >>
1); /* Cg, supersampled */ 1); /* Cg, supersampled */
} }
else else
{ {
@ -83,16 +73,15 @@ static void nsc_decode(NSC_CONTEXT* context)
cgplane = context->priv->PlaneBuffers[2] + y * context->width; /* Cg */ cgplane = context->priv->PlaneBuffers[2] + y * context->width; /* Cg */
} }
aplane = context->priv->PlaneBuffers[3] + y * context->width; /* A */
for (x = 0; x < context->width; x++) for (x = 0; x < context->width; x++)
{ {
y_val = (INT16) * yplane; INT16 y_val = (INT16) * yplane;
co_val = (INT16)(INT8)(*coplane << shift); INT16 co_val = (INT16)(INT8)(*coplane << shift);
cg_val = (INT16)(INT8)(*cgplane << shift); INT16 cg_val = (INT16)(INT8)(*cgplane << shift);
r_val = y_val + co_val - cg_val; INT16 r_val = y_val + co_val - cg_val;
g_val = y_val + cg_val; INT16 g_val = y_val + cg_val;
b_val = y_val - co_val - cg_val; INT16 b_val = y_val - co_val - cg_val;
*bmpdata++ = MINMAX(b_val, 0, 0xFF); *bmpdata++ = MINMAX(b_val, 0, 0xFF);
*bmpdata++ = MINMAX(g_val, 0, 0xFF); *bmpdata++ = MINMAX(g_val, 0, 0xFF);
*bmpdata++ = MINMAX(r_val, 0, 0xFF); *bmpdata++ = MINMAX(r_val, 0, 0xFF);
@ -187,7 +176,7 @@ static BOOL nsc_stream_initialize(NSC_CONTEXT* context, wStream* s)
Stream_Read_UINT8(s, context->ColorLossLevel); /* ColorLossLevel (1 byte) */ Stream_Read_UINT8(s, context->ColorLossLevel); /* ColorLossLevel (1 byte) */
Stream_Read_UINT8(s, Stream_Read_UINT8(s,
context->ChromaSubsamplingLevel); /* ChromaSubsamplingLevel (1 byte) */ context->ChromaSubsamplingLevel); /* ChromaSubsamplingLevel (1 byte) */
Stream_Seek(s, 2); /* Reserved (2 bytes) */ Stream_Seek(s, 2); /* Reserved (2 bytes) */
context->Planes = Stream_Pointer(s); context->Planes = Stream_Pointer(s);
return TRUE; return TRUE;
@ -306,10 +295,10 @@ NSC_CONTEXT* nsc_context_new(void)
goto error_PlanePool; goto error_PlanePool;
PROFILER_CREATE(context->priv->prof_nsc_rle_decompress_data, PROFILER_CREATE(context->priv->prof_nsc_rle_decompress_data,
"nsc_rle_decompress_data"); "nsc_rle_decompress_data");
PROFILER_CREATE(context->priv->prof_nsc_decode, "nsc_decode"); PROFILER_CREATE(context->priv->prof_nsc_decode, "nsc_decode");
PROFILER_CREATE(context->priv->prof_nsc_rle_compress_data, PROFILER_CREATE(context->priv->prof_nsc_rle_compress_data,
"nsc_rle_compress_data"); "nsc_rle_compress_data");
PROFILER_CREATE(context->priv->prof_nsc_encode, "nsc_encode"); PROFILER_CREATE(context->priv->prof_nsc_encode, "nsc_encode");
/* Default encoding parameters */ /* Default encoding parameters */
context->ColorLossLevel = 3; context->ColorLossLevel = 3;
@ -356,8 +345,12 @@ BOOL nsc_context_set_pixel_format(NSC_CONTEXT* context, UINT32 pixel_format)
} }
BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp, BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
UINT32 width, UINT32 height, const BYTE* data, UINT32 width, UINT32 height,
UINT32 length) const BYTE* data, UINT32 length,
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStride,
UINT32 nXDst, UINT32 nYDst, UINT32 nWidth,
UINT32 nHeight)
{ {
wStream* s; wStream* s;
BOOL ret; BOOL ret;
@ -366,6 +359,9 @@ BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
if (!s) if (!s)
return FALSE; return FALSE;
if (nDstStride == 0)
nDstStride = nWidth * GetBytesPerPixel(DstFormat);
switch (bpp) switch (bpp)
{ {
case 32: case 32:
@ -408,5 +404,11 @@ BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
PROFILER_ENTER(context->priv->prof_nsc_decode); PROFILER_ENTER(context->priv->prof_nsc_decode);
context->decode(context); context->decode(context);
PROFILER_EXIT(context->priv->prof_nsc_decode); PROFILER_EXIT(context->priv->prof_nsc_decode);
if (!freerdp_image_copy(pDstData, DstFormat, nDstStride, nXDst, nYDst,
width, height, context->BitmapData,
PIXEL_FORMAT_BGRA32, -1, 0, 0, NULL))
return FALSE;
return TRUE; return TRUE;
} }

View File

@ -34,7 +34,7 @@
#define TAG FREERDP_TAG("codec") #define TAG FREERDP_TAG("codec")
static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
int nWidth, int nHeight) int nWidth, int nHeight)
{ {
int x, y; int x, y;
int cRawBytes; int cRawBytes;
@ -83,10 +83,10 @@ static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
} }
static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
BYTE* pDstData, INT32 nDstStep, BYTE* pDstData, INT32 nDstStep,
UINT32 nXDst, UINT32 nYDst, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight, UINT32 nWidth, UINT32 nHeight,
UINT32 nChannel, BOOL vFlip) UINT32 nChannel, BOOL vFlip)
{ {
UINT32 x, y; UINT32 x, y;
BYTE* dstp; BYTE* dstp;
@ -218,9 +218,9 @@ static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
} }
static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4], static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
BYTE* pDstData, UINT32 DstFormat, BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
BOOL alpha, BOOL vFlip) BOOL alpha, BOOL vFlip)
{ {
INT32 x, y; INT32 x, y;
INT32 beg, end, inc; INT32 beg, end, inc;
@ -247,7 +247,7 @@ static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
for (y = beg; y != end; y += inc) for (y = beg; y != end; y += inc)
{ {
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel( BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
DstFormat))]; DstFormat))];
for (x = 0; x < nWidth; x++) for (x = 0; x < nWidth; x++)
{ {
@ -262,7 +262,7 @@ static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
for (y = beg; y != end; y += inc) for (y = beg; y != end; y += inc)
{ {
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel( BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
DstFormat))]; DstFormat))];
for (x = 0; x < nWidth; x++) for (x = 0; x < nWidth; x++)
{ {
@ -277,10 +277,10 @@ static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
} }
INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar, INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
const BYTE* pSrcData, UINT32 SrcSize, const BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, UINT32 DstFormat, BYTE** ppDstData, UINT32 DstFormat,
INT32 nDstStep, UINT32 nXDst, UINT32 nYDst, INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight, BOOL vFlip) UINT32 nWidth, UINT32 nHeight, BOOL vFlip)
{ {
BOOL cs; BOOL cs;
BOOL rle; BOOL rle;
@ -405,28 +405,28 @@ INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
{ {
planes[3] = srcp; planes[3] = srcp;
rleSizes[3] = planar_skip_plane_rle(planes[3], SrcSize - (planes[3] - pSrcData), rleSizes[3] = planar_skip_plane_rle(planes[3], SrcSize - (planes[3] - pSrcData),
rawWidths[3], rawHeights[3]); /* AlphaPlane */ rawWidths[3], rawHeights[3]); /* AlphaPlane */
if (rleSizes[3] < 0) if (rleSizes[3] < 0)
return -1; return -1;
planes[0] = planes[3] + rleSizes[3]; planes[0] = planes[3] + rleSizes[3];
rleSizes[0] = planar_skip_plane_rle(planes[0], SrcSize - (planes[0] - pSrcData), rleSizes[0] = planar_skip_plane_rle(planes[0], SrcSize - (planes[0] - pSrcData),
rawWidths[0], rawHeights[0]); /* RedPlane */ rawWidths[0], rawHeights[0]); /* RedPlane */
if (rleSizes[0] < 0) if (rleSizes[0] < 0)
return -1; return -1;
planes[1] = planes[0] + rleSizes[0]; planes[1] = planes[0] + rleSizes[0];
rleSizes[1] = planar_skip_plane_rle(planes[1], SrcSize - (planes[1] - pSrcData), rleSizes[1] = planar_skip_plane_rle(planes[1], SrcSize - (planes[1] - pSrcData),
rawWidths[1], rawHeights[1]); /* GreenPlane */ rawWidths[1], rawHeights[1]); /* GreenPlane */
if (rleSizes[1] < 1) if (rleSizes[1] < 1)
return -1; return -1;
planes[2] = planes[1] + rleSizes[1]; planes[2] = planes[1] + rleSizes[1];
rleSizes[2] = planar_skip_plane_rle(planes[2], SrcSize - (planes[2] - pSrcData), rleSizes[2] = planar_skip_plane_rle(planes[2], SrcSize - (planes[2] - pSrcData),
rawWidths[2], rawHeights[2]); /* BluePlane */ rawWidths[2], rawHeights[2]); /* BluePlane */
if (rleSizes[2] < 1) if (rleSizes[2] < 1)
return -1; return -1;
@ -435,21 +435,21 @@ INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
{ {
planes[0] = srcp; planes[0] = srcp;
rleSizes[0] = planar_skip_plane_rle(planes[0], SrcSize - (planes[0] - pSrcData), rleSizes[0] = planar_skip_plane_rle(planes[0], SrcSize - (planes[0] - pSrcData),
rawWidths[0], rawHeights[0]); /* RedPlane */ rawWidths[0], rawHeights[0]); /* RedPlane */
if (rleSizes[0] < 0) if (rleSizes[0] < 0)
return -1; return -1;
planes[1] = planes[0] + rleSizes[0]; planes[1] = planes[0] + rleSizes[0];
rleSizes[1] = planar_skip_plane_rle(planes[1], SrcSize - (planes[1] - pSrcData), rleSizes[1] = planar_skip_plane_rle(planes[1], SrcSize - (planes[1] - pSrcData),
rawWidths[1], rawHeights[1]); /* GreenPlane */ rawWidths[1], rawHeights[1]); /* GreenPlane */
if (rleSizes[1] < 1) if (rleSizes[1] < 1)
return -1; return -1;
planes[2] = planes[1] + rleSizes[1]; planes[2] = planes[1] + rleSizes[1];
rleSizes[2] = planar_skip_plane_rle(planes[2], SrcSize - (planes[2] - pSrcData), rleSizes[2] = planar_skip_plane_rle(planes[2], SrcSize - (planes[2] - pSrcData),
rawWidths[2], rawHeights[2]); /* BluePlane */ rawWidths[2], rawHeights[2]); /* BluePlane */
if (rleSizes[2] < 1) if (rleSizes[2] < 1)
return -1; return -1;
@ -463,13 +463,13 @@ INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
if (alpha) if (alpha)
{ {
planar_decompress_planes_raw(planes, pDstData, DstFormat, nDstStep, planar_decompress_planes_raw(planes, pDstData, DstFormat, nDstStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip); nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3]; srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3];
} }
else /* NoAlpha */ else /* NoAlpha */
{ {
planar_decompress_planes_raw(planes, pDstData, DstFormat, nDstStep, planar_decompress_planes_raw(planes, pDstData, DstFormat, nDstStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip); nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2]; srcp += rawSizes[0] + rawSizes[1] + rawSizes[2];
} }
@ -478,63 +478,64 @@ INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
} }
else /* RLE */ else /* RLE */
{ {
UINT32 TempFormat = PIXEL_FORMAT_ARGB32; UINT32 TempFormat;
BYTE* pTempData = pDstData; BYTE* pTempData = pDstData;
UINT32 nTempStep = nDstStep; UINT32 nTempStep = nDstStep;
if (alpha)
TempFormat = PIXEL_FORMAT_BGRA32;
else
TempFormat = PIXEL_FORMAT_BGRX32;
if (DstFormat != TempFormat) if (DstFormat != TempFormat)
{ {
pTempData = malloc(nWidth * nHeight * 4); pTempData = planar->pTempData;
nTempStep = planar->nTempStep;
if (!pTempData)
return -1;
} }
if (alpha) if (alpha)
{ {
status = planar_decompress_plane_rle(planes[3], rleSizes[3], status = planar_decompress_plane_rle(planes[3], rleSizes[3],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
vFlip); /* AlphaPlane */ vFlip); /* AlphaPlane */
status = planar_decompress_plane_rle(planes[0], rleSizes[0], status = planar_decompress_plane_rle(planes[0], rleSizes[0],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
vFlip); /* RedPlane */ vFlip); /* RedPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1], status = planar_decompress_plane_rle(planes[1], rleSizes[1],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
vFlip); /* GreenPlane */ vFlip); /* GreenPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2], status = planar_decompress_plane_rle(planes[2], rleSizes[2],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
vFlip); /* BluePlane */ vFlip); /* BluePlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2] + rleSizes[3]; srcp += rleSizes[0] + rleSizes[1] + rleSizes[2] + rleSizes[3];
} }
else /* NoAlpha */ else /* NoAlpha */
{ {
status = planar_decompress_plane_rle(planes[0], rleSizes[0], status = planar_decompress_plane_rle(planes[0], rleSizes[0],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
vFlip); /* RedPlane */ vFlip); /* RedPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1], status = planar_decompress_plane_rle(planes[1], rleSizes[1],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
vFlip); /* GreenPlane */ vFlip); /* GreenPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2], status = planar_decompress_plane_rle(planes[2], rleSizes[2],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
vFlip); /* BluePlane */ vFlip); /* BluePlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2]; srcp += rleSizes[0] + rleSizes[1] + rleSizes[2];
} }
if (pTempData != pDstData) if (pTempData != pDstData)
{ {
freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth, nHeight, freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth, nHeight,
pTempData, pTempData,
TempFormat, nTempStep, nXDst, nYDst, NULL); TempFormat, nTempStep, nXDst, nYDst, NULL);
free(pTempData);
} }
} }
} }
else /* YCoCg */ else /* YCoCg */
{ {
BYTE* pTempData; BYTE* pTempData = planar->pTempData;
UINT32 nTempStep = nDstStep; UINT32 nTempStep = planar->nTempStep;
UINT32 TempFormat = PIXEL_FORMAT_RGBA32; UINT32 TempFormat = PIXEL_FORMAT_RGBA32;
pTempData = malloc(UncompressedSize);
if (!pTempData) if (!pTempData)
return -1; return -1;
@ -542,7 +543,6 @@ INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
if (cs) if (cs)
{ {
WLog_ERR(TAG, "Chroma subsampling unimplemented"); WLog_ERR(TAG, "Chroma subsampling unimplemented");
free(pTempData);
return -1; return -1;
} }
@ -551,13 +551,13 @@ INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
if (alpha) if (alpha)
{ {
planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep, planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip); nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3]; srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3];
} }
else /* NoAlpha */ else /* NoAlpha */
{ {
planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep, planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip); nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2]; srcp += rawSizes[0] + rawSizes[1] + rawSizes[2];
} }
@ -569,37 +569,36 @@ INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
if (alpha) if (alpha)
{ {
status = planar_decompress_plane_rle(planes[3], rleSizes[3], status = planar_decompress_plane_rle(planes[3], rleSizes[3],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
vFlip); /* AlphaPlane */ vFlip); /* AlphaPlane */
status = planar_decompress_plane_rle(planes[0], rleSizes[0], status = planar_decompress_plane_rle(planes[0], rleSizes[0],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
vFlip); /* LumaPlane */ vFlip); /* LumaPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1], status = planar_decompress_plane_rle(planes[1], rleSizes[1],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
vFlip); /* OrangeChromaPlane */ vFlip); /* OrangeChromaPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2], status = planar_decompress_plane_rle(planes[2], rleSizes[2],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
vFlip); /* GreenChromaPlane */ vFlip); /* GreenChromaPlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2] + rleSizes[3]; srcp += rleSizes[0] + rleSizes[1] + rleSizes[2] + rleSizes[3];
} }
else /* NoAlpha */ else /* NoAlpha */
{ {
status = planar_decompress_plane_rle(planes[0], rleSizes[0], status = planar_decompress_plane_rle(planes[0], rleSizes[0],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
vFlip); /* LumaPlane */ vFlip); /* LumaPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1], status = planar_decompress_plane_rle(planes[1], rleSizes[1],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
vFlip); /* OrangeChromaPlane */ vFlip); /* OrangeChromaPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2], status = planar_decompress_plane_rle(planes[2], rleSizes[2],
pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0, pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
vFlip); /* GreenChromaPlane */ vFlip); /* GreenChromaPlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2]; srcp += rleSizes[0] + rleSizes[1] + rleSizes[2];
} }
} }
prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, pDstData, DstFormat, nDstStep, prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, pDstData, DstFormat, nDstStep,
nWidth, nHeight, cll, alpha); nWidth, nHeight, cll, alpha);
free(pTempData);
} }
status = (SrcSize == (srcp - pSrcData)) ? 1 : -1; status = (SrcSize == (srcp - pSrcData)) ? 1 : -1;
@ -607,8 +606,8 @@ INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
} }
static BOOL freerdp_split_color_planes(const BYTE* data, UINT32 format, static BOOL freerdp_split_color_planes(const BYTE* data, UINT32 format,
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
UINT32 scanline, BYTE** planes) UINT32 scanline, BYTE** planes)
{ {
INT32 i, j, k; INT32 i, j, k;
UINT32* pixel; UINT32* pixel;
@ -621,7 +620,7 @@ static BOOL freerdp_split_color_planes(const BYTE* data, UINT32 format,
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
{ {
*pixel = GetColor(format, planes[1][k], planes[2][k], *pixel = GetColor(format, planes[1][k], planes[2][k],
planes[3][k], planes[0][k]); planes[3][k], planes[0][k]);
pixel++; pixel++;
k++; k++;
} }
@ -745,9 +744,9 @@ static UINT32 freerdp_bitmap_planar_write_rle_bytes(
} }
static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer, static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
UINT32 inBufferSize, UINT32 inBufferSize,
BYTE* pOutBuffer, BYTE* pOutBuffer,
UINT32 outBufferSize) UINT32 outBufferSize)
{ {
BYTE symbol; BYTE symbol;
const BYTE* pInput; const BYTE* pInput;
@ -789,9 +788,9 @@ static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
{ {
pBytes = pInput - (cRawBytes + nRunLength + 1); pBytes = pInput - (cRawBytes + nRunLength + 1);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes( nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(
pBytes, cRawBytes, pBytes, cRawBytes,
nRunLength, pOutput, nRunLength, pOutput,
outBufferSize); outBufferSize);
nRunLength = 0; nRunLength = 0;
if (!nBytesWritten || (nBytesWritten > outBufferSize)) if (!nBytesWritten || (nBytesWritten > outBufferSize))
@ -813,7 +812,7 @@ static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
{ {
pBytes = pInput - (cRawBytes + nRunLength); pBytes = pInput - (cRawBytes + nRunLength);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(pBytes, nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(pBytes,
cRawBytes, nRunLength, pOutput, outBufferSize); cRawBytes, nRunLength, pOutput, outBufferSize);
if (!nBytesWritten) if (!nBytesWritten)
return 0; return 0;
@ -828,8 +827,8 @@ static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
} }
BYTE* freerdp_bitmap_planar_compress_plane_rle(const BYTE* inPlane, BYTE* freerdp_bitmap_planar_compress_plane_rle(const BYTE* inPlane,
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
BYTE* outPlane, UINT32* dstSize) BYTE* outPlane, UINT32* dstSize)
{ {
UINT32 index; UINT32 index;
const BYTE* pInput; const BYTE* pInput;
@ -859,7 +858,7 @@ BYTE* freerdp_bitmap_planar_compress_plane_rle(const BYTE* inPlane,
while (outBufferSize) while (outBufferSize)
{ {
nBytesWritten = freerdp_bitmap_planar_encode_rle_bytes( nBytesWritten = freerdp_bitmap_planar_encode_rle_bytes(
pInput, width, pOutput, outBufferSize); pInput, width, pOutput, outBufferSize);
if ((!nBytesWritten) || (nBytesWritten > outBufferSize)) if ((!nBytesWritten) || (nBytesWritten > outBufferSize))
return NULL; return NULL;
@ -894,7 +893,7 @@ static UINT32 freerdp_bitmap_planar_compress_planes_rle(
dstSizes[0] = outPlanesSize; dstSizes[0] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle( if (!freerdp_bitmap_planar_compress_plane_rle(
inPlanes[0], width, height, outPlanes, &dstSizes[0])) inPlanes[0], width, height, outPlanes, &dstSizes[0]))
return 0; return 0;
outPlanes += dstSizes[0]; outPlanes += dstSizes[0];
@ -905,7 +904,7 @@ static UINT32 freerdp_bitmap_planar_compress_planes_rle(
dstSizes[1] = outPlanesSize; dstSizes[1] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[1], width, height, if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[1], width, height,
outPlanes, &dstSizes[1])) outPlanes, &dstSizes[1]))
return 0; return 0;
outPlanes += dstSizes[1]; outPlanes += dstSizes[1];
@ -914,7 +913,7 @@ static UINT32 freerdp_bitmap_planar_compress_planes_rle(
dstSizes[2] = outPlanesSize; dstSizes[2] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[2], width, height, if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[2], width, height,
outPlanes, &dstSizes[2])) outPlanes, &dstSizes[2]))
return 0; return 0;
outPlanes += dstSizes[2]; outPlanes += dstSizes[2];
@ -923,7 +922,7 @@ static UINT32 freerdp_bitmap_planar_compress_planes_rle(
dstSizes[3] = outPlanesSize; dstSizes[3] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[3], width, height, if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[3], width, height,
outPlanes, &dstSizes[3])) outPlanes, &dstSizes[3]))
return 0; return 0;
outPlanes += dstSizes[3]; outPlanes += dstSizes[3];
@ -932,8 +931,8 @@ static UINT32 freerdp_bitmap_planar_compress_planes_rle(
} }
BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane, BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane,
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
BYTE* outPlane) BYTE* outPlane)
{ {
char s2c; char s2c;
INT32 delta; INT32 delta;
@ -968,15 +967,15 @@ BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane,
} }
BOOL freerdp_bitmap_planar_delta_encode_planes(const BYTE** inPlanes, BOOL freerdp_bitmap_planar_delta_encode_planes(const BYTE** inPlanes,
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
BYTE* outPlanes[4]) BYTE* outPlanes[4])
{ {
UINT32 i; UINT32 i;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
outPlanes[i] = freerdp_bitmap_planar_delta_encode_plane( outPlanes[i] = freerdp_bitmap_planar_delta_encode_plane(
inPlanes[i], width, height, outPlanes[i]); inPlanes[i], width, height, outPlanes[i]);
if (!outPlanes[i]) if (!outPlanes[i])
return FALSE; return FALSE;
@ -986,9 +985,9 @@ BOOL freerdp_bitmap_planar_delta_encode_planes(const BYTE** inPlanes,
} }
BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context,
const BYTE* data, UINT32 format, const BYTE* data, UINT32 format,
UINT32 width, UINT32 height, UINT32 scanline, UINT32 width, UINT32 height, UINT32 scanline,
BYTE* dstData, UINT32* pDstSize) BYTE* dstData, UINT32* pDstSize)
{ {
UINT32 size; UINT32 size;
BYTE* dstp; BYTE* dstp;
@ -1002,20 +1001,20 @@ BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context,
planeSize = width * height; planeSize = width * height;
if (!freerdp_split_color_planes(data, format, width, height, scanline, if (!freerdp_split_color_planes(data, format, width, height, scanline,
context->planes)) context->planes))
return NULL; return NULL;
if (context->AllowRunLengthEncoding) if (context->AllowRunLengthEncoding)
{ {
if (!freerdp_bitmap_planar_delta_encode_planes( if (!freerdp_bitmap_planar_delta_encode_planes(
(const BYTE**)context->planes, width, height, (const BYTE**)context->planes, width, height,
context->deltaPlanes)) context->deltaPlanes))
return NULL;; return NULL;;
if (freerdp_bitmap_planar_compress_planes_rle( if (freerdp_bitmap_planar_compress_planes_rle(
(const BYTE**)context->deltaPlanes, width, height, (const BYTE**)context->deltaPlanes, width, height,
context->rlePlanesBuffer, dstSizes, context->rlePlanesBuffer, dstSizes,
context->AllowSkipAlpha) > 0) context->AllowSkipAlpha) > 0)
{ {
int offset = 0; int offset = 0;
FormatHeader |= PLANAR_FORMAT_HEADER_RLE; FormatHeader |= PLANAR_FORMAT_HEADER_RLE;
@ -1167,9 +1166,11 @@ BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(
context->maxHeight = maxHeight; context->maxHeight = maxHeight;
context->maxPlaneSize = context->maxWidth * context->maxHeight; context->maxPlaneSize = context->maxWidth * context->maxHeight;
context->planesBuffer = malloc(context->maxPlaneSize * 4); context->planesBuffer = malloc(context->maxPlaneSize * 4);
context->nTempStep = maxWidth * 4;
context->pTempData = malloc(context->maxPlaneSize * 4);
if (!context->planesBuffer) if (!context->planesBuffer || !context->planesBuffer)
goto error_planesBuffer; goto error;
context->planes[0] = &context->planesBuffer[context->maxPlaneSize * 0]; context->planes[0] = &context->planesBuffer[context->maxPlaneSize * 0];
context->planes[1] = &context->planesBuffer[context->maxPlaneSize * 1]; context->planes[1] = &context->planesBuffer[context->maxPlaneSize * 1];
@ -1178,27 +1179,26 @@ BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(
context->deltaPlanesBuffer = malloc(context->maxPlaneSize * 4); context->deltaPlanesBuffer = malloc(context->maxPlaneSize * 4);
if (!context->deltaPlanesBuffer) if (!context->deltaPlanesBuffer)
goto error_deltaPlanesBuffer; goto error;
context->deltaPlanes[0] = &context->deltaPlanesBuffer[context->maxPlaneSize * context->deltaPlanes[0] = &context->deltaPlanesBuffer[context->maxPlaneSize *
0]; 0];
context->deltaPlanes[1] = &context->deltaPlanesBuffer[context->maxPlaneSize * context->deltaPlanes[1] = &context->deltaPlanesBuffer[context->maxPlaneSize *
1]; 1];
context->deltaPlanes[2] = &context->deltaPlanesBuffer[context->maxPlaneSize * context->deltaPlanes[2] = &context->deltaPlanesBuffer[context->maxPlaneSize *
2]; 2];
context->deltaPlanes[3] = &context->deltaPlanesBuffer[context->maxPlaneSize * context->deltaPlanes[3] = &context->deltaPlanesBuffer[context->maxPlaneSize *
3]; 3];
context->rlePlanesBuffer = malloc(context->maxPlaneSize * 4); context->rlePlanesBuffer = malloc(context->maxPlaneSize * 4);
if (!context->rlePlanesBuffer) if (!context->rlePlanesBuffer)
goto error_rlePlanesBuffer; goto error;
return context; return context;
error_rlePlanesBuffer: error:
free(context->pTempData);
free(context->deltaPlanesBuffer); free(context->deltaPlanesBuffer);
error_deltaPlanesBuffer:
free(context->planesBuffer); free(context->planesBuffer);
error_planesBuffer:
free(context); free(context);
return NULL; return NULL;
} }
@ -1208,6 +1208,7 @@ void freerdp_bitmap_planar_context_free(BITMAP_PLANAR_CONTEXT* context)
if (!context) if (!context)
return; return;
free(context->pTempData);
free(context->planesBuffer); free(context->planesBuffer);
free(context->deltaPlanesBuffer); free(context->deltaPlanesBuffer);
free(context->rlePlanesBuffer); free(context->rlePlanesBuffer);

File diff suppressed because it is too large Load Diff

View File

@ -149,7 +149,7 @@ static void rfx_profiler_print(RFX_CONTEXT* context)
PROFILER_PRINT_FOOTER; PROFILER_PRINT_FOOTER;
} }
void rfx_tile_init(RFX_TILE* tile) static void rfx_tile_init(RFX_TILE* tile)
{ {
if (tile) if (tile)
{ {
@ -164,7 +164,7 @@ void rfx_tile_init(RFX_TILE* tile)
} }
} }
RFX_TILE* rfx_decoder_tile_new() static RFX_TILE* rfx_decoder_tile_new(void)
{ {
RFX_TILE* tile = NULL; RFX_TILE* tile = NULL;
@ -181,7 +181,7 @@ RFX_TILE* rfx_decoder_tile_new()
return tile; return tile;
} }
void rfx_decoder_tile_free(RFX_TILE* tile) static void rfx_decoder_tile_free(RFX_TILE* tile)
{ {
if (tile) if (tile)
{ {
@ -192,12 +192,12 @@ void rfx_decoder_tile_free(RFX_TILE* tile)
} }
} }
RFX_TILE* rfx_encoder_tile_new() static RFX_TILE* rfx_encoder_tile_new()
{ {
return (RFX_TILE*)calloc(1, sizeof(RFX_TILE)); return (RFX_TILE*)calloc(1, sizeof(RFX_TILE));
} }
void rfx_encoder_tile_free(RFX_TILE* tile) static void rfx_encoder_tile_free(RFX_TILE* tile)
{ {
free(tile); free(tile);
} }
@ -733,8 +733,9 @@ struct _RFX_TILE_PROCESS_WORK_PARAM
}; };
typedef struct _RFX_TILE_PROCESS_WORK_PARAM RFX_TILE_PROCESS_WORK_PARAM; typedef struct _RFX_TILE_PROCESS_WORK_PARAM RFX_TILE_PROCESS_WORK_PARAM;
void CALLBACK rfx_process_message_tile_work_callback(PTP_CALLBACK_INSTANCE static void CALLBACK rfx_process_message_tile_work_callback(
instance, void* context, PTP_WORK work) PTP_CALLBACK_INSTANCE
instance, void* context, PTP_WORK work)
{ {
RFX_TILE_PROCESS_WORK_PARAM* param = (RFX_TILE_PROCESS_WORK_PARAM*) context; RFX_TILE_PROCESS_WORK_PARAM* param = (RFX_TILE_PROCESS_WORK_PARAM*) context;
rfx_decode_rgb(param->context, param->tile, param->tile->data, 64 * 4); rfx_decode_rgb(param->context, param->tile, param->tile->data, 64 * 4);

View File

@ -1094,7 +1094,7 @@ static BOOL gdi_surface_bits(rdpContext* context,
cmd->bitmapDataLength, cmd->bitmapDataLength,
cmd->destLeft, cmd->destTop, cmd->destLeft, cmd->destTop,
pDstData, gdi->dstFormat, pDstData, gdi->dstFormat,
gdi->width, gdi->height, NULL)) cmd->width, cmd->height, NULL))
{ {
WLog_ERR(TAG, "Failed to process RemoteFX message"); WLog_ERR(TAG, "Failed to process RemoteFX message");
return FALSE; return FALSE;
@ -1106,14 +1106,14 @@ static BOOL gdi_surface_bits(rdpContext* context,
gdi->width, gdi->height)) gdi->width, gdi->height))
return FALSE; return FALSE;
nsc_process_message(gdi->codecs->nsc, cmd->bpp, cmd->width, if (!nsc_process_message(gdi->codecs->nsc, cmd->bpp, cmd->width,
cmd->height, cmd->bitmapData, cmd->height, cmd->bitmapData,
cmd->bitmapDataLength); cmd->bitmapDataLength, gdi->bitmap_buffer,
gdi->dstFormat,
0, 0, 0, cmd->width, cmd->height))
return FALSE;
pDstData = gdi->bitmap_buffer; pDstData = gdi->bitmap_buffer;
pSrcData = gdi->codecs->nsc->BitmapData;
freerdp_image_copy(pDstData, gdi->dstFormat, -1, 0, 0,
cmd->width, cmd->height, pSrcData,
PIXEL_FORMAT_XRGB32_VF, -1, 0, 0, gdi->palette);
gdi_DeleteObject((HGDIOBJECT)gdi->image->bitmap); gdi_DeleteObject((HGDIOBJECT)gdi->image->bitmap);
gdi->image->bitmap = gdi_CreateBitmapEx(cmd->width, cmd->height, gdi->image->bitmap = gdi_CreateBitmapEx(cmd->width, cmd->height,
gdi->dstFormat, 0, gdi->dstFormat, 0,

File diff suppressed because it is too large Load Diff