diff --git a/makefile.in b/makefile.in index ee7e2f7c1..1daf4d5d7 100644 --- a/makefile.in +++ b/makefile.in @@ -938,10 +938,11 @@ src/multichannel/src/firpfbch_cccf.o : %.o : %.c $(include_headers) $(multichann # autotests multichannel_autotests := \ - src/multichannel/tests/firpfbch2_crcf_autotest.c \ src/multichannel/tests/firpfbch_crcf_synthesizer_autotest.c \ src/multichannel/tests/firpfbch_crcf_analyzer_autotest.c \ src/multichannel/tests/firpfbch_crcf_autotest.c \ + src/multichannel/tests/firpfbch2_crcf_autotest.c \ + src/multichannel/tests/firpfbchr_crcf_autotest.c \ src/multichannel/tests/ofdmframe_autotest.c \ # benchmarks diff --git a/src/multichannel/src/firpfbchr.proto.c b/src/multichannel/src/firpfbchr.proto.c index 9507a586a..403cde46a 100644 --- a/src/multichannel/src/firpfbchr.proto.c +++ b/src/multichannel/src/firpfbchr.proto.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 - 2022 Joseph Gaeddert + * Copyright (c) 2007 - 2024 Joseph Gaeddert * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,12 +20,8 @@ * THE SOFTWARE. */ -// -// firpfbchr.c -// // finite impulse response polyphase filterbank channelizer with output // rate Fs / P -// #include #include @@ -71,8 +67,12 @@ FIRPFBCHR() FIRPFBCHR(_create)(unsigned int _chans, // validate input if (_chans < 2) return liquid_error_config("firpfbchr_%s_create(), number of channels must be at least 2", EXTENSION_FULL); + if (_decim < 1) + return liquid_error_config("firpfbchr_%s_create(), decimation rate must be at least 1", EXTENSION_FULL); if (_m < 1) return liquid_error_config("firpfbchr_%s_create(), filter semi-length must be at least 1", EXTENSION_FULL); + if (_h == NULL) + return liquid_error_config("firpfbchr_%s_create(), filter coefficients cannot be null", EXTENSION_FULL); // create object FIRPFBCHR() q = (FIRPFBCHR()) malloc(sizeof(struct FIRPFBCHR(_s))); diff --git a/src/multichannel/tests/firpfbchr_crcf_autotest.c b/src/multichannel/tests/firpfbchr_crcf_autotest.c new file mode 100644 index 000000000..719f38b8d --- /dev/null +++ b/src/multichannel/tests/firpfbchr_crcf_autotest.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2007 - 2024 Joseph Gaeddert + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include "autotest/autotest.h" +#include "liquid.h" + +void autotest_firpfbchr_crcf_config() +{ +#if LIQUID_STRICT_EXIT + AUTOTEST_WARN("skipping firpfbchr_crcf config test with strict exit enabled\n"); + return; +#endif +#if !LIQUID_SUPPRESS_ERROR_OUTPUT + fprintf(stderr,"warning: ignore potential errors here; checking for invalid configurations\n"); +#endif + // design prototype filter + unsigned int h_len = 2*64*12+1; + float h[2*64*12+1]; + liquid_firdes_kaiser(h_len, 0.1f, 60.0f, 0.0f, h); + + // check invalid function calls + CONTEND_ISNULL(firpfbchr_crcf_create( 0, 76, 12, h)) // too few channels + CONTEND_ISNULL(firpfbchr_crcf_create(64, 0, 12, h)) // decimation rate too small + CONTEND_ISNULL(firpfbchr_crcf_create(64, 76, 0, h)) // filter delay too small + CONTEND_ISNULL(firpfbchr_crcf_create(64, 76, 12, NULL)) // coefficients pointer set to NULL + + //CONTEND_ISNULL(firpfbchr_crcf_copy(NULL)) + + // create proper object and test configurations + firpfbchr_crcf q = firpfbchr_crcf_create_kaiser(64, 76, 12, 60.0f); + + CONTEND_EQUALITY(LIQUID_OK, firpfbchr_crcf_print(q)) + + firpfbchr_crcf_destroy(q); +} +