Commit 77199170 authored by jehan's avatar jehan

downgrade speex resampler quality to min in case of arm with no neon

parent 8663a08e
......@@ -38,6 +38,7 @@ typedef struct _ResampleData{
int in_nchannels;
int out_nchannels;
SpeexResamplerState *handle;
int cpuFeatures; /*store because there is no SPEEX_LIB_GET_CPU_FEATURES*/
} ResampleData;
static ResampleData * resample_data_new(){
......@@ -48,6 +49,7 @@ static ResampleData * resample_data_new(){
obj->output_rate=16000;
obj->handle=NULL;
obj->in_nchannels=obj->out_nchannels=1;
obj->cpuFeatures=0;
return obj;
}
......@@ -59,24 +61,24 @@ static void resample_data_destroy(ResampleData *obj){
}
static void resample_init(MSFilter *obj){
ResampleData* data=resample_data_new();
#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;
data->cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
}
#elif defined(__ARM_NEON__)
cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
data->cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
#endif
ms_message("speex_lib_ctl init with neon ? %d", (cpuFeatures == SPEEX_LIB_CPU_FEATURE_NEON));
ms_message("speex_lib_ctl init with neon ? %d", (data->cpuFeatures == SPEEX_LIB_CPU_FEATURE_NEON));
#endif
speex_lib_ctl(SPEEX_LIB_SET_CPU_FEATURES, &cpuFeatures);
speex_lib_ctl(SPEEX_LIB_SET_CPU_FEATURES, &data->cpuFeatures);
#else
ms_message("speex_lib_ctl does not support SPEEX_LIB_CPU_FEATURE_NEON");
#endif
obj->data=resample_data_new();
obj->data=data;
}
static void resample_uninit(MSFilter *obj){
......@@ -129,7 +131,17 @@ static void resample_process_ms2(MSFilter *obj){
}
if (dt->handle==NULL){
int err=0;
dt->handle=speex_resampler_init(dt->in_nchannels, dt->input_rate, dt->output_rate, SPEEX_RESAMPLER_QUALITY_VOIP, &err);
int quality=SPEEX_RESAMPLER_QUALITY_VOIP; /*default value is voip*/
#if __arm__ /*on ARM, NEON optimization are mandatory to support this quality, else using basic mode*/
#if SPEEX_LIB_SET_CPU_FEATURES
if (data->cpuFeatures != SPEEX_LIB_CPU_FEATURE_NEON)
quality=SPEEX_RESAMPLER_QUALITY_MIN;
#elif !__ARM_NEON__
quality=SPEEX_RESAMPLER_QUALITY_MIN;
#endif /*SPEEX_LIB_SET_CPU_FEATURES*/
#endif /*__arm__*/
ms_message("Initializing speex resampler in mode [%s] ",(quality==SPEEX_RESAMPLER_QUALITY_VOIP?"voip":"min"));
dt->handle=speex_resampler_init(dt->in_nchannels, dt->input_rate, dt->output_rate, quality, &err);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment