lpc10.h

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.22 2009/04/11 18:11:19 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     /*! Pitch */
00052     int32_t ipitch;
00053     /*! Energy */
00054     int32_t irms;
00055     /*! Reflection coefficients */
00056     int32_t irc[10];
00057 } lpc10_frame_t;
00058 
00059 /*!
00060     LPC10 codec encoder state descriptor. This defines the state of
00061     a single working instance of the LPC10 encoder.
00062 */
00063 typedef struct lpc10_encode_state_s lpc10_encode_state_t;
00064 
00065 /*!
00066     LPC10 codec decoder state descriptor. This defines the state of
00067     a single working instance of the LPC10 decoder.
00068 */
00069 typedef struct lpc10_decode_state_s lpc10_decode_state_t;
00070 
00071 #if defined(__cplusplus)
00072 extern "C"
00073 {
00074 #endif
00075 
00076 /*! Initialise an LPC10e encode context.
00077     \param s The LPC10e context
00078     \param error_correction ???
00079     \return A pointer to the LPC10e context, or NULL for error. */
00080 SPAN_DECLARE(lpc10_encode_state_t *) lpc10_encode_init(lpc10_encode_state_t *s, int error_correction);
00081 
00082 SPAN_DECLARE(int) lpc10_encode_release(lpc10_encode_state_t *s);
00083 
00084 SPAN_DECLARE(int) lpc10_encode_free(lpc10_encode_state_t *s);
00085 
00086 /*! Encode a buffer of linear PCM data to LPC10e.
00087     \param s The LPC10e context.
00088     \param ima_data The LPC10e data produced.
00089     \param amp The audio sample buffer.
00090     \param len The number of samples in the buffer. This must be a multiple of 180, as
00091            this is the number of samples on a frame.
00092     \return The number of bytes of LPC10e data produced. */
00093 SPAN_DECLARE(int) lpc10_encode(lpc10_encode_state_t *s, uint8_t code[], const int16_t amp[], int len);
00094 
00095 /*! Initialise an LPC10e decode context.
00096     \param s The LPC10e context
00097     \param error_correction ???
00098     \return A pointer to the LPC10e context, or NULL for error. */
00099 SPAN_DECLARE(lpc10_decode_state_t *) lpc10_decode_init(lpc10_decode_state_t *st, int error_correction);
00100 
00101 SPAN_DECLARE(int) lpc10_decode_release(lpc10_decode_state_t *s);
00102 
00103 SPAN_DECLARE(int) lpc10_decode_free(lpc10_decode_state_t *s);
00104 
00105 /*! Decode a buffer of LPC10e data to linear PCM.
00106     \param s The LPC10e context.
00107     \param amp The audio sample buffer.
00108     \param code The LPC10e data.
00109     \param len The number of bytes of LPC10e data to be decoded. This must be a multiple of 7,
00110            as each frame is packed into 7 bytes.
00111     \return The number of samples returned. */
00112 SPAN_DECLARE(int) lpc10_decode(lpc10_decode_state_t *s, int16_t amp[], const uint8_t code[], int len);
00113 
00114 
00115 #if defined(__cplusplus)
00116 }
00117 #endif
00118 
00119 #endif
00120 /*- End of include ---------------------------------------------------------*/

Generated on Tue Aug 4 03:36:00 2009 for spandsp by  doxygen 1.5.9