kviewshell
BSByteStream.h
Go to the documentation of this file.00001 //C- -*- C++ -*- 00002 //C- ------------------------------------------------------------------- 00003 //C- DjVuLibre-3.5 00004 //C- Copyright (c) 2002 Leon Bottou and Yann Le Cun. 00005 //C- Copyright (c) 2001 AT&T 00006 //C- 00007 //C- This software is subject to, and may be distributed under, the 00008 //C- GNU General Public License, Version 2. The license should have 00009 //C- accompanied the software or you may obtain a copy of the license 00010 //C- from the Free Software Foundation at http://www.fsf.org . 00011 //C- 00012 //C- This program is distributed in the hope that it will be useful, 00013 //C- but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 //C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 //C- GNU General Public License for more details. 00016 //C- 00017 //C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library 00018 //C- distributed by Lizardtech Software. On July 19th 2002, Lizardtech 00019 //C- Software authorized us to replace the original DjVu(r) Reference 00020 //C- Library notice by the following text (see doc/lizard2002.djvu): 00021 //C- 00022 //C- ------------------------------------------------------------------ 00023 //C- | DjVu (r) Reference Library (v. 3.5) 00024 //C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved. 00025 //C- | The DjVu Reference Library is protected by U.S. Pat. No. 00026 //C- | 6,058,214 and patents pending. 00027 //C- | 00028 //C- | This software is subject to, and may be distributed under, the 00029 //C- | GNU General Public License, Version 2. The license should have 00030 //C- | accompanied the software or you may obtain a copy of the license 00031 //C- | from the Free Software Foundation at http://www.fsf.org . 00032 //C- | 00033 //C- | The computer code originally released by LizardTech under this 00034 //C- | license and unmodified by other parties is deemed "the LIZARDTECH 00035 //C- | ORIGINAL CODE." Subject to any third party intellectual property 00036 //C- | claims, LizardTech grants recipient a worldwide, royalty-free, 00037 //C- | non-exclusive license to make, use, sell, or otherwise dispose of 00038 //C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the 00039 //C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU 00040 //C- | General Public License. This grant only confers the right to 00041 //C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to 00042 //C- | the extent such infringement is reasonably necessary to enable 00043 //C- | recipient to make, have made, practice, sell, or otherwise dispose 00044 //C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to 00045 //C- | any greater extent that may be necessary to utilize further 00046 //C- | modifications or combinations. 00047 //C- | 00048 //C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY 00049 //C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 00050 //C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF 00051 //C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 00052 //C- +------------------------------------------------------------------ 00053 // 00054 // $Id: BSByteStream.h,v 1.8 2003/11/07 22:08:20 leonb Exp $ 00055 // $Name: release_3_5_15 $ 00056 00057 #ifndef _BSBYTESTREAM_H 00058 #define _BSBYTESTREAM_H 00059 #ifdef HAVE_CONFIG_H 00060 #include "config.h" 00061 #endif 00062 #if NEED_GNUG_PRAGMAS 00063 # pragma interface 00064 #endif 00065 00147 00148 00149 #include "ByteStream.h" 00150 #include "GException.h" 00151 #include "ZPCodec.h" 00152 00153 00154 #ifdef HAVE_NAMESPACES 00155 namespace DJVU { 00156 # ifdef NOT_DEFINED // Just to fool emacs c++ mode 00157 } 00158 #endif 00159 #endif 00160 00161 00199 class BSByteStream : public ByteStream 00200 { 00201 public: 00202 // Limits on block sizes 00203 enum { MINBLOCK=10, MAXBLOCK=4096 }; 00204 00205 // Sorting tresholds 00206 enum { FREQMAX=4, CTXIDS=3 }; 00207 00208 class Decode; 00209 class Encode; 00210 protected: 00211 BSByteStream(GP<ByteStream> bs); 00212 00213 public: 00222 static GP<ByteStream> create(GP<ByteStream> bs); 00223 00239 static GP<ByteStream> create(GP<ByteStream> bs, const int blocksize); 00240 00241 // ByteStream Interface 00242 ~BSByteStream(); 00243 virtual long tell(void) const; 00244 virtual void flush(void) = 0; 00245 protected: 00246 // Data 00247 long offset; 00248 int bptr; 00249 unsigned int blocksize; 00250 int size; 00251 ByteStream *bs; 00252 GP<ByteStream> gbs; 00253 unsigned char *data; 00254 GPBuffer<unsigned char> gdata; 00255 // Coder 00256 GP<ZPCodec> gzp; 00257 BitContext ctx[300]; 00258 private: 00259 // Cancel C++ default stuff 00260 BSByteStream(const BSByteStream &); 00261 BSByteStream & operator=(const BSByteStream &); 00262 BSByteStream(ByteStream *); 00263 BSByteStream(ByteStream *, int); 00264 }; 00265 00267 00268 00269 #ifdef HAVE_NAMESPACES 00270 } 00271 # ifndef NOT_USING_DJVU_NAMESPACE 00272 using namespace DJVU; 00273 # endif 00274 #endif 00275 #endif