Esempio n. 1
0
jboolean jni_nativetester_is_neon(JNIEnv *env, jobject thiz) {
#ifdef FEATURE_NEON
	uint64_t features;
	if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM) {
		LOGI(5, "Not an ARM CPU\n");
		return JNI_FALSE;
	}

	features = android_getCpuFeatures();

	if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7) == 0) {
		LOGI(5, "Not an ARMv7 CPU\n");
		return JNI_FALSE;
	}

	if ((features & ANDROID_CPU_ARM_FEATURE_NEON) == 0) {
		LOGI(5, "CPU doesn't support NEON\n");
		return JNI_FALSE;
	}

	return JNI_TRUE;
#else
	return JNI_FALSE;
#endif
}
		bool neonSolverKernel(SwCloth const& cloth, SwClothData& data, 
			SwKernelAllocator& allocator, IterationStateFactory& factory, 
			PxProfileZone* profileZone)
		{
			return ANDROID_CPU_ARM_FEATURE_NEON & android_getCpuFeatures() &&
				(SwSolverKernel<Simd4f>(cloth, data, allocator, factory, profileZone)(), true);
		}
Esempio n. 3
0
static void runNEONTests()
{
	uint64_t features = android_getCpuFeatures();
	if ((features & ANDROID_CPU_ARM_FEATURE_NEON) == 0)
	{
		SCE_PFX_PRINTF("CPU has NO support for NEON.");
	}
	else
	{
		SCE_PFX_PRINTF("CPU HAS support for NEON.\n");

#ifdef __ARM_NEON__
#ifdef TEST_NEON_PERFORMANCE
		SCE_PFX_PRINTF("Running NEON performance tests...\n");

		TestNeonDotProduct();
		TestNeonCrossProduct();
		TestNeonMatrix3OperatorMultiply();
		TestNeonMatrix4OperatorMultiply();
		TestNeonOrthoInverseTransform3();
		TestNeonTransform3OperatorMultiply();
		TestNeonTransposeMatrix3();
		TestNeonSolveLinearConstraintRow();

		SCE_PFX_PRINTF("Finished NEON performance tests.");
#endif	// TEST_NEON_PERFORMANCE
#endif	// __ARM_NEON__
	}
}
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle,
        void *Context, void (*DebugCallback)(void *, int, const char *))
{
    ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath)	dlsym(CoreLibHandle, "ConfigGetSharedDataFilepath");
	CoreVideo_GL_SwapBuffers 	= (ptr_VidExt_GL_SwapBuffers) 		dlsym(CoreLibHandle, "VidExt_GL_SwapBuffers");
	CoreVideo_SetVideoMode 		= (ptr_VidExt_SetVideoMode)			dlsym(CoreLibHandle, "VidExt_SetVideoMode");
	CoreVideo_Quit 				= (ptr_VidExt_Quit)					dlsym(CoreLibHandle, "VidExt_Quit");
	CoreVideo_Init 				= (ptr_VidExt_Init)					dlsym(CoreLibHandle, "VidExt_Init");

#ifdef __NEON_OPT
    if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
            (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
    {
        MathInitNeon();
        gSPInitNeon();
    }
#endif
    ticksInitialize();

    //int max_frames = Android_JNI_GetMaxFrameSkip();
	//int max_frames = 1;
// TODO: get rid of this, it should be handled through the config file:
  //  if( Android_JNI_GetAutoFrameSkip() )
    //    frameSkipper.setSkips( FrameSkipper::AUTO, max_frames );
   // else
        //frameSkipper.setSkips( FrameSkipper::MANUAL, max_frames );
//
    return M64ERR_SUCCESS;
}
Esempio n. 5
0
int isNeonSupported()
{
#if defined(ANDROID)
    if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM)
    {
        DEBUG_RFX("NEON optimization disabled - No ARM CPU found");
        return 0;
    }

    uint64_t features = android_getCpuFeatures();
    if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7))
    {
        if (features & ANDROID_CPU_ARM_FEATURE_NEON)
        {
            DEBUG_RFX("NEON optimization enabled!");
            return 1;
        }
        DEBUG_RFX("NEON optimization disabled - CPU not NEON capable");
    }
    else
        DEBUG_RFX("NEON optimization disabled - No ARMv7 CPU found");

    return 0;
