From 34eb0e5d9dfbce791f76714c79c4cbbf09a4a307 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 18 Jan 2017 16:41:02 +0100 Subject: [PATCH] Progressive structs to private header for tests. --- libfreerdp/codec/progressive.c | 204 +-------------- libfreerdp/codec/progressive.h | 233 ++++++++++++++++++ .../codec/test/TestFreeRDPCodecProgressive.c | 2 + 3 files changed, 236 insertions(+), 203 deletions(-) create mode 100644 libfreerdp/codec/progressive.h diff --git a/libfreerdp/codec/progressive.c b/libfreerdp/codec/progressive.c index ddbb01a66126..309d212aa465 100644 --- a/libfreerdp/codec/progressive.c +++ b/libfreerdp/codec/progressive.c @@ -34,212 +34,10 @@ #include "rfx_differential.h" #include "rfx_quantization.h" #include "rfx_rlgr.h" +#include "progressive.h" #define TAG FREERDP_TAG("codec.progressive") -#define RFX_SUBBAND_DIFFING 0x01 - -#define RFX_TILE_DIFFERENCE 0x01 - -#define RFX_DWT_REDUCE_EXTRAPOLATE 0x01 - -#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 -#define PROGRESSIVE_WBT_TILE_FIRST 0xCCC6 -#define PROGRESSIVE_WBT_TILE_UPGRADE 0xCCC7 - -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; - -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; - -struct _PROGRESSIVE_BLOCK -{ - UINT16 blockType; - UINT32 blockLen; -}; -typedef struct _PROGRESSIVE_BLOCK PROGRESSIVE_BLOCK; - -struct _PROGRESSIVE_BLOCK_SYNC -{ - UINT16 blockType; - UINT32 blockLen; - - UINT32 magic; - UINT16 version; -}; -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; - -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; - 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 format; - UINT32 stride; - - BYTE* data; - BYTE* current; - - UINT16 pass; - BYTE* sign; - 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; -}; -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; - RFX_PROGRESSIVE_TILE** tiles; -}; -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; - -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; - -struct _PROGRESSIVE_CONTEXT -{ - BOOL Compressor; - - wBufferPool* bufferPool; - - UINT32 cRects; - RFX_RECT* rects; - - UINT32 format; - - UINT32 cTiles; - RFX_PROGRESSIVE_TILE** tiles; - - UINT32 cQuant; - RFX_COMPONENT_CODEC_QUANT* quantVals; - - UINT32 cProgQuant; - RFX_PROGRESSIVE_CODEC_QUANT* quantProgVals; - - PROGRESSIVE_BLOCK_REGION region; - RFX_PROGRESSIVE_CODEC_QUANT quantProgValFull; - - wHashTable* SurfaceContexts; - wLog* log; -}; - static const char* progressive_get_block_type_string(UINT16 blockType) { switch (blockType) diff --git a/libfreerdp/codec/progressive.h b/libfreerdp/codec/progressive.h new file mode 100644 index 000000000000..35a093efd6ca --- /dev/null +++ b/libfreerdp/codec/progressive.h @@ -0,0 +1,233 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Progressive Codec Bitmap Compression + * + * Copyright 2017 Armin Novak + * 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 +#include + +#include + +#define RFX_SUBBAND_DIFFING 0x01 + +#define RFX_TILE_DIFFERENCE 0x01 + +#define RFX_DWT_REDUCE_EXTRAPOLATE 0x01 + +#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 +#define PROGRESSIVE_WBT_TILE_FIRST 0xCCC6 +#define PROGRESSIVE_WBT_TILE_UPGRADE 0xCCC7 + +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; + +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; + +struct _PROGRESSIVE_BLOCK +{ + UINT16 blockType; + UINT32 blockLen; +}; +typedef struct _PROGRESSIVE_BLOCK PROGRESSIVE_BLOCK; + +struct _PROGRESSIVE_BLOCK_SYNC +{ + UINT16 blockType; + UINT32 blockLen; + + UINT32 magic; + UINT16 version; +}; +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; + +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; + 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 format; + UINT32 stride; + + BYTE* data; + BYTE* current; + + UINT16 pass; + BYTE* sign; + 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; +}; +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; + RFX_PROGRESSIVE_TILE** tiles; +}; +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; + +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; + +struct _PROGRESSIVE_CONTEXT +{ + BOOL Compressor; + + wBufferPool* bufferPool; + + UINT32 cRects; + RFX_RECT* rects; + + UINT32 format; + + UINT32 cTiles; + RFX_PROGRESSIVE_TILE** tiles; + + UINT32 cQuant; + RFX_COMPONENT_CODEC_QUANT* quantVals; + + UINT32 cProgQuant; + RFX_PROGRESSIVE_CODEC_QUANT* quantProgVals; + + PROGRESSIVE_BLOCK_REGION region; + RFX_PROGRESSIVE_CODEC_QUANT quantProgValFull; + + wHashTable* SurfaceContexts; + wLog* log; +}; + +#endif /* INTERNAL_CODEC_PROGRESSIVE_H */ + diff --git a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c index 9ed19b791f2d..14e0e372b01c 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c @@ -8,6 +8,8 @@ #include +#include "../progressive.h" + /** * Microsoft Progressive Codec Sample Data * (available under NDA only)