| OLD | NEW |
| 1 // Copyright 2011 Google Inc. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // This code is licensed under the same terms as WebM: | 3 // This code is licensed under the same terms as WebM: |
| 4 // Software License Agreement: http://www.webmproject.org/license/software/ | 4 // Software License Agreement: http://www.webmproject.org/license/software/ |
| 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ | 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ |
| 6 // ----------------------------------------------------------------------------- | 6 // ----------------------------------------------------------------------------- |
| 7 // | 7 // |
| 8 // WebP encoder: internal header. | 8 // WebP encoder: internal header. |
| 9 // | 9 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) | 10 // Author: Skal (pascal.massimino@gmail.com) |
| 11 | 11 |
| 12 #ifndef WEBP_ENC_VP8ENCI_H_ | 12 #ifndef WEBP_ENC_VP8ENCI_H_ |
| 13 #define WEBP_ENC_VP8ENCI_H_ | 13 #define WEBP_ENC_VP8ENCI_H_ |
| 14 | 14 |
| 15 #include "string.h" // for memcpy() | 15 #include <string.h> // for memcpy() |
| 16 #include "../webp/encode.h" | 16 #include "../webp/encode.h" |
| 17 #include "../dsp/dsp.h" | 17 #include "../dsp/dsp.h" |
| 18 #include "../utils/bit_writer.h" | 18 #include "../utils/bit_writer.h" |
| 19 | 19 |
| 20 #if defined(__cplusplus) || defined(c_plusplus) | 20 #if defined(__cplusplus) || defined(c_plusplus) |
| 21 extern "C" { | 21 extern "C" { |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 //------------------------------------------------------------------------------ | 24 //------------------------------------------------------------------------------ |
| 25 // Various defines and enums | 25 // Various defines and enums |
| 26 | 26 |
| 27 // version numbers | 27 // version numbers |
| 28 #define ENC_MAJ_VERSION 0 | 28 #define ENC_MAJ_VERSION 0 |
| 29 #define ENC_MIN_VERSION 1 | 29 #define ENC_MIN_VERSION 2 |
| 30 #define ENC_REV_VERSION 3 | 30 #define ENC_REV_VERSION 0 |
| 31 | 31 |
| 32 // size of histogram used by CollectHistogram. | 32 // size of histogram used by CollectHistogram. |
| 33 #define MAX_COEFF_THRESH 64 | 33 #define MAX_COEFF_THRESH 64 |
| 34 | 34 |
| 35 // intra prediction modes | 35 // intra prediction modes |
| 36 enum { B_DC_PRED = 0, // 4x4 modes | 36 enum { B_DC_PRED = 0, // 4x4 modes |
| 37 B_TM_PRED = 1, | 37 B_TM_PRED = 1, |
| 38 B_VE_PRED = 2, | 38 B_VE_PRED = 2, |
| 39 B_HE_PRED = 3, | 39 B_HE_PRED = 3, |
| 40 B_RD_PRED = 4, | 40 B_RD_PRED = 4, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 #define I4HU4 (6 * 16 * BPS + 8 * BPS + 4) | 150 #define I4HU4 (6 * 16 * BPS + 8 * BPS + 4) |
| 151 #define I4TMP (6 * 16 * BPS + 8 * BPS + 8) | 151 #define I4TMP (6 * 16 * BPS + 8 * BPS + 8) |
| 152 | 152 |
| 153 typedef int64_t score_t; // type used for scores, rate, distortion | 153 typedef int64_t score_t; // type used for scores, rate, distortion |
| 154 #define MAX_COST ((score_t)0x7fffffffffffffLL) | 154 #define MAX_COST ((score_t)0x7fffffffffffffLL) |
| 155 | 155 |
| 156 #define QFIX 17 | 156 #define QFIX 17 |
| 157 #define BIAS(b) ((b) << (QFIX - 8)) | 157 #define BIAS(b) ((b) << (QFIX - 8)) |
| 158 // Fun fact: this is the _only_ line where we're actually being lossy and | 158 // Fun fact: this is the _only_ line where we're actually being lossy and |
| 159 // discarding bits. | 159 // discarding bits. |
| 160 static inline int QUANTDIV(int n, int iQ, int B) { | 160 static WEBP_INLINE int QUANTDIV(int n, int iQ, int B) { |
| 161 return (n * iQ + B) >> QFIX; | 161 return (n * iQ + B) >> QFIX; |
| 162 } | 162 } |
| 163 extern const uint8_t VP8Zigzag[16]; | 163 extern const uint8_t VP8Zigzag[16]; |
| 164 | 164 |
| 165 //------------------------------------------------------------------------------ | 165 //------------------------------------------------------------------------------ |
| 166 // Headers | 166 // Headers |
| 167 | 167 |
| 168 typedef uint8_t ProbaArray[NUM_CTX][NUM_PROBAS]; | 168 typedef uint8_t ProbaArray[NUM_CTX][NUM_PROBAS]; |
| 169 typedef uint64_t StatsArray[NUM_CTX][NUM_PROBAS][2]; | 169 typedef uint64_t StatsArray[NUM_CTX][NUM_PROBAS][2]; |
| 170 typedef uint16_t CostArray[NUM_CTX][MAX_VARIABLE_LEVEL + 1]; | 170 typedef uint16_t CostArray[NUM_CTX][MAX_VARIABLE_LEVEL + 1]; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } VP8SegmentInfo; | 234 } VP8SegmentInfo; |
| 235 | 235 |
| 236 // Handy transcient struct to accumulate score and info during RD-optimization | 236 // Handy transcient struct to accumulate score and info during RD-optimization |
| 237 // and mode evaluation. | 237 // and mode evaluation. |
| 238 typedef struct { | 238 typedef struct { |
| 239 score_t D, SD, R, score; // Distortion, spectral distortion, rate, score. | 239 score_t D, SD, R, score; // Distortion, spectral distortion, rate, score. |
| 240 int16_t y_dc_levels[16]; // Quantized levels for luma-DC, luma-AC, chroma. | 240 int16_t y_dc_levels[16]; // Quantized levels for luma-DC, luma-AC, chroma. |
| 241 int16_t y_ac_levels[16][16]; | 241 int16_t y_ac_levels[16][16]; |
| 242 int16_t uv_levels[4 + 4][16]; | 242 int16_t uv_levels[4 + 4][16]; |
| 243 int mode_i16; // mode number for intra16 prediction | 243 int mode_i16; // mode number for intra16 prediction |
| 244 int modes_i4[16]; // mode numbers for intra4 predictions | 244 uint8_t modes_i4[16]; // mode numbers for intra4 predictions |
| 245 int mode_uv; // mode number of chroma prediction | 245 int mode_uv; // mode number of chroma prediction |
| 246 uint32_t nz; // non-zero blocks | 246 uint32_t nz; // non-zero blocks |
| 247 } VP8ModeScore; | 247 } VP8ModeScore; |
| 248 | 248 |
| 249 // Iterator structure to iterate through macroblocks, pointing to the | 249 // Iterator structure to iterate through macroblocks, pointing to the |
| 250 // right neighbouring data (samples, predictions, contexts, ...) | 250 // right neighbouring data (samples, predictions, contexts, ...) |
| 251 typedef struct { | 251 typedef struct { |
| 252 int x_, y_; // current macroblock | 252 int x_, y_; // current macroblock |
| 253 int y_offset_, uv_offset_; // offset to the luma / chroma planes | 253 int y_offset_, uv_offset_; // offset to the luma / chroma planes |
| 254 int y_stride_, uv_stride_; // respective strides | 254 int y_stride_, uv_stride_; // respective strides |
| (...skipping 10 matching lines...) Expand all Loading... |
| 265 uint8_t* i4_top_; // pointer to the current top boundary sample | 265 uint8_t* i4_top_; // pointer to the current top boundary sample |
| 266 int i4_; // current intra4x4 mode being tested | 266 int i4_; // current intra4x4 mode being tested |
| 267 int top_nz_[9]; // top-non-zero context. | 267 int top_nz_[9]; // top-non-zero context. |
| 268 int left_nz_[9]; // left-non-zero. left_nz[8] is independent. | 268 int left_nz_[9]; // left-non-zero. left_nz[8] is independent. |
| 269 uint64_t bit_count_[4][3]; // bit counters for coded levels. | 269 uint64_t bit_count_[4][3]; // bit counters for coded levels. |
| 270 uint64_t luma_bits_; // macroblock bit-cost for luma | 270 uint64_t luma_bits_; // macroblock bit-cost for luma |
| 271 uint64_t uv_bits_; // macroblock bit-cost for chroma | 271 uint64_t uv_bits_; // macroblock bit-cost for chroma |
| 272 LFStats* lf_stats_; // filter stats (borrowed from enc_) | 272 LFStats* lf_stats_; // filter stats (borrowed from enc_) |
| 273 int do_trellis_; // if true, perform extra level optimisation | 273 int do_trellis_; // if true, perform extra level optimisation |
| 274 int done_; // true when scan is finished | 274 int done_; // true when scan is finished |
| 275 int percent0_; // saved initial progress percent |
| 275 } VP8EncIterator; | 276 } VP8EncIterator; |
| 276 | 277 |
| 277 // in iterator.c | 278 // in iterator.c |
| 278 // must be called first. | 279 // must be called first. |
| 279 void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it); | 280 void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it); |
| 280 // restart a scan. | 281 // restart a scan. |
| 281 void VP8IteratorReset(VP8EncIterator* const it); | 282 void VP8IteratorReset(VP8EncIterator* const it); |
| 282 // import samples from source | 283 // import samples from source |
| 283 void VP8IteratorImport(const VP8EncIterator* const it); | 284 void VP8IteratorImport(const VP8EncIterator* const it); |
| 284 // export decimated samples | 285 // export decimated samples |
| 285 void VP8IteratorExport(const VP8EncIterator* const it); | 286 void VP8IteratorExport(const VP8EncIterator* const it); |
| 286 // go to next macroblock. Returns !done_. If *block_to_save is non-null, will | 287 // go to next macroblock. Returns !done_. If *block_to_save is non-null, will |
| 287 // save the boundary values to top_/left_ arrays. block_to_save can be | 288 // save the boundary values to top_/left_ arrays. block_to_save can be |
| 288 // it->yuv_out_ or it->yuv_in_. | 289 // it->yuv_out_ or it->yuv_in_. |
| 289 int VP8IteratorNext(VP8EncIterator* const it, | 290 int VP8IteratorNext(VP8EncIterator* const it, |
| 290 const uint8_t* const block_to_save); | 291 const uint8_t* const block_to_save); |
| 292 // Report progression based on macroblock rows. Return 0 for user-abort request. |
| 293 int VP8IteratorProgress(const VP8EncIterator* const it, |
| 294 int final_delta_percent); |
| 291 // Intra4x4 iterations | 295 // Intra4x4 iterations |
| 292 void VP8IteratorStartI4(VP8EncIterator* const it); | 296 void VP8IteratorStartI4(VP8EncIterator* const it); |
| 293 // returns true if not done. | 297 // returns true if not done. |
| 294 int VP8IteratorRotateI4(VP8EncIterator* const it, | 298 int VP8IteratorRotateI4(VP8EncIterator* const it, |
| 295 const uint8_t* const yuv_out); | 299 const uint8_t* const yuv_out); |
| 296 | 300 |
| 297 // Non-zero context setup/teardown | 301 // Non-zero context setup/teardown |
| 298 void VP8IteratorNzToBytes(VP8EncIterator* const it); | 302 void VP8IteratorNzToBytes(VP8EncIterator* const it); |
| 299 void VP8IteratorBytesToNz(VP8EncIterator* const it); | 303 void VP8IteratorBytesToNz(VP8EncIterator* const it); |
| 300 | 304 |
| 301 // Helper functions to set mode properties | 305 // Helper functions to set mode properties |
| 302 void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode); | 306 void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode); |
| 303 void VP8SetIntra4Mode(const VP8EncIterator* const it, int modes[16]); | 307 void VP8SetIntra4Mode(const VP8EncIterator* const it, const uint8_t* modes); |
| 304 void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode); | 308 void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode); |
| 305 void VP8SetSkip(const VP8EncIterator* const it, int skip); | 309 void VP8SetSkip(const VP8EncIterator* const it, int skip); |
| 306 void VP8SetSegment(const VP8EncIterator* const it, int segment); | 310 void VP8SetSegment(const VP8EncIterator* const it, int segment); |
| 307 void VP8IteratorResetCosts(VP8EncIterator* const it); | 311 |
| 312 //------------------------------------------------------------------------------ |
| 313 // Paginated token buffer |
| 314 |
| 315 // WIP: #define USE_TOKEN_BUFFER |
| 316 |
| 317 #ifdef USE_TOKEN_BUFFER |
| 318 |
| 319 #define MAX_NUM_TOKEN 2048 |
| 320 |
| 321 typedef struct VP8Tokens VP8Tokens; |
| 322 struct VP8Tokens { |
| 323 uint16_t tokens_[MAX_NUM_TOKEN]; // bit#15: bit, bits 0..14: slot |
| 324 int left_; |
| 325 VP8Tokens* next_; |
| 326 }; |
| 327 |
| 328 typedef struct { |
| 329 VP8Tokens* rows_; |
| 330 uint16_t* tokens_; // set to (*last_)->tokens_ |
| 331 VP8Tokens** last_; |
| 332 int left_; |
| 333 int error_; // true in case of malloc error |
| 334 } VP8TBuffer; |
| 335 |
| 336 void VP8TBufferInit(VP8TBuffer* const b); // initialize an empty buffer |
| 337 int VP8TBufferNewPage(VP8TBuffer* const b); // allocate a new page |
| 338 void VP8TBufferClear(VP8TBuffer* const b); // de-allocate memory |
| 339 |
| 340 int VP8EmitTokens(const VP8TBuffer* const b, VP8BitWriter* const bw, |
| 341 const uint8_t* const probas); |
| 342 |
| 343 static WEBP_INLINE int VP8AddToken(VP8TBuffer* const b, |
| 344 int bit, int proba_idx) { |
| 345 if (b->left_ > 0 || VP8TBufferNewPage(b)) { |
| 346 const int slot = --b->left_; |
| 347 b->tokens_[slot] = (bit << 15) | proba_idx; |
| 348 } |
| 349 return bit; |
| 350 } |
| 351 |
| 352 #endif // USE_TOKEN_BUFFER |
| 308 | 353 |
| 309 //------------------------------------------------------------------------------ | 354 //------------------------------------------------------------------------------ |
| 310 // VP8Encoder | 355 // VP8Encoder |
| 311 | 356 |
| 312 struct VP8Encoder { | 357 struct VP8Encoder { |
| 313 const WebPConfig* config_; // user configuration and parameters | 358 const WebPConfig* config_; // user configuration and parameters |
| 314 WebPPicture* pic_; // input / output picture | 359 WebPPicture* pic_; // input / output picture |
| 315 | 360 |
| 316 // headers | 361 // headers |
| 317 VP8FilterHeader filter_hdr_; // filtering information | 362 VP8FilterHeader filter_hdr_; // filtering information |
| 318 VP8SegmentHeader segment_hdr_; // segment information | 363 VP8SegmentHeader segment_hdr_; // segment information |
| 319 | 364 |
| 320 int profile_; // VP8's profile, deduced from Config. | 365 int profile_; // VP8's profile, deduced from Config. |
| 321 | 366 |
| 322 // dimension, in macroblock units. | 367 // dimension, in macroblock units. |
| 323 int mb_w_, mb_h_; | 368 int mb_w_, mb_h_; |
| 324 int preds_w_; // stride of the *preds_ prediction plane (=4*mb_w + 1) | 369 int preds_w_; // stride of the *preds_ prediction plane (=4*mb_w + 1) |
| 325 | 370 |
| 326 // number of partitions (1, 2, 4 or 8 = MAX_NUM_PARTITIONS) | 371 // number of partitions (1, 2, 4 or 8 = MAX_NUM_PARTITIONS) |
| 327 int num_parts_; | 372 int num_parts_; |
| 328 | 373 |
| 329 // per-partition boolean decoders. | 374 // per-partition boolean decoders. |
| 330 VP8BitWriter bw_; // part0 | 375 VP8BitWriter bw_; // part0 |
| 331 VP8BitWriter parts_[MAX_NUM_PARTITIONS]; // token partitions | 376 VP8BitWriter parts_[MAX_NUM_PARTITIONS]; // token partitions |
| 332 | 377 |
| 378 int percent_; // for progress |
| 379 |
| 333 // transparency blob | 380 // transparency blob |
| 334 int has_alpha_; | 381 int has_alpha_; |
| 335 uint8_t* alpha_data_; // non-NULL if transparency is present | 382 uint8_t* alpha_data_; // non-NULL if transparency is present |
| 336 size_t alpha_data_size_; | 383 uint32_t alpha_data_size_; |
| 337 | 384 |
| 338 // enhancement layer | 385 // enhancement layer |
| 339 int use_layer_; | 386 int use_layer_; |
| 340 VP8BitWriter layer_bw_; | 387 VP8BitWriter layer_bw_; |
| 341 uint8_t* layer_data_; | 388 uint8_t* layer_data_; |
| 342 size_t layer_data_size_; | 389 size_t layer_data_size_; |
| 343 | 390 |
| 344 // quantization info (one set of DC/AC dequant factor per segment) | 391 // quantization info (one set of DC/AC dequant factor per segment) |
| 345 VP8SegmentInfo dqm_[NUM_MB_SEGMENTS]; | 392 VP8SegmentInfo dqm_[NUM_MB_SEGMENTS]; |
| 346 int base_quant_; // nominal quantizer value. Only used | 393 int base_quant_; // nominal quantizer value. Only used |
| 347 // for relative coding of segments' quant. | 394 // for relative coding of segments' quant. |
| 348 int uv_alpha_; // U/V quantization susceptibility | 395 int uv_alpha_; // U/V quantization susceptibility |
| 349 // global offset of quantizers, shared by all segments | 396 // global offset of quantizers, shared by all segments |
| 350 int dq_y1_dc_; | 397 int dq_y1_dc_; |
| 351 int dq_y2_dc_, dq_y2_ac_; | 398 int dq_y2_dc_, dq_y2_ac_; |
| 352 int dq_uv_dc_, dq_uv_ac_; | 399 int dq_uv_dc_, dq_uv_ac_; |
| 353 | 400 |
| 354 // probabilities and statistics | 401 // probabilities and statistics |
| 355 VP8Proba proba_; | 402 VP8Proba proba_; |
| 356 uint64_t sse_[3]; // sum of Y/U/V squared errors for all macroblocks | 403 uint64_t sse_[4]; // sum of Y/U/V/A squared errors for all macroblocks |
| 357 uint64_t sse_count_; // pixel count for the sse_[] stats | 404 uint64_t sse_count_; // pixel count for the sse_[] stats |
| 358 int coded_size_; | 405 int coded_size_; |
| 359 int residual_bytes_[3][4]; | 406 int residual_bytes_[3][4]; |
| 360 int block_count_[3]; | 407 int block_count_[3]; |
| 361 | 408 |
| 362 // quality/speed settings | 409 // quality/speed settings |
| 363 int method_; // 0=fastest, 6=best/slowest. | 410 int method_; // 0=fastest, 6=best/slowest. |
| 364 int rd_opt_level_; // Deduced from method_. | 411 int rd_opt_level_; // Deduced from method_. |
| 365 int max_i4_header_bits_; // partition #0 safeness factor | 412 int max_i4_header_bits_; // partition #0 safeness factor |
| 366 | 413 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 394 // Write the token probabilities | 441 // Write the token probabilities |
| 395 void VP8WriteProbas(VP8BitWriter* const bw, const VP8Proba* const probas); | 442 void VP8WriteProbas(VP8BitWriter* const bw, const VP8Proba* const probas); |
| 396 // Writes the partition #0 modes (that is: all intra modes) | 443 // Writes the partition #0 modes (that is: all intra modes) |
| 397 void VP8CodeIntraModes(VP8Encoder* const enc); | 444 void VP8CodeIntraModes(VP8Encoder* const enc); |
| 398 | 445 |
| 399 // in syntax.c | 446 // in syntax.c |
| 400 // Generates the final bitstream by coding the partition0 and headers, | 447 // Generates the final bitstream by coding the partition0 and headers, |
| 401 // and appending an assembly of all the pre-coded token partitions. | 448 // and appending an assembly of all the pre-coded token partitions. |
| 402 // Return true if everything is ok. | 449 // Return true if everything is ok. |
| 403 int VP8EncWrite(VP8Encoder* const enc); | 450 int VP8EncWrite(VP8Encoder* const enc); |
| 451 // Release memory allocated for bit-writing in VP8EncLoop & seq. |
| 452 void VP8EncFreeBitWriters(VP8Encoder* const enc); |
| 404 | 453 |
| 405 // in frame.c | 454 // in frame.c |
| 406 extern const uint8_t VP8EncBands[16 + 1]; | 455 extern const uint8_t VP8EncBands[16 + 1]; |
| 407 // Form all the four Intra16x16 predictions in the yuv_p_ cache | 456 // Form all the four Intra16x16 predictions in the yuv_p_ cache |
| 408 void VP8MakeLuma16Preds(const VP8EncIterator* const it); | 457 void VP8MakeLuma16Preds(const VP8EncIterator* const it); |
| 409 // Form all the four Chroma8x8 predictions in the yuv_p_ cache | 458 // Form all the four Chroma8x8 predictions in the yuv_p_ cache |
| 410 void VP8MakeChroma8Preds(const VP8EncIterator* const it); | 459 void VP8MakeChroma8Preds(const VP8EncIterator* const it); |
| 411 // Form all the ten Intra4x4 predictions in the yuv_p_ cache | 460 // Form all the ten Intra4x4 predictions in the yuv_p_ cache |
| 412 // for the 4x4 block it->i4_ | 461 // for the 4x4 block it->i4_ |
| 413 void VP8MakeIntra4Preds(const VP8EncIterator* const it); | 462 void VP8MakeIntra4Preds(const VP8EncIterator* const it); |
| 414 // Rate calculation | 463 // Rate calculation |
| 415 int VP8GetCostLuma16(VP8EncIterator* const it, const VP8ModeScore* const rd); | 464 int VP8GetCostLuma16(VP8EncIterator* const it, const VP8ModeScore* const rd); |
| 416 int VP8GetCostLuma4(VP8EncIterator* const it, const int16_t levels[16]); | 465 int VP8GetCostLuma4(VP8EncIterator* const it, const int16_t levels[16]); |
| 417 int VP8GetCostUV(VP8EncIterator* const it, const VP8ModeScore* const rd); | 466 int VP8GetCostUV(VP8EncIterator* const it, const VP8ModeScore* const rd); |
| 418 // Main stat / coding passes | 467 // Main stat / coding passes |
| 419 int VP8EncLoop(VP8Encoder* const enc); | 468 int VP8EncLoop(VP8Encoder* const enc); |
| 420 int VP8StatLoop(VP8Encoder* const enc); | 469 int VP8StatLoop(VP8Encoder* const enc); |
| 421 | 470 |
| 422 // in webpenc.c | 471 // in webpenc.c |
| 423 // Assign an error code to a picture. Return false for convenience. | 472 // Assign an error code to a picture. Return false for convenience. |
| 424 int WebPEncodingSetError(WebPPicture* const pic, WebPEncodingError error); | 473 int WebPEncodingSetError(const WebPPicture* const pic, WebPEncodingError error); |
| 474 int WebPReportProgress(const WebPPicture* const pic, |
| 475 int percent, int* const percent_store); |
| 425 | 476 |
| 426 // in analysis.c | 477 // in analysis.c |
| 427 // Main analysis loop. Decides the segmentations and complexity. | 478 // Main analysis loop. Decides the segmentations and complexity. |
| 428 // Assigns a first guess for Intra16 and uvmode_ prediction modes. | 479 // Assigns a first guess for Intra16 and uvmode_ prediction modes. |
| 429 int VP8EncAnalyze(VP8Encoder* const enc); | 480 int VP8EncAnalyze(VP8Encoder* const enc); |
| 430 | 481 |
| 431 // in quant.c | 482 // in quant.c |
| 432 // Sets up segment's quantization values, base_quant_ and filter strengths. | 483 // Sets up segment's quantization values, base_quant_ and filter strengths. |
| 433 void VP8SetSegmentParams(VP8Encoder* const enc, float quality); | 484 void VP8SetSegmentParams(VP8Encoder* const enc, float quality); |
| 434 // Pick best modes and fills the levels. Returns true if skipped. | 485 // Pick best modes and fills the levels. Returns true if skipped. |
| 435 int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, int rd_opt); | 486 int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, int rd_opt); |
| 436 | 487 |
| 437 // in alpha.c | 488 // in alpha.c |
| 438 void VP8EncInitAlpha(VP8Encoder* enc); // initialize alpha compression | 489 void VP8EncInitAlpha(VP8Encoder* const enc); // initialize alpha compression |
| 439 void VP8EncCodeAlphaBlock(VP8EncIterator* it); // analyze or code a macroblock | 490 int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data |
| 440 int VP8EncFinishAlpha(VP8Encoder* enc); // finalize compressed data | 491 void VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data |
| 441 void VP8EncDeleteAlpha(VP8Encoder* enc); // delete compressed data | |
| 442 | 492 |
| 443 // in layer.c | 493 // in layer.c |
| 444 void VP8EncInitLayer(VP8Encoder* const enc); // init everything | 494 void VP8EncInitLayer(VP8Encoder* const enc); // init everything |
| 445 void VP8EncCodeLayerBlock(VP8EncIterator* it); // code one more macroblock | 495 void VP8EncCodeLayerBlock(VP8EncIterator* it); // code one more macroblock |
| 446 int VP8EncFinishLayer(VP8Encoder* const enc); // finalize coding | 496 int VP8EncFinishLayer(VP8Encoder* const enc); // finalize coding |
| 447 void VP8EncDeleteLayer(VP8Encoder* enc); // reclaim memory | 497 void VP8EncDeleteLayer(VP8Encoder* enc); // reclaim memory |
| 448 | 498 |
| 449 // in filter.c | 499 // in filter.c |
| 450 extern void VP8InitFilter(VP8EncIterator* const it); | 500 |
| 451 extern void VP8StoreFilterStats(VP8EncIterator* const it); | 501 // SSIM utils |
| 452 extern void VP8AdjustFilterStrength(VP8EncIterator* const it); | 502 typedef struct { |
| 503 double w, xm, ym, xxm, xym, yym; |
| 504 } DistoStats; |
| 505 void VP8SSIMAddStats(const DistoStats* const src, DistoStats* const dst); |
| 506 void VP8SSIMAccumulatePlane(const uint8_t* src1, int stride1, |
| 507 const uint8_t* src2, int stride2, |
| 508 int W, int H, DistoStats* const stats); |
| 509 double VP8SSIMGet(const DistoStats* const stats); |
| 510 double VP8SSIMGetSquaredError(const DistoStats* const stats); |
| 511 |
| 512 // autofilter |
| 513 void VP8InitFilter(VP8EncIterator* const it); |
| 514 void VP8StoreFilterStats(VP8EncIterator* const it); |
| 515 void VP8AdjustFilterStrength(VP8EncIterator* const it); |
| 453 | 516 |
| 454 //------------------------------------------------------------------------------ | 517 //------------------------------------------------------------------------------ |
| 455 | 518 |
| 456 #if defined(__cplusplus) || defined(c_plusplus) | 519 #if defined(__cplusplus) || defined(c_plusplus) |
| 457 } // extern "C" | 520 } // extern "C" |
| 458 #endif | 521 #endif |
| 459 | 522 |
| 460 #endif /* WEBP_ENC_VP8ENCI_H_ */ | 523 #endif /* WEBP_ENC_VP8ENCI_H_ */ |
| OLD | NEW |