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 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: bitstream.h,v 1.10 2008/04/17 14:27:00 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 /*! Bitstream handler state */
00040 typedef struct
00041 {
00042     /*! The bit stream. */
00043     unsigned int bitstream;
00044     /*! The residual bits in bitstream. */
00045     unsigned int residue;
00046 } bitstream_state_t;
00047 
00048 
00049 #if defined(__cplusplus)
00050 extern "C"
00051 {
00052 #endif
00053 
00054 /*! \brief Put a chunk of bits into the output buffer.
00055     \param s A pointer to the bitstream context.
00056     \param c A pointer to the bitstream output buffer.
00057     \param value The value to be pushed into the output buffer.
00058     \param bits The number of bits of value to be pushed. 1 to 25 bit is valid. */
00059 void bitstream_put(bitstream_state_t *s, uint8_t **c, unsigned int value, int bits);
00060 
00061 void bitstream_put2(bitstream_state_t *s, uint8_t **c, unsigned int value, int bits);
00062 
00063 /*! \brief Get a chunk of bits from the input buffer.
00064     \param s A pointer to the bitstream context.
00065     \param c A pointer to the bitstream input buffer.
00066     \param bits The number of bits of value to be grabbed. 1 to 25 bit is valid.
00067     \return The value retrieved from the input buffer. */
00068 unsigned int bitstream_get(bitstream_state_t *s, const uint8_t **c, int bits);
00069 
00070 unsigned int bitstream_get2(bitstream_state_t *s, const uint8_t **c, int bits);
00071 
00072 /*! \brief Flush any residual bit to the output buffer.
00073     \param s A pointer to the bitstream context.
00074     \param c A pointer to the bitstream output buffer. */
00075 void bitstream_flush(bitstream_state_t *s, uint8_t **c);
00076 
00077 void bitstream_flush2(bitstream_state_t *s, uint8_t **c);
00078 
00079 /*! \brief Initialise a bitstream context.
00080     \param s A pointer to the bitstream context.
00081     \return A pointer to the bitstream context. */
00082 bitstream_state_t *bitstream_init(bitstream_state_t *s);
00083 
00084 #if defined(__cplusplus)
00085 }
00086 #endif
00087 
00088 #endif
00089 /*- End of file ------------------------------------------------------------*/

Generated on Tue Oct 7 20:25:45 2008 for spandsp by  doxygen 1.5.6