FreeRDP
rfx.c File Reference
#include <winpr/assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <winpr/tchar.h>
#include <winpr/sysinfo.h>
#include <winpr/registry.h>
#include <freerdp/log.h>
#include <freerdp/codec/rfx.h>
#include <freerdp/constants.h>
#include <freerdp/primitives.h>
#include <freerdp/codec/region.h>
#include <freerdp/build-config.h>
#include "rfx_constants.h"
#include "rfx_types.h"
#include "rfx_decode.h"
#include "rfx_encode.h"
#include "rfx_quantization.h"
#include "rfx_dwt.h"
#include "rfx_rlgr.h"
#include "rfx_sse2.h"
#include "rfx_neon.h"

Macros

#define TAG   FREERDP_TAG("codec")
 
#define RFX_INIT_SIMD(_rfx_context)
 
#define RFX_KEY   "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\RemoteFX"
 
#define TILE_NO(v)   ((v) / 64)
 

Functions

static void rfx_profiler_create (RFX_CONTEXT *context)
 
static void rfx_profiler_free (RFX_CONTEXT *context)
 
static void rfx_profiler_print (RFX_CONTEXT *context)
 
static void rfx_tile_init (void *obj)
 
static void * rfx_decoder_tile_new (const void *val)
 
static void rfx_decoder_tile_free (void *obj)
 
static void * rfx_encoder_tile_new (const void *val)
 
static void rfx_encoder_tile_free (void *obj)
 
RFX_CONTEXT * rfx_context_new (BOOL encoder)
 
RFX_CONTEXT * rfx_context_new_ex (BOOL encoder, UINT32 ThreadingFlags)
 
void rfx_context_free (RFX_CONTEXT *context)
 
static RFX_TILE * rfx_message_get_tile (RFX_MESSAGE *message, UINT32 index)
 
static const RFX_RECT * rfx_message_get_rect_const (const RFX_MESSAGE *message, UINT32 index)
 
static RFX_RECT * rfx_message_get_rect (RFX_MESSAGE *message, UINT32 index)
 
void rfx_context_set_pixel_format (RFX_CONTEXT *context, UINT32 pixel_format)
 
BOOL rfx_context_reset (RFX_CONTEXT *context, UINT32 width, UINT32 height)
 
static BOOL rfx_process_message_sync (RFX_CONTEXT *context, wStream *s)
 
static BOOL rfx_process_message_codec_versions (RFX_CONTEXT *context, wStream *s)
 
static BOOL rfx_process_message_channels (RFX_CONTEXT *context, wStream *s)
 
static BOOL rfx_process_message_context (RFX_CONTEXT *context, wStream *s)
 
static BOOL rfx_process_message_frame_begin (RFX_CONTEXT *context, RFX_MESSAGE *message, wStream *s, UINT16 *pExpectedBlockType)
 
static BOOL rfx_process_message_frame_end (RFX_CONTEXT *context, RFX_MESSAGE *message, wStream *s, UINT16 *pExpectedBlockType)
 
static BOOL rfx_process_message_region (RFX_CONTEXT *context, RFX_MESSAGE *message, wStream *s, UINT16 *pExpectedBlockType)
 
static void CALLBACK rfx_process_message_tile_work_callback (PTP_CALLBACK_INSTANCE instance, void *context, PTP_WORK work)
 
static BOOL rfx_process_message_tileset (RFX_CONTEXT *context, RFX_MESSAGE *message, wStream *s, UINT16 *pExpectedBlockType)
 
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)
 
UINT16 rfx_message_get_tile_count (RFX_MESSAGE *message)
 
UINT16 rfx_message_get_rect_count (RFX_MESSAGE *message)
 
void rfx_message_free (RFX_CONTEXT *context, RFX_MESSAGE *message)
 
static void rfx_update_context_properties (RFX_CONTEXT *context)
 
static void rfx_write_message_sync (RFX_CONTEXT *context, wStream *s)
 
static void rfx_write_message_codec_versions (RFX_CONTEXT *context, wStream *s)
 
static void rfx_write_message_channels (RFX_CONTEXT *context, wStream *s)
 
static void rfx_write_message_context (RFX_CONTEXT *context, wStream *s)
 
static BOOL rfx_compose_message_header (RFX_CONTEXT *context, wStream *s)
 
static int rfx_tile_length (RFX_TILE *tile)
 
static BOOL rfx_write_tile (RFX_CONTEXT *context, wStream *s, RFX_TILE *tile)
 
static void CALLBACK rfx_compose_message_tile_work_callback (PTP_CALLBACK_INSTANCE instance, void *context, PTP_WORK work)
 
static BOOL computeRegion (const RFX_RECT *rects, int numRects, REGION16 *region, int width, int height)
 
static BOOL setupWorkers (RFX_CONTEXT *context, int nbTiles)
 
RFX_MESSAGE * rfx_encode_message (RFX_CONTEXT *context, const RFX_RECT *rects, size_t numRects, const BYTE *data, UINT32 w, UINT32 h, size_t s)
 
