/***************************************************************************
* Copyright (C) 2008 by Lorenzo La Porta *
* lorelapo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef BITSTREAM_H
#define BITSTREAM_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#define GETNBIT(x, n) ((x)>>(n) & 01)
#define SETNBIT(x, n, stat) (stat?((x)|=(01<<(n))):((x)&=~(01<<(n))))
typedef unsigned long word;
typedef struct bitstream_t
{
FILE *fp; //File buffer
char buffer; //Buffer di bit
int n; //Bit letti
int read; //Lettura o scrittura
}bitstream_t; //Fornisce un buffer di lettura/scrittura dei bit
bitstream_t *bitstream_new(FILE *, int read);
void bitstream_free(bitstream_t *);
void bitstream_add_bit(bitstream_t *, int);
int bitstream_read_bit(bitstream_t *);
#endif