xfreerdp: add egfx support for planar codec

This commit is contained in:
Marc-André Moreau 2014-06-17 16:15:30 -04:00
parent b782486e89
commit d69316198f
5 changed files with 58 additions and 8 deletions

View File

@ -293,6 +293,37 @@ int xf_SurfaceCommand_ClearCodec(xfContext* xfc, RdpgfxClientContext* context, R
int xf_SurfaceCommand_Planar(xfContext* xfc, RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
{
int status;
UINT32 DstSize = 0;
BYTE* DstData = NULL;
xfGfxSurface* surface;
RECTANGLE_16 invalidRect;
surface = (xfGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
if (!surface)
return -1;
DstSize = cmd->width * cmd->height * 4;
DstData = (BYTE*) malloc(DstSize);
if (!DstData)
return -1;
status = freerdp_bitmap_planar_decompress(cmd->data, DstData, cmd->width, cmd->height, cmd->length);
freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline, cmd->left, cmd->top,
cmd->width, cmd->height, DstData, PIXEL_FORMAT_XRGB32_VF, cmd->width * 4, 0, 0);
free(DstData);
invalidRect.left = cmd->left;
invalidRect.top = cmd->top;
invalidRect.right = cmd->right;
invalidRect.bottom = cmd->bottom;
region16_union_rect(&(xfc->invalidRegion), &(xfc->invalidRegion), &invalidRect);
if (!xfc->inGfxFrame)
xf_OutputUpdate(xfc);
@ -319,7 +350,6 @@ int xf_SurfaceCommand(RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd)
break;
case RDPGFX_CODECID_PLANAR:
printf("xf_SurfaceCommand_Planar\n");
status = xf_SurfaceCommand_Planar(xfc, context, cmd);
break;

View File

@ -40,6 +40,8 @@ FREERDP_API int freerdp_bitmap_compress(char* in_data, int width, int height,
typedef struct _BITMAP_PLANAR_CONTEXT BITMAP_PLANAR_CONTEXT;
FREERDP_API int freerdp_bitmap_planar_decompress(BYTE* srcData, BYTE* dstData, int width, int height, int size);
FREERDP_API BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* data, UINT32 format,
int width, int height, int scanline, BYTE* dstData, int* dstSize);

View File

@ -36,7 +36,7 @@
#define FREERDP_PIXEL_FORMAT(_flip, _bpp, _type, _a, _r, _g, _b) \
((_flip << 30) | (_bpp << 24) | (_type << 16) | (_a << 12) | (_r << 8) | (_g << 4) | (_b))
#define FREERDP_PIXEL_FORMAT_FLIP(_format) (((_format) >> 30) & 0x02)
#define FREERDP_PIXEL_FORMAT_FLIP(_format) (((_format) >> 30) & 0x03)
#define FREERDP_PIXEL_FORMAT_BPP(_format) (((_format) >> 24) & 0x3F)
#define FREERDP_PIXEL_FORMAT_TYPE(_format) (((_format) >> 16) & 0xFF)
#define FREERDP_PIXEL_FORMAT_A(_format) (((_format) >> 12) & 0x0F)

View File

@ -1176,6 +1176,8 @@ int freerdp_image_copy(BYTE* pDstData, DWORD dwDstFormat, int nDstStep, int nXDs
int nWidth, int nHeight, BYTE* pSrcData, DWORD dwSrcFormat, int nSrcStep, int nXSrc, int nYSrc)
{
int x, y;
int srcFlip;
int dstFlip;
BYTE a, r, g, b;
int beg, end, inc;
int srcBitsPerPixel;
@ -1183,12 +1185,18 @@ int freerdp_image_copy(BYTE* pDstData, DWORD dwDstFormat, int nDstStep, int nXDs
int dstBitsPerPixel;
int dstBytesPerPixel;
BOOL overlap = FALSE;
BOOL vFlip = FALSE;
srcBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(dwSrcFormat);
srcBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(dwSrcFormat) / 8);
srcFlip = FREERDP_PIXEL_FORMAT_FLIP(dwSrcFormat);
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(dwDstFormat);
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(dwDstFormat) / 8);
dstFlip = FREERDP_PIXEL_FORMAT_FLIP(dwDstFormat);
if (srcFlip != dstFlip)
vFlip = TRUE;
if (pDstData == pSrcData)
{
@ -1252,11 +1260,23 @@ int freerdp_image_copy(BYTE* pDstData, DWORD dwDstFormat, int nDstStep, int nXDs
end = nHeight;
}
for (y = beg; y != end; y += inc)
if (!vFlip)
{
pSrcPixel = (UINT32*) &pSrcData[((nYSrc + y) * nSrcStep) + (nXSrc * srcBytesPerPixel)];
pDstPixel = (UINT32*) &pDstData[((nYDst + y) * nDstStep) + (nXDst * dstBytesPerPixel)];
MoveMemory(pDstPixel, pSrcPixel, nWidth * 4);
for (y = beg; y != end; y += inc)
{
pSrcPixel = (UINT32*) &pSrcData[((nYSrc + y) * nSrcStep) + (nXSrc * srcBytesPerPixel)];
pDstPixel = (UINT32*) &pDstData[((nYDst + y) * nDstStep) + (nXDst * dstBytesPerPixel)];
MoveMemory(pDstPixel, pSrcPixel, nWidth * 4);
}
}
else
{
for (y = beg; y != end; y += inc)
{
pSrcPixel = (UINT32*) &pSrcData[((nYSrc + y) * nSrcStep) + (nXSrc * srcBytesPerPixel)];
pDstPixel = (UINT32*) &pDstData[((nYDst + (nHeight - y - 1)) * nDstStep) + (nXDst * dstBytesPerPixel)];
MoveMemory(pDstPixel, pSrcPixel, nWidth * 4);
}
}
}
}

View File

@ -87,8 +87,6 @@ struct _BITMAP_PLANAR_CONTEXT
BYTE* rlePlanesBuffer;
};
FREERDP_API int freerdp_bitmap_planar_decompress(BYTE* srcData, BYTE* dstData, int width, int height, int size);
FREERDP_API int freerdp_split_color_planes(BYTE* data, UINT32 format, int width, int height, int scanline, BYTE* planes[4]);
FREERDP_API BYTE* freerdp_bitmap_planar_compress_plane_rle(BYTE* plane, int width, int height, BYTE* outPlane, int* dstSize);
FREERDP_API BYTE* freerdp_bitmap_planar_delta_encode_plane(BYTE* inPlane, int width, int height, BYTE* outPlane);