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

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

Issue 2584033003: libwebp-0.5.2-rc2 (Closed)
Patch Set: layout tests Created 3 years, 12 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
OLDNEW
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.
(...skipping 23 matching lines...) Expand all
34 ProbaArray* prob; 34 ProbaArray* prob;
35 StatsArray* stats; 35 StatsArray* stats;
36 CostArrayPtr costs; 36 CostArrayPtr costs;
37 }; 37 };
38 38
39 void VP8InitResidual(int first, int coeff_type, 39 void VP8InitResidual(int first, int coeff_type,
40 VP8Encoder* const enc, VP8Residual* const res); 40 VP8Encoder* const enc, VP8Residual* const res);
41 41
42 int VP8RecordCoeffs(int ctx, const VP8Residual* const res); 42 int VP8RecordCoeffs(int ctx, const VP8Residual* const res);
43 43
44 // Record proba context used.
45 static WEBP_INLINE int VP8RecordStats(int bit, proba_t* const stats) {
46 proba_t p = *stats;
47 // An overflow is inbound. Note we handle this at 0xfffe0000u instead of
48 // 0xffff0000u to make sure p + 1u does not overflow.
49 if (p >= 0xfffe0000u) {
50 p = ((p + 1u) >> 1) & 0x7fff7fffu; // -> divide the stats by 2.
51 }
52 // record bit count (lower 16 bits) and increment total count (upper 16 bits).
53 p += 0x00010000u + bit;
54 *stats = p;
55 return bit;
56 }
57
44 // Cost of coding one event with probability 'proba'. 58 // Cost of coding one event with probability 'proba'.
45 static WEBP_INLINE int VP8BitCost(int bit, uint8_t proba) { 59 static WEBP_INLINE int VP8BitCost(int bit, uint8_t proba) {
46 return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba]; 60 return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba];
47 } 61 }
48 62
49 // Level cost calculations 63 // Level cost calculations
50 extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2]; 64 extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2];
51 void VP8CalculateLevelCosts(VP8EncProba* const proba); 65 void VP8CalculateLevelCosts(VP8EncProba* const proba);
52 static WEBP_INLINE int VP8LevelCost(const uint16_t* const table, int level) { 66 static WEBP_INLINE int VP8LevelCost(const uint16_t* const table, int level) {
53 return VP8LevelFixedCosts[level] 67 return VP8LevelFixedCosts[level]
54 + table[(level > MAX_VARIABLE_LEVEL) ? MAX_VARIABLE_LEVEL : level]; 68 + table[(level > MAX_VARIABLE_LEVEL) ? MAX_VARIABLE_LEVEL : level];
55 } 69 }
56 70
57 // Mode costs 71 // Mode costs
58 extern const uint16_t VP8FixedCostsUV[4]; 72 extern const uint16_t VP8FixedCostsUV[4];
59 extern const uint16_t VP8FixedCostsI16[4]; 73 extern const uint16_t VP8FixedCostsI16[4];
60 extern const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES]; 74 extern const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES];
61 75
62 //------------------------------------------------------------------------------ 76 //------------------------------------------------------------------------------
63 77
64 #ifdef __cplusplus 78 #ifdef __cplusplus
65 } // extern "C" 79 } // extern "C"
66 #endif 80 #endif
67 81
68 #endif /* WEBP_ENC_COST_H_ */ 82 #endif /* WEBP_ENC_COST_H_ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698