FreeCalypso > hg > gsm-codec-lib
comparison libtwamr/d2_11pf.c @ 331:c75327562b5e
libtwamr: integrate d2_11pf.c
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 18 Apr 2024 22:14:40 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 330:2cf33c211544 | 331:c75327562b5e |
|---|---|
| 1 /* | |
| 2 ******************************************************************************** | |
| 3 * | |
| 4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 | |
| 5 * R99 Version 3.3.0 | |
| 6 * REL-4 Version 4.1.0 | |
| 7 * | |
| 8 ******************************************************************************** | |
| 9 * | |
| 10 * File : d2_11pf.c | |
| 11 * Purpose : Algebraic codebook decoder | |
| 12 * | |
| 13 ******************************************************************************** | |
| 14 */ | |
| 15 | |
| 16 /* | |
| 17 ******************************************************************************** | |
| 18 * MODULE INCLUDE FILE AND VERSION ID | |
| 19 ******************************************************************************** | |
| 20 */ | |
| 21 #include "namespace.h" | |
| 22 #include "d2_11pf.h" | |
| 23 | |
| 24 /* | |
| 25 ******************************************************************************** | |
| 26 * INCLUDE FILES | |
| 27 ******************************************************************************** | |
| 28 */ | |
| 29 #include "typedef.h" | |
| 30 #include "basic_op.h" | |
| 31 #include "no_count.h" | |
| 32 #include "cnst.h" | |
| 33 | |
| 34 /* | |
| 35 ******************************************************************************** | |
| 36 * LOCAL VARIABLES AND TABLES | |
| 37 ******************************************************************************** | |
| 38 */ | |
| 39 #define NB_PULSE 2 /* number of pulses */ | |
| 40 | |
| 41 /* | |
| 42 ******************************************************************************** | |
| 43 * PUBLIC PROGRAM CODE | |
| 44 ******************************************************************************** | |
| 45 */ | |
| 46 /************************************************************************* | |
| 47 * | |
| 48 * FUNCTION: decode_2i40_11bits (decod_ACELP()) | |
| 49 * | |
| 50 * PURPOSE: Algebraic codebook decoder | |
| 51 * | |
| 52 *************************************************************************/ | |
| 53 | |
| 54 void decode_2i40_11bits( | |
| 55 Word16 sign, /* i : signs of 2 pulses. */ | |
| 56 Word16 index, /* i : Positions of the 2 pulses. */ | |
| 57 Word16 cod[] /* o : algebraic (fixed) codebook excitation */ | |
| 58 ) | |
| 59 { | |
| 60 Word16 i, j; | |
| 61 Word16 pos[NB_PULSE]; | |
| 62 | |
| 63 /* Decode the positions */ | |
| 64 | |
| 65 j = index & 1; logic16 (); | |
| 66 index = shr(index, 1); | |
| 67 i = index & 7; logic16 (); | |
| 68 | |
| 69 i = add(i, shl(i, 2)); /* pos0 =i*5+1+j*2 */ | |
| 70 i = add(i, 1); | |
| 71 j = shl(j, 1); | |
| 72 pos[0] = add(i, j); move16 (); | |
| 73 | |
| 74 index = shr(index, 3); | |
| 75 j = index & 3; logic16 (); | |
| 76 index = shr(index, 2); | |
| 77 i = index & 7; logic16 (); | |
| 78 | |
| 79 test(); | |
| 80 if (sub(j, 3) == 0) | |
| 81 { | |
| 82 i = add(i, shl(i, 2)); /* pos1 =i*5+4 */ | |
| 83 pos[1] = add(i, 4); move16 (); | |
| 84 } | |
| 85 else | |
| 86 { | |
| 87 i = add(i, shl(i, 2)); /* pos1 =i*5+j */ | |
| 88 pos[1] = add(i, j); move16 (); | |
| 89 } | |
| 90 | |
| 91 /* decode the signs and build the codeword */ | |
| 92 | |
| 93 for (i = 0; i < L_SUBFR; i++) { | |
| 94 cod[i] = 0; move16 (); | |
| 95 } | |
| 96 | |
| 97 for (j = 0; j < NB_PULSE; j++) { | |
| 98 i = sign & 1; logic16 (); | |
| 99 sign = shr(sign, 1); | |
| 100 | |
| 101 test (); | |
| 102 if (i != 0) { | |
| 103 cod[pos[j]] = 8191; move16 (); /* +1.0 */ | |
| 104 } else { | |
| 105 cod[pos[j]] = -8192; move16 (); /* -1.0 */ | |
| 106 } | |
| 107 } | |
| 108 | |
| 109 return; | |
| 110 } |
