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