| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 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 #include "../utils/thread.h" |
| 19 | 20 |
| 20 #if defined(__cplusplus) || defined(c_plusplus) | 21 #if defined(__cplusplus) || defined(c_plusplus) |
| 21 extern "C" { | 22 extern "C" { |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 //------------------------------------------------------------------------------ | 25 //------------------------------------------------------------------------------ |
| 25 // Various defines and enums | 26 // Various defines and enums |
| 26 | 27 |
| 27 // version numbers | 28 // version numbers |
| 28 #define ENC_MAJ_VERSION 0 | 29 #define ENC_MAJ_VERSION 0 |
| 29 #define ENC_MIN_VERSION 2 | 30 #define ENC_MIN_VERSION 3 |
| 30 #define ENC_REV_VERSION 0 | 31 #define ENC_REV_VERSION 0 |
| 31 | 32 |
| 32 // size of histogram used by CollectHistogram. | |
| 33 #define MAX_COEFF_THRESH 64 | |
| 34 | |
| 35 // intra prediction modes | 33 // intra prediction modes |
| 36 enum { B_DC_PRED = 0, // 4x4 modes | 34 enum { B_DC_PRED = 0, // 4x4 modes |
| 37 B_TM_PRED = 1, | 35 B_TM_PRED = 1, |
| 38 B_VE_PRED = 2, | 36 B_VE_PRED = 2, |
| 39 B_HE_PRED = 3, | 37 B_HE_PRED = 3, |
| 40 B_RD_PRED = 4, | 38 B_RD_PRED = 4, |
| 41 B_VR_PRED = 5, | 39 B_VR_PRED = 5, |
| 42 B_LD_PRED = 6, | 40 B_LD_PRED = 6, |
| 43 B_VL_PRED = 7, | 41 B_VL_PRED = 7, |
| 44 B_HD_PRED = 8, | 42 B_HD_PRED = 8, |
| 45 B_HU_PRED = 9, | 43 B_HU_PRED = 9, |
| 46 NUM_BMODES = B_HU_PRED + 1 - B_DC_PRED, // = 10 | 44 NUM_BMODES = B_HU_PRED + 1 - B_DC_PRED, // = 10 |
| 47 | 45 |
| 48 // Luma16 or UV modes | 46 // Luma16 or UV modes |
| 49 DC_PRED = B_DC_PRED, V_PRED = B_VE_PRED, | 47 DC_PRED = B_DC_PRED, V_PRED = B_VE_PRED, |
| 50 H_PRED = B_HE_PRED, TM_PRED = B_TM_PRED | 48 H_PRED = B_HE_PRED, TM_PRED = B_TM_PRED, |
| 49 NUM_PRED_MODES = 4 |
| 51 }; | 50 }; |
| 52 | 51 |
| 53 enum { NUM_MB_SEGMENTS = 4, | 52 enum { NUM_MB_SEGMENTS = 4, |
| 54 MAX_NUM_PARTITIONS = 8, | 53 MAX_NUM_PARTITIONS = 8, |
| 55 NUM_TYPES = 4, // 0: i16-AC, 1: i16-DC, 2:chroma-AC, 3:i4-AC | 54 NUM_TYPES = 4, // 0: i16-AC, 1: i16-DC, 2:chroma-AC, 3:i4-AC |
| 56 NUM_BANDS = 8, | 55 NUM_BANDS = 8, |
| 57 NUM_CTX = 3, | 56 NUM_CTX = 3, |
| 58 NUM_PROBAS = 11, | 57 NUM_PROBAS = 11, |
| 59 MAX_LF_LEVELS = 64, // Maximum loop filter level | 58 MAX_LF_LEVELS = 64, // Maximum loop filter level |
| 60 MAX_VARIABLE_LEVEL = 67 // last (inclusive) level with variable cost | 59 MAX_VARIABLE_LEVEL = 67 // last (inclusive) level with variable cost |
| 61 }; | 60 }; |
| 62 | 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 |
| 63 // YUV-cache parameters. Cache is 16-pixels wide. | 69 // YUV-cache parameters. Cache is 16-pixels wide. |
| 64 // The original or reconstructed samples can be accessed using VP8Scan[] | 70 // The original or reconstructed samples can be accessed using VP8Scan[] |
| 65 // The predicted blocks can be accessed using offsets to yuv_p_ and | 71 // The predicted blocks can be accessed using offsets to yuv_p_ and |
| 66 // the arrays VP8*ModeOffsets[]; | 72 // the arrays VP8*ModeOffsets[]; |
| 67 // +----+ YUV Samples area. See VP8Scan[] for accessing the blocks. | 73 // +----+ YUV Samples area. See VP8Scan[] for accessing the blocks. |
| 68 // Y_OFF |YYYY| <- original samples (enc->yuv_in_) | 74 // Y_OFF |YYYY| <- original samples (enc->yuv_in_) |
| 69 // |YYYY| | 75 // |YYYY| |
| 70 // |YYYY| | 76 // |YYYY| |
| 71 // |YYYY| | 77 // |YYYY| |
| 72 // U_OFF |UUVV| V_OFF (=U_OFF + 8) | 78 // U_OFF |UUVV| V_OFF (=U_OFF + 8) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 typedef int64_t score_t; // type used for scores, rate, distortion | 159 typedef int64_t score_t; // type used for scores, rate, distortion |
| 154 #define MAX_COST ((score_t)0x7fffffffffffffLL) | 160 #define MAX_COST ((score_t)0x7fffffffffffffLL) |
| 155 | 161 |
| 156 #define QFIX 17 | 162 #define QFIX 17 |
| 157 #define BIAS(b) ((b) << (QFIX - 8)) | 163 #define BIAS(b) ((b) << (QFIX - 8)) |
| 158 // Fun fact: this is the _only_ line where we're actually being lossy and | 164 // Fun fact: this is the _only_ line where we're actually being lossy and |
| 159 // discarding bits. | 165 // discarding bits. |
| 160 static WEBP_INLINE int QUANTDIV(int n, int iQ, int B) { | 166 static WEBP_INLINE int QUANTDIV(int n, int iQ, int B) { |
| 161 return (n * iQ + B) >> QFIX; | 167 return (n * iQ + B) >> QFIX; |
| 162 } | 168 } |
| 163 extern const uint8_t VP8Zigzag[16]; | 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 |
| 164 | 180 |
| 165 //------------------------------------------------------------------------------ | 181 //------------------------------------------------------------------------------ |
| 166 // Headers | 182 // Headers |
| 167 | 183 |
| 184 typedef uint32_t proba_t; // 16b + 16b |
| 168 typedef uint8_t ProbaArray[NUM_CTX][NUM_PROBAS]; | 185 typedef uint8_t ProbaArray[NUM_CTX][NUM_PROBAS]; |
| 169 typedef uint64_t StatsArray[NUM_CTX][NUM_PROBAS][2]; | 186 typedef proba_t StatsArray[NUM_CTX][NUM_PROBAS]; |
| 170 typedef uint16_t CostArray[NUM_CTX][MAX_VARIABLE_LEVEL + 1]; | 187 typedef uint16_t CostArray[NUM_CTX][MAX_VARIABLE_LEVEL + 1]; |
| 171 typedef double LFStats[NUM_MB_SEGMENTS][MAX_LF_LEVELS]; // filter stats | 188 typedef double LFStats[NUM_MB_SEGMENTS][MAX_LF_LEVELS]; // filter stats |
| 172 | 189 |
| 173 typedef struct VP8Encoder VP8Encoder; | 190 typedef struct VP8Encoder VP8Encoder; |
| 174 | 191 |
| 175 // segment features | 192 // segment features |
| 176 typedef struct { | 193 typedef struct { |
| 177 int num_segments_; // Actual number of segments. 1 segment only = unused. | 194 int num_segments_; // Actual number of segments. 1 segment only = unused. |
| 178 int update_map_; // whether to update the segment map or not. | 195 int update_map_; // whether to update the segment map or not. |
| 179 // must be 0 if there's only 1 segment. | 196 // must be 0 if there's only 1 segment. |
| 180 int size_; // bit-cost for transmitting the segment map | 197 int size_; // bit-cost for transmitting the segment map |
| 181 } VP8SegmentHeader; | 198 } VP8SegmentHeader; |
| 182 | 199 |
| 183 // Struct collecting all frame-persistent probabilities. | 200 // Struct collecting all frame-persistent probabilities. |
| 184 typedef struct { | 201 typedef struct { |
| 185 uint8_t segments_[3]; // probabilities for segment tree | 202 uint8_t segments_[3]; // probabilities for segment tree |
| 186 uint8_t skip_proba_; // final probability of being skipped. | 203 uint8_t skip_proba_; // final probability of being skipped. |
| 187 ProbaArray coeffs_[NUM_TYPES][NUM_BANDS]; // 924 bytes | 204 ProbaArray coeffs_[NUM_TYPES][NUM_BANDS]; // 924 bytes |
| 188 StatsArray stats_[NUM_TYPES][NUM_BANDS]; // 7.4k | 205 StatsArray stats_[NUM_TYPES][NUM_BANDS]; // 4224 bytes |
| 189 CostArray level_cost_[NUM_TYPES][NUM_BANDS]; // 11.4k | 206 CostArray level_cost_[NUM_TYPES][NUM_BANDS]; // 11.4k |
| 207 int dirty_; // if true, need to call VP8CalculateLevelCosts() |
| 190 int use_skip_proba_; // Note: we always use skip_proba for now. | 208 int use_skip_proba_; // Note: we always use skip_proba for now. |
| 191 int nb_skip_; // number of skipped blocks | 209 int nb_skip_; // number of skipped blocks |
| 192 } VP8Proba; | 210 } VP8Proba; |
| 193 | 211 |
| 194 // Filter parameters. Not actually used in the code (we don't perform | 212 // Filter parameters. Not actually used in the code (we don't perform |
| 195 // the in-loop filtering), but filled from user's config | 213 // the in-loop filtering), but filled from user's config |
| 196 typedef struct { | 214 typedef struct { |
| 197 int simple_; // filtering type: 0=complex, 1=simple | 215 int simple_; // filtering type: 0=complex, 1=simple |
| 198 int level_; // base filter level [0..63] | 216 int level_; // base filter level [0..63] |
| 199 int sharpness_; // [0..7] | 217 int sharpness_; // [0..7] |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // Helper functions to set mode properties | 323 // Helper functions to set mode properties |
| 306 void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode); | 324 void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode); |
| 307 void VP8SetIntra4Mode(const VP8EncIterator* const it, const uint8_t* modes); | 325 void VP8SetIntra4Mode(const VP8EncIterator* const it, const uint8_t* modes); |
| 308 void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode); | 326 void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode); |
| 309 void VP8SetSkip(const VP8EncIterator* const it, int skip); | 327 void VP8SetSkip(const VP8EncIterator* const it, int skip); |
| 310 void VP8SetSegment(const VP8EncIterator* const it, int segment); | 328 void VP8SetSegment(const VP8EncIterator* const it, int segment); |
| 311 | 329 |
| 312 //------------------------------------------------------------------------------ | 330 //------------------------------------------------------------------------------ |
| 313 // Paginated token buffer | 331 // Paginated token buffer |
| 314 | 332 |
| 315 // WIP: #define USE_TOKEN_BUFFER | 333 typedef struct VP8Tokens VP8Tokens; // struct details in token.c |
| 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 | 334 |
| 328 typedef struct { | 335 typedef struct { |
| 329 VP8Tokens* rows_; | 336 #if !defined(DISABLE_TOKEN_BUFFER) |
| 330 uint16_t* tokens_; // set to (*last_)->tokens_ | 337 VP8Tokens* pages_; // first page |
| 331 VP8Tokens** last_; | 338 VP8Tokens** last_page_; // last page |
| 332 int left_; | 339 uint16_t* tokens_; // set to (*last_page_)->tokens_ |
| 333 int error_; // true in case of malloc error | 340 int left_; // how many free tokens left before the page is full. |
| 341 #endif |
| 342 int error_; // true in case of malloc error |
| 334 } VP8TBuffer; | 343 } VP8TBuffer; |
| 335 | 344 |
| 336 void VP8TBufferInit(VP8TBuffer* const b); // initialize an empty buffer | 345 void VP8TBufferInit(VP8TBuffer* const b); // initialize an empty buffer |
| 337 int VP8TBufferNewPage(VP8TBuffer* const b); // allocate a new page | 346 void VP8TBufferClear(VP8TBuffer* const b); // de-allocate pages memory |
| 338 void VP8TBufferClear(VP8TBuffer* const b); // de-allocate memory | |
| 339 | 347 |
| 340 int VP8EmitTokens(const VP8TBuffer* const b, VP8BitWriter* const bw, | 348 #if !defined(DISABLE_TOKEN_BUFFER) |
| 341 const uint8_t* const probas); | |
| 342 | 349 |
| 343 static WEBP_INLINE int VP8AddToken(VP8TBuffer* const b, | 350 // Finalizes bitstream when probabilities are known. |
| 344 int bit, int proba_idx) { | 351 // Deletes the allocated token memory if final_pass is true. |
| 345 if (b->left_ > 0 || VP8TBufferNewPage(b)) { | 352 int VP8EmitTokens(VP8TBuffer* const b, VP8BitWriter* const bw, |
| 346 const int slot = --b->left_; | 353 const uint8_t* const probas, int final_pass); |
| 347 b->tokens_[slot] = (bit << 15) | proba_idx; | |
| 348 } | |
| 349 return bit; | |
| 350 } | |
| 351 | 354 |
| 352 #endif // USE_TOKEN_BUFFER | 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 |
| 353 | 364 |
| 354 //------------------------------------------------------------------------------ | 365 //------------------------------------------------------------------------------ |
| 355 // VP8Encoder | 366 // VP8Encoder |
| 356 | 367 |
| 357 struct VP8Encoder { | 368 struct VP8Encoder { |
| 358 const WebPConfig* config_; // user configuration and parameters | 369 const WebPConfig* config_; // user configuration and parameters |
| 359 WebPPicture* pic_; // input / output picture | 370 WebPPicture* pic_; // input / output picture |
| 360 | 371 |
| 361 // headers | 372 // headers |
| 362 VP8FilterHeader filter_hdr_; // filtering information | 373 VP8FilterHeader filter_hdr_; // filtering information |
| 363 VP8SegmentHeader segment_hdr_; // segment information | 374 VP8SegmentHeader segment_hdr_; // segment information |
| 364 | 375 |
| 365 int profile_; // VP8's profile, deduced from Config. | 376 int profile_; // VP8's profile, deduced from Config. |
| 366 | 377 |
| 367 // dimension, in macroblock units. | 378 // dimension, in macroblock units. |
| 368 int mb_w_, mb_h_; | 379 int mb_w_, mb_h_; |
| 369 int preds_w_; // stride of the *preds_ prediction plane (=4*mb_w + 1) | 380 int preds_w_; // stride of the *preds_ prediction plane (=4*mb_w + 1) |
| 370 | 381 |
| 371 // number of partitions (1, 2, 4 or 8 = MAX_NUM_PARTITIONS) | 382 // number of partitions (1, 2, 4 or 8 = MAX_NUM_PARTITIONS) |
| 372 int num_parts_; | 383 int num_parts_; |
| 373 | 384 |
| 374 // per-partition boolean decoders. | 385 // per-partition boolean decoders. |
| 375 VP8BitWriter bw_; // part0 | 386 VP8BitWriter bw_; // part0 |
| 376 VP8BitWriter parts_[MAX_NUM_PARTITIONS]; // token partitions | 387 VP8BitWriter parts_[MAX_NUM_PARTITIONS]; // token partitions |
| 388 VP8TBuffer tokens_; // token buffer |
| 377 | 389 |
| 378 int percent_; // for progress | 390 int percent_; // for progress |
| 379 | 391 |
| 380 // transparency blob | 392 // transparency blob |
| 381 int has_alpha_; | 393 int has_alpha_; |
| 382 uint8_t* alpha_data_; // non-NULL if transparency is present | 394 uint8_t* alpha_data_; // non-NULL if transparency is present |
| 383 uint32_t alpha_data_size_; | 395 uint32_t alpha_data_size_; |
| 396 WebPWorker alpha_worker_; |
| 384 | 397 |
| 385 // enhancement layer | 398 // enhancement layer |
| 386 int use_layer_; | 399 int use_layer_; |
| 387 VP8BitWriter layer_bw_; | 400 VP8BitWriter layer_bw_; |
| 388 uint8_t* layer_data_; | 401 uint8_t* layer_data_; |
| 389 size_t layer_data_size_; | 402 size_t layer_data_size_; |
| 390 | 403 |
| 391 // quantization info (one set of DC/AC dequant factor per segment) | 404 // quantization info (one set of DC/AC dequant factor per segment) |
| 392 VP8SegmentInfo dqm_[NUM_MB_SEGMENTS]; | 405 VP8SegmentInfo dqm_[NUM_MB_SEGMENTS]; |
| 393 int base_quant_; // nominal quantizer value. Only used | 406 int base_quant_; // nominal quantizer value. Only used |
| 394 // for relative coding of segments' quant. | 407 // for relative coding of segments' quant. |
| 408 int alpha_; // global susceptibility (<=> complexity) |
| 395 int uv_alpha_; // U/V quantization susceptibility | 409 int uv_alpha_; // U/V quantization susceptibility |
| 396 // global offset of quantizers, shared by all segments | 410 // global offset of quantizers, shared by all segments |
| 397 int dq_y1_dc_; | 411 int dq_y1_dc_; |
| 398 int dq_y2_dc_, dq_y2_ac_; | 412 int dq_y2_dc_, dq_y2_ac_; |
| 399 int dq_uv_dc_, dq_uv_ac_; | 413 int dq_uv_dc_, dq_uv_ac_; |
| 400 | 414 |
| 401 // probabilities and statistics | 415 // probabilities and statistics |
| 402 VP8Proba proba_; | 416 VP8Proba proba_; |
| 403 uint64_t sse_[4]; // sum of Y/U/V/A squared errors for all macroblocks | 417 uint64_t sse_[4]; // sum of Y/U/V/A squared errors for all macroblocks |
| 404 uint64_t sse_count_; // pixel count for the sse_[] stats | 418 uint64_t sse_count_; // pixel count for the sse_[] stats |
| 405 int coded_size_; | 419 int coded_size_; |
| 406 int residual_bytes_[3][4]; | 420 int residual_bytes_[3][4]; |
| 407 int block_count_[3]; | 421 int block_count_[3]; |
| 408 | 422 |
| 409 // quality/speed settings | 423 // quality/speed settings |
| 410 int method_; // 0=fastest, 6=best/slowest. | 424 int method_; // 0=fastest, 6=best/slowest. |
| 411 int rd_opt_level_; // Deduced from method_. | 425 VP8RDLevel rd_opt_level_; // Deduced from method_. |
| 412 int max_i4_header_bits_; // partition #0 safeness factor | 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 |
| 413 | 430 |
| 414 // Memory | 431 // Memory |
| 415 VP8MBInfo* mb_info_; // contextual macroblock infos (mb_w_ + 1) | 432 VP8MBInfo* mb_info_; // contextual macroblock infos (mb_w_ + 1) |
| 416 uint8_t* preds_; // predictions modes: (4*mb_w+1) * (4*mb_h+1) | 433 uint8_t* preds_; // predictions modes: (4*mb_w+1) * (4*mb_h+1) |
| 417 uint32_t* nz_; // non-zero bit context: mb_w+1 | 434 uint32_t* nz_; // non-zero bit context: mb_w+1 |
| 418 uint8_t* yuv_in_; // input samples | 435 uint8_t* yuv_in_; // input samples |
| 419 uint8_t* yuv_out_; // output samples | 436 uint8_t* yuv_out_; // output samples |
| 420 uint8_t* yuv_out2_; // secondary scratch out-buffer. swapped with yuv_out_. | 437 uint8_t* yuv_out2_; // secondary scratch out-buffer. swapped with yuv_out_. |
| 421 uint8_t* yuv_p_; // scratch buffer for prediction | 438 uint8_t* yuv_p_; // scratch buffer for prediction |
| 422 uint8_t *y_top_; // top luma samples. | 439 uint8_t *y_top_; // top luma samples. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 446 // in syntax.c | 463 // in syntax.c |
| 447 // Generates the final bitstream by coding the partition0 and headers, | 464 // Generates the final bitstream by coding the partition0 and headers, |
| 448 // and appending an assembly of all the pre-coded token partitions. | 465 // and appending an assembly of all the pre-coded token partitions. |
| 449 // Return true if everything is ok. | 466 // Return true if everything is ok. |
| 450 int VP8EncWrite(VP8Encoder* const enc); | 467 int VP8EncWrite(VP8Encoder* const enc); |
| 451 // Release memory allocated for bit-writing in VP8EncLoop & seq. | 468 // Release memory allocated for bit-writing in VP8EncLoop & seq. |
| 452 void VP8EncFreeBitWriters(VP8Encoder* const enc); | 469 void VP8EncFreeBitWriters(VP8Encoder* const enc); |
| 453 | 470 |
| 454 // in frame.c | 471 // in frame.c |
| 455 extern const uint8_t VP8EncBands[16 + 1]; | 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 |
| 456 // Form all the four Intra16x16 predictions in the yuv_p_ cache | 478 // Form all the four Intra16x16 predictions in the yuv_p_ cache |
| 457 void VP8MakeLuma16Preds(const VP8EncIterator* const it); | 479 void VP8MakeLuma16Preds(const VP8EncIterator* const it); |
| 458 // Form all the four Chroma8x8 predictions in the yuv_p_ cache | 480 // Form all the four Chroma8x8 predictions in the yuv_p_ cache |
| 459 void VP8MakeChroma8Preds(const VP8EncIterator* const it); | 481 void VP8MakeChroma8Preds(const VP8EncIterator* const it); |
| 460 // Form all the ten Intra4x4 predictions in the yuv_p_ cache | 482 // Form all the ten Intra4x4 predictions in the yuv_p_ cache |
| 461 // for the 4x4 block it->i4_ | 483 // for the 4x4 block it->i4_ |
| 462 void VP8MakeIntra4Preds(const VP8EncIterator* const it); | 484 void VP8MakeIntra4Preds(const VP8EncIterator* const it); |
| 463 // Rate calculation | 485 // Rate calculation |
| 464 int VP8GetCostLuma16(VP8EncIterator* const it, const VP8ModeScore* const rd); | 486 int VP8GetCostLuma16(VP8EncIterator* const it, const VP8ModeScore* const rd); |
| 465 int VP8GetCostLuma4(VP8EncIterator* const it, const int16_t levels[16]); | 487 int VP8GetCostLuma4(VP8EncIterator* const it, const int16_t levels[16]); |
| 466 int VP8GetCostUV(VP8EncIterator* const it, const VP8ModeScore* const rd); | 488 int VP8GetCostUV(VP8EncIterator* const it, const VP8ModeScore* const rd); |
| 467 // Main stat / coding passes | 489 // Main coding calls |
| 468 int VP8EncLoop(VP8Encoder* const enc); | 490 int VP8EncLoop(VP8Encoder* const enc); |
| 469 int VP8StatLoop(VP8Encoder* const enc); | 491 int VP8EncTokenLoop(VP8Encoder* const enc); |
| 470 | 492 |
| 471 // in webpenc.c | 493 // in webpenc.c |
| 472 // Assign an error code to a picture. Return false for convenience. | 494 // Assign an error code to a picture. Return false for convenience. |
| 473 int WebPEncodingSetError(const WebPPicture* const pic, WebPEncodingError error); | 495 int WebPEncodingSetError(const WebPPicture* const pic, WebPEncodingError error); |
| 474 int WebPReportProgress(const WebPPicture* const pic, | 496 int WebPReportProgress(const WebPPicture* const pic, |
| 475 int percent, int* const percent_store); | 497 int percent, int* const percent_store); |
| 476 | 498 |
| 477 // in analysis.c | 499 // in analysis.c |
| 478 // Main analysis loop. Decides the segmentations and complexity. | 500 // Main analysis loop. Decides the segmentations and complexity. |
| 479 // Assigns a first guess for Intra16 and uvmode_ prediction modes. | 501 // Assigns a first guess for Intra16 and uvmode_ prediction modes. |
| 480 int VP8EncAnalyze(VP8Encoder* const enc); | 502 int VP8EncAnalyze(VP8Encoder* const enc); |
| 481 | 503 |
| 482 // in quant.c | 504 // in quant.c |
| 483 // Sets up segment's quantization values, base_quant_ and filter strengths. | 505 // Sets up segment's quantization values, base_quant_ and filter strengths. |
| 484 void VP8SetSegmentParams(VP8Encoder* const enc, float quality); | 506 void VP8SetSegmentParams(VP8Encoder* const enc, float quality); |
| 485 // Pick best modes and fills the levels. Returns true if skipped. | 507 // Pick best modes and fills the levels. Returns true if skipped. |
| 486 int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, int rd_opt); | 508 int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, |
| 509 VP8RDLevel rd_opt); |
| 487 | 510 |
| 488 // in alpha.c | 511 // in alpha.c |
| 489 void VP8EncInitAlpha(VP8Encoder* const enc); // initialize alpha compression | 512 void VP8EncInitAlpha(VP8Encoder* const enc); // initialize alpha compression |
| 513 int VP8EncStartAlpha(VP8Encoder* const enc); // start alpha coding process |
| 490 int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data | 514 int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data |
| 491 void VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data | 515 int VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data |
| 492 | 516 |
| 493 // in layer.c | 517 // in layer.c |
| 494 void VP8EncInitLayer(VP8Encoder* const enc); // init everything | 518 void VP8EncInitLayer(VP8Encoder* const enc); // init everything |
| 495 void VP8EncCodeLayerBlock(VP8EncIterator* it); // code one more macroblock | 519 void VP8EncCodeLayerBlock(VP8EncIterator* it); // code one more macroblock |
| 496 int VP8EncFinishLayer(VP8Encoder* const enc); // finalize coding | 520 int VP8EncFinishLayer(VP8Encoder* const enc); // finalize coding |
| 497 void VP8EncDeleteLayer(VP8Encoder* enc); // reclaim memory | 521 void VP8EncDeleteLayer(VP8Encoder* enc); // reclaim memory |
| 498 | 522 |
| 499 // in filter.c | 523 // in filter.c |
| 500 | 524 |
| 501 // SSIM utils | 525 // SSIM utils |
| (...skipping 12 matching lines...) Expand all Loading... |
| 514 void VP8StoreFilterStats(VP8EncIterator* const it); | 538 void VP8StoreFilterStats(VP8EncIterator* const it); |
| 515 void VP8AdjustFilterStrength(VP8EncIterator* const it); | 539 void VP8AdjustFilterStrength(VP8EncIterator* const it); |
| 516 | 540 |
| 517 //------------------------------------------------------------------------------ | 541 //------------------------------------------------------------------------------ |
| 518 | 542 |
| 519 #if defined(__cplusplus) || defined(c_plusplus) | 543 #if defined(__cplusplus) || defined(c_plusplus) |
| 520 } // extern "C" | 544 } // extern "C" |
| 521 #endif | 545 #endif |
| 522 | 546 |
| 523 #endif /* WEBP_ENC_VP8ENCI_H_ */ | 547 #endif /* WEBP_ENC_VP8ENCI_H_ */ |
| OLD | NEW |