Home | History | Annotate | Download | only in enc
      1 // Copyright 2011 Google Inc. All Rights Reserved.
      2 //
      3 // Use of this source code is governed by a BSD-style license
      4 // that can be found in the COPYING file in the root of the source
      5 // tree. An additional intellectual property rights grant can be found
      6 // in the file PATENTS. All contributing project authors may
      7 // be found in the AUTHORS file in the root of the source tree.
      8 // -----------------------------------------------------------------------------
      9 //
     10 // Cost tables for level and modes.
     11 //
     12 // Author: Skal (pascal.massimino (at) gmail.com)
     13 
     14 #ifndef WEBP_ENC_COST_H_
     15 #define WEBP_ENC_COST_H_
     16 
     17 #include "./vp8enci.h"
     18 
     19 #if defined(__cplusplus) || defined(c_plusplus)
     20 extern "C" {
     21 #endif
     22 
     23 // approximate cost per level:
     24 extern const uint16_t VP8LevelFixedCosts[MAX_LEVEL + 1];
     25 extern const uint16_t VP8EntropyCost[256];        // 8bit fixed-point log(p)
     26 
     27 // Cost of coding one event with probability 'proba'.
     28 static WEBP_INLINE int VP8BitCost(int bit, uint8_t proba) {
     29   return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba];
     30 }
     31 
     32 // Level cost calculations
     33 extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2];
     34 void VP8CalculateLevelCosts(VP8Proba* const proba);
     35 static WEBP_INLINE int VP8LevelCost(const uint16_t* const table, int level) {
     36   return VP8LevelFixedCosts[level]
     37        + table[(level > MAX_VARIABLE_LEVEL) ? MAX_VARIABLE_LEVEL : level];
     38 }
     39 
     40 // Mode costs
     41 extern const uint16_t VP8FixedCostsUV[4];
     42 extern const uint16_t VP8FixedCostsI16[4];
     43 extern const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES];
     44 
     45 //------------------------------------------------------------------------------
     46 
     47 #if defined(__cplusplus) || defined(c_plusplus)
     48 }    // extern "C"
     49 #endif
     50 
     51 #endif  /* WEBP_ENC_COST_H_ */
     52