00001 /* 00002 Copyright (c) 2000-2003 Lee Thomason (www.grinninglizard.com) 00003 00004 Grinning Lizard Utilities. Note that software that uses the 00005 utility package (including Lilith3D and Kyra) have more restrictive 00006 licences which applies to code outside of the utility package. 00007 00008 00009 This software is provided 'as-is', without any express or implied 00010 warranty. In no event will the authors be held liable for any 00011 damages arising from the use of this software. 00012 00013 Permission is granted to anyone to use this software for any 00014 purpose, including commercial applications, and to alter it and 00015 redistribute it freely, subject to the following restrictions: 00016 00017 1. The origin of this software must not be misrepresented; you must 00018 not claim that you wrote the original software. If you use this 00019 software in a product, an acknowledgment in the product documentation 00020 would be appreciated but is not required. 00021 00022 2. Altered source versions must be plainly marked as such, and 00023 must not be misrepresented as being the original software. 00024 00025 3. This notice may not be removed or altered from any source 00026 distribution. 00027 */ 00028 00029 #ifndef BITSTREAMER_INCLUDED 00030 #define BITSTREAMER_INCLUDED 00031 00032 #include "../../grinliz/gltypes.h" 00033 #include "SDL_rwops.h" 00034 00035 00036 class GlBitStream 00037 { 00038 public: 00039 static int BitsNeeded( U32 maxValue ); 00040 00041 }; 00042 00043 class GlWriteBitStream : public GlBitStream 00044 { 00045 public: 00046 GlWriteBitStream( SDL_RWops* fp ); 00047 ~GlWriteBitStream(); 00048 00049 void WriteBits( U32 data, int nBitsInData ); 00050 void Flush(); 00051 00052 private: 00053 SDL_RWops* fp; 00054 00055 U8 accum; 00056 int bitsLeft; 00057 }; 00058 00059 00060 class GlReadBitStream : public GlBitStream 00061 { 00062 public: 00063 GlReadBitStream( SDL_RWops* fp ); 00064 ~GlReadBitStream() {} 00065 00066 U32 ReadBits( int nBitsInData ); 00067 void Flush(); 00068 00069 private: 00070 SDL_RWops* fp; 00071 int bitsLeft; 00072 U8 accum; 00073 }; 00074 00075 #endif
1.4.7