Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: third_party/libwebp/enc/cost.h

Issue 10832153: libwebp: update snapshot to v0.2.0-rc1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 Google Inc. 1 // Copyright 2011 Google Inc. All Rights Reserved.
2 // 2 //
3 // This code is licensed under the same terms as WebM: 3 // This code is licensed under the same terms as WebM:
4 // Software License Agreement: http://www.webmproject.org/license/software/ 4 // Software License Agreement: http://www.webmproject.org/license/software/
5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/
6 // ----------------------------------------------------------------------------- 6 // -----------------------------------------------------------------------------
7 // 7 //
8 // Cost tables for level and modes. 8 // Cost tables for level and modes.
9 // 9 //
10 // Author: Skal (pascal.massimino@gmail.com) 10 // Author: Skal (pascal.massimino@gmail.com)
11 11
12 #ifndef WEBP_ENC_COST_H_ 12 #ifndef WEBP_ENC_COST_H_
13 #define WEBP_ENC_COST_H_ 13 #define WEBP_ENC_COST_H_
14 14
15 #include "vp8enci.h" 15 #include "./vp8enci.h"
16 16
17 #if defined(__cplusplus) || defined(c_plusplus) 17 #if defined(__cplusplus) || defined(c_plusplus)
18 extern "C" { 18 extern "C" {
19 #endif 19 #endif
20 20
21 extern const uint16_t VP8LevelFixedCosts[2048]; // approximate cost per level 21 extern const uint16_t VP8LevelFixedCosts[2048]; // approximate cost per level
22 extern const uint16_t VP8EntropyCost[256]; // 8bit fixed-point log(p) 22 extern const uint16_t VP8EntropyCost[256]; // 8bit fixed-point log(p)
23 23
24 // Cost of coding one event with probability 'proba'. 24 // Cost of coding one event with probability 'proba'.
25 static inline int VP8BitCost(int bit, uint8_t proba) { 25 static WEBP_INLINE int VP8BitCost(int bit, uint8_t proba) {
26 return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba]; 26 return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba];
27 } 27 }
28 28
29 // Cost of coding 'nb' 1's and 'total-nb' 0's using 'proba' probability. 29 // Cost of coding 'nb' 1's and 'total-nb' 0's using 'proba' probability.
30 static inline uint64_t VP8BranchCost(uint64_t nb, uint64_t total, 30 static WEBP_INLINE uint64_t VP8BranchCost(uint64_t nb, uint64_t total,
31 uint8_t proba) { 31 uint8_t proba) {
32 return nb * VP8BitCost(1, proba) + (total - nb) * VP8BitCost(0, proba); 32 return nb * VP8BitCost(1, proba) + (total - nb) * VP8BitCost(0, proba);
33 } 33 }
34 34
35 // Level cost calculations 35 // Level cost calculations
36 extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2]; 36 extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2];
37 void VP8CalculateLevelCosts(VP8Proba* const proba); 37 void VP8CalculateLevelCosts(VP8Proba* const proba);
38 static inline int VP8LevelCost(const uint16_t* const table, int level) { 38 static WEBP_INLINE int VP8LevelCost(const uint16_t* const table, int level) {
39 return VP8LevelFixedCosts[level] 39 return VP8LevelFixedCosts[level]
40 + table[level > MAX_VARIABLE_LEVEL ? MAX_VARIABLE_LEVEL : level]; 40 + table[level > MAX_VARIABLE_LEVEL ? MAX_VARIABLE_LEVEL : level];
41 } 41 }
42 42
43 // Mode costs 43 // Mode costs
44 extern const uint16_t VP8FixedCostsUV[4]; 44 extern const uint16_t VP8FixedCostsUV[4];
45 extern const uint16_t VP8FixedCostsI16[4]; 45 extern const uint16_t VP8FixedCostsI16[4];
46 extern const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES]; 46 extern const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES];
47 47
48 //------------------------------------------------------------------------------ 48 //------------------------------------------------------------------------------
49 49
50 #if defined(__cplusplus) || defined(c_plusplus) 50 #if defined(__cplusplus) || defined(c_plusplus)
51 } // extern "C" 51 } // extern "C"
52 #endif 52 #endif
53 53
54 #endif /* WEBP_ENC_COST_H_ */ 54 #endif /* WEBP_ENC_COST_H_ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698