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