#else
    return 1;
#endif
}
Esempio n. 6
0
 AnrdoidNeonChecker()
 {
     if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
         _isNeonEnabled = true;
     else
         _isNeonEnabled = false;
 }
Esempio n. 7
0
jstring
Java_com_github_hiteshsondhi88_libffmpeg_ArmArchHelper_cpuArchFromJNI(JNIEnv* env, jobject obj)
{
	// Maximum we need to store here is ARM v7-neon
	// Which is 11 char long, so initializing a character array of length 11
	char arch_info[13] = "";

//	logI("ANDROID_CPU_FAMILY_ARM = %d",ANDROID_CPU_FAMILY_ARM);
//	logI("ANDROID_CPU_ARM_FEATURE_ARMv7 = %d",ANDROID_CPU_ARM_FEATURE_ARMv7);
//	logI("ANDROID_CPU_ARM_FEATURE_NEON = %d",ANDROID_CPU_ARM_FEATURE_NEON);
//	logI("android_getCpuFamily = %d",android_getCpuFamily());
//	logI("android_getCpuFeatures = %" PRIu64 "",android_getCpuFeatures());


	int cpu = android_getCpuFamily();
	// checking if CPU is of ARM family or not
	if (cpu == ANDROID_CPU_FAMILY_ARM) {
		strcpy(arch_info, "ARM");
	} else if (cpu == ANDROID_CPU_FAMILY_ARM64) {
		strcpy(arch_info, "ARM_64");
	}
	// checking if CPU is ARM v7 or not
	uint64_t cpuFeatures = android_getCpuFeatures();
	if ((cpuFeatures & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0) {
		strcat(arch_info, " v7");

		// checking if CPU is ARM v7 Neon
		if((cpuFeatures & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
			strcat(arch_info, "-neon");
		}
	}
	return (*env)->NewStringUTF(env, arch_info);
}
JNIEXPORT jboolean JNICALL Java_org_linphone_mediastream_Version_nativeHasNeon(JNIEnv *env, jclass c) {
	if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
	{
		return 1;
	}
	return 0;
}
int main(void)
{
    if (android_getRuntimeCpuFamily() != ANDROID_CPU_FAMILY_ARM) {
        printf("This is emulated ARM device, skip this test\n");
        return 0;
    }

    uint32_t cpu_id = android_getCpuIdArm();
    printf("cpu-features reports the following CPUID: 0x%08x\n",
           cpu_id);

    uint64_t features = android_getCpuFeatures();
#ifdef __thumb2__
    const uint64_t idiv_flag = ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2;
    const char* variant = "thumb";
#else
    const uint64_t idiv_flag = ANDROID_CPU_ARM_FEATURE_IDIV_ARM;
    const char* variant = "arm";
#endif

    printf("status of %s idiv instruction:\n", variant);
    int idiv_reported = (features & idiv_flag) != 0;
    printf("  reported      : %s\n",
           idiv_reported ? "supported" : "unsupported");

    int idiv_checked = check_idiv();
    printf("  runtime check : %s\n",
           idiv_checked ? "supported" : "unsupported");

    return (idiv_reported != idiv_checked);
}
Esempio n. 10
0
status_t FFRender::render(AVFrame* frame)
{
#if defined(__CYGWIN__) || defined(_MSC_VER)
    return render_sws(frame);
#elif defined(__ANDROID__)
#ifdef __arm__ // // android_arm implement
    if (mForceSW)
        return render_sws(frame);

    uint64_t cpuFeatures = android_getCpuFeatures();
    if ((cpuFeatures & ANDROID_CPU_ARM_FEATURE_NEON) != 0 &&
            (mFrameFormat == AV_PIX_FMT_YUV420P ||
             mFrameFormat == AV_PIX_FMT_NV12 ||
             mFrameFormat == AV_PIX_FMT_NV21))
    {
        return render_neon(frame);
    }
    else
    {
        return render_sws(frame);
    }
#elif defined(__aarch64__)
    if (mFrameFormat == AV_PIX_FMT_YUV420P)
        return render_neon(frame);
    else
        return render_sws(frame);
#else // android_x86 implement
    return render_sws(frame);
#endif
#else // ios implement
    return render_opengl(frame);
#endif
}
Esempio n. 11
0
static void
crypto_scrypt_smix_fn(uint8_t *B, size_t r, uint64_t N, void *_V, void *XY)
{
    if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON)
        crypto_scrypt_smix_neon(B, r, N, _V, XY);
    else
        crypto_scrypt_smix_c(B, r, N, _V, XY);
}
Esempio n. 12
0
 jboolean Java_ws_websca_benchscaw_MainActivity_getCpuArmVFPv3( JNIEnv* env,
         jobject thiz )
 {
     if(android_getCpuFamily()!=ANDROID_CPU_FAMILY_ARM)
         return JNI_FALSE;
     if ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_VFPv3) != 0)
         return JNI_TRUE;
     else
         return JNI_FALSE;
 }
