[primitives,codec] guard NEON code with platform

NEON optimized code might be used in multiarch/universal builds.
So not only guard with WITH_NEON but also with architecture defines from
winpr/platform.h
This commit is contained in:
akallabeth 2024-06-25 10:00:41 +02:00
parent 896ea3c445
commit 8020efcd0b
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
6 changed files with 36 additions and 20 deletions

View File

@ -18,6 +18,7 @@
* limitations under the License.
*/
#include <winpr/platform.h>
#include <winpr/sysinfo.h>
#include <freerdp/config.h>
#include <freerdp/log.h>
@ -27,9 +28,15 @@
#define TAG FREERDP_TAG("codec.nsc.neon")
#if defined(WITH_NEON)
#if defined(_M_ARM64) || defined(_M_ARM)
#define NEON_ENABLED
#endif
#endif
void nsc_init_neon(NSC_CONTEXT* context)
{
#if defined(WITH_NEON)
#if defined(NEON_ENABLED)
if (!IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
return;

View File

@ -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.rfx.neon")
#if defined(WITH_NEON)
#if defined(_M_ARM64) || defined(_M_ARM)
#define NEON_ENABLED
#endif
#endif
#if defined(NEON_ENABLED)
#include <stdio.h>
#include <stdlib.h>
@ -520,11 +527,11 @@ static void rfx_dwt_2d_extrapolate_decode_neon(INT16* buffer, INT16* temp)
rfx_dwt_2d_decode_extrapolate_block_neon(&buffer[3007], temp, 2);
rfx_dwt_2d_decode_extrapolate_block_neon(&buffer[0], temp, 1);
}
#endif // WITH_NEON
#endif // NEON_ENABLED
void rfx_init_neon(RFX_CONTEXT* context)
{
#if defined(WITH_NEON)
#if defined(NEON_ENABLED)
if (IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
{
DEBUG_RFX("Using NEON optimizations");

View File

@ -23,15 +23,13 @@
#include <freerdp/primitives.h>
#include <winpr/sysinfo.h>
#if defined(WITH_NEON)
#include <arm_neon.h>
#endif
#include "prim_internal.h"
#include "prim_templates.h"
#include "prim_YCoCg.h"
#if defined(WITH_NEON)
#if defined(NEON_ENABLED)
#include <arm_neon.h>
static primitives_t* generic = NULL;
static pstatus_t neon_YCoCgToRGB_8u_X(const BYTE* WINPR_RESTRICT pSrc, INT32 srcStep,
@ -159,7 +157,7 @@ static pstatus_t neon_YCoCgToRGB_8u_AC4R(const BYTE* WINPR_RESTRICT pSrc, INT32
/* ------------------------------------------------------------------------- */
void primitives_init_YCoCg_neon(primitives_t* WINPR_RESTRICT prims)
{
#if defined(WITH_NEON)
#if defined(NEON_ENABLED)
generic = primitives_get_generic();
primitives_init_YCoCg(prims);

View File

@ -30,7 +30,7 @@
#include "prim_internal.h"
#include "prim_YUV.h"
#if defined(WITH_NEON)
#if defined(NEON_ENABLED)
#include <arm_neon.h>
static primitives_t* generic = NULL;
@ -744,7 +744,7 @@ static pstatus_t neon_YUV420CombineToYUV444(avc444_frame_type type,
void primitives_init_YUV_neon(primitives_t* prims)
{
#if defined(WITH_NEON)
#if defined(NEON_ENABLED)
generic = primitives_get_generic();
primitives_init_YUV(prims);

View File

@ -23,16 +23,14 @@
#include <freerdp/primitives.h>
#include <winpr/sysinfo.h>
#if defined(WITH_NEON)
#include <arm_neon.h>
#endif
#include "prim_internal.h"
#include "prim_templates.h"
#include "prim_colors.h"
/*---------------------------------------------------------------------------*/
#ifdef WITH_NEON
#if defined(NEON_ENABLED)
#include <arm_neon.h>
static primitives_t* generic = NULL;
static pstatus_t
@ -344,12 +342,12 @@ neon_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_NEON */
#endif /* NEON_ENABLED */
/* ------------------------------------------------------------------------- */
void primitives_init_colors_neon(primitives_t* prims)
{
#if defined(WITH_NEON)
#if defined(NEON_ENABLED)
generic = primitives_get_generic();
primitives_init_colors(prims);

View File

@ -40,11 +40,17 @@
#endif
#endif
#if defined(SSE2_ENABLED) || defined(WITH_NEON) || defined(WITH_OPENCL)
#if defined(WITH_NEON)
#if defined(_M_ARM64) || defined(_M_ARM)
#define NEON_ENABLED
#endif
#endif
#if defined(SSE2_ENABLED) || defined(NEON_ENABLED) || defined(WITH_OPENCL)
#define HAVE_OPTIMIZED_PRIMITIVES 1
#endif
#if defined(SSE2_ENABLED) || defined(WITH_NEON)
#if defined(SSE2_ENABLED) || defined(NEON_ENABLED)
#define HAVE_CPU_OPTIMIZED_PRIMITIVES 1
#endif