Mercurial > hg > audiostuff
comparison spandsp-0.0.3/spandsp-0.0.3/src/spandsp/gsm0610.h @ 5:f762bf195c4b
import spandsp-0.0.3
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 16:00:21 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:26cd8f1ef0b1 | 5:f762bf195c4b |
---|---|
1 /* | |
2 * SpanDSP - a series of DSP components for telephony | |
3 * | |
4 * gsm0610.h - GSM 06.10 full rate speech codec. | |
5 * | |
6 * Written by Steve Underwood <steveu@coppice.org> | |
7 * | |
8 * Copyright (C) 2006 Steve Underwood | |
9 * | |
10 * All rights reserved. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License version 2, as | |
14 * published by the Free Software Foundation. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 * | |
25 * $Id: gsm0610.h,v 1.7 2006/10/24 13:45:28 steveu Exp $ | |
26 */ | |
27 | |
28 #if !defined(_GSM0610_H_) | |
29 #define _GSM0610_H_ | |
30 | |
31 /*! \page gsm0610_page GSM 06.10 encoding and decoding | |
32 \section gsm0610_page_sec_1 What does it do? | |
33 | |
34 The GSM 06.10 module is an version of the widely used GSM FR codec software | |
35 available from http://kbs.cs.tu-berlin.de/~jutta/toast.html. This version | |
36 was produced since some versions of this codec are not bit exact, or not | |
37 very efficient on modern processors. This implementation can use MMX instructions | |
38 on Pentium class processors, or alternative methods on other processors. It | |
39 passes all the ETSI test vectors. That is, it is a tested bit exact implementation. | |
40 | |
41 This implementation supports encoded data in one of three packing formats: | |
42 - Unpacked, with the 76 parameters of a GSM 06.10 code frame each occupying a | |
43 separate byte. (note that none of the parameters exceed 8 bits). | |
44 - Packed the the 33 byte per frame, used for VoIP, where 4 bits per frame are wasted. | |
45 - Packed in WAV49 format, where 2 frames are packed into 65 bytes. | |
46 | |
47 \section gsm0610_page_sec_2 How does it work? | |
48 ???. | |
49 */ | |
50 | |
51 enum | |
52 { | |
53 GSM0610_PACKING_NONE, | |
54 GSM0610_PACKING_WAV49, | |
55 GSM0610_PACKING_VOIP | |
56 }; | |
57 | |
58 /*! | |
59 GSM 06.10 FR codec unpacked frame. | |
60 */ | |
61 typedef struct | |
62 { | |
63 int16_t LARc[8]; | |
64 int16_t Nc[4]; | |
65 int16_t bc[4]; | |
66 int16_t Mc[4]; | |
67 int16_t xmaxc[4]; | |
68 int16_t xMc[4][13]; | |
69 } gsm0610_frame_t; | |
70 | |
71 /*! | |
72 GSM 06.10 FR codec state descriptor. This defines the state of | |
73 a single working instance of the GSM 06.10 FR encoder or decoder. | |
74 */ | |
75 typedef struct | |
76 { | |
77 /*! \brief One of the packing modes */ | |
78 int packing; | |
79 | |
80 int16_t dp0[280]; | |
81 | |
82 int16_t z1; /* preprocessing, Offset_com. */ | |
83 int32_t L_z2; /* Offset_com. */ | |
84 int16_t mp; /* Preemphasis */ | |
85 | |
86 int16_t u[8]; /* short_term_delay_filter */ | |
87 int16_t LARpp[2][8]; | |
88 int16_t j; | |
89 | |
90 int16_t nrp; /* long term synthesis */ | |
91 int16_t v[9]; /* short term synthesis */ | |
92 int16_t msr; /* decoder postprocessing */ | |
93 | |
94 int16_t e[50]; /* encoder */ | |
95 uint8_t frame_index; | |
96 uint8_t frame_chain; | |
97 } gsm0610_state_t; | |
98 | |
99 #ifdef __cplusplus | |
100 extern "C" { | |
101 #endif | |
102 | |
103 /*! Initialise a GSM 06.10 encode or decode context. | |
104 \param s The GSM 06.10 context | |
105 \param packing One of the GSM0610_PACKING_xxx options. | |
106 \return A pointer to the GSM 06.10 context, or NULL for error. */ | |
107 gsm0610_state_t *gsm0610_init(gsm0610_state_t *s, int packing); | |
108 | |
109 int gsm0610_release(gsm0610_state_t *s); | |
110 | |
111 /*! Encode a buffer of linear PCM data to GSM 06.10. | |
112 \param s The GSM 06.10 context. | |
113 \param ima_data The GSM 06.10 data produced. | |
114 \param amp The audio sample buffer. | |
115 \param len The number of samples in the buffer. | |
116 \return The number of bytes of GSM 06.10 data produced. */ | |
117 int gsm0610_encode(gsm0610_state_t *s, uint8_t code[], const int16_t amp[], int quant); | |
118 | |
119 /*! Decode a buffer of GSM 06.10 data to linear PCM. | |
120 \param s The GSM 06.10 context. | |
121 \param amp The audio sample buffer. | |
122 \param code The GSM 06.10 data. | |
123 \param quant The number of frames of GSM 06.10 data to be decoded. | |
124 \return The number of samples returned. */ | |
125 int gsm0610_decode(gsm0610_state_t *s, int16_t amp[], const uint8_t code[], int quant); | |
126 | |
127 int gsm0610_pack_none(uint8_t c[], gsm0610_frame_t *s); | |
128 | |
129 int gsm0610_pack_wav49(uint8_t c[], gsm0610_frame_t *s, int half); | |
130 | |
131 int gsm0610_pack_voip(uint8_t c[], gsm0610_frame_t *s); | |
132 | |
133 int gsm0610_unpack_none(gsm0610_frame_t *s, const uint8_t c[]); | |
134 | |
135 int gsm0610_unpack_wav49(gsm0610_frame_t *s, const uint8_t c[], int half); | |
136 | |
137 int gsm0610_unpack_voip(gsm0610_frame_t *s, const uint8_t c[]); | |
138 | |
139 #ifdef __cplusplus | |
140 } | |
141 #endif | |
142 | |
143 #endif | |
144 /*- End of include ---------------------------------------------------------*/ |