FreeCalypso > hg > rtp-debug-utils
annotate pcm-study/g711u-grep-gsmout.c @ 11:8b047c9bfe5f
g711u-grep-gsmout program written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 15 May 2024 02:31:01 +0000 |
parents | |
children |
rev | line source |
---|---|
11
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This programs reads a G.711 PCMU sample stream and 'grep's it for |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * particular patterns that result from a GSM-FR or GSM-EFR decoder |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * processing uplink test frames constructed in vband-misc repository, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * ul-test subdirectory. |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 */ |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdint.h> |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 static const uint8_t match_frame_fr[160] = { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 0xFF,0x0F,0x0E,0x1B,0x8D,0x8A,0x9C,0x23,0x1D,0x38,0x1C,0x1B,0x26,0x8A,0x80,0x92, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 0x11,0x06,0x1E,0xA3,0x9B,0xBF,0x9B,0x91,0x9C,0x11,0x06,0x1C,0x98,0x87,0x8D,0xAF, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 0x1D,0x16,0x13,0x1F,0xBE,0x8D,0x88,0x99,0x1D,0x07,0x05,0x12,0xAC,0x8B,0x87,0x95, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 0x25,0x09,0x06,0x14,0xAA,0x8B,0x88,0x97,0x25,0x0A,0x09,0x1A,0xA4,0x8C,0x8A,0x99, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 0x28,0x0C,0x09,0x1B,0xA5,0x8C,0x8B,0x9D,0x23,0x0C,0x0A,0x19,0xA4,0x8C,0x8A,0x9D, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 0x1E,0x0A,0x0A,0x1C,0xA2,0x8C,0x8B,0x9B,0x25,0x0C,0x0A,0x19,0xA7,0x8C,0x8B,0x9B, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 0x26,0x0D,0x0B,0x1A,0xAA,0x8D,0x8A,0x99,0x2A,0x0D,0x0B,0x1A,0xAB,0x8E,0x8C,0x99, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 0x2F,0x0F,0x0B,0x19,0xAE,0x8E,0x8C,0x99,0x34,0x0F,0x0D,0x1A,0xB2,0x91,0x8D,0x99, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 0x3B,0x12,0x0D,0x19,0xBA,0x92,0x8E,0x9B,0x38,0x14,0x0F,0x1B,0xBB,0x94,0x8E,0x9A, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 0x3B,0x13,0x0E,0x1B,0xBA,0x95,0x90,0x9B,0x3F,0x16,0x0F,0x1B,0xBB,0x94,0x8F,0x9C, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 }; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 static const uint8_t match_frame_efr_classic[160] = { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 0x6F,0x64,0x63,0x6B,0xE8,0xDA,0xDC,0xEF,0x60,0x5A,0x5D,0x6F,0xE2,0xD8,0xD9,0xEC, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 0x5F,0x58,0x5E,0x7E,0xE2,0xDF,0xE2,0xF0,0x63,0x58,0x59,0x67,0xE0,0xD4,0xD7,0xEC, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 0x5E,0x56,0x5A,0x6D,0xE1,0xD6,0xD7,0xEA,0x4D,0x37,0x2F,0x3A,0xC2,0xA7,0xA3,0xB5, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 0x2F,0x1C,0x1A,0x2D,0xA9,0x96,0x96,0xAE,0x22,0x12,0x14,0x31,0x9E,0x8F,0x94,0xB6, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 0x1B,0x0D,0x0F,0x2C,0x9B,0x8C,0x8E,0xAB,0x17,0x09,0x0C,0x28,0x97,0x88,0x8A,0xA7, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 0x15,0x07,0x0A,0x29,0x95,0x88,0x8B,0xAA,0x15,0x08,0x0B,0x2A,0x96,0x88,0x8B,0xAA, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 0x15,0x09,0x0C,0x2A,0x97,0x89,0x8C,0xAA,0x17,0x0A,0x0D,0x2B,0x98,0x8A,0x8D,0xAB, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 0x18,0x0A,0x0D,0x2A,0x99,0x8A,0x8D,0xAA,0x18,0x0A,0x0D,0x29,0x99,0x8A,0x8D,0xA9, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 0x19,0x0A,0x0D,0x29,0x99,0x8A,0x8D,0xA9,0x19,0x0A,0x0D,0x29,0x99,0x8A,0x8D,0xA9, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 0x19,0x0A,0x0D,0x28,0x99,0x8A,0x8C,0xA8,0x19,0x0A,0x0D,0x27,0x9A,0x8B,0x8D,0xA7, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 }; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 static const uint8_t match_frame_amrefr_dec[160] = { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 0x6F,0x66,0x66,0x6E,0xE5,0xDA,0xDD,0xF2,0x5F,0x5A,0x5E,0x76,0xE0,0xD8,0xDA,0xEF, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 0x5E,0x59,0x5F,0xFC,0xE1,0xDF,0xE5,0xF5,0x61,0x59,0x5B,0x6B,0xDE,0xD4,0xD9,0xEF, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 0x5D,0x56,0x5B,0x71,0xDF,0xD6,0xD8,0xEE,0x4D,0x38,0x31,0x3E,0xBD,0xA7,0xA5,0xB9, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 0x2D,0x1C,0x1C,0x35,0xA5,0x96,0x98,0xB4,0x1F,0x12,0x17,0x3D,0x9C,0x90,0x96,0xC1, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 0x1A,0x0E,0x12,0x38,0x98,0x8C,0x8F,0xB4,0x16,0x0A,0x0D,0x32,0x94,0x88,0x8C,0xAE, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 0x13,0x08,0x0C,0x35,0x92,0x88,0x8C,0xB3,0x13,0x08,0x0D,0x35,0x93,0x88,0x8D,0xB3, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 0x13,0x09,0x0D,0x34,0x94,0x89,0x8D,0xB3,0x15,0x0A,0x0E,0x35,0x96,0x8B,0x8E,0xB5, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 0x16,0x0B,0x0E,0x32,0x97,0x8B,0x8E,0xB3,0x16,0x0A,0x0E,0x32,0x96,0x8A,0x8E,0xB1, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 0x16,0x0B,0x0E,0x31,0x96,0x8B,0x8E,0xB1,0x16,0x0B,0x0E,0x31,0x97,0x8B,0x8E,0xB1, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 0x16,0x0A,0x0E,0x30,0x97,0x8A,0x8E,0xAF,0x17,0x0B,0x0E,0x2F,0x97,0x8B,0x8E,0xAE, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 }; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 enum state { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 STATE_GROUND = 0, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 STATE_FE, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 STATE_EFR_PRELIM, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 STATE_EFR_CLASSIC, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 STATE_EFR_AMR, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 STATE_FR, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 }; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 static enum state state; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 static unsigned fe_byte_count, match_pos; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 static void |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 report_match(name, offset) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 char *name; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 unsigned offset; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 offset -= 319; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 printf("Matched output of %s decoder\n", name); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 printf("File offset: %u (0x%x), offset % 160 = %u\n", offset, offset, |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 offset % 160); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 static void |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 process_sample(samp, offset) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 unsigned samp, offset; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 if (samp == 0xFE) { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 if (state != STATE_FE) { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 state = STATE_FE; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 fe_byte_count = 1; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 } else if (fe_byte_count < 160) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 fe_byte_count++; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 switch (state) { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 case STATE_GROUND: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 case STATE_FE: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 if (fe_byte_count < 160) { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 state = STATE_GROUND; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 switch (samp) { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 case 0x6F: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 state = STATE_EFR_PRELIM; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 case 0xFF: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 state = STATE_FR; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 match_pos = 1; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 default: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 state = STATE_GROUND; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 case STATE_EFR_PRELIM: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 switch (samp) { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 case 0x64: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 state = STATE_EFR_CLASSIC; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 match_pos = 2; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 case 0x66: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 state = STATE_EFR_AMR; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 match_pos = 2; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 default: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 state = STATE_GROUND; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 case STATE_EFR_CLASSIC: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 if (samp == match_frame_efr_classic[match_pos]) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 match_pos++; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 else { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 state = STATE_GROUND; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 if (match_pos < 160) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 report_match("classic EFR", offset); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 state = STATE_GROUND; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 case STATE_EFR_AMR: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 if (samp == match_frame_amrefr_dec[match_pos]) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 match_pos++; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 else { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 state = STATE_GROUND; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 if (match_pos < 160) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 report_match("AMR-EFR", offset); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 state = STATE_GROUND; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 case STATE_FR: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 if (samp == match_frame_fr[match_pos]) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 match_pos++; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 else { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 state = STATE_GROUND; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 if (match_pos < 160) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 report_match("GSM-FR", offset); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 state = STATE_GROUND; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 return; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 default: |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 state = STATE_GROUND; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 main(argc, argv) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 char **argv; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 FILE *inf; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 unsigned offset; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 int c; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 if (argc != 2) { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 fprintf(stderr, "usage: %s pcmu-bin-file\n", argv[0]); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 exit(1); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 inf = fopen(argv[1], "r"); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 if (!inf) { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 perror(argv[1]); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 exit(1); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 for (offset = 0; ; offset++) { |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 c = getc(inf); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 if (c < 0) |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 break; |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 process_sample(c, offset); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 } |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 exit(0); |
8b047c9bfe5f
g711u-grep-gsmout program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 } |