annotate libgsmhr1/enc_out_order.c @ 527:f3246d109e2d

libgsmfr2: add gsmfr_fulldec_bfi_bits()
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 19 Sep 2024 07:03:12 +0000
parents 17c0aabae474
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
505
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module was derived from host.c in the original GSM 06.06 source,
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * reduced to just fillBitAlloc() function.
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 /*_________________________________________________________________________
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 | |
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 | Include Files |
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 |_________________________________________________________________________|
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 */
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "typedefs.h"
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "namespace.h"
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include "enc_out_order.h"
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 /***************************************************************************
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 * FUNCTION NAME: fillBitAlloc
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 * PURPOSE:
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 * Arrange speech parameters for encoder output
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 * INPUTS:
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 * The speechcoders codewords:
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 * iR0 - Frame energy
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 * piVqIndeces[0:2] - LPC vector quantizer codewords
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 * iSoftInterp - Soft interpolation bit 1 or 0
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 * iVoicing - voicing mode 0,1,2,3
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 * piLags[0:3] - Frame and delta lag codewords
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 * piCodeWrdsA[0:3] - VSELP codevector 1
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 * piCodeWrdsB[0:3] - VSELP codevector 2 (n/a for voiced modes)
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 * piGsp0s[0:3] - GSP0 codewords
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 * swVadFlag - voice activity detection flag
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 * swSP - Speech flag
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 * OUTPUTS:
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 * pswBAlloc[0:20] - an array into which the coded data is moved
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 * RETURN VALUE:
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 * none
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 * REFERENCES: Sub-clause 2.1 and 4.1.12 of GSM Recomendation 06.20
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 **************************************************************************/
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 void fillBitAlloc(int iVoicing, int iR0, int *piVqIndeces,
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 int iSoftInterp, int *piLags,
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 int *piCodeWrdsA, int *piCodeWrdsB,
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 int *piGsp0s, Shortword swVadFlag,
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 Shortword swSP, Shortword *pswBAlloc)
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 {
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 /*_________________________________________________________________________
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 | |
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 | Automatic Variables |
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 |_________________________________________________________________________|
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 */
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 int i;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 Shortword *pswNxt;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 /*_________________________________________________________________________
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 | |
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 | Executable Code |
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 |_________________________________________________________________________|
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 */
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 pswNxt = pswBAlloc;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 *pswNxt++ = iR0;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 for (i = 0; i < 3; i++)
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 *pswNxt++ = *piVqIndeces++;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 *pswNxt++ = iSoftInterp;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 *pswNxt++ = iVoicing;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 /* check voicing mode */
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 if (iVoicing)
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 {
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 /* voiced mode */
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 for (i = 0; i < N_SUB; i++)
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 {
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 *pswNxt++ = *piLags++;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 *pswNxt++ = *piCodeWrdsA++;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 *pswNxt++ = *piGsp0s++;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 }
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 }
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 else
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 { /* unvoiced frame */
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 for (i = 0; i < N_SUB; i++)
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 {
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 *pswNxt++ = *piCodeWrdsA++;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 *pswNxt++ = *piCodeWrdsB++;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 *pswNxt++ = *piGsp0s++;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 }
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 }
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 *pswNxt++ = swVadFlag;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 *pswNxt++ = swSP;
17c0aabae474 libgsmhr1: integrate fillBitAlloc()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 }