comparison spandsp-0.0.6pre17/src/spandsp/gsm0610.h @ 4:26cd8f1ef0b1

import spandsp-0.0.6pre17
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 15:50:58 +0200
parents
children
comparison
equal deleted inserted replaced
3:c6c5a16ce2f2 4:26cd8f1ef0b1
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 Lesser General Public License version 2.1,
14 * as 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 Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License 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.21 2009/02/10 13:06:47 steveu Exp $
26 */
27
28 #if !defined(_SPANDSP_GSM0610_H_)
29 #define _SPANDSP_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 gsm0610_state_s gsm0610_state_t;
76
77 #if defined(__cplusplus)
78 extern "C"
79 {
80 #endif
81
82 /*! Initialise a GSM 06.10 encode or decode context.
83 \param s The GSM 06.10 context
84 \param packing One of the GSM0610_PACKING_xxx options.
85 \return A pointer to the GSM 06.10 context, or NULL for error. */
86 SPAN_DECLARE(gsm0610_state_t *) gsm0610_init(gsm0610_state_t *s, int packing);
87
88 /*! Release a GSM 06.10 encode or decode context.
89 \param s The GSM 06.10 context
90 \return 0 for success, else -1. */
91 SPAN_DECLARE(int) gsm0610_release(gsm0610_state_t *s);
92
93 /*! Free a GSM 06.10 encode or decode context.
94 \param s The GSM 06.10 context
95 \return 0 for success, else -1. */
96 SPAN_DECLARE(int) gsm0610_free(gsm0610_state_t *s);
97
98 /*! Set the packing format for a GSM 06.10 encode or decode context.
99 \param s The GSM 06.10 context
100 \param packing One of the GSM0610_PACKING_xxx options.
101 \return 0 for success, else -1. */
102 SPAN_DECLARE(int) gsm0610_set_packing(gsm0610_state_t *s, int packing);
103
104 /*! Encode a buffer of linear PCM data to GSM 06.10.
105 \param s The GSM 06.10 context.
106 \param code The GSM 06.10 data produced.
107 \param amp The audio sample buffer.
108 \param len The number of samples in the buffer.
109 \return The number of bytes of GSM 06.10 data produced. */
110 SPAN_DECLARE(int) gsm0610_encode(gsm0610_state_t *s, uint8_t code[], const int16_t amp[], int len);
111
112 /*! Decode a buffer of GSM 06.10 data to linear PCM.
113 \param s The GSM 06.10 context.
114 \param amp The audio sample buffer.
115 \param code The GSM 06.10 data.
116 \param len The number of bytes of GSM 06.10 data to be decoded.
117 \return The number of samples returned. */
118 SPAN_DECLARE(int) gsm0610_decode(gsm0610_state_t *s, int16_t amp[], const uint8_t code[], int len);
119
120 SPAN_DECLARE(int) gsm0610_pack_none(uint8_t c[], const gsm0610_frame_t *s);
121
122 /*! Pack a pair of GSM 06.10 frames in the format used for wave files (wave type 49).
123 \param c The buffer for the packed data. This must be at least 65 bytes long.
124 \param s A pointer to the frames to be packed.
125 \return The number of bytes generated. */
126 SPAN_DECLARE(int) gsm0610_pack_wav49(uint8_t c[], const gsm0610_frame_t *s);
127
128 /*! Pack a GSM 06.10 frames in the format used for VoIP.
129 \param c The buffer for the packed data. This must be at least 33 bytes long.
130 \param s A pointer to the frame to be packed.
131 \return The number of bytes generated. */
132 SPAN_DECLARE(int) gsm0610_pack_voip(uint8_t c[], const gsm0610_frame_t *s);
133
134 SPAN_DECLARE(int) gsm0610_unpack_none(gsm0610_frame_t *s, const uint8_t c[]);
135
136 /*! Unpack a pair of GSM 06.10 frames from the format used for wave files (wave type 49).
137 \param s A pointer to a buffer into which the frames will be packed.
138 \param c The buffer containing the data to be unpacked. This must be at least 65 bytes long.
139 \return The number of bytes absorbed. */
140 SPAN_DECLARE(int) gsm0610_unpack_wav49(gsm0610_frame_t *s, const uint8_t c[]);
141
142 /*! Unpack a GSM 06.10 frame from the format used for VoIP.
143 \param s A pointer to a buffer into which the frame will be packed.
144 \param c The buffer containing the data to be unpacked. This must be at least 33 bytes long.
145 \return The number of bytes absorbed. */
146 SPAN_DECLARE(int) gsm0610_unpack_voip(gsm0610_frame_t *s, const uint8_t c[]);
147
148 #if defined(__cplusplus)
149 }
150 #endif
151
152 #endif
153 /*- End of include ---------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.