| 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_dec.h" |
| 19 #include "../dsp/dsp.h" | 19 #include "../dsp/dsp.h" |
| 20 #include "../utils/bit_writer.h" | 20 #include "../utils/bit_writer_utils.h" |
| 21 #include "../utils/thread.h" | 21 #include "../utils/thread_utils.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 __cplusplus | 25 #ifdef __cplusplus |
| 26 extern "C" { | 26 extern "C" { |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 //------------------------------------------------------------------------------ | 29 //------------------------------------------------------------------------------ |
| 30 // Various defines and enums | 30 // Various defines and enums |
| 31 | 31 |
| 32 // version numbers | 32 // version numbers |
| 33 #define ENC_MAJ_VERSION 0 | 33 #define ENC_MAJ_VERSION 0 |
| 34 #define ENC_MIN_VERSION 5 | 34 #define ENC_MIN_VERSION 6 |
| 35 #define ENC_REV_VERSION 2 | 35 #define ENC_REV_VERSION 0 |
| 36 | 36 |
| 37 enum { MAX_LF_LEVELS = 64, // Maximum loop filter level | 37 enum { MAX_LF_LEVELS = 64, // Maximum loop filter level |
| 38 MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost | 38 MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost |
| 39 MAX_LEVEL = 2047 // max level (note: max codable is 2047 + 67) | 39 MAX_LEVEL = 2047 // max level (note: max codable is 2047 + 67) |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 typedef enum { // Rate-distortion optimization levels | 42 typedef enum { // Rate-distortion optimization levels |
| 43 RD_OPT_NONE = 0, // no rd-opt | 43 RD_OPT_NONE = 0, // no rd-opt |
| 44 RD_OPT_BASIC = 1, // basic scoring (no trellis) | 44 RD_OPT_BASIC = 1, // basic scoring (no trellis) |
| 45 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 int mode_i16; // mode number for intra16 prediction | 212 int mode_i16; // mode number for intra16 prediction |
| 213 uint8_t modes_i4[16]; // mode numbers for intra4 predictions | 213 uint8_t modes_i4[16]; // mode numbers for intra4 predictions |
| 214 int mode_uv; // mode number of chroma prediction | 214 int mode_uv; // mode number of chroma prediction |
| 215 uint32_t nz; // non-zero blocks | 215 uint32_t nz; // non-zero blocks |
| 216 } VP8ModeScore; | 216 } VP8ModeScore; |
| 217 | 217 |
| 218 // Iterator structure to iterate through macroblocks, pointing to the | 218 // Iterator structure to iterate through macroblocks, pointing to the |
| 219 // right neighbouring data (samples, predictions, contexts, ...) | 219 // right neighbouring data (samples, predictions, contexts, ...) |
| 220 typedef struct { | 220 typedef struct { |
| 221 int x_, y_; // current macroblock | 221 int x_, y_; // current macroblock |
| 222 int y_stride_, uv_stride_; // respective strides | |
| 223 uint8_t* yuv_in_; // input samples | 222 uint8_t* yuv_in_; // input samples |
| 224 uint8_t* yuv_out_; // output samples | 223 uint8_t* yuv_out_; // output samples |
| 225 uint8_t* yuv_out2_; // secondary buffer swapped with yuv_out_. | 224 uint8_t* yuv_out2_; // secondary buffer swapped with yuv_out_. |
| 226 uint8_t* yuv_p_; // scratch buffer for prediction | 225 uint8_t* yuv_p_; // scratch buffer for prediction |
| 227 VP8Encoder* enc_; // back-pointer | 226 VP8Encoder* enc_; // back-pointer |
| 228 VP8MBInfo* mb_; // current macroblock | 227 VP8MBInfo* mb_; // current macroblock |
| 229 VP8BitWriter* bw_; // current bit-writer | 228 VP8BitWriter* bw_; // current bit-writer |
| 230 uint8_t* preds_; // intra mode predictors (4x4 blocks) | 229 uint8_t* preds_; // intra mode predictors (4x4 blocks) |
| 231 uint32_t* nz_; // non-zero pattern | 230 uint32_t* nz_; // non-zero pattern |
| 232 uint8_t i4_boundary_[37]; // 32+5 boundary samples needed by intra4x4 | 231 uint8_t i4_boundary_[37]; // 32+5 boundary samples needed by intra4x4 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 // Pick best modes and fills the levels. Returns true if skipped. | 466 // Pick best modes and fills the levels. Returns true if skipped. |
| 468 int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, | 467 int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, |
| 469 VP8RDLevel rd_opt); | 468 VP8RDLevel rd_opt); |
| 470 | 469 |
| 471 // in alpha.c | 470 // in alpha.c |
| 472 void VP8EncInitAlpha(VP8Encoder* const enc); // initialize alpha compression | 471 void VP8EncInitAlpha(VP8Encoder* const enc); // initialize alpha compression |
| 473 int VP8EncStartAlpha(VP8Encoder* const enc); // start alpha coding process | 472 int VP8EncStartAlpha(VP8Encoder* const enc); // start alpha coding process |
| 474 int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data | 473 int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data |
| 475 int VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data | 474 int VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data |
| 476 | 475 |
| 477 // in filter.c | |
| 478 void VP8SSIMAddStats(const VP8DistoStats* const src, VP8DistoStats* const dst); | |
| 479 void VP8SSIMAccumulatePlane(const uint8_t* src1, int stride1, | |
| 480 const uint8_t* src2, int stride2, | |
| 481 int W, int H, VP8DistoStats* const stats); | |
| 482 double VP8SSIMGet(const VP8DistoStats* const stats); | |
| 483 double VP8SSIMGetSquaredError(const VP8DistoStats* const stats); | |
| 484 | |
| 485 // autofilter | 476 // autofilter |
| 486 void VP8InitFilter(VP8EncIterator* const it); | 477 void VP8InitFilter(VP8EncIterator* const it); |
| 487 void VP8StoreFilterStats(VP8EncIterator* const it); | 478 void VP8StoreFilterStats(VP8EncIterator* const it); |
| 488 void VP8AdjustFilterStrength(VP8EncIterator* const it); | 479 void VP8AdjustFilterStrength(VP8EncIterator* const it); |
| 489 | 480 |
| 490 // returns the approximate filtering strength needed to smooth a edge | 481 // returns the approximate filtering strength needed to smooth a edge |
| 491 // step of 'delta', given a sharpness parameter 'sharpness'. | 482 // step of 'delta', given a sharpness parameter 'sharpness'. |
| 492 int VP8FilterStrengthFromDelta(int sharpness, int delta); | 483 int VP8FilterStrengthFromDelta(int sharpness, int delta); |
| 493 | 484 |
| 494 // misc utils for picture_*.c: | 485 // misc utils for picture_*.c: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 520 uint32_t* argb, uint32_t* argb_scratch, | 511 uint32_t* argb, uint32_t* argb_scratch, |
| 521 const uint32_t* const transform_data, | 512 const uint32_t* const transform_data, |
| 522 int quality, int subtract_green); | 513 int quality, int subtract_green); |
| 523 //------------------------------------------------------------------------------ | 514 //------------------------------------------------------------------------------ |
| 524 | 515 |
| 525 #ifdef __cplusplus | 516 #ifdef __cplusplus |
| 526 } // extern "C" | 517 } // extern "C" |
| 527 #endif | 518 #endif |
| 528 | 519 |
| 529 #endif /* WEBP_ENC_VP8ENCI_H_ */ | 520 #endif /* WEBP_ENC_VP8ENCI_H_ */ |
| OLD | NEW |