1 // Copyright 2011 Google Inc. All Rights Reserved.
2 //
3 // This code is licensed under the same terms as WebM:
4 // Software License Agreement: http://www.webmproject.org/license/software/
5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/
6 // -----------------------------------------------------------------------------
7 //
8 // WebP encoder: internal header.
9 //
10 // Author: Skal (pascal.massimino@gmail.com)
11
12 #ifndef WEBP_ENC_VP8ENCI_H_
13 #define WEBP_ENC_VP8ENCI_H_
14
15 #include <string.h> // for memcpy()
16 #include "webp/encode.h"
17 #include "../dsp/dsp.h"
18 #include "../utils/bit_writer.h"
19 #include "../utils/thread.h"
20
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24
25 //------------------------------------------------------------------------------
26 // Various defines and enums
27
28 // version numbers
29 #define ENC_MAJ_VERSION 0
30 #define ENC_MIN_VERSION 2
31 #define ENC_REV_VERSION 1
32
33 // intra prediction modes
34 enum { B_DC_PRED = 0, // 4x4 modes
35 B_TM_PRED = 1,
36 B_VE_PRED = 2,
37 B_HE_PRED = 3,
38 B_RD_PRED = 4,
39 B_VR_PRED = 5,
40 B_LD_PRED = 6,
41 B_VL_PRED = 7,
42 B_HD_PRED = 8,
43 B_HU_PRED = 9,
44 NUM_BMODES = B_HU_PRED + 1 - B_DC_PRED, // = 10
45
46 // Luma16 or UV modes
47 DC_PRED = B_DC_PRED, V_PRED = B_VE_PRED,
48 H_PRED = B_HE_PRED, TM_PRED = B_TM_PRED,
49 NUM_PRED_MODES = 4
50 };
51
52 enum { NUM_MB_SEGMENTS = 4,
53 MAX_NUM_PARTITIONS = 8,
54 NUM_TYPES = 4, // 0: i16-AC, 1: i16-DC, 2:chroma-AC, 3:i4-AC
55 NUM_BANDS = 8,
56 NUM_CTX = 3,
57 NUM_PROBAS = 11,
58 MAX_LF_LEVELS = 64, // Maximum loop filter level
59 MAX_VARIABLE_LEVEL = 67 // last (inclusive) level with variable cost
60 };
61
62 typedef enum { // Rate-distortion optimization levels
63 RD_OPT_NONE = 0, // no rd-opt
64 RD_OPT_BASIC = 1, // basic scoring (no trellis)
65 RD_OPT_TRELLIS = 2, // perform trellis-quant on the final decision only
66 RD_OPT_TRELLIS_ALL = 3 // trellis-quant for every scoring (much slower)
67 } VP8RDLevel;
68
69 // YUV-cache parameters. Cache is 16-pixels wide.
70 // The original or reconstructed samples can be accessed using VP8Scan[]
71 // The predicted blocks can be accessed using offsets to yuv_p_ and
72 // the arrays VP8*ModeOffsets[];
73 // +----+ YUV Samples area. See VP8Scan[] for accessing the blocks.
74 // Y_OFF |YYYY| <- original samples (enc->yuv_in_)
75 // |YYYY|
76 // |YYYY|
77 // |YYYY|
78 // U_OFF |UUVV| V_OFF (=U_OFF + 8)
79 // |UUVV|
80 // +----+
81 // Y_OFF |YYYY| <- compressed/decoded samples ('yuv_out_')
82 // |YYYY| There are two buffers like this ('yuv_out_'/'yuv_out2_')
83 // |YYYY|
84 // |YYYY|
85 // U_OFF |UUVV| V_OFF
86 // |UUVV|
87 // x2 (for yuv_out2_)
88 // +----+ Prediction area ('yuv_p_', size = PRED_SIZE)
89 // I16DC16 |YYYY| Intra16 predictions (16x16 block each)
90 // |YYYY|
91 // |YYYY|
92 // |YYYY|
93 // I16TM16 |YYYY|
94 // |YYYY|
95 // |YYYY|
96 // |YYYY|
97 // I16VE16 |YYYY|
98 // |YYYY|
99 // |YYYY|
100 // |YYYY|
101 // I16HE16 |YYYY|
102 // |YYYY|
103 // |YYYY|
104 // |YYYY|
105 // +----+ Chroma U/V predictions (16x8 block each)
106 // C8DC8 |UUVV|
107 // |UUVV|
108 // C8TM8 |UUVV|
109 // |UUVV|
110 // C8VE8 |UUVV|
111 // |UUVV|
112 // C8HE8 |UUVV|
113 // |UUVV|
114 // +----+ Intra 4x4 predictions (4x4 block each)
115 // |YYYY| I4DC4 I4TM4 I4VE4 I4HE4
116 // |YYYY| I4RD4 I4VR4 I4LD4 I4VL4
117 // |YY..| I4HD4 I4HU4 I4TMP
118 // +----+
119 #define BPS 16 // this is the common stride
120 #define Y_SIZE (BPS * 16)
121 #define UV_SIZE (BPS * 8)
122 #define YUV_SIZE (Y_SIZE + UV_SIZE)
123 #define PRED_SIZE (6 * 16 * BPS + 12 * BPS)
124 #define Y_OFF (0)
125 #define U_OFF (Y_SIZE)
126 #define V_OFF (U_OFF + 8)
127 #define ALIGN_CST 15
128 #define DO_ALIGN(PTR) ((uintptr_t)((PTR) + ALIGN_CST) & ~ALIGN_CST)
129
130 extern const int VP8Scan[16 + 4 + 4]; // in quant.c
131 extern const int VP8UVModeOffsets[4]; // in analyze.c
132 extern const int VP8I16ModeOffsets[4];
133 extern const int VP8I4ModeOffsets[NUM_BMODES];
134
135 // Layout of prediction blocks
136 // intra 16x16
137 #define I16DC16 (0 * 16 * BPS)
138 #define I16TM16 (1 * 16 * BPS)
139 #define I16VE16 (2 * 16 * BPS)
140 #define I16HE16 (3 * 16 * BPS)
141 // chroma 8x8, two U/V blocks side by side (hence: 16x8 each)
142 #define C8DC8 (4 * 16 * BPS)
143 #define C8TM8 (4 * 16 * BPS + 8 * BPS)
144 #define C8VE8 (5 * 16 * BPS)
145 #define C8HE8 (5 * 16 * BPS + 8 * BPS)
146 // intra 4x4
147 #define I4DC4 (6 * 16 * BPS + 0)
148 #define I4TM4 (6 * 16 * BPS + 4)
149 #define I4VE4 (6 * 16 * BPS + 8)
150 #define I4HE4 (6 * 16 * BPS + 12)
151 #define I4RD4 (6 * 16 * BPS + 4 * BPS + 0)
152 #define I4VR4 (6 * 16 * BPS + 4 * BPS + 4)
153 #define I4LD4 (6 * 16 * BPS + 4 * BPS + 8)
154 #define I4VL4 (6 * 16 * BPS + 4 * BPS + 12)
155 #define I4HD4 (6 * 16 * BPS + 8 * BPS + 0)
156 #define I4HU4 (6 * 16 * BPS + 8 * BPS + 4)
157 #define I4TMP (6 * 16 * BPS + 8 * BPS + 8)
158
159 typedef int64_t score_t; // type used for scores, rate, distortion
160 #define MAX_COST ((score_t)0x7fffffffffffffLL)
161
162 #define QFIX 17
163 #define BIAS(b) ((b) << (QFIX - 8))
164 // Fun fact: this is the _only_ line where we're actually being lossy and
165 // discarding bits.
QUANTDIV(int n,int iQ,int B)166 static WEBP_INLINE int QUANTDIV(int n, int iQ, int B) {
167 return (n * iQ + B) >> QFIX;
168 }
169
170 // size of histogram used by CollectHistogram.
171 #define MAX_COEFF_THRESH 31
172 typedef struct VP8Histogram VP8Histogram;
173 struct VP8Histogram {
174 // TODO(skal): we only need to store the max_value and last_non_zero actually.
175 int distribution[MAX_COEFF_THRESH + 1];
176 };
177
178 // Uncomment the following to remove token-buffer code:
179 // #define DISABLE_TOKEN_BUFFER
180
181 //------------------------------------------------------------------------------
182 // Headers
183
184 typedef uint32_t proba_t; // 16b + 16b
185 typedef uint8_t ProbaArray[NUM_CTX][NUM_PROBAS];
186 typedef proba_t StatsArray[NUM_CTX][NUM_PROBAS];
187 typedef uint16_t CostArray[NUM_CTX][MAX_VARIABLE_LEVEL + 1];
188 typedef double LFStats[NUM_MB_SEGMENTS][MAX_LF_LEVELS]; // filter stats
189
190 typedef struct VP8Encoder VP8Encoder;
191
192 // segment features
193 typedef struct {
194 int num_segments_; // Actual number of segments. 1 segment only = unused.
195 int update_map_; // whether to update the segment map or not.
196 // must be 0 if there's only 1 segment.
197 int size_; // bit-cost for transmitting the segment map
198 } VP8SegmentHeader;
199
200 // Struct collecting all frame-persistent probabilities.
201 typedef struct {
202 uint8_t segments_[3]; // probabilities for segment tree
203 uint8_t skip_proba_; // final probability of being skipped.
204 ProbaArray coeffs_[NUM_TYPES][NUM_BANDS]; // 924 bytes
205 StatsArray stats_[NUM_TYPES][NUM_BANDS]; // 4224 bytes
206 CostArray level_cost_[NUM_TYPES][NUM_BANDS]; // 11.4k
207 int dirty_; // if true, need to call VP8CalculateLevelCosts()
208 int use_skip_proba_; // Note: we always use skip_proba for now.
209 int nb_skip_; // number of skipped blocks
210 } VP8Proba;
211
212 // Filter parameters. Not actually used in the code (we don't perform
213 // the in-loop filtering), but filled from user's config
214 typedef struct {
215 int simple_; // filtering type: 0=complex, 1=simple
216 int level_; // base filter level [0..63]
217 int sharpness_; // [0..7]
218 int i4x4_lf_delta_; // delta filter level for i4x4 relative to i16x16
219 } VP8FilterHeader;
220
221 //------------------------------------------------------------------------------
222 // Informations about the macroblocks.
223
224 typedef struct {
225 // block type
226 unsigned int type_:2; // 0=i4x4, 1=i16x16
227 unsigned int uv_mode_:2;
228 unsigned int skip_:1;
229 unsigned int segment_:2;
230 uint8_t alpha_; // quantization-susceptibility
231 } VP8MBInfo;
232
233 typedef struct VP8Matrix {
234 uint16_t q_[16]; // quantizer steps
235 uint16_t iq_[16]; // reciprocals, fixed point.
236 uint16_t bias_[16]; // rounding bias
237 uint16_t zthresh_[16]; // value under which a coefficient is zeroed
238 uint16_t sharpen_[16]; // frequency boosters for slight sharpening
239 } VP8Matrix;
240
241 typedef struct {
242 VP8Matrix y1_, y2_, uv_; // quantization matrices
243 int alpha_; // quant-susceptibility, range [-127,127]. Zero is neutral.
244 // Lower values indicate a lower risk of blurriness.
245 int beta_; // filter-susceptibility, range [0,255].
246 int quant_; // final segment quantizer.
247 int fstrength_; // final in-loop filtering strength
248 // reactivities
249 int lambda_i16_, lambda_i4_, lambda_uv_;
250 int lambda_mode_, lambda_trellis_, tlambda_;
251 int lambda_trellis_i16_, lambda_trellis_i4_, lambda_trellis_uv_;
252 } VP8SegmentInfo;
253
254 // Handy transcient struct to accumulate score and info during RD-optimization
255 // and mode evaluation.
256 typedef struct {
257 score_t D, SD, R, score; // Distortion, spectral distortion, rate, score.
258 int16_t y_dc_levels[16]; // Quantized levels for luma-DC, luma-AC, chroma.
259 int16_t y_ac_levels[16][16];
260 int16_t uv_levels[4 + 4][16];
261 int mode_i16; // mode number for intra16 prediction
262 uint8_t modes_i4[16]; // mode numbers for intra4 predictions
263 int mode_uv; // mode number of chroma prediction
264 uint32_t nz; // non-zero blocks
265 } VP8ModeScore;
266
267 // Iterator structure to iterate through macroblocks, pointing to the
268 // right neighbouring data (samples, predictions, contexts, ...)
269 typedef struct {
270 int x_, y_; // current macroblock
271 int y_offset_, uv_offset_; // offset to the luma / chroma planes
272 int y_stride_, uv_stride_; // respective strides
273 uint8_t* yuv_in_; // borrowed from enc_ (for now)
274 uint8_t* yuv_out_; // ''
275 uint8_t* yuv_out2_; // ''
276 uint8_t* yuv_p_; // ''
277 VP8Encoder* enc_; // back-pointer
278 VP8MBInfo* mb_; // current macroblock
279 VP8BitWriter* bw_; // current bit-writer
280 uint8_t* preds_; // intra mode predictors (4x4 blocks)
281 uint32_t* nz_; // non-zero pattern
282 uint8_t i4_boundary_[37]; // 32+5 boundary samples needed by intra4x4
283 uint8_t* i4_top_; // pointer to the current top boundary sample
284 int i4_; // current intra4x4 mode being tested
285 int top_nz_[9]; // top-non-zero context.
286 int left_nz_[9]; // left-non-zero. left_nz[8] is independent.
287 uint64_t bit_count_[4][3]; // bit counters for coded levels.
288 uint64_t luma_bits_; // macroblock bit-cost for luma
289 uint64_t uv_bits_; // macroblock bit-cost for chroma
290 LFStats* lf_stats_; // filter stats (borrowed from enc_)
291 int do_trellis_; // if true, perform extra level optimisation
292 int done_; // true when scan is finished
293 int percent0_; // saved initial progress percent
294 } VP8EncIterator;
295
296 // in iterator.c
297 // must be called first.
298 void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it);
299 // restart a scan.
300 void VP8IteratorReset(VP8EncIterator* const it);
301 // import samples from source
302 void VP8IteratorImport(const VP8EncIterator* const it);
303 // export decimated samples
304 void VP8IteratorExport(const VP8EncIterator* const it);
305 // go to next macroblock. Returns !done_. If *block_to_save is non-null, will
306 // save the boundary values to top_/left_ arrays. block_to_save can be
307 // it->yuv_out_ or it->yuv_in_.
308 int VP8IteratorNext(VP8EncIterator* const it,
309 const uint8_t* const block_to_save);
310 // Report progression based on macroblock rows. Return 0 for user-abort request.
311 int VP8IteratorProgress(const VP8EncIterator* const it,
312 int final_delta_percent);
313 // Intra4x4 iterations
314 void VP8IteratorStartI4(VP8EncIterator* const it);
315 // returns true if not done.
316 int VP8IteratorRotateI4(VP8EncIterator* const it,
317 const uint8_t* const yuv_out);
318
319 // Non-zero context setup/teardown
320 void VP8IteratorNzToBytes(VP8EncIterator* const it);
321 void VP8IteratorBytesToNz(VP8EncIterator* const it);
322
323 // Helper functions to set mode properties
324 void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode);
325 void VP8SetIntra4Mode(const VP8EncIterator* const it, const uint8_t* modes);
326 void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode);
327 void VP8SetSkip(const VP8EncIterator* const it, int skip);
328 void VP8SetSegment(const VP8EncIterator* const it, int segment);
329
330 //------------------------------------------------------------------------------
331 // Paginated token buffer
332
333 typedef struct VP8Tokens VP8Tokens; // struct details in token.c
334
335 typedef struct {
336 #if !defined(DISABLE_TOKEN_BUFFER)
337 VP8Tokens* pages_; // first page
338 VP8Tokens** last_page_; // last page
339 uint16_t* tokens_; // set to (*last_page_)->tokens_
340 int left_; // how many free tokens left before the page is full.
341 #endif
342 int error_; // true in case of malloc error
343 } VP8TBuffer;
344
345 void VP8TBufferInit(VP8TBuffer* const b); // initialize an empty buffer
346 void VP8TBufferClear(VP8TBuffer* const b); // de-allocate pages memory
347
348 #if !defined(DISABLE_TOKEN_BUFFER)
349
350 // Finalizes bitstream when probabilities are known.
351 // Deletes the allocated token memory if final_pass is true.
352 int VP8EmitTokens(VP8TBuffer* const b, VP8BitWriter* const bw,
353 const uint8_t* const probas, int final_pass);
354
355 // record the coding of coefficients without knowing the probabilities yet
356 int VP8RecordCoeffTokens(int ctx, int coeff_type, int first, int last,
357 const int16_t* const coeffs,
358 VP8TBuffer* const tokens);
359
360 // unused for now
361 void VP8TokenToStats(const VP8TBuffer* const b, proba_t* const stats);
362
363 #endif // !DISABLE_TOKEN_BUFFER
364
365 //------------------------------------------------------------------------------
366 // VP8Encoder
367
368 struct VP8Encoder {
369 const WebPConfig* config_; // user configuration and parameters
370 WebPPicture* pic_; // input / output picture
371
372 // headers
373 VP8FilterHeader filter_hdr_; // filtering information
374 VP8SegmentHeader segment_hdr_; // segment information
375
376 int profile_; // VP8's profile, deduced from Config.
377
378 // dimension, in macroblock units.
379 int mb_w_, mb_h_;
380 int preds_w_; // stride of the *preds_ prediction plane (=4*mb_w + 1)
381
382 // number of partitions (1, 2, 4 or 8 = MAX_NUM_PARTITIONS)
383 int num_parts_;
384
385 // per-partition boolean decoders.
386 VP8BitWriter bw_; // part0
387 VP8BitWriter parts_[MAX_NUM_PARTITIONS]; // token partitions
388 VP8TBuffer tokens_; // token buffer
389
390 int percent_; // for progress
391
392 // transparency blob
393 int has_alpha_;
394 uint8_t* alpha_data_; // non-NULL if transparency is present
395 uint32_t alpha_data_size_;
396 WebPWorker alpha_worker_;
397
398 // enhancement layer
399 int use_layer_;
400 VP8BitWriter layer_bw_;
401 uint8_t* layer_data_;
402 size_t layer_data_size_;
403
404 // quantization info (one set of DC/AC dequant factor per segment)
405 VP8SegmentInfo dqm_[NUM_MB_SEGMENTS];
406 int base_quant_; // nominal quantizer value. Only used
407 // for relative coding of segments' quant.
408 int alpha_; // global susceptibility (<=> complexity)
409 int uv_alpha_; // U/V quantization susceptibility
410 // global offset of quantizers, shared by all segments
411 int dq_y1_dc_;
412 int dq_y2_dc_, dq_y2_ac_;
413 int dq_uv_dc_, dq_uv_ac_;
414
415 // probabilities and statistics
416 VP8Proba proba_;
417 uint64_t sse_[4]; // sum of Y/U/V/A squared errors for all macroblocks
418 uint64_t sse_count_; // pixel count for the sse_[] stats
419 int coded_size_;
420 int residual_bytes_[3][4];
421 int block_count_[3];
422
423 // quality/speed settings
424 int method_; // 0=fastest, 6=best/slowest.
425 VP8RDLevel rd_opt_level_; // Deduced from method_.
426 int max_i4_header_bits_; // partition #0 safeness factor
427 int thread_level_; // derived from config->thread_level
428 int do_search_; // derived from config->target_XXX
429 int use_tokens_; // if true, use token buffer
430
431 // Memory
432 VP8MBInfo* mb_info_; // contextual macroblock infos (mb_w_ + 1)
433 uint8_t* preds_; // predictions modes: (4*mb_w+1) * (4*mb_h+1)
434 uint32_t* nz_; // non-zero bit context: mb_w+1
435 uint8_t* yuv_in_; // input samples
436 uint8_t* yuv_out_; // output samples
437 uint8_t* yuv_out2_; // secondary scratch out-buffer. swapped with yuv_out_.
438 uint8_t* yuv_p_; // scratch buffer for prediction
439 uint8_t *y_top_; // top luma samples.
440 uint8_t *uv_top_; // top u/v samples.
441 // U and V are packed into 16 pixels (8 U + 8 V)
442 uint8_t *y_left_; // left luma samples (adressable from index -1 to 15).
443 uint8_t *u_left_; // left u samples (adressable from index -1 to 7)
444 uint8_t *v_left_; // left v samples (adressable from index -1 to 7)
445
446 LFStats *lf_stats_; // autofilter stats (if NULL, autofilter is off)
447 };
448
449 //------------------------------------------------------------------------------
450 // internal functions. Not public.
451
452 // in tree.c
453 extern const uint8_t VP8CoeffsProba0[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS];
454 extern const uint8_t
455 VP8CoeffsUpdateProba[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS];
456 // Reset the token probabilities to their initial (default) values
457 void VP8DefaultProbas(VP8Encoder* const enc);
458 // Write the token probabilities
459 void VP8WriteProbas(VP8BitWriter* const bw, const VP8Proba* const probas);
460 // Writes the partition #0 modes (that is: all intra modes)
461 void VP8CodeIntraModes(VP8Encoder* const enc);
462
463 // in syntax.c
464 // Generates the final bitstream by coding the partition0 and headers,
465 // and appending an assembly of all the pre-coded token partitions.
466 // Return true if everything is ok.
467 int VP8EncWrite(VP8Encoder* const enc);
468 // Release memory allocated for bit-writing in VP8EncLoop & seq.
469 void VP8EncFreeBitWriters(VP8Encoder* const enc);
470
471 // in frame.c
472 extern const uint8_t VP8EncBands[16 + 1];
473 extern const uint8_t VP8Cat3[];
474 extern const uint8_t VP8Cat4[];
475 extern const uint8_t VP8Cat5[];
476 extern const uint8_t VP8Cat6[];
477
478 // Form all the four Intra16x16 predictions in the yuv_p_ cache
479 void VP8MakeLuma16Preds(const VP8EncIterator* const it);
480 // Form all the four Chroma8x8 predictions in the yuv_p_ cache
481 void VP8MakeChroma8Preds(const VP8EncIterator* const it);
482 // Form all the ten Intra4x4 predictions in the yuv_p_ cache
483 // for the 4x4 block it->i4_
484 void VP8MakeIntra4Preds(const VP8EncIterator* const it);
485 // Rate calculation
486 int VP8GetCostLuma16(VP8EncIterator* const it, const VP8ModeScore* const rd);
487 int VP8GetCostLuma4(VP8EncIterator* const it, const int16_t levels[16]);
488 int VP8GetCostUV(VP8EncIterator* const it, const VP8ModeScore* const rd);
489 // Main coding calls
490 int VP8EncLoop(VP8Encoder* const enc);
491 int VP8EncTokenLoop(VP8Encoder* const enc);
492
493 // in webpenc.c
494 // Assign an error code to a picture. Return false for convenience.
495 int WebPEncodingSetError(const WebPPicture* const pic, WebPEncodingError error);
496 int WebPReportProgress(const WebPPicture* const pic,
497 int percent, int* const percent_store);
498
499 // in analysis.c
500 // Main analysis loop. Decides the segmentations and complexity.
501 // Assigns a first guess for Intra16 and uvmode_ prediction modes.
502 int VP8EncAnalyze(VP8Encoder* const enc);
503
504 // in quant.c
505 // Sets up segment's quantization values, base_quant_ and filter strengths.
506 void VP8SetSegmentParams(VP8Encoder* const enc, float quality);
507 // Pick best modes and fills the levels. Returns true if skipped.
508 int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd,
509 VP8RDLevel rd_opt);
510
511 // in alpha.c
512 void VP8EncInitAlpha(VP8Encoder* const enc); // initialize alpha compression
513 int VP8EncStartAlpha(VP8Encoder* const enc); // start alpha coding process
514 int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data
515 int VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data
516
517 // in layer.c
518 void VP8EncInitLayer(VP8Encoder* const enc); // init everything
519 void VP8EncCodeLayerBlock(VP8EncIterator* it); // code one more macroblock
520 int VP8EncFinishLayer(VP8Encoder* const enc); // finalize coding
521 void VP8EncDeleteLayer(VP8Encoder* enc); // reclaim memory
522
523 // in filter.c
524
525 // SSIM utils
526 typedef struct {
527 double w, xm, ym, xxm, xym, yym;
528 } DistoStats;
529 void VP8SSIMAddStats(const DistoStats* const src, DistoStats* const dst);
530 void VP8SSIMAccumulatePlane(const uint8_t* src1, int stride1,
531 const uint8_t* src2, int stride2,
532 int W, int H, DistoStats* const stats);
533 double VP8SSIMGet(const DistoStats* const stats);
534 double VP8SSIMGetSquaredError(const DistoStats* const stats);
535
536 // autofilter
537 void VP8InitFilter(VP8EncIterator* const it);
538 void VP8StoreFilterStats(VP8EncIterator* const it);
539 void VP8AdjustFilterStrength(VP8EncIterator* const it);
540
541 //------------------------------------------------------------------------------
542
543 #if defined(__cplusplus) || defined(c_plusplus)
544 } // extern "C"
545 #endif
546
547 #endif /* WEBP_ENC_VP8ENCI_H_ */
548