static RFX_MESSAGE * rfx_split_message (RFX_CONTEXT *context, RFX_MESSAGE *message, size_t *numMessages, size_t maxDataSize)
 
RFX_MESSAGE * 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)
 
static BOOL rfx_write_message_tileset (RFX_CONTEXT *context, wStream *s, const RFX_MESSAGE *message)
 
static BOOL rfx_write_message_frame_begin (RFX_CONTEXT *context, wStream *s, const RFX_MESSAGE *message)
 
static BOOL rfx_write_message_region (RFX_CONTEXT *context, wStream *s, const RFX_MESSAGE *message)
 
static BOOL rfx_write_message_frame_end (RFX_CONTEXT *context, wStream *s, const RFX_MESSAGE *message)
 
BOOL rfx_write_message (RFX_CONTEXT *context, wStream *s, const RFX_MESSAGE *message)
 
BOOL rfx_compose_message (RFX_CONTEXT *context, wStream *s, const RFX_RECT *rects, size_t numRects, const BYTE *data, UINT32 width, UINT32 height, UINT32 scanline)
 

Variables

static const UINT32 rfx_default_quantization_values [] = { 6, 6, 6, 6, 7, 7, 8, 8, 8, 9 }
 

Macro Definition Documentation

◆ RFX_INIT_SIMD

#define RFX_INIT_SIMD (   _rfx_context)
Value:
do \
{ \
} while (0)

◆ RFX_KEY

#define RFX_KEY   "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\RemoteFX"

◆ TAG

#define TAG   FREERDP_TAG("codec")

FreeRDP: A Remote Desktop Protocol Implementation RemoteFX Codec Library

Copyright 2011 Vic Lee Copyright 2015 Thincast Technologies GmbH Copyright 2015 Norbert Federa norbe.nosp@m.rt.f.nosp@m.edera.nosp@m.@thi.nosp@m.ncast.nosp@m..com

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.

◆ TILE_NO

#define TILE_NO (   v)    ((v) / 64)

Function Documentation

◆ computeRegion()

