Blame include/freerdp/codec/rfx.h

Packit 1fb8d4
/**
Packit 1fb8d4
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit 1fb8d4
 * RemoteFX Codec
Packit 1fb8d4
 *
Packit 1fb8d4
 * Copyright 2011 Vic Lee
Packit 1fb8d4
 * Copyright 2016 Armin Novak <armin.novak@thincast.com>
Packit 1fb8d4
 * Copyright 2016 Thincast Technologies GmbH
Packit 1fb8d4
 *
Packit 1fb8d4
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 1fb8d4
 * you may not use this file except in compliance with the License.
Packit 1fb8d4
 * You may obtain a copy of the License at
Packit 1fb8d4
 *
Packit 1fb8d4
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 1fb8d4
 *
Packit 1fb8d4
 * Unless required by applicable law or agreed to in writing, software
Packit 1fb8d4
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 1fb8d4
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 1fb8d4
 * See the License for the specific language governing permissions and
Packit 1fb8d4
 * limitations under the License.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#ifndef FREERDP_CODEC_REMOTEFX_H
Packit 1fb8d4
#define FREERDP_CODEC_REMOTEFX_H
Packit 1fb8d4
Packit 1fb8d4
typedef struct _RFX_RECT RFX_RECT;
Packit 1fb8d4
typedef struct _RFX_TILE RFX_TILE;
Packit 1fb8d4
typedef struct _RFX_MESSAGE RFX_MESSAGE;
Packit 1fb8d4
typedef struct _RFX_CONTEXT RFX_CONTEXT;
Packit 1fb8d4
Packit 1fb8d4
#include <freerdp/api.h>
Packit 1fb8d4
#include <freerdp/types.h>
Packit 1fb8d4
#include <freerdp/freerdp.h>
Packit 1fb8d4
#include <freerdp/constants.h>
Packit 1fb8d4
#include <freerdp/codec/region.h>
Packit 1fb8d4
Packit 1fb8d4
#include <winpr/stream.h>
Packit 1fb8d4
Packit 1fb8d4
#ifdef __cplusplus
Packit Service 5a9772
extern "C"
Packit 1fb8d4
{
Packit Service 5a9772
#endif
Packit 1fb8d4
Packit Service 5a9772
	enum _RLGR_MODE
Packit Service 5a9772
	{
Packit Service 5a9772
		RLGR1,
Packit Service 5a9772
		RLGR3
Packit Service 5a9772
	};
Packit Service 5a9772
	typedef enum _RLGR_MODE RLGR_MODE;
Packit Service 5a9772
Packit Service 5a9772
	struct _RFX_RECT
Packit Service 5a9772
	{
Packit Service 5a9772
		UINT16 x;
Packit Service 5a9772
		UINT16 y;
Packit Service 5a9772
		UINT16 width;
Packit Service 5a9772
		UINT16 height;
Packit Service 5a9772
	};
Packit Service 5a9772
Packit Service 5a9772
	struct _RFX_TILE
Packit Service 5a9772
	{
Packit Service 5a9772
		UINT16 x;
Packit Service 5a9772
		UINT16 y;
Packit Service 5a9772
		UINT32 width;
Packit Service 5a9772
		UINT32 height;
Packit Service 5a9772
		BYTE* data;
Packit Service 5a9772
		UINT32 scanline;
Packit Service 5a9772
		BOOL allocated;
Packit Service 5a9772
		BYTE quantIdxY;
Packit Service 5a9772
		BYTE quantIdxCb;
Packit Service 5a9772
		BYTE quantIdxCr;
Packit Service 5a9772
		UINT16 xIdx;
Packit Service 5a9772
		UINT16 yIdx;
Packit Service 5a9772
		UINT16 YLen;
Packit Service 5a9772
		UINT16 CbLen;
Packit Service 5a9772
		UINT16 CrLen;
Packit Service 5a9772
		BYTE* YData;
Packit Service 5a9772
		BYTE* CbData;
Packit Service 5a9772
		BYTE* CrData;
Packit Service 5a9772
		BYTE* YCbCrData;
Packit Service 5a9772
	};
Packit Service 5a9772
Packit Service 5a9772
	struct _RFX_MESSAGE
Packit Service 5a9772
	{
Packit Service 5a9772
		UINT32 frameIdx;
Packit Service 5a9772
Packit Service 5a9772
		/**
Packit Service 5a9772
		 * The rects array represents the updated region of the frame. The UI
Packit Service 5a9772
		 * requires to clip drawing destination base on the union of the rects.
Packit Service 5a9772
		 */
Packit Service 5a9772
		UINT16 numRects;
Packit Service 5a9772
		RFX_RECT* rects;
Packit Service 5a9772
		BOOL freeRects;
Packit Service 5a9772
Packit Service 5a9772
		/**
Packit Service 5a9772
		 * The tiles array represents the actual frame data. Each tile is always
Packit Service 5a9772
		 * 64x64. Note that only pixels inside the updated region (represented as
Packit Service 5a9772
		 * rects described above) are valid. Pixels outside of the region may
Packit Service 5a9772
		 * contain arbitrary data.
Packit Service 5a9772
		 */
Packit Service 5a9772
		UINT16 numTiles;
Packit Service 5a9772
		RFX_TILE** tiles;
Packit Service 5a9772
Packit Service 5a9772
		UINT16 numQuant;
Packit Service 5a9772
		UINT32* quantVals;
Packit Service 5a9772
Packit Service 5a9772
		UINT32 tilesDataSize;
Packit Service 5a9772
Packit Service 5a9772
		BOOL freeArray;
Packit Service 5a9772
	};
Packit Service 5a9772
Packit Service 5a9772
	typedef struct _RFX_CONTEXT_PRIV RFX_CONTEXT_PRIV;
Packit Service 5a9772
Packit Service 5a9772
	enum _RFX_STATE
Packit Service 5a9772
	{
Packit Service 5a9772
		RFX_STATE_INITIAL,
Packit Service 5a9772
		RFX_STATE_SERVER_UNINITIALIZED,
Packit Service 5a9772
		RFX_STATE_SEND_HEADERS,
Packit Service 5a9772
		RFX_STATE_SEND_FRAME_DATA,
Packit Service 5a9772
		RFX_STATE_FRAME_DATA_SENT,
Packit Service 5a9772
		RFX_STATE_FINAL
Packit Service 5a9772
	};
Packit Service 5a9772
	typedef enum _RFX_STATE RFX_STATE;
Packit Service 5a9772
Packit Service 5a9772
#define _RFX_DECODED_SYNC 0x00000001
Packit Service 5a9772
#define _RFX_DECODED_CONTEXT 0x00000002
Packit Service 5a9772
#define _RFX_DECODED_VERSIONS 0x00000004
Packit Service 5a9772
#define _RFX_DECODED_CHANNELS 0x00000008
Packit Service 5a9772
#define _RFX_DECODED_HEADERS 0x0000000F
Packit Service 5a9772
Packit Service 5a9772
	struct _RFX_CONTEXT
