OLD | NEW |
1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 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 // WebP encoder: internal header. | 10 // WebP encoder: internal header. |
11 // | 11 // |
12 // Author: Skal (pascal.massimino@gmail.com) | 12 // Author: Skal (pascal.massimino@gmail.com) |
13 | 13 |
14 #ifndef WEBP_ENC_VP8ENCI_H_ | 14 #ifndef WEBP_ENC_VP8ENCI_H_ |
15 #define WEBP_ENC_VP8ENCI_H_ | 15 #define WEBP_ENC_VP8ENCI_H_ |
16 | 16 |
17 #include <string.h> // for memcpy() | 17 #include <string.h> // for memcpy() |
18 #include "../dec/common.h" | 18 #include "../dec/common.h" |
19 #include "../dsp/dsp.h" | 19 #include "../dsp/dsp.h" |
20 #include "../utils/bit_writer.h" | 20 #include "../utils/bit_writer.h" |
21 #include "../utils/thread.h" | 21 #include "../utils/thread.h" |
22 #include "../utils/utils.h" | 22 #include "../utils/utils.h" |
23 #include "../webp/encode.h" | 23 #include "../webp/encode.h" |
24 | 24 |
25 #ifdef WEBP_EXPERIMENTAL_FEATURES | |
26 #include "./vp8li.h" | |
27 #endif // WEBP_EXPERIMENTAL_FEATURES | |
28 | |
29 #ifdef __cplusplus | 25 #ifdef __cplusplus |
30 extern "C" { | 26 extern "C" { |
31 #endif | 27 #endif |
32 | 28 |
33 //------------------------------------------------------------------------------ | 29 //------------------------------------------------------------------------------ |
34 // Various defines and enums | 30 // Various defines and enums |
35 | 31 |
36 // version numbers | 32 // version numbers |
37 #define ENC_MAJ_VERSION 0 | 33 #define ENC_MAJ_VERSION 0 |
38 #define ENC_MIN_VERSION 5 | 34 #define ENC_MIN_VERSION 5 |
39 #define ENC_REV_VERSION 0 | 35 #define ENC_REV_VERSION 1 |
40 | 36 |
41 enum { MAX_LF_LEVELS = 64, // Maximum loop filter level | 37 enum { MAX_LF_LEVELS = 64, // Maximum loop filter level |
42 MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost | 38 MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost |
43 MAX_LEVEL = 2047 // max level (note: max codable is 2047 + 67) | 39 MAX_LEVEL = 2047 // max level (note: max codable is 2047 + 67) |
44 }; | 40 }; |
45 | 41 |
46 typedef enum { // Rate-distortion optimization levels | 42 typedef enum { // Rate-distortion optimization levels |
47 RD_OPT_NONE = 0, // no rd-opt | 43 RD_OPT_NONE = 0, // no rd-opt |
48 RD_OPT_BASIC = 1, // basic scoring (no trellis) | 44 RD_OPT_BASIC = 1, // basic scoring (no trellis) |
49 RD_OPT_TRELLIS = 2, // perform trellis-quant on the final decision only | 45 RD_OPT_TRELLIS = 2, // perform trellis-quant on the final decision only |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // Lower values indicate a lower risk of blurriness. | 189 // Lower values indicate a lower risk of blurriness. |
194 int beta_; // filter-susceptibility, range [0,255]. | 190 int beta_; // filter-susceptibility, range [0,255]. |
195 int quant_; // final segment quantizer. | 191 int quant_; // final segment quantizer. |
196 int fstrength_; // final in-loop filtering strength | 192 int fstrength_; // final in-loop filtering strength |
197 int max_edge_; // max edge delta (for filtering strength) | 193 int max_edge_; // max edge delta (for filtering strength) |
198 int min_disto_; // minimum distortion required to trigger filtering record | 194 int min_disto_; // minimum distortion required to trigger filtering record |
199 // reactivities | 195 // reactivities |
200 int lambda_i16_, lambda_i4_, lambda_uv_; | 196 int lambda_i16_, lambda_i4_, lambda_uv_; |
201 int lambda_mode_, lambda_trellis_, tlambda_; | 197 int lambda_mode_, lambda_trellis_, tlambda_; |
202 int lambda_trellis_i16_, lambda_trellis_i4_, lambda_trellis_uv_; | 198 int lambda_trellis_i16_, lambda_trellis_i4_, lambda_trellis_uv_; |
| 199 |
| 200 // lambda values for distortion-based evaluation |
| 201 score_t i4_penalty_; // penalty for using Intra4 |
203 } VP8SegmentInfo; | 202 } VP8SegmentInfo; |
204 | 203 |
205 // Handy transient struct to accumulate score and info during RD-optimization | 204 // Handy transient struct to accumulate score and info during RD-optimization |
206 // and mode evaluation. | 205 // and mode evaluation. |
207 typedef struct { | 206 typedef struct { |
208 score_t D, SD; // Distortion, spectral distortion | 207 score_t D, SD; // Distortion, spectral distortion |
209 score_t H, R, score; // header bits, rate, score. | 208 score_t H, R, score; // header bits, rate, score. |
210 int16_t y_dc_levels[16]; // Quantized levels for luma-DC, luma-AC, chroma. | 209 int16_t y_dc_levels[16]; // Quantized levels for luma-DC, luma-AC, chroma. |
211 int16_t y_ac_levels[16][16]; | 210 int16_t y_ac_levels[16][16]; |
212 int16_t uv_levels[4 + 4][16]; | 211 int16_t uv_levels[4 + 4][16]; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 uint64_t sse_[4]; // sum of Y/U/V/A squared errors for all macroblocks | 387 uint64_t sse_[4]; // sum of Y/U/V/A squared errors for all macroblocks |
389 uint64_t sse_count_; // pixel count for the sse_[] stats | 388 uint64_t sse_count_; // pixel count for the sse_[] stats |
390 int coded_size_; | 389 int coded_size_; |
391 int residual_bytes_[3][4]; | 390 int residual_bytes_[3][4]; |
392 int block_count_[3]; | 391 int block_count_[3]; |
393 | 392 |
394 // quality/speed settings | 393 // quality/speed settings |
395 int method_; // 0=fastest, 6=best/slowest. | 394 int method_; // 0=fastest, 6=best/slowest. |
396 VP8RDLevel rd_opt_level_; // Deduced from method_. | 395 VP8RDLevel rd_opt_level_; // Deduced from method_. |
397 int max_i4_header_bits_; // partition #0 safeness factor | 396 int max_i4_header_bits_; // partition #0 safeness factor |
| 397 int mb_header_limit_; // rough limit for header bits per MB |
398 int thread_level_; // derived from config->thread_level | 398 int thread_level_; // derived from config->thread_level |
399 int do_search_; // derived from config->target_XXX | 399 int do_search_; // derived from config->target_XXX |
400 int use_tokens_; // if true, use token buffer | 400 int use_tokens_; // if true, use token buffer |
401 | 401 |
402 // Memory | 402 // Memory |
403 VP8MBInfo* mb_info_; // contextual macroblock infos (mb_w_ + 1) | 403 VP8MBInfo* mb_info_; // contextual macroblock infos (mb_w_ + 1) |
404 uint8_t* preds_; // predictions modes: (4*mb_w+1) * (4*mb_h+1) | 404 uint8_t* preds_; // predictions modes: (4*mb_w+1) * (4*mb_h+1) |
405 uint32_t* nz_; // non-zero bit context: mb_w+1 | 405 uint32_t* nz_; // non-zero bit context: mb_w+1 |
406 uint8_t* y_top_; // top luma samples. | 406 uint8_t* y_top_; // top luma samples. |
407 uint8_t* uv_top_; // top u/v samples. | 407 uint8_t* uv_top_; // top u/v samples. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, | 470 int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, |
471 VP8RDLevel rd_opt); | 471 VP8RDLevel rd_opt); |
472 | 472 |
473 // in alpha.c | 473 // in alpha.c |
474 void VP8EncInitAlpha(VP8Encoder* const enc); // initialize alpha compression | 474 void VP8EncInitAlpha(VP8Encoder* const enc); // initialize alpha compression |
475 int VP8EncStartAlpha(VP8Encoder* const enc); // start alpha coding process | 475 int VP8EncStartAlpha(VP8Encoder* const enc); // start alpha coding process |
476 int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data | 476 int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data |
477 int VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data | 477 int VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data |
478 | 478 |
479 // in filter.c | 479 // in filter.c |
480 | 480 void VP8SSIMAddStats(const VP8DistoStats* const src, VP8DistoStats* const dst); |
481 // SSIM utils | |
482 typedef struct { | |
483 double w, xm, ym, xxm, xym, yym; | |
484 } DistoStats; | |
485 void VP8SSIMAddStats(const DistoStats* const src, DistoStats* const dst); | |
486 void VP8SSIMAccumulatePlane(const uint8_t* src1, int stride1, | 481 void VP8SSIMAccumulatePlane(const uint8_t* src1, int stride1, |
487 const uint8_t* src2, int stride2, | 482 const uint8_t* src2, int stride2, |
488 int W, int H, DistoStats* const stats); | 483 int W, int H, VP8DistoStats* const stats); |
489 double VP8SSIMGet(const DistoStats* const stats); | 484 double VP8SSIMGet(const VP8DistoStats* const stats); |
490 double VP8SSIMGetSquaredError(const DistoStats* const stats); | 485 double VP8SSIMGetSquaredError(const VP8DistoStats* const stats); |
491 | 486 |
492 // autofilter | 487 // autofilter |
493 void VP8InitFilter(VP8EncIterator* const it); | 488 void VP8InitFilter(VP8EncIterator* const it); |
494 void VP8StoreFilterStats(VP8EncIterator* const it); | 489 void VP8StoreFilterStats(VP8EncIterator* const it); |
495 void VP8AdjustFilterStrength(VP8EncIterator* const it); | 490 void VP8AdjustFilterStrength(VP8EncIterator* const it); |
496 | 491 |
497 // returns the approximate filtering strength needed to smooth a edge | 492 // returns the approximate filtering strength needed to smooth a edge |
498 // step of 'delta', given a sharpness parameter 'sharpness'. | 493 // step of 'delta', given a sharpness parameter 'sharpness'. |
499 int VP8FilterStrengthFromDelta(int sharpness, int delta); | 494 int VP8FilterStrengthFromDelta(int sharpness, int delta); |
500 | 495 |
(...skipping 26 matching lines...) Expand all Loading... |
527 uint32_t* argb, uint32_t* argb_scratch, | 522 uint32_t* argb, uint32_t* argb_scratch, |
528 const uint32_t* const transform_data, | 523 const uint32_t* const transform_data, |
529 int quality, int subtract_green); | 524 int quality, int subtract_green); |
530 //------------------------------------------------------------------------------ | 525 //------------------------------------------------------------------------------ |
531 | 526 |
532 #ifdef __cplusplus | 527 #ifdef __cplusplus |
533 } // extern "C" | 528 } // extern "C" |
534 #endif | 529 #endif |
535 | 530 |
536 #endif /* WEBP_ENC_VP8ENCI_H_ */ | 531 #endif /* WEBP_ENC_VP8ENCI_H_ */ |
OLD | NEW |