Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ignore output text files
testlog.txt
res_*.txt
*.log

# Release files
release_*
Expand Down
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,25 @@ endif()
if(IOS_PLATFORM AND IOS_DEMO)
add_subdirectory(ios)
endif()

# This may run the static code analyzer CppCheck on all the project sources,
# if it is available on the system.
# NOTE This only works wit hcmake 3.10 or later
Comment thread
hoijui marked this conversation as resolved.
Outdated
# If you want to run CppCheck manually,
# you may use this command:
# cppcheck --enable=all --std=c99 . 2>&1 \
# | grep -v " is never used." \
# | grep -v "Checking " \
# | grep -v " files checked " \
# > cppcheck.log
find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck)
if(CMAKE_CXX_CPPCHECK)
list(
APPEND CMAKE_CXX_CPPCHECK
"--std=c99"
"--enable=all"
"--inconclusive"
"--inline-suppr"
)
endif()

5 changes: 2 additions & 3 deletions modules/NE10_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ ne10_result_t ne10_HasNEON()

ne10_result_t ne10_init()
{
ne10_result_t status = NE10_ERR;
ne10_result_t status;
#ifndef __MACH__
FILE* infofile = NULL; // To open the file /proc/cpuinfo
ne10_int8_t cpuinfo[CPUINFO_BUFFER_SIZE]; // The buffer to read in the string
ne10_uint32_t bytes = 0; // Numbers of bytes read from the file
ne10_int32_t i = 0; // Temporary loop counter

memset (cpuinfo, 0, CPUINFO_BUFFER_SIZE);
infofile = fopen ("/proc/cpuinfo", "r");
FILE* infofile = fopen ("/proc/cpuinfo", "r");

if (!infofile)
{
Expand Down
6 changes: 2 additions & 4 deletions modules/dsp/NE10_fft.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,13 @@ ne10_fft_cfg_float32_t ne10_fft_alloc_c2c_float32_neon (ne10_int32_t nfft)
return ne10_fft_alloc_c2c_float32_c (nfft);
}

ne10_fft_cfg_float32_t st = NULL;
ne10_uint32_t memneeded = sizeof (ne10_fft_state_float32_t)
+ sizeof (ne10_int32_t) * (NE10_MAXFACTORS * 2) /* factors */
+ sizeof (ne10_fft_cpx_float32_t) * nfft /* twiddles */
+ sizeof (ne10_fft_cpx_float32_t) * nfft /* buffer */
+ NE10_FFT_BYTE_ALIGNMENT; /* 64-bit alignment */

st = (ne10_fft_cfg_float32_t) NE10_MALLOC (memneeded);
ne10_fft_cfg_float32_t st = (ne10_fft_cfg_float32_t) NE10_MALLOC (memneeded);

// Bad allocation.
if (st == NULL)
Expand Down Expand Up @@ -459,14 +458,13 @@ ne10_fft_cfg_int32_t ne10_fft_alloc_c2c_int32_neon (ne10_int32_t nfft)
return ne10_fft_alloc_c2c_int32_c (nfft);
}

ne10_fft_cfg_int32_t st = NULL;
ne10_uint32_t memneeded = sizeof (ne10_fft_state_int32_t)
+ sizeof (ne10_int32_t) * (NE10_MAXFACTORS * 2) /* factors */
+ sizeof (ne10_fft_cpx_int32_t) * nfft /* twiddles */
+ sizeof (ne10_fft_cpx_int32_t) * nfft /* buffer */
+ NE10_FFT_BYTE_ALIGNMENT; /* 64-bit alignment */

st = (ne10_fft_cfg_int32_t) NE10_MALLOC (memneeded);
ne10_fft_cfg_int32_t st = (ne10_fft_cfg_int32_t) NE10_MALLOC (memneeded);