Packit Service 5a9772
	{
Packit Service 5a9772
		RFX_STATE state;
Packit Service 5a9772
Packit Service 5a9772
		BOOL encoder;
Packit Service 5a9772
		UINT16 flags;
Packit Service 5a9772
		UINT16 properties;
Packit Service 5a9772
		UINT16 width;
Packit Service 5a9772
		UINT16 height;
Packit Service 5a9772
		RLGR_MODE mode;
Packit Service 5a9772
		UINT32 version;
Packit Service 5a9772
		UINT32 codec_id;
Packit Service 5a9772
		UINT32 codec_version;
Packit Service 5a9772
		UINT32 pixel_format;
Packit Service 5a9772
		BYTE bits_per_pixel;
Packit Service 5a9772
Packit Service 5a9772
		/* color palette allocated by the application */
Packit Service 5a9772
		const BYTE* palette;
Packit Service 5a9772
Packit Service 5a9772
		/* temporary data within a frame */
Packit Service 5a9772
		UINT32 frameIdx;
Packit Service 5a9772
		BYTE numQuant;
Packit Service 5a9772
		UINT32* quants;
Packit Service 5a9772
		BYTE quantIdxY;
Packit Service 5a9772
		BYTE quantIdxCb;
Packit Service 5a9772
		BYTE quantIdxCr;
Packit Service 5a9772
Packit Service 5a9772
		/* decoded header blocks */
Packit Service 5a9772
		UINT32 decodedHeaderBlocks;
Packit Service 5a9772
		UINT16 expectedDataBlockType;
Packit Service 5a9772
		RFX_MESSAGE currentMessage;
Packit Service 5a9772
Packit Service 5a9772
		/* routines */
Packit Service 5a9772
		void (*quantization_decode)(INT16* buffer, const UINT32* quantization_values);
Packit Service 5a9772
		void (*quantization_encode)(INT16* buffer, const UINT32* quantization_values);
Packit Service 5a9772
		void (*dwt_2d_decode)(INT16* buffer, INT16* dwt_buffer);
Packit Service 5a9772
		void (*dwt_2d_encode)(INT16* buffer, INT16* dwt_buffer);
Packit Service 5a9772
		int (*rlgr_decode)(RLGR_MODE mode, const BYTE* data, UINT32 data_size, INT16* buffer,
Packit Service 5a9772
		                   UINT32 buffer_size);
Packit Service 5a9772
		int (*rlgr_encode)(RLGR_MODE mode, const INT16* data, UINT32 data_size, BYTE* buffer,
Packit Service 5a9772
		                   UINT32 buffer_size);
Packit Service 5a9772
Packit Service 5a9772
		/* private definitions */
Packit Service 5a9772
		RFX_CONTEXT_PRIV* priv;
Packit Service 5a9772
	};
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, UINT32 pixel_format);
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data, UINT32 length,
Packit Service 5a9772
	                                     UINT32 left, UINT32 top, BYTE* dst, UINT32 dstFormat,
Packit Service 5a9772
	                                     UINT32 dstStride, UINT32 dstHeight,
Packit Service 5a9772
	                                     REGION16* invalidRegion);
Packit Service 5a9772
	FREERDP_API UINT16 rfx_message_get_tile_count(RFX_MESSAGE* message);
Packit Service 5a9772
	FREERDP_API UINT16 rfx_message_get_rect_count(RFX_MESSAGE* message);
Packit Service 5a9772
	FREERDP_API void rfx_message_free(RFX_CONTEXT* context, RFX_MESSAGE* message);
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API BOOL rfx_compose_message(RFX_CONTEXT* context, wStream* s, const RFX_RECT* rects,
Packit Service 5a9772
	                                     int num_rects, BYTE* image_data, int width, int height,
Packit Service 5a9772
	                                     int rowstride);
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
Packit Service 5a9772
	                                            int numRects, BYTE* data, int width, int height,
Packit Service 5a9772
	                                            int scanline);
Packit Service 5a9772
	FREERDP_API RFX_MESSAGE* rfx_encode_messages(RFX_CONTEXT* context, const RFX_RECT* rects,
Packit Service 5a9772
	                                             int numRects, BYTE* data, int width, int height,
Packit Service 5a9772
	                                             int scanline, int* numMessages, int maxDataSize);
Packit Service 5a9772
	FREERDP_API BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s, RFX_MESSAGE* message);
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width, UINT32 height);
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API RFX_CONTEXT* rfx_context_new(BOOL encoder);
Packit Service 5a9772
	FREERDP_API void rfx_context_free(RFX_CONTEXT* context);
Packit 1fb8d4
Packit 1fb8d4
#ifdef __cplusplus
Packit 1fb8d4
}
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
#endif /* FREERDP_CODEC_REMOTEFX_H */