diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-04-07 12:29:46 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-04-07 12:29:46 +0000 |
commit | 3ade1510e72926d02d7c7d4416257449bc0cd3f3 (patch) | |
tree | c51d4960cac0fcd8bf3483a8e77444ac5f9a3177 /third_party/gsm/tst | |
parent | bfd3f58f5b715238fe618d053ddf908a34f1e56c (diff) |
Split speex, portaudio, and gsm into third_party directory
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/split-3rd-party@1168 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'third_party/gsm/tst')
-rw-r--r-- | third_party/gsm/tst/cod2lin.c | 104 | ||||
-rw-r--r-- | third_party/gsm/tst/cod2txt.c | 94 | ||||
-rw-r--r-- | third_party/gsm/tst/gsm2cod.c | 93 | ||||
-rw-r--r-- | third_party/gsm/tst/lin2cod.c | 105 | ||||
-rw-r--r-- | third_party/gsm/tst/lin2txt.c | 94 | ||||
-rw-r--r-- | third_party/gsm/tst/run | 34 |
6 files changed, 524 insertions, 0 deletions
diff --git a/third_party/gsm/tst/cod2lin.c b/third_party/gsm/tst/cod2lin.c new file mode 100644 index 00000000..07a95105 --- /dev/null +++ b/third_party/gsm/tst/cod2lin.c @@ -0,0 +1,104 @@ +/* + * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische + * Universitaet Berlin. See the accompanying file "COPYRIGHT" for + * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. + */ + +/*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/cod2lin.c,v 1.2 1996/07/02 14:33:10 jutta Exp jutta $*/ + +#include <stdio.h> +#include <assert.h> + +#include "gsm.h" +#include "proto.h" + +char * pname; + +int debug = 0; +int verbosity = 0; +int fast = 0; +int wav = 0; +int error = 0; + +usage P0() +{ + fprintf(stderr, "Usage: %s [-vwF] [files...]\n", pname); + exit(1); +} + +void process P2((f, filename), FILE * f, char * filename) +{ + gsm_frame buf; + gsm_signal source[160]; + + int cc; + gsm r; + + (void)memset(source, 0x00, sizeof(source)); + + if (!(r = gsm_create())) { + perror("gsm_create"); + error = 1; + return ; + } + gsm_option(r, GSM_OPT_VERBOSE, &verbosity); + gsm_option(r, GSM_OPT_FAST, &fast); + gsm_option(r, GSM_OPT_WAV49, &wav); + for (;;) { + cc = fread((char *)source, sizeof(*source), 76, f); + if (cc == 0) { + gsm_destroy(r); + return; + } + if (cc != 76) { + error = 1; + fprintf(stderr, + "%s: %s -- %d trailing bytes ignored\n", + pname, filename, cc); + gsm_destroy(r); + return; + } + + gsm_implode(r, source, buf); + gsm_decode(r, buf, source); + + if (write(1, source, sizeof(source)) != sizeof(source)) { + perror("write"); + error = 1; + gsm_destroy(r); + return; + } + } +} + +main P2((ac, av), int ac, char ** av) +{ + int opt; + extern char * optarg; + extern int optind; + + FILE * f; + + if (!(pname = av[0])) pname = "cod2out"; + + while ((opt = getopt(ac, av, "vwF")) != EOF) switch (opt) { + case 'v': verbosity++; break; + case 'w': wav++; break; + case 'F': fast++; break; + default: usage(); + } + + ac -= optind; + av += optind; + + if (!ac) process(stdin, "*stdin*"); + else for (; *av; av++) { + if (!(f = fopen(*av, "r"))) perror(*av); + else { + process(f, *av); + fclose(f); + } + } + + exit(error); +} diff --git a/third_party/gsm/tst/cod2txt.c b/third_party/gsm/tst/cod2txt.c new file mode 100644 index 00000000..71c362e0 --- /dev/null +++ b/third_party/gsm/tst/cod2txt.c @@ -0,0 +1,94 @@ +/* + * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische + * Universitaet Berlin. See the accompanying file "COPYRIGHT" for + * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. + */ + +/*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/cod2txt.c,v 1.1 1994/10/21 20:52:11 jutta Exp $*/ + +#include <stdio.h> +#include <assert.h> + +#include "gsm.h" +#include "proto.h" + +char * pname; + +int debug = 0; +int verbosity = 0; +int error = 0; + +usage P0() +{ + fprintf(stderr, "Usage: %s [files...]\n", pname); + exit(1); +} + +void process P2((f, filename), FILE * f, char * filename) +{ + gsm_frame buf; + gsm_signal source[160]; + + int cc; + gsm r; + int nr=0; + + (void)memset(source, 0, sizeof(source)); + + if (!(r = gsm_create())) { + perror("gsm_create"); + error = 1; + return ; + } + gsm_option(r, GSM_OPT_VERBOSE, &verbosity); + for (;;) { + cc = fread((char *)source, sizeof(*source), 76, f); + if (cc == 0) { + gsm_destroy(r); + return; + } + if (cc != 76) { + error = 1; + fprintf(stderr, + "%s: %s -- %d trailing bytes ignored\n", + pname, filename, cc); + gsm_destroy(r); + return; + } + + gsm_implode(r, source, buf); + printf("[%d] ", ++nr); + if (gsm_print(stdout, r, buf)) { + fprintf(stderr, + "%s: %s: bad magic\n", pname, filename); + gsm_destroy(r); + return; + + } + } +} + +main P2((ac, av), int ac, char ** av) +{ + int opt; + extern char * optarg; + extern int optind; + + FILE * f; + + if (!(pname = av[0])) pname = "cod2txt"; + + ac--; + av++; + + if (!ac) process(stdin, "*stdin*"); + else for (; *av; av++) { + if (!(f = fopen(*av, "r"))) perror(*av); + else { + process(f, *av); + fclose(f); + } + } + + exit(error); +} diff --git a/third_party/gsm/tst/gsm2cod.c b/third_party/gsm/tst/gsm2cod.c new file mode 100644 index 00000000..f2e7c2c6 --- /dev/null +++ b/third_party/gsm/tst/gsm2cod.c @@ -0,0 +1,93 @@ +/* + * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische + * Universitaet Berlin. See the accompanying file "COPYRIGHT" for + * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. + */ + +/*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/gsm2cod.c,v 1.1 1994/10/21 20:52:11 jutta Exp $*/ + +#include <stdio.h> +#include <assert.h> + +#include "gsm.h" +#include "proto.h" + +char * pname; + +int debug = 0; +int verbosity = 0; +int error = 0; + +usage P0() +{ + fprintf(stderr, "Usage: %s [files...]\n", pname); + exit(1); +} + +void process P2((f, filename), FILE * f, char * filename) +{ + gsm_frame buf; + gsm_signal source[76]; + + int cc; + gsm r; + int nr=0; + + (void)memset(source, 0, sizeof(source)); + + if (!(r = gsm_create())) { + perror("gsm_create"); + error = 1; + return ; + } + gsm_option(r, GSM_OPT_VERBOSE, &verbosity); + for (;;) { + cc = fread((char *)buf, sizeof(buf), 1, f); + if (cc == 0) { + gsm_destroy(r); + return; + } + if (cc != 1) { + error = 1; + fprintf(stderr, + "%s: %s -- trailing bytes ignored\n", + pname, filename); + gsm_destroy(r); + return; + } + + gsm_explode(r, buf, source); + if (write(1, (char *)source, sizeof(source))!= sizeof(source)) { + + perror("write"); + error = 1; + gsm_destroy(r); + return; + } + } +} + +main P2((ac, av), int ac, char ** av) +{ + int opt; + extern char * optarg; + extern int optind; + + FILE * f; + + if (!(pname = av[0])) pname = "gsm2cod"; + + ac--; + av++; + + if (!ac) process(stdin, "*stdin*"); + else for (; *av; av++) { + if (!(f = fopen(*av, "r"))) perror(*av); + else { + process(f, *av); + fclose(f); + } + } + + exit(error); +} diff --git a/third_party/gsm/tst/lin2cod.c b/third_party/gsm/tst/lin2cod.c new file mode 100644 index 00000000..2c42b10b --- /dev/null +++ b/third_party/gsm/tst/lin2cod.c @@ -0,0 +1,105 @@ +/* + * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische + * Universitaet Berlin. See the accompanying file "COPYRIGHT" for + * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. + */ + +/*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/lin2cod.c,v 1.2 1996/07/02 14:33:13 jutta Exp jutta $*/ + +#include <stdio.h> + +#include "gsm.h" +#include "proto.h" + +char * pname; + +int debug = 0; +int verbosity = 0; +int fast = 0; +int wav = 0; +int error = 0; + +usage P0() +{ + fprintf(stderr, "Usage: %s [-vwF] [files...]\n", pname); + exit(1); +} + +void process P2((f, filename), FILE * f, char * filename) +{ + gsm_frame buf; + short source[160]; + int cc; + gsm r; + + if (!(r = gsm_create())) { + perror("gsm_create"); + error = 1; + return ; + } + gsm_option(r, GSM_OPT_VERBOSE, &verbosity); + gsm_option(r, GSM_OPT_FAST, &fast); + gsm_option(r, GSM_OPT_WAV49, &wav); + for (;;) { + + if ((cc = fread((char *)source, 1, sizeof(source), f)) == 0) { + gsm_destroy(r); +#ifdef COUNT_OVERFLOW + dump_overflow(stderr); +#endif + return; + } + + if (cc != sizeof(source)) { + error = 1; + perror(filename); + fprintf(stderr, "%s: cannot read input from %s\n", + pname, filename); + gsm_destroy(r); + return; + } + + gsm_encode(r, source, buf); + gsm_explode(r, buf, source); /* 76 shorts */ + if (write(1, source, sizeof(*source) * 76) + != sizeof(*source) * 76) { + + perror("write"); + error = 1; + gsm_destroy(r); + return; + } + } +} + +main P2((ac, av), int ac, char ** av) +{ + int opt; + extern char * optarg; + extern int optind; + + FILE * f; + + if (!(pname = av[0])) pname = "inp2cod"; + + while ((opt = getopt(ac, av, "vwF")) != EOF) switch (opt) { + case 'v': verbosity++; break; + case 'w': wav++; break; + case 'F': fast++; break; + default: usage(); + } + + ac -= optind; + av += optind; + + if (!ac) process(stdin, "*stdin*"); + else for (; *av; av++) { + if (!(f = fopen(*av, "r"))) perror(*av); + else { + process(f, *av); + fclose(f); + } + } + + exit(error); +} diff --git a/third_party/gsm/tst/lin2txt.c b/third_party/gsm/tst/lin2txt.c new file mode 100644 index 00000000..fb39504c --- /dev/null +++ b/third_party/gsm/tst/lin2txt.c @@ -0,0 +1,94 @@ +/* + * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische + * Universitaet Berlin. See the accompanying file "COPYRIGHT" for + * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. + */ + +/*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/lin2txt.c,v 1.1 1994/10/21 20:52:11 jutta Exp $*/ + +#include <stdio.h> + +#include "gsm.h" +#include "proto.h" + +char * pname; + +int debug = 0; +int verbosity = 0; +int error = 0; + +usage P0() +{ + fprintf(stderr, "Usage: %s [-v] [files...]\n", pname); + exit(1); +} + +void process P2((f, filename), FILE * f, char * filename) +{ + short source[160]; + int cc, j, k; + gsm r; + + if (!(r = gsm_create())) { + perror("gsm_create"); + error = 1; + return ; + } + gsm_option(r, GSM_OPT_VERBOSE, &verbosity); + for (;;) { + + if ((cc = fread((char *)source, 1, sizeof(source), f)) == 0) { + gsm_destroy(r); +#ifdef COUNT_OVERFLOW + dump_overflow(stderr); +#endif + return; + } + + printf("{\t"); + for (j = 0; j < 4; j++) { + printf("{\t"); + for (k = 0; k < 40; k++) { + printf("%d", (int)source[ j * 40 + k ]); + if (k < 39) { + printf(", "); + if (k % 4 == 3) printf("\n\t\t"); + } else { + printf("\t}"); + if (j == 3) printf("\t},\n"); + else printf(",\n\t"); + } + } + } + } +} + +main P2((ac, av), int ac, char ** av) +{ + int opt; + extern char * optarg; + extern int optind; + + FILE * f; + + if (!(pname = av[0])) pname = "inp2txt"; + + while ((opt = getopt(ac, av, "v")) != EOF) switch (opt) { + case 'v': verbosity++; break; + default: usage(); + } + + ac -= optind; + av += optind; + + if (!ac) process(stdin, "*stdin*"); + else for (; *av; av++) { + if (!(f = fopen(*av, "r"))) perror(*av); + else { + process(f, *av); + fclose(f); + } + } + + exit(error); +} diff --git a/third_party/gsm/tst/run b/third_party/gsm/tst/run new file mode 100644 index 00000000..5eec3b2f --- /dev/null +++ b/third_party/gsm/tst/run @@ -0,0 +1,34 @@ +: +# +# Copyright 1992 by Jutta Degener and Carsten Bormann, Technische +# Universitaet Berlin. See the accompanying file "COPYRIGHT" for +# details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. +# +if [ ! -f 1.inp ] ; then + echo Sorry, but we cannot provide the test data with this release. + exit +fi + +echo -n 'Linear to code: ' +for i in 1 2 3 4 +do + echo -n $i.. + ./lin2cod < $i.inp | cmp - $i.cod +done +echo "" + +echo -n 'Code to linear: ' +for i in 1 2 3 4 +do + echo -n $i.. + ./cod2lin < $i.cod | cmp - $i.out +done +echo "" + +echo -n 'Toast: ' +for i in 1 2 3 4 +do + echo -n $i.. + ../bin/toast -l < $i.inp | ../bin/toast -dl | cmp - $i.out +done +echo "" |