FreeCalypso > hg > efr-experiments
comparison src/prm2bits.c @ 0:56410792419a
src: original EFR source from ETSI
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 03 Apr 2024 05:31:37 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:56410792419a |
---|---|
1 /************************************************************************* | |
2 * | |
3 * FUNCTION: Prm2bits_12k2 | |
4 * | |
5 * PURPOSE: converts the encoder parameter vector into a vector of serial | |
6 * bits. | |
7 * | |
8 * DESCRIPTION: The encoder parameters are: | |
9 * | |
10 * LPC: | |
11 * 1st codebook 7 bit | |
12 * 2nd codebook 8 bit | |
13 * 3rd codebook 8+1 bit | |
14 * 4th codebook 8 bit | |
15 * 5th codebook 6 bit | |
16 * | |
17 * 1st and 3rd subframes: | |
18 * pitch period 9 bit | |
19 * pitch gain 4 bit | |
20 * codebook index 35 bit | |
21 * codebook gain 5 bit | |
22 * | |
23 * 2nd and 4th subframes: | |
24 * pitch period 6 bit | |
25 * pitch gain 4 bit | |
26 * codebook index 35 bit | |
27 * codebook gain 5 bit | |
28 * | |
29 *************************************************************************/ | |
30 | |
31 #include "typedef.h" | |
32 #include "basic_op.h" | |
33 #include "count.h" | |
34 | |
35 /* Local function */ | |
36 | |
37 void Int2bin ( | |
38 Word16 value, /* input : value to be converted to binary */ | |
39 Word16 no_of_bits, /* input : number of bits associated with value */ | |
40 Word16 *bitstream /* output: address where bits are written */ | |
41 ); | |
42 | |
43 #define BIT_0 0 | |
44 #define BIT_1 1 | |
45 #define MASK 0x0001 | |
46 #define PRM_NO 57 | |
47 | |
48 void Prm2bits_12k2 ( | |
49 Word16 prm[], /* input : analysis parameters (57 parameters) */ | |
50 Word16 bits[] /* output: 244 serial bits */ | |
51 ) | |
52 { | |
53 Word16 i; | |
54 | |
55 static const Word16 bitno[PRM_NO] = | |
56 { | |
57 7, 8, 9, 8, 6, /* LSP VQ */ | |
58 9, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* first subframe */ | |
59 6, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* second subframe */ | |
60 9, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* third subframe */ | |
61 6, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5 /* fourth subframe */ | |
62 }; | |
63 for (i = 0; i < PRM_NO; i++) | |
64 { | |
65 Int2bin (prm[i], bitno[i], bits); | |
66 bits += bitno[i]; | |
67 } | |
68 | |
69 return; | |
70 } | |
71 | |
72 /************************************************************************* | |
73 * | |
74 * FUNCTION: Int2bin | |
75 * | |
76 * PURPOSE: convert integer to binary and write the bits to the array | |
77 * bitstream[]. The most significant bits are written first. | |
78 * | |
79 *************************************************************************/ | |
80 | |
81 void Int2bin ( | |
82 Word16 value, /* input : value to be converted to binary */ | |
83 Word16 no_of_bits, /* input : number of bits associated with value */ | |
84 Word16 *bitstream /* output: address where bits are written */ | |
85 ) | |
86 { | |
87 Word16 *pt_bitstream, i, bit; | |
88 | |
89 pt_bitstream = &bitstream[no_of_bits]; move16 (); | |
90 | |
91 for (i = 0; i < no_of_bits; i++) | |
92 { | |
93 bit = value & MASK; logic16 (); | |
94 test (); | |
95 if (bit == 0) | |
96 { | |
97 *--pt_bitstream = BIT_0; move16 (); | |
98 } | |
99 else | |
100 { | |
101 *--pt_bitstream = BIT_1; move16 (); | |
102 } | |
103 value = shr (value, 1); | |
104 } | |
105 } |