comparison libtwamr/dhf_check.c @ 355:9beb01439a90

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