OLD | NEW |
1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 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 // Author: Jyrki Alakuijala (jyrki@google.com) | 8 // Author: Jyrki Alakuijala (jyrki@google.com) |
9 // | 9 // |
10 // Models the histograms of literal and distance codes. | 10 // Models the histograms of literal and distance codes. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 const PixOrCopy* const v); | 73 const PixOrCopy* const v); |
74 | 74 |
75 // Estimate how many bits the combined entropy of literals and distance | 75 // Estimate how many bits the combined entropy of literals and distance |
76 // approximately maps to. | 76 // approximately maps to. |
77 double VP8LHistogramEstimateBits(const VP8LHistogram* const p); | 77 double VP8LHistogramEstimateBits(const VP8LHistogram* const p); |
78 | 78 |
79 // This function estimates the cost in bits excluding the bits needed to | 79 // This function estimates the cost in bits excluding the bits needed to |
80 // represent the entropy code itself. | 80 // represent the entropy code itself. |
81 double VP8LHistogramEstimateBitsBulk(const VP8LHistogram* const p); | 81 double VP8LHistogramEstimateBitsBulk(const VP8LHistogram* const p); |
82 | 82 |
83 static WEBP_INLINE void VP8LHistogramAdd(VP8LHistogram* const p, | |
84 const VP8LHistogram* const a) { | |
85 int i; | |
86 for (i = 0; i < PIX_OR_COPY_CODES_MAX; ++i) { | |
87 p->literal_[i] += a->literal_[i]; | |
88 } | |
89 for (i = 0; i < NUM_DISTANCE_CODES; ++i) { | |
90 p->distance_[i] += a->distance_[i]; | |
91 } | |
92 for (i = 0; i < 256; ++i) { | |
93 p->red_[i] += a->red_[i]; | |
94 p->blue_[i] += a->blue_[i]; | |
95 p->alpha_[i] += a->alpha_[i]; | |
96 } | |
97 } | |
98 | |
99 static WEBP_INLINE int VP8LHistogramNumCodes(const VP8LHistogram* const p) { | 83 static WEBP_INLINE int VP8LHistogramNumCodes(const VP8LHistogram* const p) { |
100 return 256 + NUM_LENGTH_CODES + | 84 return 256 + NUM_LENGTH_CODES + |
101 ((p->palette_code_bits_ > 0) ? (1 << p->palette_code_bits_) : 0); | 85 ((p->palette_code_bits_ > 0) ? (1 << p->palette_code_bits_) : 0); |
102 } | 86 } |
103 | 87 |
104 // Builds the histogram image. | 88 // Builds the histogram image. |
105 int VP8LGetHistoImageSymbols(int xsize, int ysize, | 89 int VP8LGetHistoImageSymbols(int xsize, int ysize, |
106 const VP8LBackwardRefs* const refs, | 90 const VP8LBackwardRefs* const refs, |
107 int quality, int histogram_bits, int cache_bits, | 91 int quality, int histogram_bits, int cache_bits, |
108 VP8LHistogramSet* const image_in, | 92 VP8LHistogramSet* const image_in, |
109 uint16_t* const histogram_symbols); | 93 uint16_t* const histogram_symbols); |
110 | 94 |
111 #if defined(__cplusplus) || defined(c_plusplus) | 95 #if defined(__cplusplus) || defined(c_plusplus) |
112 } | 96 } |
113 #endif | 97 #endif |
114 | 98 |
115 #endif // WEBP_ENC_HISTOGRAM_H_ | 99 #endif // WEBP_ENC_HISTOGRAM_H_ |
OLD | NEW |