ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mpeg_encode/src/bitio.h
Revision: 22
Committed: Mon Jul 7 22:16:37 2008 UTC (11 years, 4 months ago) by wdelano
File size: 3494 byte(s)
Log Message:
initial checkin of mpeg_encode source
Line File contents
1 /*===========================================================================*
2 * bitio.h *
3 * *
4 * bitwise input/output *
5 * *
6 *===========================================================================*/
7
8 /*
9 * Copyright (c) 1995 The Regents of the University of California.
10 * All rights reserved.
11 *
12 * Permission to use, copy, modify, and distribute this software and its
13 * documentation for any purpose, without fee, and without written agreement is
14 * hereby granted, provided that the above copyright notice and the following
15 * two paragraphs appear in all copies of this software.
16 *
17 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
18 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
19 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
20 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 *
22 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
25 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
26 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
27 */
28
29 /*
30 * $Header: /n/charlie-brown/project/mm/mpeg/mpeg_dist/mpeg_encode/headers/RCS/bitio.h,v 1.8 1995/01/19 23:54:37 eyhung Exp $
31 * $Log: bitio.h,v $
32 * Revision 1.8 1995/01/19 23:54:37 eyhung
33 * Changed copyrights
34 *
35 * Revision 1.7 1994/11/12 02:12:14 keving
36 * nothing
37 *
38 * Revision 1.6 1993/07/22 22:24:23 keving
39 * nothing
40 *
41 * Revision 1.5 1993/07/09 00:17:23 keving
42 * nothing
43 *
44 * Revision 1.4 1993/06/03 21:08:53 keving
45 * nothing
46 *
47 * Revision 1.3 1993/01/18 10:20:02 dwallach
48 * *** empty log message ***
49 *
50 * Revision 1.2 1993/01/18 10:17:29 dwallach
51 * RCS headers installed, code indented uniformly
52 *
53 * Revision 1.2 1993/01/18 10:17:29 dwallach
54 * RCS headers installed, code indented uniformly
55 *
56 */
57
58
59 #ifndef BIT_IO_INCLUDED
60 #define BIT_IO_INCLUDED
61
62
63 /*==============*
64 * HEADER FILES *
65 *==============*/
66
67 #include "general.h"
68 #include "ansi.h"
69
70
71 /*===========*
72 * CONSTANTS *
73 *===========*/
74
75 #define WORDS_PER_BUCKET 128
76 #define MAXBITS_PER_BUCKET (WORDS_PER_BUCKET * 32)
77 #define MAX_BUCKETS 128
78 #define MAX_BITS MAX_BUCKETS*MAXBITS_PER_BUCKET
79
80
81 /*=======================*
82 * STRUCTURE DEFINITIONS *
83 *=======================*/
84
85 typedef struct bitBucket {
86 struct bitBucket *nextPtr;
87 uint32 bits[WORDS_PER_BUCKET];
88 int bitsleft, bitsleftcur, currword;
89 } ActualBucket;
90
91 typedef struct _BitBucket {
92 int totalbits;
93 int cumulativeBits;
94 int bitsWritten;
95 FILE *filePtr;
96 ActualBucket *firstPtr;
97 ActualBucket *lastPtr;
98 } BitBucket;
99
100
101 /*========*
102 * MACROS *
103 *========*/
104
105 #define SET_ITH_BIT(bits, i) (bits |= (1 << (i)))
106 #define GET_ITH_BIT(bits, i) (bits & (1 << (i)))
107
108
109 /*===============================*
110 * EXTERNAL PROCEDURE prototypes *
111 *===============================*/
112
113 void Bitio_Free _ANSI_ARGS_((BitBucket *bbPtr));
114 void Bitio_Write _ANSI_ARGS_((BitBucket *bbPtr, uint32 bits, int nbits));
115 void Bitio_BytePad _ANSI_ARGS_((BitBucket *bbPtr));
116 BitBucket *Bitio_New _ANSI_ARGS_((FILE *filePtr));
117 void Bitio_Flush _ANSI_ARGS_((BitBucket *bbPtr));
118 void Bitio_WriteToSocket _ANSI_ARGS_((BitBucket *bbPtr, int socket));
119
120
121 #endif /* BIT_IO_INCLUDED */