annotate libtwamr/calc_cor.c @ 391:be8edf9e6bc1

libtwamr: integrate pitch_fr.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 18:30:00 +0000
parents 67c31802392b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
325
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : calc_cor.c
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Calculate all correlations for prior the OL LTP
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 ********************************************************************************
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 */
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 /*
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 ********************************************************************************
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 * MODULE INCLUDE FILE AND VERSION ID
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 ********************************************************************************
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 */
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #include "namespace.h"
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #include "calc_cor.h"
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /*
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 ********************************************************************************
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 * INCLUDE FILES
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 ********************************************************************************
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 */
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #include "typedef.h"
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "basic_op.h"
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "oper_32b.h"
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "no_count.h"
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "cnst.h"
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /*
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 ********************************************************************************
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 * PUBLIC PROGRAM CODE
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 ********************************************************************************
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 */
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 /*************************************************************************
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 *
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 * FUNCTION: comp_corr
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 *
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 * PURPOSE: Calculate all correlations of scal_sig[] in a given delay
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 * range.
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 *
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 * DESCRIPTION:
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 * The correlation is given by
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 * cor[t] = <scal_sig[n],scal_sig[n-t]>, t=lag_min,...,lag_max
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 * The functions outputs the all correlations
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 *
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 *************************************************************************/
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 void comp_corr (
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 Word16 scal_sig[], /* i : scaled signal. */
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 Word16 L_frame, /* i : length of frame to compute pitch */
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 Word16 lag_max, /* i : maximum lag */
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 Word16 lag_min, /* i : minimum lag */
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 Word32 corr[]) /* o : correlation of selected lag */
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 {
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 Word16 i, j;
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 Word16 *p, *p1;
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 Word32 t0;
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 for (i = lag_max; i >= lag_min; i--)
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 {
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 p = scal_sig; move16 ();
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 p1 = &scal_sig[-i]; move16 ();
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 t0 = 0; move32 ();
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 for (j = 0; j < L_frame; j++, p++, p1++)
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 {
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 t0 = L_mac (t0, *p, *p1);
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 corr[-i] = t0; move32 ();
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 }
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 return;
67c31802392b libtwamr: integrate calc_cor.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 }