FreeRDP
rfx.c File Reference
#include <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)   do { } while (0)
 
#define RFX_KEY
 
#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 voidrfx_decoder_tile_new (void *val)
 
static void rfx_decoder_tile_free (void *obj)
 
static voidrfx_encoder_tile_new (void *val)
 
static void rfx_encoder_tile_free (void *obj)
 
RFX_CONTEXT * rfx_context_new (BOOL encoder)
 
void rfx_context_free (RFX_CONTEXT *context)
 
static RFX_TILE * rfx_message_get_tile (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)
 
BOOL setupWorkers (RFX_CONTEXT *context, int nbTiles)
 
RFX_MESSAGE * rfx_encode_message (RFX_CONTEXT *context, const RFX_RECT *rects, int numRects, BYTE *data, int width, int height, int scanline)
 
RFX_MESSAGE * rfx_split_message (RFX_CONTEXT *context, RFX_MESSAGE *message, int *numMessages, int maxDataSize)
 
RFX_MESSAGE * rfx_encode_messages (RFX_CONTEXT *context, const RFX_RECT *rects, int numRects, BYTE *data, int width, int height, int scanline, int *numMessages, int maxDataSize)
 
static BOOL rfx_write_message_tileset (RFX_CONTEXT *context, wStream *s, RFX_MESSAGE *message)
 
static BOOL rfx_write_message_frame_begin (RFX_CONTEXT *context, wStream *s, RFX_MESSAGE *message)
 
static BOOL rfx_write_message_region (RFX_CONTEXT *context, wStream *s, RFX_MESSAGE *message)
 
BOOL rfx_write_message_frame_end (RFX_CONTEXT *context, wStream *s, RFX_MESSAGE *message)
 
BOOL rfx_write_message (RFX_CONTEXT *context, wStream *s, RFX_MESSAGE *message)
 
BOOL rfx_compose_message (RFX_CONTEXT *context, wStream *s, const RFX_RECT *rects, int numRects, BYTE *data, int width, int height, int scanline)
 

Variables

static const UINT32 rfx_default_quantization_values []
 

Macro Definition Documentation

#define RFX_INIT_SIMD (   _rfx_context)    do { } while (0)
#define RFX_KEY
Value:
"Software\\"FREERDP_VENDOR_STRING"\\" \
FREERDP_PRODUCT_STRING"\\RemoteFX"
#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.

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

Function Documentation

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:

BOOL rfx_compose_message ( RFX_CONTEXT *  context,
wStream *  s,
const RFX_RECT *  rects,
int  numRects,
BYTE data,
int  width,
int  height,
int  scanline 
)

Here is the call graph for this function:

Here is the caller graph for this function:

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:

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:

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* rfx_context_new ( BOOL  encoder)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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:

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:

static void* rfx_decoder_tile_new ( void val)
static

Here is the call graph for this function:

Here is the caller graph for this function:

RFX_MESSAGE* rfx_encode_message ( RFX_CONTEXT *  context,
const RFX_RECT *  rects,
int  numRects,
BYTE data,
int  width,
int  height,
int  scanline 
)

Here is the call graph for this function:

Here is the caller graph for this function:

RFX_MESSAGE* rfx_encode_messages ( RFX_CONTEXT *  context,
const RFX_RECT *  rects,
int  numRects,
BYTE data,
int  width,
int  height,
int  scanline,
int *  numMessages,
int  maxDataSize 
)

Here is the call graph for this function:

Here is the caller graph for this function:

static void rfx_encoder_tile_free ( void obj)
static

Here is the caller graph for this function:

static void* rfx_encoder_tile_new ( void val)
static

Here is the caller graph for this function:

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:

static RFX_RECT* rfx_message_get_rect ( RFX_MESSAGE *  message,
UINT32  index 
)
static

Here is the caller graph for this function:

UINT16 rfx_message_get_rect_count ( RFX_MESSAGE *  message)
static RFX_TILE* rfx_message_get_tile ( RFX_MESSAGE *  message,
UINT32  index 
)
static

Here is the caller graph for this function:

UINT16 rfx_message_get_tile_count ( RFX_MESSAGE *  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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

static void rfx_profiler_create ( RFX_CONTEXT *  context)
static

Here is the caller graph for this function:

static void rfx_profiler_free ( RFX_CONTEXT *  context)
static

Here is the caller graph for this function:

static void rfx_profiler_print ( RFX_CONTEXT *  context)
static

Here is the caller graph for this function:

RFX_MESSAGE* rfx_split_message ( RFX_CONTEXT *  context,
RFX_MESSAGE *  message,
int *  numMessages,
int  maxDataSize 
)

Here is the call graph for this function:

Here is the caller graph for this function:

static void rfx_tile_init ( void obj)
static

Here is the caller graph for this function:

static int rfx_tile_length ( RFX_TILE *  tile)
static

Here is the caller graph for this function:

static void rfx_update_context_properties ( RFX_CONTEXT *  context)
static

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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:

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:

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:

static BOOL rfx_write_message_frame_begin ( RFX_CONTEXT *  context,
wStream *  s,
RFX_MESSAGE *  message 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL rfx_write_message_frame_end ( RFX_CONTEXT *  context,
wStream *  s,
RFX_MESSAGE *  message 
)

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL rfx_write_message_region ( RFX_CONTEXT *  context,
wStream *  s,
RFX_MESSAGE *  message 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

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:

static BOOL rfx_write_message_tileset ( RFX_CONTEXT *  context,
wStream *  s,
RFX_MESSAGE *  message 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

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:

BOOL setupWorkers ( RFX_CONTEXT *  context,
int  nbTiles 
)

Here is the caller graph for this function:

Variable Documentation

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

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