summaryrefslogtreecommitdiffstats
path: root/include/freerdp/codec/rfx.h
blob: 2b122be67273184ff7108f8b00c8d98ecf886691 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/**
 * FreeRDP: A Remote Desktop Protocol Implementation
 * RemoteFX Codec
 *
 * Copyright 2011 Vic Lee
 * Copyright 2016 Armin Novak <armin.novak@thincast.com>
 * Copyright 2016 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 FREERDP_CODEC_REMOTEFX_H
#define FREERDP_CODEC_REMOTEFX_H

#include <freerdp/api.h>
#include <freerdp/types.h>
#include <freerdp/constants.h>
#include <freerdp/codec/region.h>

#include <winpr/stream.h>

#ifdef __cplusplus
extern "C"
{
#endif

	typedef enum
	{
		RLGR1,
		RLGR3
	} RLGR_MODE;

	typedef struct
	{
		UINT16 x;
		UINT16 y;
		UINT16 width;
		UINT16 height;
	} RFX_RECT;

	typedef struct
	{
		UINT16 x;
		UINT16 y;
		UINT32 width;
		UINT32 height;
		BYTE* data;
		UINT32 scanline;
		BOOL allocated;
		BYTE quantIdxY;
		BYTE quantIdxCb;
		BYTE quantIdxCr;
		UINT16 xIdx;
		UINT16 yIdx;
		UINT16 YLen;
		UINT16 CbLen;
		UINT16 CrLen;
		BYTE* YData;
		BYTE* CbData;
		BYTE* CrData;
		BYTE* YCbCrData;
	} RFX_TILE;

	typedef struct S_RFX_MESSAGE_LIST RFX_MESSAGE_LIST;
	typedef struct S_RFX_MESSAGE RFX_MESSAGE;
	typedef struct S_RFX_CONTEXT RFX_CONTEXT;

	FREERDP_API BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data, UINT32 length,
	                                     UINT32 left, UINT32 top, BYTE* dst, UINT32 dstFormat,
	                                     UINT32 dstStride, UINT32 dstHeight,
	                                     REGION16* invalidRegion);

	FREERDP_API UINT32 rfx_message_get_frame_idx(const RFX_MESSAGE* message);
	FREERDP_API const UINT32* rfx_message_get_quants(const RFX_MESSAGE* message,
	                                                 UINT16* numQuantVals);

	FREERDP_API const RFX_TILE** rfx_message_get_tiles(const RFX_MESSAGE* message,
	                                                   UINT16* numTiles);
	FREERDP_API UINT16 rfx_message_get_tile_count(const RFX_MESSAGE* message);

	FREERDP_API const RFX_RECT* rfx_message_get_rects(const RFX_MESSAGE* message, UINT16* numRects);
	FREERDP_API UINT16 rfx_message_get_rect_count(const RFX_MESSAGE* message);

	FREERDP_API void rfx_message_free(RFX_CONTEXT* context, RFX_MESSAGE* message);

	FREERDP_API BOOL rfx_compose_message(RFX_CONTEXT* context, wStream* s, const RFX_RECT* rects,
	                                     size_t num_rects, const BYTE* image_data, UINT32 width,
	                                     UINT32 height, UINT32 rowstride);

	FREERDP_API RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
	                                            size_t numRects, const BYTE* data, UINT32 width,
	                                            UINT32 height, size_t scanline);

	FREERDP_API RFX_MESSAGE_LIST* rfx_encode_messages(RFX_CONTEXT* context, const RFX_RECT* rects,
	                                                  size_t numRects, const BYTE* data,
	                                                  UINT32 width, UINT32 height, UINT32 scanline,
	                                                  size_t* numMessages, size_t maxDataSize);
	FREERDP_API void rfx_message_list_free(RFX_MESSAGE_LIST* messages);

	FREERDP_API const RFX_MESSAGE* rfx_message_list_get(const RFX_MESSAGE_LIST* messages,
	                                                    size_t idx);

	FREERDP_API BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s,
	                                   const RFX_MESSAGE* message);

	FREERDP_API void rfx_context_free(RFX_CONTEXT* context);

	WINPR_ATTR_MALLOC(rfx_context_free, 1)
	FREERDP_API RFX_CONTEXT* rfx_context_new_ex(BOOL encoder, UINT32 ThreadingFlags);

	WINPR_ATTR_MALLOC(rfx_context_free, 1)
	FREERDP_API RFX_CONTEXT* rfx_context_new(BOOL encoder);

	FREERDP_API BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width, UINT32 height);

	FREERDP_API BOOL rfx_context_set_mode(RFX_CONTEXT* context, RLGR_MODE mode);
	FREERDP_API RLGR_MODE rfx_context_get_mode(RFX_CONTEXT* context);

	FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, UINT32 pixel_format);
	FREERDP_API UINT32 rfx_context_get_pixel_format(RFX_CONTEXT* context);

	FREERDP_API void rfx_context_set_palette(RFX_CONTEXT* context, const BYTE* palette);
	FREERDP_API const BYTE* rfx_context_get_palette(RFX_CONTEXT* context);

	FREERDP_API UINT32 rfx_context_get_frame_idx(const RFX_CONTEXT* context);

	FREERDP_API BOOL rfx_write_message_progressive_simple(RFX_CONTEXT* rfx, wStream* s,
	                                                      const RFX_MESSAGE* msg);

#ifdef __cplusplus
}
#endif

#endif /* FREERDP_CODEC_REMOTEFX_H */