comparison spandsp-0.0.6pre17/src/spandsp/lpc10.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 * lpc10.h - LPC10 low bit 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: lpc10.h,v 1.22 2009/04/11 18:11:19 steveu Exp $
26 */
27
28 #if !defined(_SPANDSP_LPC10_H_)
29 #define _SPANDSP_LPC10_H_
30
31 /*! \page lpc10_page LPC10 encoding and decoding
32 \section lpc10_page_sec_1 What does it do?
33 The LPC10 module implements the US Department of Defense LPC10
34 codec. This codec produces compressed data at 2400bps. At such
35 a low rate high fidelity cannot be expected. However, the speech
36 clarity is quite good, and this codec is unencumbered by patent
37 or other restrictions.
38
39 \section lpc10_page_sec_2 How does it work?
40 ???.
41 */
42
43 #define LPC10_SAMPLES_PER_FRAME 180
44 #define LPC10_BITS_IN_COMPRESSED_FRAME 54
45
46 /*!
47 LPC10 codec unpacked frame.
48 */
49 typedef struct
50 {
51 /*! Pitch */
52 int32_t ipitch;
53 /*! Energy */
54 int32_t irms;
55 /*! Reflection coefficients */
56 int32_t irc[10];
57 } lpc10_frame_t;
58
59 /*!
60 LPC10 codec encoder state descriptor. This defines the state of
61 a single working instance of the LPC10 encoder.
62 */
63 typedef struct lpc10_encode_state_s lpc10_encode_state_t;
64
65 /*!
66 LPC10 codec decoder state descriptor. This defines the state of
67 a single working instance of the LPC10 decoder.
68 */
69 typedef struct lpc10_decode_state_s lpc10_decode_state_t;
70
71 #if defined(__cplusplus)
72 extern "C"
73 {
74 #endif
75
76 /*! Initialise an LPC10e encode context.
77 \param s The LPC10e context
78 \param error_correction ???
79 \return A pointer to the LPC10e context, or NULL for error. */
80 SPAN_DECLARE(lpc10_encode_state_t *) lpc10_encode_init(lpc10_encode_state_t *s, int error_correction);
81
82 SPAN_DECLARE(int) lpc10_encode_release(lpc10_encode_state_t *s);
83
84 SPAN_DECLARE(int) lpc10_encode_free(lpc10_encode_state_t *s);
85
86 /*! Encode a buffer of linear PCM data to LPC10e.
87 \param s The LPC10e context.
88 \param ima_data The LPC10e data produced.
89 \param amp The audio sample buffer.
90 \param len The number of samples in the buffer. This must be a multiple of 180, as
91 this is the number of samples on a frame.
92 \return The number of bytes of LPC10e data produced. */
93 SPAN_DECLARE(int) lpc10_encode(lpc10_encode_state_t *s, uint8_t code[], const int16_t amp[], int len);
94
95 /*! Initialise an LPC10e decode context.
96 \param s The LPC10e context
97 \param error_correction ???
98 \return A pointer to the LPC10e context, or NULL for error. */
99 SPAN_DECLARE(lpc10_decode_state_t *) lpc10_decode_init(lpc10_decode_state_t *st, int error_correction);
100
101 SPAN_DECLARE(int) lpc10_decode_release(lpc10_decode_state_t *s);
102
103 SPAN_DECLARE(int) lpc10_decode_free(lpc10_decode_state_t *s);
104
105 /*! Decode a buffer of LPC10e data to linear PCM.
106 \param s The LPC10e context.
107 \param amp The audio sample buffer.
108 \param code The LPC10e data.
109 \param len The number of bytes of LPC10e data to be decoded. This must be a multiple of 7,
110 as each frame is packed into 7 bytes.
111 \return The number of samples returned. */
112 SPAN_DECLARE(int) lpc10_decode(lpc10_decode_state_t *s, int16_t amp[], const uint8_t code[], int len);
113
114
115 #if defined(__cplusplus)
116 }
117 #endif
118
119 #endif
120 /*- End of include ---------------------------------------------------------*/

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