Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Hzip - BitStream.h

BitStream.h

Caricato da:
Scarica il programma completo

  1. /***************************************************************************
  2.  *   Copyright (C) 2008 by Lorenzo La Porta   *
  3.  *   lorelapo@gmail.com   *
  4.  *                                                                         *
  5.  *   This program is free software; you can redistribute it and/or modify  *
  6.  *   it under the terms of the GNU General Public License as published by  *
  7.  *   the Free Software Foundation; either version 2 of the License, or     *
  8.  *   (at your option) any later version.                                   *
  9.  *                                                                         *
  10.  *   This program is distributed in the hope that it will be useful,       *
  11.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  12.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  13.  *   GNU General Public License for more details.                          *
  14.  *                                                                         *
  15.  *   You should have received a copy of the GNU General Public License     *
  16.  *   along with this program; if not, write to the                         *
  17.  *   Free Software Foundation, Inc.,                                       *
  18.  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  19.  ***************************************************************************/
  20.  
  21. #ifndef BITSTREAM_H
  22. #define BITSTREAM_H
  23. #ifdef HAVE_CONFIG_H
  24. #include <config.h>
  25. #endif
  26.  
  27.  
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30.  
  31. #define GETNBIT(x, n) ((x)>>(n) & 01)
  32. #define SETNBIT(x, n, stat) (stat?((x)|=(01<<(n))):((x)&=~(01<<(n))))
  33.  
  34. typedef unsigned long word;
  35.  
  36. typedef struct bitstream_t
  37. {
  38.         FILE *fp;       //File buffer
  39.         char buffer;    //Buffer di bit
  40.         int n;          //Bit letti
  41.         int read;       //Lettura o scrittura
  42. }bitstream_t;           //Fornisce un buffer di lettura/scrittura dei bit
  43.  
  44. bitstream_t *bitstream_new(FILE *, int read);
  45.  
  46. void bitstream_free(bitstream_t *);
  47.  
  48. void bitstream_add_bit(bitstream_t *, int);
  49.  
  50. int bitstream_read_bit(bitstream_t *);
  51.  
  52. #endif