static BOOL computeRegion ( const RFX_RECT *  rects,
int  numRects,
REGION16 *  region,
int  width,
int  height 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_compose_message()

BOOL rfx_compose_message ( RFX_CONTEXT *  context,
wStream *  s,
const RFX_RECT *  rects,
size_t  numRects,
const BYTE data,
UINT32  width,
UINT32  height,
UINT32  scanline 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_compose_message_header()

static BOOL rfx_compose_message_header ( RFX_CONTEXT *  context,
wStream *  s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_compose_message_tile_work_callback()

static void CALLBACK rfx_compose_message_tile_work_callback ( PTP_CALLBACK_INSTANCE  instance,
void *  context,
PTP_WORK  work 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_context_free()

void rfx_context_free ( RFX_CONTEXT *  context)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_context_new()

RFX_CONTEXT* rfx_context_new ( BOOL  encoder)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_context_new_ex()

RFX_CONTEXT* rfx_context_new_ex ( BOOL  encoder,
UINT32  ThreadingFlags 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_context_reset()

BOOL rfx_context_reset ( RFX_CONTEXT *  context,
UINT32  width,
UINT32  height 
)
Here is the caller graph for this function:

◆ rfx_context_set_pixel_format()

void rfx_context_set_pixel_format ( RFX_CONTEXT *  context,
UINT32  pixel_format 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_decoder_tile_free()

static void rfx_decoder_tile_free ( void *  obj)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_decoder_tile_new()

static void* rfx_decoder_tile_new ( const void *  val)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_encode_message()

RFX_MESSAGE* rfx_encode_message ( RFX_CONTEXT *  context,
const RFX_RECT *  rects,
size_t  numRects,
const BYTE data,
UINT32  w,
UINT32  h,
size_t  s 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_encode_messages()

RFX_MESSAGE* 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 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_encoder_tile_free()

static void rfx_encoder_tile_free ( void *  obj)
static
Here is the caller graph for this function:

◆ rfx_encoder_tile_new()

static void* rfx_encoder_tile_new ( const void *  val)
static
Here is the caller graph for this function:

◆ rfx_message_free()

void rfx_message_free ( RFX_CONTEXT *  context,
RFX_MESSAGE *  message 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_message_get_rect()

static RFX_RECT* rfx_message_get_rect ( RFX_MESSAGE *  message,
UINT32  index 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_message_get_rect_const()

static const RFX_RECT* rfx_message_get_rect_const ( const RFX_MESSAGE *  message,
UINT32  index 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_message_get_rect_count()

UINT16 rfx_message_get_rect_count ( RFX_MESSAGE *  message)
Here is the call graph for this function:

◆ rfx_message_get_tile()

static RFX_TILE* rfx_message_get_tile ( RFX_MESSAGE *  message,
UINT32  index 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_message_get_tile_count()

UINT16 rfx_message_get_tile_count ( RFX_MESSAGE *  message)
Here is the call graph for this function:

◆ rfx_process_message()

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 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_process_message_channels()

static BOOL rfx_process_message_channels ( RFX_CONTEXT *  context,
wStream *  s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_process_message_codec_versions()

static BOOL rfx_process_message_codec_versions ( RFX_CONTEXT *  context,
wStream *  s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_process_message_context()

static BOOL rfx_process_message_context ( RFX_CONTEXT *  context,
wStream *  s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_process_message_frame_begin()

static BOOL rfx_process_message_frame_begin ( RFX_CONTEXT *  context,
RFX_MESSAGE *  message,
wStream *  s,
UINT16 pExpectedBlockType 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_process_message_frame_end()

static BOOL rfx_process_message_frame_end ( RFX_CONTEXT *  context,
RFX_MESSAGE *  message,
wStream *  s,
UINT16 pExpectedBlockType 
)
static
Here is the caller graph for this function:

◆ rfx_process_message_region()

static BOOL rfx_process_message_region ( RFX_CONTEXT *  context,
RFX_MESSAGE *  message,
wStream *  s,
UINT16 pExpectedBlockType 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_process_message_sync()

static BOOL rfx_process_message_sync ( RFX_CONTEXT *  context,
wStream *  s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_process_message_tile_work_callback()

static void CALLBACK rfx_process_message_tile_work_callback ( PTP_CALLBACK_INSTANCE  instance,
void *  context,
PTP_WORK  work 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_process_message_tileset()

static BOOL rfx_process_message_tileset ( RFX_CONTEXT *  context,
RFX_MESSAGE *  message,
wStream *  s,
UINT16 pExpectedBlockType 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_profiler_create()

static void rfx_profiler_create ( RFX_CONTEXT *  context)
static
Here is the caller graph for this function:

◆ rfx_profiler_free()

static void rfx_profiler_free ( RFX_CONTEXT *  context)
static
Here is the caller graph for this function:

◆ rfx_profiler_print()

static void rfx_profiler_print ( RFX_CONTEXT *  context)
static
Here is the caller graph for this function:

◆ rfx_split_message()

static RFX_MESSAGE* rfx_split_message ( RFX_CONTEXT *  context,
RFX_MESSAGE *  message,
size_t *  numMessages,
size_t  maxDataSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_tile_init()

static void rfx_tile_init ( void *  obj)
static
Here is the caller graph for this function:

◆ rfx_tile_length()

static int rfx_tile_length ( RFX_TILE *  tile)
static
Here is the caller graph for this function:

◆ rfx_update_context_properties()

static void rfx_update_context_properties ( RFX_CONTEXT *  context)
static
Here is the caller graph for this function:

◆ rfx_write_message()

BOOL rfx_write_message ( RFX_CONTEXT *  context,
wStream *  s,
const RFX_MESSAGE *  message 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_write_message_channels()

static void rfx_write_message_channels ( RFX_CONTEXT *  context,
wStream *  s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_write_message_codec_versions()

static void rfx_write_message_codec_versions ( RFX_CONTEXT *  context,
wStream *  s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_write_message_context()

static void rfx_write_message_context ( RFX_CONTEXT *  context,
wStream *  s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_write_message_frame_begin()

static BOOL rfx_write_message_frame_begin ( RFX_CONTEXT *  context,
wStream *  s,
const RFX_MESSAGE *  message 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_write_message_frame_end()

static BOOL rfx_write_message_frame_end ( RFX_CONTEXT *  context,
wStream *  s,
const RFX_MESSAGE *  message 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_write_message_region()

static BOOL rfx_write_message_region ( RFX_CONTEXT *  context,
wStream *  s,
const RFX_MESSAGE *  message 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_write_message_sync()

static void rfx_write_message_sync ( RFX_CONTEXT *  context,
wStream *  s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_write_message_tileset()

static BOOL rfx_write_message_tileset ( RFX_CONTEXT *  context,
wStream *  s,
const RFX_MESSAGE *  message 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfx_write_tile()

static BOOL rfx_write_tile ( RFX_CONTEXT *  context,
wStream *  s,
RFX_TILE *  tile 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setupWorkers()

static BOOL setupWorkers ( RFX_CONTEXT *  context,
int  nbTiles 
)
static
Here is the caller graph for this function:

Variable Documentation

◆ rfx_default_quantization_values

const UINT32 rfx_default_quantization_values[] = { 6, 6, 6, 6, 7, 7, 8, 8, 8, 9 }
static

The quantization values control the compression rate and quality. The value range is between 6 and 15. The higher value, the higher compression rate and lower quality.

This is the default values being use by the MS RDP server, and we will also use it as our default values for the encoder. It can be overrided by setting the context->num_quants and context->quants member.

The order of the values are: LL3, LH3, HL3, HH3, LH2, HL2, HH2, LH1, HL1, HH1