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

Side by Side Diff: third_party/libwebp/dsp/lossless.h

Issue 2149863002: libwebp: update to v0.5.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « third_party/libwebp/dsp/filters_sse2.c ('k') | third_party/libwebp/dsp/lossless.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 Google Inc. All Rights Reserved. 1 // Copyright 2012 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 // Image transforms and color space conversion methods for lossless decoder. 10 // Image transforms and color space conversion methods for lossless decoder.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void VP8LCollectColorBlueTransforms_C(const uint32_t* argb, int stride, 151 void VP8LCollectColorBlueTransforms_C(const uint32_t* argb, int stride,
152 int tile_width, int tile_height, 152 int tile_width, int tile_height,
153 int green_to_blue, int red_to_blue, 153 int green_to_blue, int red_to_blue,
154 int histo[]); 154 int histo[]);
155 155
156 //------------------------------------------------------------------------------ 156 //------------------------------------------------------------------------------
157 // Image transforms. 157 // Image transforms.
158 158
159 void VP8LResidualImage(int width, int height, int bits, int low_effort, 159 void VP8LResidualImage(int width, int height, int bits, int low_effort,
160 uint32_t* const argb, uint32_t* const argb_scratch, 160 uint32_t* const argb, uint32_t* const argb_scratch,
161 uint32_t* const image, int exact); 161 uint32_t* const image, int near_lossless, int exact,
162 int used_subtract_green);
162 163
163 void VP8LColorSpaceTransform(int width, int height, int bits, int quality, 164 void VP8LColorSpaceTransform(int width, int height, int bits, int quality,
164 uint32_t* const argb, uint32_t* image); 165 uint32_t* const argb, uint32_t* image);
165 166
166 //------------------------------------------------------------------------------ 167 //------------------------------------------------------------------------------
167 // Misc methods. 168 // Misc methods.
168 169
169 // Computes sampled size of 'size' when sampling using 'sampling bits'. 170 // Computes sampled size of 'size' when sampling using 'sampling bits'.
170 static WEBP_INLINE uint32_t VP8LSubSampleSize(uint32_t size, 171 static WEBP_INLINE uint32_t VP8LSubSampleSize(uint32_t size,
171 uint32_t sampling_bits) { 172 uint32_t sampling_bits) {
172 return (size + (1 << sampling_bits) - 1) >> sampling_bits; 173 return (size + (1 << sampling_bits) - 1) >> sampling_bits;
173 } 174 }
174 175
176 // Converts near lossless quality into max number of bits shaved off.
177 static WEBP_INLINE int VP8LNearLosslessBits(int near_lossless_quality) {
178 // 100 -> 0
179 // 80..99 -> 1
180 // 60..79 -> 2
181 // 40..59 -> 3
182 // 20..39 -> 4
183 // 0..19 -> 5
184 return 5 - near_lossless_quality / 20;
185 }
186
175 // ----------------------------------------------------------------------------- 187 // -----------------------------------------------------------------------------
176 // Faster logarithm for integers. Small values use a look-up table. 188 // Faster logarithm for integers. Small values use a look-up table.
177 189
178 // The threshold till approximate version of log_2 can be used. 190 // The threshold till approximate version of log_2 can be used.
179 // Practically, we can get rid of the call to log() as the two values match to 191 // Practically, we can get rid of the call to log() as the two values match to
180 // very high degree (the ratio of these two is 0.99999x). 192 // very high degree (the ratio of these two is 0.99999x).
181 // Keeping a high threshold for now. 193 // Keeping a high threshold for now.
182 #define APPROX_LOG_WITH_CORRECTION_MAX 65536 194 #define APPROX_LOG_WITH_CORRECTION_MAX 65536
183 #define APPROX_LOG_MAX 4096 195 #define APPROX_LOG_MAX 4096
184 #define LOG_2_RECIPROCAL 1.44269504088896338700465094007086 196 #define LOG_2_RECIPROCAL 1.44269504088896338700465094007086
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 extern GetEntropyUnrefinedHelperFunc VP8LGetEntropyUnrefinedHelper; 267 extern GetEntropyUnrefinedHelperFunc VP8LGetEntropyUnrefinedHelper;
256 268
257 typedef void (*VP8LHistogramAddFunc)(const VP8LHistogram* const a, 269 typedef void (*VP8LHistogramAddFunc)(const VP8LHistogram* const a,
258 const VP8LHistogram* const b, 270 const VP8LHistogram* const b,
259 VP8LHistogram* const out); 271 VP8LHistogram* const out);
260 extern VP8LHistogramAddFunc VP8LHistogramAdd; 272 extern VP8LHistogramAddFunc VP8LHistogramAdd;
261 273
262 // ----------------------------------------------------------------------------- 274 // -----------------------------------------------------------------------------
263 // PrefixEncode() 275 // PrefixEncode()
264 276
277 typedef int (*VP8LVectorMismatchFunc)(const uint32_t* const array1,
278 const uint32_t* const array2, int length);
279 // Returns the first index where array1 and array2 are different.
280 extern VP8LVectorMismatchFunc VP8LVectorMismatch;
281
265 static WEBP_INLINE int VP8LBitsLog2Ceiling(uint32_t n) { 282 static WEBP_INLINE int VP8LBitsLog2Ceiling(uint32_t n) {
266 const int log_floor = BitsLog2Floor(n); 283 const int log_floor = BitsLog2Floor(n);
267 if (n == (n & ~(n - 1))) // zero or a power of two. 284 if (n == (n & ~(n - 1))) // zero or a power of two.
268 return log_floor; 285 return log_floor;
269 else 286 else
270 return log_floor + 1; 287 return log_floor + 1;
271 } 288 }
272 289
273 // Splitting of distance and length codes into prefixes and 290 // Splitting of distance and length codes into prefixes and
274 // extra bits. The prefixes are encoded with an entropy code 291 // extra bits. The prefixes are encoded with an entropy code
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (distance < PREFIX_LOOKUP_IDX_MAX) { 334 if (distance < PREFIX_LOOKUP_IDX_MAX) {
318 const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance]; 335 const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance];
319 *code = prefix_code.code_; 336 *code = prefix_code.code_;
320 *extra_bits = prefix_code.extra_bits_; 337 *extra_bits = prefix_code.extra_bits_;
321 *extra_bits_value = kPrefixEncodeExtraBitsValue[distance]; 338 *extra_bits_value = kPrefixEncodeExtraBitsValue[distance];
322 } else { 339 } else {
323 VP8LPrefixEncodeNoLUT(distance, code, extra_bits, extra_bits_value); 340 VP8LPrefixEncodeNoLUT(distance, code, extra_bits, extra_bits_value);
324 } 341 }
325 } 342 }
326 343
327 // In-place difference of each component with mod 256. 344 // Sum of each component, mod 256.
345 static WEBP_INLINE uint32_t VP8LAddPixels(uint32_t a, uint32_t b) {
346 const uint32_t alpha_and_green = (a & 0xff00ff00u) + (b & 0xff00ff00u);
347 const uint32_t red_and_blue = (a & 0x00ff00ffu) + (b & 0x00ff00ffu);
348 return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
349 }
350
351 // Difference of each component, mod 256.
328 static WEBP_INLINE uint32_t VP8LSubPixels(uint32_t a, uint32_t b) { 352 static WEBP_INLINE uint32_t VP8LSubPixels(uint32_t a, uint32_t b) {
329 const uint32_t alpha_and_green = 353 const uint32_t alpha_and_green =
330 0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u); 354 0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u);
331 const uint32_t red_and_blue = 355 const uint32_t red_and_blue =
332 0xff00ff00u + (a & 0x00ff00ffu) - (b & 0x00ff00ffu); 356 0xff00ff00u + (a & 0x00ff00ffu) - (b & 0x00ff00ffu);
333 return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); 357 return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
334 } 358 }
335 359
336 void VP8LBundleColorMap(const uint8_t* const row, int width, 360 void VP8LBundleColorMap(const uint8_t* const row, int width,
337 int xbits, uint32_t* const dst); 361 int xbits, uint32_t* const dst);
338 362
339 // Must be called before calling any of the above methods. 363 // Must be called before calling any of the above methods.
340 void VP8LEncDspInit(void); 364 void VP8LEncDspInit(void);
341 365
342 //------------------------------------------------------------------------------ 366 //------------------------------------------------------------------------------
343 367
344 #ifdef __cplusplus 368 #ifdef __cplusplus
345 } // extern "C" 369 } // extern "C"
346 #endif 370 #endif
347 371
348 #endif // WEBP_DSP_LOSSLESS_H_ 372 #endif // WEBP_DSP_LOSSLESS_H_
OLDNEW
« no previous file with comments | « third_party/libwebp/dsp/filters_sse2.c ('k') | third_party/libwebp/dsp/lossless.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698