diff options
author | erdgeist@erdgeist.org <erdgeist@bauklotz.fritz.box> | 2019-07-04 23:26:09 +0200 |
---|---|---|
committer | erdgeist@erdgeist.org <erdgeist@bauklotz.fritz.box> | 2019-07-04 23:26:09 +0200 |
commit | f02dfce6e6c34b3d8a7b8a0e784b506178e331fa (patch) | |
tree | 45556e6104242d4702689760433d7321ae74ec17 /stripdown.sh |
stripdown of version 0.9
Diffstat (limited to 'stripdown.sh')
-rwxr-xr-x | stripdown.sh | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/stripdown.sh b/stripdown.sh new file mode 100755 index 0000000..2e4466e --- /dev/null +++ b/stripdown.sh | |||
@@ -0,0 +1,120 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | BUILDDIR=build_stripped | ||
4 | DESTDIR=codec2lite | ||
5 | |||
6 | LIBSRC="codebook.c codebookd.c codebookge.c codebookjvm.c codebooknewamp1.c codebooknewamp1_energy.c codec2.c codec2_fft.c interp.c kiss_fft.c kiss_fftr.c lpc.c lsp.c mbest.c newamp1.c newamp2.c nlp.c pack.c phase.c postfilter.c quantise.c sine.c" | ||
7 | LIBGENSRC="codebooklspmelvq.c codebookmel.c codebooknewamp2.c codebooknewamp2_energy.c" | ||
8 | |||
9 | LIBINC="_kiss_fft_guts.h comp_prim.h lpc.h os.h bpf.h lsp.h phase.h bpfb.h defines.h machdep.h postfilter.h mbest.h quantise.h codec2_fft.h interp.h newamp1.h sine.h codec2_internal.h kiss_fft.h newamp2.h comp.h kiss_fftr.h nlp.h" | ||
10 | LIBGENINC="version.h" | ||
11 | |||
12 | EMPTYINC="c2wideband.h dump.h" | ||
13 | |||
14 | rm -rf "${BUILDDIR}" "${DESTDIR}" | ||
15 | mkdir "${BUILDDIR}" "${DESTDIR}" | ||
16 | |||
17 | # copy LICENSE | ||
18 | cp COPYING "${DESTDIR}"/ | ||
19 | |||
20 | # copy static sources | ||
21 | for file in ${LIBSRC} ${LIBINC}; do | ||
22 | cp src/"${file}" "${DESTDIR}"/ | ||
23 | done | ||
24 | |||
25 | # fixup one include | ||
26 | sed s:codec2/version.h:version.h: src/codec2.h > "${DESTDIR}"/codec2.h | ||
27 | |||
28 | cat > "${DESTDIR}"/debug_alloc.h <<'EOF' | ||
29 | #define FREE free | ||
30 | #define MALLOC malloc | ||
31 | EOF | ||
32 | |||
33 | for file in ${EMPTYINC}; do | ||
34 | touch "${DESTDIR}"/"${file}" | ||
35 | done | ||
36 | |||
37 | cd ${BUILDDIR} | ||
38 | cmake .. | ||
39 | make tnewamp1 | ||
40 | |||
41 | # copy generated files | ||
42 | for file in ${LIBGENSRC}; do | ||
43 | cp src/"${file}" ../"${DESTDIR}"/ | ||
44 | done | ||
45 | |||
46 | for file in ${LIBGENINC}; do | ||
47 | cp codec2/"${file}" ../"${DESTDIR}"/ | ||
48 | done | ||
49 | |||
50 | cd .. | ||
51 | rm -r "${BUILDDIR}" | ||
52 | |||
53 | cat > "${DESTDIR}"/Makefile <<'EOF' | ||
54 | CFLAGS = -Wall -Wno-strict-overflow -std=gnu11 -fPIC -g -O2 -I. | ||
55 | CFLAGS += -DHORUS_L2_RX -DINTERLEAVER -DRUN_TIME_TABLES -DSCRAMBLER -Dcodec2_EXPORTS | ||
56 | CFLAGS += -Wno-incompatible-pointer-types-discards-qualifiers | ||
57 | |||
58 | LIBSRC=codebook.c codebookd.c codebookge.c codebookmel.c codebooklspmelvq.c codebookjvm.c \ | ||
59 | codebooknewamp1.c codebooknewamp1_energy.c codebooknewamp2.c codebooknewamp2_energy.c \ | ||
60 | codec2.c codec2_fft.c interp.c kiss_fft.c kiss_fftr.c lpc.c lsp.c mbest.c \ | ||
61 | newamp1.c newamp2.c nlp.c pack.c phase.c postfilter.c quantise.c sine.c | ||
62 | |||
63 | all: main | ||
64 | |||
65 | main: main.c $(LIBSRC) | ||
66 | clang $(CFLAGS) -o $@ $^ | ||
67 | |||
68 | .PHONY: clean | ||
69 | clean: | ||
70 | rm -f main | ||
71 | EOF | ||
72 | |||
73 | cat > "${DESTDIR}"/main.c <<'EOF' | ||
74 | #include <time.h> | ||
75 | #include <stdio.h> | ||
76 | |||
77 | #include "codec2.h" | ||
78 | |||
79 | int main() { | ||
80 | struct timespec tstart={0,0}, tend={0,0}; | ||
81 | short input[976692]; | ||
82 | FILE * recoded = fopen("count-recoded.raw", "w+"); | ||
83 | FILE * f = fopen("count.raw", "r"); | ||
84 | void * codec2 = codec2_create(CODEC2_MODE_700C); | ||
85 | int nsam = codec2_samples_per_frame(codec2); | ||
86 | int nbit = codec2_bits_per_frame(codec2); | ||
87 | int off = 0; | ||
88 | unsigned char bits[128]; | ||
89 | |||
90 | fread(input, 976692, 1, f); | ||
91 | fclose(f); | ||
92 | |||
93 | clock_gettime(CLOCK_MONOTONIC, &tstart); | ||
94 | |||
95 | while (off < 976692 / 2) { | ||
96 | codec2_encode(codec2, bits, input + off); | ||
97 | codec2_decode(codec2, input + off, bits); | ||
98 | off += 320; | ||
99 | } | ||
100 | |||
101 | clock_gettime(CLOCK_MONOTONIC, &tend); | ||
102 | printf("%lf\n", ((double)tend.tv_sec + 1.0e-9*tend.tv_nsec) - ((double)tstart.tv_sec + 1.0e-9*tstart.tv_nsec)); | ||
103 | |||
104 | fwrite(input, 976692, 1, recoded); | ||
105 | |||
106 | codec2_destroy(codec2); | ||
107 | } | ||
108 | EOF | ||
109 | |||
110 | cat > ${DESTDIR}/README <<'EOF' | ||
111 | |||
112 | This project is meant to generate a subset of the amazing codec2 library containing only the actual speech codec and having no further dependencies than a C99 compiler. | ||
113 | |||
114 | The generate a stripped down version of codec2 that does not need CMake etc, just copy the stripdown.sh file to your codec2 directory and run it. This will generate the directory you see here. | ||
115 | |||
116 | Codec 2 is an open source (LGPL 2.1) low bit rate speech codec: | ||
117 | |||
118 | http://rowetel.com/codec2.html | ||
119 | |||
120 | EOF | ||