Esempio n. 13
0
 jboolean Java_ws_websca_benchscaw_MainActivity_getCpuX86MOVBE( JNIEnv* env,
         jobject thiz )
 {
     if(android_getCpuFamily()!=ANDROID_CPU_FAMILY_X86)
         return JNI_FALSE;
     if ((android_getCpuFeatures() & ANDROID_CPU_X86_FEATURE_MOVBE) != 0)
         return JNI_TRUE;
     else
         return JNI_FALSE;
 }
JNIEXPORT jint JNICALL Java_com_vipercn_viper4android_1v2_activity_V4AJniInterface_CheckCPUHasNEON
(
	JNIEnv *env, jclass cls
)
{
	if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM) return (jint)0;
	uint64_t uiCPUFeatures = android_getCpuFeatures();
	if ((uiCPUFeatures & ANDROID_CPU_ARM_FEATURE_NEON) == 0) return (jint)0;
	return (jint)1;
}
Esempio n. 15
0
 static void init() {
     // TODO: Chrome's not linking _sse* opts on iOS simulator builds.  Bug or feature?
 #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS)
     uint32_t abcd[] = {0,0,0,0};
     cpuid(abcd);
     if (abcd[2] & (1<< 9)) { Init_ssse3(); }
     if (abcd[2] & (1<<19)) { Init_sse41(); }
 #elif !defined(SK_ARM_HAS_NEON) && defined(SK_CPU_ARM32) && defined(SK_BUILD_FOR_ANDROID)
     if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) { Init_neon(); }
 #endif
 }
/*
 * Function: cpuHasNeon
 * Purpose: Check if we have an ARM CPU with NEON instructions
 * Parameters: none
 * Returns: boolean: (true) if NEON is available, (false) otherwise
 * Exceptions: none
 */
static jboolean android_security_cts_EncryptionTest_cpuHasNeon(JNIEnv *, jobject)
{
    jboolean rc = false;
    AndroidCpuFamily family = android_getCpuFamily();

    if (family == ANDROID_CPU_FAMILY_ARM) {
        rc = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
    } else {
        rc = (family == ANDROID_CPU_FAMILY_ARM64);
    }

    ALOGE("EncryptionTest::cpuHasNeon: %d", rc);
    return rc;
}
/*
 * Function: cpuHasAes
 * Purpose: Check if we have an ARM CPU with AES instruction
 * Parameters: none
 * Returns: boolean: (true) if AES is available, (false) otherwise
 * Exceptions: none
 */
static jboolean android_security_cts_EncryptionTest_cpuHasAes(JNIEnv *, jobject)
{
    jboolean rc = false;
    AndroidCpuFamily family = android_getCpuFamily();
    uint64_t features = android_getCpuFeatures();

    if (family == ANDROID_CPU_FAMILY_ARM) {
        rc = (features & ANDROID_CPU_ARM_FEATURE_AES) != 0;
    } else if (family == ANDROID_CPU_FAMILY_ARM64) {
        rc = (features & ANDROID_CPU_ARM64_FEATURE_AES) != 0;
    }

    ALOGE("EncryptionTest::cpuHasAes: %d", rc);
    return rc;
}
Esempio n. 18
0
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle,
        void *Context, void (*DebugCallback)(void *, int, const char *))
{
    ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath)
            dlsym(CoreLibHandle, "ConfigGetSharedDataFilepath");

