// Copyright 2011 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // WebP encoder: main entry point // // Author: Skal ([email protected]) #include <assert.h> #include <stdlib.h> #include <string.h> #include <math.h> #include "src/enc/cost_enc.h" #include "src/enc/vp8i_enc.h" #include "src/enc/vp8li_enc.h" #include "src/utils/utils.h" // #define PRINT_MEMORY_INFO #ifdef PRINT_MEMORY_INFO #include <stdio.h> #endif //------------------------------------------------------------------------------ int WebPGetEncoderVersion(void) { … } //------------------------------------------------------------------------------ // VP8Encoder //------------------------------------------------------------------------------ static void ResetSegmentHeader(VP8Encoder* const enc) { … } static void ResetFilterHeader(VP8Encoder* const enc) { … } static void ResetBoundaryPredictions(VP8Encoder* const enc) { … } // Mapping from config->method_ to coding tools used. //-------------------+---+---+---+---+---+---+---+ // Method | 0 | 1 | 2 | 3 |(4)| 5 | 6 | //-------------------+---+---+---+---+---+---+---+ // fast probe | x | | | x | | | | //-------------------+---+---+---+---+---+---+---+ // dynamic proba | ~ | x | x | x | x | x | x | //-------------------+---+---+---+---+---+---+---+ // fast mode analysis|[x]|[x]| | | x | x | x | //-------------------+---+---+---+---+---+---+---+ // basic rd-opt | | | | x | x | x | x | //-------------------+---+---+---+---+---+---+---+ // disto-refine i4/16| x | x | x | | | | | //-------------------+---+---+---+---+---+---+---+ // disto-refine uv | | x | x | | | | | //-------------------+---+---+---+---+---+---+---+ // rd-opt i4/16 | | | ~ | x | x | x | x | //-------------------+---+---+---+---+---+---+---+ // token buffer (opt)| | | | x | x | x | x | //-------------------+---+---+---+---+---+---+---+ // Trellis | | | | | | x |Ful| //-------------------+---+---+---+---+---+---+---+ // full-SNS | | | | | x | x | x | //-------------------+---+---+---+---+---+---+---+ static void MapConfigToTools(VP8Encoder* const enc) { … } // Memory scaling with dimensions: // memory (bytes) ~= 2.25 * w + 0.0625 * w * h // // Typical memory footprint (614x440 picture) // encoder: 22111 // info: 4368 // preds: 17741 // top samples: 1263 // non-zero: 175 // lf-stats: 0 // total: 45658 // Transient object sizes: // VP8EncIterator: 3360 // VP8ModeScore: 872 // VP8SegmentInfo: 732 // VP8EncProba: 18352 // LFStats: 2048 // Picture size (yuv): 419328 static VP8Encoder* InitVP8Encoder(const WebPConfig* const config, WebPPicture* const picture) { … } static int DeleteVP8Encoder(VP8Encoder* enc) { … } //------------------------------------------------------------------------------ #if !defined(WEBP_DISABLE_STATS) static double GetPSNR(uint64_t err, uint64_t size) { … } static void FinalizePSNR(const VP8Encoder* const enc) { … } #endif // !defined(WEBP_DISABLE_STATS) static void StoreStats(VP8Encoder* const enc) { … } int WebPEncodingSetError(const WebPPicture* const pic, WebPEncodingError error) { … } int WebPReportProgress(const WebPPicture* const pic, int percent, int* const percent_store) { … } //------------------------------------------------------------------------------ int WebPEncode(const WebPConfig* config, WebPPicture* pic) { … }