Path: blob/master/3rdparty/libwebp/src/dec/vp8li_dec.h
16358 views
// Copyright 2012 Google Inc. All Rights Reserved.1//2// Use of this source code is governed by a BSD-style license3// that can be found in the COPYING file in the root of the source4// tree. An additional intellectual property rights grant can be found5// in the file PATENTS. All contributing project authors may6// be found in the AUTHORS file in the root of the source tree.7// -----------------------------------------------------------------------------8//9// Lossless decoder: internal header.10//11// Author: Skal ([email protected])12// Vikas Arora([email protected])1314#ifndef WEBP_DEC_VP8LI_DEC_H_15#define WEBP_DEC_VP8LI_DEC_H_1617#include <string.h> // for memcpy()18#include "src/dec/webpi_dec.h"19#include "src/utils/bit_reader_utils.h"20#include "src/utils/color_cache_utils.h"21#include "src/utils/huffman_utils.h"2223#ifdef __cplusplus24extern "C" {25#endif2627typedef enum {28READ_DATA = 0,29READ_HDR = 1,30READ_DIM = 231} VP8LDecodeState;3233typedef struct VP8LTransform VP8LTransform;34struct VP8LTransform {35VP8LImageTransformType type_; // transform type.36int bits_; // subsampling bits defining transform window.37int xsize_; // transform window X index.38int ysize_; // transform window Y index.39uint32_t *data_; // transform data.40};4142typedef struct {43int color_cache_size_;44VP8LColorCache color_cache_;45VP8LColorCache saved_color_cache_; // for incremental4647int huffman_mask_;48int huffman_subsample_bits_;49int huffman_xsize_;50uint32_t *huffman_image_;51int num_htree_groups_;52HTreeGroup *htree_groups_;53HuffmanCode *huffman_tables_;54} VP8LMetadata;5556typedef struct VP8LDecoder VP8LDecoder;57struct VP8LDecoder {58VP8StatusCode status_;59VP8LDecodeState state_;60VP8Io *io_;6162const WebPDecBuffer *output_; // shortcut to io->opaque->output6364uint32_t *pixels_; // Internal data: either uint8_t* for alpha65// or uint32_t* for BGRA.66uint32_t *argb_cache_; // Scratch buffer for temporary BGRA storage.6768VP8LBitReader br_;69int incremental_; // if true, incremental decoding is expected70VP8LBitReader saved_br_; // note: could be local variables too71int saved_last_pixel_;7273int width_;74int height_;75int last_row_; // last input row decoded so far.76int last_pixel_; // last pixel decoded so far. However, it may77// not be transformed, scaled and78// color-converted yet.79int last_out_row_; // last row output so far.8081VP8LMetadata hdr_;8283int next_transform_;84VP8LTransform transforms_[NUM_TRANSFORMS];85// or'd bitset storing the transforms types.86uint32_t transforms_seen_;8788uint8_t *rescaler_memory; // Working memory for rescaling work.89WebPRescaler *rescaler; // Common rescaler for all channels.90};9192//------------------------------------------------------------------------------93// internal functions. Not public.9495struct ALPHDecoder; // Defined in dec/alphai.h.9697// in vp8l.c9899// Decodes image header for alpha data stored using lossless compression.100// Returns false in case of error.101int VP8LDecodeAlphaHeader(struct ALPHDecoder* const alph_dec,102const uint8_t* const data, size_t data_size);103104// Decodes *at least* 'last_row' rows of alpha. If some of the initial rows are105// already decoded in previous call(s), it will resume decoding from where it106// was paused.107// Returns false in case of bitstream error.108int VP8LDecodeAlphaImageStream(struct ALPHDecoder* const alph_dec,109int last_row);110111// Allocates and initialize a new lossless decoder instance.112VP8LDecoder* VP8LNew(void);113114// Decodes the image header. Returns false in case of error.115int VP8LDecodeHeader(VP8LDecoder* const dec, VP8Io* const io);116117// Decodes an image. It's required to decode the lossless header before calling118// this function. Returns false in case of error, with updated dec->status_.119int VP8LDecodeImage(VP8LDecoder* const dec);120121// Resets the decoder in its initial state, reclaiming memory.122// Preserves the dec->status_ value.123void VP8LClear(VP8LDecoder* const dec);124125// Clears and deallocate a lossless decoder instance.126void VP8LDelete(VP8LDecoder* const dec);127128//------------------------------------------------------------------------------129130#ifdef __cplusplus131} // extern "C"132#endif133134#endif /* WEBP_DEC_VP8LI_DEC_H_ */135136137