FreeCalypso > hg > efr-experiments
annotate src/decoder.c @ 2:c511bfb36c2a
beginning of EFR2 decoder, using AMR version of AGC module
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 03 Apr 2024 05:47:51 +0000 |
parents | 56410792419a |
children | 799b56cbccb6 |
rev | line source |
---|---|
0
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /*************************************************************************** |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * FILE NAME: decoder.c |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * Usage : decoder bitstream_file synth_file |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * Format for bitstream_file: |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * One word (2-byte) for bad frame indication (BFI) flag bit |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * 0x0000 -> good frame; 0x0001 -> bad frame |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * 244 words (2-byte) containing 244 bits. |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Bit 0 = 0x0000 and Bit 1 = 0x0001 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * One word (2-byte) for ternary Silence Descriptor (SID) flag |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * 0x0000 -> inactive (no detected speech activity); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 * 0x0001 -> active |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 * One word (2-byte) for Time Alignment Flag (TAF) bit |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 * 0x0000 -> inactive (no transmission of speech frames); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 * 0x0001 -> active |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 * Format for synth_file: |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 * Synthesis is written to a binary file of 16 bits data. |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 * |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 ***************************************************************************/ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include <stdio.h> |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #include <stdlib.h> |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 #include "typedef.h" |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 #include "n_stack.h" |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #include "basic_op.h" |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "sig_proc.h" |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "count.h" |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "codec.h" |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "cnst.h" |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "d_homing.h" |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 /* These constants define the number of consecutive parameters |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 that function decoder_homing_frame_test() checks */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 #define WHOLE_FRAME 57 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 #define TO_FIRST_SUBFRAME 18 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 Word16 synth_buf[L_FRAME + M]; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 /* L_FRAME, M, PRM_SIZE, AZ_SIZE, SERIAL_SIZE: defined in "cnst.h" */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 /*-----------------------------------------------------------------* |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * Global variables * |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 *-----------------------------------------------------------------*/ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 #if (WMOPS) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 Word16 dtx_mode = 0; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 #endif |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 /*-----------------------------------------------------------------* |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 * Main decoder routine * |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 *-----------------------------------------------------------------*/ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 int |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 main (int argc, char *argv[]) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 Word16 *synth; /* Synthesis */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 Word16 parm[PRM_SIZE + 1]; /* Synthesis parameters */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 Word16 serial[SERIAL_SIZE+2];/* Serial stream */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 Word16 Az_dec[AZ_SIZE]; /* Decoded Az for post-filter */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 /* in 4 subframes, length= 44 */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 Word16 i, frame, temp; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 FILE *f_syn, *f_serial; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 Word16 TAF, SID_flag; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 Word16 reset_flag; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 static Word16 reset_flag_old = 1; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 proc_head ("Decoder"); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 /*-----------------------------------------------------------------* |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 * Read passed arguments and open in/out files * |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 *-----------------------------------------------------------------*/ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 if (argc != 3) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 fprintf (stderr, |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 " Usage:\n\n decoder bitstream_file synth_file\n"); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 fprintf (stderr, "\n"); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 exit (1); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 /* Open file for synthesis and packed serial stream */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 if ((f_serial = fopen (argv[1], "rb")) == NULL) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 fprintf (stderr, "Input file '%s' does not exist !!\n", argv[1]); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 exit (0); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 else |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 fprintf (stderr, "Input bitstream file: %s\n", argv[1]); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 if ((f_syn = fopen (argv[2], "wb")) == NULL) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 fprintf (stderr, "Cannot open file '%s' !!\n", argv[2]); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 exit (0); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 else |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 fprintf (stderr, "Synthesis speech file: %s\n", argv[2]); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 /*-----------------------------------------------------------------* |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 * Initialization of decoder * |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 *-----------------------------------------------------------------*/ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 synth = synth_buf + M; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 reset_dec (); /* Bring the decoder and receive DTX to the initial state */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 #if (WMOPS) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 Init_WMOPS_counter (); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 #endif |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 /*-----------------------------------------------------------------* |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 * Loop for each "L_FRAME" speech data * |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 *-----------------------------------------------------------------*/ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 frame = 0; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 while (fread (serial, sizeof (Word16), 247, f_serial) == 247) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 #if (WMOPS) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 fprintf (stderr, "frame=%d ", ++frame); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 #else |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 fprintf (stderr, "\nframe=%d ", ++frame); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 #endif |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 #if (WMOPS) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 Reset_WMOPS_counter (); /* reset WMOPS counter for the new frame */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 #endif |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 SID_flag = serial[245]; /* Receive SID flag */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 TAF = serial[246]; /* Receive TAF flag */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 Bits2prm_12k2 (serial, parm); /* serial to parameters */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 #if (WMOPS) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 fwc (); /* function worst case */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 #endif |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 if (parm[0] == 0) /* BFI == 0, perform DHF check */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 if (reset_flag_old == 1) /* Check for second and further |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 successive DHF (to first subfr.) */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 reset_flag = decoder_homing_frame_test (&parm[1], |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 TO_FIRST_SUBFRAME); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 else |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 reset_flag = 0; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 else /* BFI==1, bypass DHF check (frame |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 is taken as not being a DHF) */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 reset_flag = 0; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 if ((reset_flag != 0) && (reset_flag_old != 0)) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 /* Force the output to be the encoder homing frame pattern */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 for (i = 0; i < L_FRAME; i++) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 synth[i] = EHF_MASK; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 else |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 Decoder_12k2 (parm, synth, Az_dec, TAF, SID_flag);/* Synthesis */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 Post_Filter (synth, Az_dec); /* Post-filter */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 #if (WMOPS) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 fwc (); /* function worst case */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 #endif |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 for (i = 0; i < L_FRAME; i++) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 /* Upscale the 15 bit linear PCM to 16 bits, |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 then truncate to 13 bits */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 temp = shl (synth[i], 1); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 synth[i] = temp & 0xfff8; logic16 (); move16 (); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 #if (WMOPS) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 fwc (); /* function worst case */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 #endif |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 #if (WMOPS) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 WMOPS_output (dtx_mode);/* output WMOPS values for current frame */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 #endif |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 } /* else */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 fwrite (synth, sizeof (Word16), L_FRAME, f_syn); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 /* BFI == 0, perform check for first DHF (whole frame) */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 if ((parm[0] == 0) && (reset_flag_old == 0)) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 reset_flag = decoder_homing_frame_test (&parm[1], WHOLE_FRAME); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 if (reset_flag != 0) |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 { |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 /* Bring the decoder and receive DTX to the home state */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 reset_dec (); |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 } |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 reset_flag_old = reset_flag; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 } /* while */ |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 return 0; |
56410792419a
src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 } |