crwdecompressor.h

00001 /*
00002  * libopenraw - crwdecompressor.h
00003  *
00004  * Copyright (C) 2007 Hubert Figuiere
00005  *
00006  * This library is free software: you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public License
00008  * as published by the Free Software Foundation, either version 3 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library.  If not, see
00018  * <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 #ifndef __OPENRAW_CRWDECOMPRESS_H__
00022 #define __OPENRAW_CRWDECOMPRESS_H__
00023 
00024 #include <boost/noncopyable.hpp>
00025 
00026 #include <libopenraw/libopenraw.h>
00027 
00028 #include "decompressor.h"
00029 
00030 namespace OpenRaw {
00031 
00032     class RawData;
00033 
00034     namespace IO {
00035         class Stream;
00036     }
00037 
00038     namespace Internals {
00039 
00040         class RawContainer;
00041 
00042         class CrwDecompressor
00043             : public Decompressor
00044         {
00045         public:
00046             CrwDecompressor(IO::Stream * stream,
00047                                                     RawContainer * container);
00048             virtual ~CrwDecompressor();
00049             
00057             virtual RawData *decompress(RawData *in = NULL);
00058             void setDecoderTable(uint32_t t)
00059                 { m_table = t; }
00060             void setOutputDimensions(uint32_t x, uint32_t y)
00061                 { m_height = y; m_width = x; }
00062         private:
00063             
00064             struct decode_t {
00065                 decode_t *branch[2];
00066                 int leaf;
00067             };
00068 
00069             uint32_t getbits(IO::Stream * s, int nbits);
00070             void make_decoder(decode_t *dest, const uint8_t *source, 
00071                                                 int level);
00072             void init_tables(uint32_t table_idx);
00073 
00074             uint32_t m_table;
00075             uint32_t m_height, m_width;
00076 
00077             decode_t m_first_decode[32];
00078             decode_t m_second_decode[512];
00079             // for make_decoder
00080             decode_t *m_free; /* Next unused node */
00081             int m_leaf; /* no. of leaves already added */
00082             // for getbits
00083             uint32_t m_bitbuf;
00084             int m_vbits;
00085         };
00086 
00087     }
00088 }
00089 
00090 
00091 #endif
Generated on Thu Jul 29 20:40:27 2010 for libopenraw by  doxygen 1.6.3