| OLD | NEW |
| 1 // Copyright 2010 Google Inc. All Rights Reserved. | 1 // Copyright 2010 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Use of this source code is governed by a BSD-style license | 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 | 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 | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
| 8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 9 // | 9 // |
| 10 // VP8 decoder: internal header. | 10 // VP8 decoder: internal header. |
| 11 // | 11 // |
| 12 // Author: Skal (pascal.massimino@gmail.com) | 12 // Author: Skal (pascal.massimino@gmail.com) |
| 13 | 13 |
| 14 #ifndef WEBP_DEC_VP8I_H_ | 14 #ifndef WEBP_DEC_VP8I_H_ |
| 15 #define WEBP_DEC_VP8I_H_ | 15 #define WEBP_DEC_VP8I_H_ |
| 16 | 16 |
| 17 #include <string.h> // for memcpy() | 17 #include <string.h> // for memcpy() |
| 18 #include "./common.h" |
| 18 #include "./vp8li.h" | 19 #include "./vp8li.h" |
| 19 #include "../utils/bit_reader.h" | 20 #include "../utils/bit_reader.h" |
| 20 #include "../utils/random.h" | 21 #include "../utils/random.h" |
| 21 #include "../utils/thread.h" | 22 #include "../utils/thread.h" |
| 22 #include "../dsp/dsp.h" | 23 #include "../dsp/dsp.h" |
| 23 | 24 |
| 24 #ifdef __cplusplus | 25 #ifdef __cplusplus |
| 25 extern "C" { | 26 extern "C" { |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 //------------------------------------------------------------------------------ | 29 //------------------------------------------------------------------------------ |
| 29 // Various defines and enums | 30 // Various defines and enums |
| 30 | 31 |
| 31 // version numbers | 32 // version numbers |
| 32 #define DEC_MAJ_VERSION 0 | 33 #define DEC_MAJ_VERSION 0 |
| 33 #define DEC_MIN_VERSION 4 | 34 #define DEC_MIN_VERSION 5 |
| 34 #define DEC_REV_VERSION 4 | 35 #define DEC_REV_VERSION 0 |
| 35 | 36 |
| 36 // intra prediction modes | 37 // YUV-cache parameters. Cache is 32-bytes wide (= one cacheline). |
| 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, | |
| 57 B_DC_PRED_NOTOPLEFT = 6, | |
| 58 NUM_B_DC_MODES = 7 }; | |
| 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), | 38 // 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, | 39 // 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 | 40 // 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 | 41 // top-left samples (from previously decoded blocks), along with four |
| 77 // extra top-right samples for luma (intra4x4 prediction only). | 42 // extra top-right samples for luma (intra4x4 prediction only). |
| 78 // One possible layout is, using 32 * (17 + 9) bytes: | 43 // One possible layout is, using 32 * (17 + 9) bytes: |
| 79 // | 44 // |
| 80 // .+------ <- only 1 pixel high | 45 // .+------ <- only 1 pixel high |
| 81 // .|yyyyt. | 46 // .|yyyyt. |
| 82 // .|yyyyt. | 47 // .|yyyyt. |
| 83 // .|yyyyt. | 48 // .|yyyyt. |
| 84 // .|yyyy.. | 49 // .|yyyy.. |
| 85 // .+--.+-- <- only 1 pixel high | 50 // .+--.+-- <- only 1 pixel high |
| 86 // .|uu.|vv | 51 // .|uu.|vv |
| 87 // .|uu.|vv | 52 // .|uu.|vv |
| 88 // | 53 // |
| 89 // Every character is a 4x4 block, with legend: | 54 // Every character is a 4x4 block, with legend: |
| 90 // '.' = unused | 55 // '.' = unused |
| 91 // 'y' = y-samples 'u' = u-samples 'v' = u-samples | 56 // 'y' = y-samples 'u' = u-samples 'v' = u-samples |
| 92 // '|' = left sample, '-' = top sample, '+' = top-left sample | 57 // '|' = left sample, '-' = top sample, '+' = top-left sample |
| 93 // 't' = extra top-right sample for 4x4 modes | 58 // '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) | 59 #define YUV_SIZE (BPS * 17 + BPS * 9) |
| 97 #define Y_SIZE (BPS * 17) | 60 #define Y_SIZE (BPS * 17) |
| 98 #define Y_OFF (BPS * 1 + 8) | 61 #define Y_OFF (BPS * 1 + 8) |
| 99 #define U_OFF (Y_OFF + BPS * 16 + BPS) | 62 #define U_OFF (Y_OFF + BPS * 16 + BPS) |
| 100 #define V_OFF (U_OFF + 16) | 63 #define V_OFF (U_OFF + 16) |
| 101 | 64 |
| 102 // minimal width under which lossy multi-threading is always disabled | 65 // minimal width under which lossy multi-threading is always disabled |
| 103 #define MIN_WIDTH_FOR_THREADS 512 | 66 #define MIN_WIDTH_FOR_THREADS 512 |
| 104 | 67 |
| 105 //------------------------------------------------------------------------------ | 68 //------------------------------------------------------------------------------ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 123 | 86 |
| 124 // segment features | 87 // segment features |
| 125 typedef struct { | 88 typedef struct { |
| 126 int use_segment_; | 89 int use_segment_; |
| 127 int update_map_; // whether to update the segment map or not | 90 int update_map_; // whether to update the segment map or not |
| 128 int absolute_delta_; // absolute or delta values for quantizer and filter | 91 int absolute_delta_; // absolute or delta values for quantizer and filter |
| 129 int8_t quantizer_[NUM_MB_SEGMENTS]; // quantization changes | 92 int8_t quantizer_[NUM_MB_SEGMENTS]; // quantization changes |
| 130 int8_t filter_strength_[NUM_MB_SEGMENTS]; // filter strength for segments | 93 int8_t filter_strength_[NUM_MB_SEGMENTS]; // filter strength for segments |
| 131 } VP8SegmentHeader; | 94 } VP8SegmentHeader; |
| 132 | 95 |
| 133 | |
| 134 // probas associated to one of the contexts | 96 // probas associated to one of the contexts |
| 135 typedef uint8_t VP8ProbaArray[NUM_PROBAS]; | 97 typedef uint8_t VP8ProbaArray[NUM_PROBAS]; |
| 136 | 98 |
| 137 typedef struct { // all the probas associated to one band | 99 typedef struct { // all the probas associated to one band |
| 138 VP8ProbaArray probas_[NUM_CTX]; | 100 VP8ProbaArray probas_[NUM_CTX]; |
| 139 } VP8BandProbas; | 101 } VP8BandProbas; |
| 140 | 102 |
| 141 // Struct collecting all frame-persistent probabilities. | 103 // Struct collecting all frame-persistent probabilities. |
| 142 typedef struct { | 104 typedef struct { |
| 143 uint8_t segments_[MB_FEATURE_TREE_PROBS]; | 105 uint8_t segments_[MB_FEATURE_TREE_PROBS]; |
| 144 // Type: 0:Intra16-AC 1:Intra16-DC 2:Chroma 3:Intra4 | 106 // Type: 0:Intra16-AC 1:Intra16-DC 2:Chroma 3:Intra4 |
| 145 VP8BandProbas bands_[NUM_TYPES][NUM_BANDS]; | 107 VP8BandProbas bands_[NUM_TYPES][NUM_BANDS]; |
| 108 const VP8BandProbas* bands_ptr_[NUM_TYPES][16 + 1]; |
| 146 } VP8Proba; | 109 } VP8Proba; |
| 147 | 110 |
| 148 // Filter parameters | 111 // Filter parameters |
| 149 typedef struct { | 112 typedef struct { |
| 150 int simple_; // 0=complex, 1=simple | 113 int simple_; // 0=complex, 1=simple |
| 151 int level_; // [0..63] | 114 int level_; // [0..63] |
| 152 int sharpness_; // [0..7] | 115 int sharpness_; // [0..7] |
| 153 int use_lf_delta_; | 116 int use_lf_delta_; |
| 154 int ref_lf_delta_[NUM_REF_LF_DELTAS]; | 117 int ref_lf_delta_[NUM_REF_LF_DELTAS]; |
| 155 int mode_lf_delta_[NUM_MODE_LF_DELTAS]; | 118 int mode_lf_delta_[NUM_MODE_LF_DELTAS]; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 // in tree.c | 273 // in tree.c |
| 311 void VP8ResetProba(VP8Proba* const proba); | 274 void VP8ResetProba(VP8Proba* const proba); |
| 312 void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec); | 275 void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec); |
| 313 // parses one row of intra mode data in partition 0, returns !eof | 276 // parses one row of intra mode data in partition 0, returns !eof |
| 314 int VP8ParseIntraModeRow(VP8BitReader* const br, VP8Decoder* const dec); | 277 int VP8ParseIntraModeRow(VP8BitReader* const br, VP8Decoder* const dec); |
| 315 | 278 |
| 316 // in quant.c | 279 // in quant.c |
| 317 void VP8ParseQuant(VP8Decoder* const dec); | 280 void VP8ParseQuant(VP8Decoder* const dec); |
| 318 | 281 |
| 319 // in frame.c | 282 // in frame.c |
| 320 int VP8InitFrame(VP8Decoder* const dec, VP8Io* io); | 283 int VP8InitFrame(VP8Decoder* const dec, VP8Io* const io); |
| 321 // Call io->setup() and finish setting up scan parameters. | 284 // Call io->setup() and finish setting up scan parameters. |
| 322 // After this call returns, one must always call VP8ExitCritical() with the | 285 // 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 | 286 // 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. | 287 // if ok, otherwise sets and returns the error status on *dec. |
| 325 VP8StatusCode VP8EnterCritical(VP8Decoder* const dec, VP8Io* const io); | 288 VP8StatusCode VP8EnterCritical(VP8Decoder* const dec, VP8Io* const io); |
| 326 // Must always be called in pair with VP8EnterCritical(). | 289 // Must always be called in pair with VP8EnterCritical(). |
| 327 // Returns false in case of error. | 290 // Returns false in case of error. |
| 328 int VP8ExitCritical(VP8Decoder* const dec, VP8Io* const io); | 291 int VP8ExitCritical(VP8Decoder* const dec, VP8Io* const io); |
| 329 // Return the multi-threading method to use (0=off), depending | 292 // Return the multi-threading method to use (0=off), depending |
| 330 // on options and bitstream size. Only for lossy decoding. | 293 // on options and bitstream size. Only for lossy decoding. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 345 const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, | 308 const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, |
| 346 int row, int num_rows); | 309 int row, int num_rows); |
| 347 | 310 |
| 348 //------------------------------------------------------------------------------ | 311 //------------------------------------------------------------------------------ |
| 349 | 312 |
| 350 #ifdef __cplusplus | 313 #ifdef __cplusplus |
| 351 } // extern "C" | 314 } // extern "C" |
| 352 #endif | 315 #endif |
| 353 | 316 |
| 354 #endif /* WEBP_DEC_VP8I_H_ */ | 317 #endif /* WEBP_DEC_VP8I_H_ */ |
| OLD | NEW |