2017-01-18 18:41:02 +03:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* Progressive Codec Bitmap Compression
|
|
|
|
*
|
|
|
|
* Copyright 2017 Armin Novak <anovak@thincast.com>
|
|
|
|
* Copyright 2017 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.
|
|
|
|
* 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 INTERNAL_CODEC_PROGRESSIVE_H
|
|
|
|
#define INTERNAL_CODEC_PROGRESSIVE_H
|
|
|
|
|
|
|
|
#include <winpr/wlog.h>
|
|
|
|
#include <winpr/collections.h>
|
|
|
|
|
|
|
|
#include <freerdp/codec/rfx.h>
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define RFX_SUBBAND_DIFFING 0x01
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define RFX_TILE_DIFFERENCE 0x01
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define RFX_DWT_REDUCE_EXTRAPOLATE 0x01
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
BYTE LL3;
|
|
|
|
BYTE HL3;
|
|
|
|
BYTE LH3;
|
|
|
|
BYTE HH3;
|
|
|
|
BYTE HL2;
|
|
|
|
BYTE LH2;
|
|
|
|
BYTE HH2;
|
|
|
|
BYTE HL1;
|
|
|
|
BYTE LH1;
|
|
|
|
BYTE HH1;
|
2022-02-14 16:59:22 +03:00
|
|
|
} RFX_COMPONENT_CODEC_QUANT;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
BYTE quality;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT yQuantValues;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT cbQuantValues;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT crQuantValues;
|
2022-02-14 16:59:22 +03:00
|
|
|
} RFX_PROGRESSIVE_CODEC_QUANT;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
2022-02-14 16:59:22 +03:00
|
|
|
} PROGRESSIVE_BLOCK;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
UINT32 magic;
|
|
|
|
UINT16 version;
|
2022-02-14 16:59:22 +03:00
|
|
|
} PROGRESSIVE_BLOCK_SYNC;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
BYTE ctxId;
|
|
|
|
UINT16 tileSize;
|
|
|
|
BYTE flags;
|
2022-02-14 16:59:22 +03:00
|
|
|
} PROGRESSIVE_BLOCK_CONTEXT;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
BYTE quantIdxY;
|
|
|
|
BYTE quantIdxCb;
|
|
|
|
BYTE quantIdxCr;
|
|
|
|
UINT16 xIdx;
|
|
|
|
UINT16 yIdx;
|
|
|
|
|
|
|
|
BYTE flags;
|
|
|
|
BYTE quality;
|
2023-05-10 00:33:52 +03:00
|
|
|
BOOL dirty;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
|
|
|
UINT16 yLen;
|
|
|
|
UINT16 cbLen;
|
|
|
|
UINT16 crLen;
|
|
|
|
UINT16 tailLen;
|
|
|
|
const BYTE* yData;
|
|
|
|
const BYTE* cbData;
|
|
|
|
const BYTE* crData;
|
|
|
|
const BYTE* tailData;
|
|
|
|
|
|
|
|
UINT16 ySrlLen;
|
|
|
|
UINT16 yRawLen;
|
|
|
|
UINT16 cbSrlLen;
|
|
|
|
UINT16 cbRawLen;
|
|
|
|
UINT16 crSrlLen;
|
|
|
|
UINT16 crRawLen;
|
|
|
|
const BYTE* ySrlData;
|
|
|
|
const BYTE* yRawData;
|
|
|
|
const BYTE* cbSrlData;
|
|
|
|
const BYTE* cbRawData;
|
|
|
|
const BYTE* crSrlData;
|
|
|
|
const BYTE* crRawData;
|
|
|
|
|
|
|
|
UINT32 x;
|
|
|
|
UINT32 y;
|
|
|
|
UINT32 width;
|
|
|
|
UINT32 height;
|
|
|
|
UINT32 stride;
|
|
|
|
|
|
|
|
BYTE* data;
|
|
|
|
BYTE* current;
|
|
|
|
|
|
|
|
UINT16 pass;
|
|
|
|
BYTE* sign;
|
2019-12-10 18:19:20 +03:00
|
|
|
|
2017-01-18 18:41:02 +03:00
|
|
|
RFX_COMPONENT_CODEC_QUANT yBitPos;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT cbBitPos;
|
|
|
|
RFX_COMPONENT_CODEC_QUANT crBitPos;
|
|
|
|
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;
|
2022-02-14 16:59:22 +03:00
|
|
|
} RFX_PROGRESSIVE_TILE;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
BYTE tileSize;
|
|
|
|
UINT16 numRects;
|
|
|
|
BYTE numQuant;
|
|
|
|
BYTE numProgQuant;
|
|
|
|
BYTE flags;
|
|
|
|
UINT16 numTiles;
|
2019-12-10 18:19:20 +03:00
|
|
|
UINT16 usedTiles;
|
2017-01-18 18:41:02 +03:00
|
|
|
UINT32 tileDataSize;
|
2019-12-10 18:19:20 +03:00
|
|
|
RFX_RECT rects[0x10000];
|
|
|
|
RFX_COMPONENT_CODEC_QUANT quantVals[0x100];
|
|
|
|
RFX_PROGRESSIVE_CODEC_QUANT quantProgVals[0x100];
|
|
|
|
RFX_PROGRESSIVE_TILE* tiles[0x10000];
|
2022-02-14 16:59:22 +03:00
|
|
|
} PROGRESSIVE_BLOCK_REGION;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
|
|
|
|
|
|
|
UINT32 frameIndex;
|
|
|
|
UINT16 regionCount;
|
|
|
|
PROGRESSIVE_BLOCK_REGION* regions;
|
2022-02-14 16:59:22 +03:00
|
|
|
} PROGRESSIVE_BLOCK_FRAME_BEGIN;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
UINT16 blockType;
|
|
|
|
UINT32 blockLen;
|
2022-02-14 16:59:22 +03:00
|
|
|
} PROGRESSIVE_BLOCK_FRAME_END;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
UINT16 id;
|
|
|
|
UINT32 width;
|
|
|
|
UINT32 height;
|
|
|
|
UINT32 gridWidth;
|
|
|
|
UINT32 gridHeight;
|
|
|
|
UINT32 gridSize;
|
2023-03-23 13:15:40 +03:00
|
|
|
RFX_PROGRESSIVE_TILE** tiles;
|
2022-04-28 09:00:39 +03:00
|
|
|
size_t tilesSize;
|
2021-02-04 08:01:38 +03:00
|
|
|
UINT32 frameId;
|
|
|
|
UINT32 numUpdatedTiles;
|
|
|
|
UINT32* updatedTileIndices;
|
2022-02-14 16:59:22 +03:00
|
|
|
} PROGRESSIVE_SURFACE_CONTEXT;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef enum
|
2019-12-10 18:19:20 +03:00
|
|
|
{
|
|
|
|
FLAG_WBT_SYNC = 0x01,
|
|
|
|
FLAG_WBT_FRAME_BEGIN = 0x02,
|
|
|
|
FLAG_WBT_FRAME_END = 0x04,
|
|
|
|
FLAG_WBT_CONTEXT = 0x08,
|
|
|
|
FLAG_WBT_REGION = 0x10
|
2022-02-14 16:59:22 +03:00
|
|
|
} WBT_STATE_FLAG;
|
2019-12-10 18:19:20 +03:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
struct S_PROGRESSIVE_CONTEXT
|
2017-01-18 18:41:02 +03:00
|
|
|
{
|
|
|
|
BOOL Compressor;
|
|
|
|
|
|
|
|
wBufferPool* bufferPool;
|
|
|
|
|
|
|
|
UINT32 format;
|
2019-12-10 18:19:20 +03:00
|
|
|
UINT32 state;
|
2017-01-18 18:41:02 +03:00
|
|
|
|
2019-12-10 18:19:20 +03:00
|
|
|
PROGRESSIVE_BLOCK_CONTEXT context;
|
2017-01-18 18:41:02 +03:00
|
|
|
PROGRESSIVE_BLOCK_REGION region;
|
|
|
|
RFX_PROGRESSIVE_CODEC_QUANT quantProgValFull;
|
|
|
|
|
|
|
|
wHashTable* SurfaceContexts;
|
|
|
|
wLog* log;
|
2020-12-15 11:58:37 +03:00
|
|
|
wStream* buffer;
|
|
|
|
wStream* rects;
|
|
|
|
RFX_CONTEXT* rfx_context;
|
2017-01-18 18:41:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* INTERNAL_CODEC_PROGRESSIVE_H */
|