diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-08-19 03:12:28 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-08-19 03:12:28 +0000 |
commit | 1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch) | |
tree | 64c8c96cf54d8718847339a403e5e67b922e8c3f /converter/other/fiasco/lib/bit-io.h | |
download | netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip |
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/fiasco/lib/bit-io.h')
-rw-r--r-- | converter/other/fiasco/lib/bit-io.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/converter/other/fiasco/lib/bit-io.h b/converter/other/fiasco/lib/bit-io.h new file mode 100644 index 00000000..d37cc47c --- /dev/null +++ b/converter/other/fiasco/lib/bit-io.h @@ -0,0 +1,58 @@ +/* + * bit-io.h + * + * Written by: Ullrich Hafner + * + * This file is part of FIASCO («F»ractal «I»mage «A»nd «S»equence «CO»dec) + * Copyright (C) 1994-2000 Ullrich Hafner <hafner@bigfoot.de> + */ + +/* + * $Date: 2000/06/14 20:49:37 $ + * $Author: hafner $ + * $Revision: 5.1 $ + * $State: Exp $ + */ + +#ifndef _BIT_IO_H +#define _BIT_IO_H + +#include <stdio.h> +#include "types.h" + +#define OUTPUT_BYTE_ALIGN(bfile) while ((bfile)->bitpos) put_bit (bfile, 0); +#define INPUT_BYTE_ALIGN(bfile) while ((bfile)->bitpos) get_bit (bfile); + +typedef enum {READ_ACCESS, WRITE_ACCESS} openmode_e; + +typedef struct bitfile +{ + FILE *file; /* associated filepointer */ + char *filename; /* corresponding filename */ + byte_t *buffer; /* stream buffer */ + byte_t *ptr; /* pointer to current buffer pos */ + unsigned bytepos; /* current I/O byte */ + unsigned bitpos; /* current I/O bit */ + unsigned bits_processed; /* number of bits already processed */ + openmode_e mode; /* access mode */ +} bitfile_t; + +FILE * +open_file (const char *filename, const char *env_var, openmode_e mode); +bitfile_t * +open_bitfile (const char *filename, const char *env_var, openmode_e mode); +void +put_bit (bitfile_t *bitfile, unsigned value); +void +put_bits (bitfile_t *bitfile, unsigned value, unsigned bits); +bool_t +get_bit (bitfile_t *bitfile); +unsigned +get_bits (bitfile_t *bitfile, unsigned bits); +void +close_bitfile (bitfile_t *bitfile); +unsigned +bits_processed (const bitfile_t *bitfile); + +#endif /* not _BIT_IO_H */ + |