annotate libtwamr/pre_big.c @ 430:edbbbf1c4ab1

implement twamr-tseq-dec test program
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 May 2024 23:35:41 +0000
parents 38ee82480462
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
396
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : pre_big.c
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Big subframe (2 subframes) preprocessing
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 ********************************************************************************
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 /*
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 ********************************************************************************
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 * MODULE INCLUDE FILE AND VERSION ID
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 ********************************************************************************
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #include "namespace.h"
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #include "pre_big.h"
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /*
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 ********************************************************************************
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 * INCLUDE FILES
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 ********************************************************************************
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #include "typedef.h"
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "basic_op.h"
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "oper_32b.h"
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "syn_filt.h"
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "weight_a.h"
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #include "residu.h"
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 #include "no_count.h"
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 #include "cnst.h"
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 /*
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 ********************************************************************************
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 * PUBLIC PROGRAM CODE
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 ********************************************************************************
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 int pre_big(
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 enum Mode mode, /* i : coder mode */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 const Word16 gamma1[], /* i : spectral exp. factor 1 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 const Word16 gamma1_12k2[],/* i : spectral exp. factor 1 for EFR */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 const Word16 gamma2[], /* i : spectral exp. factor 2 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 Word16 A_t[], /* i : A(z) unquantized, for 4 subframes, Q12 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 Word16 frameOffset, /* i : Start position in speech vector, Q0 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 Word16 speech[], /* i : speech, Q0 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 Word16 mem_w[], /* i/o: synthesis filter memory state, Q0 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 Word16 wsp[] /* o : weighted speech Q0 */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 )
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 {
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 Word16 Ap1[MP1]; /* A(z) with spectral expansion */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 Word16 Ap2[MP1]; /* A(z) with spectral expansion */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 const Word16 *g1; /* Pointer to correct gammma1 vector */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 Word16 aOffset;
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 Word16 i;
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 test ();
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 if (sub (mode, MR795) <= 0 )
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 {
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 g1 = gamma1; move16 ();
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 }
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 else
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 {
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 g1 = gamma1_12k2; move16 ();
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 }
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 test ();
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 if (frameOffset > 0) {
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 aOffset = 2*MP1; move16 ();
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 }
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 else {
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 aOffset = 0; move16 ();
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 /* process two subframes (which form the "big" subframe) */
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 for (i = 0; i < 2; i++)
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 {
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 Weight_Ai(&A_t[aOffset], g1, Ap1);
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 Weight_Ai(&A_t[aOffset], gamma2, Ap2);
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 Residu(Ap1, &speech[frameOffset], &wsp[frameOffset], L_SUBFR);
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 Syn_filt(Ap2, &wsp[frameOffset], &wsp[frameOffset], L_SUBFR, mem_w, 1);
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 aOffset = add (aOffset, MP1);
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 frameOffset = add (frameOffset, L_SUBFR);
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 }
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 return 0;
38ee82480462 libtwamr: integrate pre_big.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 }