Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rfx.h « freerdp « include - github.com/FreeRDP/FreeRDP-old.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 932f5f58982cd41b6f71b147b4ddd7d495c217f8 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
   FreeRDP: A Remote Desktop Protocol client.
   RemoteFX Codec Library - API Header

   Copyright 2011 Vic Lee

   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 __RFX_H
#define __RFX_H

#include "types/base.h"

#include <freerdp/utils/profiler.h>

#ifdef __cplusplus
extern "C" {
#endif

/* sync */
#define WF_MAGIC		0xCACCACCA
#define WF_VERSION_1_0		0x0100

/* blockType */
#define WBT_SYNC		0xCCC0
#define WBT_CODEC_VERSIONS	0xCCC1
#define WBT_CHANNELS		0xCCC2
#define WBT_CONTEXT		0xCCC3
#define WBT_FRAME_BEGIN		0xCCC4
#define WBT_FRAME_END		0xCCC5
#define WBT_REGION		0xCCC6
#define WBT_EXTENSION		0xCCC7
#define CBT_REGION		0xCAC1
#define CBT_TILESET		0xCAC2
#define CBT_TILE		0xCAC3

/* tileSize */
#define CT_TILE_64x64		0x0040

/* properties.flags */
#define CODEC_MODE		0x02

/* properties.cct */
#define COL_CONV_ICT		0x1

/* properties.xft */
#define CLW_XFORM_DWT_53_A	0x1

/* properties.et */
#define CLW_ENTROPY_RLGR1	0x01
#define CLW_ENTROPY_RLGR3	0x04

/* properties.qt */
#define SCALAR_QUANTIZATION	0x1

enum _RLGR_MODE
{
	RLGR1,
	RLGR3
};
typedef enum _RLGR_MODE RLGR_MODE;

enum _RFX_PIXEL_FORMAT
{
	RFX_PIXEL_FORMAT_BGRA,
	RFX_PIXEL_FORMAT_RGBA,
	RFX_PIXEL_FORMAT_BGR,
	RFX_PIXEL_FORMAT_RGB
};
typedef enum _RFX_PIXEL_FORMAT RFX_PIXEL_FORMAT;

struct _RFX_RECT
{
	uint16 x;
	uint16 y;
	uint16 width;
	uint16 height;
};
typedef struct _RFX_RECT RFX_RECT;

struct _RFX_TILE
{
	uint16 x;
	uint16 y;
	uint8 * data;
};
typedef struct _RFX_TILE RFX_TILE;

struct _RFX_POOL
{
	int size;
	int count;
	RFX_TILE **tiles;
};
typedef struct _RFX_POOL RFX_POOL;

struct _RFX_MESSAGE
{
	/*
	 * The rects array represents the updated region of the frame. The UI
	 * requires to clip drawing destination base on the union of the rects.
	 */
	uint16 num_rects;
	RFX_RECT * rects;

	/* The tiles array represents the actual frame data. Each tile is always
	 * 64x64. Note that only pixels inside the updated region (represented as
	 * rects described above) are valid. Pixels outside of the region may
	 * contain arbitrary data.
	 */
	uint16 num_tiles;
	RFX_TILE** tiles;
};
typedef struct _RFX_MESSAGE RFX_MESSAGE;

struct _RFX_CONTEXT
{
	uint16 flags;
	uint16 properties;
	uint16 width;
	uint16 height;
	RLGR_MODE mode;
	uint32 version;
	uint32 codec_id;
	uint32 codec_version;
	RFX_PIXEL_FORMAT pixel_format;
	uint8 bytes_per_pixel;

	/* temporary data within a frame */
	uint32 frame_idx;
	uint8 num_quants;
	uint32 * quants;
	uint8 quant_idx_y;
	uint8 quant_idx_cb;
	uint8 quant_idx_cr;

	/* pre-allocated buffers */

	RFX_POOL* pool; /* memory pool */

	sint16 y_r_mem[4096+8]; /* 4096 = 64x64 (+ 8x2 = 16 for mem align) */
	sint16 cb_g_mem[4096+8]; /* 4096 = 64x64 (+ 8x2 = 16 for mem align) */
	sint16 cr_b_mem[4096+8]; /* 4096 = 64x64 (+ 8x2 = 16 for mem align) */
 
 	sint16 * y_r_buffer;
	sint16 * cb_g_buffer;
	sint16 * cr_b_buffer;
 
	sint16 dwt_mem[32*32*2*2 + 8]; /* maximum sub-band width is 32 */

	sint16 * dwt_buffer;

	/* routines */
	void (* decode_YCbCr_to_RGB)(sint16 * y_r_buf, sint16 * cb_g_buf, sint16 * cr_b_buf);
	void (* encode_RGB_to_YCbCr)(sint16 * y_r_buf, sint16 * cb_g_buf, sint16 * cr_b_buf);
	void (* quantization_decode)(sint16 * buffer, const uint32 * quantization_values);
	void (* quantization_encode)(sint16 * buffer, const uint32 * quantization_values);
	void (* dwt_2d_decode)(sint16 * buffer, sint16 * dwt_buffer);
	void (* dwt_2d_encode)(sint16 * buffer, sint16 * dwt_buffer);

	/* profiler definitions */
	PROFILER_DEFINE(prof_rfx_decode_rgb);
	PROFILER_DEFINE(prof_rfx_decode_component);
	PROFILER_DEFINE(prof_rfx_rlgr_decode);
	PROFILER_DEFINE(prof_rfx_differential_decode);
	PROFILER_DEFINE(prof_rfx_quantization_decode);
	PROFILER_DEFINE(prof_rfx_dwt_2d_decode);
	PROFILER_DEFINE(prof_rfx_decode_YCbCr_to_RGB);
	PROFILER_DEFINE(prof_rfx_decode_format_RGB);

	PROFILER_DEFINE(prof_rfx_encode_rgb);
	PROFILER_DEFINE(prof_rfx_encode_component);
	PROFILER_DEFINE(prof_rfx_rlgr_encode);
	PROFILER_DEFINE(prof_rfx_differential_encode);
	PROFILER_DEFINE(prof_rfx_quantization_encode);
	PROFILER_DEFINE(prof_rfx_dwt_2d_encode);
	PROFILER_DEFINE(prof_rfx_encode_RGB_to_YCbCr);
	PROFILER_DEFINE(prof_rfx_encode_format_RGB);
};
typedef struct _RFX_CONTEXT RFX_CONTEXT;

RFX_CONTEXT* rfx_context_new(void);
void rfx_context_free(RFX_CONTEXT * context);
void rfx_context_set_pixel_format(RFX_CONTEXT * context, RFX_PIXEL_FORMAT pixel_format);

RFX_MESSAGE* rfx_process_message(RFX_CONTEXT * context, uint8 * data, int size);
void rfx_message_free(RFX_CONTEXT * context, RFX_MESSAGE * message);

int rfx_compose_message_header(RFX_CONTEXT * context, uint8 * buffer, int buffer_size);
int rfx_compose_message_data(RFX_CONTEXT * context, uint8 * buffer, int buffer_size,
	const RFX_RECT * rects, int num_rects, uint8 * image_data, int width, int height, int rowstride);

#ifdef __cplusplus
}
#endif

#endif /* __RFX_H */