diff options
Diffstat (limited to 'baseline/source/g723_enc/g723_enc.c')
| -rw-r--r-- | baseline/source/g723_enc/g723_enc.c | 886 |
1 files changed, 0 insertions, 886 deletions
diff --git a/baseline/source/g723_enc/g723_enc.c b/baseline/source/g723_enc/g723_enc.c deleted file mode 100644 index bf2df51..0000000 --- a/baseline/source/g723_enc/g723_enc.c +++ /dev/null | |||
| @@ -1,886 +0,0 @@ | |||
| 1 | /* | ||
| 2 | |||
| 3 | This program is part of the TACLeBench benchmark suite. | ||
| 4 | Version V 1.x | ||
| 5 | |||
| 6 | Name: g723_enc | ||
| 7 | |||
| 8 | Author: Unknown | ||
| 9 | |||
| 10 | Function: g723 encoder. | ||
| 11 | |||
| 12 | Source: SUN Microsystems | ||
| 13 | |||
| 14 | Changes: The benchmark was changed to use the g723 encoder | ||
| 15 | |||
| 16 | License: "Unrestricted use" (see license.txt) | ||
| 17 | |||
| 18 | */ | ||
| 19 | |||
| 20 | /* | ||
| 21 | Declaration of data types | ||
| 22 | */ | ||
| 23 | |||
| 24 | /* | ||
| 25 | The following is the definition of the state structure | ||
| 26 | used by the G.721/G.723 encoder and decoder to preserve their internal | ||
| 27 | state between successive calls. The meanings of the majority | ||
| 28 | of the state structure fields are explained in detail in the | ||
| 29 | CCITT Recommendation G.721. The field names are essentially indentical | ||
| 30 | to variable names in the bit level description of the coding algorithm | ||
| 31 | included in this Recommendation. | ||
| 32 | */ | ||
| 33 | |||
| 34 | #include "extra.h" | ||
| 35 | struct g723_enc_state_t { | ||
| 36 | long yl; /* Locked or steady state step size multiplier. */ | ||
| 37 | short yu; /* Unlocked or non-steady state step size multiplier. */ | ||
| 38 | short dms; /* Short term energy estimate. */ | ||
| 39 | short dml; /* Long term energy estimate. */ | ||
| 40 | short ap; /* Linear weighting coefficient of 'yl' and 'yu'. */ | ||
| 41 | |||
| 42 | short a[2]; /* Coefficients of pole portion of prediction filter. */ | ||
| 43 | short b[6]; /* Coefficients of zero portion of prediction filter. */ | ||
| 44 | short pk[2]; /* | ||
| 45 | Signs of previous two samples of a partially | ||
| 46 | reconstructed signal. | ||
| 47 | */ | ||
| 48 | short dq[6]; /* | ||
| 49 | Previous 6 samples of the quantized difference | ||
| 50 | signal represented in an internal floating point | ||
| 51 | format. | ||
| 52 | */ | ||
| 53 | short sr[2]; /* | ||
| 54 | Previous 2 samples of the quantized difference | ||
| 55 | signal represented in an internal floating point | ||
| 56 | format. | ||
| 57 | */ | ||
| 58 | char td; /* delayed tone detect, new in 1988 version */ | ||
| 59 | }; | ||
| 60 | |||
| 61 | |||
| 62 | /* | ||
| 63 | Forward declaration of functions | ||
| 64 | */ | ||
| 65 | |||
| 66 | int g723_enc_abs( int num ); | ||
| 67 | void g723_enc_init_state( struct g723_enc_state_t *state_ptr ); | ||
| 68 | int g723_enc_predictor_zero( struct g723_enc_state_t *state_ptr ); | ||
| 69 | int g723_enc_fmult( int an, int srn ); | ||
| 70 | int g723_enc_predictor_pole( struct g723_enc_state_t *state_ptr ); | ||
| 71 | int g723_enc_step_size( struct g723_enc_state_t *state_ptr ); | ||
| 72 | int g723_enc_quantize( | ||
| 73 | int d, /* Raw difference signal sample */ | ||
| 74 | int y, /* Step size multiplier */ | ||
| 75 | short *table, /* quantization table */ | ||
| 76 | int size ); /* table size of short integers */ | ||
| 77 | int g723_enc_reconstruct( | ||
| 78 | int sign, /* 0 for non-negative value */ | ||
| 79 | int dqln, /* G.72x codeword */ | ||
| 80 | int y ); /* Step size multiplier */ | ||
| 81 | void g723_enc_update( | ||
| 82 | int code_size, /* distinguish 723_40 with others */ | ||
| 83 | int y, /* quantizer step size */ | ||
| 84 | int wi, /* scale factor multiplier */ | ||
| 85 | int fi, /* for long/short term energies */ | ||
| 86 | int dq, /* quantized prediction difference */ | ||
| 87 | int sr, /* reconstructed signal */ | ||
| 88 | int dqsez, /* difference from 2-pole predictor */ | ||
| 89 | struct g723_enc_state_t *state_ptr ); /* coder state pointer */ | ||
| 90 | int g723_enc_quan( | ||
| 91 | int val, | ||
| 92 | short *table, | ||
| 93 | int size ); | ||
| 94 | int g723_enc_search( | ||
| 95 | int val, | ||
| 96 | short *table, | ||
| 97 | int size ); | ||
| 98 | int g723_enc_alaw2linear( unsigned char a_val ); | ||
| 99 | int g723_enc_ulaw2linear( unsigned char u_val ); | ||
| 100 | int g723_enc_g723_24_encoder( | ||
| 101 | int sample, | ||
| 102 | int in_coding, | ||
| 103 | struct g723_enc_state_t *state_ptr ); | ||
| 104 | int g723_enc_pack_output( | ||
| 105 | unsigned char code, | ||
| 106 | int bits ); | ||
| 107 | |||
| 108 | void g723_enc_init(); | ||
| 109 | int g723_enc_return(); | ||
| 110 | void g723_enc_main(); | ||
| 111 | //int main( void ); | ||
| 112 | |||
| 113 | /* | ||
| 114 | Declaration of global variables | ||
| 115 | */ | ||
| 116 | |||
| 117 | struct g723_enc_state_t g723_enc_state; | ||
| 118 | |||
| 119 | unsigned int g723_enc_INPUT[256] = { | ||
| 120 | 51, 17, 31, 53, 95, 17, 70, 22, 49, 12, 8, 39, 28, 37, 99, 54, | ||
| 121 | 77, 65, 77, 78, 83, 15, 63, 31, 35, 92, 52, 40, 61, 79, 94, 87, | ||
| 122 | 87, 68, 76, 58, 39, 35, 20, 83, 42, 46, 98, 12, 21, 96, 74, 41, | ||
| 123 | 78, 76, 96, 2, 32, 76, 24, 59, 4, 96, 32, 5, 44, 92, 57, 12, | ||
| 124 | 57, 25, 50, 23, 48, 41, 88, 43, 36, 38, 4, 16, 52, 70, 9, 40, | ||
| 125 | 78, 24, 34, 23, 30, 30, 89, 3, 65, 40, 68, 73, 94, 23, 84, 97, | ||
| 126 | 78, 43, 68, 81, 16, 28, 13, 87, 75, 21, 14, 29, 81, 22, 56, 72, | ||
| 127 | 19, 99, 25, 43, 76, 86, 90, 98, 39, 43, 12, 46, 24, 99, 65, 61, | ||
| 128 | 24, 45, 79, 7, 48, 15, 24, 95, 62, 99, 48, 80, 75, 38, 48, 53, | ||
| 129 | 9, 60, 35, 14, 78, 71, 45, 71, 9, 97, 55, 74, 58, 64, 78, 18, | ||
| 130 | 30, 28, 69, 29, 57, 42, 30, 44, 57, 49, 61, 42, 13, 25, 3, 98, | ||
| 131 | 11, 38, 65, 35, 55, 36, 57, 48, 16, 62, 17, 56, 29, 88, 84, 85, | ||
| 132 | 90, 60, 54, 16, 66, 69, 26, 10, 82, 19, 42, 35, 84, 13, 26, 17, | ||
| 133 | 48, 38, 50, 50, 35, 53, 12, 52, 61, 74, 56, 34, 80, 59, 26, 67, | ||
| 134 | 55, 79, 89, 89, 6, 80, 91, 65, 16, 30, 16, 28, 85, 54, 3, 20, | ||
| 135 | 2, 36, 62, 52, 55, 15, 83, 3, 2, 38, 62, 2, 63, 92, 37, 73 | ||
| 136 | }; | ||
| 137 | |||
| 138 | |||
| 139 | |||
| 140 | unsigned int g723_enc_OUTPUT[256]; | ||
| 141 | |||
| 142 | short g723_enc_power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, | ||
| 143 | 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000 | ||
| 144 | }; | ||
| 145 | |||
| 146 | |||
| 147 | /* | ||
| 148 | Maps G.723_24 code word to reconstructed scale factor normalized log | ||
| 149 | magnitude values. | ||
| 150 | */ | ||
| 151 | |||
| 152 | short g723_enc_qtab_723_24[3] = {8, 218, 331}; | ||
| 153 | |||
| 154 | /* | ||
| 155 | Maps G.721 code word to reconstructed scale factor normalized log | ||
| 156 | magnitude values. | ||
| 157 | */ | ||
| 158 | short g723_enc_dqlntab[16] = { -2048, 4, 135, 213, 273, 323, 373, 425, | ||
| 159 | 425, 373, 323, 273, 213, 135, 4, -2048 | ||
| 160 | }; | ||
| 161 | |||
| 162 | /* Maps G.721 code word to log of scale factor multiplier. */ | ||
| 163 | short g723_enc_witab[16] = { -12, 18, 41, 64, 112, 198, 355, 1122, | ||
| 164 | 1122, 355, 198, 112, 64, 41, 18, -12 | ||
| 165 | }; | ||
| 166 | /* | ||
| 167 | Maps G.721 code words to a set of values whose long and short | ||
| 168 | term averages are computed and then compared to give an indication | ||
| 169 | how stationary (steady state) the signal is. | ||
| 170 | */ | ||
| 171 | short g723_enc_fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00, | ||
| 172 | 0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0 | ||
| 173 | }; | ||
| 174 | |||
| 175 | static unsigned int g723_enc_out_buffer = 0; | ||
| 176 | static int g723_enc_out_bits = 0; | ||
| 177 | static int g723_enc_i = 0; | ||
| 178 | |||
| 179 | /* | ||
| 180 | Declaration of macros | ||
| 181 | */ | ||
| 182 | |||
| 183 | |||
| 184 | #define AUDIO_ENCODING_ULAW (1) /* ISDN u-law */ | ||
| 185 | #define AUDIO_ENCODING_ALAW (2) /* ISDN A-law */ | ||
| 186 | #define AUDIO_ENCODING_LINEAR (3) /* PCM 2's-complement (0-center) */ | ||
| 187 | |||
| 188 | #define BIAS (0x84) /* Bias for linear code. */ | ||
| 189 | |||
| 190 | #define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ | ||
| 191 | #define QUANT_MASK (0xf) /* Quantization field mask. */ | ||
| 192 | #define SEG_SHIFT (4) /* Left shift for segment number. */ | ||
| 193 | #define SEG_MASK (0x70) /* Segment field mask. */ | ||
| 194 | |||
| 195 | /* | ||
| 196 | Arithmetic math functions | ||
| 197 | */ | ||
| 198 | |||
| 199 | /* | ||
| 200 | g723_enc_fmult() | ||
| 201 | |||
| 202 | returns the integer product of the 14-bit integer "an" and | ||
