annotate libtwamr/dhf_check.c @ 480:332397bc80aa

doc/AMR-library-API: document public const data items
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 19 May 2024 23:18:17 +0000
parents 9beb01439a90
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
355
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the DHF checking function.
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdint.h>
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <string.h>
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "tw_amr.h"
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "typedef.h"
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "namespace.h"
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "bitno.h"
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 static const Word16 * const dhf_per_mode[8] = {
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 amr_dhf_mr475,
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 amr_dhf_mr515,
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 amr_dhf_mr59,
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 amr_dhf_mr67,
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 amr_dhf_mr74,
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 amr_dhf_mr795,
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 amr_dhf_mr102,
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 amr_dhf_mr122
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 };
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 int amr_check_dhf(const struct amr_param_frame *frame, int first_sub_only)
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 {
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 const Word16 *table;
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 Word16 nparam;
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (frame->type != RX_SPEECH_GOOD)
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 return 0;
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 if ((frame->mode & 0x87) == 0x87)
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 table = amr_dhf_gsmefr;
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 else
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 table = dhf_per_mode[frame->mode & 7];
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (first_sub_only)
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 nparam = prmnofsf[frame->mode & 7];
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 else
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 nparam = prmno[frame->mode & 7];
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 if (memcmp(frame->param, table, nparam * sizeof(int16_t)))
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 return 0;
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 else
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 return 1;
9beb01439a90 libtwamr: implement DHF check function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }