From c87f901cfd9a5729273c18156e487a9634819610 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 21 Jul 2008 14:47:41 +0000 Subject: Remove libresample from the Asterisk source tree. It is now available in its own repository, and must be installed like any other library for Asterisk to use. The two modules that require it are codec_resample and app_jack. To install libresample: $ svn co http://svn.digium.com/svn/libresample/trunk libresample $ cd libresample $ ./configure $ make $ sudo make install This code is currently in our own repository because the build system did not include the appropriate targets for building a dynamic library or for installing the library. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@132390 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/libresample/tests/compareresample.c | 183 ------------------------- main/libresample/tests/resample-sndfile.c | 213 ------------------------------ main/libresample/tests/testresample.c | 182 ------------------------- 3 files changed, 578 deletions(-) delete mode 100644 main/libresample/tests/compareresample.c delete mode 100644 main/libresample/tests/resample-sndfile.c delete mode 100644 main/libresample/tests/testresample.c (limited to 'main/libresample/tests') diff --git a/main/libresample/tests/compareresample.c b/main/libresample/tests/compareresample.c deleted file mode 100644 index 8773c9d4e..000000000 --- a/main/libresample/tests/compareresample.c +++ /dev/null @@ -1,183 +0,0 @@ -/********************************************************************** - - compareresample.c - - Real-time library interface by Dominic Mazzoni - - Based on resample-1.7: - http://www-ccrma.stanford.edu/~jos/resample/ - - License: LGPL - see the file LICENSE.txt for more information - -**********************************************************************/ - -#include "../include/libresample.h" - -#include - -#include -#include -#include - -#include - -#define MIN(A, B) (A) < (B)? (A) : (B) - -void dostat(char *name, float *d1, float *d2, int len) -{ - int i; - double sum, sumsq, err, rmserr; - - sum = 0.0; - sumsq = 0.0; - for(i=0; i= 0) - out += o; - if (o < 0 || (o == 0 && srcpos == srclen)) - break; - } - resample_close(handle); - - gettimeofday(&tv1, NULL); - deltat = - (tv1.tv_sec + tv1.tv_usec * 0.000001) - - (tv0.tv_sec + tv0.tv_usec * 0.000001); - - if (o < 0) { - printf("Error: resample_process returned an error: %d\n", o); - } - - if (out <= 0) { - printf("Error: resample_process returned %d samples\n", out); - free(dst_rs); - return; - } - - printf(" resample: %.3f seconds, %d outputs\n", deltat, out); - - /* do rabbit (Erik's libsamplerate) */ - - for(i=0; i 0) - statlen = MIN(statlen, anslen); - - if (ans) { - dostat("resample ", dst_rs, ans, statlen); - dostat("rabbit ", dst_rabbit, ans, statlen); - } - dostat( "RS vs rabbit", dst_rs, dst_rabbit, statlen); - - free(dst_rs); - free(dst_rabbit); -} - -int main(int argc, char **argv) -{ - int i, srclen; - float *src, *ans; - - printf("\n*** sin wave, factor = 1.0 *** \n\n"); - srclen = 100000; - src = malloc(srclen * sizeof(float)); - for(i=0; i - -#include -#include -#include -#include - -#include - -#define MIN(A, B) (A) < (B)? (A) : (B) - -void usage(char *progname) -{ - fprintf(stderr, "Usage: %s -by \n", progname); - fprintf(stderr, " %s -to \n", progname); - fprintf(stderr, "\n"); - exit(-1); -} - -int main(int argc, char **argv) -{ - SNDFILE *srcfile, *dstfile; - SF_INFO srcinfo, dstinfo; - SF_FORMAT_INFO formatinfo; - char *extension; - void **handle; - int channels; - int srclen, dstlen; - float *src, *srci; - float *dst, *dsti; - double ratio = 0.0; - double srcrate; - double dstrate = 0.0; - struct timeval tv0, tv1; - double deltat; - int numformats; - int pos, bufferpos, outcount; - int i, c; - - if (argc != 5) - usage(argv[0]); - - if (!strcmp(argv[1], "-by")) { - ratio = atof(argv[2]); - if (ratio <= 0.0) { - fprintf(stderr, "Ratio of %f is illegal\n", ratio); - usage(argv[0]); - } - } - else if (!strcmp(argv[1], "-to")) { - dstrate = atof(argv[2]); - if (dstrate < 10.0 || dstrate > 100000.0) { - fprintf(stderr, "Sample rate of %f is illegal\n", dstrate); - usage(argv[0]); - } - } - else - usage(argv[0]); - - memset(&srcinfo, 0, sizeof(srcinfo)); - memset(&dstinfo, 0, sizeof(dstinfo)); - srcfile = sf_open(argv[3], SFM_READ, &srcinfo); - if (!srcfile) { - fprintf(stderr, "%s", sf_strerror(NULL)); - exit(-1); - } - - srcrate = srcinfo.samplerate; - if (dstrate == 0.0) - dstrate = srcrate * ratio; - else - ratio = dstrate / srcrate; - - channels = srcinfo.channels; - - /* figure out format of destination file */ - - extension = strstr(argv[4], "."); - if (extension) { - extension++; - sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, - &numformats, sizeof(numformats)); - for(i=0; i= 1) - dsti[i*channels+c] = 1; - else - dsti[i*channels+c] = dst[i]; - } - } - - sf_writef_float(dstfile, dsti, out); - - bufferpos = block - inUsed; - for(i=0; i -#include -#include - -#define MIN(A, B) (A) < (B)? (A) : (B) - -void runtest(int srclen, double freq, double factor, - int srcblocksize, int dstblocksize) -{ - int expectedlen = (int)(srclen * factor); - int dstlen = expectedlen + 1000; - float *src = (float *)malloc((srclen+100) * sizeof(float)); - float *dst = (float *)malloc((dstlen+100) * sizeof(float)); - void *handle; - double sum, sumsq, err, rmserr; - int i, out, o, srcused, errcount, rangecount; - int statlen, srcpos, lendiff; - int fwidth; - - printf("-- srclen: %d sin freq: %.1f factor: %.3f srcblk: %d dstblk: %d\n", - srclen, freq, factor, srcblocksize, dstblocksize); - - for(i=0; i= 0) - out += o; - if (o < 0 || (o == 0 && srcpos == srclen)) - break; - } - resample_close(handle); - - if (o < 0) { - printf("Error: resample_process returned an error: %d\n", o); - } - - if (out <= 0) { - printf("Error: resample_process returned %d samples\n", out); - free(src); - free(dst); - return; - } - - lendiff = abs(out - expectedlen); - if (lendiff > (int)(2*factor + 1.0)) { - printf(" Expected ~%d, got %d samples out\n", - expectedlen, out); - } - - sum = 0.0; - sumsq = 0.0; - errcount = 0.0; - - /* Don't compute statistics on all output values; the last few - are guaranteed to be off because it's based on far less - interpolation. */ - statlen = out - fwidth; - - for(i=0; i 0.05) { - if (errcount == 0) - printf(" First error at i=%d: expected %.3f, got %.3f\n", - i, sin((i/freq)/factor), dst[i]); - errcount++; - } - sum += fabs(diff); - sumsq += diff * diff; - } - - rangecount = 0; - for(i=0; i 1.01) { - if (rangecount == 0) - printf(" Error at i=%d: value is %.3f\n", i, dst[i]); - rangecount++; - } - } - if (rangecount > 1) - printf(" At least %d samples were out of range\n", rangecount); - - if (errcount > 0) { - i = out - 1; - printf(" i=%d: expected %.3f, got %.3f\n", - i, sin((i/freq)/factor), dst[i]); - printf(" At least %d samples had significant error.\n", errcount); - } - err = sum / statlen; - rmserr = sqrt(sumsq / statlen); - printf(" Out: %d samples Avg err: %f RMS err: %f\n", out, err, rmserr); - free(src); - free(dst); -} - -int main(int argc, char **argv) -{ - int i, srclen, dstlen, ifreq; - double factor; - - printf("\n*** Vary source block size*** \n\n"); - srclen = 10000; - ifreq = 100; - for(i=0; i<20; i++) { - factor = ((rand() % 16) + 1) / 4.0; - dstlen = (int)(srclen * factor + 10); - runtest(srclen, (double)ifreq, factor, 64, dstlen); - runtest(srclen, (double)ifreq, factor, 32, dstlen); - runtest(srclen, (double)ifreq, factor, 8, dstlen); - runtest(srclen, (double)ifreq, factor, 2, dstlen); - runtest(srclen, (double)ifreq, factor, srclen, dstlen); - } - - printf("\n*** Vary dest block size ***\n\n"); - srclen = 10000; - ifreq = 100; - for(i=0; i<20; i++) { - factor = ((rand() % 16) + 1) / 4.0; - runtest(srclen, (double)ifreq, factor, srclen, 32); - dstlen = (int)(srclen * factor + 10); - runtest(srclen, (double)ifreq, factor, srclen, dstlen); - } - - printf("\n*** Resample factor 1.0, testing different srclen ***\n\n"); - ifreq = 40; - for(i=0; i<100; i++) { - srclen = (rand() % 30000) + 10; - dstlen = (int)(srclen + 10); - runtest(srclen, (double)ifreq, 1.0, srclen, dstlen); - } - - printf("\n*** Resample factor 1.0, testing different sin freq ***\n\n"); - srclen = 10000; - for(i=0; i<100; i++) { - ifreq = ((int)rand() % 10000) + 1; - dstlen = (int)(srclen * 10); - runtest(srclen, (double)ifreq, 1.0, srclen, dstlen); - } - - printf("\n*** Resample with different factors ***\n\n"); - srclen = 10000; - ifreq = 100; - for(i=0; i<100; i++) { - factor = ((rand() % 64) + 1) / 4.0; - dstlen = (int)(srclen * factor + 10); - runtest(srclen, (double)ifreq, factor, srclen, dstlen); - } - - return 0; -} -- cgit v1.2.3