bitstream.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * bitstream.h - Bitstream composition and decomposition routines.
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 General Public License version 2, as
00014  * 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 General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  *
00025  * $Id: bitstream.h,v 1.7 2007/08/20 15:22:22 steveu Exp $
00026  */
00027 
00028 /*! \file */
00029 
00030 #if !defined(_SPANDSP_BITSTREAM_H_)
00031 #define _SPANDSP_BITSTREAM_H_
00032 
00033 /*! \page bitstream_page Bitstream composition and decomposition
00034 \section bitstream_page_sec_1 What does it do?
00035 
00036 \section bitstream_page_sec_2 How does it work?
00037 */
00038 
00039 typedef struct
00040 {
00041     unsigned int bitstream;
00042     unsigned int residue;
00043 } bitstream_state_t;
00044 
00045 
00046 #if defined(__cplusplus)
00047 extern "C"
00048 {
00049 #endif
00050 
00051 /*! \brief Put a chunk of bits into the output buffer.
00052     \param s A pointer to the bitstream context.
00053     \param c A pointer to the bitstream output buffer.
00054     \param value The value to be pushed into the output buffer.
00055     \param bits The number of bits of value to be pushed. 1 to 25 bit is valid. */
00056 void bitstream_put(bitstream_state_t *s, uint8_t **c, unsigned int value, int bits);
00057 
00058 void bitstream_put2(bitstream_state_t *s, uint8_t **c, unsigned int value, int bits);
00059 
00060 /*! \brief Get a chunk of bits from the input buffer.
00061     \param s A pointer to the bitstream context.
00062     \param c A pointer to the bitstream input buffer.
00063     \param bits The number of bits of value to be grabbed. 1 to 25 bit is valid.
00064     \return The value retrieved from the input buffer. */
00065 unsigned int bitstream_get(bitstream_state_t *s, const uint8_t **c, int bits);
00066 
00067 unsigned int bitstream_get2(bitstream_state_t *s, const uint8_t **c, int bits);
00068 
00069 /*! \brief Flush any residual bit to the output buffer.
00070     \param s A pointer to the bitstream context.
00071     \param c A pointer to the bitstream output buffer. */
00072 void bitstream_flush(bitstream_state_t *s, uint8_t **c);
00073 
00074 void bitstream_flush2(bitstream_state_t *s, uint8_t **c);
00075 
00076 /*! \brief Initialise a bitstream context.
00077     \param s A pointer to the bitstream context.
00078     \return A pointer to the bitstream context. */
00079 bitstream_state_t *bitstream_init(bitstream_state_t *s);
00080 
00081 #if defined(__cplusplus)
00082 }
00083 #endif
00084 
00085 #endif
00086 /*- End of file ------------------------------------------------------------*/

Generated on Mon Dec 3 15:37:14 2007 for libspandsp by  doxygen 1.5.4