2014-07-29 01:42:23 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* Progressive Codec Bitmap Compression
|
|
|
|
*
|
|
|
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FREERDP_CODEC_PROGRESSIVE_H
|
|
|
|
#define FREERDP_CODEC_PROGRESSIVE_H
|
|
|
|
|
|
|
|
#include <freerdp/api.h>
|
|
|
|
#include <freerdp/types.h>
|
|
|
|
|
2014-08-22 03:43:37 +04:00
|
|
|
#include <winpr/wlog.h>
|
2014-08-06 18:23:14 +04:00
|
|
|
#include <winpr/collections.h>
|
|
|
|
|
2014-07-29 07:41:16 +04:00
|
|
|
#include <freerdp/codec/rfx.h>
|
2014-07-29 01:42:23 +04:00
|
|
|
#include <freerdp/codec/color.h>
|
|
|
|
|
2014-07-30 01:37:46 +04:00
|
|
|
#define RFX_SUBBAND_DIFFING 0x01
|
|
|
|
|
|
|
|
#define RFX_TILE_DIFFERENCE 0x01
|
|
|
|
|
|
|
|
#define RFX_DWT_REDUCE_EXTRAPOLATE 0x01
|
|
|
|
|
2014-07-29 07:41:16 +04:00
|
|
|
#define PROGRESSIVE_WBT_SYNC 0xCCC0
|
|
|
|
#define PROGRESSIVE_WBT_FRAME_BEGIN 0xCCC1
|
|
|
|
#define PROGRESSIVE_WBT_FRAME_END 0xCCC2
|
|
|
|
#define PROGRESSIVE_WBT_CONTEXT 0xCCC3
|
|
|
|
#define PROGRESSIVE_WBT_REGION 0xCCC4
|
|
|
|
#define PROGRESSIVE_WBT_TILE_SIMPLE 0xCCC5
|
2014-07-29 20:38:29 +04:00
|
|
|
#define PROGRESSIVE_WBT_TILE_FIRST 0xCCC6
|
|
|
|
#define PROGRESSIVE_WBT_TILE_UPGRADE 0xCCC7
|
2014-07-29 07:41:16 +04:00
|
|
|
|
2014-07-30 01:37:46 +04:00
|
|
|
#define PROGRESSIVE_BLOCKS_ALL 0x0001
|
|
|
|
#define PROGRESSIVE_BLOCKS_REGION 0x0002
|
|
|
|
#define PROGRESSIVE_BLOCKS_TILE 0x0004
|
|
|
|
|
2014-07-29 20:38:29 +04:00
|
|
|
struct _RFX_COMPONENT_CODEC_QUANT
|
|
|
|
{
|
|
|
|
BYTE LL3;
|
|
|
|
BYTE HL3;
|
|
|
|
BYTE LH3;
|
|
|
|
BYTE HH3;
|
|
|
|
BYTE HL2;
|
|
|
|
BYTE LH2;
|
|
|
|
BYTE HH2;
|
|
|
|
BYTE HL1;
|
|
|
|
BYTE LH1;
|
|
|
|
BYTE HH1;
|
|
|
|
};
|
|
|
|
typedef struct _RFX_COMPONENT_CODEC_QUANT RFX_COMPONENT_CODEC_QUANT;
|
|
|
|
|
2014-08-26 01:58:38 +04:00
|
|
|
struct _RFX_PROGRESSIVE_CODEC_QUANT
|
|
|
|
{
|
|
|
|
BYTE quality;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT yQuantValues;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT cbQuantValues;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT crQuantValues;
|
|
|
|
};
|
|
|
|
typedef struct _RFX_PROGRESSIVE_CODEC_QUANT RFX_PROGRESSIVE_CODEC_QUANT;
|
|
|
|
|
2014-07-29 20:38:29 +04:00
|
|
|
struct _PROGRESSIVE_BLOCK
|
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
};
|
|
|
|
typedef struct _PROGRESSIVE_BLOCK PROGRESSIVE_BLOCK;
|
|
|
|
|
|
|
|
struct _PROGRESSIVE_BLOCK_SYNC
|
2014-07-29 07:41:16 +04:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
UINT32 magic;
|
|
|
|
UINT16 version;
|
|
|
|
};
|
2014-07-29 20:38:29 +04:00
|
|
|
typedef struct _PROGRESSIVE_BLOCK_SYNC PROGRESSIVE_BLOCK_SYNC;
|
|
|
|
|
|
|
|
struct _PROGRESSIVE_BLOCK_CONTEXT
|
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
BYTE ctxId;
|
|
|
|
UINT16 tileSize;
|
|
|
|
BYTE flags;
|
|
|
|
};
|
|
|
|
typedef struct _PROGRESSIVE_BLOCK_CONTEXT PROGRESSIVE_BLOCK_CONTEXT;
|
2014-07-29 07:41:16 +04:00
|
|
|
|
2014-07-29 20:38:29 +04:00
|
|
|
struct _PROGRESSIVE_BLOCK_TILE_SIMPLE
|
2014-07-29 07:41:16 +04:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
BYTE quantIdxY;
|
|
|
|
BYTE quantIdxCb;
|
|
|
|
BYTE quantIdxCr;
|
|
|
|
UINT16 xIdx;
|
|
|
|
UINT16 yIdx;
|
|
|
|
BYTE flags;
|
|
|
|
UINT16 yLen;
|
|
|
|
UINT16 cbLen;
|
|
|
|
UINT16 crLen;
|
|
|
|
UINT16 tailLen;
|
|
|
|
BYTE* yData;
|
|
|
|
BYTE* cbData;
|
|
|
|
BYTE* crData;
|
|
|
|
BYTE* tailData;
|
|
|
|
};
|
2014-07-29 20:38:29 +04:00
|
|
|
typedef struct _PROGRESSIVE_BLOCK_TILE_SIMPLE PROGRESSIVE_BLOCK_TILE_SIMPLE;
|
2014-07-29 07:41:16 +04:00
|
|
|
|
2014-07-29 20:38:29 +04:00
|
|
|
struct _PROGRESSIVE_BLOCK_TILE_FIRST
|
2014-07-29 07:41:16 +04:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
BYTE quantIdxY;
|
|
|
|
BYTE quantIdxCb;
|
|
|
|
BYTE quantIdxCr;
|
|
|
|
UINT16 xIdx;
|
|
|
|
UINT16 yIdx;
|
|
|
|
BYTE flags;
|
|
|
|
BYTE quality;
|
|
|
|
UINT16 yLen;
|
|
|
|
UINT16 cbLen;
|
|
|
|
UINT16 crLen;
|
|
|
|
UINT16 tailLen;
|
|
|
|
BYTE* yData;
|
|
|
|
BYTE* cbData;
|
|
|
|
BYTE* crData;
|
|
|
|
BYTE* tailData;
|
|
|
|
};
|
2014-07-29 20:38:29 +04:00
|
|
|
typedef struct _PROGRESSIVE_BLOCK_TILE_FIRST PROGRESSIVE_BLOCK_TILE_FIRST;
|
2014-07-29 07:41:16 +04:00
|
|
|
|
2014-07-29 20:38:29 +04:00
|
|
|
struct _PROGRESSIVE_BLOCK_TILE_UPGRADE
|
2014-07-29 07:41:16 +04:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
BYTE quantIdxY;
|
|
|
|
BYTE quantIdxCb;
|
|
|
|
BYTE quantIdxCr;
|
|
|
|
UINT16 xIdx;
|
|
|
|
UINT16 yIdx;
|
|
|
|
BYTE quality;
|
|
|
|
UINT16 ySrlLen;
|
|
|
|
UINT16 yRawLen;
|
|
|
|
UINT16 cbSrlLen;
|
|
|
|
UINT16 cbRawLen;
|
|
|
|
UINT16 crSrlLen;
|
|
|
|
UINT16 crRawLen;
|
|
|
|
BYTE* ySrlData;
|
|
|
|
BYTE* yRawData;
|
|
|
|
BYTE* cbSrlData;
|
|
|
|
BYTE* cbRawData;
|
|
|
|
BYTE* crSrlData;
|
|
|
|
BYTE* crRawData;
|
|
|
|
};
|
2014-07-29 20:38:29 +04:00
|
|
|
typedef struct _PROGRESSIVE_BLOCK_TILE_UPGRADE PROGRESSIVE_BLOCK_TILE_UPGRADE;
|
2014-07-29 07:41:16 +04:00
|
|
|
|
2014-08-01 17:44:00 +04:00
|
|
|
struct _RFX_PROGRESSIVE_TILE
|
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
BYTE quantIdxY;
|
|
|
|
BYTE quantIdxCb;
|
|
|
|
BYTE quantIdxCr;
|
|
|
|
UINT16 xIdx;
|
|
|
|
UINT16 yIdx;
|
|
|
|
|
|
|
|
BYTE flags;
|
|
|
|
BYTE quality;
|
|
|
|
|
|
|
|
UINT16 yLen;
|
|
|
|
UINT16 cbLen;
|
|
|
|
UINT16 crLen;
|
|
|
|
UINT16 tailLen;
|
|
|
|
BYTE* yData;
|
|
|
|
BYTE* cbData;
|
|
|
|
BYTE* crData;
|
|
|
|
BYTE* tailData;
|
|
|
|
|
|
|
|
UINT16 ySrlLen;
|
|
|
|
UINT16 yRawLen;
|
|
|
|
UINT16 cbSrlLen;
|
|
|
|
UINT16 cbRawLen;
|
|
|
|
UINT16 crSrlLen;
|
|
|
|
UINT16 crRawLen;
|
|
|
|
BYTE* ySrlData;
|
|
|
|
BYTE* yRawData;
|
|
|
|
BYTE* cbSrlData;
|
|
|
|
BYTE* cbRawData;
|
|
|
|
BYTE* crSrlData;
|
|
|
|
BYTE* crRawData;
|
2014-08-19 22:48:09 +04:00
|
|
|
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
BYTE* data;
|
2014-08-28 01:02:15 +04:00
|
|
|
BYTE* current;
|
|
|
|
|
2014-08-28 20:14:28 +04:00
|
|
|
int pass;
|
2014-08-28 23:14:01 +04:00
|
|
|
BYTE* sign;
|
2014-08-28 01:02:15 +04:00
|
|
|
RFX_COMPONENT_CODEC_QUANT yBitPos;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT cbBitPos;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT crBitPos;
|
2014-09-02 21:31:40 +04:00
|
|
|
RFX_COMPONENT_CODEC_QUANT yQuant;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT cbQuant;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT crQuant;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT yProgQuant;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT cbProgQuant;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT crProgQuant;
|
2014-08-01 17:44:00 +04:00
|
|
|
};
|
|
|
|
typedef struct _RFX_PROGRESSIVE_TILE RFX_PROGRESSIVE_TILE;
|
|
|
|
|
|
|
|
struct _PROGRESSIVE_BLOCK_REGION
|
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
BYTE tileSize;
|
|
|
|
UINT16 numRects;
|
|
|
|
BYTE numQuant;
|
|
|
|
BYTE numProgQuant;
|
|
|
|
BYTE flags;
|
|
|
|
UINT16 numTiles;
|
|
|
|
UINT32 tileDataSize;
|
|
|
|
RFX_RECT* rects;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT* quantVals;
|
|
|
|
RFX_PROGRESSIVE_CODEC_QUANT* quantProgVals;
|
2014-08-27 00:15:22 +04:00
|
|
|
RFX_PROGRESSIVE_TILE** tiles;
|
2014-08-01 17:44:00 +04:00
|
|
|
};
|
|
|
|
typedef struct _PROGRESSIVE_BLOCK_REGION PROGRESSIVE_BLOCK_REGION;
|
|
|
|
|
|
|
|
struct _PROGRESSIVE_BLOCK_FRAME_BEGIN
|
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
UINT32 frameIndex;
|
|
|
|
UINT16 regionCount;
|
|
|
|
PROGRESSIVE_BLOCK_REGION* regions;
|
|
|
|
};
|
|
|
|
typedef struct _PROGRESSIVE_BLOCK_FRAME_BEGIN PROGRESSIVE_BLOCK_FRAME_BEGIN;
|
|
|
|
|
|
|
|
struct _PROGRESSIVE_BLOCK_FRAME_END
|
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
};
|
|
|
|
typedef struct _PROGRESSIVE_BLOCK_FRAME_END PROGRESSIVE_BLOCK_FRAME_END;
|
|
|
|
|
2014-08-27 00:15:22 +04:00
|
|
|
struct _PROGRESSIVE_SURFACE_CONTEXT
|
|
|
|
{
|
|
|
|
UINT16 id;
|
|
|
|
UINT32 width;
|
|
|
|
UINT32 height;
|
|
|
|
UINT32 gridWidth;
|
|
|
|
UINT32 gridHeight;
|
|
|
|
UINT32 gridSize;
|
|
|
|
RFX_PROGRESSIVE_TILE* tiles;
|
|
|
|
};
|
|
|
|
typedef struct _PROGRESSIVE_SURFACE_CONTEXT PROGRESSIVE_SURFACE_CONTEXT;
|
|
|
|
|
2014-07-29 01:42:23 +04:00
|
|
|
struct _PROGRESSIVE_CONTEXT
|
|
|
|
{
|
|
|
|
BOOL Compressor;
|
2014-07-30 01:37:46 +04:00
|
|
|
|
2014-08-22 03:43:37 +04:00
|
|
|
wLog* log;
|
2014-08-06 18:23:14 +04:00
|
|
|
wBufferPool* bufferPool;
|
|
|
|
|
2014-07-30 01:37:46 +04:00
|
|
|
UINT32 cRects;
|
|
|
|
RFX_RECT* rects;
|
|
|
|
|
2014-08-01 17:44:00 +04:00
|
|
|
UINT32 cTiles;
|
2014-08-27 00:15:22 +04:00
|
|
|
RFX_PROGRESSIVE_TILE** tiles;
|
2014-08-01 17:44:00 +04:00
|
|
|
|
2014-07-30 01:37:46 +04:00
|
|
|
UINT32 cQuant;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT* quantVals;
|
|
|
|
|
|
|
|
UINT32 cProgQuant;
|
|
|
|
RFX_PROGRESSIVE_CODEC_QUANT* quantProgVals;
|
2014-07-31 23:08:54 +04:00
|
|
|
|
|
|
|
PROGRESSIVE_BLOCK_REGION region;
|
|
|
|
RFX_PROGRESSIVE_CODEC_QUANT quantProgValFull;
|
2014-08-27 00:15:22 +04:00
|
|
|
|
|
|
|
wHashTable* SurfaceContexts;
|
2014-07-29 01:42:23 +04:00
|
|
|
};
|
|
|
|
typedef struct _PROGRESSIVE_CONTEXT PROGRESSIVE_CONTEXT;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FREERDP_API int progressive_compress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize);
|
|
|
|
|
|
|
|
FREERDP_API int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UINT32 SrcSize,
|
2014-08-27 00:15:22 +04:00
|
|
|
BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int 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);
|
2014-07-29 01:42:23 +04:00
|
|
|
|
|
|
|
FREERDP_API void progressive_context_reset(PROGRESSIVE_CONTEXT* progressive);
|
|
|
|
|
|
|
|
FREERDP_API PROGRESSIVE_CONTEXT* progressive_context_new(BOOL Compressor);
|
|
|
|
FREERDP_API void progressive_context_free(PROGRESSIVE_CONTEXT* progressive);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* FREERDP_CODEC_PROGRESSIVE_H */
|
|
|
|
|