[primitives,codec] guard SSE code with platform
SSE optimized code might be used in multiarch/universal builds. So not only guard with WITH_SSE2 but also with architecture defines from winpr/platform.h
This commit is contained in:
parent
55258cd9eb
commit
896ea3c445
@ -17,6 +17,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <winpr/platform.h>
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
@ -26,6 +27,12 @@
|
||||
#define TAG FREERDP_TAG("codec.nsc.sse2")
|
||||
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined(_M_IX86_AMD64)
|
||||
#define SSE2_ENABLED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -381,7 +388,7 @@ static BOOL nsc_encode_sse2(NSC_CONTEXT* context, const BYTE* data, UINT32 scanl
|
||||
|
||||
void nsc_init_sse2(NSC_CONTEXT* context)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
if (!IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
|
||||
return;
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <winpr/platform.h>
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
@ -27,6 +28,12 @@
|
||||
#define TAG FREERDP_TAG("codec.rfx.sse2")
|
||||
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined(_M_IX86_AMD64)
|
||||
#define SSE2_ENABLED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -485,7 +492,7 @@ static void rfx_dwt_2d_encode_sse2(INT16* WINPR_RESTRICT buffer, INT16* WINPR_RE
|
||||
|
||||
void rfx_init_sse2(RFX_CONTEXT* context)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
if (!IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
|
||||
return;
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#ifndef FREERDP_LIB_PRIM_INTERNAL_H
|
||||
#define FREERDP_LIB_PRIM_INTERNAL_H
|
||||
|
||||
#include <winpr/platform.h>
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <freerdp/primitives.h>
|
||||
@ -33,15 +34,21 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(WITH_SSE2) || defined(WITH_NEON) || defined(WITH_OPENCL)
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined(_M_IX86_AMD64)
|
||||
#define SSE2_ENABLED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SSE2_ENABLED) || defined(WITH_NEON) || defined(WITH_OPENCL)
|
||||
#define HAVE_OPTIMIZED_PRIMITIVES 1
|
||||
#endif
|
||||
|
||||
#if defined(WITH_SSE2) || defined(WITH_NEON)
|
||||
#if defined(SSE2_ENABLED) || defined(WITH_NEON)
|
||||
#define HAVE_CPU_OPTIMIZED_PRIMITIVES 1
|
||||
#endif
|
||||
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
/* Use lddqu for unaligned; load for 16-byte aligned. */
|
||||
#define LOAD_SI128(_ptr_) \
|
||||
(((const ULONG_PTR)(_ptr_)&0x0f) ? _mm_lddqu_si128((const __m128i*)(_ptr_)) \
|
||||
|
@ -25,15 +25,13 @@
|
||||
|
||||
#include "prim_YCoCg.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#include <emmintrin.h>
|
||||
#include <tmmintrin.h>
|
||||
#endif
|
||||
|
||||
#include "prim_internal.h"
|
||||
#include "prim_templates.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
#include <tmmintrin.h>
|
||||
|
||||
static primitives_t* generic = NULL;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -436,12 +434,12 @@ static pstatus_t ssse3_YCoCgRToRGB_8u_AC4R(const BYTE* WINPR_RESTRICT pSrc, INT3
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* WITH_SSE2 */
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
void primitives_init_YCoCg_ssse3(primitives_t* WINPR_RESTRICT prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
generic = primitives_get_generic();
|
||||
primitives_init_YCoCg(prims);
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "prim_internal.h"
|
||||
#include "prim_YUV.h"
|
||||
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
#include <tmmintrin.h>
|
||||
|
||||
@ -1498,7 +1498,7 @@ static pstatus_t ssse3_YUV420CombineToYUV444(avc444_frame_type type,
|
||||
|
||||
void primitives_init_YUV_ssse3(primitives_t* WINPR_RESTRICT prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
generic = primitives_get_generic();
|
||||
primitives_init_YUV(prims);
|
||||
|
||||
|
@ -22,15 +22,13 @@
|
||||
|
||||
#include "prim_add.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#include <emmintrin.h>
|
||||
#include <pmmintrin.h>
|
||||
#endif /* WITH_SSE2 */
|
||||
|
||||
#include "prim_internal.h"
|
||||
#include "prim_templates.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
#include <pmmintrin.h>
|
||||
|
||||
static primitives_t* generic = NULL;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -172,13 +170,12 @@ static pstatus_t sse3_add_16s_inplace(INT16* WINPR_RESTRICT pSrcDst1,
|
||||
|
||||
return PRIMITIVES_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
void primitives_init_add_sse3(primitives_t* WINPR_RESTRICT prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
generic = primitives_get_generic();
|
||||
primitives_init_add(prims);
|
||||
|
||||
|
@ -28,15 +28,13 @@
|
||||
|
||||
#include "prim_alphaComp.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#include <emmintrin.h>
|
||||
#include <pmmintrin.h>
|
||||
#endif /* WITH_SSE2 */
|
||||
|
||||
#include "prim_internal.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#ifdef WITH_SSE2
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
#include <pmmintrin.h>
|
||||
|
||||
static primitives_t* generic = NULL;
|
||||
|
||||
static pstatus_t sse2_alphaComp_argb(const BYTE* WINPR_RESTRICT pSrc1, UINT32 src1Step,
|
||||
@ -211,7 +209,7 @@ static pstatus_t sse2_alphaComp_argb(const BYTE* WINPR_RESTRICT pSrc1, UINT32 sr
|
||||
/* ------------------------------------------------------------------------- */
|
||||
void primitives_init_alphaComp_sse3(primitives_t* WINPR_RESTRICT prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
generic = primitives_get_generic();
|
||||
primitives_init_alphaComp(prims);
|
||||
|
||||
|
@ -21,27 +21,26 @@
|
||||
|
||||
#include "prim_andor.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#include <emmintrin.h>
|
||||
#include <pmmintrin.h>
|
||||
#endif /* WITH_SSE2 */
|
||||
|
||||
#include "prim_internal.h"
|
||||
#include "prim_templates.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
#include <pmmintrin.h>
|
||||
|
||||
static primitives_t* generic = NULL;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
SSE3_SCD_PRE_ROUTINE(sse3_andC_32u, UINT32, generic->andC_32u, _mm_and_si128,
|
||||
*dptr++ = *sptr++ & val)
|
||||
SSE3_SCD_PRE_ROUTINE(sse3_orC_32u, UINT32, generic->orC_32u, _mm_or_si128, *dptr++ = *sptr++ | val)
|
||||
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
void primitives_init_andor_sse3(primitives_t* WINPR_RESTRICT prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
generic = primitives_get_generic();
|
||||
primitives_init_andor(prims);
|
||||
|
||||
|
@ -25,14 +25,12 @@
|
||||
|
||||
#include "prim_colors.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#include <emmintrin.h>
|
||||
#endif /* WITH_SSE2 */
|
||||
|
||||
#include "prim_internal.h"
|
||||
#include "prim_templates.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
|
||||
static primitives_t* generic = NULL;
|
||||
|
||||
#ifdef __GNUC__
|
||||
@ -1243,11 +1241,11 @@ sse2_RGBToRGB_16s8u_P3AC4R(const INT16* const WINPR_RESTRICT pSrc[3], /* 16-bit
|
||||
return generic->RGBToRGB_16s8u_P3AC4R(pSrc, srcStep, pDst, dstStep, DstFormat, roi);
|
||||
}
|
||||
}
|
||||
#endif /* WITH_SSE2 */
|
||||
#endif
|
||||
|
||||
void primitives_init_colors_sse2(primitives_t* prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
generic = primitives_get_generic();
|
||||
primitives_init_colors(prims);
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#define TAG FREERDP_TAG("primitives.copy")
|
||||
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
#include <immintrin.h>
|
||||
|
||||
@ -265,13 +265,12 @@ static pstatus_t avx2_image_copy_no_overlap(BYTE* WINPR_RESTRICT pDstData, DWORD
|
||||
nXSrc, nYSrc, palette, srcVMultiplier, srcVOffset,
|
||||
dstVMultiplier, dstVOffset);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
void primitives_init_copy_avx2(primitives_t* prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
if (IsProcessorFeaturePresent(PF_AVX2_INSTRUCTIONS_AVAILABLE))
|
||||
{
|
||||
WLog_VRB(PRIM_TAG, "AVX2 optimizations");
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#define TAG FREERDP_TAG("primitives.copy")
|
||||
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
#include <immintrin.h>
|
||||
|
||||
@ -264,13 +264,12 @@ static pstatus_t sse_image_copy_no_overlap(BYTE* WINPR_RESTRICT pDstData, DWORD
|
||||
nXSrc, nYSrc, palette, srcVMultiplier, srcVOffset,
|
||||
dstVMultiplier, dstVOffset);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
void primitives_init_copy_sse41(primitives_t* prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
if (IsProcessorFeaturePresent(PF_SSE4_1_INSTRUCTIONS_AVAILABLE))
|
||||
{
|
||||
WLog_VRB(PRIM_TAG, "SSE4.1 optimizations");
|
||||
|
@ -21,15 +21,13 @@
|
||||
#include <freerdp/primitives.h>
|
||||
#include <winpr/sysinfo.h>
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#include <emmintrin.h>
|
||||
#endif /* WITH_SSE2 */
|
||||
|
||||
#include "prim_internal.h"
|
||||
#include "prim_set.h"
|
||||
|
||||
/* ========================================================================= */
|
||||
#ifdef WITH_SSE2
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
|
||||
static primitives_t* generic = NULL;
|
||||
|
||||
static pstatus_t sse2_set_8u(BYTE val, BYTE* WINPR_RESTRICT pDst, UINT32 len)
|
||||
@ -113,10 +111,8 @@ static pstatus_t sse2_set_8u(BYTE val, BYTE* WINPR_RESTRICT pDst, UINT32 len)
|
||||
|
||||
return PRIMITIVES_SUCCESS;
|
||||
}
|
||||
#endif /* WITH_SSE2 */
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#ifdef WITH_SSE2
|
||||
static pstatus_t sse2_set_32u(UINT32 val, UINT32* WINPR_RESTRICT pDst, UINT32 len)
|
||||
{
|
||||
const primitives_t* prim = primitives_get_generic();
|
||||
@ -214,12 +210,12 @@ static pstatus_t sse2_set_32s(INT32 val, INT32* WINPR_RESTRICT pDst, UINT32 len)
|
||||
UINT32 uval = *((UINT32*)&val);
|
||||
return sse2_set_32u(uval, (UINT32*)pDst, len);
|
||||
}
|
||||
#endif /* WITH_SSE2 */
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
void primitives_init_set_sse2(primitives_t* WINPR_RESTRICT prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
generic = primitives_get_generic();
|
||||
primitives_init_set(prims);
|
||||
/* Pick tuned versions if possible. */
|
||||
|
@ -21,15 +21,13 @@
|
||||
|
||||
#include "prim_shift.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#include <emmintrin.h>
|
||||
#include <pmmintrin.h>
|
||||
#endif /* WITH_SSE2 */
|
||||
|
||||
#include "prim_internal.h"
|
||||
#include "prim_templates.h"
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
#include <pmmintrin.h>
|
||||
|
||||
static primitives_t* generic = NULL;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -135,7 +133,6 @@ static pstatus_t sse2_lShiftC_16s_inplace(INT16* WINPR_RESTRICT pSrcDst, UINT32
|
||||
|
||||
return PRIMITIVES_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Note: the IPP version will have to call ippLShiftC_16s or ippRShiftC_16s
|
||||
@ -146,7 +143,7 @@ static pstatus_t sse2_lShiftC_16s_inplace(INT16* WINPR_RESTRICT pSrcDst, UINT32
|
||||
/* ------------------------------------------------------------------------- */
|
||||
void primitives_init_shift_sse3(primitives_t* WINPR_RESTRICT prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
generic = primitives_get_generic();
|
||||
primitives_init_shift(prims);
|
||||
|
||||
|
@ -21,14 +21,12 @@
|
||||
|
||||
#include "prim_sign.h"
|
||||
|
||||
#if defined(WITH_SSE2)
|
||||
#include <emmintrin.h>
|
||||
#include <tmmintrin.h>
|
||||
#endif
|
||||
|
||||
#include "prim_internal.h"
|
||||
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
#include <emmintrin.h>
|
||||
#include <tmmintrin.h>
|
||||
|
||||
static primitives_t* generic = NULL;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -166,12 +164,13 @@ static pstatus_t ssse3_sign_16s(const INT16* WINPR_RESTRICT pSrc, INT16* WINPR_R
|
||||
|
||||
return PRIMITIVES_SUCCESS;
|
||||
}
|
||||
#endif /* WITH_SSE2 */
|
||||
|
||||
#endif /* SSE2_ENABLED */
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
void primitives_init_sign_ssse3(primitives_t* WINPR_RESTRICT prims)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
#if defined(SSE2_ENABLED)
|
||||
generic = primitives_get_generic();
|
||||
primitives_init_sign(prims);
|
||||
/* Pick tuned versions if possible. */
|
||||
|
@ -94,9 +94,10 @@ WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
|
||||
|
||||
/* Intel x86 (_M_IX86) */
|
||||
|
||||
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || \
|
||||
defined(__i586__) || defined(__i686__) || defined(__X86__) || defined(_X86_) || \
|
||||
defined(__I86__) || defined(__IA32__) || defined(__THW_INTEL__) || defined(__INTEL__)
|
||||
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || \
|
||||
defined(__i586__) || defined(__i686__) || defined(__X86__) || defined(_X86_) || \
|
||||
defined(__I86__) || defined(__IA32__) || defined(__THW_INTEL__) || defined(__INTEL__) || \
|
||||
defined(_M_IX86)
|
||||
#ifndef _M_IX86
|
||||
#define _M_IX86 1
|
||||
#endif
|
||||
@ -111,6 +112,13 @@ WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Intel ia64 */
|
||||
#if defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
||||
#ifndef _M_IA64
|
||||
#define _M_IA64 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Intel x86 or AMD64 (_M_IX86_AMD64) */
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_AMD64)
|
||||
|
Loading…
Reference in New Issue
Block a user