annotate libtwamr/sid_sync.c @ 458:e26b974f7ba3

doc/AMR-study-utils: update for the current situation
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 10 May 2024 18:45:36 +0000
parents a8b73b1c5b19
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
402
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : sid_sync.c
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 *
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 */
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 /*
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 * MODULE INCLUDE FILE AND VERSION ID
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 */
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #include "namespace.h"
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 #include "sid_sync.h"
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 /*
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 * INCLUDE FILES
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 */
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 #include "tw_amr.h"
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 #include "typedef.h"
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #include "basic_op.h"
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "no_count.h"
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 /*
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 * LOCAL VARIABLES AND TABLES
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 */
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 /*
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 * PUBLIC PROGRAM CODE
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 *****************************************************************************
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 */
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 void sid_sync_reset (sid_syncState *st)
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 st->sid_update_rate = 8;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 st->sid_update_counter = 3;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 st->sid_handover_debt = 0;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 st->prev_ft = TX_SPEECH_GOOD;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 int sid_sync_set_handover_debt (sid_syncState *st,
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 Word16 debtFrames)
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 /* debtFrames >= 0 */
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 st->sid_handover_debt = debtFrames;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 return 0;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 }
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 void sid_sync (sid_syncState *st, enum Mode mode,
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 enum TXFrameType *tx_frame_type)
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 if (mode == MRDTX)
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 st->sid_update_counter--;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 if (st->prev_ft == TX_SPEECH_GOOD)
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 *tx_frame_type = TX_SID_FIRST;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 st->sid_update_counter = 3;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 }
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 else
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 /* TX_SID_UPDATE or TX_NO_DATA */
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 if ((st->sid_handover_debt > 0) &&
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 (st->sid_update_counter > 2) )
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 /* ensure extra updates are properly delayed after
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 a possible SID_FIRST */
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 *tx_frame_type = TX_SID_UPDATE;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 st->sid_handover_debt--;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 else
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 if (st->sid_update_counter == 0)
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 *tx_frame_type = TX_SID_UPDATE;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 st->sid_update_counter = st->sid_update_rate;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 } else {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 *tx_frame_type = TX_NO_DATA;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 }
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 }
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 }
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 }
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 else
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 {
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 st->sid_update_counter = st->sid_update_rate ;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 *tx_frame_type = TX_SPEECH_GOOD;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 }
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 st->prev_ft = *tx_frame_type;
a8b73b1c5b19 libtwamr: integrate sid_sync.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 }