codec/rfx: use sysinfo to detect sse2/neon
This also moves (sse2) detection code out of the client into the decoder.
This commit is contained in:
parent
bf7f7f0f60
commit
23a7ef6c47
@ -762,46 +762,6 @@ BOOL xf_pre_connect(freerdp* instance)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void cpuid(unsigned info, unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
__asm volatile
|
||||
(
|
||||
/* The EBX (or RBX register on x86_64) is used for the PIC base address
|
||||
and must not be corrupted by our inline assembly. */
|
||||
#if defined(__i386__)
|
||||
"mov %%ebx, %%esi;"
|
||||
"cpuid;"
|
||||
"xchg %%ebx, %%esi;"
|
||||
#else
|
||||
"mov %%rbx, %%rsi;"
|
||||
"cpuid;"
|
||||
"xchg %%rbx, %%rsi;"
|
||||
#endif
|
||||
: "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
|
||||
: "0" (info)
|
||||
);
|
||||
#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_MSG("SSE2 detected");
|
||||
cpu_opt |= CPU_SSE2;
|
||||
}
|
||||
|
||||
return cpu_opt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback given to freerdp_connect() to perform post-connection operations.
|
||||
* It will be called only if the connection was initialized properly, and will continue the initialization based on the
|
||||
@ -809,9 +769,6 @@ UINT32 xf_detect_cpu()
|
||||
*/
|
||||
BOOL xf_post_connect(freerdp* instance)
|
||||
{
|
||||
#ifdef WITH_SSE2
|
||||
UINT32 cpu;
|
||||
#endif
|
||||
xfInfo* xfi;
|
||||
XGCValues gcv;
|
||||
rdpCache* cache;
|
||||
@ -866,15 +823,6 @@ BOOL xf_post_connect(freerdp* instance)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
/* detect only if needed */
|
||||
cpu = xf_detect_cpu();
|
||||
if (rfx_context)
|
||||
rfx_context_set_cpu_opt(rfx_context, cpu);
|
||||
if (nsc_context)
|
||||
nsc_context_set_cpu_opt(nsc_context, cpu);
|
||||
#endif
|
||||
|
||||
xfi->width = instance->settings->DesktopWidth;
|
||||
xfi->height = instance->settings->DesktopHeight;
|
||||
|
||||
|
@ -113,7 +113,6 @@ typedef struct _RFX_CONTEXT RFX_CONTEXT;
|
||||
|
||||
FREERDP_API RFX_CONTEXT* rfx_context_new(void);
|
||||
FREERDP_API void rfx_context_free(RFX_CONTEXT* context);
|
||||
FREERDP_API void rfx_context_set_cpu_opt(RFX_CONTEXT* context, UINT32 cpu_opt);
|
||||
FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, RDP_PIXEL_FORMAT pixel_format);
|
||||
FREERDP_API void rfx_context_reset(RFX_CONTEXT* context);
|
||||
|
||||
|
@ -238,13 +238,6 @@ RFX_CONTEXT* rfx_context_new(void)
|
||||
return context;
|
||||
}
|
||||
|
||||
void rfx_context_set_cpu_opt(RFX_CONTEXT* context, UINT32 cpu_opt)
|
||||
{
|
||||
/* enable SIMD CPU acceleration if detected */
|
||||
if (cpu_opt & CPU_SSE2)
|
||||
RFX_INIT_SIMD(context);
|
||||
}
|
||||
|
||||
void rfx_context_free(RFX_CONTEXT* context)
|
||||
{
|
||||
free(context->quants);
|
||||
|
@ -252,43 +252,9 @@ void rfx_dwt_2d_decode_NEON(INT16 * buffer, INT16 * dwt_buffer)
|
||||
rfx_dwt_2d_decode_block_NEON(buffer, dwt_buffer, 32);
|
||||
}
|
||||
|
||||
int isNeonSupported()
|
||||
{
|
||||
#if ANDROID
|
||||
if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM)
|
||||
{
|
||||
DEBUG_RFX("NEON optimization disabled - No ARM CPU found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT64 features = android_getCpuFeatures();
|
||||
|
||||
if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7))
|
||||
{
|
||||
if (features & ANDROID_CPU_ARM_FEATURE_NEON)
|
||||
{
|
||||
DEBUG_RFX("NEON optimization enabled!");
|
||||
return FALSE;
|
||||
}
|
||||
DEBUG_RFX("NEON optimization disabled - CPU not NEON capable");
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_RFX("NEON optimization disabled - No ARMv7 CPU found");
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#elif defined(__APPLE)
|
||||
/* assume NEON support on iOS devices */
|
||||
return TRUE;
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void rfx_init_neon(RFX_CONTEXT * context)
|
||||
{
|
||||
if (isNeonSupported())
|
||||
if (IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
|
||||
{
|
||||
DEBUG_RFX("Using NEON optimizations");
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <winpr/sysinfo.h>
|
||||
|
||||
#include <xmmintrin.h>
|
||||
#include <emmintrin.h>
|
||||
@ -490,6 +491,10 @@ static void rfx_dwt_2d_encode_sse2(INT16* buffer, INT16* dwt_buffer)
|
||||
|
||||
void rfx_init_sse2(RFX_CONTEXT* context)
|
||||
{
|
||||
|
||||
if (!IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
|
||||
return;
|
||||
|
||||
DEBUG_RFX("Using SSE2 optimizations");
|
||||
|
||||
IF_PROFILER(context->priv->prof_rfx_quantization_decode->name = "rfx_quantization_decode_sse2");
|
||||
|
Loading…
Reference in New Issue
Block a user