Merge branch 'master' of github.com:FreeRDP/FreeRDP

This commit is contained in:
Marc-André Moreau 2011-10-25 02:46:33 -04:00
commit 6a3cc63290
17 changed files with 73 additions and 23 deletions

View File

@ -76,7 +76,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()
if(WITH_SSE2)
if(WITH_SSE2_TARGET)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
endif()
endif()

View File

@ -43,7 +43,7 @@ void xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
if (bitmap->data != NULL)
{
data = freerdp_image_convert(bitmap->data, NULL,
bitmap->width, bitmap->height, bitmap->bpp, xfi->bpp, xfi->clrconv);
bitmap->width, bitmap->height, xfi->srcBpp, xfi->bpp, xfi->clrconv);
if (bitmap->ephemeral != True)
{
@ -106,7 +106,7 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
{
uint16 size;
size = width * height * (bpp / 8);
size = width * height * (bpp + 7) / 8;
if (bitmap->data == NULL)
bitmap->data = (uint8*) xmalloc(size);

View File

@ -570,7 +570,7 @@ boolean xf_post_connect(freerdp* instance)
xfi->primary_buffer = (uint8*) xzalloc(xfi->width * xfi->height * xfi->bpp);
if (instance->settings->rfx_codec)
xfi->rfx_context = (void*) rfx_context_new();
xfi->rfx_context = (void*) rfx_context_new(instance->settings);
if (instance->settings->ns_codec)
xfi->nsc_context = (void*) nsc_context_new();
@ -675,6 +675,39 @@ boolean xf_verify_certificate(freerdp* instance, char* subject, char* issuer, ch
}
void cpuid(unsigned info, unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
{
#ifdef __GNUC__
#if defined(__i386__) || defined(__x86_64__)
*eax = info;
__asm volatile
("mov %%ebx, %%edi;" /* 32bit PIC: don't clobber ebx */
"cpuid;"
"mov %%ebx, %%esi;"
"mov %%edi, %%ebx;"
:"+a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
: :"edi");
#endif
#endif
}
uint32 xf_detect_cpu()
{
unsigned int eax, ebx, ecx, edx = 0;
uint32 cpu_opt = 0;
cpuid(1, &eax, &ebx, &ecx, &edx);
if (edx & (1<<26))
{
DEBUG("SSE2 detected");
cpu_opt |= CPU_SSE2;
}
return cpu_opt;
}
int xf_process_client_args(rdpSettings* settings, const char* opt, const char* val, void* user_data)
{
int argc = 0;
@ -971,6 +1004,11 @@ int main(int argc, char* argv[])
instance->context->argv = argv;
instance->settings->sw_gdi = False;
#ifdef WITH_SSE2
/* detect only if needed */
instance->settings->cpu_opt = xf_detect_cpu();
#endif
data = (struct thread_data*) xzalloc(sizeof(struct thread_data));
data->instance = instance;

View File

@ -12,6 +12,9 @@ option(WITH_DEBUG_RFX "Print RemoteFX debug messages." OFF)
option(WITH_DEBUG_X11 "Print X11 Client debug messages" OFF)
option(WITH_DEBUG_RAIL "Print RemoteApp debug messages" OFF)
option(WITH_DEBUG_XV "Print XVideo debug messages" OFF)
option(WITH_DEBUG_SCARD "Print smartcard debug messages" OFF)
option(WITH_DEBUG_ORDERS "Print drawing orders debug messages" OFF)
option(WITH_MANPAGES "Generate manpages." ON)
option(WITH_PROFILER "Compile profiler." OFF)
option(WITH_SSE2 "Use SSE2 optimization." OFF)
option(WITH_SSE2_TARGET "Allow compiler to generate SSE2 instructions." OFF)

View File

@ -31,9 +31,11 @@
#cmakedefine WITH_DEBUG_RFX
#cmakedefine WITH_PROFILER
#cmakedefine WITH_SSE2
#cmakedefine WITH_SSE2_TARGET
#cmakedefine WITH_DEBUG_X11
#cmakedefine WITH_DEBUG_RAIL
#cmakedefine WITH_DEBUG_XV
#cmakedefine WITH_DEBUG_SCARD
#cmakedefine WITH_DEBUG_ORDERS
#endif

View File

@ -267,7 +267,7 @@ void test_dwt(void)
{
RFX_CONTEXT* context;
context = rfx_context_new();
context = rfx_context_new(NULL);
rfx_dwt_2d_decode(buffer, context->priv->dwt_buffer);
//dump_buffer(buffer, 4096);
rfx_context_free(context);
@ -304,7 +304,7 @@ void test_decode(void)
stream_write(s, cr_data, sizeof(cr_data));
stream_set_pos(s, 0);
context = rfx_context_new();
context = rfx_context_new(NULL);
context->mode = RLGR3;
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
rfx_decode_rgb(context, s,
@ -334,7 +334,7 @@ void test_encode(void)
enc_stream = stream_new(65536);
stream_clear(enc_stream);
context = rfx_context_new();
context = rfx_context_new(NULL);
context->mode = RLGR3;
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
@ -378,7 +378,7 @@ void test_message(void)
s = stream_new(65536);
stream_clear(s);
context = rfx_context_new();
context = rfx_context_new(NULL);
context->mode = RLGR3;
context->width = 800;
context->height = 600;

View File

@ -125,7 +125,7 @@ struct _RFX_CONTEXT
};
typedef struct _RFX_CONTEXT RFX_CONTEXT;
FREERDP_API RFX_CONTEXT* rfx_context_new(void);
FREERDP_API RFX_CONTEXT* rfx_context_new(rdpSettings* settings);
FREERDP_API void rfx_context_free(RFX_CONTEXT* context);
FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, RFX_PIXEL_FORMAT pixel_format);
FREERDP_API void rfx_context_reset(RFX_CONTEXT* context);

View File

@ -90,6 +90,9 @@
#define GLYPH_SUPPORT_FULL 0x0002
#define GLYPH_SUPPORT_ENCODE 0x0003
/* CPU Optimization flags */
#define CPU_SSE2 0x1
/* SYSTEM_TIME */
typedef struct
{
@ -325,6 +328,8 @@ struct rdp_settings
boolean rail_langbar_supported;
boolean mouse_motion;
uint32 cpu_opt;
};
typedef struct rdp_settings rdpSettings;

View File

@ -46,6 +46,7 @@ if(WITH_SSE2)
rfx_sse2.c
rfx_sse2.h
)
set_property(SOURCE rfx_sse2.c PROPERTY COMPILE_FLAGS "-msse2")
endif()
add_library(freerdp-codec ${FREERDP_CODEC_SRCS})

View File

@ -97,7 +97,7 @@ uint32 freerdp_color_convert_rgb(uint32 srcColor, int srcBpp, int dstBpp, HCLRCO
case 32:
if (clrconv->alpha)
{
GetABGR32(alpha, red, green, blue, srcColor);
GetARGB32(alpha, red, green, blue, srcColor);
}
else
{
@ -108,10 +108,10 @@ uint32 freerdp_color_convert_rgb(uint32 srcColor, int srcBpp, int dstBpp, HCLRCO
GetBGR24(red, green, blue, srcColor);
break;
case 16:
GetRGB16(red, green, blue, srcColor);
GetBGR16(red, green, blue, srcColor);
break;
case 15:
GetRGB15(red, green, blue, srcColor);
GetBGR15(red, green, blue, srcColor);
break;
case 8:
srcColor &= 0xFF;
@ -133,7 +133,7 @@ uint32 freerdp_color_convert_rgb(uint32 srcColor, int srcBpp, int dstBpp, HCLRCO
switch (dstBpp)
{
case 32:
dstColor = ARGB32(alpha, red, green, blue);
dstColor = ABGR32(alpha, red, green, blue);
break;
case 24:
dstColor = BGR24(red, green, blue);
@ -372,7 +372,7 @@ uint8* freerdp_image_convert_15bpp(uint8* srcData, uint8* dstData, int width, in
{
pixel = *src16;
src16++;
GetBGR16(red, green, blue, pixel);
GetBGR15(red, green, blue, pixel);
pixel = BGR32(red, green, blue);
*dst32 = pixel;
dst32++;

View File

@ -128,7 +128,7 @@ static void rfx_profiler_print(RFX_CONTEXT* context)
PROFILER_PRINT_FOOTER;
}
RFX_CONTEXT* rfx_context_new(void)
RFX_CONTEXT* rfx_context_new(rdpSettings* settings)
{
RFX_CONTEXT* context;
@ -157,8 +157,9 @@ RFX_CONTEXT* rfx_context_new(void)
context->dwt_2d_decode = rfx_dwt_2d_decode;
context->dwt_2d_encode = rfx_dwt_2d_encode;
/* detect and enable SIMD CPU acceleration */
RFX_INIT_SIMD(context);
/* enable SIMD CPU acceleration if detected */
if (settings && settings->cpu_opt & CPU_SSE2)
RFX_INIT_SIMD(context);
return context;
}

View File

@ -45,7 +45,7 @@ void rfx_quantization_decode(sint16* buffer, const uint32* quantization_values)
rfx_quantization_decode_block(buffer + 3584, 256, quantization_values[6] - 6); /* HH2 */
rfx_quantization_decode_block(buffer + 3840, 64, quantization_values[2] - 6); /* HL3 */
rfx_quantization_decode_block(buffer + 3904, 64, quantization_values[1] - 6); /* LH3 */
rfx_quantization_decode_block(buffer + 3868, 64, quantization_values[3] - 6); /* HH3 */
rfx_quantization_decode_block(buffer + 3968, 64, quantization_values[3] - 6); /* HH3 */
rfx_quantization_decode_block(buffer + 4032, 64, quantization_values[0] - 6); /* LL3 */
}

View File

@ -249,7 +249,7 @@ static void rfx_quantization_decode_sse2(sint16* buffer, const uint32* quantizat
rfx_quantization_decode_block_sse2(buffer + 3584, 256, quantization_values[6] - 6); /* HH2 */
rfx_quantization_decode_block_sse2(buffer + 3840, 64, quantization_values[2] - 6); /* HL3 */
rfx_quantization_decode_block_sse2(buffer + 3904, 64, quantization_values[1] - 6); /* LH3 */
rfx_quantization_decode_block_sse2(buffer + 3868, 64, quantization_values[3] - 6); /* HH3 */
rfx_quantization_decode_block_sse2(buffer + 3968, 64, quantization_values[3] - 6); /* HH3 */
rfx_quantization_decode_block_sse2(buffer + 4032, 64, quantization_values[0] - 6); /* LL3 */
}

View File

@ -1054,7 +1054,7 @@ int gdi_init(freerdp* instance, uint32 flags, uint8* buffer)
gdi_register_graphics(instance->context->graphics);
gdi->rfx_context = rfx_context_new();
gdi->rfx_context = rfx_context_new(instance->settings);
gdi->nsc_context = nsc_context_new();
return 0;

View File

@ -83,7 +83,7 @@ void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
{
uint16 size;
size = width * height * (bpp / 8);
size = width * height * (bpp + 7) / 8;
if (bitmap->data == NULL)
bitmap->data = (uint8*) xmalloc(size);

View File

@ -121,7 +121,7 @@ void xf_peer_context_size(freerdp_peer* client, uint32* size)
void xf_peer_context_new(freerdp_peer* client, xfPeerContext* context)
{
context->info = xf_info_init();
context->rfx_context = rfx_context_new();
context->rfx_context = rfx_context_new(client->settings);
context->rfx_context->mode = RLGR3;
context->rfx_context->width = client->settings->width;
context->rfx_context->height = client->settings->height;

View File

@ -64,7 +64,7 @@ void test_peer_context_size(freerdp_peer* client, uint32* size)
void test_peer_context_new(freerdp_peer* client, testPeerContext* context)
{
context->rfx_context = rfx_context_new();
context->rfx_context = rfx_context_new(client->settings);
context->rfx_context->mode = RLGR3;
context->rfx_context->width = client->settings->width;
context->rfx_context->height = client->settings->height;