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