diff options
Diffstat (limited to 'all_pairs/source/g723_enc')
| -rw-r--r-- | all_pairs/source/g723_enc/ChangeLog.txt | 34 | ||||
| -rw-r--r-- | all_pairs/source/g723_enc/g723_enc.c | 887 | ||||
| -rw-r--r-- | all_pairs/source/g723_enc/license.txt | 23 |
3 files changed, 944 insertions, 0 deletions
diff --git a/all_pairs/source/g723_enc/ChangeLog.txt b/all_pairs/source/g723_enc/ChangeLog.txt new file mode 100644 index 0000000..8657026 --- /dev/null +++ b/all_pairs/source/g723_enc/ChangeLog.txt | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | File: g723_enc.c | ||
| 2 | Original provenience: SUN Microsystems | ||
| 3 | |||
| 4 | 2016-03-02: | ||
| 5 | - Renamed file to g723_enc and removed all g721 dead code | ||
| 6 | - Added TACLeBench header to line 1 | ||
| 7 | - Moved SUN license to license.txt | ||
| 8 | - Deleted unused code that was commented out | ||
| 9 | - Renamed functions prepended g723_enc to all function names | ||
| 10 | - Renamed function main to g723_enc_main | ||
| 11 | - Created new function main, calling g723_enc_init, g723_enc_main and | ||
| 12 | returning g723_enc_return | ||
| 13 | - Reordered functions in source code: initialization- and | ||
| 14 | return-value-related functions first, followed by algorithm core | ||
| 15 | functions, followed by main functions | ||
| 16 | - Applied code formatting with astyle as in the example | ||
| 17 | |||
| 18 | 2016-03-09: | ||
| 19 | - Renamed global variables, prepended g723_enc_ | ||
| 20 | - Removed static keyword from global variables | ||
| 21 | - Renamed datatype from g723_enc_g72x_state to g723_enc_state | ||
| 22 | - Renamed function g723_enc_g72x_init_state to g723_enc_init_state | ||
| 23 | |||
| 24 | 2016-05-23: | ||
| 25 | - Added initialization with volatile int | ||
| 26 | - Added check_sum and comparison with expected result | ||
| 27 | |||
| 28 | 2016-05-25 | ||
| 29 | - Changed name of struct g723_enc_state to g723_enc_state_t | ||
| 30 | - Changed name of variable state to g723_enc_state | ||
| 31 | |||
| 32 | 2017-07-10 | ||
| 33 | - Fixed undefined behaviour introduced by accessing the result of a pointer | ||
| 34 | type cast. | ||
diff --git a/all_pairs/source/g723_enc/g723_enc.c b/all_pairs/source/g723_enc/g723_enc.c new file mode 100644 index 0000000..6f31210 --- /dev/null +++ b/all_pairs/source/g723_enc/g723_enc.c | |||
| @@ -0,0 +1,887 @@ | |||
| 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. */ | ||
