summaryrefslogtreecommitdiff
path: root/apps/codecs/libspeex
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libspeex')
-rw-r--r--apps/codecs/libspeex/testdenoise.c44
-rw-r--r--apps/codecs/libspeex/testecho.c53
-rw-r--r--apps/codecs/libspeex/testenc.c142
-rw-r--r--apps/codecs/libspeex/testenc_uwb.c137
-rw-r--r--apps/codecs/libspeex/testenc_wb.c143
-rw-r--r--apps/codecs/libspeex/testresample.c86
6 files changed, 0 insertions, 605 deletions
diff --git a/apps/codecs/libspeex/testdenoise.c b/apps/codecs/libspeex/testdenoise.c
deleted file mode 100644
index 42644cb011..0000000000
--- a/apps/codecs/libspeex/testdenoise.c
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <speex/speex_preprocess.h>
-#include <stdio.h>
-
-#define NN 160
-
-int main()
-{
- short in[NN];
- int i;
- SpeexPreprocessState *st;
- int count=0;
- float f;
-
- st = speex_preprocess_state_init(NN, 8000);
- i=1;
- speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DENOISE, &i);
- i=0;
- speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC, &i);
- f=8000;
- speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC_LEVEL, &f);
- i=0;
- speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB, &i);
- f=.0;
- speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f);
- f=.0;
- speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
- while (1)
- {
- int vad;
- fread(in, sizeof(short), NN, stdin);
- if (feof(stdin))
- break;
- vad = speex_preprocess_run(st, in);
- /*fprintf (stderr, "%d\n", vad);*/
- fwrite(in, sizeof(short), NN, stdout);
- count++;
- }
- speex_preprocess_state_destroy(st);
- return 0;
-}
diff --git a/apps/codecs/libspeex/testecho.c b/apps/codecs/libspeex/testecho.c
deleted file mode 100644
index 7c32c8f60e..0000000000
--- a/apps/codecs/libspeex/testecho.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include "speex/speex_echo.h"
-#include "speex/speex_preprocess.h"
-
-
-#define NN 128
-#define TAIL 1024
-
-int main(int argc, char **argv)
-{
- int echo_fd, ref_fd, e_fd;
- short echo_buf[NN], ref_buf[NN], e_buf[NN];
- SpeexEchoState *st;
- SpeexPreprocessState *den;
-
- if (argc != 4)
- {
- fprintf (stderr, "testecho mic_signal.sw speaker_signal.sw output.sw\n");
- exit(1);
- }
- echo_fd = open (argv[2], O_RDONLY);
- ref_fd = open (argv[1], O_RDONLY);
- e_fd = open (argv[3], O_WRONLY | O_CREAT | O_TRUNC, 0644);
-
- st = speex_echo_state_init(NN, TAIL);
- den = speex_preprocess_state_init(NN, 8000);
- int tmp = 8000;
- speex_echo_ctl(st, SPEEX_ECHO_SET_SAMPLING_RATE, &tmp);
- speex_preprocess_ctl(den, SPEEX_PREPROCESS_SET_ECHO_STATE, st);
-
- while (read(ref_fd, ref_buf, NN*2))
- {
- read(echo_fd, echo_buf, NN*2);
- speex_echo_cancellation(st, ref_buf, echo_buf, e_buf);
- speex_preprocess_run(den, e_buf);
- write(e_fd, e_buf, NN*2);
- }
- speex_echo_state_destroy(st);
- speex_preprocess_state_destroy(den);
- close(e_fd);
- close(echo_fd);
- close(ref_fd);
- return 0;
-}
diff --git a/apps/codecs/libspeex/testenc.c b/apps/codecs/libspeex/testenc.c
deleted file mode 100644
index eabd02cc76..0000000000
--- a/apps/codecs/libspeex/testenc.c
+++ /dev/null
@@ -1,142 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <speex/speex.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <speex/speex_callbacks.h>
-
-#ifdef FIXED_DEBUG
-extern long long spx_mips;
-#endif
-
-#define FRAME_SIZE 160
-#include <math.h>
-int main(int argc, char **argv)
-{
- char *inFile, *outFile, *bitsFile;
- FILE *fin, *fout, *fbits=NULL;
- short in_short[FRAME_SIZE];
- short out_short[FRAME_SIZE];
- float sigpow,errpow,snr, seg_snr=0;
- int snr_frames = 0;
- char cbits[200];
- int nbBits;
- int i;
- void *st;
- void *dec;
- SpeexBits bits;
- spx_int32_t tmp;
- int bitCount=0;
- spx_int32_t skip_group_delay;
- SpeexCallback callback;
-
- sigpow = 0;
- errpow = 0;
-
- st = speex_encoder_init(&speex_nb_mode);
- dec = speex_decoder_init(&speex_nb_mode);
-
- /* BEGIN: You probably don't need the following in a real application */
- callback.callback_id = SPEEX_INBAND_CHAR;
- callback.func = speex_std_char_handler;
- callback.data = stderr;
- speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
-
- callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
- callback.func = speex_std_mode_request_handler;
- callback.data = st;
- speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
- /* END of unnecessary stuff */
-
- tmp=1;
- speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
- tmp=0;
- speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
- tmp=8;
- speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
- tmp=1;
- speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
-
- /* Turn this off if you want to measure SNR (on by default) */
- tmp=1;
- speex_encoder_ctl(st, SPEEX_SET_HIGHPASS, &tmp);
- speex_decoder_ctl(dec, SPEEX_SET_HIGHPASS, &tmp);
-
- speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay);
- speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp);
- skip_group_delay += tmp;
-
- if (argc != 4 && argc != 3)
- {
- fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
- exit(1);
- }
- inFile = argv[1];
- fin = fopen(inFile, "r");
- outFile = argv[2];
- fout = fopen(outFile, "w+");
- if (argc==4)
- {
- bitsFile = argv[3];
- fbits = fopen(bitsFile, "w");
- }
- speex_bits_init(&bits);
- while (!feof(fin))
- {
- fread(in_short, sizeof(short), FRAME_SIZE, fin);
- if (feof(fin))
- break;
- speex_bits_reset(&bits);
-
- speex_encode_int(st, in_short, &bits);
- nbBits = speex_bits_write(&bits, cbits, 200);
- bitCount+=bits.nbBits;
-
- if (argc==4)
- fwrite(cbits, 1, nbBits, fbits);
- speex_bits_rewind(&bits);
-
- speex_decode_int(dec, &bits, out_short);
- speex_bits_reset(&bits);
-
- fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
- skip_group_delay = 0;
- }
- fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
- speex_encoder_destroy(st);
- speex_decoder_destroy(dec);
- speex_bits_destroy(&bits);
-
- /* This code just computes SNR, so you don't need it either */
- rewind(fin);
- rewind(fout);
-
- while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin)
- &&
- FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) )
- {
- float s=0, e=0;
- for (i=0;i<FRAME_SIZE;++i) {
- s += (float)in_short[i] * in_short[i];
- e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
- }
- seg_snr += 10*log10((s+160)/(e+160));
- sigpow += s;
- errpow += e;
- snr_frames++;
- }
- fclose(fin);
- fclose(fout);
-
- snr = 10 * log10( sigpow / errpow );
- seg_snr /= snr_frames;
- fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
-
-#ifdef FIXED_DEBUG
- printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
-#endif
-
- return 0;
-}
diff --git a/apps/codecs/libspeex/testenc_uwb.c b/apps/codecs/libspeex/testenc_uwb.c
deleted file mode 100644
index e9bf18a667..0000000000
--- a/apps/codecs/libspeex/testenc_uwb.c
+++ /dev/null
@@ -1,137 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <speex/speex.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <speex/speex_callbacks.h>
-
-#ifdef FIXED_DEBUG
-extern long long spx_mips;
-#endif
-
-#define FRAME_SIZE 640
-#include <math.h>
-int main(int argc, char **argv)
-{
- char *inFile, *outFile, *bitsFile;
- FILE *fin, *fout, *fbits=NULL;
- short in_short[FRAME_SIZE];
- short out_short[FRAME_SIZE];
- float in_float[FRAME_SIZE];
- float sigpow,errpow,snr, seg_snr=0;
- int snr_frames = 0;
- char cbits[200];
- int nbBits;
- int i;
- void *st;
- void *dec;
- SpeexBits bits;
- spx_int32_t tmp;
- int bitCount=0;
- spx_int32_t skip_group_delay;
- SpeexCallback callback;
-
- sigpow = 0;
- errpow = 0;
-
- st = speex_encoder_init(&speex_uwb_mode);
- dec = speex_decoder_init(&speex_uwb_mode);
-
- callback.callback_id = SPEEX_INBAND_CHAR;
- callback.func = speex_std_char_handler;
- callback.data = stderr;
- speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
-
- callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
- callback.func = speex_std_mode_request_handler;
- callback.data = st;
- speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
-
- tmp=0;
- speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
- tmp=0;
- speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
- tmp=7;
- speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
- tmp=1;
- speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
-
- speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay);
- speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp);
- skip_group_delay += tmp;
-
-
- if (argc != 4 && argc != 3)
- {
- fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
- exit(1);
- }
- inFile = argv[1];
- fin = fopen(inFile, "r");
- outFile = argv[2];
- fout = fopen(outFile, "w+");
- if (argc==4)
- {
- bitsFile = argv[3];
- fbits = fopen(bitsFile, "w");
- }
- speex_bits_init(&bits);
- while (!feof(fin))
- {
- fread(in_short, sizeof(short), FRAME_SIZE, fin);
- if (feof(fin))
- break;
- for (i=0;i<FRAME_SIZE;i++)
- in_float[i]=in_short[i];
- speex_bits_reset(&bits);
-
- speex_encode_int(st, in_short, &bits);
- nbBits = speex_bits_write(&bits, cbits, 200);
- bitCount+=bits.nbBits;
-
- if (argc==4)
- fwrite(cbits, 1, nbBits, fbits);
- speex_bits_rewind(&bits);
-
- speex_decode_int(dec, &bits, out_short);
- speex_bits_reset(&bits);
-
- fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
- skip_group_delay = 0;
- }
- fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
- speex_encoder_destroy(st);
- speex_decoder_destroy(dec);
-
- rewind(fin);
- rewind(fout);
-
- while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin)
- &&
- FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) )
- {
- float s=0, e=0;
- for (i=0;i<FRAME_SIZE;++i) {
- s += (float)in_short[i] * in_short[i];
- e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
- }
- seg_snr += 10*log10((s+1)/(e+1));
- sigpow += s;
- errpow += e;
- snr_frames++;
- }
- fclose(fin);
- fclose(fout);
-
- snr = 10 * log10( sigpow / errpow );
- seg_snr /= snr_frames;
- fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
-
-#ifdef FIXED_DEBUG
- printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
-#endif
-
- return 1;
-}
diff --git a/apps/codecs/libspeex/testenc_wb.c b/apps/codecs/libspeex/testenc_wb.c
deleted file mode 100644
index 8e515cb13c..0000000000
--- a/apps/codecs/libspeex/testenc_wb.c
+++ /dev/null
@@ -1,143 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <speex/speex.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <speex/speex_callbacks.h>
-
-#ifdef FIXED_DEBUG
-extern long long spx_mips;
-#endif
-
-#define FRAME_SIZE 320
-#include <math.h>
-int main(int argc, char **argv)
-{
- char *inFile, *outFile, *bitsFile;
- FILE *fin, *fout, *fbits=NULL;
- short in_short[FRAME_SIZE];
- short out_short[FRAME_SIZE];
- float in_float[FRAME_SIZE];
- float sigpow,errpow,snr, seg_snr=0;
- int snr_frames = 0;
- char cbits[200];
- int nbBits;
- int i;
- void *st;
- void *dec;
- SpeexBits bits;
- spx_int32_t tmp;
- int bitCount=0;
- spx_int32_t skip_group_delay;
- SpeexCallback callback;
-
- sigpow = 0;
- errpow = 0;
-
- st = speex_encoder_init(&speex_wb_mode);
- dec = speex_decoder_init(&speex_wb_mode);
-
- callback.callback_id = SPEEX_INBAND_CHAR;
- callback.func = speex_std_char_handler;
- callback.data = stderr;
- speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
-
- callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
- callback.func = speex_std_mode_request_handler;
- callback.data = st;
- speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
-
- tmp=1;
- speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
- tmp=0;
- speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
- tmp=8;
- speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
- tmp=3;
- speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
- /*tmp=3;
- speex_encoder_ctl(st, SPEEX_SET_HIGH_MODE, &tmp);
- tmp=6;
- speex_encoder_ctl(st, SPEEX_SET_LOW_MODE, &tmp);
-*/
-
- speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay);
- speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp);
- skip_group_delay += tmp;
-
-
- if (argc != 4 && argc != 3)
- {
- fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
- exit(1);
- }
- inFile = argv[1];
- fin = fopen(inFile, "r");
- outFile = argv[2];
- fout = fopen(outFile, "w+");
- if (argc==4)
- {
- bitsFile = argv[3];
- fbits = fopen(bitsFile, "w");
- }
- speex_bits_init(&bits);
- while (!feof(fin))
- {
- fread(in_short, sizeof(short), FRAME_SIZE, fin);
- if (feof(fin))
- break;
- for (i=0;i<FRAME_SIZE;i++)
- in_float[i]=in_short[i];
- speex_bits_reset(&bits);
-
- speex_encode_int(st, in_short, &bits);
- nbBits = speex_bits_write(&bits, cbits, 200);
- bitCount+=bits.nbBits;
-
- if (argc==4)
- fwrite(cbits, 1, nbBits, fbits);
- speex_bits_rewind(&bits);
-
- speex_decode_int(dec, &bits, out_short);
- speex_bits_reset(&bits);
-
- fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
- skip_group_delay = 0;
- }
- fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
- speex_encoder_destroy(st);
- speex_decoder_destroy(dec);
- speex_bits_destroy(&bits);
-
- rewind(fin);
- rewind(fout);
-
- while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin)
- &&
- FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) )
- {
- float s=0, e=0;
- for (i=0;i<FRAME_SIZE;++i) {
- s += (float)in_short[i] * in_short[i];
- e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
- }
- seg_snr += 10*log10((s+160)/(e+160));
- sigpow += s;
- errpow += e;
- snr_frames++;
- }
- fclose(fin);
- fclose(fout);
-
- snr = 10 * log10( sigpow / errpow );
- seg_snr /= snr_frames;
- fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
-
-#ifdef FIXED_DEBUG
- printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
-#endif
-
- return 1;
-}
diff --git a/apps/codecs/libspeex/testresample.c b/apps/codecs/libspeex/testresample.c
deleted file mode 100644
index 71392cc011..0000000000
--- a/apps/codecs/libspeex/testresample.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Copyright (C) 2007 Jean-Marc Valin
-
- File: testresample.c
- Testing the resampling code
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include "speex/speex_resampler.h"
-#include <math.h>
-#include <stdlib.h>
-
-#define NN 256
-
-int main()
-{
- spx_uint32_t i;
- short *in;
- short *out;
- float *fin, *fout;
- int count = 0;
- SpeexResamplerState *st = speex_resampler_init(1, 8000, 12000, 10, NULL);
- speex_resampler_set_rate(st, 96000, 44100);
- speex_resampler_skip_zeros(st);
-
- in = malloc(NN*sizeof(short));
- out = malloc(2*NN*sizeof(short));
- fin = malloc(NN*sizeof(float));
- fout = malloc(2*NN*sizeof(float));
- while (1)
- {
- spx_uint32_t in_len;
- spx_uint32_t out_len;
- fread(in, sizeof(short), NN, stdin);
- if (feof(stdin))
- break;
- for (i=0;i<NN;i++)
- fin[i]=in[i];
- in_len = NN;
- out_len = 2*NN;
- /*if (count==2)
- speex_resampler_set_quality(st, 10);*/
- speex_resampler_process_float(st, 0, fin, &in_len, fout, &out_len);
- for (i=0;i<out_len;i++)
- out[i]=floor(.5+fout[i]);
- /*speex_warning_int("writing", out_len);*/
- fwrite(out, sizeof(short), out_len, stdout);
- count++;
- }
- speex_resampler_destroy(st);
- free(in);
- free(out);
- free(fin);
- free(fout);
- return 0;
-}
-