Enable Tab Dragging Tests with Linux and Ash
[chromium-blink-merge.git] / third_party / libwebp / enc / cost.h
blob3cbad1ae4c8adf315311116a107d541b7fdab678
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.
12 // Author: Skal (pascal.massimino@gmail.com)
14 #ifndef WEBP_ENC_COST_H_
15 #define WEBP_ENC_COST_H_
17 #include "./vp8enci.h"
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
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)
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];
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];
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];
45 //------------------------------------------------------------------------------
47 #ifdef __cplusplus
48 } // extern "C"
49 #endif
51 #endif /* WEBP_ENC_COST_H_ */