00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * lpc10.h - LPC10 low bit rate speech codec. 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2006 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 * 00025 * $Id: lpc10.h,v 1.18 2008/11/30 05:43:37 steveu Exp $ 00026 */ 00027 00028 #if !defined(_SPANDSP_LPC10_H_) 00029 #define _SPANDSP_LPC10_H_ 00030 00031 /*! \page lpc10_page LPC10 encoding and decoding 00032 \section lpc10_page_sec_1 What does it do? 00033 The LPC10 module implements the US Department of Defense LPC10 00034 codec. This codec produces compressed data at 2400bps. At such 00035 a low rate high fidelity cannot be expected. However, the speech 00036 clarity is quite good, and this codec is unencumbered by patent 00037 or other restrictions. 00038 00039 \section lpc10_page_sec_2 How does it work? 00040 ???. 00041 */ 00042 00043 #define LPC10_SAMPLES_PER_FRAME 180 00044 #define LPC10_BITS_IN_COMPRESSED_FRAME 54 00045 00046 /*! 00047 LPC10 codec unpacked frame. 00048 */ 00049 typedef struct 00050 { 00051 int32_t ipitch; 00052 int32_t irms; 00053 int32_t irc[10]; 00054 } lpc10_frame_t; 00055 00056 /*! 00057 LPC10 codec encoder state descriptor. This defines the state of 00058 a single working instance of the LPC10 encoder. 00059 */ 00060 typedef struct lpc10_encode_state_s lpc10_encode_state_t; 00061 00062 /*! 00063 LPC10 codec decoder state descriptor. This defines the state of 00064 a single working instance of the LPC10 decoder. 00065 */ 00066 typedef struct lpc10_decode_state_s lpc10_decode_state_t; 00067 00068 #if defined(__cplusplus) 00069 extern "C" 00070 { 00071 #endif 00072 00073 /*! Initialise an LPC10e encode context. 00074 \param s The LPC10e context 00075 \param error_correction ??? 00076 \return A pointer to the LPC10e context, or NULL for error. */ 00077 lpc10_encode_state_t *lpc10_encode_init(lpc10_encode_state_t *s, int error_correction); 00078 00079 int lpc10_encode_release(lpc10_encode_state_t *s); 00080 00081 /*! Encode a buffer of linear PCM data to LPC10e. 00082 \param s The LPC10e context. 00083 \param ima_data The LPC10e data produced. 00084 \param amp The audio sample buffer. 00085 \param len The number of samples in the buffer. This must be a multiple of 180, as 00086 this is the number of samples on a frame. 00087 \return The number of bytes of LPC10e data produced. */ 00088 int lpc10_encode(lpc10_encode_state_t *s, uint8_t code[], const int16_t amp[], int len); 00089 00090 /*! Initialise an LPC10e decode context. 00091 \param s The LPC10e context 00092 \param error_correction ??? 00093 \return A pointer to the LPC10e context, or NULL for error. */ 00094 lpc10_decode_state_t *lpc10_decode_init(lpc10_decode_state_t *st, int error_correction); 00095 00096 int lpc10_decode_release(lpc10_decode_state_t *s); 00097 00098 /*! Decode a buffer of LPC10e data to linear PCM. 00099 \param s The LPC10e context. 00100 \param amp The audio sample buffer. 00101 \param code The LPC10e data. 00102 \param len The number of bytes of LPC10e data to be decoded. This must be a multiple of 7, 00103 as each frame is packed into 7 bytes. 00104 \return The number of samples returned. */ 00105 int lpc10_decode(lpc10_decode_state_t *s, int16_t amp[], const uint8_t code[], int len); 00106 00107 00108 #if defined(__cplusplus) 00109 } 00110 #endif 00111 00112 #endif 00113 /*- End of include ---------------------------------------------------------*/