1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
/*
* libopenraw - crwdecompressor.h
*
* Copyright (C) 2007 Hubert Figuiere
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef __OPENRAW_CRWDECOMPRESS_H__
#define __OPENRAW_CRWDECOMPRESS_H__
#include <boost/noncopyable.hpp>
#include <libopenraw/libopenraw.h>
#include "decompressor.h"
namespace OpenRaw {
class RawData;
namespace IO {
class Stream;
}
namespace Internals {
class RawContainer;
class CrwDecompressor
: public Decompressor
{
public:
CrwDecompressor(IO::Stream * stream,
RawContainer * container);
virtual ~CrwDecompressor();
/** decompress the bitmapdata and return a new bitmap
* @param in a preallocated BitmapData instance
* or NULL if decompress has to allocate it.
* @return the new bitmap decompressed. NULL is failure.
* Caller owns it.
* @todo use a shared_ptr here, or something
*/
virtual RawData *decompress(RawData *in = NULL);
void setDecoderTable(uint32_t t)
{ m_table = t; }
void setOutputDimensions(uint32_t x, uint32_t y)
{ m_height = y; m_width = x; }
private:
struct decode_t {
decode_t *branch[2];
int leaf;
};
uint32_t getbits(IO::Stream * s, int nbits);
void make_decoder(decode_t *dest, const uint8_t *source,
int level);
void init_tables(uint32_t table_idx);
uint32_t m_table;
uint32_t m_height, m_width;
decode_t m_first_decode[32];
decode_t m_second_decode[512];
// for make_decoder
decode_t *m_free; /* Next unused node */
int m_leaf; /* no. of leaves already added */
// for getbits
uint32_t m_bitbuf;
int m_vbits;
};
}
}
#endif
|