Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 1 | // Copyright 2010 Google Inc. All Rights Reserved. |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 2 | // |
Vikas Arora | 0406ce1 | 2013-08-09 15:57:12 -0700 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license |
| 4 | // that can be found in the COPYING file in the root of the source |
| 5 | // tree. An additional intellectual property rights grant can be found |
| 6 | // in the file PATENTS. All contributing project authors may |
| 7 | // be found in the AUTHORS file in the root of the source tree. |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 8 | // ----------------------------------------------------------------------------- |
| 9 | // |
| 10 | // VP8 decoder: internal header. |
| 11 | // |
| 12 | // Author: Skal (pascal.massimino@gmail.com) |
| 13 | |
Vikas Arora | 03d5e34 | 2011-06-02 23:59:44 +0530 | [diff] [blame] | 14 | #ifndef WEBP_DEC_VP8I_H_ |
| 15 | #define WEBP_DEC_VP8I_H_ |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 16 | |
| 17 | #include <string.h> // for memcpy() |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 18 | #include "./vp8li.h" |
| 19 | #include "../utils/bit_reader.h" |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 20 | #include "../utils/random.h" |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 21 | #include "../utils/thread.h" |
| 22 | #include "../dsp/dsp.h" |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 23 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 24 | #ifdef __cplusplus |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 25 | extern "C" { |
| 26 | #endif |
| 27 | |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 28 | //------------------------------------------------------------------------------ |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 29 | // Various defines and enums |
| 30 | |
Vikas Arora | 03d5e34 | 2011-06-02 23:59:44 +0530 | [diff] [blame] | 31 | // version numbers |
| 32 | #define DEC_MAJ_VERSION 0 |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 33 | #define DEC_MIN_VERSION 4 |
James Zern | 9e80ee9 | 2015-03-17 18:54:21 -0700 | [diff] [blame] | 34 | #define DEC_REV_VERSION 3 |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 35 | |
| 36 | // intra prediction modes |
| 37 | enum { B_DC_PRED = 0, // 4x4 modes |
| 38 | B_TM_PRED, |
| 39 | B_VE_PRED, |
| 40 | B_HE_PRED, |
| 41 | B_RD_PRED, |
| 42 | B_VR_PRED, |
| 43 | B_LD_PRED, |
| 44 | B_VL_PRED, |
| 45 | B_HD_PRED, |
| 46 | B_HU_PRED, |
| 47 | NUM_BMODES = B_HU_PRED + 1 - B_DC_PRED, // = 10 |
| 48 | |
| 49 | // Luma16 or UV modes |
| 50 | DC_PRED = B_DC_PRED, V_PRED = B_VE_PRED, |
| 51 | H_PRED = B_HE_PRED, TM_PRED = B_TM_PRED, |
| 52 | B_PRED = NUM_BMODES, // refined I4x4 mode |
| 53 | |
| 54 | // special modes |
| 55 | B_DC_PRED_NOTOP = 4, |
| 56 | B_DC_PRED_NOLEFT = 5, |
Vikas Arora | 03d5e34 | 2011-06-02 23:59:44 +0530 | [diff] [blame] | 57 | B_DC_PRED_NOTOPLEFT = 6, |
| 58 | NUM_B_DC_MODES = 7 }; |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 59 | |
| 60 | enum { MB_FEATURE_TREE_PROBS = 3, |
| 61 | NUM_MB_SEGMENTS = 4, |
| 62 | NUM_REF_LF_DELTAS = 4, |
| 63 | NUM_MODE_LF_DELTAS = 4, // I4x4, ZERO, *, SPLIT |
| 64 | MAX_NUM_PARTITIONS = 8, |
| 65 | // Probabilities |
| 66 | NUM_TYPES = 4, |
| 67 | NUM_BANDS = 8, |
| 68 | NUM_CTX = 3, |
| 69 | NUM_PROBAS = 11, |
| 70 | NUM_MV_PROBAS = 19 }; |
| 71 | |
| 72 | // YUV-cache parameters. |
| 73 | // Constraints are: We need to store one 16x16 block of luma samples (y), |
| 74 | // and two 8x8 chroma blocks (u/v). These are better be 16-bytes aligned, |
| 75 | // in order to be SIMD-friendly. We also need to store the top, left and |
| 76 | // top-left samples (from previously decoded blocks), along with four |
| 77 | // extra top-right samples for luma (intra4x4 prediction only). |
| 78 | // One possible layout is, using 32 * (17 + 9) bytes: |
| 79 | // |
| 80 | // .+------ <- only 1 pixel high |
| 81 | // .|yyyyt. |
| 82 | // .|yyyyt. |
| 83 | // .|yyyyt. |
| 84 | // .|yyyy.. |
| 85 | // .+--.+-- <- only 1 pixel high |
| 86 | // .|uu.|vv |
| 87 | // .|uu.|vv |
| 88 | // |
| 89 | // Every character is a 4x4 block, with legend: |
| 90 | // '.' = unused |
| 91 | // 'y' = y-samples 'u' = u-samples 'v' = u-samples |
| 92 | // '|' = left sample, '-' = top sample, '+' = top-left sample |
| 93 | // 't' = extra top-right sample for 4x4 modes |
| 94 | // With this layout, BPS (=Bytes Per Scan-line) is one cacheline size. |
| 95 | #define BPS 32 // this is the common stride used by yuv[] |
| 96 | #define YUV_SIZE (BPS * 17 + BPS * 9) |
| 97 | #define Y_SIZE (BPS * 17) |
| 98 | #define Y_OFF (BPS * 1 + 8) |
| 99 | #define U_OFF (Y_OFF + BPS * 16 + BPS) |
| 100 | #define V_OFF (U_OFF + 16) |
| 101 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 102 | // minimal width under which lossy multi-threading is always disabled |
| 103 | #define MIN_WIDTH_FOR_THREADS 512 |
| 104 | |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 105 | //------------------------------------------------------------------------------ |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 106 | // Headers |
| 107 | |
| 108 | typedef struct { |
| 109 | uint8_t key_frame_; |
| 110 | uint8_t profile_; |
| 111 | uint8_t show_; |
| 112 | uint32_t partition_length_; |
| 113 | } VP8FrameHeader; |
| 114 | |
| 115 | typedef struct { |
| 116 | uint16_t width_; |
| 117 | uint16_t height_; |
| 118 | uint8_t xscale_; |
| 119 | uint8_t yscale_; |
| 120 | uint8_t colorspace_; // 0 = YCbCr |
| 121 | uint8_t clamp_type_; |
| 122 | } VP8PictureHeader; |
| 123 | |
| 124 | // segment features |
| 125 | typedef struct { |
| 126 | int use_segment_; |
| 127 | int update_map_; // whether to update the segment map or not |
| 128 | int absolute_delta_; // absolute or delta values for quantizer and filter |
| 129 | int8_t quantizer_[NUM_MB_SEGMENTS]; // quantization changes |
| 130 | int8_t filter_strength_[NUM_MB_SEGMENTS]; // filter strength for segments |
| 131 | } VP8SegmentHeader; |
| 132 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 133 | |
| 134 | // probas associated to one of the contexts |
| 135 | typedef uint8_t VP8ProbaArray[NUM_PROBAS]; |
| 136 | |
| 137 | typedef struct { // all the probas associated to one band |
| 138 | VP8ProbaArray probas_[NUM_CTX]; |
| 139 | } VP8BandProbas; |
| 140 | |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 141 | // Struct collecting all frame-persistent probabilities. |
| 142 | typedef struct { |
| 143 | uint8_t segments_[MB_FEATURE_TREE_PROBS]; |
| 144 | // Type: 0:Intra16-AC 1:Intra16-DC 2:Chroma 3:Intra4 |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 145 | VP8BandProbas bands_[NUM_TYPES][NUM_BANDS]; |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 146 | } VP8Proba; |
| 147 | |
| 148 | // Filter parameters |
| 149 | typedef struct { |
| 150 | int simple_; // 0=complex, 1=simple |
| 151 | int level_; // [0..63] |
| 152 | int sharpness_; // [0..7] |
| 153 | int use_lf_delta_; |
| 154 | int ref_lf_delta_[NUM_REF_LF_DELTAS]; |
| 155 | int mode_lf_delta_[NUM_MODE_LF_DELTAS]; |
| 156 | } VP8FilterHeader; |
| 157 | |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 158 | //------------------------------------------------------------------------------ |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 159 | // Informations about the macroblocks. |
| 160 | |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 161 | typedef struct { // filter specs |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 162 | uint8_t f_limit_; // filter limit in [3..189], or 0 if no filtering |
| 163 | uint8_t f_ilevel_; // inner limit in [1..63] |
| 164 | uint8_t f_inner_; // do inner filtering? |
| 165 | uint8_t hev_thresh_; // high edge variance threshold in [0..2] |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 166 | } VP8FInfo; |
| 167 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 168 | typedef struct { // Top/Left Contexts used for syntax-parsing |
| 169 | uint8_t nz_; // non-zero AC/DC coeffs (4bit for luma + 4bit for chroma) |
| 170 | uint8_t nz_dc_; // non-zero DC coeff (1bit) |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 171 | } VP8MB; |
| 172 | |
| 173 | // Dequantization matrices |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 174 | typedef int quant_t[2]; // [DC / AC]. Can be 'uint16_t[2]' too (~slower). |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 175 | typedef struct { |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 176 | quant_t y1_mat_, y2_mat_, uv_mat_; |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 177 | |
| 178 | int uv_quant_; // U/V quantizer value |
| 179 | int dither_; // dithering amplitude (0 = off, max=255) |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 180 | } VP8QuantMatrix; |
| 181 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 182 | // Data needed to reconstruct a macroblock |
| 183 | typedef struct { |
| 184 | int16_t coeffs_[384]; // 384 coeffs = (16+4+4) * 4*4 |
| 185 | uint8_t is_i4x4_; // true if intra4x4 |
| 186 | uint8_t imodes_[16]; // one 16x16 mode (#0) or sixteen 4x4 modes |
| 187 | uint8_t uvmode_; // chroma prediction mode |
| 188 | // bit-wise info about the content of each sub-4x4 blocks (in decoding order). |
| 189 | // Each of the 4x4 blocks for y/u/v is associated with a 2b code according to: |
| 190 | // code=0 -> no coefficient |
| 191 | // code=1 -> only DC |
| 192 | // code=2 -> first three coefficients are non-zero |
| 193 | // code=3 -> more than three coefficients are non-zero |
| 194 | // This allows to call specialized transform functions. |
| 195 | uint32_t non_zero_y_; |
| 196 | uint32_t non_zero_uv_; |
| 197 | uint8_t dither_; // local dithering strength (deduced from non_zero_*) |
Vikas Arora | 33f74da | 2014-07-25 13:53:32 -0700 | [diff] [blame] | 198 | uint8_t skip_; |
| 199 | uint8_t segment_; |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 200 | } VP8MBData; |
| 201 | |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 202 | // Persistent information needed by the parallel processing |
| 203 | typedef struct { |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 204 | int id_; // cache row to process (in [0..2]) |
| 205 | int mb_y_; // macroblock position of the row |
| 206 | int filter_row_; // true if row-filtering is needed |
| 207 | VP8FInfo* f_info_; // filter strengths (swapped with dec->f_info_) |
| 208 | VP8MBData* mb_data_; // reconstruction data (swapped with dec->mb_data_) |
| 209 | VP8Io io_; // copy of the VP8Io to pass to put() |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 210 | } VP8ThreadContext; |
| 211 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 212 | // Saved top samples, per macroblock. Fits into a cache-line. |
| 213 | typedef struct { |
| 214 | uint8_t y[16], u[8], v[8]; |
| 215 | } VP8TopSamples; |
| 216 | |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 217 | //------------------------------------------------------------------------------ |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 218 | // VP8Decoder: the main opaque structure handed over to user |
| 219 | |
| 220 | struct VP8Decoder { |
Vikas Arora | 03d5e34 | 2011-06-02 23:59:44 +0530 | [diff] [blame] | 221 | VP8StatusCode status_; |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 222 | int ready_; // true if ready to decode a picture with VP8Decode() |
| 223 | const char* error_msg_; // set when status_ is not OK. |
| 224 | |
| 225 | // Main data source |
| 226 | VP8BitReader br_; |
| 227 | |
| 228 | // headers |
| 229 | VP8FrameHeader frm_hdr_; |
| 230 | VP8PictureHeader pic_hdr_; |
| 231 | VP8FilterHeader filter_hdr_; |
| 232 | VP8SegmentHeader segment_hdr_; |
| 233 | |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 234 | // Worker |
| 235 | WebPWorker worker_; |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 236 | int mt_method_; // multi-thread method: 0=off, 1=[parse+recon][filter] |
| 237 | // 2=[parse][recon+filter] |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 238 | int cache_id_; // current cache row |
| 239 | int num_caches_; // number of cached rows of 16 pixels (1, 2 or 3) |
| 240 | VP8ThreadContext thread_ctx_; // Thread context |
| 241 | |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 242 | // dimension, in macroblock units. |
| 243 | int mb_w_, mb_h_; |
| 244 | |
Vikas Arora | 4667279 | 2011-07-13 16:37:55 +0530 | [diff] [blame] | 245 | // Macroblock to process/filter, depending on cropping and filter_type. |
| 246 | int tl_mb_x_, tl_mb_y_; // top-left MB that must be in-loop filtered |
| 247 | int br_mb_x_, br_mb_y_; // last bottom-right MB that must be decoded |
| 248 | |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 249 | // number of partitions. |
| 250 | int num_parts_; |
| 251 | // per-partition boolean decoders. |
| 252 | VP8BitReader parts_[MAX_NUM_PARTITIONS]; |
| 253 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 254 | // Dithering strength, deduced from decoding options |
| 255 | int dither_; // whether to use dithering or not |
| 256 | VP8Random dithering_rg_; // random generator for dithering |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 257 | |
| 258 | // dequantization (one set of DC/AC dequant factor per segment) |
| 259 | VP8QuantMatrix dqm_[NUM_MB_SEGMENTS]; |
| 260 | |
| 261 | // probabilities |
| 262 | VP8Proba proba_; |
| 263 | int use_skip_proba_; |
| 264 | uint8_t skip_p_; |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 265 | |
| 266 | // Boundary data cache and persistent buffers. |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 267 | uint8_t* intra_t_; // top intra modes values: 4 * mb_w_ |
| 268 | uint8_t intra_l_[4]; // left intra modes values |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 269 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 270 | VP8TopSamples* yuv_t_; // top y/u/v samples |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 271 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 272 | VP8MB* mb_info_; // contextual macroblock info (mb_w_ + 1) |
| 273 | VP8FInfo* f_info_; // filter strength info |
| 274 | uint8_t* yuv_b_; // main block for Y/U/V (size = YUV_SIZE) |
| 275 | |
| 276 | uint8_t* cache_y_; // macroblock row for storing unfiltered samples |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 277 | uint8_t* cache_u_; |
| 278 | uint8_t* cache_v_; |
| 279 | int cache_y_stride_; |
| 280 | int cache_uv_stride_; |
| 281 | |
| 282 | // main memory chunk for the above data. Persistent. |
| 283 | void* mem_; |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 284 | size_t mem_size_; |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 285 | |
| 286 | // Per macroblock non-persistent infos. |
| 287 | int mb_x_, mb_y_; // current position, in macroblock units |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 288 | VP8MBData* mb_data_; // parsed reconstruction data |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 289 | |
| 290 | // Filtering side-info |
Vikas Arora | 1e7bf88 | 2013-03-13 16:43:18 -0700 | [diff] [blame] | 291 | int filter_type_; // 0=off, 1=simple, 2=complex |
Vikas Arora | 1e7bf88 | 2013-03-13 16:43:18 -0700 | [diff] [blame] | 292 | VP8FInfo fstrengths_[NUM_MB_SEGMENTS][2]; // precalculated per-segment/type |
Vikas Arora | 4667279 | 2011-07-13 16:37:55 +0530 | [diff] [blame] | 293 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 294 | // Alpha |
| 295 | struct ALPHDecoder* alph_dec_; // alpha-plane decoder object |
| 296 | const uint8_t* alpha_data_; // compressed alpha data (if present) |
Vikas Arora | 4667279 | 2011-07-13 16:37:55 +0530 | [diff] [blame] | 297 | size_t alpha_data_size_; |
Vikas Arora | 0406ce1 | 2013-08-09 15:57:12 -0700 | [diff] [blame] | 298 | int is_alpha_decoded_; // true if alpha_data_ is decoded in alpha_plane_ |
Vikas Arora | 33f74da | 2014-07-25 13:53:32 -0700 | [diff] [blame] | 299 | uint8_t* alpha_plane_; // output. Persistent, contains the whole data. |
| 300 | int alpha_dithering_; // derived from decoding options (0=off, 100=full). |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 301 | }; |
| 302 | |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 303 | //------------------------------------------------------------------------------ |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 304 | // internal functions. Not public. |
| 305 | |
| 306 | // in vp8.c |
Vikas Arora | 03d5e34 | 2011-06-02 23:59:44 +0530 | [diff] [blame] | 307 | int VP8SetError(VP8Decoder* const dec, |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 308 | VP8StatusCode error, const char* const msg); |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 309 | |
| 310 | // in tree.c |
| 311 | void VP8ResetProba(VP8Proba* const proba); |
| 312 | void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec); |
Vikas Arora | 33f74da | 2014-07-25 13:53:32 -0700 | [diff] [blame] | 313 | // parses one row of intra mode data in partition 0, returns !eof |
| 314 | int VP8ParseIntraModeRow(VP8BitReader* const br, VP8Decoder* const dec); |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 315 | |
| 316 | // in quant.c |
| 317 | void VP8ParseQuant(VP8Decoder* const dec); |
| 318 | |
| 319 | // in frame.c |
| 320 | int VP8InitFrame(VP8Decoder* const dec, VP8Io* io); |
Vikas Arora | 4667279 | 2011-07-13 16:37:55 +0530 | [diff] [blame] | 321 | // Call io->setup() and finish setting up scan parameters. |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 322 | // After this call returns, one must always call VP8ExitCritical() with the |
| 323 | // same parameters. Both functions should be used in pair. Returns VP8_STATUS_OK |
| 324 | // if ok, otherwise sets and returns the error status on *dec. |
| 325 | VP8StatusCode VP8EnterCritical(VP8Decoder* const dec, VP8Io* const io); |
| 326 | // Must always be called in pair with VP8EnterCritical(). |
| 327 | // Returns false in case of error. |
| 328 | int VP8ExitCritical(VP8Decoder* const dec, VP8Io* const io); |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 329 | // Return the multi-threading method to use (0=off), depending |
| 330 | // on options and bitstream size. Only for lossy decoding. |
| 331 | int VP8GetThreadMethod(const WebPDecoderOptions* const options, |
| 332 | const WebPHeaderStructure* const headers, |
| 333 | int width, int height); |
| 334 | // Initialize dithering post-process if needed. |
| 335 | void VP8InitDithering(const WebPDecoderOptions* const options, |
| 336 | VP8Decoder* const dec); |
| 337 | // Process the last decoded row (filtering + output). |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 338 | int VP8ProcessRow(VP8Decoder* const dec, VP8Io* const io); |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 339 | // To be called at the start of a new scanline, to initialize predictors. |
| 340 | void VP8InitScanline(VP8Decoder* const dec); |
Vikas Arora | 03d5e34 | 2011-06-02 23:59:44 +0530 | [diff] [blame] | 341 | // Decode one macroblock. Returns false if there is not enough data. |
| 342 | int VP8DecodeMB(VP8Decoder* const dec, VP8BitReader* const token_br); |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 343 | |
Vikas Arora | 4667279 | 2011-07-13 16:37:55 +0530 | [diff] [blame] | 344 | // in alpha.c |
| 345 | const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, |
| 346 | int row, int num_rows); |
| 347 | |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 348 | //------------------------------------------------------------------------------ |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 349 | |
Vikas Arora | 8b72022 | 2014-01-02 16:48:02 -0800 | [diff] [blame] | 350 | #ifdef __cplusplus |
Eric Hassold | 9aea642 | 2011-01-04 17:22:46 -0800 | [diff] [blame] | 351 | } // extern "C" |
| 352 | #endif |
| 353 | |
Vikas Arora | a241572 | 2012-08-09 16:18:58 -0700 | [diff] [blame] | 354 | #endif /* WEBP_DEC_VP8I_H_ */ |