// Bad allocation.
if (st == NULL)
Expand Down
6 changes: 2 additions & 4 deletions modules/dsp/NE10_fft_float32.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,14 +828,13 @@ static void ne10_fft_split_c2r_1d_float32 (ne10_fft_cpx_float32_t *dst,
*/
ne10_fft_cfg_float32_t ne10_fft_alloc_c2c_float32_c (ne10_int32_t nfft)
{
ne10_fft_cfg_float32_t st = NULL;
ne10_uint32_t memneeded = sizeof (ne10_fft_state_float32_t)
+ sizeof (ne10_int32_t) * (NE10_MAXFACTORS * 2) /* factors */
+ sizeof (ne10_fft_cpx_float32_t) * nfft /* twiddles */
+ sizeof (ne10_fft_cpx_float32_t) * nfft /* buffer */
+ NE10_FFT_BYTE_ALIGNMENT; /* 64-bit alignment */

st = (ne10_fft_cfg_float32_t) NE10_MALLOC (memneeded);
ne10_fft_cfg_float32_t st = (ne10_fft_cfg_float32_t) NE10_MALLOC (memneeded);

if (st == NULL)
{
Expand Down Expand Up @@ -943,7 +942,6 @@ void ne10_fft_c2c_1d_float32_c (ne10_fft_cpx_float32_t *fout,
*/
ne10_fft_r2c_cfg_float32_t ne10_fft_alloc_r2c_float32 (ne10_int32_t nfft)
{
ne10_fft_r2c_cfg_float32_t st = NULL;
ne10_int32_t ncfft = nfft >> 1;

ne10_uint32_t memneeded = sizeof (ne10_fft_r2c_state_float32_t)
Expand All @@ -953,7 +951,7 @@ ne10_fft_r2c_cfg_float32_t ne10_fft_alloc_r2c_float32 (ne10_int32_t nfft)
+ sizeof (ne10_fft_cpx_float32_t) * nfft /* buffer */
+ NE10_FFT_BYTE_ALIGNMENT; /* 64-bit alignment */

st = (ne10_fft_r2c_cfg_float32_t) NE10_MALLOC (memneeded);
ne10_fft_r2c_cfg_float32_t st = (ne10_fft_r2c_cfg_float32_t) NE10_MALLOC (memneeded);

if (st)
{
Expand Down
22 changes: 10 additions & 12 deletions modules/dsp/NE10_fft_float32.neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@ static void ne10_fft_split_r2c_1d_float32_neon (ne10_fft_cpx_float32_t *dst,
float32x4_t q_tw_r, q_tw_i;
float32x4_t q_tmp0, q_tmp1, q_tmp2, q_tmp3, q_val;
float32x4_t q_dst_r, q_dst_i, q_dst2_r, q_dst2_i;
float32_t *p_src, *p_src2, *p_dst, *p_dst2, *p_twiddles;

tdc.r = src[0].r;
tdc.i = src[0].i;
Expand All @@ -490,11 +489,11 @@ static void ne10_fft_split_r2c_1d_float32_neon (ne10_fft_cpx_float32_t *dst,
{
for (k = 1; k <= count ; k += 4)
{
p_src = (float32_t*) (& (src[k]));
p_src2 = (float32_t*) (& (src[ncfft - k - 3]));
p_twiddles = (float32_t*) (& (twiddles[k - 1]));
p_dst = (float32_t*) (& (dst[k]));
p_dst2 = (float32_t*) (& (dst[ncfft - k - 3]));
float32_t* p_src = (float32_t*) (& (src[k]));
float32_t* p_src2 = (float32_t*) (& (src[ncfft - k - 3]));
float32_t* p_twiddles = (float32_t*) (& (twiddles[k - 1]));
float32_t* p_dst = (float32_t*) (& (dst[k]));
float32_t* p_dst2 = (float32_t*) (& (dst[ncfft - k - 3]));

q2_fpk = vld2q_f32 (p_src);
q2_fpnk = vld2q_f32 (p_src2);
Expand Down Expand Up @@ -575,7 +574,6 @@ static void ne10_fft_split_c2r_1d_float32_neon (ne10_fft_cpx_float32_t *dst,
float32x4_t q_fek_r, q_fek_i, q_fok_r, q_fok_i;
float32x4_t q_tmp0, q_tmp1, q_tmp2, q_tmp3, q_val;
float32x4_t q_dst2_r, q_dst2_i;
float32_t *p_src, *p_src2, *p_dst, *p_dst2, *p_twiddles;

dst[0].r = (src[0].r + src[ncfft].r) * 0.5f;
dst[0].i = (src[0].r - src[ncfft].r) * 0.5f;
Expand All @@ -584,11 +582,11 @@ static void ne10_fft_split_c2r_1d_float32_neon (ne10_fft_cpx_float32_t *dst,
{
for (k = 1; k <= count ; k += 4)
{
p_src = (float32_t*) (& (src[k]));
p_src2 = (float32_t*) (& (src[ncfft - k - 3]));
p_twiddles = (float32_t*) (& (twiddles[k - 1]));
p_dst = (float32_t*) (& (dst[k]));
p_dst2 = (float32_t*) (& (dst[ncfft - k - 3]));
float32_t* p_src = (float32_t*) (& (src[k]));
float32_t* p_src2 = (float32_t*) (& (src[ncfft - k - 3]));
float32_t* p_twiddles = (float32_t*) (& (twiddles[k - 1]));
float32_t* p_dst = (float32_t*) (& (dst[k]));
float32_t* p_dst2 = (float32_t*) (& (dst[ncfft - k - 3]));

q2_fk = vld2q_f32 (p_src);
q2_fnkc = vld2q_f32 (p_src2);
Expand Down
6 changes: 2 additions & 4 deletions modules/dsp/NE10_fft_int16.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,14 +1071,13 @@ static void ne10_fft_split_c2r_1d_int16 (ne10_fft_cpx_int16_t *dst,
*/
ne10_fft_cfg_int16_t ne10_fft_alloc_c2c_int16 (ne10_int32_t nfft)
{
ne10_fft_cfg_int16_t st = NULL;
ne10_uint32_t memneeded = sizeof (ne10_fft_state_int16_t)
+ sizeof (ne10_int32_t) * (NE10_MAXFACTORS * 2) /* factors */
+ sizeof (ne10_fft_cpx_int16_t) * (nfft) /* twiddles */
+ sizeof (ne10_fft_cpx_int16_t) * nfft /* buffer */
+ NE10_FFT_BYTE_ALIGNMENT; /* 64-bit alignment */

st = (ne10_fft_cfg_int16_t) NE10_MALLOC (memneeded);
ne10_fft_cfg_int16_t st = (ne10_fft_cfg_int16_t) NE10_MALLOC (memneeded);

if (st)
{
Expand Down Expand Up @@ -1163,7 +1162,6 @@ void ne10_fft_c2c_1d_int16_c (ne10_fft_cpx_int16_t *fout,
*/
ne10_fft_r2c_cfg_int16_t ne10_fft_alloc_r2c_int16 (ne10_int32_t nfft)
{
ne10_fft_r2c_cfg_int16_t st = NULL;
ne10_int32_t ncfft = nfft >> 1;

ne10_uint32_t memneeded = sizeof (ne10_fft_r2c_state_int16_t)
Expand All @@ -1173,7 +1171,7 @@ ne10_fft_r2c_cfg_int16_t ne10_fft_alloc_r2c_int16 (ne10_int32_t nfft)
+ sizeof (ne10_fft_cpx_int32_t) * nfft /* buffer */
+ NE10_FFT_BYTE_ALIGNMENT; /* 64-bit alignment */

st = (ne10_fft_r2c_cfg_int16_t) NE10_MALLOC (memneeded);
ne10_fft_r2c_cfg_int16_t st = (ne10_fft_r2c_cfg_int16_t) NE10_MALLOC (memneeded);

if (st)
{
Expand Down
58 changes: 26 additions & 32 deletions modules/dsp/NE10_fft_int16.neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ static void ne10_fft_split_r2c_1d_int16_neon (ne10_fft_cpx_int16_t *dst,
ne10_int32_t ncfft,
ne10_int32_t scaled_flag)
{
ne10_int32_t k;
ne10_int32_t count = ncfft / 2;
ne10_fft_cpx_int16_t fpnk, fpk, f1k, f2k, tw, tdc;
int16x8x2_t q2_fpk, q2_fpnk, q2_tw, q2_dst, q2_dst2;
Expand All @@ -463,7 +462,6 @@ static void ne10_fft_split_r2c_1d_int16_neon (ne10_fft_cpx_int16_t *dst,
int16x8_t q_tw_r, q_tw_i;
int16x8_t q_tmp0, q_tmp1, q_tmp2, q_tmp3;
int16x8_t q_dst2_r, q_dst2_i;
int16_t *p_src, *p_src2, *p_dst, *p_dst2, *p_twiddles;

tdc.r = src[0].r;
tdc.i = src[0].i;
Expand All @@ -479,13 +477,13 @@ static void ne10_fft_split_r2c_1d_int16_neon (ne10_fft_cpx_int16_t *dst,

if (scaled_flag)
{
for (k = 1; k <= count ; k += 8)
for (ne10_int32_t k = 1; k <= count ; k += 8)
{
p_src = (int16_t*) (& (src[k]));
p_src2 = (int16_t*) (& (src[ncfft - k - 7]));
p_twiddles = (int16_t*) (& (twiddles[k - 1]));
p_dst = (int16_t*) (& (dst[k]));
p_dst2 = (int16_t*) (& (dst[ncfft - k - 7]));
int16_t* p_src = (int16_t*) (& (src[k]));
int16_t* p_src2 = (int16_t*) (& (src[ncfft - k - 7]));
int16_t* p_twiddles = (int16_t*) (& (twiddles[k - 1]));
int16_t* p_dst = (int16_t*) (& (dst[k]));
int16_t* p_dst2 = (int16_t*) (& (dst[ncfft - k - 7]));

q2_fpk = vld2q_s16 (p_src);
q2_fpnk = vld2q_s16 (p_src2);
Expand Down Expand Up @@ -529,13 +527,13 @@ static void ne10_fft_split_r2c_1d_int16_neon (ne10_fft_cpx_int16_t *dst,
}
else
{
for (k = 1; k <= count ; k += 8)
for (ne10_int32_t k = 1; k <= count ; k += 8)
{
p_src = (int16_t*) (& (src[k]));
p_src2 = (int16_t*) (& (src[ncfft - k - 7]));
p_twiddles = (int16_t*) (& (twiddles[k - 1]));
p_dst = (int16_t*) (& (dst[k]));
p_dst2 = (int16_t*) (& (dst[ncfft - k - 7]));
int16_t* p_src = (int16_t*) (& (src[k]));
int16_t* p_src2 = (int16_t*) (& (src[ncfft - k - 7]));
int16_t* p_twiddles = (int16_t*) (& (twiddles[k - 1]));
int16_t* p_dst = (int16_t*) (& (dst[k]));
int16_t* p_dst2 = (int16_t*) (& (dst[ncfft - k - 7]));

q2_fpk = vld2q_s16 (p_src);
q2_fpnk = vld2q_s16 (p_src2);
Expand Down Expand Up @@ -574,14 +572,12 @@ static void ne10_fft_split_r2c_1d_int16_neon (ne10_fft_cpx_int16_t *dst,
q2_dst2.val[1] = vcombine_s16 (vget_high_s16 (q_dst2_i), vget_low_s16 (q_dst2_i));
vst2q_s16 (p_dst, q2_dst);
vst2q_s16 (p_dst2, q2_dst2);

}
}
}
else
{

for (k = 1; k <= ncfft / 2 ; ++k)
for (ne10_int32_t k = 1; k <= ncfft / 2 ; ++k)
{
fpk = src[k];
fpnk.r = src[ncfft - k].r;
Expand Down Expand Up @@ -618,15 +614,13 @@ static void ne10_fft_split_c2r_1d_int16_neon (ne10_fft_cpx_int16_t *dst,
ne10_int32_t scaled_flag)
{

ne10_int32_t k;
ne10_int32_t count = ncfft / 2;
ne10_fft_cpx_int16_t fk, fnkc, fek, fok, tmp;
int16x8x2_t q2_fk, q2_fnkc, q2_tw, q2_dst, q2_dst2;
int16x8_t q_fnkc_r, q_fnkc_i;
int16x8_t q_fek_r, q_fek_i, q_fok_r, q_fok_i;
int16x8_t q_tmp0, q_tmp1, q_tmp2, q_tmp3;
int16x8_t q_dst2_r, q_dst2_i;
int16_t *p_src, *p_src2, *p_dst, *p_dst2, *p_twiddles;


dst[0].r = src[0].r + src[ncfft].r;
Expand All @@ -638,13 +632,13 @@ static void ne10_fft_split_c2r_1d_int16_neon (ne10_fft_cpx_int16_t *dst,
{
if (scaled_flag)
{
for (k = 1; k <= count ; k += 8)
for (ne10_int32_t k = 1; k <= count ; k += 8)
{
p_src = (int16_t*) (& (src[k]));
p_src2 = (int16_t*) (& (src[ncfft - k - 7]));
p_twiddles = (int16_t*) (& (twiddles[k - 1]));
p_dst = (int16_t*) (& (dst[k]));
p_dst2 = (int16_t*) (& (dst[ncfft - k - 7]));
int16_t* p_src = (int16_t*) (& (src[k]));
int16_t* p_src2 = (int16_t*) (& (src[ncfft - k - 7]));
int16_t* p_twiddles = (int16_t*) (& (twiddles[k - 1]));
int16_t* p_dst = (int16_t*) (& (dst[k]));
int16_t* p_dst2 = (int16_t*) (& (dst[ncfft - k - 7]));

q2_fk = vld2q_s16 (p_src);
q2_fnkc = vld2q_s16 (p_src2);
Expand Down Expand Up @@ -687,13 +681,13 @@ static void ne10_fft_split_c2r_1d_int16_neon (ne10_fft_cpx_int16_t *dst,
}
else
{
for (k = 1; k <= count ; k += 8)
for (ne10_int32_t k = 1; k <= count ; k += 8)
{
p_src = (int16_t*) (& (src[k]));
p_src2 = (int16_t*) (& (src[ncfft - k - 7]));
p_twiddles = (int16_t*) (& (twiddles[k - 1]));
p_dst = (int16_t*) (& (dst[k]));
p_dst2 = (int16_t*) (& (dst[ncfft - k - 7]));
int16_t* p_src = (int16_t*) (& (src[k]));
int16_t* p_src2 = (int16_t*) (& (src[ncfft - k - 7]));
int16_t* p_twiddles = (int16_t*) (& (twiddles[k - 1]));
int16_t* p_dst = (int16_t*) (& (dst[k]));
int16_t* p_dst2 = (int16_t*) (& (dst[ncfft - k - 7]));

q2_fk = vld2q_s16 (p_src);
q2_fnkc = vld2q_s16 (p_src2);
Expand Down Expand Up @@ -737,7 +731,7 @@ static void ne10_fft_split_c2r_1d_int16_neon (ne10_fft_cpx_int16_t *dst,
else
{

for (k = 1; k <= ncfft / 2; k++)
for (ne10_int32_t k = 1; k <= ncfft / 2; k++)
{
fk = src[k];
fnkc.r = src[ncfft - k].r;
Expand Down
Loading