Blame lib/crwdecompressor.hpp

rpm-build d2b433
/* -*- Mode: C++ -*- */
rpm-build d2b433
/*
rpm-build d2b433
 * libopenraw - crwdecompressor.h
rpm-build d2b433
 *
rpm-build d2b433
 * Copyright (C) 2007-2016 Hubert Figuiere
rpm-build d2b433
 *
rpm-build d2b433
 * This library is free software: you can redistribute it and/or
rpm-build d2b433
 * modify it under the terms of the GNU Lesser General Public License
rpm-build d2b433
 * as published by the Free Software Foundation, either version 3 of
rpm-build d2b433
 * the License, or (at your option) any later version.
rpm-build d2b433
 *
rpm-build d2b433
 * This library is distributed in the hope that it will be useful,
rpm-build d2b433
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build d2b433
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build d2b433
 * Lesser General Public License for more details.
rpm-build d2b433
 *
rpm-build d2b433
 * You should have received a copy of the GNU Lesser General Public
rpm-build d2b433
 * License along with this library.  If not, see
rpm-build d2b433
 * <http://www.gnu.org/licenses/>.
rpm-build d2b433
 */
rpm-build d2b433
rpm-build d2b433
#ifndef OR_INTERNALS_CRWDECOMPRESS_H_
rpm-build d2b433
#define OR_INTERNALS_CRWDECOMPRESS_H_
rpm-build d2b433
rpm-build d2b433
#include <stddef.h>
rpm-build d2b433
#include <stdint.h>
rpm-build d2b433
rpm-build d2b433
#include "decompressor.hpp"
rpm-build d2b433
rpm-build d2b433
namespace OpenRaw {
rpm-build d2b433
rpm-build d2b433
class RawData;
rpm-build d2b433
rpm-build d2b433
namespace IO {
rpm-build d2b433
class Stream;
rpm-build d2b433
}
rpm-build d2b433
rpm-build d2b433
namespace Internals {
rpm-build d2b433
rpm-build d2b433
class RawContainer;
rpm-build d2b433
rpm-build d2b433
class CrwDecompressor : public Decompressor {
rpm-build d2b433
public:
rpm-build d2b433
    CrwDecompressor(IO::Stream *stream, RawContainer *container);
rpm-build d2b433
    virtual ~CrwDecompressor();
rpm-build d2b433
rpm-build d2b433
    /** decompress the bitmapdata and return a new bitmap
rpm-build d2b433
     * @return the new bitmap decompressed. NULL is failure.
rpm-build d2b433
     */
rpm-build d2b433
    virtual RawDataPtr decompress() override;
rpm-build d2b433
    void setDecoderTable(uint32_t t) { m_table = t; }
rpm-build d2b433
    void setOutputDimensions(uint32_t x, uint32_t y) {
rpm-build d2b433
        m_height = y;
rpm-build d2b433
        m_width = x;
rpm-build d2b433
    }
rpm-build d2b433
rpm-build d2b433
private:
rpm-build d2b433
    struct decode_t {
rpm-build d2b433
        decode_t *branch[2];
rpm-build d2b433
        int leaf;
rpm-build d2b433
    };
rpm-build d2b433
rpm-build d2b433
    uint32_t getbits(IO::Stream *s, int nbits);
rpm-build d2b433
    void make_decoder(decode_t *dest, const uint8_t *source, int level);
rpm-build d2b433
    void init_tables(uint32_t table_idx);
rpm-build d2b433
rpm-build d2b433
    uint32_t m_table;
rpm-build d2b433
    uint32_t m_height, m_width;
rpm-build d2b433
rpm-build d2b433
    decode_t m_first_decode[32];
rpm-build d2b433
    decode_t m_second_decode[512];
rpm-build d2b433
    // for make_decoder
rpm-build d2b433
    decode_t *m_free; /* Next unused node */
rpm-build d2b433
    int m_leaf;       /* no. of leaves already added */
rpm-build d2b433
    // for getbits
rpm-build d2b433
    uint32_t m_bitbuf;
rpm-build d2b433
    int m_vbits;
rpm-build d2b433
};
rpm-build d2b433
}
rpm-build d2b433
}
rpm-build d2b433
rpm-build d2b433
#endif