aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/ut.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/test/ut.c b/test/ut.c
index f099b70..9f531b1 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -17,7 +17,7 @@ static float* create_chirp(int sz)
static int done = 0;
for(i = 0; i < sz; i++) {
float t = i;
- buf[i] = sinf((t + t * t * 0.5 / 2.0) * 2.0 * M_PI/(float)sz);
+ buf[i] = sinf((t + t * t * 0.5 / 2.0) * 2.0 * M_PI/(float)sz);
}
return buf;
}
@@ -34,59 +34,63 @@ static float* create_chirp(int sz)
#define PQF_TEST_COVER(module) \
FCT_SUITE_BGN(module) \
{ \
- uint16_t sb_sz = module.get_subband_sz(); \
- uint16_t sb_num = module.get_subbands_num(); \
+ uint16_t sb_sz = module.get_subband_sz(); \
+ uint16_t sb_num = module.get_subbands_num(); \
uint16_t proto_sz = module.get_proto_sz(); \
- const float* proto = module.get_proto(); \
- const float* dummy = calloc(sb_sz * sb_num, sizeof(float)); \
+ const float* const proto = module.get_proto(); \
+ float* const dummy = alloca(sb_sz * sb_num * sizeof(float)); \
+ for (int i = 0; i < sb_sz * sb_num; i++) \
+ dummy[i] = 0; \
FCT_TEST_BGN(module-IMP) \
{ \
- int k;\
+ int k;\
pqf_a_ctx_t ctx; \
int status = pqf_create_a_ctx(sb_sz, sb_num, proto_sz, proto, &ctx); \
fct_chk_eq_int(status, PQF_SUCCESS); \
- float* in_buf1 = calloc(sb_sz * sb_num, sizeof(float)); \
+ float* in_buf1 = calloc(sb_sz * sb_num, sizeof(float)); \
in_buf1[500] = 1.0; \
float* out_buf = malloc(sizeof(float) * sb_sz * sb_num); \
float* synth_buf = malloc(sizeof(float) * sb_sz * sb_num * 2); \
- void* dec_ctx = module.create_ctx(); \
+ void* dec_ctx = module.create_ctx(); \
pqf_do_analyse(ctx, in_buf1, out_buf); \
- module.synth_filter(out_buf, synth_buf, dec_ctx); \
+ module.synth_filter(out_buf, synth_buf, dec_ctx); \
pqf_do_analyse(ctx, dummy, out_buf); \
- module.synth_filter(out_buf, synth_buf + sb_sz * sb_num, dec_ctx); \
+ module.synth_filter(out_buf, synth_buf + sb_sz * sb_num, dec_ctx); \
\
check_reconstruction(in_buf1, synth_buf + proto_sz, sb_sz * sb_num); \
\
module.free_ctx(dec_ctx); \
- free(synth_buf); \
+ free(synth_buf); \
free(out_buf); \
free(in_buf1); \
+ pqf_free_a_ctx(ctx); \
} \
FCT_TEST_END(); \
FCT_TEST_BGN(module-DC) \
{ \
- int k; \
+ int k; \
pqf_a_ctx_t ctx; \
uint16_t i = 0; \
int status = pqf_create_a_ctx(sb_sz, sb_num, proto_sz, proto, &ctx); \
fct_chk_eq_int(status, PQF_SUCCESS); \
- float* in_buf1 = calloc(sb_sz * sb_num, sizeof(float)); \
- for (i = 0; i < sb_sz * sb_num; i++) \
+ float* in_buf1 = calloc(sb_sz * sb_num, sizeof(float)); \
+ for (i = 0; i < sb_sz * sb_num; i++) \
in_buf1[i] = 1.0; \
float* out_buf = malloc(sizeof(float) * sb_sz * sb_num); \
float* synth_buf = malloc(sizeof(float) * sb_sz * sb_num * 2); \
- void* dec_ctx = module.create_ctx(); \
+ void* dec_ctx = module.create_ctx(); \
pqf_do_analyse(ctx, in_buf1, out_buf); \
- module.synth_filter(out_buf, synth_buf, dec_ctx); \
+ module.synth_filter(out_buf, synth_buf, dec_ctx); \
pqf_do_analyse(ctx, in_buf1, out_buf); \
- module.synth_filter(out_buf, synth_buf + sb_sz * sb_num, dec_ctx); \
+ module.synth_filter(out_buf, synth_buf + sb_sz * sb_num, dec_ctx); \
\
check_reconstruction(in_buf1, synth_buf + proto_sz, sb_sz * sb_num); \
\
module.free_ctx(dec_ctx); \
- free(synth_buf); \
+ free(synth_buf); \
free(out_buf); \
free(in_buf1); \
+ pqf_free_a_ctx(ctx); \
} \
FCT_TEST_END(); \
FCT_TEST_BGN(module-CHIRP-SHORT) \
@@ -98,18 +102,19 @@ static float* create_chirp(int sz)
float* out_buf = malloc(sizeof(float) * sb_sz * sb_num); \
float* synth_buf = malloc(sizeof(float) * sb_sz * sb_num * 2); \
fct_chk_eq_int(status, PQF_SUCCESS); \
- void* dec_ctx = module.create_ctx(); \
+ void* dec_ctx = module.create_ctx(); \
pqf_do_analyse(ctx, chirp, out_buf); \
- module.synth_filter(out_buf, synth_buf, dec_ctx); \
+ module.synth_filter(out_buf, synth_buf, dec_ctx); \
pqf_do_analyse(ctx, dummy, out_buf); \
- module.synth_filter(out_buf, synth_buf + sb_sz * sb_num, dec_ctx); \
+ module.synth_filter(out_buf, synth_buf + sb_sz * sb_num, dec_ctx); \
\
check_reconstruction(chirp, synth_buf + proto_sz, sb_sz * sb_num); \
\
module.free_ctx(dec_ctx); \
- free(synth_buf); \
+ free(synth_buf); \
free(out_buf); \
free(chirp); \
+ pqf_free_a_ctx(ctx); \
} \
FCT_TEST_END(); \
FCT_TEST_BGN(module-CHIRP-LONG) \
@@ -119,27 +124,27 @@ static float* create_chirp(int sz)
uint16_t i = 0; \
float* chirp = create_chirp(16384); \
float* out_buf = malloc(sizeof(float) * sb_sz * sb_num); \
- float* synth_buf = malloc(sizeof(float) * 16384 + sb_sz * sb_num); \
+ float* const synth_buf = malloc(sizeof(float) * (16384 + sb_sz * sb_num)); \
fct_chk_eq_int(status, PQF_SUCCESS); \
- void* dec_ctx = module.create_ctx(); \
- pqf_do_analyse(ctx, chirp, out_buf); \
- module.synth_filter(out_buf, synth_buf, dec_ctx); \
- for (i = sb_sz * sb_num; i < 16384; i += sb_sz * sb_num) { \
+ void* dec_ctx = module.create_ctx(); \
+ /*pqf_do_analyse(ctx, chirp, out_buf);*/ \
+ /*module.synth_filter(out_buf, synth_buf, dec_ctx);*/ \
+ for (i = 0 /*sb_sz * sb_num*/; i < 16384; i += sb_sz * sb_num) { \
pqf_do_analyse(ctx, chirp + i, out_buf); \
module.synth_filter(out_buf, synth_buf + i, dec_ctx); \
} \
pqf_do_analyse(ctx, dummy, out_buf); \
- module.synth_filter(out_buf, synth_buf + 16384, dec_ctx); \
+ module.synth_filter(out_buf, synth_buf + 16384, dec_ctx); \
\
check_reconstruction(chirp, synth_buf + proto_sz, 16384); \
\
module.free_ctx(dec_ctx); \
- free(synth_buf); \
+ free(synth_buf); \
free(out_buf); \
free(chirp); \
+ pqf_free_a_ctx(ctx); \
} \
FCT_TEST_END(); \
- free((void*)dummy); \
} \
FCT_SUITE_END(); \