FreeCalypso > hg > efr-experiments
comparison src/bits2prm.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: Bits2prm_12k2 | |
| 4 * | |
| 5 * PURPOSE: Retrieves the vector of encoder parameters from the received | |
| 6 * serial bits in a frame. | |
| 7 * | |
| 8 * DESCRIPTION: The encoder parameters are: | |
| 9 * | |
| 10 * BFI bad frame indicator 1 bit | |
| 11 * | |
| 12 * LPC: | |
| 13 * 1st codebook 7 bit | |
| 14 * 2nd codebook 8 bit | |
| 15 * 3rd codebook 8+1 bit | |
| 16 * 4th codebook 8 bit | |
| 17 * 5th codebook 6 bit | |
| 18 * | |
| 19 * 1st and 3rd subframes: | |
| 20 * pitch period 9 bit | |
| 21 * pitch gain 4 bit | |
| 22 * codebook index 35 bit | |
| 23 * codebook gain 5 bit | |
| 24 * | |
| 25 * 2nd and 4th subframes: | |
| 26 * pitch period 6 bit | |
| 27 * pitch gain 4 bit | |
| 28 * codebook index 35 bit | |
| 29 * codebook gain 5 bit | |
| 30 * | |
| 31 *************************************************************************/ | |
| 32 | |
| 33 #include "typedef.h" | |
| 34 #include "basic_op.h" | |
| 35 #include "count.h" | |
| 36 | |
| 37 /* Local function */ | |
| 38 | |
| 39 Word16 Bin2int ( /* Reconstructed parameter */ | |
| 40 Word16 no_of_bits, /* input : number of bits associated with value */ | |
| 41 Word16 *bitstream /* output: address where bits are written */ | |
| 42 ); | |
| 43 | |
| 44 #define BIT_0 0 | |
| 45 #define BIT_1 1 | |
| 46 #define PRM_NO 57 | |
| 47 | |
| 48 void Bits2prm_12k2 ( | |
| 49 Word16 bits[], /* input : serial bits (244 + bfi) */ | |
| 50 Word16 prm[] /* output: analysis parameters (57+1 parameters) */ | |
| 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 *prm++ = *bits++; move16 (); /* read BFI */ | |
| 64 | |
| 65 for (i = 0; i < PRM_NO; i++) | |
| 66 { | |
| 67 prm[i] = Bin2int (bitno[i], bits); move16 (); | |
| 68 bits += bitno[i]; | |
| 69 } | |
| 70 return; | |
| 71 } | |
| 72 | |
| 73 /************************************************************************* | |
| 74 * | |
| 75 * FUNCTION: Bin2int | |
| 76 * | |
| 77 * PURPOSE: Read "no_of_bits" bits from the array bitstream[] and convert | |
| 78 * to integer. | |
| 79 * | |
| 80 *************************************************************************/ | |
| 81 | |
| 82 Word16 Bin2int ( /* Reconstructed parameter */ | |
| 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 value, i, bit; | |
| 88 | |
| 89 value = 0; move16 (); | |
| 90 for (i = 0; i < no_of_bits; i++) | |
| 91 { | |
| 92 value = shl (value, 1); | |
| 93 bit = *bitstream++; move16 (); | |
| 94 test (); | |
| 95 if (sub (bit, BIT_1) == 0) | |
| 96 value = add (value, 1); | |
| 97 } | |
| 98 return (value); | |
| 99 } |
