// Copyright 2012 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. // ----------------------------------------------------------------------------- // // Author: Jyrki Alakuijala (jyrki@google.com) //
typedefstruct { // mode as uint8_t to make the memory layout to be exactly 8 bytes.
uint8_t mode;
uint16_t len;
uint32_t argb_or_distance;
} PixOrCopy;
// If you change this, you need MAX_LENGTH_BITS + WINDOW_SIZE_BITS <= 32 as it // is used in VP8LHashChain. #define MAX_LENGTH_BITS 12 #define WINDOW_SIZE_BITS 20 // We want the max value to be attainable and stored in MAX_LENGTH_BITS bits. #define MAX_LENGTH ((1 << MAX_LENGTH_BITS) - 1) #if MAX_LENGTH_BITS + WINDOW_SIZE_BITS > 32 #error"MAX_LENGTH_BITS + WINDOW_SIZE_BITS > 32" #endif
typedefstruct VP8LHashChain VP8LHashChain; struct VP8LHashChain { // The 20 most significant bits contain the offset at which the best match // is found. These 20 bits are the limit defined by GetWindowSizeForHashChain // (through WINDOW_SIZE = 1<<20). // The lower 12 bits contain the length of the match. The 12 bit limit is // defined in MaxFindCopyLength with MAX_LENGTH=4096.
uint32_t* offset_length_; // This is the maximum size of the hash_chain that can be constructed. // Typically this is the pixel count (width x height) for a given image. int size_;
};
// Must be called first, to set size. int VP8LHashChainInit(VP8LHashChain* const p, int size); // Pre-compute the best matches for argb. pic and percent are for progress. int VP8LHashChainFill(VP8LHashChain* const p, int quality, const uint32_t* const argb, int xsize, int ysize, int low_effort, const WebPPicture* const pic, int percent_range, int* const percent); void VP8LHashChainClear(VP8LHashChain* const p); // release memory
// Container for blocks chain struct VP8LBackwardRefs { int block_size_; // common block-size int error_; // set to true if some memory error occurred
PixOrCopyBlock* refs_; // list of currently used blocks
PixOrCopyBlock** tail_; // for list recycling
PixOrCopyBlock* free_blocks_; // free-list
PixOrCopyBlock* last_block_; // used for adding new refs (internal)
};
// Initialize the object. 'block_size' is the common block size to store // references (typically, width * height / MAX_REFS_BLOCK_PER_IMAGE). void VP8LBackwardRefsInit(VP8LBackwardRefs* const refs, int block_size); // Release memory for backward references. void VP8LBackwardRefsClear(VP8LBackwardRefs* const refs);
// Cursor for iterating on references content typedefstruct { // public:
PixOrCopy* cur_pos; // current position // private:
PixOrCopyBlock* cur_block_; // current block in the refs list const PixOrCopy* last_pos_; // sentinel for switching to next block
} VP8LRefsCursor;
// Returns a cursor positioned at the beginning of the references list.
VP8LRefsCursor VP8LRefsCursorInit(const VP8LBackwardRefs* const refs); // Returns true if cursor is pointing at a valid position. static WEBP_INLINE int VP8LRefsCursorOk(const VP8LRefsCursor* const c) { return (c->cur_pos != NULL);
} // Move to next block of references. Internal, not to be called directly. void VP8LRefsCursorNextBlock(VP8LRefsCursor* const c); // Move to next position, or NULL. Should not be called if !VP8LRefsCursorOk(). static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
assert(c != NULL);
assert(VP8LRefsCursorOk(c)); if (++c->cur_pos == c->last_pos_) VP8LRefsCursorNextBlock(c);
}
// ----------------------------------------------------------------------------- // Main entry points
// Evaluates best possible backward references for specified quality. // The input cache_bits to 'VP8LGetBackwardReferences' sets the maximum cache // bits to use (passing 0 implies disabling the local color cache). // The optimal cache bits is evaluated and set for the *cache_bits_best // parameter with the matching refs_best. // If do_no_cache == 0, refs is an array of 2 values and the best // VP8LBackwardRefs is put in the first element. // If do_no_cache != 0, refs is an array of 3 values and the best // VP8LBackwardRefs is put in the first element, the best value with no-cache in // the second element. // In both cases, the last element is used as temporary internally. // pic and percent are for progress. // Returns false in case of error (stored in pic->error_code). int VP8LGetBackwardReferences( int width, int height, const uint32_t* const argb, int quality, int low_effort, int lz77_types_to_try, int cache_bits_max, int do_no_cache, const VP8LHashChain* const hash_chain, VP8LBackwardRefs* const refs, int* const cache_bits_best, const WebPPicture* const pic, int percent_range, int* const percent);
#ifdef __cplusplus
} #endif
#endif// WEBP_ENC_BACKWARD_REFERENCES_ENC_H_
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.