annotate libgsmhr1/paramval_cod.c @ 513:03a40ac2e931

libgsmhr1: implement validation for *.cod frames
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Aug 2024 19:00:03 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
513
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The function implemented in this module examines a frame of 20 int16_t words
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * that corresponds to GSM-HR encoder output format, and checks if the unused
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * upper bits of each int16_t word are cleared as they should be.
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * This function should be used when reading from ETSI-format *.cod files,
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * to guard against reading garbage or wrong endian.
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 */
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdint.h>
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "tw_gsmhr.h"
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 int gsmhr_check_encoder_params(const int16_t *params)
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 if (params[18] & 0xFFFE)
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 return -1;
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 if (params[19] & 0xFFFE)
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 return -1;
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 return gsmhr_check_common_params(params);
03a40ac2e931 libgsmhr1: implement validation for *.cod frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 }