#ifdef __NEON_OPT
    if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
            (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
    {
        MathInitNeon();
        gSPInitNeon();
    }
#endif
    return M64ERR_SUCCESS;
}
Esempio n. 19
0
jstring Java_com_github_shadowsocks_system_getabi(JNIEnv *env, jobject thiz) {
  AndroidCpuFamily family = android_getCpuFamily();
  uint64_t features = android_getCpuFeatures();
  const char *abi;

  if (family == ANDROID_CPU_FAMILY_X86) {
    abi = "x86";
  } else if (family == ANDROID_CPU_FAMILY_MIPS) {
    abi = "mips";
  } else if (family == ANDROID_CPU_FAMILY_ARM) {
    if (features & ANDROID_CPU_ARM_FEATURE_ARMv7) {
      abi = "armeabi-v7a";
    } else {
      abi = "armeabi";
    }
  }
  return env->NewStringUTF(abi);
}
Esempio n. 20
0
jstring Java_com_proxy_shadowsocksr_Jni_getABI
        (JNIEnv *env, jobject thiz) {
    AndroidCpuFamily family = android_getCpuFamily();
    uint64_t features = android_getCpuFeatures();
    const char *abi;

    if (family == ANDROID_CPU_FAMILY_X86) {
        abi = "x86";
    } else if (family == ANDROID_CPU_FAMILY_MIPS) {
        abi = "mips";
    } else if (family == ANDROID_CPU_FAMILY_ARM) {
        abi = "armeabi-v7a";
    } else if (family == ANDROID_CPU_FAMILY_ARM64) {
        abi = "arm64-v8a";
    } else if (family == ANDROID_CPU_FAMILY_X86_64) {
        abi = "x86_64";
    }
    return env->NewStringUTF(abi);
}
Esempio n. 21
0
jint JNI_NOARGS(getCPUType)
{
	AndroidCpuFamily cpuFamily = android_getCpuFamily();
	uint64_t cpuFeatures = android_getCpuFeatures();
	if (cpuFamily == ANDROID_CPU_FAMILY_ARM &&
        (cpuFeatures & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
    {
		return CPUTYPE_NEON;
    }
	else if (cpuFamily == ANDROID_CPU_FAMILY_ARM &&
        (cpuFeatures & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0)
	{
		return CPUTYPE_V7;
	}
    else
    {
        return CPUTYPE_COMPAT;
    }
}
Esempio n. 22
0
	DeviceInfo::DeviceInfo()
	{
#if ALICE_SUPPORT_SSE
		int data[4] = { 0 };

		// Add more code here to extract vendor string or what ever is needed
		__cpuid(data, 0);
		if (data[0] >= 1) {
			__cpuid(data, 1);
			m_CPUIDFeatures = data[3];
		}

		m_IsSSESupported = (m_CPUIDFeatures & CPUID_FEATURES_SSE) != 0;
		m_IsSSE2Supported = (m_CPUIDFeatures & CPUID_FEATURES_SSE2) != 0;
#elif ALICE_ANDROID && ALICE_SUPPORTS_NEON
		m_CPUIDFeatures = android_getCpuFeatures();
		m_IsNEONSupported = (m_CPUIDFeatures & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
#endif
		m_Initialized = true;
	}
Esempio n. 23
0
static void resample_init(MSFilter *obj){
#ifdef SPEEX_LIB_SET_CPU_FEATURES
	int cpuFeatures = 0;
#ifdef __arm__
	#ifdef ANDROID
	if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM 
		&& (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
		cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
	}
	#elif defined(__ARM_NEON__)
	cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
	#endif
	ms_message("speex_lib_ctl init with neon ? %d", (cpuFeatures == SPEEX_LIB_CPU_FEATURE_NEON));
#endif
	speex_lib_ctl(SPEEX_LIB_SET_CPU_FEATURES, &cpuFeatures);
#else
	ms_message("speex_lib_ctl does not support SPEEX_LIB_CPU_FEATURE_NEON");
#endif
	obj->data=resample_data_new();
}
Esempio n. 24
0
static void discover_cpu_family(void) {
    LOG("Discovering CPU family...");

    AndroidCpuFamily family = android_getCpuFamily();
    uint64_t features = android_getCpuFeatures();
    if (family == ANDROID_CPU_FAMILY_X86) {
        if (features & ANDROID_CPU_X86_FEATURE_SSSE3) {
            LOG("nANDROID_CPU_X86_FEATURE_SSSE3");
            android_x86SSSE3Enabled = true;
        }
        if (features & ANDROID_CPU_X86_FEATURE_MOVBE) {
            LOG("ANDROID_CPU_X86_FEATURE_MOVBE");
        }
        if (features & ANDROID_CPU_X86_FEATURE_POPCNT) {
            LOG("ANDROID_CPU_X86_FEATURE_POPCNT");
        }
    } else if (family == ANDROID_CPU_FAMILY_ARM) {
        if (features & ANDROID_CPU_ARM_FEATURE_ARMv7) {
            LOG("ANDROID_CPU_ARM_FEATURE_ARMv7");
            android_armArchV7A = true;
        } else {
            LOG("!!! NOT ANDROID_CPU_ARM_FEATURE_ARMv7");
            android_armArch = true;
        }

        if (features & ANDROID_CPU_ARM_FEATURE_VFPv3) {
            LOG("ANDROID_CPU_ARM_FEATURE_VFPv3");
        }
        if (features & ANDROID_CPU_ARM_FEATURE_NEON) {
            LOG("ANDROID_CPU_ARM_FEATURE_NEON");
            android_armNeonEnabled = true;
        }
        if (features & ANDROID_CPU_ARM_FEATURE_LDREX_STREX) {
            LOG("ANDROID_CPU_ARM_FEATURE_LDREX_STREX");
        }
    } else if (family == ANDROID_CPU_FAMILY_ARM64) {
#warning FIXME TODO ...
        //android_arm64Arch = true;
        android_armArchV7A = true;
    }
}
Esempio n. 25
0
ARImageProcInfo *arImageProcInit(const int xsize, const int ysize, const AR_PIXEL_FORMAT pixFormat, int alwaysCopy)
{
    ARImageProcInfo *ipi = (ARImageProcInfo *)malloc(sizeof(ARImageProcInfo));
    if (ipi) {
        ipi->pixFormat = pixFormat;
        if (alwaysCopy || (pixFormat != AR_PIXEL_FORMAT_MONO && pixFormat != AR_PIXEL_FORMAT_420v && pixFormat != AR_PIXEL_FORMAT_420f && pixFormat != AR_PIXEL_FORMAT_NV21)) {
            ipi->image = (unsigned char *)malloc(xsize * ysize * sizeof(unsigned char));
            if (!ipi->image) goto bail;
            ipi->imageWasAllocated = TRUE;
        } else {
            ipi->imageWasAllocated = FALSE;
        }
        ipi->alwaysCopy = alwaysCopy;
        ipi->image2 = NULL;
        ipi->imageX = xsize;
        ipi->imageY = ysize;
#if AR_IMAGEPROC_USE_VIMAGE
        ipi->tempBuffer = NULL;
#endif
#ifdef HAVE_ARM_NEON
        ipi->fastPath = (ipi->imageX * ipi->imageY % 8 == 0
                         && (pixFormat == AR_PIXEL_FORMAT_RGBA
                             || pixFormat == AR_PIXEL_FORMAT_BGRA
                             || pixFormat == AR_PIXEL_FORMAT_ABGR
                             ||pixFormat == AR_PIXEL_FORMAT_ARGB
                             )
                         );
#  ifdef ANDROID
        // Not all Android devices with ARMv7 are guaranteed to have NEON, so check.
        uint64_t features = android_getCpuFeatures();
        ipi->fastPath = ipi->fastPath && (features & ANDROID_CPU_ARM_FEATURE_ARMv7) && (features & ANDROID_CPU_ARM_FEATURE_NEON);
#  endif
        if (ipi->fastPath) ARLOGd("arImageProc will use ARM NEON acceleration.\n");
#endif
    }
    return (ipi);
    
bail:
    free(ipi);
    return (NULL);
}
JNIEXPORT jboolean JNICALL
Java_com_h6ah4i_android_media_opensl_OpenSLMediaPlayerNativeLibraryLoader_checkIsNeonDisabledLibRequired(
    JNIEnv *env, jclass clazz) noexcept
{
    const AndroidCpuFamily cpu_family = android_getCpuFamily();
    const uint64_t cpu_features = android_getCpuFeatures();

    const bool is_arm_v7a =
        (cpu_family == ANDROID_CPU_FAMILY_ARM) &&
        ((cpu_features & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0);

    if (!is_arm_v7a) {
        return false;
    }

    const bool support_neon = ((cpu_features & ANDROID_CPU_ARM_FEATURE_NEON) != 0);

    if (support_neon) {
        return false;
    }

    return true;
}
bool hasNeon()
{
    AndroidCpuFamily family = android_getCpuFamily();
    switch (family) {
       case ANDROID_CPU_FAMILY_ARM:
    	   DP("CPU family is ARM\n");
           break;
       case ANDROID_CPU_FAMILY_X86:
    	   DP("CPU family is x86\n");
           break;
       case ANDROID_CPU_FAMILY_MIPS:
    	   DP("CPU family is MIPS\n");
           break;
       default:
    	   DP("Unsupported CPU family: %d\n", family);
           return 0;
       }
    	if (family == ANDROID_CPU_FAMILY_ARM) {
           uint64_t features = android_getCpuFeatures();
           DP( "Supported ARM features:\n");
           if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0) {
               DP( "  ARMv7\n" );
           }
           if ((features & ANDROID_CPU_ARM_FEATURE_VFPv3) != 0) {
        	   DP( "  VFPv3\n" );
           }
           if ((features & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
        	   DP( "  NEON\n" );
               return 1;
           }
           if ((features & ANDROID_CPU_ARM_FEATURE_LDREX_STREX) != 0) {
        	   DP( "  ldrex/strex\n" );
           }
       }
    	return 0;
}
Esempio n. 28
0
static arm_cpu_features_t
detect_cpu_features (void)
{
    arm_cpu_features_t features = 0;
    AndroidCpuFamily cpu_family;
    uint64_t cpu_features;

    cpu_family = android_getCpuFamily();
    cpu_features = android_getCpuFeatures();

    if (cpu_family == ANDROID_CPU_FAMILY_ARM)
    {
        if (cpu_features & ANDROID_CPU_ARM_FEATURE_ARMv7)
            features |= ARM_V7;

        if (cpu_features & ANDROID_CPU_ARM_FEATURE_VFPv3)
            features |= ARM_VFP;

        if (cpu_features & ANDROID_CPU_ARM_FEATURE_NEON)
            features |= ARM_NEON;
    }

    return features;
}
Esempio n. 29
0
static void enc_init(MSFilter *f){
	SpeexEncState *s=ms_new0(SpeexEncState,1);
#ifdef SPEEX_LIB_SET_CPU_FEATURES
	int cpuFeatures = 0;
#endif
	s->rate=8000;
	s->bitrate=-1;
	s->maxbitrate=-1;
	s->ip_bitrate=-1;
	s->ptime=20;
	s->mode=-1;
	s->vbr=0;
	s->cng=0;
	s->frame_size=0;
	s->state=0;
	s->ts=0;
	s->bufferizer=ms_bufferizer_new();
	f->data=s;

#ifdef SPEEX_LIB_SET_CPU_FEATURES
#ifdef __ARM_NEON__
	#ifdef ANDROID
	if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM
		&& (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
		cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
	}
	#else
	cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
	#endif
#endif
	ms_message("speex_lib_ctl init %s neon", (cpuFeatures == SPEEX_LIB_CPU_FEATURE_NEON)?"with":"without");
	speex_lib_ctl(SPEEX_LIB_SET_CPU_FEATURES, &cpuFeatures);
#else
	ms_message("speex_lib_ctl does not support SPEEX_LIB_CPU_FEATURE_NEON");
#endif
}
uint64_t WebRtc_GetCPUFeaturesARM(void) {
  return android_getCpuFeatures();
}