// Copyright 2010 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // VP8 decoder: internal header. // // Author: Skal ([email protected]) #ifndef WEBP_DEC_VP8I_DEC_H_ #define WEBP_DEC_VP8I_DEC_H_ #include <string.h> // for memcpy() #include "src/dec/common_dec.h" #include "src/dec/vp8li_dec.h" #include "src/utils/bit_reader_utils.h" #include "src/utils/random_utils.h" #include "src/utils/thread_utils.h" #include "src/dsp/dsp.h" #include "src/webp/types.h" #ifdef __cplusplus extern "C" { #endif //------------------------------------------------------------------------------ // Various defines and enums // version numbers #define DEC_MAJ_VERSION … #define DEC_MIN_VERSION … #define DEC_REV_VERSION … // YUV-cache parameters. Cache is 32-bytes wide (= one cacheline). // Constraints are: We need to store one 16x16 block of luma samples (y), // and two 8x8 chroma blocks (u/v). These are better be 16-bytes aligned, // in order to be SIMD-friendly. We also need to store the top, left and // top-left samples (from previously decoded blocks), along with four // extra top-right samples for luma (intra4x4 prediction only). // One possible layout is, using 32 * (17 + 9) bytes: // // .+------ <- only 1 pixel high // .|yyyyt. // .|yyyyt. // .|yyyyt. // .|yyyy.. // .+--.+-- <- only 1 pixel high // .|uu.|vv // .|uu.|vv // // Every character is a 4x4 block, with legend: // '.' = unused // 'y' = y-samples 'u' = u-samples 'v' = u-samples // '|' = left sample, '-' = top sample, '+' = top-left sample // 't' = extra top-right sample for 4x4 modes #define YUV_SIZE … #define Y_OFF … #define U_OFF … #define V_OFF … // minimal width under which lossy multi-threading is always disabled #define MIN_WIDTH_FOR_THREADS … //------------------------------------------------------------------------------ // Headers VP8FrameHeader; VP8PictureHeader; // segment features VP8SegmentHeader; // probas associated to one of the contexts VP8ProbaArray; VP8BandProbas; // Struct collecting all frame-persistent probabilities. VP8Proba; // Filter parameters VP8FilterHeader; //------------------------------------------------------------------------------ // Informations about the macroblocks. VP8FInfo; VP8MB; // Dequantization matrices quant_t; // [DC / AC]. Can be 'uint16_t[2]' too (~slower). VP8QuantMatrix; // Data needed to reconstruct a macroblock VP8MBData; // Persistent information needed by the parallel processing VP8ThreadContext; // Saved top samples, per macroblock. Fits into a cache-line. VP8TopSamples; //------------------------------------------------------------------------------ // VP8Decoder: the main opaque structure handed over to user struct VP8Decoder { … }; //------------------------------------------------------------------------------ // internal functions. Not public. // in vp8.c int VP8SetError(VP8Decoder* const dec, VP8StatusCode error, const char* const msg); // in tree.c void VP8ResetProba(VP8Proba* const proba); void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec); // parses one row of intra mode data in partition 0, returns !eof int VP8ParseIntraModeRow(VP8BitReader* const br, VP8Decoder* const dec); // in quant.c void VP8ParseQuant(VP8Decoder* const dec); // in frame.c WEBP_NODISCARD int VP8InitFrame(VP8Decoder* const dec, VP8Io* const io); // Call io->setup() and finish setting up scan parameters. // After this call returns, one must always call VP8ExitCritical() with the // same parameters. Both functions should be used in pair. Returns VP8_STATUS_OK // if ok, otherwise sets and returns the error status on *dec. VP8StatusCode VP8EnterCritical(VP8Decoder* const dec, VP8Io* const io); // Must always be called in pair with VP8EnterCritical(). // Returns false in case of error. WEBP_NODISCARD int VP8ExitCritical(VP8Decoder* const dec, VP8Io* const io); // Return the multi-threading method to use (0=off), depending // on options and bitstream size. Only for lossy decoding. int VP8GetThreadMethod(const WebPDecoderOptions* const options, const WebPHeaderStructure* const headers, int width, int height); // Initialize dithering post-process if needed. void VP8InitDithering(const WebPDecoderOptions* const options, VP8Decoder* const dec); // Process the last decoded row (filtering + output). WEBP_NODISCARD int VP8ProcessRow(VP8Decoder* const dec, VP8Io* const io); // To be called at the start of a new scanline, to initialize predictors. void VP8InitScanline(VP8Decoder* const dec); // Decode one macroblock. Returns false if there is not enough data. WEBP_NODISCARD int VP8DecodeMB(VP8Decoder* const dec, VP8BitReader* const token_br); // in alpha.c const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, const VP8Io* const io, int row, int num_rows); //------------------------------------------------------------------------------ #ifdef __cplusplus } // extern "C" #endif #endif // WEBP_DEC_VP8I_DEC_H_