libfreerdp-codec: add support for android cpu-features module
This commit is contained in:
parent
a79e913e6d
commit
158030c57a
@ -61,9 +61,12 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
# Default to build shared libs
|
||||
if(NOT DEFINED BUILD_SHARED_LIBS)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
if(ANDROID)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
else()
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED EXPORT_ALL_SYMBOLS)
|
||||
|
@ -3,6 +3,8 @@ if((CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686|x86") AND (CMAKE_SIZEOF_VOID_P EQU
|
||||
set(TARGET_ARCH "x86")
|
||||
elseif((CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") AND (CMAKE_SIZEOF_VOID_P EQUAL 8))
|
||||
set(TARGET_ARCH "x64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm*")
|
||||
set(TARGET_ARCH "ARM")
|
||||
endif()
|
||||
|
||||
option(WITH_MANPAGES "Generate manpages." ON)
|
||||
@ -14,7 +16,11 @@ else()
|
||||
option(WITH_SSE2 "Enable SSE2 optimization." OFF)
|
||||
endif()
|
||||
|
||||
option(WITH_NEON "Enable NEON optimization." OFF)
|
||||
if((TARGET_ARCH MATCHES "ARM") AND (NOT DEFINED WITH_NEON))
|
||||
option(WITH_NEON "Enable NEON optimization." ON)
|
||||
else()
|
||||
option(WITH_NEON "Enable NEON optimization." OFF)
|
||||
endif()
|
||||
|
||||
option(WITH_JPEG "Use JPEG decoding." OFF)
|
||||
|
||||
@ -31,13 +37,18 @@ option(BUILD_TESTING "Build unit tests" OFF)
|
||||
option(WITH_SAMPLE "Build sample code" OFF)
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_GREATER 2.8.8)
|
||||
option(MONOLITHIC_BUILD "Use monolithic build" OFF)
|
||||
if(ANDROID)
|
||||
option(MONOLITHIC_BUILD "Use monolithic build" ON)
|
||||
else()
|
||||
option(MONOLITHIC_BUILD "Use monolithic build" OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(WITH_CLIENT "Build client binaries" ON)
|
||||
option(WITH_SERVER "Build server binaries" OFF)
|
||||
|
||||
option(STATIC_CHANNELS "Build channels statically" ON)
|
||||
|
||||
option(WITH_CHANNELS "Build virtual channel plugins" ON)
|
||||
|
||||
if(WITH_CLIENT AND WITH_CHANNELS)
|
||||
|
@ -61,17 +61,24 @@ if(WITH_SSE2)
|
||||
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_SSE2_SRCS})
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set_property(SOURCE rfx_sse2.c nsc_sse2.c PROPERTY COMPILE_FLAGS "-msse2")
|
||||
set_source_files_properties(${${MODULE_PREFIX}_SSE2_SRCS} PROPERTIES COMPILE_FLAGS "-msse2")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set_property(SOURCE rfx_sse2.c nsc_sse2.c PROPERTY COMPILE_FLAGS "/arch:SSE2")
|
||||
set_source_files_properties(${${MODULE_PREFIX}_SSE2_SRCS} PROPERTIES COMPILE_FLAGS "/arch:SSE2")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_NEON)
|
||||
if(ANDROID)
|
||||
set(ANDROID_CPU_FEATURES_PATH "${ANDROID_NDK}/sources/android/cpufeatures")
|
||||
include_directories(${ANDROID_CPU_FEATURES_PATH})
|
||||
set(${MODULE_PREFIX}_NEON_SRCS ${${MODULE_PREFIX}_NEON_SRCS}
|
||||
${ANDROID_CPU_FEATURES_PATH}/cpu-features.c
|
||||
${ANDROID_CPU_FEATURES_PATH}/cpu-features.h)
|
||||
endif()
|
||||
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_NEON_SRCS})
|
||||
set_property(SOURCE rfx_neon.c PROPERTY COMPILE_FLAGS "-mfpu=neon -mfloat-abi=softfp")
|
||||
set_source_files_properties(${${MODULE_PREFIX}_NEON_SRCS} PROPERTIES COMPILE_FLAGS "-mfpu=neon -mfloat-abi=softfp -Wno-unused-variable")
|
||||
endif()
|
||||
|
||||
if(WITH_JPEG)
|
||||
|
@ -31,28 +31,27 @@
|
||||
#include "rfx_types.h"
|
||||
#include "rfx_neon.h"
|
||||
|
||||
#if defined(ANDROID)
|
||||
#include <cpu-features.h>
|
||||
#if ANDROID
|
||||
#include "cpu-features.h"
|
||||
#endif
|
||||
|
||||
|
||||
void rfx_decode_YCbCr_to_RGB_NEON(INT16 * y_r_buffer, INT16 * cb_g_buffer, INT16 * cr_b_buffer)
|
||||
{
|
||||
int16x8_t zero = vdupq_n_s16(0);
|
||||
int16x8_t max = vdupq_n_s16(255);
|
||||
int16x8_t y_add = vdupq_n_s16(128);
|
||||
|
||||
int16x8_t* y_r_buf = (int16x8_t*)y_r_buffer;
|
||||
int16x8_t* cb_g_buf = (int16x8_t*)cb_g_buffer;
|
||||
int16x8_t* cr_b_buf = (int16x8_t*)cr_b_buffer;
|
||||
int16x8_t* y_r_buf = (int16x8_t*) y_r_buffer;
|
||||
int16x8_t* cb_g_buf = (int16x8_t*) cb_g_buffer;
|
||||
int16x8_t* cr_b_buf = (int16x8_t*) cr_b_buffer;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 4096 / 8; i++)
|
||||
{
|
||||
int16x8_t y = vld1q_s16((INT16*)&y_r_buf[i]);
|
||||
int16x8_t y = vld1q_s16((INT16*) &y_r_buf[i]);
|
||||
y = vaddq_s16(y, y_add);
|
||||
|
||||
int16x8_t cr = vld1q_s16((INT16*)&cr_b_buf[i]);
|
||||
int16x8_t cr = vld1q_s16((INT16*) &cr_b_buf[i]);
|
||||
|
||||
// r = between((y + cr + (cr >> 2) + (cr >> 3) + (cr >> 5)), 0, 255);
|
||||
int16x8_t r = vaddq_s16(y, cr);
|
||||
@ -295,50 +294,47 @@ rfx_dwt_2d_decode_block_NEON(INT16 * buffer, INT16 * idwt, int subband_width)
|
||||
rfx_dwt_2d_decode_block_vert_NEON(l_dst, h_dst, buffer, subband_width);
|
||||
}
|
||||
|
||||
void
|
||||
rfx_dwt_2d_decode_NEON(INT16 * buffer, INT16 * dwt_buffer)
|
||||
void rfx_dwt_2d_decode_NEON(INT16 * buffer, INT16 * dwt_buffer)
|
||||
{
|
||||
rfx_dwt_2d_decode_block_NEON(buffer + 3840, dwt_buffer, 8);
|
||||
rfx_dwt_2d_decode_block_NEON(buffer + 3072, dwt_buffer, 16);
|
||||
rfx_dwt_2d_decode_block_NEON(buffer, dwt_buffer, 32);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int isNeonSupported()
|
||||
{
|
||||
#if defined(ANDROID)
|
||||
#if ANDROID
|
||||
if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM)
|
||||
{
|
||||
DEBUG_RFX("NEON optimization disabled - No ARM CPU found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT64_t features = android_getCpuFeatures();
|
||||
UINT64 features = android_getCpuFeatures();
|
||||
|
||||
if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7))
|
||||
{
|
||||
if (features & ANDROID_CPU_ARM_FEATURE_NEON)
|
||||
{
|
||||
DEBUG_RFX("NEON optimization enabled!");
|
||||
return 1;
|
||||
return FALSE;
|
||||
}
|
||||
DEBUG_RFX("NEON optimization disabled - CPU not NEON capable");
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_RFX("NEON optimization disabled - No ARMv7 CPU found");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
#else
|
||||
return 1;
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void rfx_init_neon(RFX_CONTEXT * context)
|
||||
{
|
||||
|
||||
|
||||
if(isNeonSupported())
|
||||
if (isNeonSupported())
|
||||
{
|
||||
DEBUG_RFX("Using NEON optimizations");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user