comparison libgsmefr/dec_main.c @ 94:d80e9f12a1d1

libgsmefr: decoder main function put together
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 26 Nov 2022 18:52:49 +0000
parents
children 18866c0354ef
comparison
equal deleted inserted replaced
93:b651adfce60d 94:d80e9f12a1d1
1 /*
2 * This module contains our GSM EFR decoder main function, EFR_decode_params(),
3 * that stands at the boundary between our public interface and the guts of
4 * ETSI-based codec.
5 */
6
7 #include "gsm_efr.h"
8 #include "typedef.h"
9 #include "namespace.h"
10 #include "cnst.h"
11 #include "codec.h"
12 #include "sig_proc.h"
13 #include "memops.h"
14 #include "dec_state.h"
15 #include "d_homing.h"
16
17 /* These constants define the number of consecutive parameters
18 that function decoder_homing_frame_test() checks */
19
20 #define WHOLE_FRAME 57
21 #define TO_FIRST_SUBFRAME 18
22
23 void EFR_decode_params(struct EFR_decoder_state *st, const int16_t *params,
24 int bfi, int SID_flag, int TAF, int16_t *pcm_out)
25 {
26 Word16 *synth = st->synth_buf + M;
27 Word16 Az_dec[AZ_SIZE];
28 Word16 i, temp;
29 Word16 reset_flag;
30
31 if (!bfi) /* BFI == 0, perform DHF check */
32 {
33 if (st->reset_flag_old) /* Check for second and further
34 successive DHF (to first subfr.) */
35 {
36 reset_flag = decoder_homing_frame_test (params,
37 TO_FIRST_SUBFRAME);
38 }
39 else
40 {
41 reset_flag = 0;
42 }
43 }
44 else /* BFI==1, bypass DHF check (frame
45 is taken as not being a DHF) */
46 {
47 reset_flag = 0;
48 }
49
50 if (reset_flag && st->reset_flag_old)
51 {
52 /* Force the output to be the encoder homing frame pattern */
53
54 for (i = 0; i < L_FRAME; i++)
55 {
56 synth[i] = EHF_MASK;
57 }
58 }
59 else
60 {
61 /* Synthesis */
62 Decoder_12k2 (st, bfi, params, synth, Az_dec, TAF, SID_flag);
63
64 Post_Filter (st, synth, Az_dec); /* Post-filter */
65
66 for (i = 0; i < L_FRAME; i++)
67 /* Upscale the 15 bit linear PCM to 16 bits,
68 then truncate to 13 bits */
69 {
70 temp = synth[i] << 1;
71 synth[i] = temp & 0xfff8;
72 }
73 } /* else */
74
75 Copy (synth, pcm_out, L_FRAME);
76
77 /* BFI == 0, perform check for first DHF (whole frame) */
78 if (!bfi && !st->reset_flag_old)
79 {
80 reset_flag = decoder_homing_frame_test (params, WHOLE_FRAME);
81 }
82
83 if (reset_flag)
84 {
85 /* Bring the decoder and receive DTX to the home state */
86 EFR_decoder_reset(st);
87 } else {
88 st->reset_flag_old = 0;
89 }
90 }