rfx.h (6241B)
1/** 2 * FreeRDP: A Remote Desktop Protocol Implementation 3 * RemoteFX Codec 4 * 5 * Copyright 2011 Vic Lee 6 * Copyright 2016 Armin Novak <armin.novak@thincast.com> 7 * Copyright 2016 Thincast Technologies GmbH 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22#ifndef FREERDP_CODEC_REMOTEFX_H 23#define FREERDP_CODEC_REMOTEFX_H 24 25typedef struct _RFX_RECT RFX_RECT; 26typedef struct _RFX_TILE RFX_TILE; 27typedef struct _RFX_MESSAGE RFX_MESSAGE; 28typedef struct _RFX_CONTEXT RFX_CONTEXT; 29 30#include <freerdp/api.h> 31#include <freerdp/types.h> 32#include <freerdp/freerdp.h> 33#include <freerdp/constants.h> 34#include <freerdp/codec/region.h> 35 36#include <winpr/stream.h> 37 38#ifdef __cplusplus 39extern "C" 40{ 41#endif 42 43 enum _RLGR_MODE 44 { 45 RLGR1, 46 RLGR3 47 }; 48 typedef enum _RLGR_MODE RLGR_MODE; 49 50 struct _RFX_RECT 51 { 52 UINT16 x; 53 UINT16 y; 54 UINT16 width; 55 UINT16 height; 56 }; 57 58 struct _RFX_TILE 59 { 60 UINT16 x; 61 UINT16 y; 62 UINT32 width; 63 UINT32 height; 64 BYTE* data; 65 UINT32 scanline; 66 BOOL allocated; 67 BYTE quantIdxY; 68 BYTE quantIdxCb; 69 BYTE quantIdxCr; 70 UINT16 xIdx; 71 UINT16 yIdx; 72 UINT16 YLen; 73 UINT16 CbLen; 74 UINT16 CrLen; 75 BYTE* YData; 76 BYTE* CbData; 77 BYTE* CrData; 78 BYTE* YCbCrData; 79 }; 80 81 struct _RFX_MESSAGE 82 { 83 UINT32 frameIdx; 84 85 /** 86 * The rects array represents the updated region of the frame. The UI 87 * requires to clip drawing destination base on the union of the rects. 88 */ 89 UINT16 numRects; 90 RFX_RECT* rects; 91 BOOL freeRects; 92 93 /** 94 * The tiles array represents the actual frame data. Each tile is always 95 * 64x64. Note that only pixels inside the updated region (represented as 96 * rects described above) are valid. Pixels outside of the region may 97 * contain arbitrary data. 98 */ 99 UINT16 numTiles; 100 RFX_TILE** tiles; 101 102 UINT16 numQuant; 103 UINT32* quantVals; 104 105 UINT32 tilesDataSize; 106 107 BOOL freeArray; 108 }; 109 110 typedef struct _RFX_CONTEXT_PRIV RFX_CONTEXT_PRIV; 111 112 enum _RFX_STATE 113 { 114 RFX_STATE_INITIAL, 115 RFX_STATE_SERVER_UNINITIALIZED, 116 RFX_STATE_SEND_HEADERS, 117 RFX_STATE_SEND_FRAME_DATA, 118 RFX_STATE_FRAME_DATA_SENT, 119 RFX_STATE_FINAL 120 }; 121 typedef enum _RFX_STATE RFX_STATE; 122 123#define _RFX_DECODED_SYNC 0x00000001 124#define _RFX_DECODED_CONTEXT 0x00000002 125#define _RFX_DECODED_VERSIONS 0x00000004 126#define _RFX_DECODED_CHANNELS 0x00000008 127#define _RFX_DECODED_HEADERS 0x0000000F 128 129 struct _RFX_CONTEXT 130 { 131 RFX_STATE state; 132 133 BOOL encoder; 134 UINT16 flags; 135 UINT16 properties; 136 UINT16 width; 137 UINT16 height; 138 RLGR_MODE mode; 139 UINT32 version; 140 UINT32 codec_id; 141 UINT32 codec_version; 142 UINT32 pixel_format; 143 BYTE bits_per_pixel; 144 145 /* color palette allocated by the application */ 146 const BYTE* palette; 147 148 /* temporary data within a frame */ 149 UINT32 frameIdx; 150 BYTE numQuant; 151 UINT32* quants; 152 BYTE quantIdxY; 153 BYTE quantIdxCb; 154 BYTE quantIdxCr; 155 156 /* decoded header blocks */ 157 UINT32 decodedHeaderBlocks; 158 UINT16 expectedDataBlockType; 159 RFX_MESSAGE currentMessage; 160 161 /* routines */ 162 void (*quantization_decode)(INT16* buffer, const UINT32* quantization_values); 163 void (*quantization_encode)(INT16* buffer, const UINT32* quantization_values); 164 void (*dwt_2d_decode)(INT16* buffer, INT16* dwt_buffer); 165 void (*dwt_2d_encode)(INT16* buffer, INT16* dwt_buffer); 166 int (*rlgr_decode)(RLGR_MODE mode, const BYTE* data, UINT32 data_size, INT16* buffer, 167 UINT32 buffer_size); 168 int (*rlgr_encode)(RLGR_MODE mode, const INT16* data, UINT32 data_size, BYTE* buffer, 169 UINT32 buffer_size); 170 171 /* private definitions */ 172 RFX_CONTEXT_PRIV* priv; 173 }; 174 175 FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, UINT32 pixel_format); 176 177 FREERDP_API BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data, UINT32 length, 178 UINT32 left, UINT32 top, BYTE* dst, UINT32 dstFormat, 179 UINT32 dstStride, UINT32 dstHeight, 180 REGION16* invalidRegion); 181 FREERDP_API UINT16 rfx_message_get_tile_count(RFX_MESSAGE* message); 182 FREERDP_API UINT16 rfx_message_get_rect_count(RFX_MESSAGE* message); 183 FREERDP_API void rfx_message_free(RFX_CONTEXT* context, RFX_MESSAGE* message); 184 185 FREERDP_API BOOL rfx_compose_message(RFX_CONTEXT* context, wStream* s, const RFX_RECT* rects, 186 size_t num_rects, const BYTE* image_data, UINT32 width, 187 UINT32 height, UINT32 rowstride); 188 189 FREERDP_API RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects, 190 size_t numRects, const BYTE* data, UINT32 width, 191 UINT32 height, size_t scanline); 192 193#if !defined(DEFINE_NO_DEPRECATED) 194 FREERDP_API WINPR_DEPRECATED(RFX_MESSAGE* rfx_encode_messages( 195 RFX_CONTEXT* context, const RFX_RECT* rects, int numRects, const BYTE* data, int width, 196 int height, int scanline, int* numMessages, int maxDataSize)); 197#endif 198 199 FREERDP_API RFX_MESSAGE* rfx_encode_messages_ex(RFX_CONTEXT* context, const RFX_RECT* rects, 200 size_t numRects, const BYTE* data, UINT32 width, 201 UINT32 height, UINT32 scanline, 202 size_t* numMessages, size_t maxDataSize); 203 FREERDP_API BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s, 204 const RFX_MESSAGE* message); 205 206 FREERDP_API BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width, UINT32 height); 207 208 FREERDP_API RFX_CONTEXT* rfx_context_new(BOOL encoder); 209 FREERDP_API void rfx_context_free(RFX_CONTEXT* context); 210 211#ifdef __cplusplus 212} 213#endif 214 215#endif /* FREERDP_CODEC_REMOTEFX_H */