return FALSE;
}
- nsc_process_message(xfc->codecs->nsc, cmd->bpp, cmd->width, cmd->height,
- cmd->bitmapData, cmd->bitmapDataLength);
+ if (!nsc_process_message(xfc->codecs->nsc, cmd->bpp, cmd->width, cmd->height,
+ 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);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
pSrcData = xfc->codecs->nsc->BitmapData;
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,
(char*) pDstData, cmd->width, cmd->height, xfc->scanline_pad, 0);
XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0,
UINT32 seqNumber;
BYTE* TempBuffer;
UINT32 TempSize;
+ UINT32 nTempStep;
+ UINT32 TempFormat;
UINT32 format;
CLEAR_GLYPH_ENTRY GlyphCache[4000];
UINT32 VBarStorageCursor;
case 16:
case 15:
color = ((UINT32)src[1] << 8) | src[0];
- color = ((color >> 11) & 0x1F) | (color & 0x7E0) | ((color & 0x1F) << 11);
break;
case 8:
case 16:
case 15:
- color = ((color >> 11) & 0x1F) | (color & 0x7E0) | ((color & 0x1F) << 11);
dst[1] = color >> 8;
dst[0] = color;
break;
UINT32 pixel_format);
FREERDP_API BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
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,
const BYTE* bmpdata,
UINT32 width, UINT32 height, UINT32 rowstride);
BYTE* rlePlanes[4];
BYTE* rlePlanesBuffer;
+
+ BYTE* pTempData;
+ UINT32 nTempStep;
};
#ifdef __cplusplus
extern "C" {
#endif
-FREERDP_API int progressive_compress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize);
-
-FREERDP_API UINT progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
- const BYTE* pSrcData, UINT32 SrcSize,
- BYTE* pDstData, UINT32 DstFormat,
- UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight, UINT16 surfaceId);
-
-FREERDP_API int progressive_create_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId, UINT32 width, UINT32 height);
-FREERDP_API int progressive_delete_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId);
+FREERDP_API int progressive_compress(PROGRESSIVE_CONTEXT* progressive,
+ BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize);
+
+FREERDP_API INT32 progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
+ const BYTE* pSrcData, UINT32 SrcSize,
+ BYTE* pDstData, UINT32 DstFormat,
+ UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+ UINT32 nWidth, UINT32 nHeight, UINT16 surfaceId);
+
+FREERDP_API INT32 progressive_create_surface_context(PROGRESSIVE_CONTEXT*
+ 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);
};
static void convert_color(BYTE* dst, UINT32 nDstStep, UINT32 DstFormat,
- UINT32 nXDst, UINT32 nYDst,
- const BYTE* src, UINT32 nSrcStep, UINT32 SrcFormat,
- UINT32 nWidth, UINT32 nHeight)
+ UINT32 nXDst, UINT32 nYDst,
+ const BYTE* src, UINT32 nSrcStep, UINT32 SrcFormat,
+ UINT32 nWidth, UINT32 nHeight)
{
UINT32 x, y;
&pDstLine[(nXDst + x) * GetBytesPerPixel(DstFormat)];
UINT32 color = ReadColor(pSrcPixel, SrcFormat);
color = ConvertColor(color, SrcFormat,
- DstFormat, NULL);
+ DstFormat, NULL);
WriteColor(pDstPixel, DstFormat, color);
}
}
}
static BOOL clear_decompress_nscodec(NSC_CONTEXT* nsc, UINT32 width,
- UINT32 height,
- const BYTE* bitmapData, UINT32 bitmapDataByteCount,
- BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
- UINT32 nXDstRel, UINT32 nYDstRel)
+ UINT32 height,
+ const BYTE* bitmapData, UINT32 bitmapDataByteCount,
+ BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
+ UINT32 nXDstRel, UINT32 nYDstRel)
{
- UINT32 nSrcStep;
-
- if (nsc_process_message(nsc, 32, width, height, bitmapData,
- 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;
+ return nsc_process_message(nsc, 32, width, height, bitmapData,
+ bitmapDataByteCount, pDstData, DstFormat,
+ nDstStep, nXDstRel, nYDstRel, width, height);
}
static BOOL clear_decompress_subcode_rlex(const BYTE* bitmapData,
- UINT32 bitmapDataByteCount,
- UINT32 width, UINT32 height,
- BYTE* tmpBuffer, UINT32 nTmpBufferSize,
- BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
- UINT32 nXDstRel, UINT32 nYDstRel)
+ UINT32 bitmapDataByteCount,
+ UINT32 width, UINT32 height,
+ BYTE* tmpBuffer, UINT32 nTmpBufferSize,
+ BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
+ UINT32 nXDstRel, UINT32 nYDstRel)
{
UINT32 i;
UINT32 SrcFormat = PIXEL_FORMAT_BGR24;
for (i = 0; i < paletteCount; i++)
{
UINT32 color = GetColor(SrcFormat,
- pSrcPixel8[2],
- pSrcPixel8[1],
- pSrcPixel8[0],
- 0xFF);
+ pSrcPixel8[2],
+ pSrcPixel8[1],
+ pSrcPixel8[0],
+ 0xFF);
palette[i] = color;
pSrcPixel8 += GetBytesPerPixel(SrcFormat);
}
stopIndex = bitmapData[bitmapDataOffset] & CLEAR_8BIT_MASKS[numBits];
suiteDepth = (bitmapData[bitmapDataOffset] >> numBits) & CLEAR_8BIT_MASKS[(8 -
- numBits)];
+ numBits)];
startIndex = stopIndex - suiteDepth;
bitmapDataOffset++;
runLengthFactor = (UINT32) bitmapData[bitmapDataOffset];
return -1055;
convert_color(pDstData, nDstStep, DstFormat,
- nXDstRel, nYDstRel,
- tmpBuffer, nSrcStep, SrcFormat,
- width, height);
+ nXDstRel, nYDstRel,
+ tmpBuffer, nSrcStep, SrcFormat,
+ width, height);
return TRUE;
}
static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear,
- const BYTE* residualData,
- UINT32 residualByteCount, UINT32 SrcSize,
- UINT32 nWidth, UINT32 nHeight,
- BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
- UINT32 nXDst, UINT32 nYDst)
+ const BYTE* residualData,
+ UINT32 residualByteCount, UINT32 SrcSize,
+ UINT32 nWidth, UINT32 nHeight,
+ BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
+ UINT32 nXDst, UINT32 nYDst)
{
UINT32 i;
UINT32 nSrcStep;
return -1015;
color = GetColor(clear->format, residualData[suboffset + 2],
- residualData[suboffset + 1],
- residualData[suboffset + 0], 0xFF);
+ residualData[suboffset + 1],
+ residualData[suboffset + 0], 0xFF);
suboffset += 3;
runLengthFactor = residualData[suboffset];
suboffset++;
return -1019;
convert_color(pDstData, nDstStep, DstFormat,
- nXDst, nYDst,
- clear->TempBuffer, nSrcStep, clear->format,
- nWidth, nHeight);
+ nXDst, nYDst,
+ clear->TempBuffer, nSrcStep, clear->format,
+ nWidth, nHeight);
return TRUE;
}
static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear,
- const BYTE* bandsData,
- UINT32 bandsByteCount, UINT32 SrcSize,
- UINT32 nWidth, UINT32 nHeight,
- BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
- UINT32 nXDst, UINT32 nYDst)
+ const BYTE* bandsData,
+ UINT32 bandsByteCount, UINT32 SrcSize,
+ UINT32 nWidth, UINT32 nHeight,
+ BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
+ UINT32 nXDst, UINT32 nYDst)
{
UINT32 i, y;
UINT32 count;
yEnd = *((UINT16*) &bandsData[suboffset + 6]);
suboffset += 8;
colorBkg = GetColor(clear->format, bandsData[suboffset + 2],
- bandsData[suboffset + 1],
- bandsData[suboffset + 0],
- 0xFF);
+ bandsData[suboffset + 1],
+ bandsData[suboffset + 0],
+ 0xFF);
suboffset += 3;
if (xEnd < xStart)
BYTE* tmp;
vBarShortEntry->size = vBarShortEntry->count;
tmp = (BYTE*) realloc(
- vBarShortEntry->pixels,
- vBarShortEntry->count * GetBytesPerPixel(clear->format));
+ vBarShortEntry->pixels,
+ vBarShortEntry->count * GetBytesPerPixel(clear->format));
if (!tmp)
return -1;
BYTE* dstBuffer =
&vBarShortEntry->pixels[y * GetBytesPerPixel(clear->format)];
UINT32 color = GetColor(clear->format,
- pSrcPixel8[2],
- pSrcPixel8[1],
- pSrcPixel8[0],
- 0xFF);
+ pSrcPixel8[2],
+ pSrcPixel8[1],
+ pSrcPixel8[0],
+ 0xFF);
WriteColor(dstBuffer, clear->format, color);
pSrcPixel8 += 3;
}
BYTE* tmp;
vBarEntry->size = vBarEntry->count;
tmp = (BYTE*) realloc(vBarEntry->pixels,
- vBarEntry->count * GetBytesPerPixel(clear->format));
+ vBarEntry->count * GetBytesPerPixel(clear->format));
if (!tmp)
return -1;
count = (vBarPixelCount > y) ? (vBarPixelCount - y) : 0;
pSrcPixel = &vBarShortEntry->pixels[(y - vBarYOn) * GetBytesPerPixel(
- clear->format)];
+ clear->format)];
for (x = 0; x < count; x++)
{
UINT32 color;
color = ReadColor(&vBarShortEntry->pixels[x * GetBytesPerPixel(clear->format)],
- clear->format);
+ clear->format);
WriteColor(dstBuffer, clear->format, color);
dstBuffer += GetBytesPerPixel(clear->format);
}
for (y = 0; y < count; y++)
{
BYTE* pDstPixel8 = &pDstData[((nYDstRel + y) * nDstStep) +
- ((nXDstRel + i) * GetBytesPerPixel(DstFormat))];
+ ((nXDstRel + i) * GetBytesPerPixel(DstFormat))];
UINT32 color = ReadColor(pSrcPixel, clear->format);
color = ConvertColor(color, clear->format,
- DstFormat, NULL);
+ DstFormat, NULL);
WriteColor(pDstPixel8, DstFormat, color);
pSrcPixel += GetBytesPerPixel(clear->format);
}
}
INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
- UINT32 SrcSize,
- BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
- UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight)
+ UINT32 SrcSize,
+ BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
+ UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight)
{
BYTE seqNumber;
BYTE glyphFlags;
nSrcStep = nWidth * GetBytesPerPixel(clear->format);
convert_color(pDstData, nDstStep, DstFormat,
- nXDst, nYDst,
- glyphData, nSrcStep, clear->format,
- nWidth, nHeight);
+ nXDst, nYDst,
+ glyphData, nSrcStep, clear->format,
+ nWidth, nHeight);
return 1; /* Finish */
}
}
if (residualByteCount > 0)
{
if (!clear_decompress_residual_data(clear,
- &pSrcData[offset], residualByteCount,
- SrcSize - offset, nWidth, nHeight,
- pDstData, DstFormat, nDstStep, nXDst, nYDst))
+ &pSrcData[offset], residualByteCount,
+ SrcSize - offset, nWidth, nHeight,
+ pDstData, DstFormat, nDstStep, nXDst, nYDst))
return -1111;
offset += residualByteCount;
if (bandsByteCount > 0)
{
if (!clear_decompress_bands_data(clear,
- &pSrcData[offset], bandsByteCount,
- SrcSize - offset, nWidth, nHeight,
- pDstData, DstFormat, nDstStep, nXDst, nYDst))
+ &pSrcData[offset], bandsByteCount,
+ SrcSize - offset, nWidth, nHeight,
+ pDstData, DstFormat, nDstStep, nXDst, nYDst))
return FALSE;
offset += bandsByteCount;
return -1045;
convert_color(pDstData, nDstStep, DstFormat,
- nXDstRel, nYDstRel,
- bitmapData, nSrcStep,
- PIXEL_FORMAT_BGR24,
- width, height);
+ nXDstRel, nYDstRel,
+ bitmapData, nSrcStep,
+ PIXEL_FORMAT_BGR24,
+ width, height);
}
else if (subcodecId == 1) /* NSCodec */
{
if (!clear_decompress_nscodec(clear->nsc, width, height,
- bitmapData, bitmapDataByteCount,
- pDstData, DstFormat, nDstStep,
- nXDstRel, nYDstRel))
+ bitmapData, bitmapDataByteCount,
+ pDstData, DstFormat, nDstStep,
+ nXDstRel, nYDstRel))
return -1046;
}
else if (subcodecId == 2) /* CLEARCODEC_SUBCODEC_RLEX */
{
if (!clear_decompress_subcode_rlex(bitmapData,
- bitmapDataByteCount,
- width, height,
- clear->TempBuffer, clear->TempSize,
- pDstData, DstFormat, nDstStep,
- nXDstRel, nYDstRel))
+ bitmapDataByteCount,
+ width, height,
+ clear->TempBuffer, clear->TempSize,
+ pDstData, DstFormat, nDstStep,
+ nXDstRel, nYDstRel))
return -1047;
}
else
glyphData = (BYTE*) glyphEntry->pixels;
nSrcStep = nWidth * GetBytesPerPixel(clear->format);
convert_color(pDstData, nDstStep, DstFormat,
- nXDst, nYDst,
- glyphData, nSrcStep, clear->format,
- nWidth, nHeight);
+ nXDst, nYDst,
+ glyphData, nSrcStep, clear->format,
+ nWidth, nHeight);
}
if (offset != SrcSize)
}
int clear_compress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize,
- BYTE** ppDstData, UINT32* pDstSize)
+ BYTE** ppDstData, UINT32* pDstSize)
{
return 1;
}
roi.width = width;
roi.height = height;
- // TODO: Color format converstion support!!!
if (use444)
{
if (prims->YUV444ToRGB_8u_P3AC4R(
{
UINT16 x;
UINT16 y;
- UINT16 rw;
- BYTE shift;
- BYTE* yplane;
- BYTE* coplane;
- 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);
+ UINT16 rw = ROUND_UP_TO(context->width, 8);
+ BYTE shift = context->ColorLossLevel - 1; /* colorloss recovery + YCoCg shift */;
+
+ BYTE* bmpdata = context->BitmapData;
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)
{
yplane = context->priv->PlaneBuffers[0] + y * rw; /* Y */
coplane = context->priv->PlaneBuffers[1] + (y >> 1) * (rw >>
- 1); /* Co, supersampled */
+ 1); /* Co, supersampled */
cgplane = context->priv->PlaneBuffers[2] + (y >> 1) * (rw >>
- 1); /* Cg, supersampled */
+ 1); /* Cg, supersampled */
}
else
{
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++)
{
- y_val = (INT16) * yplane;
- co_val = (INT16)(INT8)(*coplane << shift);
- cg_val = (INT16)(INT8)(*cgplane << shift);
- r_val = y_val + co_val - cg_val;
- g_val = y_val + cg_val;
- b_val = y_val - co_val - cg_val;
+ INT16 y_val = (INT16) * yplane;
+ INT16 co_val = (INT16)(INT8)(*coplane << shift);
+ INT16 cg_val = (INT16)(INT8)(*cgplane << shift);
+ INT16 r_val = y_val + co_val - cg_val;
+ INT16 g_val = y_val + cg_val;
+ INT16 b_val = y_val - co_val - cg_val;
+
*bmpdata++ = MINMAX(b_val, 0, 0xFF);
*bmpdata++ = MINMAX(g_val, 0, 0xFF);
*bmpdata++ = MINMAX(r_val, 0, 0xFF);
Stream_Read_UINT8(s, context->ColorLossLevel); /* ColorLossLevel (1 byte) */
Stream_Read_UINT8(s,
- context->ChromaSubsamplingLevel); /* ChromaSubsamplingLevel (1 byte) */
+ context->ChromaSubsamplingLevel); /* ChromaSubsamplingLevel (1 byte) */
Stream_Seek(s, 2); /* Reserved (2 bytes) */
context->Planes = Stream_Pointer(s);
return TRUE;
goto error_PlanePool;
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_rle_compress_data,
- "nsc_rle_compress_data");
+ "nsc_rle_compress_data");
PROFILER_CREATE(context->priv->prof_nsc_encode, "nsc_encode");
/* Default encoding parameters */
context->ColorLossLevel = 3;
}
BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
- UINT32 width, UINT32 height, const BYTE* data,
- UINT32 length)
+ UINT32 width, UINT32 height,
+ const BYTE* data, UINT32 length,
+ BYTE* pDstData, UINT32 DstFormat,
+ UINT32 nDstStride,
+ UINT32 nXDst, UINT32 nYDst, UINT32 nWidth,
+ UINT32 nHeight)
{
wStream* s;
BOOL ret;
if (!s)
return FALSE;
+ if (nDstStride == 0)
+ nDstStride = nWidth * GetBytesPerPixel(DstFormat);
+
switch (bpp)
{
case 32:
PROFILER_ENTER(context->priv->prof_nsc_decode);
context->decode(context);
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;
}
#define TAG FREERDP_TAG("codec")
static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
- int nWidth, int nHeight)
+ int nWidth, int nHeight)
{
int x, y;
int cRawBytes;
}
static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
- BYTE* pDstData, INT32 nDstStep,
- UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight,
- UINT32 nChannel, BOOL vFlip)
+ BYTE* pDstData, INT32 nDstStep,
+ UINT32 nXDst, UINT32 nYDst,
+ UINT32 nWidth, UINT32 nHeight,
+ UINT32 nChannel, BOOL vFlip)
{
UINT32 x, y;
BYTE* dstp;
}
static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
- BYTE* pDstData, UINT32 DstFormat,
- UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
- BOOL alpha, BOOL vFlip)
+ BYTE* pDstData, UINT32 DstFormat,
+ UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
+ BOOL alpha, BOOL vFlip)
{
INT32 x, y;
INT32 beg, end, inc;
for (y = beg; y != end; y += inc)
{
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
- DstFormat))];
+ DstFormat))];
for (x = 0; x < nWidth; x++)
{
for (y = beg; y != end; y += inc)
{
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
- DstFormat))];
+ DstFormat))];
for (x = 0; x < nWidth; x++)
{
}
INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
- const BYTE* pSrcData, UINT32 SrcSize,
- BYTE** ppDstData, UINT32 DstFormat,
- INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight, BOOL vFlip)
+ const BYTE* pSrcData, UINT32 SrcSize,
+ BYTE** ppDstData, UINT32 DstFormat,
+ INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+ UINT32 nWidth, UINT32 nHeight, BOOL vFlip)
{
BOOL cs;
BOOL rle;
{
planes[3] = srcp;
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)
return -1;
planes[0] = planes[3] + rleSizes[3];
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)
return -1;
planes[1] = planes[0] + rleSizes[0];
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)
return -1;
planes[2] = planes[1] + rleSizes[1];
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)
return -1;
{
planes[0] = srcp;
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)
return -1;
planes[1] = planes[0] + rleSizes[0];
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)
return -1;
planes[2] = planes[1] + rleSizes[1];
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)
return -1;
if (alpha)
{
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];
}
else /* NoAlpha */
{
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];
}
}
else /* RLE */
{
- UINT32 TempFormat = PIXEL_FORMAT_ARGB32;
+ UINT32 TempFormat;
BYTE* pTempData = pDstData;
UINT32 nTempStep = nDstStep;
+ if (alpha)
+ TempFormat = PIXEL_FORMAT_BGRA32;
+ else
+ TempFormat = PIXEL_FORMAT_BGRX32;
+
if (DstFormat != TempFormat)
{
- pTempData = malloc(nWidth * nHeight * 4);
-
- if (!pTempData)
- return -1;
+ pTempData = planar->pTempData;
+ nTempStep = planar->nTempStep;
}
if (alpha)
{
status = planar_decompress_plane_rle(planes[3], rleSizes[3],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
- vFlip); /* AlphaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
+ vFlip); /* AlphaPlane */
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
- vFlip); /* RedPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ vFlip); /* RedPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
- vFlip); /* GreenPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ vFlip); /* GreenPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
- vFlip); /* BluePlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ vFlip); /* BluePlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2] + rleSizes[3];
}
else /* NoAlpha */
{
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
- vFlip); /* RedPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ vFlip); /* RedPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
- vFlip); /* GreenPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ vFlip); /* GreenPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
- vFlip); /* BluePlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ vFlip); /* BluePlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2];
}
if (pTempData != pDstData)
{
freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth, nHeight,
- pTempData,
- TempFormat, nTempStep, nXDst, nYDst, NULL);
- free(pTempData);
+ pTempData,
+ TempFormat, nTempStep, nXDst, nYDst, NULL);
}
}
}
else /* YCoCg */
{
- BYTE* pTempData;
- UINT32 nTempStep = nDstStep;
+ BYTE* pTempData = planar->pTempData;
+ UINT32 nTempStep = planar->nTempStep;
UINT32 TempFormat = PIXEL_FORMAT_RGBA32;
- pTempData = malloc(UncompressedSize);
if (!pTempData)
return -1;
if (cs)
{
WLog_ERR(TAG, "Chroma subsampling unimplemented");
- free(pTempData);
return -1;
}
if (alpha)
{
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];
}
else /* NoAlpha */
{
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];
}
if (alpha)
{
status = planar_decompress_plane_rle(planes[3], rleSizes[3],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
- vFlip); /* AlphaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
+ vFlip); /* AlphaPlane */
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
- vFlip); /* LumaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ vFlip); /* LumaPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
- vFlip); /* OrangeChromaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ vFlip); /* OrangeChromaPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
- vFlip); /* GreenChromaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ vFlip); /* GreenChromaPlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2] + rleSizes[3];
}
else /* NoAlpha */
{
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
- vFlip); /* LumaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ vFlip); /* LumaPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
- vFlip); /* OrangeChromaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ vFlip); /* OrangeChromaPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
- vFlip); /* GreenChromaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ vFlip); /* GreenChromaPlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2];
}
}
prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, pDstData, DstFormat, nDstStep,
- nWidth, nHeight, cll, alpha);
- free(pTempData);
+ nWidth, nHeight, cll, alpha);
}
status = (SrcSize == (srcp - pSrcData)) ? 1 : -1;
}
static BOOL freerdp_split_color_planes(const BYTE* data, UINT32 format,
- UINT32 width, UINT32 height,
- UINT32 scanline, BYTE** planes)
+ UINT32 width, UINT32 height,
+ UINT32 scanline, BYTE** planes)
{
INT32 i, j, k;
UINT32* pixel;
for (j = 0; j < width; j++)
{
*pixel = GetColor(format, planes[1][k], planes[2][k],
- planes[3][k], planes[0][k]);
+ planes[3][k], planes[0][k]);
pixel++;
k++;
}
}
static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
- UINT32 inBufferSize,
- BYTE* pOutBuffer,
- UINT32 outBufferSize)
+ UINT32 inBufferSize,
+ BYTE* pOutBuffer,
+ UINT32 outBufferSize)
{
BYTE symbol;
const BYTE* pInput;
{
pBytes = pInput - (cRawBytes + nRunLength + 1);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(
- pBytes, cRawBytes,
- nRunLength, pOutput,
- outBufferSize);
+ pBytes, cRawBytes,
+ nRunLength, pOutput,
+ outBufferSize);
nRunLength = 0;
if (!nBytesWritten || (nBytesWritten > outBufferSize))
{
pBytes = pInput - (cRawBytes + nRunLength);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(pBytes,
- cRawBytes, nRunLength, pOutput, outBufferSize);
+ cRawBytes, nRunLength, pOutput, outBufferSize);
if (!nBytesWritten)
return 0;
}
BYTE* freerdp_bitmap_planar_compress_plane_rle(const BYTE* inPlane,
- UINT32 width, UINT32 height,
- BYTE* outPlane, UINT32* dstSize)
+ UINT32 width, UINT32 height,
+ BYTE* outPlane, UINT32* dstSize)
{
UINT32 index;
const BYTE* pInput;
while (outBufferSize)
{
nBytesWritten = freerdp_bitmap_planar_encode_rle_bytes(
- pInput, width, pOutput, outBufferSize);
+ pInput, width, pOutput, outBufferSize);
if ((!nBytesWritten) || (nBytesWritten > outBufferSize))
return NULL;
dstSizes[0] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(
- inPlanes[0], width, height, outPlanes, &dstSizes[0]))
+ inPlanes[0], width, height, outPlanes, &dstSizes[0]))
return 0;
outPlanes += dstSizes[0];
dstSizes[1] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[1], width, height,
- outPlanes, &dstSizes[1]))
+ outPlanes, &dstSizes[1]))
return 0;
outPlanes += dstSizes[1];
dstSizes[2] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[2], width, height,
- outPlanes, &dstSizes[2]))
+ outPlanes, &dstSizes[2]))
return 0;
outPlanes += dstSizes[2];
dstSizes[3] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[3], width, height,
- outPlanes, &dstSizes[3]))
+ outPlanes, &dstSizes[3]))
return 0;
outPlanes += dstSizes[3];
}
BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane,
- UINT32 width, UINT32 height,
- BYTE* outPlane)
+ UINT32 width, UINT32 height,
+ BYTE* outPlane)
{
char s2c;
INT32 delta;
}
BOOL freerdp_bitmap_planar_delta_encode_planes(const BYTE** inPlanes,
- UINT32 width, UINT32 height,
- BYTE* outPlanes[4])
+ UINT32 width, UINT32 height,
+ BYTE* outPlanes[4])
{
UINT32 i;
for (i = 0; i < 4; i++)
{
outPlanes[i] = freerdp_bitmap_planar_delta_encode_plane(
- inPlanes[i], width, height, outPlanes[i]);
+ inPlanes[i], width, height, outPlanes[i]);
if (!outPlanes[i])
return FALSE;
}
BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context,
- const BYTE* data, UINT32 format,
- UINT32 width, UINT32 height, UINT32 scanline,
- BYTE* dstData, UINT32* pDstSize)
+ const BYTE* data, UINT32 format,
+ UINT32 width, UINT32 height, UINT32 scanline,
+ BYTE* dstData, UINT32* pDstSize)
{
UINT32 size;
BYTE* dstp;
planeSize = width * height;
if (!freerdp_split_color_planes(data, format, width, height, scanline,
- context->planes))
+ context->planes))
return NULL;
if (context->AllowRunLengthEncoding)
{
if (!freerdp_bitmap_planar_delta_encode_planes(
- (const BYTE**)context->planes, width, height,
- context->deltaPlanes))
+ (const BYTE**)context->planes, width, height,
+ context->deltaPlanes))
return NULL;;
if (freerdp_bitmap_planar_compress_planes_rle(
- (const BYTE**)context->deltaPlanes, width, height,
- context->rlePlanesBuffer, dstSizes,
- context->AllowSkipAlpha) > 0)
+ (const BYTE**)context->deltaPlanes, width, height,
+ context->rlePlanesBuffer, dstSizes,
+ context->AllowSkipAlpha) > 0)
{
int offset = 0;
FormatHeader |= PLANAR_FORMAT_HEADER_RLE;
context->maxHeight = maxHeight;
context->maxPlaneSize = context->maxWidth * context->maxHeight;
context->planesBuffer = malloc(context->maxPlaneSize * 4);
+ context->nTempStep = maxWidth * 4;
+ context->pTempData = malloc(context->maxPlaneSize * 4);
- if (!context->planesBuffer)
- goto error_planesBuffer;
+ if (!context->planesBuffer || !context->planesBuffer)
+ goto error;
context->planes[0] = &context->planesBuffer[context->maxPlaneSize * 0];
context->planes[1] = &context->planesBuffer[context->maxPlaneSize * 1];
context->deltaPlanesBuffer = malloc(context->maxPlaneSize * 4);
if (!context->deltaPlanesBuffer)
- goto error_deltaPlanesBuffer;
+ goto error;
context->deltaPlanes[0] = &context->deltaPlanesBuffer[context->maxPlaneSize *
- 0];
+ 0];
context->deltaPlanes[1] = &context->deltaPlanesBuffer[context->maxPlaneSize *
- 1];
+ 1];
context->deltaPlanes[2] = &context->deltaPlanesBuffer[context->maxPlaneSize *
- 2];
+ 2];
context->deltaPlanes[3] = &context->deltaPlanesBuffer[context->maxPlaneSize *
- 3];
+ 3];
context->rlePlanesBuffer = malloc(context->maxPlaneSize * 4);
if (!context->rlePlanesBuffer)
- goto error_rlePlanesBuffer;
+ goto error;
return context;
-error_rlePlanesBuffer:
+error:
+ free(context->pTempData);
free(context->deltaPlanesBuffer);
-error_deltaPlanesBuffer:
free(context->planesBuffer);
-error_planesBuffer:
free(context);
return NULL;
}
if (!context)
return;
+ free(context->pTempData);
free(context->planesBuffer);
free(context->deltaPlanesBuffer);
free(context->rlePlanesBuffer);
}
static void progressive_component_codec_quant_read(const BYTE* block,
- RFX_COMPONENT_CODEC_QUANT* quantVal)
+ RFX_COMPONENT_CODEC_QUANT* quantVal)
{
quantVal->LL3 = block[0] & 0x0F;
quantVal->HL3 = block[0] >> 4;
}
static void progressive_rfx_quant_add(RFX_COMPONENT_CODEC_QUANT* q1,
- RFX_COMPONENT_CODEC_QUANT* q2,
- RFX_COMPONENT_CODEC_QUANT* dst)
+ RFX_COMPONENT_CODEC_QUANT* q2,
+ RFX_COMPONENT_CODEC_QUANT* dst)
{
dst->HL1 = q1->HL1 + q2->HL1; /* HL1 */
dst->LH1 = q1->LH1 + q2->LH1; /* LH1 */
}
static void progressive_rfx_quant_sub(RFX_COMPONENT_CODEC_QUANT* q1,
- RFX_COMPONENT_CODEC_QUANT* q2,
- RFX_COMPONENT_CODEC_QUANT* dst)
+ RFX_COMPONENT_CODEC_QUANT* q2,
+ RFX_COMPONENT_CODEC_QUANT* dst)
{
dst->HL1 = q1->HL1 - q2->HL1; /* HL1 */
dst->LH1 = q1->LH1 - q2->LH1; /* LH1 */
}
static BOOL progressive_rfx_quant_lcmp_less_equal(RFX_COMPONENT_CODEC_QUANT* q,
- int val)
+ int val)
{
if (q->HL1 > val) return FALSE; /* HL1 */
+
if (q->LH1 > val) return FALSE; /* LH1 */
+
if (q->HH1 > val) return FALSE; /* HH1 */
+
if (q->HL2 > val) return FALSE; /* HL2 */
+
if (q->LH2 > val) return FALSE; /* LH2 */
+
if (q->HH2 > val) return FALSE; /* HH2 */
+
if (q->HL3 > val) return FALSE; /* HL3 */
+
if (q->LH3 > val) return FALSE; /* LH3 */
+
if (q->HH3 > val) return FALSE; /* HH3 */
+
if (q->LL3 > val) return FALSE; /* LL3 */
+
return TRUE;
}
static BOOL progressive_rfx_quant_cmp_less_equal(RFX_COMPONENT_CODEC_QUANT* q1,
- RFX_COMPONENT_CODEC_QUANT* q2)
+ RFX_COMPONENT_CODEC_QUANT* q2)
{
if (q1->HL1 > q2->HL1) return FALSE; /* HL1 */
+
if (q1->LH1 > q2->LH1) return FALSE; /* LH1 */
+
if (q1->HH1 > q2->HH1) return FALSE; /* HH1 */
+
if (q1->HL2 > q2->HL2) return FALSE; /* HL2 */
+
if (q1->LH2 > q2->LH2) return FALSE; /* LH2 */
+
if (q1->HH2 > q2->HH2) return FALSE; /* HH2 */
+
if (q1->HL3 > q2->HL3) return FALSE; /* HL3 */
+
if (q1->LH3 > q2->LH3) return FALSE; /* LH3 */
+
if (q1->HH3 > q2->HH3) return FALSE; /* HH3 */
+
if (q1->LL3 > q2->LL3) return FALSE; /* LL3 */
+
return TRUE;
}
-static BOOL progressive_rfx_quant_lcmp_greater_equal(RFX_COMPONENT_CODEC_QUANT* q,
- int val)
+static BOOL progressive_rfx_quant_lcmp_greater_equal(RFX_COMPONENT_CODEC_QUANT*
+ q,
+ int val)
{
if (q->HL1 < val) return FALSE; /* HL1 */
+
if (q->LH1 < val) return FALSE; /* LH1 */
+
if (q->HH1 < val) return FALSE; /* HH1 */
+
if (q->HL2 < val) return FALSE; /* HL2 */
+
if (q->LH2 < val) return FALSE; /* LH2 */
+
if (q->HH2 < val) return FALSE; /* HH2 */
+
if (q->HL3 < val) return FALSE; /* HL3 */
+
if (q->LH3 < val) return FALSE; /* LH3 */
+
if (q->HH3 < val) return FALSE; /* HH3 */
+
if (q->LL3 < val) return FALSE; /* LL3 */
+
return TRUE;
}
-static BOOL progressive_rfx_quant_cmp_greater_equal(RFX_COMPONENT_CODEC_QUANT* q1,
- RFX_COMPONENT_CODEC_QUANT* q2)
+static BOOL progressive_rfx_quant_cmp_greater_equal(RFX_COMPONENT_CODEC_QUANT*
+ q1,
+ RFX_COMPONENT_CODEC_QUANT* q2)
{
if (q1->HL1 < q2->HL1) return FALSE; /* HL1 */
+
if (q1->LH1 < q2->LH1) return FALSE; /* LH1 */
+
if (q1->HH1 < q2->HH1) return FALSE; /* HH1 */
+
if (q1->HL2 < q2->HL2) return FALSE; /* HL2 */
+
if (q1->LH2 < q2->LH2) return FALSE; /* LH2 */
+
if (q1->HH2 < q2->HH2) return FALSE; /* HH2 */
+
if (q1->HL3 < q2->HL3) return FALSE; /* HL3 */
+
if (q1->LH3 < q2->LH3) return FALSE; /* LH3 */
+
if (q1->HH3 < q2->HH3) return FALSE; /* HH3 */
+
if (q1->LL3 < q2->LL3) return FALSE; /* LL3 */
+
return TRUE;
}
static BOOL progressive_rfx_quant_cmp_equal(RFX_COMPONENT_CODEC_QUANT* q1,
- RFX_COMPONENT_CODEC_QUANT* q2)
+ RFX_COMPONENT_CODEC_QUANT* q2)
{
if (q1->HL1 != q2->HL1) return FALSE; /* HL1 */
+
if (q1->LH1 != q2->LH1) return FALSE; /* LH1 */
+
if (q1->HH1 != q2->HH1) return FALSE; /* HH1 */
+
if (q1->HL2 != q2->HL2) return FALSE; /* HL2 */
+
if (q1->LH2 != q2->LH2) return FALSE; /* LH2 */
+
if (q1->HH2 != q2->HH2) return FALSE; /* HH2 */
+
if (q1->HL3 != q2->HL3) return FALSE; /* HL3 */
+
if (q1->LH3 != q2->LH3) return FALSE; /* LH3 */
+
if (q1->HH3 != q2->HH3) return FALSE; /* HH3 */
+
if (q1->LL3 != q2->LL3) return FALSE; /* LL3 */
+
return TRUE;
}
static void progressive_rfx_quant_print(RFX_COMPONENT_CODEC_QUANT* q,
- const char* name)
+ const char* name)
{
- fprintf(stderr, "%s: HL1: %d LH1: %d HH1: %d HL2: %d LH2: %d HH2: %d HL3: %d LH3: %d HH3: %d LL3: %d\n",
- name, q->HL1, q->LH1, q->HH1, q->HL2, q->LH2, q->HH2, q->HL3, q->LH3, q->HH3, q->LL3);
+ fprintf(stderr,
+ "%s: HL1: %d LH1: %d HH1: %d HL2: %d LH2: %d HH2: %d HL3: %d LH3: %d HH3: %d LL3: %d\n",
+ name, q->HL1, q->LH1, q->HH1, q->HL2, q->LH2, q->HH2, q->HL3, q->LH3, q->HH3,
+ q->LL3);
}
static int progressive_set_surface_data(PROGRESSIVE_CONTEXT* progressive,
- UINT16 surfaceId, void* pData)
+ UINT16 surfaceId, void* pData)
{
ULONG_PTR key;
-
key = ((ULONG_PTR) surfaceId) + 1;
if (pData)
}
static void* progressive_get_surface_data(PROGRESSIVE_CONTEXT* progressive,
- UINT16 surfaceId)
+ UINT16 surfaceId)
{
ULONG_PTR key;
void* pData = NULL;
-
key = ((ULONG_PTR) surfaceId) + 1;
-
pData = HashTable_GetItemValue(progressive->SurfaceContexts, (void*) key);
-
return pData;
}
static PROGRESSIVE_SURFACE_CONTEXT* progressive_surface_context_new(
- UINT16 surfaceId, UINT32 width, UINT32 height)
+ UINT16 surfaceId, UINT32 width, UINT32 height)
{
PROGRESSIVE_SURFACE_CONTEXT* surface;
-
surface = (PROGRESSIVE_SURFACE_CONTEXT*) calloc(
- 1, sizeof(PROGRESSIVE_SURFACE_CONTEXT));
+ 1, sizeof(PROGRESSIVE_SURFACE_CONTEXT));
if (!surface)
return NULL;
surface->gridWidth = (width + (64 - width % 64)) / 64;
surface->gridHeight = (height + (64 - height % 64)) / 64;
surface->gridSize = surface->gridWidth * surface->gridHeight;
-
surface->tiles = (RFX_PROGRESSIVE_TILE*) calloc(
- surface->gridSize, sizeof(RFX_PROGRESSIVE_TILE));
+ surface->gridSize, sizeof(RFX_PROGRESSIVE_TILE));
if (!surface->tiles)
{
return surface;
}
-static void progressive_surface_context_free(PROGRESSIVE_SURFACE_CONTEXT* surface)
+static void progressive_surface_context_free(PROGRESSIVE_SURFACE_CONTEXT*
+ surface)
{
UINT32 index;
RFX_PROGRESSIVE_TILE* tile;
free(surface);
}
-int progressive_create_surface_context(PROGRESSIVE_CONTEXT* progressive,
- UINT16 surfaceId, UINT32 width, UINT32 height)
+INT32 progressive_create_surface_context(PROGRESSIVE_CONTEXT* progressive,
+ UINT16 surfaceId, UINT32 width, UINT32 height)
{
PROGRESSIVE_SURFACE_CONTEXT* surface;
-
surface = (PROGRESSIVE_SURFACE_CONTEXT*) progressive_get_surface_data(
- progressive, surfaceId);
+ progressive, surfaceId);
if (!surface)
{
return 1;
}
-int progressive_delete_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId)
+int progressive_delete_surface_context(PROGRESSIVE_CONTEXT* progressive,
+ UINT16 surfaceId)
{
PROGRESSIVE_SURFACE_CONTEXT* surface;
-
surface = (PROGRESSIVE_SURFACE_CONTEXT*) progressive_get_surface_data(
- progressive, surfaceId);
+ progressive, surfaceId);
if (surface)
{
* LL3 4015 9x9 81
*/
-static void progressive_rfx_idwt_x(INT16* pLowBand, int nLowStep, INT16* pHighBand,
- int nHighStep, INT16* pDstBand, int nDstStep,
- int nLowCount, int nHighCount, int nDstCount)
+static void progressive_rfx_idwt_x(INT16* pLowBand, int nLowStep,
+ INT16* pHighBand,
+ int nHighStep, INT16* pDstBand, int nDstStep,
+ int nLowCount, int nHighCount, int nDstCount)
{
int i, j;
INT16 L0;
INT16 H0, H1;
INT16 X0, X1, X2;
- INT16 *pL, *pH, *pX;
+ INT16* pL, *pH, *pX;
for (i = 0; i < nDstCount; i++)
{
pL = pLowBand;
pH = pHighBand;
pX = pDstBand;
-
H0 = *pH;
pH++;
-
L0 = *pL;
pL++;
-
X0 = L0 - H0;
X2 = L0 - H0;
{
H1 = *pH;
pH++;
-
L0 = *pL;
pL++;
-
X2 = L0 - ((H0 + H1) / 2);
X1 = ((X0 + X2) / 2) + (2 * H0);
-
pX[0] = X0;
pX[1] = X1;
pX += 2;
-
X0 = X2;
H0 = H1;
}
{
L0 = *pL;
pL++;
-
X0 = L0 - H0;
-
pX[0] = X2;
pX[1] = ((X0 + X2) / 2) + (2 * H0);
pX[2] = X0;
{
L0 = *pL;
pL++;
-
X0 = L0 - (H0 / 2);
-
pX[0] = X2;
pX[1] = ((X0 + X2) / 2) + (2 * H0);
pX[2] = X0;
-
L0 = *pL;
pL++;
-
pX[3] = (X0 + L0) / 2;
}
}
}
-static void progressive_rfx_idwt_y(INT16* pLowBand, int nLowStep, INT16* pHighBand,
- int nHighStep, INT16* pDstBand, int nDstStep,
- int nLowCount, int nHighCount, int nDstCount)
+static void progressive_rfx_idwt_y(INT16* pLowBand, int nLowStep,
+ INT16* pHighBand,
+ int nHighStep, INT16* pDstBand, int nDstStep,
+ int nLowCount, int nHighCount, int nDstCount)
{
int i, j;
INT16 L0;
INT16 H0, H1;
INT16 X0, X1, X2;
- INT16 *pL, *pH, *pX;
+ INT16* pL, *pH, *pX;
for (i = 0; i < nDstCount; i++)
{
pL = pLowBand;
pH = pHighBand;
pX = pDstBand;
-
H0 = *pH;
pH += nHighStep;
-
L0 = *pL;
pL += nLowStep;
-
X0 = L0 - H0;
X2 = L0 - H0;
{
H1 = *pH;
pH += nHighStep;
-
L0 = *pL;
pL += nLowStep;
-
X2 = L0 - ((H0 + H1) / 2);
X1 = ((X0 + X2) / 2) + (2 * H0);
-
*pX = X0;
pX += nDstStep;
-
*pX = X1;
pX += nDstStep;
-
X0 = X2;
H0 = H1;
}
{
*pX = X2;
pX += nDstStep;
-
*pX = X2 + (2 * H0);
pX += nDstStep;
}
{
L0 = *pL;
pL += nLowStep;
-
X0 = L0 - H0;
-
*pX = X2;
pX += nDstStep;
-
*pX = ((X0 + X2) / 2) + (2 * H0);
pX += nDstStep;
-
*pX = X0;
pX += nDstStep;
}
{
L0 = *pL;
pL += nLowStep;
-
X0 = L0 - (H0 / 2);
-
*pX = X2;
pX += nDstStep;
-
*pX = ((X0 + X2) / 2) + (2 * H0);
pX += nDstStep;
-
*pX = X0;
pX += nDstStep;
-
L0 = *pL;
pL += nLowStep;
-
*pX = (X0 + L0) / 2;
pX += nDstStep;
}
return (64 + (1 << (level - 1))) >> level;
}
-static void progressive_rfx_dwt_2d_decode_block(INT16* buffer, INT16* temp, int level)
+static void progressive_rfx_dwt_2d_decode_block(INT16* buffer, INT16* temp,
+ int level)
{
int offset;
int nBandL;
int nBandH;
int nDstStepX;
int nDstStepY;
- INT16 *HL, *LH;
- INT16 *HH, *LL;
- INT16 *L, *H, *LLx;
+ INT16* HL, *LH;
+ INT16* HH, *LL;
+ INT16* L, *H, *LLx;
INT16* pLowBand[3];
INT16* pHighBand[3];
INT16* pDstBand[3];
int nLowCount[3];
int nHighCount[3];
int nDstCount[3];
-
nBandL = progressive_rfx_get_band_l_count(level);
nBandH = progressive_rfx_get_band_h_count(level);
-
offset = 0;
-
HL = &buffer[offset];
offset += (nBandH * nBandL);
-
LH = &buffer[offset];
offset += (nBandL * nBandH);
-
HH = &buffer[offset];
offset += (nBandH * nBandH);
-
LL = &buffer[offset];
offset += (nBandL * nBandL);
-
nDstStepX = (nBandL + nBandH);
nDstStepY = (nBandL + nBandH);
-
offset = 0;
-
L = &temp[offset];
offset += (nBandL * nDstStepX);
-
H = &temp[offset];
offset += (nBandH * nDstStepX);
-
LLx = &buffer[0];
-
/* horizontal (LL + HL -> L) */
-
pLowBand[0] = LL;
nLowStep[0] = nBandL;
pHighBand[0] = HL;
nLowCount[0] = nBandL;
nHighCount[0] = nBandH;
nDstCount[0] = nBandL;
-
- progressive_rfx_idwt_x(pLowBand[0], nLowStep[0], pHighBand[0], nHighStep[0], pDstBand[0], nDstStep[0], nLowCount[0], nHighCount[0], nDstCount[0]);
-
+ progressive_rfx_idwt_x(pLowBand[0], nLowStep[0], pHighBand[0], nHighStep[0],
+ pDstBand[0], nDstStep[0], nLowCount[0], nHighCount[0], nDstCount[0]);
/* horizontal (LH + HH -> H) */
-
pLowBand[1] = LH;
nLowStep[1] = nBandL;
pHighBand[1] = HH;
nLowCount[1] = nBandL;
nHighCount[1] = nBandH;
nDstCount[1] = nBandH;
-
- progressive_rfx_idwt_x(pLowBand[1], nLowStep[1], pHighBand[1], nHighStep[1], pDstBand[1], nDstStep[1], nLowCount[1], nHighCount[1], nDstCount[1]);
-
+ progressive_rfx_idwt_x(pLowBand[1], nLowStep[1], pHighBand[1], nHighStep[1],
+ pDstBand[1], nDstStep[1], nLowCount[1], nHighCount[1], nDstCount[1]);
/* vertical (L + H -> LL) */
-
pLowBand[2] = pDstBand[0];
nLowStep[2] = nDstStep[0];
pHighBand[2] = pDstBand[1];
nLowCount[2] = nBandL;
nHighCount[2] = nBandH;
nDstCount[2] = nBandL + nBandH;
-
- progressive_rfx_idwt_y(pLowBand[2], nLowStep[2], pHighBand[2], nHighStep[2], pDstBand[2], nDstStep[2], nLowCount[2], nHighCount[2], nDstCount[2]);
+ progressive_rfx_idwt_y(pLowBand[2], nLowStep[2], pHighBand[2], nHighStep[2],
+ pDstBand[2], nDstStep[2], nLowCount[2], nHighCount[2], nDstCount[2]);
}
static void progressive_rfx_dwt_2d_decode(INT16* buffer, INT16* temp,
- INT16* current, INT16* sign, BOOL diff)
+ INT16* current, INT16* sign, BOOL diff)
{
const primitives_t* prims = primitives_get();
prims->add_16s(buffer, current, buffer, 4096);
CopyMemory(current, buffer, 4096 * 2);
-
progressive_rfx_dwt_2d_decode_block(&buffer[3807], temp, 3);
progressive_rfx_dwt_2d_decode_block(&buffer[3007], temp, 2);
progressive_rfx_dwt_2d_decode_block(&buffer[0], temp, 1);
}
-static void progressive_rfx_decode_block(const primitives_t* prims, INT16* buffer,
- int length, UINT32 shift)
+static void progressive_rfx_decode_block(const primitives_t* prims,
+ INT16* buffer,
+ int length, UINT32 shift)
{
if (!shift)
return;
}
static int progressive_rfx_decode_component(PROGRESSIVE_CONTEXT* progressive,
- RFX_COMPONENT_CODEC_QUANT* shift,
- const BYTE* data, int length,
- INT16* buffer, INT16* current,
- INT16* sign, BOOL diff)
+ RFX_COMPONENT_CODEC_QUANT* shift,
+ const BYTE* data, int length,
+ INT16* buffer, INT16* current,
+ INT16* sign, BOOL diff)
{
int status;
INT16* temp;
const primitives_t* prims = primitives_get();
-
status = rfx_rlgr_decode(data, length, buffer, 4096, 1);
if (status < 0)
return status;
CopyMemory(sign, buffer, 4096 * 2);
-
rfx_differential_decode(&buffer[4015], 81); /* LL3 */
-
progressive_rfx_decode_block(prims, &buffer[0], 1023, shift->HL1); /* HL1 */
progressive_rfx_decode_block(prims, &buffer[1023], 1023, shift->LH1); /* LH1 */
progressive_rfx_decode_block(prims, &buffer[2046], 961, shift->HH1); /* HH1 */
progressive_rfx_decode_block(prims, &buffer[3879], 72, shift->LH3); /* LH3 */
progressive_rfx_decode_block(prims, &buffer[3951], 64, shift->HH3); /* HH3 */
progressive_rfx_decode_block(prims, &buffer[4015], 81, shift->LL3); /* LL3 */
-
temp = (INT16*) BufferPool_Take(progressive->bufferPool, -1); /* DWT buffer */
-
progressive_rfx_dwt_2d_decode(buffer, temp, current, sign, diff);
-
BufferPool_Return(progressive->bufferPool, temp);
-
return 1;
}
static int progressive_decompress_tile_first(PROGRESSIVE_CONTEXT* progressive,
- RFX_PROGRESSIVE_TILE* tile)
+ RFX_PROGRESSIVE_TILE* tile)
{
BOOL diff;
BYTE* pBuffer;
RFX_PROGRESSIVE_CODEC_QUANT* quantProgVal;
static const prim_size_t roi_64x64 = { 64, 64 };
const primitives_t* prims = primitives_get();
-
tile->pass = 1;
-
diff = tile->flags & RFX_TILE_DIFFERENCE;
-
- WLog_DBG(TAG, "ProgressiveTile%s: quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d flags: 0x%02X quality: %d yLen: %d cbLen: %d crLen: %d tailLen: %d",
- (tile->blockType == PROGRESSIVE_WBT_TILE_FIRST) ? "First" : "Simple",
- tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr,
- tile->xIdx, tile->yIdx, tile->flags, tile->quality, tile->yLen,
- tile->cbLen, tile->crLen, tile->tailLen);
-
+ WLog_DBG(TAG,
+ "ProgressiveTile%s: quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d flags: 0x%02X quality: %d yLen: %d cbLen: %d crLen: %d tailLen: %d",
+ (tile->blockType == PROGRESSIVE_WBT_TILE_FIRST) ? "First" : "Simple",
+ tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr,
+ tile->xIdx, tile->yIdx, tile->flags, tile->quality, tile->yLen,
+ tile->cbLen, tile->crLen, tile->tailLen);
region = &(progressive->region);
if (tile->quantIdxY >= region->numQuant)
quantProgY = &(quantProgVal->yQuantValues);
quantProgCb = &(quantProgVal->cbQuantValues);
quantProgCr = &(quantProgVal->crQuantValues);
-
CopyMemory(&(tile->yQuant), quantY, sizeof(RFX_COMPONENT_CODEC_QUANT));
CopyMemory(&(tile->cbQuant), quantCb, sizeof(RFX_COMPONENT_CODEC_QUANT));
CopyMemory(&(tile->crQuant), quantCr, sizeof(RFX_COMPONENT_CODEC_QUANT));
-
CopyMemory(&(tile->yProgQuant), quantProgY, sizeof(RFX_COMPONENT_CODEC_QUANT));
- CopyMemory(&(tile->cbProgQuant), quantProgCb, sizeof(RFX_COMPONENT_CODEC_QUANT));
- CopyMemory(&(tile->crProgQuant), quantProgCr, sizeof(RFX_COMPONENT_CODEC_QUANT));
-
+ CopyMemory(&(tile->cbProgQuant), quantProgCb,
+ sizeof(RFX_COMPONENT_CODEC_QUANT));
+ CopyMemory(&(tile->crProgQuant), quantProgCr,
+ sizeof(RFX_COMPONENT_CODEC_QUANT));
progressive_rfx_quant_add(quantY, quantProgY, &(tile->yBitPos));
progressive_rfx_quant_add(quantCb, quantProgCb, &(tile->cbBitPos));
progressive_rfx_quant_add(quantCr, quantProgCr, &(tile->crBitPos));
-
progressive_rfx_quant_add(quantY, quantProgY, &shiftY);
progressive_rfx_quant_lsub(&shiftY, 1); /* -6 + 5 = -1 */
progressive_rfx_quant_add(quantCb, quantProgCb, &shiftCb);
pBuffer = tile->sign;
pSign[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* Y/R buffer */
- pSign[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* Cb/G buffer */
- pSign[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* Cr/B buffer */
-
+ pSign[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) +
+ 16])); /* Cb/G buffer */
+ pSign[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) +
+ 16])); /* Cr/B buffer */
pBuffer = tile->current;
- pCurrent[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* Y/R buffer */
- pCurrent[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* Cb/G buffer */
- pCurrent[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* Cr/B buffer */
-
+ pCurrent[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) +
+ 16])); /* Y/R buffer */
+ pCurrent[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) +
+ 16])); /* Cb/G buffer */
+ pCurrent[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) +
+ 16])); /* Cr/B buffer */
pBuffer = (BYTE*) BufferPool_Take(progressive->bufferPool, -1);
- pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* Y/R buffer */
- pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* Cb/G buffer */
- pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* Cr/B buffer */
-
+ pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) +
+ 16])); /* Y/R buffer */
+ pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) +
+ 16])); /* Cb/G buffer */
+ pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) +
+ 16])); /* Cr/B buffer */
progressive_rfx_decode_component(progressive, &shiftY, tile->yData, tile->yLen,
- pSrcDst[0], pCurrent[0], pSign[0], diff); /* Y */
- progressive_rfx_decode_component(progressive, &shiftCb, tile->cbData, tile->cbLen,
- pSrcDst[1], pCurrent[1], pSign[1], diff); /* Cb */
- progressive_rfx_decode_component(progressive, &shiftCr, tile->crData, tile->crLen,
- pSrcDst[2], pCurrent[2], pSign[2], diff); /* Cr */
+ pSrcDst[0], pCurrent[0], pSign[0], diff); /* Y */
+ progressive_rfx_decode_component(progressive, &shiftCb, tile->cbData,
+ tile->cbLen,
+ pSrcDst[1], pCurrent[1], pSign[1], diff); /* Cb */
+ progressive_rfx_decode_component(progressive, &shiftCr, tile->crData,
+ tile->crLen,
+ pSrcDst[2], pCurrent[2], pSign[2], diff); /* Cr */
if (!progressive->invert)
prims->yCbCrToRGB_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2,
- tile->data, PIXEL_FORMAT_BGRX32,
- 64 * 4, &roi_64x64);
+ tile->data, PIXEL_FORMAT_BGRX32,
+ 64 * 4, &roi_64x64);
else
prims->yCbCrToBGR_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2,
- tile->data, PIXEL_FORMAT_BGRX32,
- 64 * 4, &roi_64x64);
+ tile->data, PIXEL_FORMAT_BGRX32,
+ 64 * 4, &roi_64x64);
BufferPool_Return(progressive->bufferPool, pBuffer);
-
return 1;
}
typedef struct _RFX_PROGRESSIVE_UPGRADE_STATE RFX_PROGRESSIVE_UPGRADE_STATE;
static INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* state,
- UINT32 numBits)
+ UINT32 numBits)
{
int k;
UINT32 bit;
if (!state->mode)
{
/* zero encoding */
-
bit = (bs->accumulator & 0x80000000) ? 1 : 0;
BitStream_Shift(bs, 1);
if (!bit)
{
/* '0' bit, nz >= (1 << k), nz = (1 << k) */
-
state->nz = (1 << k);
-
state->kp += 4;
if (state->kp > 80)
else
{
/* '1' bit, nz < (1 << k), nz = next k bits */
-
state->nz = 0;
state->mode = 1; /* unary encoding is next */
}
state->mode = 0; /* zero encoding is next */
-
/* unary encoding */
-
/* read sign bit */
-
sign = (bs->accumulator & 0x80000000) ? 1 : 0;
BitStream_Shift(bs, 1);
-
state->kp -= 6;
if (state->kp < 0)
return sign ? -1 * mag : mag;
}
-static int progressive_rfx_upgrade_state_finish(RFX_PROGRESSIVE_UPGRADE_STATE* state)
+static int progressive_rfx_upgrade_state_finish(RFX_PROGRESSIVE_UPGRADE_STATE*
+ state)
{
int pad;
wBitStream* srl;
wBitStream* raw;
-
srl = state->srl;
raw = state->raw;
-
/* Read trailing bits from RAW/SRL bit streams */
-
pad = (raw->position % 8) ? (8 - (raw->position % 8)) : 0;
if (pad)
}
static int progressive_rfx_upgrade_block(RFX_PROGRESSIVE_UPGRADE_STATE* state,
- INT16* buffer, INT16* sign, UINT32 length,
- UINT32 shift, UINT32 bitPos, UINT32 numBits)
+ INT16* buffer, INT16* sign, UINT32 length,
+ UINT32 shift, UINT32 bitPos, UINT32 numBits)
{
int index;
INT16 input;
for (index = 0; index < length; index++)
{
raw->mask = ((1 << numBits) - 1);
- input = (INT16) ((raw->accumulator >> (32 - numBits)) & raw->mask);
+ input = (INT16)((raw->accumulator >> (32 - numBits)) & raw->mask);
BitStream_Shift(raw, numBits);
-
buffer[index] += (input << shift);
}
if (sign[index] > 0)
{
/* sign > 0, read from raw */
-
raw->mask = ((1 << numBits) - 1);
- input = (INT16) ((raw->accumulator >> (32 - numBits)) & raw->mask);
+ input = (INT16)((raw->accumulator >> (32 - numBits)) & raw->mask);
BitStream_Shift(raw, numBits);
}
else if (sign[index] < 0)
{
/* sign < 0, read from raw */
-
raw->mask = ((1 << numBits) - 1);
- input = (INT16) ((raw->accumulator >> (32 - numBits)) & raw->mask);
+ input = (INT16)((raw->accumulator >> (32 - numBits)) & raw->mask);
BitStream_Shift(raw, numBits);
-
input *= -1;
}
else
{
/* sign == 0, read from srl */
-
input = progressive_rfx_srl_read(state, numBits);
-
sign[index] = input;
}
}
static int progressive_rfx_upgrade_component(PROGRESSIVE_CONTEXT* progressive,
- RFX_COMPONENT_CODEC_QUANT* shift,
- RFX_COMPONENT_CODEC_QUANT* bitPos,
- RFX_COMPONENT_CODEC_QUANT* numBits,
- INT16* buffer,
- INT16* current, INT16* sign,
- const BYTE* srlData,
- UINT32 srlLen, const BYTE* rawData,
- UINT32 rawLen)
+ RFX_COMPONENT_CODEC_QUANT* shift,
+ RFX_COMPONENT_CODEC_QUANT* bitPos,
+ RFX_COMPONENT_CODEC_QUANT* numBits,
+ INT16* buffer,
+ INT16* current, INT16* sign,
+ const BYTE* srlData,
+ UINT32 srlLen, const BYTE* rawData,
+ UINT32 rawLen)
{
INT16* temp;
UINT32 aRawLen;
wBitStream s_srl;
wBitStream s_raw;
RFX_PROGRESSIVE_UPGRADE_STATE state;
-
ZeroMemory(&s_srl, sizeof(wBitStream));
ZeroMemory(&s_raw, sizeof(wBitStream));
ZeroMemory(&state, sizeof(RFX_PROGRESSIVE_UPGRADE_STATE));
-
state.kp = 8;
state.mode = 0;
state.srl = &s_srl;
state.raw = &s_raw;
-
BitStream_Attach(state.srl, srlData, srlLen);
BitStream_Fetch(state.srl);
-
BitStream_Attach(state.raw, rawData, rawLen);
BitStream_Fetch(state.raw);
-
state.nonLL = TRUE;
- progressive_rfx_upgrade_block(&state, ¤t[0], &sign[0], 1023, shift->HL1, bitPos->HL1, numBits->HL1); /* HL1 */
- progressive_rfx_upgrade_block(&state, ¤t[1023], &sign[1023], 1023, shift->LH1, bitPos->LH1, numBits->LH1); /* LH1 */
- progressive_rfx_upgrade_block(&state, ¤t[2046], &sign[2046], 961, shift->HH1, bitPos->HH1, numBits->HH1); /* HH1 */
- progressive_rfx_upgrade_block(&state, ¤t[3007], &sign[3007], 272, shift->HL2, bitPos->HL2, numBits->HL2); /* HL2 */
- progressive_rfx_upgrade_block(&state, ¤t[3279], &sign[3279], 272, shift->LH2, bitPos->LH2, numBits->LH2); /* LH2 */
- progressive_rfx_upgrade_block(&state, ¤t[3551], &sign[3551], 256, shift->HH2, bitPos->HH2, numBits->HH2); /* HH2 */
- progressive_rfx_upgrade_block(&state, ¤t[3807], &sign[3807], 72, shift->HL3, bitPos->HL3, numBits->HL3); /* HL3 */
- progressive_rfx_upgrade_block(&state, ¤t[3879], &sign[3879], 72, shift->LH3, bitPos->LH3, numBits->LH3); /* LH3 */
- progressive_rfx_upgrade_block(&state, ¤t[3951], &sign[3951], 64, shift->HH3, bitPos->HH3, numBits->HH3); /* HH3 */
-
+ progressive_rfx_upgrade_block(&state, ¤t[0], &sign[0], 1023, shift->HL1,
+ bitPos->HL1, numBits->HL1); /* HL1 */
+ progressive_rfx_upgrade_block(&state, ¤t[1023], &sign[1023], 1023,
+ shift->LH1, bitPos->LH1, numBits->LH1); /* LH1 */
+ progressive_rfx_upgrade_block(&state, ¤t[2046], &sign[2046], 961,
+ shift->HH1, bitPos->HH1, numBits->HH1); /* HH1 */
+ progressive_rfx_upgrade_block(&state, ¤t[3007], &sign[3007], 272,
+ shift->HL2, bitPos->HL2, numBits->HL2); /* HL2 */
+ progressive_rfx_upgrade_block(&state, ¤t[3279], &sign[3279], 272,
+ shift->LH2, bitPos->LH2, numBits->LH2); /* LH2 */
+ progressive_rfx_upgrade_block(&state, ¤t[3551], &sign[3551], 256,
+ shift->HH2, bitPos->HH2, numBits->HH2); /* HH2 */
+ progressive_rfx_upgrade_block(&state, ¤t[3807], &sign[3807], 72,
+ shift->HL3, bitPos->HL3, numBits->HL3); /* HL3 */
+ progressive_rfx_upgrade_block(&state, ¤t[3879], &sign[3879], 72,
+ shift->LH3, bitPos->LH3, numBits->LH3); /* LH3 */
+ progressive_rfx_upgrade_block(&state, ¤t[3951], &sign[3951], 64,
+ shift->HH3, bitPos->HH3, numBits->HH3); /* HH3 */
state.nonLL = FALSE;
- progressive_rfx_upgrade_block(&state, ¤t[4015], &sign[4015], 81, shift->LL3, bitPos->LL3, numBits->LL3); /* LL3 */
+ progressive_rfx_upgrade_block(&state, ¤t[4015], &sign[4015], 81,
+ shift->LL3, bitPos->LL3, numBits->LL3); /* LL3 */
progressive_rfx_upgrade_state_finish(&state);
-
aRawLen = (state.raw->position + 7) / 8;
aSrlLen = (state.srl->position + 7) / 8;
int pSrlLen = 0;
if (rawLen)
- pRawLen = (int) ((((float) aRawLen) / ((float) rawLen)) * 100.0f);
+ pRawLen = (int)((((float) aRawLen) / ((float) rawLen)) * 100.0f);
if (srlLen)
- pSrlLen = (int) ((((float) aSrlLen) / ((float) srlLen)) * 100.0f);
+ pSrlLen = (int)((((float) aSrlLen) / ((float) srlLen)) * 100.0f);
WLog_INFO(TAG, "RAW: %d/%d %d%% (%d/%d:%d)\tSRL: %d/%d %d%% (%d/%d:%d)",
- aRawLen, rawLen, pRawLen, state.raw->position, rawLen * 8,
- (rawLen * 8) - state.raw->position,
- aSrlLen, srlLen, pSrlLen, state.srl->position, srlLen * 8,
- (srlLen * 8) - state.srl->position);
-
+ aRawLen, rawLen, pRawLen, state.raw->position, rawLen * 8,
+ (rawLen * 8) - state.raw->position,
+ aSrlLen, srlLen, pSrlLen, state.srl->position, srlLen * 8,
+ (srlLen * 8) - state.srl->position);
return -1;
}
temp = (INT16*) BufferPool_Take(progressive->bufferPool, -1); /* DWT buffer */
-
CopyMemory(buffer, current, 4096 * 2);
-
progressive_rfx_dwt_2d_decode_block(&buffer[3807], temp, 3);
progressive_rfx_dwt_2d_decode_block(&buffer[3007], temp, 2);
progressive_rfx_dwt_2d_decode_block(&buffer[0], temp, 1);
-
BufferPool_Return(progressive->bufferPool, temp);
-
return 1;
}
static int progressive_decompress_tile_upgrade(PROGRESSIVE_CONTEXT* progressive,
- RFX_PROGRESSIVE_TILE* tile)
+ RFX_PROGRESSIVE_TILE* tile)
{
int status;
BYTE* pBuffer;
RFX_PROGRESSIVE_CODEC_QUANT* quantProg;
static const prim_size_t roi_64x64 = { 64, 64 };
const primitives_t* prims = primitives_get();
-
tile->pass++;
-
- WLog_DBG(TAG, "ProgressiveTileUpgrade: pass: %d quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d quality: %d ySrlLen: %d yRawLen: %d cbSrlLen: %d cbRawLen: %d crSrlLen: %d crRawLen: %d",
- tile->pass, tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx, tile->yIdx, tile->quality, tile->ySrlLen, tile->yRawLen, tile->cbSrlLen, tile->cbRawLen, tile->crSrlLen, tile->crRawLen);
-
+ WLog_DBG(TAG,
+ "ProgressiveTileUpgrade: pass: %d quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d quality: %d ySrlLen: %d yRawLen: %d cbSrlLen: %d cbRawLen: %d crSrlLen: %d crRawLen: %d",
+ tile->pass, tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx,
+ tile->yIdx, tile->quality, tile->ySrlLen, tile->yRawLen, tile->cbSrlLen,
+ tile->cbRawLen, tile->crSrlLen, tile->crRawLen);
region = &(progressive->region);
if (tile->quantIdxY >= region->numQuant)
if (!progressive_rfx_quant_cmp_equal(quantY, &(tile->yQuant)))
WLog_WARN(TAG, "non-progressive quantY has changed!");
+
if (!progressive_rfx_quant_cmp_equal(quantCb, &(tile->cbQuant)))
WLog_WARN(TAG, "non-progressive quantCb has changed!");
+
if (!progressive_rfx_quant_cmp_equal(quantCr, &(tile->crQuant)))
WLog_WARN(TAG, "non-progressive quantCr has changed!");
progressive_rfx_quant_add(quantY, quantProgY, &yBitPos);
progressive_rfx_quant_add(quantCb, quantProgCb, &cbBitPos);
progressive_rfx_quant_add(quantCr, quantProgCr, &crBitPos);
-
progressive_rfx_quant_sub(&(tile->yBitPos), &yBitPos, &yNumBits);
progressive_rfx_quant_sub(&(tile->cbBitPos), &cbBitPos, &cbNumBits);
progressive_rfx_quant_sub(&(tile->crBitPos), &crBitPos, &crNumBits);
-
progressive_rfx_quant_add(quantY, quantProgY, &shiftY);
progressive_rfx_quant_lsub(&shiftY, 1); /* -6 + 5 = -1 */
progressive_rfx_quant_add(quantCb, quantProgCb, &shiftCb);
progressive_rfx_quant_lsub(&shiftCb, 1); /* -6 + 5 = -1 */
progressive_rfx_quant_add(quantCr, quantProgCr, &shiftCr);
progressive_rfx_quant_lsub(&shiftCr, 1); /* -6 + 5 = -1 */
-
CopyMemory(&(tile->yBitPos), &yBitPos, sizeof(RFX_COMPONENT_CODEC_QUANT));
CopyMemory(&(tile->cbBitPos), &cbBitPos, sizeof(RFX_COMPONENT_CODEC_QUANT));
CopyMemory(&(tile->crBitPos), &crBitPos, sizeof(RFX_COMPONENT_CODEC_QUANT));
-
CopyMemory(&(tile->yQuant), quantY, sizeof(RFX_COMPONENT_CODEC_QUANT));
CopyMemory(&(tile->cbQuant), quantCb, sizeof(RFX_COMPONENT_CODEC_QUANT));
CopyMemory(&(tile->crQuant), quantCr, sizeof(RFX_COMPONENT_CODEC_QUANT));
-
CopyMemory(&(tile->yProgQuant), quantProgY, sizeof(RFX_COMPONENT_CODEC_QUANT));
- CopyMemory(&(tile->cbProgQuant), quantProgCb, sizeof(RFX_COMPONENT_CODEC_QUANT));
- CopyMemory(&(tile->crProgQuant), quantProgCr, sizeof(RFX_COMPONENT_CODEC_QUANT));
-
+ CopyMemory(&(tile->cbProgQuant), quantProgCb,
+ sizeof(RFX_COMPONENT_CODEC_QUANT));
+ CopyMemory(&(tile->crProgQuant), quantProgCr,
+ sizeof(RFX_COMPONENT_CODEC_QUANT));
pBuffer = tile->sign;
pSign[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* Y/R buffer */
- pSign[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* Cb/G buffer */
- pSign[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* Cr/B buffer */
-
+ pSign[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) +
+ 16])); /* Cb/G buffer */
+ pSign[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) +
+ 16])); /* Cr/B buffer */
pBuffer = tile->current;
- pCurrent[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* Y/R buffer */
- pCurrent[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* Cb/G buffer */
- pCurrent[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* Cr/B buffer */
-
+ pCurrent[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) +
+ 16])); /* Y/R buffer */
+ pCurrent[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) +
+ 16])); /* Cb/G buffer */
+ pCurrent[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) +
+ 16])); /* Cr/B buffer */
pBuffer = (BYTE*) BufferPool_Take(progressive->bufferPool, -1);
- pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* Y/R buffer */
- pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* Cb/G buffer */
- pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* Cr/B buffer */
-
- status = progressive_rfx_upgrade_component(progressive, &shiftY, quantProgY, &yNumBits,
- pSrcDst[0], pCurrent[0], pSign[0], tile->ySrlData, tile->ySrlLen, tile->yRawData, tile->yRawLen); /* Y */
+ pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) +
+ 16])); /* Y/R buffer */
+ pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) +
+ 16])); /* Cb/G buffer */
+ pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) +
+ 16])); /* Cr/B buffer */
+ status = progressive_rfx_upgrade_component(progressive, &shiftY, quantProgY,
+ &yNumBits,
+ pSrcDst[0], pCurrent[0], pSign[0], tile->ySrlData, tile->ySrlLen,
+ tile->yRawData, tile->yRawLen); /* Y */
if (status < 0)
return -1;
- status = progressive_rfx_upgrade_component(progressive, &shiftCb, quantProgCb, &cbNumBits,
- pSrcDst[1], pCurrent[1], pSign[1], tile->cbSrlData, tile->cbSrlLen, tile->cbRawData, tile->cbRawLen); /* Cb */
+ status = progressive_rfx_upgrade_component(progressive, &shiftCb, quantProgCb,
+ &cbNumBits,
+ pSrcDst[1], pCurrent[1], pSign[1], tile->cbSrlData, tile->cbSrlLen,
+ tile->cbRawData, tile->cbRawLen); /* Cb */
if (status < 0)
return -1;
- status = progressive_rfx_upgrade_component(progressive, &shiftCr, quantProgCr, &crNumBits,
- pSrcDst[2], pCurrent[2], pSign[2], tile->crSrlData, tile->crSrlLen, tile->crRawData, tile->crRawLen); /* Cr */
+ status = progressive_rfx_upgrade_component(progressive, &shiftCr, quantProgCr,
+ &crNumBits,
+ pSrcDst[2], pCurrent[2], pSign[2], tile->crSrlData, tile->crSrlLen,
+ tile->crRawData, tile->crRawLen); /* Cr */
if (status < 0)
return -1;
if (!progressive->invert)
prims->yCbCrToRGB_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2,
- tile->data, PIXEL_FORMAT_BGRX32,
- 64 * 4, &roi_64x64);
+ tile->data, PIXEL_FORMAT_BGRX32,
+ 64 * 4, &roi_64x64);
else
prims->yCbCrToBGR_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2,
- tile->data, PIXEL_FORMAT_BGRX32,
- 64 * 4, &roi_64x64);
+ tile->data, PIXEL_FORMAT_BGRX32,
+ 64 * 4, &roi_64x64);
BufferPool_Return(progressive->bufferPool, pBuffer);
-
return 1;
}
static int progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive,
- const BYTE* blocks, UINT32 blocksLen,
- const PROGRESSIVE_SURFACE_CONTEXT* surface)
+ const BYTE* blocks, UINT32 blocksLen,
+ const PROGRESSIVE_SURFACE_CONTEXT* surface)
{
int status = -1;
const BYTE* block;
RFX_PROGRESSIVE_TILE* tile;
RFX_PROGRESSIVE_TILE** tiles;
PROGRESSIVE_BLOCK_REGION* region;
-
region = &(progressive->region);
-
tiles = region->tiles;
while ((blocksLen - offset) >= 6)
{
boffset = 0;
block = &blocks[offset];
-
blockType = *((UINT16*) &block[boffset + 0]); /* blockType (2 bytes) */
blockLen = *((UINT32*) &block[boffset + 2]); /* blockLen (4 bytes) */
boffset += 6;
switch (blockType)
{
case PROGRESSIVE_WBT_TILE_SIMPLE:
-
if ((blockLen - boffset) < 16)
return -1022;
xIdx = *((UINT16*) &block[boffset + 3]); /* xIdx (2 bytes) */
yIdx = *((UINT16*) &block[boffset + 5]); /* yIdx (2 bytes) */
-
zIdx = (yIdx * surface->gridWidth) + xIdx;
if (zIdx >= surface->gridSize)
return -1;
tiles[count] = tile = &(surface->tiles[zIdx]);
-
tile->blockType = blockType;
tile->blockLen = blockLen;
-
tile->quality = 0xFF; /* simple tiles use no progressive techniques */
-
tile->quantIdxY = block[boffset + 0]; /* quantIdxY (1 byte) */
tile->quantIdxCb = block[boffset + 1]; /* quantIdxCb (1 byte) */
tile->quantIdxCr = block[boffset + 2]; /* quantIdxCr (1 byte) */
tile->tailData = &block[boffset];
boffset += tile->tailLen;
-
tile->width = 64;
tile->height = 64;
tile->x = tile->xIdx * 64;
tile->y = tile->yIdx * 64;
-
tile->flags &= 1;
-
break;
case PROGRESSIVE_WBT_TILE_FIRST:
-
if ((blockLen - boffset) < 17)
return -1027;
xIdx = *((UINT16*) &block[boffset + 3]); /* xIdx (2 bytes) */
yIdx = *((UINT16*) &block[boffset + 5]); /* yIdx (2 bytes) */
-
zIdx = (yIdx * surface->gridWidth) + xIdx;
if (zIdx >= surface->gridSize)
return -1;
tiles[count] = tile = &(surface->tiles[zIdx]);
-
tile->blockType = blockType;
tile->blockLen = blockLen;
-
tile->quantIdxY = block[boffset + 0]; /* quantIdxY (1 byte) */
tile->quantIdxCb = block[boffset + 1]; /* quantIdxCb (1 byte) */
tile->quantIdxCr = block[boffset + 2]; /* quantIdxCr (1 byte) */
tile->tailData = &block[boffset];
boffset += tile->tailLen;
-
tile->width = 64;
tile->height = 64;
tile->x = tile->xIdx * 64;
tile->y = tile->yIdx * 64;
-
break;
case PROGRESSIVE_WBT_TILE_UPGRADE:
-
if ((blockLen - boffset) < 20)
return -1032;
xIdx = *((UINT16*) &block[boffset + 3]); /* xIdx (2 bytes) */
yIdx = *((UINT16*) &block[boffset + 5]); /* yIdx (2 bytes) */
-
zIdx = (yIdx * surface->gridWidth) + xIdx;
if (zIdx >= surface->gridSize)
return -1;
tiles[count] = tile = &(surface->tiles[zIdx]);
-
tile->blockType = blockType;
tile->blockLen = blockLen;
-
tile->flags = 0;
-
tile->quantIdxY = block[boffset + 0]; /* quantIdxY (1 byte) */
tile->quantIdxCb = block[boffset + 1]; /* quantIdxCb (1 byte) */
tile->quantIdxCr = block[boffset + 2]; /* quantIdxCr (1 byte) */
tile->crRawData = &block[boffset];
boffset += tile->crRawLen;
-
tile->width = 64;
tile->height = 64;
tile->x = tile->xIdx * 64;
tile->y = tile->yIdx * 64;
-
break;
default:
if (count != region->numTiles)
{
- WLog_WARN(TAG, "numTiles inconsistency: actual: %d, expected: %d\n", count, region->numTiles);
+ WLog_WARN(TAG, "numTiles inconsistency: actual: %d, expected: %d\n", count,
+ region->numTiles);
}
for (index = 0; index < region->numTiles; index++)
return (int) offset;
}
-UINT progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
- const BYTE* pSrcData, UINT32 SrcSize,
- BYTE* pDstData, UINT32 DstFormat,
- UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight, UINT16 surfaceId)
+INT32 progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
+ const BYTE* pSrcData, UINT32 SrcSize,
+ BYTE* pDstData, UINT32 DstFormat,
+ UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+ UINT32 nWidth, UINT32 nHeight, UINT16 surfaceId)
{
UINT status;
const BYTE* block;
PROGRESSIVE_SURFACE_CONTEXT* surface;
RFX_COMPONENT_CODEC_QUANT* quantVal;
RFX_PROGRESSIVE_CODEC_QUANT* quantProgVal;
-
progressive->invert = FREERDP_PIXEL_FORMAT_IS_ABGR(DstFormat) ? TRUE : FALSE;
-
- surface = (PROGRESSIVE_SURFACE_CONTEXT*) progressive_get_surface_data(progressive, surfaceId);
+ surface = (PROGRESSIVE_SURFACE_CONTEXT*) progressive_get_surface_data(
+ progressive, surfaceId);
if (!surface)
return -1001;
blocks = pSrcData;
blocksLen = SrcSize;
-
region = &(progressive->region);
while ((blocksLen - offset) >= 6)
{
boffset = 0;
block = &blocks[offset];
-
blockType = *((UINT16*) &block[boffset + 0]); /* blockType (2 bytes) */
blockLen = *((UINT32*) &block[boffset + 2]); /* blockLen (4 bytes) */
boffset += 6;
switch (blockType)
{
case PROGRESSIVE_WBT_SYNC:
-
WLog_DBG(TAG, "ProgressiveSync");
-
sync.blockType = blockType;
sync.blockLen = blockLen;
if ((blockLen - boffset) != 6)
return -1004;
- sync.magic = (UINT32) *((UINT32*) &block[boffset + 0]); /* magic (4 bytes) */
- sync.version = (UINT32) *((UINT16*) &block[boffset + 4]); /* version (2 bytes) */
+ sync.magic = (UINT32) * ((UINT32*) &block[boffset + 0]); /* magic (4 bytes) */
+ sync.version = (UINT32) * ((UINT16*) &block[boffset +
+ 4]); /* version (2 bytes) */
boffset += 6;
if (sync.magic != 0xCACCACCA)
break;
case PROGRESSIVE_WBT_FRAME_BEGIN:
-
frameBegin.blockType = blockType;
frameBegin.blockLen = blockLen;
if ((blockLen - boffset) < 6)
return -1007;
- frameBegin.frameIndex = (UINT32) *((UINT32*) &block[boffset + 0]); /* frameIndex (4 bytes) */
- frameBegin.regionCount = (UINT32) *((UINT16*) &block[boffset + 4]); /* regionCount (2 bytes) */
+ frameBegin.frameIndex = (UINT32) * ((UINT32*) &block[boffset +
+ 0]); /* frameIndex (4 bytes) */
+ frameBegin.regionCount = (UINT32) * ((UINT16*) &block[boffset +
+ 4]); /* regionCount (2 bytes) */
boffset += 6;
-
WLog_DBG(TAG, "ProgressiveFrameBegin: frameIndex: %d regionCount: %d",
- frameBegin.frameIndex, frameBegin.regionCount);
-
+ frameBegin.frameIndex, frameBegin.regionCount);
/**
* If the number of elements specified by the regionCount field is
* larger than the actual number of elements in the regions field,
* the decoder SHOULD ignore this inconsistency.
*/
-
break;
case PROGRESSIVE_WBT_FRAME_END:
-
WLog_DBG(TAG, "ProgressiveFrameEnd");
-
frameEnd.blockType = blockType;
frameEnd.blockLen = blockLen;
break;
case PROGRESSIVE_WBT_CONTEXT:
-
context.blockType = blockType;
context.blockLen = blockLen;
break;
case PROGRESSIVE_WBT_REGION:
-
region->blockType = blockType;
region->blockLen = blockLen;
region->numProgQuant = block[boffset + 4]; /* numProgQuant (1 byte) */
region->flags = block[boffset + 5]; /* flags (1 byte) */
region->numTiles = *((UINT16*) &block[boffset + 6]); /* numTiles (2 bytes) */
- region->tileDataSize = *((UINT32*) &block[boffset + 8]); /* tileDataSize (4 bytes) */
+ region->tileDataSize = *((UINT32*) &block[boffset +
+ 8]); /* tileDataSize (4 bytes) */
boffset += 12;
if (region->tileSize != 64)
if (region->numRects > progressive->cRects)
{
- progressive->rects = (RFX_RECT*) realloc(progressive->rects, region->numRects * sizeof(RFX_RECT));
+ progressive->rects = (RFX_RECT*) realloc(progressive->rects,
+ region->numRects * sizeof(RFX_RECT));
progressive->cRects = region->numRects;
}
if (region->numQuant > progressive->cQuant)
{
- progressive->quantVals = (RFX_COMPONENT_CODEC_QUANT*) realloc(progressive->quantVals,
- region->numQuant * sizeof(RFX_COMPONENT_CODEC_QUANT));
+ progressive->quantVals = (RFX_COMPONENT_CODEC_QUANT*) realloc(
+ progressive->quantVals,
+ region->numQuant * sizeof(RFX_COMPONENT_CODEC_QUANT));
progressive->cQuant = region->numQuant;
}
if (region->numProgQuant > progressive->cProgQuant)
{
- progressive->quantProgVals = (RFX_PROGRESSIVE_CODEC_QUANT*) realloc(progressive->quantProgVals,
- region->numProgQuant * sizeof(RFX_PROGRESSIVE_CODEC_QUANT));
+ progressive->quantProgVals = (RFX_PROGRESSIVE_CODEC_QUANT*) realloc(
+ progressive->quantProgVals,
+ region->numProgQuant * sizeof(RFX_PROGRESSIVE_CODEC_QUANT));
progressive->cProgQuant = region->numProgQuant;
}
{
quantProgVal = &(region->quantProgVals[index]);
quantProgVal->quality = block[boffset + 0];
-
- progressive_component_codec_quant_read(&block[boffset + 1], &(quantProgVal->yQuantValues));
- progressive_component_codec_quant_read(&block[boffset + 6], &(quantProgVal->cbQuantValues));
- progressive_component_codec_quant_read(&block[boffset + 11], &(quantProgVal->crQuantValues));
+ progressive_component_codec_quant_read(&block[boffset + 1],
+ &(quantProgVal->yQuantValues));
+ progressive_component_codec_quant_read(&block[boffset + 6],
+ &(quantProgVal->cbQuantValues));
+ progressive_component_codec_quant_read(&block[boffset + 11],
+ &(quantProgVal->crQuantValues));
boffset += 16;
}
if (progressive->cTiles < surface->gridSize)
{
progressive->tiles = (RFX_PROGRESSIVE_TILE**) realloc(progressive->tiles,
- surface->gridSize * sizeof(RFX_PROGRESSIVE_TILE*));
+ surface->gridSize * sizeof(RFX_PROGRESSIVE_TILE*));
progressive->cTiles = surface->gridSize;
}
if (!region->tiles)
return -1;
- WLog_DBG(TAG, "ProgressiveRegion: numRects: %d numTiles: %d tileDataSize: %d flags: 0x%02X numQuant: %d numProgQuant: %d",
- region->numRects, region->numTiles, region->tileDataSize, region->flags, region->numQuant, region->numProgQuant);
+ WLog_DBG(TAG,
+ "ProgressiveRegion: numRects: %d numTiles: %d tileDataSize: %d flags: 0x%02X numQuant: %d numProgQuant: %d",
+ region->numRects, region->numTiles, region->tileDataSize, region->flags,
+ region->numQuant, region->numProgQuant);
if (!(region->flags & RFX_DWT_REDUCE_EXTRAPOLATE))
{
for (index = 0; index < region->numRects; index++)
{
rect = &(region->rects[index]);
-
idxLeft = rect->x / 64;
idxTop = rect->y / 64;
idxRight = (rect->x + rect->width + 63) / 64;
boxBottom = idxBottom;
WLog_DBG(TAG, "rect[%d]: x: %d y: %d w: %d h: %d",
- index, rect->x, rect->y, rect->width, rect->height);
+ index, rect->x, rect->y, rect->width, rect->height);
}
- status = progressive_process_tiles(progressive, &block[boffset], region->tileDataSize, surface);
+ status = progressive_process_tiles(progressive, &block[boffset],
+ region->tileDataSize, surface);
if (status < 0)
return status;
}
boffset += (UINT32) status;
-
break;
default:
return -1041;
region = &(progressive->region);
-
region16_init(&clippingRects);
for (i = 0; i < region->numRects; i++)
{
RECTANGLE_16 clippingRect;
RFX_RECT* rect = &(region->rects[i]);
-
clippingRect.left = nXDst + rect->x;
clippingRect.top = nYDst + rect->y;
clippingRect.right = clippingRect.left + rect->width;
clippingRect.bottom = clippingRect.top + rect->height;
-
region16_union_rect(&clippingRects, &clippingRects, &clippingRect);
}
const RECTANGLE_16* updateRects;
RECTANGLE_16 updateRect;
RFX_PROGRESSIVE_TILE* tile = region->tiles[i];
-
updateRect.left = nXDst + tile->x;
updateRect.top = nYDst + tile->y;
updateRect.right = updateRect.left + 64;
updateRect.bottom = updateRect.top + 64;
-
region16_init(&updateRegion);
region16_intersect_rect(&updateRegion, &clippingRects, &updateRect);
updateRects = region16_rects(&updateRegion, &nbUpdateRects);
UINT32 nYSrc;
nWidth = updateRects[j].right - updateRects[j].left;
nHeight = updateRects[j].bottom - updateRects[j].top;
-
nXSrc = updateRects[j].left - (nXDst + tile->x);
nYSrc = updateRects[j].top - (nYDst + tile->y);
-
freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
- nWidth, nHeight, tile->data, PIXEL_FORMAT_XRGB32,
- 64 * 4, nXSrc, nYSrc, NULL);
+ nWidth, nHeight, tile->data, PIXEL_FORMAT_XRGB32,
+ 64 * 4, nXSrc, nYSrc, NULL);
}
region16_uninit(&updateRegion);
}
region16_uninit(&clippingRects);
-
return 1;
}
int progressive_compress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData,
- UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize)
+ UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize)
{
return 1;
}
PROGRESSIVE_CONTEXT* progressive_context_new(BOOL Compressor)
{
PROGRESSIVE_CONTEXT* progressive;
-
progressive = (PROGRESSIVE_CONTEXT*) calloc(1, sizeof(PROGRESSIVE_CONTEXT));
if (progressive)
{
progressive->Compressor = Compressor;
-
progressive->bufferPool = BufferPool_New(TRUE, (8192 + 32) * 3, 16);
-
progressive->cRects = 64;
progressive->rects = (RFX_RECT*) malloc(progressive->cRects * sizeof(RFX_RECT));
goto cleanup;
progressive->cTiles = 64;
- progressive->tiles = (RFX_PROGRESSIVE_TILE**) malloc(progressive->cTiles * sizeof(RFX_PROGRESSIVE_TILE*));
+ progressive->tiles = (RFX_PROGRESSIVE_TILE**) malloc(progressive->cTiles *
+ sizeof(RFX_PROGRESSIVE_TILE*));
if (!progressive->tiles)
goto cleanup;
progressive->cQuant = 8;
- progressive->quantVals = (RFX_COMPONENT_CODEC_QUANT*) malloc(progressive->cQuant * sizeof(RFX_COMPONENT_CODEC_QUANT));
+ progressive->quantVals = (RFX_COMPONENT_CODEC_QUANT*) malloc(
+ progressive->cQuant * sizeof(RFX_COMPONENT_CODEC_QUANT));
if (!progressive->quantVals)
goto cleanup;
progressive->cProgQuant = 8;
- progressive->quantProgVals = (RFX_PROGRESSIVE_CODEC_QUANT*) malloc(progressive->cProgQuant * sizeof(RFX_PROGRESSIVE_CODEC_QUANT));
+ progressive->quantProgVals = (RFX_PROGRESSIVE_CODEC_QUANT*) malloc(
+ progressive->cProgQuant * sizeof(RFX_PROGRESSIVE_CODEC_QUANT));
if (!progressive->quantProgVals)
goto cleanup;
- ZeroMemory(&(progressive->quantProgValFull), sizeof(RFX_PROGRESSIVE_CODEC_QUANT));
+ ZeroMemory(&(progressive->quantProgValFull),
+ sizeof(RFX_PROGRESSIVE_CODEC_QUANT));
progressive->quantProgValFull.quality = 100;
-
progressive->SurfaceContexts = HashTable_New(TRUE);
-
progressive_context_reset(progressive);
}
return progressive;
-
cleanup:
free(progressive->rects);
free(progressive->tiles);
return;
BufferPool_Free(progressive->bufferPool);
-
free(progressive->rects);
free(progressive->tiles);
free(progressive->quantVals);
free(progressive->quantProgVals);
-
count = HashTable_GetKeys(progressive->SurfaceContexts, &pKeys);
for (index = 0; index < count; index++)
{
- surface = (PROGRESSIVE_SURFACE_CONTEXT*) HashTable_GetItemValue(progressive->SurfaceContexts, (void*) pKeys[index]);
+ surface = (PROGRESSIVE_SURFACE_CONTEXT*) HashTable_GetItemValue(
+ progressive->SurfaceContexts, (void*) pKeys[index]);
progressive_surface_context_free(surface);
}
free(pKeys);
-
HashTable_Free(progressive->SurfaceContexts);
-
free(progressive);
}
PROFILER_PRINT_FOOTER;
}
-void rfx_tile_init(RFX_TILE* tile)
+static void rfx_tile_init(RFX_TILE* tile)
{
if (tile)
{
}
}
-RFX_TILE* rfx_decoder_tile_new()
+static RFX_TILE* rfx_decoder_tile_new(void)
{
RFX_TILE* tile = NULL;
return tile;
}
-void rfx_decoder_tile_free(RFX_TILE* tile)
+static void rfx_decoder_tile_free(RFX_TILE* tile)
{
if (tile)
{
}
}
-RFX_TILE* rfx_encoder_tile_new()
+static RFX_TILE* rfx_encoder_tile_new()
{
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);
}
};
typedef struct _RFX_TILE_PROCESS_WORK_PARAM RFX_TILE_PROCESS_WORK_PARAM;
-void CALLBACK rfx_process_message_tile_work_callback(PTP_CALLBACK_INSTANCE
- instance, void* context, PTP_WORK work)
+static void CALLBACK rfx_process_message_tile_work_callback(
+ PTP_CALLBACK_INSTANCE
+ instance, void* context, PTP_WORK work)
{
RFX_TILE_PROCESS_WORK_PARAM* param = (RFX_TILE_PROCESS_WORK_PARAM*) context;
rfx_decode_rgb(param->context, param->tile, param->tile->data, 64 * 4);
cmd->bitmapDataLength,
cmd->destLeft, cmd->destTop,
pDstData, gdi->dstFormat,
- gdi->width, gdi->height, NULL))
+ cmd->width, cmd->height, NULL))
{
WLog_ERR(TAG, "Failed to process RemoteFX message");
return FALSE;
gdi->width, gdi->height))
return FALSE;
- nsc_process_message(gdi->codecs->nsc, cmd->bpp, cmd->width,
- cmd->height, cmd->bitmapData,
- cmd->bitmapDataLength);
+ if (!nsc_process_message(gdi->codecs->nsc, cmd->bpp, cmd->width,
+ cmd->height, cmd->bitmapData,
+ cmd->bitmapDataLength, gdi->bitmap_buffer,
+ gdi->dstFormat,
+ 0, 0, 0, cmd->width, cmd->height))
+ return FALSE;
+
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->image->bitmap = gdi_CreateBitmapEx(cmd->width, cmd->height,
gdi->dstFormat, 0,
* GDI Graphics Pipeline
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ * Copyright 2016 Armin Novak <armin.novak@thincast.com>
+ * Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_ResetGraphics(RdpgfxClientContext* context, RDPGFX_RESET_GRAPHICS_PDU* resetGraphics)
+static UINT gdi_ResetGraphics(RdpgfxClientContext* context,
+ const RDPGFX_RESET_GRAPHICS_PDU* resetGraphics)
{
- int index;
+ UINT32 index;
UINT16 count;
UINT32 DesktopWidth;
UINT32 DesktopHeight;
rdpGdi* gdi = (rdpGdi*) context->custom;
rdpUpdate* update = gdi->context->update;
rdpSettings* settings = gdi->context->settings;
-
DesktopWidth = resetGraphics->width;
DesktopHeight = resetGraphics->height;
- if ((DesktopWidth != settings->DesktopWidth) || (DesktopHeight != settings->DesktopHeight))
+ if ((DesktopWidth != settings->DesktopWidth)
+ || (DesktopHeight != settings->DesktopHeight))
{
settings->DesktopWidth = DesktopWidth;
settings->DesktopHeight = DesktopHeight;
continue;
if (!freerdp_client_codecs_reset(surface->codecs, FREERDP_CODEC_ALL,
- surface->width, surface->height))
+ surface->width, surface->height))
{
- free (pSurfaceIds);
+ free(pSurfaceIds);
return ERROR_INTERNAL_ERROR;
}
return ERROR_INTERNAL_ERROR;
gdi->graphicsReset = TRUE;
-
return CHANNEL_RC_OK;
}
-int gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface)
+static UINT gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface)
{
- int nDstStep;
- BYTE* pDstData;
- int nXDst, nYDst;
- int nXSrc, nYSrc;
+ UINT32 nXDst, nYDst;
+ UINT32 nXSrc, nYSrc;
UINT16 width, height;
UINT32 surfaceX, surfaceY;
RECTANGLE_16 surfaceRect;
const RECTANGLE_16* extents;
rdpUpdate* update = gdi->context->update;
-
- pDstData = gdi->primary_buffer;
- nDstStep = gdi->bytesPerPixel * gdi->width;
-
surfaceX = surface->outputOriginX;
surfaceY = surface->outputOriginY;
-
surfaceRect.left = 0;
surfaceRect.top = 0;
surfaceRect.right = surface->width;
surfaceRect.bottom = surface->height;
-
- region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion), &surfaceRect);
+ region16_intersect_rect(&(surface->invalidRegion),
+ &(surface->invalidRegion), &surfaceRect);
if (!region16_is_empty(&(surface->invalidRegion)))
{
extents = region16_extents(&(surface->invalidRegion));
-
nXSrc = extents->left;
nYSrc = extents->top;
-
nXDst = surfaceX + extents->left;
nYDst = surfaceY + extents->top;
-
width = extents->right - extents->left;
height = extents->bottom - extents->top;
-
update->BeginPaint(gdi->context);
-
- freerdp_image_copy(pDstData, gdi->format, nDstStep, nXDst, nYDst,
- width, height, surface->data, surface->format,
- surface->scanline, nXSrc, nYSrc, NULL);
-
+ freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
+ nXDst, nYDst, width, height,
+ surface->data, surface->format,
+ surface->scanline, nXSrc, nYSrc, NULL);
gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, width, height);
-
update->EndPaint(gdi->context);
}
region16_clear(&(surface->invalidRegion));
-
- return 1;
+ return CHANNEL_RC_OK;
}
-int gdi_UpdateSurfaces(rdpGdi* gdi)
+static UINT gdi_UpdateSurfaces(RdpgfxClientContext* context)
{
UINT16 count;
- int index;
- int status = 1;
+ UINT16 index;
+ UINT status = CHANNEL_RC_OK;
gdiGfxSurface* surface;
UINT16* pSurfaceIds = NULL;
- RdpgfxClientContext* context = gdi->gfx;
+ rdpGdi* gdi = (rdpGdi*)context->custom;
if (!gdi->graphicsReset)
- return 1;
+ return status;
context->GetSurfaceIds(context, &pSurfaceIds, &count);
status = gdi_OutputUpdate(gdi, surface);
- if (status < 0)
+ if (status != CHANNEL_RC_OK)
break;
}
free(pSurfaceIds);
-
- return status;
-}
-
-int gdi_OutputExpose(rdpGdi* gdi, int x, int y, int width, int height)
-{
- int index;
- int status = 1;
- UINT16 count;
- gdiGfxSurface* surface;
- RECTANGLE_16 invalidRect;
- RECTANGLE_16 surfaceRect;
- RECTANGLE_16 intersection;
- UINT16* pSurfaceIds = NULL;
- RdpgfxClientContext* context = gdi->gfx;
-
- invalidRect.left = x;
- invalidRect.top = y;
- invalidRect.right = x + width;
- invalidRect.bottom = y + height;
-
- context->GetSurfaceIds(context, &pSurfaceIds, &count);
-
- for (index = 0; index < count; index++)
- {
- surface = (gdiGfxSurface*) context->GetSurfaceData(context, pSurfaceIds[index]);
-
- if (!surface || !surface->outputMapped)
- continue;
-
- surfaceRect.left = surface->outputOriginX;
- surfaceRect.top = surface->outputOriginY;
- surfaceRect.right = surface->outputOriginX + surface->width;
- surfaceRect.bottom = surface->outputOriginY + surface->height;
-
- if (rectangles_intersection(&invalidRect, &surfaceRect, &intersection))
- {
- /* Invalid rects are specified relative to surface origin */
- intersection.left -= surfaceRect.left;
- intersection.top -= surfaceRect.top;
- intersection.right -= surfaceRect.left;
- intersection.bottom -= surfaceRect.top;
-
- region16_union_rect(&surface->invalidRegion, &surface->invalidRegion, &intersection);
- }
- }
-
- free(pSurfaceIds);
-
- if (gdi_UpdateSurfaces(gdi) < 0)
- status = -1;
-
return status;
}
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_StartFrame(RdpgfxClientContext* context, RDPGFX_START_FRAME_PDU* startFrame)
+static UINT gdi_StartFrame(RdpgfxClientContext* context,
+ const RDPGFX_START_FRAME_PDU* startFrame)
{
rdpGdi* gdi = (rdpGdi*) context->custom;
-
gdi->inGfxFrame = TRUE;
-
return CHANNEL_RC_OK;
}
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_EndFrame(RdpgfxClientContext* context, RDPGFX_END_FRAME_PDU* endFrame)
+static UINT gdi_EndFrame(RdpgfxClientContext* context,
+ const RDPGFX_END_FRAME_PDU* endFrame)
{
+ UINT status = CHANNEL_RC_NOT_INITIALIZED;
rdpGdi* gdi = (rdpGdi*) context->custom;
-
- gdi_UpdateSurfaces(gdi);
-
+ IFCALLRET(context->UpdateSurfaces, status, context);
gdi->inGfxFrame = FALSE;
-
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_SurfaceCommand_Uncompressed(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
+static UINT gdi_SurfaceCommand_Uncompressed(rdpGdi* gdi,
+ RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd)
{
+ UINT status = CHANNEL_RC_OK;
gdiGfxSurface* surface;
RECTANGLE_16 invalidRect;
-
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
if (!surface)
return ERROR_INTERNAL_ERROR;
- freerdp_image_copy(surface->data, surface->format, surface->scanline, cmd->left, cmd->top,
- cmd->width, cmd->height, cmd->data, PIXEL_FORMAT_XRGB32, cmd->width * 4, 0, 0, NULL);
+ if (!freerdp_image_copy(surface->data, surface->format, surface->scanline,
+ cmd->left, cmd->top, cmd->width, cmd->height,
+ cmd->data, cmd->format, -1, 0, 0, NULL))
+ return ERROR_INTERNAL_ERROR;
invalidRect.left = cmd->left;
invalidRect.top = cmd->top;
invalidRect.right = cmd->right;
invalidRect.bottom = cmd->bottom;
-
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
+ region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &invalidRect);
if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
+ {
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
+ }
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_SurfaceCommand_RemoteFX(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
+static UINT gdi_SurfaceCommand_RemoteFX(rdpGdi* gdi,
+ RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd)
{
- int j;
- UINT16 i;
- RFX_RECT* rect;
- RFX_TILE* tile;
- int nXDst, nYDst;
- int nWidth, nHeight;
- int nbUpdateRects;
- RFX_MESSAGE* message;
+ UINT status = CHANNEL_RC_OK;
gdiGfxSurface* surface;
- REGION16 updateRegion;
- RECTANGLE_16 updateRect;
- RECTANGLE_16* updateRects;
- REGION16 clippingRects;
- RECTANGLE_16 clippingRect;
-
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
if (!surface)
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_REMOTEFX))
return ERROR_INTERNAL_ERROR;
- if (!(message = rfx_process_message(surface->codecs->rfx, cmd->data, cmd->length)))
+ if (!rfx_process_message(surface->codecs->rfx, cmd->data, cmd->format,
+ cmd->length,
+ cmd->left, cmd->top,
+ surface->data, surface->format, surface->scanline,
+ surface->height, &surface->invalidRegion))
{
WLog_ERR(TAG, "Failed to process RemoteFX message");
return ERROR_INTERNAL_ERROR;
}
- region16_init(&clippingRects);
-
- for (i = 0; i < message->numRects; i++)
+ if (!gdi->inGfxFrame)
{
- rect = &(message->rects[i]);
-
- clippingRect.left = cmd->left + rect->x;
- clippingRect.top = cmd->top + rect->y;
- clippingRect.right = clippingRect.left + rect->width;
- clippingRect.bottom = clippingRect.top + rect->height;
-
- region16_union_rect(&clippingRects, &clippingRects, &clippingRect);
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
}
- for (i = 0; i < message->numTiles; i++)
- {
- tile = message->tiles[i];
-
- updateRect.left = cmd->left + tile->x;
- updateRect.top = cmd->top + tile->y;
- updateRect.right = updateRect.left + 64;
- updateRect.bottom = updateRect.top + 64;
-
- region16_init(&updateRegion);
- region16_intersect_rect(&updateRegion, &clippingRects, &updateRect);
- updateRects = (RECTANGLE_16*) region16_rects(&updateRegion, &nbUpdateRects);
-
- for (j = 0; j < nbUpdateRects; j++)
- {
- nXDst = updateRects[j].left;
- nYDst = updateRects[j].top;
- nWidth = updateRects[j].right - updateRects[j].left;
- nHeight = updateRects[j].bottom - updateRects[j].top;
-
- freerdp_image_copy(surface->data, surface->format, surface->scanline,
- nXDst, nYDst, nWidth, nHeight,
- tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, 0, 0, NULL);
-
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &updateRects[j]);
- }
-
- region16_uninit(&updateRegion);
- }
-
- region16_uninit(&clippingRects);
-
- rfx_message_free(surface->codecs->rfx, message);
-
- if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
-
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_SurfaceCommand_ClearCodec(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
+static UINT gdi_SurfaceCommand_ClearCodec(rdpGdi* gdi,
+ RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd)
{
- int status;
- BYTE* DstData = NULL;
+ INT32 rc;
+ UINT status = CHANNEL_RC_OK;
gdiGfxSurface* surface;
RECTANGLE_16 invalidRect;
-
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
if (!surface)
if (!freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_CLEARCODEC))
return ERROR_INTERNAL_ERROR;
- DstData = surface->data;
-
- status = clear_decompress(gdi->codecs->clear, cmd->data, cmd->length, &DstData,
- surface->format, surface->scanline, cmd->left, cmd->top, cmd->width, cmd->height);
+ rc = clear_decompress(gdi->codecs->clear, cmd->data, cmd->length,
+ surface->data, surface->format,
+ surface->scanline, cmd->left, cmd->top,
+ cmd->width, cmd->height);
- if (status < 0)
+ if (rc < 0)
{
WLog_ERR(TAG, "clear_decompress failure: %d", status);
return ERROR_INTERNAL_ERROR;
invalidRect.top = cmd->top;
invalidRect.right = cmd->right;
invalidRect.bottom = cmd->bottom;
-
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
+ region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &invalidRect);
if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
+ {
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
+ }
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_SurfaceCommand_Planar(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
+static UINT gdi_SurfaceCommand_Planar(rdpGdi* gdi, RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd)
{
- int status;
+ INT32 rc;
+ UINT status = CHANNEL_RC_OK;
BYTE* DstData = NULL;
gdiGfxSurface* surface;
RECTANGLE_16 invalidRect;
-
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
if (!surface)
return ERROR_INTERNAL_ERROR;
DstData = surface->data;
+ rc = planar_decompress(surface->codecs->planar, cmd->data, cmd->length,
+ &DstData, surface->format,
+ surface->scanline, cmd->left, cmd->top,
+ cmd->width, cmd->height, FALSE);
- status = planar_decompress(surface->codecs->planar, cmd->data, cmd->length, &DstData,
- PIXEL_FORMAT_XRGB32, surface->scanline, cmd->left, cmd->top, cmd->width, cmd->height, FALSE);
+ if (rc < 0)
+ return ERROR_INTERNAL_ERROR;
invalidRect.left = cmd->left;
invalidRect.top = cmd->top;
invalidRect.right = cmd->right;
invalidRect.bottom = cmd->bottom;
-
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
+ region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &invalidRect);
if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
+ {
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
+ }
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
+static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi,
+ RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd)
{
- int status;
+ INT32 rc;
+ UINT status = CHANNEL_RC_OK;
UINT32 i;
gdiGfxSurface* surface;
RDPGFX_H264_METABLOCK* meta;
RDPGFX_AVC420_BITMAP_STREAM* bs;
-
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
if (!surface)
return ERROR_INTERNAL_ERROR;
meta = &(bs->meta);
+ rc = avc420_decompress(surface->codecs->h264, bs->data, bs->length,
+ surface->data, surface->format,
+ surface->scanline, surface->width,
+ surface->height, meta->regionRects,
+ meta->numRegionRects);
- status = avc420_decompress(surface->codecs->h264, bs->data, bs->length,
- surface->data, PIXEL_FORMAT_XRGB32,
- surface->scanline, surface->width,
- surface->height, meta->regionRects,
- meta->numRegionRects);
-
- if (status < 0)
+ if (rc < 0)
{
WLog_WARN(TAG, "avc420_decompress failure: %d, ignoring update.", status);
return CHANNEL_RC_OK;
for (i = 0; i < meta->numRegionRects; i++)
{
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), (RECTANGLE_16*) &(meta->regionRects[i]));
+ region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ (RECTANGLE_16*) & (meta->regionRects[i]));
}
if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
+ {
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
+ }
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
+static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd)
{
- int status;
+ INT32 rc;
+ UINT status = CHANNEL_RC_OK;
UINT32 i;
gdiGfxSurface* surface;
RDPGFX_AVC444_BITMAP_STREAM* bs;
RDPGFX_AVC420_BITMAP_STREAM* avc2;
RDPGFX_H264_METABLOCK* meta2;
RECTANGLE_16* regionRects = NULL;
-
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
if (!surface)
avc2 = &bs->bitstream[1];
meta1 = &avc1->meta;
meta2 = &avc2->meta;
- status = avc444_decompress(surface->codecs->h264, bs->LC,
- meta1->regionRects, meta1->numRegionRects,
- avc1->data, avc1->length,
- meta2->regionRects, meta2->numRegionRects,
- avc2->data, avc2->length,
- surface->data, PIXEL_FORMAT_XRGB32,
- surface->scanline, surface->width,
- surface->height);
+ rc = avc444_decompress(surface->codecs->h264, bs->LC,
+ meta1->regionRects, meta1->numRegionRects,
+ avc1->data, avc1->length,
+ meta2->regionRects, meta2->numRegionRects,
+ avc2->data, avc2->length,
+ surface->data, surface->format,
+ surface->scanline, surface->width,
+ surface->height);
if (status < 0)
{
for (i = 0; i < meta1->numRegionRects; i++)
{
region16_union_rect(&(surface->invalidRegion),
- &(surface->invalidRegion),
- &(meta1->regionRects[i]));
+ &(surface->invalidRegion),
+ &(meta1->regionRects[i]));
}
for (i = 0; i < meta2->numRegionRects; i++)
{
region16_union_rect(&(surface->invalidRegion),
- &(surface->invalidRegion),
- &(meta2->regionRects[i]));
+ &(surface->invalidRegion),
+ &(meta2->regionRects[i]));
}
if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
+ {
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
+ }
free(regionRects);
-
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_SurfaceCommand_Alpha(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
+static UINT gdi_SurfaceCommand_Alpha(rdpGdi* gdi, RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd)
{
- int status = 0;
+ UINT status = CHANNEL_RC_OK;
gdiGfxSurface* surface;
RECTANGLE_16 invalidRect;
-
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
if (!surface)
return ERROR_INTERNAL_ERROR;
WLog_DBG(TAG, "gdi_SurfaceCommand_Alpha: status: %d", status);
-
/* fill with green for now to distinguish from the rest */
-
- freerdp_image_fill(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline,
- cmd->left, cmd->top, cmd->width, cmd->height, 0x00FF00);
+ if (!freerdp_image_fill(surface->data, surface->format, surface->scanline,
+ cmd->left, cmd->top, cmd->width, cmd->height, 0x00FF00))
+ return ERROR_INTERNAL_ERROR;
invalidRect.left = cmd->left;
invalidRect.top = cmd->top;
invalidRect.right = cmd->right;
invalidRect.bottom = cmd->bottom;
-
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
+ region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &invalidRect);
if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
+ {
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
+ }
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_SurfaceCommand_Progressive(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
+static UINT gdi_SurfaceCommand_Progressive(rdpGdi* gdi,
+ RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd)
{
- int i, j;
- int status;
- BYTE* DstData;
- RFX_RECT* rect;
- int nXDst, nYDst;
- int nXSrc, nYSrc;
- int nWidth, nHeight;
- int nbUpdateRects;
+ INT32 rc;
+ UINT status = CHANNEL_RC_OK;
gdiGfxSurface* surface;
- REGION16 updateRegion;
- RECTANGLE_16 updateRect;
- RECTANGLE_16* updateRects;
- REGION16 clippingRects;
- RECTANGLE_16 clippingRect;
- RFX_PROGRESSIVE_TILE* tile;
- PROGRESSIVE_BLOCK_REGION* region;
-
+ RECTANGLE_16 invalidRect;
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
if (!surface)
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_PROGRESSIVE))
return ERROR_INTERNAL_ERROR;
- progressive_create_surface_context(surface->codecs->progressive, cmd->surfaceId, surface->width, surface->height);
-
- DstData = surface->data;
-
- status = progressive_decompress(surface->codecs->progressive, cmd->data, cmd->length, &DstData,
- PIXEL_FORMAT_XRGB32, surface->scanline, cmd->left, cmd->top, cmd->width, cmd->height, cmd->surfaceId);
+ rc = progressive_create_surface_context(surface->codecs->progressive,
+ cmd->surfaceId,
+ surface->width, surface->height);
if (status < 0)
{
return ERROR_INTERNAL_ERROR;
}
- region = &(surface->codecs->progressive->region);
-
- region16_init(&clippingRects);
-
- for (i = 0; i < region->numRects; i++)
- {
- rect = &(region->rects[i]);
-
- clippingRect.left = cmd->left + rect->x;
- clippingRect.top = cmd->top + rect->y;
- clippingRect.right = clippingRect.left + rect->width;
- clippingRect.bottom = clippingRect.top + rect->height;
-
- region16_union_rect(&clippingRects, &clippingRects, &clippingRect);
- }
+ invalidRect.left = cmd->left;
+ invalidRect.top = cmd->top;
+ invalidRect.right = cmd->right;
+ invalidRect.bottom = cmd->bottom;
+ region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &invalidRect);
- for (i = 0; i < region->numTiles; i++)
+ if (!gdi->inGfxFrame)
{
- tile = region->tiles[i];
-
- updateRect.left = cmd->left + tile->x;
- updateRect.top = cmd->top + tile->y;
- updateRect.right = updateRect.left + 64;
- updateRect.bottom = updateRect.top + 64;
-
- region16_init(&updateRegion);
- region16_intersect_rect(&updateRegion, &clippingRects, &updateRect);
- updateRects = (RECTANGLE_16*) region16_rects(&updateRegion, &nbUpdateRects);
-
- for (j = 0; j < nbUpdateRects; j++)
- {
- nXDst = updateRects[j].left;
- nYDst = updateRects[j].top;
- nWidth = updateRects[j].right - updateRects[j].left;
- nHeight = updateRects[j].bottom - updateRects[j].top;
-
- nXSrc = nXDst - (cmd->left + tile->x);
- nYSrc = nYDst - (cmd->top + tile->y);
-
- freerdp_image_copy(surface->data, surface->format,
- surface->scanline, nXDst, nYDst, nWidth, nHeight,
- tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, nXSrc, nYSrc, NULL);
-
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &updateRects[j]);
- }
-
- region16_uninit(&updateRegion);
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
}
- region16_uninit(&clippingRects);
-
- if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
-
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_SurfaceCommand(RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
+static UINT gdi_SurfaceCommand(RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd)
{
UINT status = CHANNEL_RC_OK;
rdpGdi* gdi = (rdpGdi*) context->custom;
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_DeleteEncodingContext(RdpgfxClientContext* context, RDPGFX_DELETE_ENCODING_CONTEXT_PDU* deleteEncodingContext)
+static UINT gdi_DeleteEncodingContext(RdpgfxClientContext* context,
+ const RDPGFX_DELETE_ENCODING_CONTEXT_PDU* deleteEncodingContext)
{
return CHANNEL_RC_OK;
}
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_CreateSurface(RdpgfxClientContext* context, RDPGFX_CREATE_SURFACE_PDU* createSurface)
+static UINT gdi_CreateSurface(RdpgfxClientContext* context,
+ const RDPGFX_CREATE_SURFACE_PDU* createSurface)
{
gdiGfxSurface* surface;
rdpGdi* gdi = (rdpGdi*) context->custom;
-
surface = (gdiGfxSurface*) calloc(1, sizeof(gdiGfxSurface));
if (!surface)
if (!surface->codecs)
{
- free (surface);
+ free(surface);
return CHANNEL_RC_NO_MEMORY;
}
if (!freerdp_client_codecs_reset(surface->codecs, FREERDP_CODEC_ALL,
- createSurface->width, createSurface->height))
+ createSurface->width, createSurface->height))
{
- free (surface);
+ free(surface);
return ERROR_INTERNAL_ERROR;
}
surface->surfaceId = createSurface->surfaceId;
surface->width = (UINT32) createSurface->width;
surface->height = (UINT32) createSurface->height;
- surface->alpha = (createSurface->pixelFormat == PIXEL_FORMAT_ARGB_8888) ? TRUE : FALSE;
- surface->format = (!gdi->invert) ? PIXEL_FORMAT_XRGB32 : PIXEL_FORMAT_XBGR32;
+ switch (createSurface->pixelFormat)
+ {
+ case PIXEL_FORMAT_ARGB_8888:
+ surface->format = PIXEL_FORMAT_BGRA32;
+ break;
+
+ case PIXEL_FORMAT_XRGB_8888:
+ surface->format = PIXEL_FORMAT_BGRX32;
+ break;
+
+ default:
+ free(surface);
+ return ERROR_INTERNAL_ERROR;
+ }
surface->scanline = (surface->width + (surface->width % 4)) * 4;
surface->data = (BYTE*) calloc(1, surface->scanline * surface->height);
}
surface->outputMapped = FALSE;
-
region16_init(&surface->invalidRegion);
-
context->SetSurfaceData(context, surface->surfaceId, (void*) surface);
-
return CHANNEL_RC_OK;
}
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_DeleteSurface(RdpgfxClientContext* context, RDPGFX_DELETE_SURFACE_PDU* deleteSurface)
+static UINT gdi_DeleteSurface(RdpgfxClientContext* context,
+ const RDPGFX_DELETE_SURFACE_PDU* deleteSurface)
{
rdpCodecs* codecs = NULL;
gdiGfxSurface* surface = NULL;
-
- surface = (gdiGfxSurface*) context->GetSurfaceData(context, deleteSurface->surfaceId);
+ surface = (gdiGfxSurface*) context->GetSurfaceData(context,
+ deleteSurface->surfaceId);
if (surface)
{
context->SetSurfaceData(context, deleteSurface->surfaceId, NULL);
if (codecs && codecs->progressive)
- progressive_delete_surface_context(codecs->progressive, deleteSurface->surfaceId);
+ progressive_delete_surface_context(codecs->progressive,
+ deleteSurface->surfaceId);
codecs_free(codecs);
-
return CHANNEL_RC_OK;
}
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_SolidFill(RdpgfxClientContext* context, RDPGFX_SOLID_FILL_PDU* solidFill)
+static UINT gdi_SolidFill(RdpgfxClientContext* context,
+ const RDPGFX_SOLID_FILL_PDU* solidFill)
{
+ UINT status = CHANNEL_RC_OK;
UINT16 index;
UINT32 color;
BYTE a, r, g, b;
- int nWidth, nHeight;
+ UINT32 nWidth, nHeight;
RECTANGLE_16* rect;
gdiGfxSurface* surface;
RECTANGLE_16 invalidRect;
rdpGdi* gdi = (rdpGdi*) context->custom;
-
- surface = (gdiGfxSurface*) context->GetSurfaceData(context, solidFill->surfaceId);
+ surface = (gdiGfxSurface*) context->GetSurfaceData(context,
+ solidFill->surfaceId);
if (!surface)
return ERROR_INTERNAL_ERROR;
g = solidFill->fillPixel.G;
r = solidFill->fillPixel.R;
a = solidFill->fillPixel.XA;
-
- if (!gdi->invert)
- color = ARGB32(a, r, g, b);
- else
- color = ABGR32(a, r, g, b);
+ color = GetColor(PIXEL_FORMAT_ARGB32, r, g, b, a);
+ color = ConvertColor(color, PIXEL_FORMAT_ARGB32, surface->format, NULL);
for (index = 0; index < solidFill->fillRectCount; index++)
{
rect = &(solidFill->fillRects[index]);
-
nWidth = rect->right - rect->left;
nHeight = rect->bottom - rect->top;
-
invalidRect.left = rect->left;
invalidRect.top = rect->top;
invalidRect.right = rect->right;
invalidRect.bottom = rect->bottom;
-
freerdp_image_fill(surface->data, surface->format, surface->scanline,
- rect->left, rect->top, nWidth, nHeight, color);
-
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
+ rect->left, rect->top, nWidth, nHeight, color);
+ region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &invalidRect);
}
if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
+ {
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
+ }
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_SurfaceToSurface(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_SURFACE_PDU* surfaceToSurface)
+static UINT gdi_SurfaceToSurface(RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_TO_SURFACE_PDU* surfaceToSurface)
{
+ UINT status = CHANNEL_RC_OK;
UINT16 index;
BOOL sameSurface;
- int nWidth, nHeight;
- RECTANGLE_16* rectSrc;
+ UINT32 nWidth, nHeight;
+ const RECTANGLE_16* rectSrc;
RDPGFX_POINT16* destPt;
RECTANGLE_16 invalidRect;
gdiGfxSurface* surfaceSrc;
gdiGfxSurface* surfaceDst;
rdpGdi* gdi = (rdpGdi*) context->custom;
-
rectSrc = &(surfaceToSurface->rectSrc);
-
- surfaceSrc = (gdiGfxSurface*) context->GetSurfaceData(context, surfaceToSurface->surfaceIdSrc);
-
- sameSurface = (surfaceToSurface->surfaceIdSrc == surfaceToSurface->surfaceIdDest) ? TRUE : FALSE;
+ surfaceSrc = (gdiGfxSurface*) context->GetSurfaceData(context,
+ surfaceToSurface->surfaceIdSrc);
+ sameSurface = (surfaceToSurface->surfaceIdSrc ==
+ surfaceToSurface->surfaceIdDest) ? TRUE : FALSE;
if (!sameSurface)
- surfaceDst = (gdiGfxSurface*) context->GetSurfaceData(context, surfaceToSurface->surfaceIdDest);
+ surfaceDst = (gdiGfxSurface*) context->GetSurfaceData(context,
+ surfaceToSurface->surfaceIdDest);
else
surfaceDst = surfaceSrc;
for (index = 0; index < surfaceToSurface->destPtsCount; index++)
{
destPt = &surfaceToSurface->destPts[index];
-
- if (sameSurface)
- {
- freerdp_image_move(surfaceDst->data, surfaceDst->format, surfaceDst->scanline,
- destPt->x, destPt->y, nWidth, nHeight, rectSrc->left, rectSrc->top);
- }
- else
- {
- freerdp_image_copy(surfaceDst->data, surfaceDst->format, surfaceDst->scanline,
- destPt->x, destPt->y, nWidth, nHeight, surfaceSrc->data, surfaceSrc->format,
- surfaceSrc->scanline, rectSrc->left, rectSrc->top, NULL);
- }
-
+ freerdp_image_copy(surfaceDst->data, surfaceDst->format,
+ surfaceDst->scanline,
+ destPt->x, destPt->y, nWidth, nHeight,
+ surfaceSrc->data, surfaceSrc->format,
+ surfaceSrc->scanline,
+ rectSrc->left, rectSrc->top, NULL);
invalidRect.left = destPt->x;
invalidRect.top = destPt->y;
invalidRect.right = destPt->x + rectSrc->right;
invalidRect.bottom = destPt->y + rectSrc->bottom;
-
- region16_union_rect(&surfaceDst->invalidRegion, &surfaceDst->invalidRegion, &invalidRect);
+ region16_union_rect(&surfaceDst->invalidRegion, &surfaceDst->invalidRegion,
+ &invalidRect);
}
if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
+ {
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
+ }
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_SurfaceToCache(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_CACHE_PDU* surfaceToCache)
+static UINT gdi_SurfaceToCache(RdpgfxClientContext* context,
+ const RDPGFX_SURFACE_TO_CACHE_PDU* surfaceToCache)
{
- RECTANGLE_16* rect;
+ const RECTANGLE_16* rect;
gdiGfxSurface* surface;
gdiGfxCacheEntry* cacheEntry;
- rdpGdi* gdi = (rdpGdi*) context->custom;
-
rect = &(surfaceToCache->rectSrc);
-
- surface = (gdiGfxSurface*) context->GetSurfaceData(context, surfaceToCache->surfaceId);
+ surface = (gdiGfxSurface*) context->GetSurfaceData(context,
+ surfaceToCache->surfaceId);
if (!surface)
return ERROR_INTERNAL_ERROR;
if (!cacheEntry)
return ERROR_INTERNAL_ERROR;
- cacheEntry->width = (UINT32) (rect->right - rect->left);
- cacheEntry->height = (UINT32) (rect->bottom - rect->top);
- cacheEntry->alpha = surface->alpha;
-
- cacheEntry->format = (!gdi->invert) ? PIXEL_FORMAT_XRGB32 : PIXEL_FORMAT_XBGR32;
-
+ cacheEntry->width = (UINT32)(rect->right - rect->left);
+ cacheEntry->height = (UINT32)(rect->bottom - rect->top);
+ cacheEntry->format = surface->format;
cacheEntry->scanline = (cacheEntry->width + (cacheEntry->width % 4)) * 4;
cacheEntry->data = (BYTE*) calloc(1, cacheEntry->scanline * cacheEntry->height);
}
freerdp_image_copy(cacheEntry->data, cacheEntry->format, cacheEntry->scanline,
- 0, 0, cacheEntry->width, cacheEntry->height, surface->data,
- surface->format, surface->scanline, rect->left, rect->top, NULL);
-
- context->SetCacheSlotData(context, surfaceToCache->cacheSlot, (void*) cacheEntry);
-
+ 0, 0, cacheEntry->width, cacheEntry->height, surface->data,
+ surface->format, surface->scanline, rect->left, rect->top, NULL);
+ context->SetCacheSlotData(context, surfaceToCache->cacheSlot,
+ (void*) cacheEntry);
return CHANNEL_RC_OK;
}
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_CacheToSurface(RdpgfxClientContext* context, RDPGFX_CACHE_TO_SURFACE_PDU* cacheToSurface)
+static UINT gdi_CacheToSurface(RdpgfxClientContext* context,
+ const RDPGFX_CACHE_TO_SURFACE_PDU* cacheToSurface)
{
+ UINT status = CHANNEL_RC_OK;
UINT16 index;
RDPGFX_POINT16* destPt;
gdiGfxSurface* surface;
gdiGfxCacheEntry* cacheEntry;
RECTANGLE_16 invalidRect;
rdpGdi* gdi = (rdpGdi*) context->custom;
-
- surface = (gdiGfxSurface*) context->GetSurfaceData(context, cacheToSurface->surfaceId);
- cacheEntry = (gdiGfxCacheEntry*) context->GetCacheSlotData(context, cacheToSurface->cacheSlot);
+ surface = (gdiGfxSurface*) context->GetSurfaceData(context,
+ cacheToSurface->surfaceId);
+ cacheEntry = (gdiGfxCacheEntry*) context->GetCacheSlotData(context,
+ cacheToSurface->cacheSlot);
if (!surface || !cacheEntry)
return ERROR_INTERNAL_ERROR;
for (index = 0; index < cacheToSurface->destPtsCount; index++)
{
destPt = &cacheToSurface->destPts[index];
-
freerdp_image_copy(surface->data, surface->format, surface->scanline,
- destPt->x, destPt->y, cacheEntry->width, cacheEntry->height,
- cacheEntry->data, cacheEntry->format, cacheEntry->scanline, 0, 0, NULL);
-
+ destPt->x, destPt->y, cacheEntry->width, cacheEntry->height,
+ cacheEntry->data, cacheEntry->format, cacheEntry->scanline, 0, 0, NULL);
invalidRect.left = destPt->x;
invalidRect.top = destPt->y;
invalidRect.right = destPt->x + cacheEntry->width - 1;
invalidRect.bottom = destPt->y + cacheEntry->height - 1;
-
- region16_union_rect(&surface->invalidRegion, &surface->invalidRegion, &invalidRect);
+ region16_union_rect(&surface->invalidRegion, &surface->invalidRegion,
+ &invalidRect);
}
if (!gdi->inGfxFrame)
- gdi_UpdateSurfaces(gdi);
+ {
+ status = CHANNEL_RC_NOT_INITIALIZED;
+ IFCALLRET(context->UpdateSurfaces, status, context);
+ }
- return CHANNEL_RC_OK;
+ return status;
}
/**
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_CacheImportReply(RdpgfxClientContext* context, RDPGFX_CACHE_IMPORT_REPLY_PDU* cacheImportReply)
+static UINT gdi_CacheImportReply(RdpgfxClientContext* context,
+ const RDPGFX_CACHE_IMPORT_REPLY_PDU* cacheImportReply)
{
return CHANNEL_RC_OK;
}
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_EvictCacheEntry(RdpgfxClientContext* context, RDPGFX_EVICT_CACHE_ENTRY_PDU* evictCacheEntry)
+static UINT gdi_EvictCacheEntry(RdpgfxClientContext* context,
+ const RDPGFX_EVICT_CACHE_ENTRY_PDU* evictCacheEntry)
{
gdiGfxCacheEntry* cacheEntry;
-
- cacheEntry = (gdiGfxCacheEntry*) context->GetCacheSlotData(context, evictCacheEntry->cacheSlot);
+ cacheEntry = (gdiGfxCacheEntry*) context->GetCacheSlotData(context,
+ evictCacheEntry->cacheSlot);
if (cacheEntry)
{
}
context->SetCacheSlotData(context, evictCacheEntry->cacheSlot, NULL);
-
return CHANNEL_RC_OK;
}
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_MapSurfaceToOutput(RdpgfxClientContext* context, RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU* surfaceToOutput)
+static UINT gdi_MapSurfaceToOutput(RdpgfxClientContext* context,
+ const RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU* surfaceToOutput)
{
gdiGfxSurface* surface;
-
- surface = (gdiGfxSurface*) context->GetSurfaceData(context, surfaceToOutput->surfaceId);
+ surface = (gdiGfxSurface*) context->GetSurfaceData(context,
+ surfaceToOutput->surfaceId);
if (!surface)
return ERROR_INTERNAL_ERROR;
surface->outputMapped = TRUE;
surface->outputOriginX = surfaceToOutput->outputOriginX;
surface->outputOriginY = surfaceToOutput->outputOriginY;
-
region16_clear(&surface->invalidRegion);
-
return CHANNEL_RC_OK;
}
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT gdi_MapSurfaceToWindow(RdpgfxClientContext* context, RDPGFX_MAP_SURFACE_TO_WINDOW_PDU* surfaceToWindow)
+static UINT gdi_MapSurfaceToWindow(RdpgfxClientContext* context,
+ const RDPGFX_MAP_SURFACE_TO_WINDOW_PDU* surfaceToWindow)
{
return CHANNEL_RC_OK;
}
{
gdi->gfx = gfx;
gfx->custom = (void*) gdi;
-
gfx->ResetGraphics = gdi_ResetGraphics;
gfx->StartFrame = gdi_StartFrame;
gfx->EndFrame = gdi_EndFrame;
gfx->EvictCacheEntry = gdi_EvictCacheEntry;
gfx->MapSurfaceToOutput = gdi_MapSurfaceToOutput;
gfx->MapSurfaceToWindow = gdi_MapSurfaceToWindow;
+ gfx->UpdateSurfaces = gdi_UpdateSurfaces;
}
void gdi_graphics_pipeline_uninit(rdpGdi* gdi, RdpgfxClientContext* gfx)
{
region16_uninit(&(gdi->invalidRegion));
-
gdi->gfx = NULL;
gfx->custom = NULL;
}