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 00026 #if !defined(_SPANDSP_LPC10_H_) 00027 #define _SPANDSP_LPC10_H_ 00028 00029 /*! \page lpc10_page LPC10 encoding and decoding 00030 \section lpc10_page_sec_1 What does it do? 00031 The LPC10 module implements the US Department of Defense LPC10 00032 codec. This codec produces compressed data at 2400bps. At such 00033 a low rate high fidelity cannot be expected. However, the speech 00034 clarity is quite good, and this codec is unencumbered by patent 00035 or other restrictions. 00036 00037 \section lpc10_page_sec_2 How does it work? 00038 ???. 00039 */ 00040 00041 #define LPC10_SAMPLES_PER_FRAME 180 00042 #define LPC10_BITS_IN_COMPRESSED_FRAME 54 00043 00044 /*! 00045 LPC10 codec unpacked frame. 00046 */ 00047 typedef struct 00048 { 00049 /*! Pitch */ 00050 int32_t ipitch; 00051 /*! Energy */ 00052 int32_t irms; 00053 /*! Reflection coefficients */ 00054 int32_t irc[10]; 00055 } lpc10_frame_t; 00056 00057 /*! 00058 LPC10 codec encoder state descriptor. This defines the state of 00059 a single working instance of the LPC10 encoder. 00060 */ 00061 typedef struct lpc10_encode_state_s lpc10_encode_state_t; 00062 00063 /*! 00064 LPC10 codec decoder state descriptor. This defines the state of 00065 a single working instance of the LPC10 decoder. 00066 */ 00067 typedef struct lpc10_decode_state_s lpc10_decode_state_t; 00068 00069 #if defined(__cplusplus) 00070 extern "C" 00071 { 00072 #endif 00073 00074 /*! Initialise an LPC10e encode context. 00075 \param s The LPC10e context 00076 \param error_correction ??? 00077 \return A pointer to the LPC10e context, or NULL for error. */ 00078 SPAN_DECLARE(lpc10_encode_state_t *) lpc10_encode_init(lpc10_encode_state_t *s, int error_correction); 00079 00080 SPAN_DECLARE(int) lpc10_encode_release(lpc10_encode_state_t *s); 00081 00082 SPAN_DECLARE(int) lpc10_encode_free(lpc10_encode_state_t *s); 00083 00084 /*! Encode a buffer of linear PCM data to LPC10e. 00085 \param s The LPC10e context. 00086 \param ima_data The LPC10e data produced. 00087 \param amp The audio sample buffer. 00088 \param len The number of samples in the buffer. This must be a multiple of 180, as 00089 this is the number of samples on a frame. 00090 \return The number of bytes of LPC10e data produced. */ 00091 SPAN_DECLARE(int) lpc10_encode(lpc10_encode_state_t *s, uint8_t code[], const int16_t amp[], int len); 00092 00093 /*! Initialise an LPC10e decode context. 00094 \param s The LPC10e context 00095 \param error_correction ??? 00096 \return A pointer to the LPC10e context, or NULL for error. */ 00097 SPAN_DECLARE(lpc10_decode_state_t *) lpc10_decode_init(lpc10_decode_state_t *st, int error_correction); 00098 00099 SPAN_DECLARE(int) lpc10_decode_release(lpc10_decode_state_t *s); 00100 00101 SPAN_DECLARE(int) lpc10_decode_free(lpc10_decode_state_t *s); 00102 00103 /*! Decode a buffer of LPC10e data to linear PCM. 00104 \param s The LPC10e context. 00105 \param amp The audio sample buffer. 00106 \param code The LPC10e data. 00107 \param len The number of bytes of LPC10e data to be decoded. This must be a multiple of 7, 00108 as each frame is packed into 7 bytes. 00109 \return The number of samples returned. */ 00110 SPAN_DECLARE(int) lpc10_decode(lpc10_decode_state_t *s, int16_t amp[], const uint8_t code[], int len); 00111 00112 00113 #if defined(__cplusplus) 00114 } 00115 #endif 00116 00117 #endif 00118 /*- End of include ---------------------------------------------------------*/