Alexandre Lision | 7c6f4a6 | 2013-09-05 13:27:01 -0400 | [diff] [blame] | 1 | /* |
| 2 | * This source code is a product of Sun Microsystems, Inc. and is provided |
| 3 | * for unrestricted use. Users may copy or modify this source code without |
| 4 | * charge. |
| 5 | * |
| 6 | * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING |
| 7 | * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR |
| 8 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. |
| 9 | * |
| 10 | * Sun source code is provided with no support and without any obligation on |
| 11 | * the part of Sun Microsystems, Inc. to assist in its use, correction, |
| 12 | * modification or enhancement. |
| 13 | * |
| 14 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE |
| 15 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE |
| 16 | * OR ANY PART THEREOF. |
| 17 | * |
| 18 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue |
| 19 | * or profits or other special, indirect and consequential damages, even if |
| 20 | * Sun has been advised of the possibility of such damages. |
| 21 | * |
| 22 | * Sun Microsystems, Inc. |
| 23 | * 2550 Garcia Avenue |
| 24 | * Mountain View, California 94043 |
| 25 | */ |
| 26 | |
| 27 | #ifndef G72X_PRIVATE_H |
| 28 | #define G72X_PRIVATE_H |
| 29 | |
| 30 | #ifdef __cplusplus |
| 31 | #error "This code is not designed to be compiled with a C++ compiler." |
| 32 | #endif |
| 33 | |
| 34 | /* |
| 35 | ** The following is the definition of the state structure used by the |
| 36 | ** G.721/G.723 encoder and decoder to preserve their internal state |
| 37 | ** between successive calls. The meanings of the majority of the state |
| 38 | ** structure fields are explained in detail in the CCITT Recommendation |
| 39 | ** G.721. The field names are essentially identical to variable names |
| 40 | ** in the bit level description of the coding algorithm included in this |
| 41 | ** Recommendation. |
| 42 | */ |
| 43 | |
| 44 | struct g72x_state |
| 45 | { long yl; /* Locked or steady state step size multiplier. */ |
| 46 | short yu; /* Unlocked or non-steady state step size multiplier. */ |
| 47 | short dms; /* Short term energy estimate. */ |
| 48 | short dml; /* Long term energy estimate. */ |
| 49 | short ap; /* Linear weighting coefficient of 'yl' and 'yu'. */ |
| 50 | |
| 51 | short a[2]; /* Coefficients of pole portion of prediction filter. */ |
| 52 | short b[6]; /* Coefficients of zero portion of prediction filter. */ |
| 53 | short pk[2]; /* |
| 54 | ** Signs of previous two samples of a partially |
| 55 | ** reconstructed signal. |
| 56 | **/ |
| 57 | short dq[6]; /* |
| 58 | ** Previous 6 samples of the quantized difference |
| 59 | ** signal represented in an internal floating point |
| 60 | ** format. |
| 61 | **/ |
| 62 | short sr[2]; /* |
| 63 | ** Previous 2 samples of the quantized difference |
| 64 | ** signal represented in an internal floating point |
| 65 | ** format. |
| 66 | */ |
| 67 | char td; /* delayed tone detect, new in 1988 version */ |
| 68 | |
| 69 | /* The following struct members were added for libsndfile. The original |
| 70 | ** code worked by calling a set of functions on a sample by sample basis |
| 71 | ** which is slow on architectures like Intel x86. For libsndfile, this |
| 72 | ** was changed so that the encoding and decoding routines could work on |
| 73 | ** a block of samples at a time to reduce the function call overhead. |
| 74 | */ |
| 75 | int (*encoder) (int, struct g72x_state* state) ; |
| 76 | int (*decoder) (int, struct g72x_state* state) ; |
| 77 | |
| 78 | int codec_bits, blocksize, samplesperblock ; |
| 79 | } ; |
| 80 | |
| 81 | typedef struct g72x_state G72x_STATE ; |
| 82 | |
| 83 | int predictor_zero (G72x_STATE *state_ptr); |
| 84 | |
| 85 | int predictor_pole (G72x_STATE *state_ptr); |
| 86 | |
| 87 | int step_size (G72x_STATE *state_ptr); |
| 88 | |
| 89 | int quantize (int d, int y, short *table, int size); |
| 90 | |
| 91 | int reconstruct (int sign, int dqln, int y); |
| 92 | |
| 93 | void update (int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, G72x_STATE *state_ptr); |
| 94 | |
| 95 | int g721_encoder (int sample, G72x_STATE *state_ptr); |
| 96 | int g721_decoder (int code, G72x_STATE *state_ptr); |
| 97 | |
| 98 | int g723_16_encoder (int sample, G72x_STATE *state_ptr); |
| 99 | int g723_16_decoder (int code, G72x_STATE *state_ptr); |
| 100 | |
| 101 | int g723_24_encoder (int sample, G72x_STATE *state_ptr); |
| 102 | int g723_24_decoder (int code, G72x_STATE *state_ptr); |
| 103 | |
| 104 | int g723_40_encoder (int sample, G72x_STATE *state_ptr); |
| 105 | int g723_40_decoder (int code, G72x_STATE *state_ptr); |
| 106 | |
| 107 | void private_init_state (G72x_STATE *state_ptr) ; |
| 108 | |
| 109 | #endif /* G72X_PRIVATE_H */ |