Doxygen Source Code Documentation
bitio.h
Go to the documentation of this file.00001 /*===========================================================================* 00002 * bitio.h * 00003 * * 00004 * bitwise input/output * 00005 * * 00006 *===========================================================================*/ 00007 00008 /* 00009 * Copyright (c) 1995 The Regents of the University of California. 00010 * All rights reserved. 00011 * 00012 * Permission to use, copy, modify, and distribute this software and its 00013 * documentation for any purpose, without fee, and without written agreement is 00014 * hereby granted, provided that the above copyright notice and the following 00015 * two paragraphs appear in all copies of this software. 00016 * 00017 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR 00018 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00019 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF 00020 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00021 * 00022 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00023 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00024 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 00025 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO 00026 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 00027 */ 00028 00029 /* 00030 * $Header: /misc/elrond0/share/cvs/AFNI/src/mpeg_encodedir/headers/bitio.h,v 1.5 2004/04/02 15:12:41 rwcox Exp $ 00031 * $Log: bitio.h,v $ 00032 * Revision 1.5 2004/04/02 15:12:41 rwcox 00033 * Cput 00034 * 00035 * Revision 1.4 2004/02/05 21:32:23 rwcox 00036 * Cput 00037 * 00038 * Revision 1.3 2003/12/23 13:50:08 rwcox 00039 * Cput 00040 * 00041 * Revision 1.2 2003/12/03 14:46:15 rwcox 00042 * Cput 00043 * 00044 * Revision 1.1 2001/12/17 18:25:44 rwcox 00045 * Cadd 00046 * 00047 * Revision 1.8 1995/01/19 23:54:37 eyhung 00048 * Changed copyrights 00049 * 00050 * Revision 1.7 1994/11/12 02:12:14 keving 00051 * nothing 00052 * 00053 * Revision 1.6 1993/07/22 22:24:23 keving 00054 * nothing 00055 * 00056 * Revision 1.5 1993/07/09 00:17:23 keving 00057 * nothing 00058 * 00059 * Revision 1.4 1993/06/03 21:08:53 keving 00060 * nothing 00061 * 00062 * Revision 1.3 1993/01/18 10:20:02 dwallach 00063 * *** empty log message *** 00064 * 00065 * Revision 1.2 1993/01/18 10:17:29 dwallach 00066 * RCS headers installed, code indented uniformly 00067 * 00068 * Revision 1.2 1993/01/18 10:17:29 dwallach 00069 * RCS headers installed, code indented uniformly 00070 * 00071 */ 00072 00073 00074 #ifndef BIT_IO_INCLUDED 00075 #define BIT_IO_INCLUDED 00076 00077 00078 /*==============* 00079 * HEADER FILES * 00080 *==============*/ 00081 00082 #include "general.h" 00083 #include "ansi.h" 00084 00085 00086 /*===========* 00087 * CONSTANTS * 00088 *===========*/ 00089 00090 #define WORDS_PER_BUCKET 128 00091 #define MAXBITS_PER_BUCKET (WORDS_PER_BUCKET * 32) 00092 #define MAX_BUCKETS 128 00093 #define MAX_BITS MAX_BUCKETS*MAXBITS_PER_BUCKET 00094 00095 00096 /*=======================* 00097 * STRUCTURE DEFINITIONS * 00098 *=======================*/ 00099 00100 typedef struct bitBucket { 00101 struct bitBucket *nextPtr; 00102 uint32 bits[WORDS_PER_BUCKET]; 00103 int bitsleft, bitsleftcur, currword; 00104 } ActualBucket; 00105 00106 typedef struct _BitBucket { 00107 int totalbits; 00108 int cumulativeBits; 00109 int bitsWritten; 00110 FILE *filePtr; 00111 ActualBucket *firstPtr; 00112 ActualBucket *lastPtr; 00113 } BitBucket; 00114 00115 00116 /*========* 00117 * MACROS * 00118 *========*/ 00119 00120 #define SET_ITH_BIT(bits, i) (bits |= (1 << (i))) 00121 #define GET_ITH_BIT(bits, i) (bits & (1 << (i))) 00122 00123 00124 /*===============================* 00125 * EXTERNAL PROCEDURE prototypes * 00126 *===============================*/ 00127 00128 void Bitio_Free _ANSI_ARGS_((BitBucket *bbPtr)); 00129 void Bitio_Write _ANSI_ARGS_((BitBucket *bbPtr, uint32 bits, int nbits)); 00130 void Bitio_BytePad _ANSI_ARGS_((BitBucket *bbPtr)); 00131 BitBucket *Bitio_New _ANSI_ARGS_((FILE *filePtr)); 00132 void Bitio_Flush _ANSI_ARGS_((BitBucket *bbPtr)); 00133 void Bitio_WriteToSocket _ANSI_ARGS_((BitBucket *bbPtr, int socket)); 00134 00135 00136 #endif /* BIT_IO_INCLUDED */