From: drowe67 Date: Thu, 16 Mar 2017 00:49:40 +0000 (+0000) Subject: fix some warnings, remove unused ancient unittests X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=5932dca0fc1ec3da2165e4f1d765ec140a9a35c5;p=freetel-svn-tracking.git fix some warnings, remove unused ancient unittests git-svn-id: https://svn.code.sf.net/p/freetel/code@3063 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/unittest/CMakeLists.txt b/codec2-dev/unittest/CMakeLists.txt index 0f444b12..c358f044 100644 --- a/codec2-dev/unittest/CMakeLists.txt +++ b/codec2-dev/unittest/CMakeLists.txt @@ -13,15 +13,6 @@ target_link_libraries(extract codec2) add_executable(vqtrain vqtrain.c) target_link_libraries(vqtrain codec2) -add_executable(vqtrainjnd vqtrainjnd.c) -target_link_libraries(vqtrainjnd codec2) - -add_executable(vqtrainph vqtrainph.c) -target_link_libraries(vqtrainph codec2) - -add_executable(vqtrainsp vqtrainsp.c) -target_link_libraries(vqtrainsp codec2) - add_executable(genphdata genphdata.c) target_link_libraries(genphdata codec2) @@ -75,12 +66,6 @@ target_link_libraries(tdeframer m codec2) add_executable(tfreedv_data_channel tfreedv_data_channel.c) target_link_libraries(tfreedv_data_channel codec2) -#add_executable(t48_8 t48_8.c ../src/fdmdv.c ../src/kiss_fft.c) -#target_link_libraries(t48_8 codec2) - -add_executable(lspsync lspsync.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c ${CODEBOOKS}) -target_link_libraries(lspsync codec2) - add_executable(create_interleaver create_interleaver.c) target_link_libraries(create_interleaver codec2) diff --git a/codec2-dev/unittest/lspsync.c b/codec2-dev/unittest/lspsync.c deleted file mode 100644 index 007200c7..00000000 --- a/codec2-dev/unittest/lspsync.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - lspsync.c - David Rowe 24 May 2012 - - Attempt at using LSP information to provide frame sync. If we have - correct frame alignment, LSPs will not need sorting. - - However this method as tested appears unreliable, often several - sync positions per frame are found, even with a F=10 memory. For - F=6, about 87% relaible. This might be useful if combined with a - another sync method, for example a single alternating sync bit per - frame. - -*/ - -#include -#include -#include -#include "codec2.h" -#include "defines.h" -#include "quantise.h" - -#define F 6 /* look at LSP ordering in F-1 frames */ -#define CORRECT_OFFSET 10 /* LSPs start 10 bits int frame qt 2400 bit/s */ - - -static int check_candidate(unsigned char bits[], int offset) -{ - int i; - int lsp_indexes[LPC_ORD]; - float lsps[LPC_ORD]; - unsigned int nbit = offset; - int swaps; - - for(i=0; i. -*/ - -/*-----------------------------------------------------------------------*\ - - INCLUDES - -\*-----------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include - -/*-----------------------------------------------------------------------*\ - - DEFINES - -\*-----------------------------------------------------------------------*/ - -#define PI 3.141592654 /* mathematical constant */ -#define MAX_POP 10 - -/*-----------------------------------------------------------------------*\ - - FUNCTION PROTOTYPES - -\*-----------------------------------------------------------------------*/ - -void zero(float v[], int k); -void acc(float v1[], float v2[], int k); -void norm(float v[], int k, long n); -void locate_lsps_jnd_steps(float lsps[], float step, int k); - -/*-----------------------------------------------------------------------* \ - - MAIN - -\*-----------------------------------------------------------------------*/ - -int main(int argc, char *argv[]) { - int k; /* dimension and codebook size */ - float *vec; /* current vector */ - int *n; /* number of vectors in this interval */ - int J; /* number of vectors in training set */ - int i,j; - FILE *ftrain; /* file containing training set */ - float *train; /* training database */ - //float *pend_train; /* last entry */ - float *pt; - int ntrain, match, vec_exists, vec_index=0, entry; - int popular[MAX_POP], pop_thresh; - FILE *fvq; - float jnd; - - /* Interpret command line arguments */ - - if (argc != 6) { - printf("usage: %s TrainFile K(dimension) JND popThresh VQFile\n", - argv[0]); - exit(1); - } - - /* Open training file */ - - ftrain = fopen(argv[1],"rb"); - if (ftrain == NULL) { - printf("Error opening training database file: %s\n",argv[1]); - exit(1); - } - - /* determine k and m, and allocate arrays */ - - k = atol(argv[2]); - jnd = atof(argv[3]); - pop_thresh = atol(argv[4]); - printf("dimension K=%d popThresh=%d JND=%3.1f Hz\n", - k, pop_thresh, jnd); - vec = (float*)malloc(sizeof(float)*k); - if (vec == NULL) { - printf("Error in malloc.\n"); - exit(1); - } - - /* determine size of training set */ - - J = 0; - while(fread(vec, sizeof(float), k, ftrain) == (size_t)k) - J++; - printf("J=%d entries in training set\n", J); - train = (float*)malloc(sizeof(float)*k*J); - if (train == NULL) { - printf("Error in malloc.\n"); - exit(1); - } - printf("training array is %lu bytes\n", sizeof(float)*k*J); - - n = (int*)malloc(sizeof(int)*J); - if (n == NULL) { - printf("Error in malloc.\n"); - exit(1); - } - for(i=0; i pop_thresh) { - for(j=0; j. -*/ - -/*-----------------------------------------------------------------------*\ - - INCLUDES - -\*-----------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -typedef struct { - float real; - float imag; -} COMP; - -/*-----------------------------------------------------------------------* \ - - DEFINES - -\*-----------------------------------------------------------------------*/ - -#define DELTAQ 0.01 /* quiting distortion */ -#define MAX_STR 80 /* maximum string length */ -#define PI 3.141592654 - -/*-----------------------------------------------------------------------*\ - - FUNCTION PROTOTYPES - -\*-----------------------------------------------------------------------*/ - -void zero(COMP v[], int d); -void acc(COMP v1[], COMP v2[], int d); -void norm(COMP v[], int k); -int quantise(COMP cb[], COMP vec[], int d, int e, float *se); -void print_vec(COMP cb[], int d, int e); - -/*-----------------------------------------------------------------------* \ - - MAIN - -\*-----------------------------------------------------------------------*/ - -int main(int argc, char *argv[]) { - int d,e; /* dimension and codebook size */ - COMP *vec; /* current vector */ - COMP *cb; /* vector codebook */ - COMP *cent; /* centroids for each codebook entry */ - int *n; /* number of vectors in this interval */ - int J; /* number of vectors in training set */ - int ind; /* index of current vector */ - float se; /* total squared error for this iteration */ - float var; /* variance */ - float var_1; /* previous variance */ - float delta; /* improvement in distortion */ - FILE *ftrain; /* file containing training set */ - FILE *fvq; /* file containing vector quantiser */ - int i,j, finished, iterations; - float sd_vec; - int var_n; - - /* Interpret command line arguments */ - - if (argc != 5) { - printf("usage: %s TrainFile D(dimension) E(number of entries) VQFile\n", argv[0]); - exit(1); - } - - /* Open training file */ - - ftrain = fopen(argv[1],"rb"); - if (ftrain == NULL) { - printf("Error opening training database file: %s\n",argv[1]); - exit(1); - } - - /* determine k and m, and allocate arrays */ - - d = atoi(argv[2]); - e = atoi(argv[3]); - printf("\n"); - printf("dimension D=%d number of entries E=%d\n", d, e); - vec = (COMP*)malloc(sizeof(COMP)*d); - cb = (COMP*)malloc(sizeof(COMP)*d*e); - cent = (COMP*)malloc(sizeof(COMP)*d*e); - n = (int*)malloc(sizeof(int)*e); - if (cb == NULL || cb == NULL || cent == NULL || vec == NULL) { - printf("Error in malloc.\n"); - exit(1); - } - - /* determine size of training set */ - - J = 0; - var_n = 0; - while(fread(vec, sizeof(COMP), d, ftrain) == (size_t)d) { - for(j=0; j 1) { - if (var > 0.0) { - delta = (var_1 - var)/var; - } - else - delta = 0; - if (delta < DELTAQ) - finished = 1; - } - - if (!finished) { - /* determine new codebook from centroids */ - - for(i=0; i. -*/ - -/*-----------------------------------------------------------------------*\ - - INCLUDES - -\*-----------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -typedef struct { - float real; - float imag; -} COMP; - -/*-----------------------------------------------------------------------* \ - - DEFINES - -\*-----------------------------------------------------------------------*/ - -#define DELTAQ 0.01 /* quiting distortion */ -#define MAX_STR 80 /* maximum string length */ - -/*-----------------------------------------------------------------------*\ - - FUNCTION PROTOTYPES - -\*-----------------------------------------------------------------------*/ - -void zero(float v[], int d); -void acc(float v1[], float v2[], int d); -void norm(float v[], int k, int n[]); -int quantise(float cb[], float vec[], int d, int e, float *se); -void print_vec(float cb[], int d, int e); -void split(float cb[], int d, int b); -int gain_shape_quantise(float cb[], float vec[], int d, int e, float *se, float *best_gain); - -/*-----------------------------------------------------------------------* \ - - MAIN - -\*-----------------------------------------------------------------------*/ - -int main(int argc, char *argv[]) { - int d,e; /* dimension and codebook size */ - float *vec; /* current vector */ - float *cb; /* vector codebook */ - float *cent; /* centroids for each codebook entry */ - int *n; /* number of vectors in this interval */ - int J; /* number of vectors in training set */ - int ind; /* index of current vector */ - float se; /* total squared error for this iteration */ - float var; /* variance */ - float var_1; /* previous variance */ - float delta; /* improvement in distortion */ - FILE *ftrain; /* file containing training set */ - FILE *fvq; /* file containing vector quantiser */ - int i,j, finished, iterations; - float sd; - int var_n, bits, b, levels; - - /* Interpret command line arguments */ - - if (argc < 5) { - printf("usage: %s TrainFile D(dimension) B(number of bits) VQFile [error.txt file]\n", argv[0]); - exit(1); - } - - /* Open training file */ - - ftrain = fopen(argv[1],"rb"); - if (ftrain == NULL) { - printf("Error opening training database file: %s\n",argv[1]); - exit(1); - } - - /* determine k and m, and allocate arrays */ - - d = atoi(argv[2]); - bits = atoi(argv[3]); - e = 1< 1) { - if (var > 0.0) { - delta = (var_1 - var)/var; - } - else - delta = 0; - if (delta < DELTAQ) - finished = 1; - } - - if (!finished) { - /* determine new codebook from centroids */ - - for(i=0; i