Mercurial > hg > audiostuff
annotate spandsp-0.0.6pre17/tests/gsm0610_tests.c @ 6:22a74b01a099 default tip
implement more meaningful test program
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 16:14:50 +0200 |
parents | 26cd8f1ef0b1 |
children |
rev | line source |
---|---|
4
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
1 /* |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
2 * SpanDSP - a series of DSP components for telephony |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
3 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
4 * gsm0610_tests.c - Test the GSM 06.10 FR codec. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
5 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
6 * Written by Steve Underwood <steveu@coppice.org> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
7 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
8 * Copyright (C) 2006 Steve Underwood |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
9 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
10 * All rights reserved. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
11 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License version 2, as |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
14 * published by the Free Software Foundation. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
15 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
16 * This program is distributed in the hope that it will be useful, |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
19 * GNU General Public License for more details. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
20 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
21 * You should have received a copy of the GNU General Public License |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
22 * along with this program; if not, write to the Free Software |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
24 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
25 * $Id: gsm0610_tests.c,v 1.25 2009/05/30 15:23:13 steveu Exp $ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
26 */ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
27 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
28 /*! \file */ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
29 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
30 /*! \page gsm0610_tests_page GSM 06.10 full rate codec tests |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
31 \section gsm0610_tests_page_sec_1 What does it do? |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
32 Two sets of tests are performed: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
33 - The tests defined in the GSM 06.10 specification, using the test data files supplied with |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
34 the specification. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
35 - A generally audio quality test, consisting of compressing and decompressing a speeech |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
36 file for audible comparison. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
37 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
38 \section gsm0610_tests_page_sec_2 How is it used? |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
39 To perform the tests in the GSM 06.10 specification you need to obtain the test data files from the |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
40 specification. These are copyright material, and so cannot be distributed with this test software. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
41 They can, however, be freely downloaded from the ETSI web site. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
42 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
43 The files, containing test vectors, which are supplied with the GSM 06.10 specification, should be |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
44 copied to etsitests/gsm0610/unpacked so the files are arranged in the following directories. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
45 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
46 ./fr_A: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
47 Seq01-A.cod Seq01-A.inp Seq01-A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
48 Seq02-A.cod Seq02-A.inp Seq02-A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
49 Seq03-A.cod Seq03-A.inp Seq03-A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
50 Seq04-A.cod Seq04-A.inp Seq04-A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
51 Seq05-A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
52 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
53 ./fr_L: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
54 Seq01.cod Seq01.inp Seq01.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
55 Seq02.cod Seq02.inp Seq02.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
56 Seq03.cod Seq03.inp Seq03.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
57 Seq04.cod Seq04.inp Seq04.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
58 Seq05.cod Seq05.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
59 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
60 ./fr_U: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
61 Seq01-U.cod Seq01-U.inp Seq01-U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
62 Seq02-U.cod Seq02-U.inp Seq02-U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
63 Seq03-U.cod Seq03-U.inp Seq03-U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
64 Seq04-U.cod Seq04-U.inp Seq04-U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
65 Seq05-U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
66 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
67 ./fr_homing_A: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
68 Homing01_A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
69 Seq01H_A.cod Seq01H_A.inp Seq01H_A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
70 Seq02H_A.cod Seq02H_A.inp Seq02H_A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
71 Seq03H_A.cod Seq03H_A.inp Seq03H_A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
72 Seq04H_A.cod Seq04H_A.inp Seq04H_A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
73 Seq05H_A.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
74 Seq06H_A.cod Seq06H_A.inp |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
75 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
76 ./fr_homing_L: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
77 Homing01.cod Homing01.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
78 Seq01h.cod Seq01h.inp Seq01h.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
79 Seq02h.cod Seq02h.inp Seq02h.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
80 Seq03h.cod Seq03h.inp Seq03h.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
81 Seq04h.cod Seq04h.inp Seq04h.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
82 Seq05h.cod Seq05h.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
83 Seq06h.cod Seq06h.inp |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
84 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
85 ./fr_homing_U: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
86 Homing01_U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
87 Seq01H_U.cod Seq01H_U.inp Seq01H_U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
88 Seq02H_U.cod Seq02H_U.inp Seq02H_U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
89 Seq03H_U.cod Seq03H_U.inp Seq03H_U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
90 Seq04H_U.cod Seq04H_U.inp Seq04H_U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
91 Seq05H_U.out |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
92 Seq06H_U.cod Seq06H_U.inp |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
93 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
94 ./fr_sync_A: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
95 Seqsync_A.inp |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
96 Sync000_A.cod --to-- Sync159_A.cod |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
97 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
98 ./fr_sync_L: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
99 Bitsync.inp |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
100 Seqsync.inp |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
101 Sync000.cod --to-- Sync159.cod |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
102 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
103 ./fr_sync_U: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
104 Seqsync_U.inp |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
105 Sync000_U.cod --to-- Sync159_U.cod |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
106 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
107 This is different from the directory structure in which they are supplied. Also, the files names are a little |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
108 different. The supplied names are messy, and inconsistent across the sets. The names required by these tests |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
109 just clean up these inconsistencies. Note that you will need a Windows machine to unpack some of the supplied |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
110 files. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
111 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
112 To perform a general audio quality test, gsm0610_tests should be run. The file ../test-data/local/short_nb_voice.wav |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
113 will be compressed to GSM 06.10 data, decompressed, and the resulting audio stored in post_gsm0610.wav. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
114 */ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
115 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
116 #if defined(HAVE_CONFIG_H) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
117 #include "config.h" |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
118 #endif |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
119 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
120 #include <stdlib.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
121 #include <stdio.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
122 #include <fcntl.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
123 #include <unistd.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
124 #include <string.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
125 #include <ctype.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
126 #include <sndfile.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
127 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
128 //#if defined(WITH_SPANDSP_INTERNALS) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
129 #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
130 //#endif |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
131 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
132 #include "spandsp.h" |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
133 #include "spandsp-sim.h" |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
134 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
135 #define BLOCK_LEN 160 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
136 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
137 #define TESTDATA_DIR "../test-data/etsi/gsm0610/unpacked/fr_" |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
138 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
139 #define IN_FILE_NAME "../test-data/local/short_nb_voice.wav" |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
140 #define OUT_FILE_NAME "post_gsm0610.wav" |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
141 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
142 #define HIST_LEN 1000 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
143 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
144 uint8_t law_in_vector[1000000]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
145 int16_t in_vector[1000000]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
146 uint16_t code_vector_buf[1000000]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
147 uint8_t code_vector[1000000]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
148 uint8_t ref_code_vector[1000000]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
149 uint8_t decoder_code_vector[1000000]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
150 uint8_t law_out_vector[1000000]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
151 int16_t out_vector[1000000]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
152 int16_t ref_out_vector[1000000]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
153 uint8_t ref_law_out_vector[1000000]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
154 int vector_len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
155 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
156 static int get_test_vector(int full, int disk, const char *name) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
157 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
158 char buf[500]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
159 int in; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
160 int len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
161 int i; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
162 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
163 if (full) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
164 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
165 sprintf(buf, "%s%c/%s.inp", TESTDATA_DIR, 'L', name); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
166 if ((in = open(buf, O_RDONLY)) < 0) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
167 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
168 fprintf(stderr, "Cannot open %s\n", buf); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
169 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
170 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
171 len = read(in, in_vector, 1000000); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
172 close(in); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
173 len /= sizeof(int16_t); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
174 vector_len = len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
175 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
176 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
177 sprintf(buf, "%s%c/%s.out", TESTDATA_DIR, 'L', name); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
178 if ((in = open(buf, O_RDONLY)) < 0) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
179 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
180 fprintf(stderr, "Cannot open %s\n", buf); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
181 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
182 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
183 len = read(in, ref_out_vector, 1000000); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
184 close(in); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
185 len /= sizeof(int16_t); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
186 if (full) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
187 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
188 if (len != vector_len) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
189 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
190 fprintf(stderr, "Input and reference vector lengths do not match - %d %d\n", vector_len, len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
191 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
192 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
193 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
194 else |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
195 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
196 vector_len = len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
197 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
198 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
199 sprintf(buf, "%s%c/%s.cod", TESTDATA_DIR, 'L', name); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
200 if ((in = open(buf, O_RDONLY)) < 0) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
201 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
202 fprintf(stderr, "Cannot open %s\n", buf); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
203 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
204 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
205 len = read(in, code_vector_buf, 1000000); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
206 close(in); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
207 len /= sizeof(int16_t); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
208 for (i = 0; i < len; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
209 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
210 ref_code_vector[i] = code_vector_buf[i]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
211 decoder_code_vector[i] = code_vector_buf[i]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
212 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
213 if (len*BLOCK_LEN != vector_len*76) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
214 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
215 fprintf(stderr, "Input and code vector lengths do not match - %d %d\n", vector_len, len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
216 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
217 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
218 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
219 return len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
220 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
221 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
222 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
223 static int get_law_test_vector(int full, int law, const char *name) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
224 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
225 char buf[500]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
226 int in; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
227 int len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
228 int i; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
229 int law_uc; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
230 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
231 law_uc = toupper(law); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
232 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
233 if (full) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
234 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
235 sprintf(buf, "%s%c/%s-%c.inp", TESTDATA_DIR, law_uc, name, law_uc); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
236 if ((in = open(buf, O_RDONLY)) < 0) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
237 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
238 fprintf(stderr, "Cannot open %s\n", buf); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
239 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
240 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
241 len = read(in, law_in_vector, 1000000); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
242 close(in); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
243 vector_len = len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
244 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
245 sprintf(buf, "%s%c/%s-%c.cod", TESTDATA_DIR, law_uc, name, law_uc); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
246 if ((in = open(buf, O_RDONLY)) < 0) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
247 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
248 fprintf(stderr, "Cannot open %s\n", buf); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
249 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
250 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
251 len = read(in, code_vector_buf, 1000000); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
252 close(in); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
253 len /= sizeof(int16_t); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
254 for (i = 0; i < len; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
255 ref_code_vector[i] = code_vector_buf[i]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
256 if (len*BLOCK_LEN != vector_len*76) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
257 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
258 fprintf(stderr, "Input and code vector lengths do not match - %d %d\n", vector_len, len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
259 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
260 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
261 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
262 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
263 sprintf(buf, "%s%c/%s-%c.out", TESTDATA_DIR, law_uc, name, law_uc); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
264 if ((in = open(buf, O_RDONLY)) < 0) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
265 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
266 fprintf(stderr, "Cannot open %s\n", buf); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
267 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
268 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
269 len = read(in, ref_law_out_vector, 1000000); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
270 close(in); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
271 if (full) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
272 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
273 if (len != vector_len) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
274 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
275 fprintf(stderr, "Input and reference vector lengths do not match - %d %d\n", vector_len, len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
276 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
277 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
278 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
279 else |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
280 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
281 vector_len = len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
282 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
283 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
284 sprintf(buf, "%s%c/%s.cod", TESTDATA_DIR, 'L', name); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
285 if ((in = open(buf, O_RDONLY)) < 0) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
286 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
287 fprintf(stderr, "Cannot open %s\n", buf); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
288 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
289 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
290 len = read(in, code_vector_buf, 1000000); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
291 close(in); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
292 len /= sizeof(int16_t); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
293 for (i = 0; i < len; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
294 decoder_code_vector[i] = code_vector_buf[i]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
295 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
296 return len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
297 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
298 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
299 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
300 static int perform_linear_test(int full, int disk, const char *name) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
301 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
302 gsm0610_state_t *gsm0610_enc_state; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
303 gsm0610_state_t *gsm0610_dec_state; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
304 int i; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
305 int xxx; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
306 int mismatches; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
307 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
308 printf("Performing linear test '%s' from disk %d\n", name, disk); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
309 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
310 get_test_vector(full, disk, name); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
311 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
312 if (full) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
313 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
314 if ((gsm0610_enc_state = gsm0610_init(NULL, GSM0610_PACKING_NONE)) == NULL) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
315 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
316 fprintf(stderr, " Cannot create encoder\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
317 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
318 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
319 xxx = gsm0610_encode(gsm0610_enc_state, code_vector, in_vector, vector_len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
320 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
321 printf("Check code vector of length %d\n", xxx); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
322 for (i = 0, mismatches = 0; i < xxx; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
323 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
324 if (code_vector[i] != ref_code_vector[i]) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
325 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
326 printf("%8d/%3d: %6d %6d\n", i/76, i%76, code_vector[i], ref_code_vector[i]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
327 mismatches++; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
328 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
329 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
330 gsm0610_release(gsm0610_enc_state); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
331 if (mismatches) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
332 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
333 printf("Test failed: %d of %d samples mismatch\n", mismatches, xxx); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
334 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
335 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
336 printf("Test passed\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
337 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
338 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
339 if ((gsm0610_dec_state = gsm0610_init(NULL, GSM0610_PACKING_NONE)) == NULL) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
340 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
341 fprintf(stderr, " Cannot create decoder\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
342 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
343 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
344 xxx = gsm0610_decode(gsm0610_dec_state, out_vector, decoder_code_vector, vector_len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
345 printf("Check output vector of length %d\n", vector_len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
346 for (i = 0, mismatches = 0; i < vector_len; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
347 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
348 if (out_vector[i] != ref_out_vector[i]) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
349 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
350 printf("%8d: %6d %6d\n", i, out_vector[i], ref_out_vector[i]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
351 mismatches++; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
352 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
353 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
354 if (mismatches) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
355 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
356 printf("Test failed: %d of %d samples mismatch\n", mismatches, vector_len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
357 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
358 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
359 gsm0610_release(gsm0610_dec_state); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
360 printf("Test passed\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
361 return 0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
362 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
363 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
364 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
365 static int perform_law_test(int full, int law, const char *name) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
366 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
367 gsm0610_state_t *gsm0610_enc_state; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
368 gsm0610_state_t *gsm0610_dec_state; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
369 int i; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
370 int xxx; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
371 int mismatches; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
372 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
373 if (law == 'a') |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
374 printf("Performing A-law test '%s'\n", name); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
375 else |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
376 printf("Performing u-law test '%s'\n", name); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
377 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
378 get_law_test_vector(full, law, name); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
379 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
380 if (full) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
381 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
382 if ((gsm0610_enc_state = gsm0610_init(NULL, GSM0610_PACKING_NONE)) == NULL) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
383 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
384 fprintf(stderr, " Cannot create encoder\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
385 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
386 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
387 if (law == 'a') |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
388 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
389 for (i = 0; i < vector_len; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
390 in_vector[i] = alaw_to_linear(law_in_vector[i]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
391 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
392 else |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
393 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
394 for (i = 0; i < vector_len; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
395 in_vector[i] = ulaw_to_linear(law_in_vector[i]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
396 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
397 xxx = gsm0610_encode(gsm0610_enc_state, code_vector, in_vector, vector_len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
398 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
399 printf("Check code vector of length %d\n", xxx); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
400 for (i = 0, mismatches = 0; i < xxx; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
401 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
402 if (code_vector[i] != ref_code_vector[i]) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
403 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
404 printf("%8d/%3d: %6d %6d %6d\n", i/76, i%76, code_vector[i], ref_code_vector[i], decoder_code_vector[i]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
405 mismatches++; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
406 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
407 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
408 if (mismatches) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
409 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
410 printf("Test failed: %d of %d samples mismatch\n", mismatches, xxx); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
411 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
412 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
413 printf("Test passed\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
414 gsm0610_release(gsm0610_enc_state); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
415 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
416 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
417 if ((gsm0610_dec_state = gsm0610_init(NULL, GSM0610_PACKING_NONE)) == NULL) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
418 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
419 fprintf(stderr, " Cannot create decoder\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
420 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
421 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
422 xxx = gsm0610_decode(gsm0610_dec_state, out_vector, decoder_code_vector, vector_len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
423 if (law == 'a') |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
424 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
425 for (i = 0; i < vector_len; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
426 law_out_vector[i] = linear_to_alaw(out_vector[i]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
427 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
428 else |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
429 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
430 for (i = 0; i < vector_len; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
431 law_out_vector[i] = linear_to_ulaw(out_vector[i]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
432 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
433 printf("Check output vector of length %d\n", vector_len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
434 for (i = 0, mismatches = 0; i < vector_len; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
435 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
436 if (law_out_vector[i] != ref_law_out_vector[i]) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
437 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
438 printf("%8d: %6d %6d\n", i, law_out_vector[i], ref_law_out_vector[i]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
439 mismatches++; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
440 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
441 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
442 if (mismatches) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
443 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
444 printf("Test failed: %d of %d samples mismatch\n", mismatches, vector_len); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
445 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
446 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
447 gsm0610_release(gsm0610_dec_state); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
448 printf("Test passed\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
449 return 0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
450 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
451 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
452 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
453 static int repack_gsm0610_voip_to_wav49(uint8_t c[], const uint8_t d[]) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
454 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
455 gsm0610_frame_t frame[2]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
456 int n; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
457 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
458 n = gsm0610_unpack_voip(&frame[0], d); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
459 gsm0610_unpack_voip(&frame[1], d + n); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
460 n = gsm0610_pack_wav49(c, frame); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
461 return n; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
462 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
463 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
464 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
465 static int repack_gsm0610_wav49_to_voip(uint8_t d[], const uint8_t c[]) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
466 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
467 gsm0610_frame_t frame[2]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
468 int n[2]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
469 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
470 gsm0610_unpack_wav49(frame, c); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
471 n[0] = gsm0610_pack_voip(d, &frame[0]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
472 n[1] = gsm0610_pack_voip(d + n[0], &frame[1]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
473 return n[0] + n[1]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
474 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
475 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
476 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
477 static int perform_pack_unpack_test(void) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
478 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
479 uint8_t a[66]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
480 uint8_t b[66]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
481 uint8_t c[66]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
482 int i; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
483 int j; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
484 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
485 printf("Performing packing/unpacking tests (not part of the ETSI conformance tests).\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
486 /* Try trans-packing a lot of random data looking for before/after mismatch. */ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
487 for (j = 0; j < 1000; j++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
488 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
489 for (i = 0; i < 65; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
490 a[i] = rand(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
491 repack_gsm0610_wav49_to_voip(b, a); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
492 repack_gsm0610_voip_to_wav49(c, b); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
493 if (memcmp(a, c, 65)) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
494 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
495 printf("Test failed: data mismatch\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
496 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
497 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
498 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
499 for (i = 0; i < 66; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
500 a[i] = rand(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
501 /* Insert the magic code */ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
502 a[0] = (a[0] & 0xF) | 0xD0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
503 a[33] = (a[33] & 0xF) | 0xD0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
504 repack_gsm0610_voip_to_wav49(b, a); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
505 repack_gsm0610_wav49_to_voip(c, b); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
506 //for (i = 0; i < 66; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
507 // printf("%2d: 0x%02X 0x%02X\n", i, a[i], c[i]); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
508 if (memcmp(a, c, 66)) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
509 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
510 printf("Test failed: data mismatch\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
511 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
512 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
513 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
514 printf("Test passed\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
515 return 0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
516 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
517 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
518 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
519 static void etsi_compliance_tests(void) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
520 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
521 perform_linear_test(TRUE, 1, "Seq01"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
522 perform_linear_test(TRUE, 1, "Seq02"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
523 perform_linear_test(TRUE, 1, "Seq03"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
524 perform_linear_test(TRUE, 1, "Seq04"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
525 perform_linear_test(FALSE, 1, "Seq05"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
526 perform_law_test(TRUE, 'a', "Seq01"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
527 perform_law_test(TRUE, 'a', "Seq02"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
528 perform_law_test(TRUE, 'a', "Seq03"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
529 perform_law_test(TRUE, 'a', "Seq04"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
530 perform_law_test(FALSE, 'a', "Seq05"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
531 perform_law_test(TRUE, 'u', "Seq01"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
532 perform_law_test(TRUE, 'u', "Seq02"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
533 perform_law_test(TRUE, 'u', "Seq03"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
534 perform_law_test(TRUE, 'u', "Seq04"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
535 perform_law_test(FALSE, 'u', "Seq05"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
536 /* This is not actually an ETSI test */ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
537 perform_pack_unpack_test(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
538 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
539 printf("Tests passed.\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
540 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
541 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
542 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
543 int main(int argc, char *argv[]) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
544 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
545 SNDFILE *inhandle; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
546 SNDFILE *outhandle; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
547 int frames; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
548 int outframes; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
549 int bytes; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
550 int16_t pre_amp[HIST_LEN]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
551 int16_t post_amp[HIST_LEN]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
552 uint8_t gsm0610_data[HIST_LEN]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
553 gsm0610_state_t *gsm0610_enc_state; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
554 gsm0610_state_t *gsm0610_dec_state; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
555 int opt; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
556 int etsitests; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
557 int packing; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
558 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
559 etsitests = TRUE; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
560 packing = GSM0610_PACKING_NONE; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
561 while ((opt = getopt(argc, argv, "lp:")) != -1) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
562 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
563 switch (opt) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
564 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
565 case 'l': |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
566 etsitests = FALSE; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
567 break; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
568 case 'p': |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
569 packing = atoi(optarg); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
570 break; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
571 default: |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
572 //usage(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
573 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
574 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
575 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
576 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
577 if (etsitests) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
578 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
579 etsi_compliance_tests(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
580 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
581 else |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
582 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
583 if ((inhandle = sf_open_telephony_read(IN_FILE_NAME, 1)) == NULL) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
584 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
585 fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
586 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
587 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
588 if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
589 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
590 fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
591 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
592 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
593 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
594 if ((gsm0610_enc_state = gsm0610_init(NULL, packing)) == NULL) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
595 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
596 fprintf(stderr, " Cannot create encoder\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
597 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
598 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
599 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
600 if ((gsm0610_dec_state = gsm0610_init(NULL, packing)) == NULL) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
601 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
602 fprintf(stderr, " Cannot create decoder\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
603 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
604 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
605 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
606 while ((frames = sf_readf_short(inhandle, pre_amp, 2*BLOCK_LEN))) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
607 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
608 bytes = gsm0610_encode(gsm0610_enc_state, gsm0610_data, pre_amp, frames); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
609 gsm0610_decode(gsm0610_dec_state, post_amp, gsm0610_data, bytes); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
610 outframes = sf_writef_short(outhandle, post_amp, frames); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
611 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
612 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
613 if (sf_close(inhandle) != 0) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
614 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
615 fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
616 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
617 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
618 if (sf_close(outhandle) != 0) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
619 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
620 fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
621 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
622 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
623 gsm0610_release(gsm0610_enc_state); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
624 gsm0610_release(gsm0610_dec_state); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
625 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
626 return 0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
627 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
628 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
629 /*- End of file ------------------------------------------------------------*/ |