1 /* 2 * SpanDSP - a series of DSP components for telephony 3 * 4 * g722.h - The ITU G.722 codec. 5 * 6 * Written by Steve Underwood <steveu (at) coppice.org> 7 * 8 * Copyright (C) 2005 Steve Underwood 9 * 10 * Despite my general liking of the GPL, I place my own contributions 11 * to this code in the public domain for the benefit of all mankind - 12 * even the slimy ones who might try to proprietize my work and use it 13 * to my detriment. 14 * 15 * Based on a single channel G.722 codec which is: 16 * 17 ***** Copyright (c) CMU 1993 ***** 18 * Computer Science, Speech Group 19 * Chengxiang Lu and Alex Hauptmann 20 * 21 * $Id: g722.h,v 1.10 2006/06/16 12:45:53 steveu Exp $ 22 * 23 * Modifications for WebRtc, 2011/04/28, by tlegrand: 24 * -Changed to use WebRtc types 25 * -Added new defines for minimum and maximum values of short int 26 */ 27 28 29 /*! \file */ 30 31 #if !defined(_G722_ENC_DEC_H_) 32 #define _G722_ENC_DEC_H_ 33 34 /*! \page g722_page G.722 encoding and decoding 35 \section g722_page_sec_1 What does it do? 36 The G.722 module is a bit exact implementation of the ITU G.722 specification for all three 37 specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests. 38 39 To allow fast and flexible interworking with narrow band telephony, the encoder and decoder 40 support an option for the linear audio to be an 8k samples/second stream. In this mode the 41 codec is considerably faster, and still fully compatible with wideband terminals using G.722. 42 43 \section g722_page_sec_2 How does it work? 44 ???. 45 */ 46 47 #define WEBRTC_INT16_MAX 32767 48 #define WEBRTC_INT16_MIN -32768 49 50 enum 51 { 52 G722_SAMPLE_RATE_8000 = 0x0001, 53 G722_PACKED = 0x0002 54 }; 55 56 typedef struct 57 { 58 /*! TRUE if the operating in the special ITU test mode, with the band split filters 59 disabled. */ 60 int itu_test_mode; 61 /*! TRUE if the G.722 data is packed */ 62 int packed; 63 /*! TRUE if encode from 8k samples/second */ 64 int eight_k; 65 /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ 66 int bits_per_sample; 67 68 /*! Signal history for the QMF */ 69 int x[24]; 70 71 struct 72 { 73 int s; 74 int sp; 75 int sz; 76 int r[3]; 77 int a[3]; 78 int ap[3]; 79 int p[3]; 80 int d[7]; 81 int b[7]; 82 int bp[7]; 83 int sg[7]; 84 int nb; 85 int det; 86 } band[2]; 87 88 unsigned int in_buffer; 89 int in_bits; 90 unsigned int out_buffer; 91 int out_bits; 92 } g722_encode_state_t; 93 94 typedef struct 95 { 96 /*! TRUE if the operating in the special ITU test mode, with the band split filters 97 disabled. */ 98 int itu_test_mode; 99 /*! TRUE if the G.722 data is packed */ 100 int packed; 101 /*! TRUE if decode to 8k samples/second */ 102 int eight_k; 103 /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ 104 int bits_per_sample; 105 106 /*! Signal history for the QMF */ 107 int x[24]; 108 109 struct 110 { 111 int s; 112 int sp; 113 int sz; 114 int r[3]; 115 int a[3]; 116 int ap[3]; 117 int p[3]; 118 int d[7]; 119 int b[7]; 120 int bp[7]; 121 int sg[7]; 122 int nb; 123 int det; 124 } band[2]; 125 126 unsigned int in_buffer; 127 int in_bits; 128 unsigned int out_buffer; 129 int out_bits; 130 } g722_decode_state_t; 131 132 #ifdef __cplusplus 133 extern "C" { 134 #endif 135 136 g722_encode_state_t *WebRtc_g722_encode_init(g722_encode_state_t *s, 137 int rate, 138 int options); 139 int WebRtc_g722_encode_release(g722_encode_state_t *s); 140 int WebRtc_g722_encode(g722_encode_state_t *s, 141 uint8_t g722_data[], 142 const int16_t amp[], 143 int len); 144 145 g722_decode_state_t *WebRtc_g722_decode_init(g722_decode_state_t *s, 146 int rate, 147 int options); 148 int WebRtc_g722_decode_release(g722_decode_state_t *s); 149 int WebRtc_g722_decode(g722_decode_state_t *s, 150 int16_t amp[], 151 const uint8_t g722_data[], 152 int len); 153 154 #ifdef __cplusplus 155 } 156 #endif 157 158 #endif 159