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