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

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

Issue 2651883004: libwebp-0.6.0-rc1 (Closed)
Patch Set: Created 3 years, 11 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/dec_sse41.c ('k') | third_party/libwebp/dsp/enc.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 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 // Speed-critical functions. 10 // Speed-critical functions.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 #define WEBP_TSAN_IGNORE_FUNCTION 104 #define WEBP_TSAN_IGNORE_FUNCTION
105 #if defined(__has_feature) 105 #if defined(__has_feature)
106 #if __has_feature(thread_sanitizer) 106 #if __has_feature(thread_sanitizer)
107 #undef WEBP_TSAN_IGNORE_FUNCTION 107 #undef WEBP_TSAN_IGNORE_FUNCTION
108 #define WEBP_TSAN_IGNORE_FUNCTION __attribute__((no_sanitize_thread)) 108 #define WEBP_TSAN_IGNORE_FUNCTION __attribute__((no_sanitize_thread))
109 #endif 109 #endif
110 #endif 110 #endif
111 111
112 #define WEBP_UBSAN_IGNORE_UNDEF 112 #define WEBP_UBSAN_IGNORE_UNDEF
113 #define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW 113 #define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW
114 #if !defined(WEBP_FORCE_ALIGNED) && defined(__clang__) && \ 114 #if defined(__clang__) && defined(__has_attribute)
115 defined(__has_attribute)
116 #if __has_attribute(no_sanitize) 115 #if __has_attribute(no_sanitize)
117 // This macro prevents the undefined behavior sanitizer from reporting 116 // This macro prevents the undefined behavior sanitizer from reporting
118 // failures. This is only meant to silence unaligned loads on platforms that 117 // failures. This is only meant to silence unaligned loads on platforms that
119 // are known to support them. 118 // are known to support them.
120 #undef WEBP_UBSAN_IGNORE_UNDEF 119 #undef WEBP_UBSAN_IGNORE_UNDEF
121 #define WEBP_UBSAN_IGNORE_UNDEF \ 120 #define WEBP_UBSAN_IGNORE_UNDEF \
122 __attribute__((no_sanitize("undefined"))) 121 __attribute__((no_sanitize("undefined")))
123 122
124 // This macro prevents the undefined behavior sanitizer from reporting 123 // This macro prevents the undefined behavior sanitizer from reporting
125 // failures related to unsigned integer overflows. This is only meant to 124 // failures related to unsigned integer overflows. This is only meant to
126 // silence cases where this well defined behavior is expected. 125 // silence cases where this well defined behavior is expected.
127 #undef WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW 126 #undef WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW
128 #define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW \ 127 #define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW \
129 __attribute__((no_sanitize("unsigned-integer-overflow"))) 128 __attribute__((no_sanitize("unsigned-integer-overflow")))
130 #endif 129 #endif
131 #endif 130 #endif
132 131
133 typedef enum { 132 typedef enum {
134 kSSE2, 133 kSSE2,
135 kSSE3, 134 kSSE3,
135 kSlowSSSE3, // special feature for slow SSSE3 architectures
136 kSSE4_1, 136 kSSE4_1,
137 kAVX, 137 kAVX,
138 kAVX2, 138 kAVX2,
139 kNEON, 139 kNEON,
140 kMIPS32, 140 kMIPS32,
141 kMIPSdspR2, 141 kMIPSdspR2,
142 kMSA 142 kMSA
143 } CPUFeature; 143 } CPUFeature;
144 // returns true if the CPU supports the feature. 144 // returns true if the CPU supports the feature.
145 typedef int (*VP8CPUInfo)(CPUFeature feature); 145 typedef int (*VP8CPUInfo)(CPUFeature feature);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 extern VP8IntraPreds VP8EncPredChroma8; 178 extern VP8IntraPreds VP8EncPredChroma8;
179 179
180 typedef int (*VP8Metric)(const uint8_t* pix, const uint8_t* ref); 180 typedef int (*VP8Metric)(const uint8_t* pix, const uint8_t* ref);
181 extern VP8Metric VP8SSE16x16, VP8SSE16x8, VP8SSE8x8, VP8SSE4x4; 181 extern VP8Metric VP8SSE16x16, VP8SSE16x8, VP8SSE8x8, VP8SSE4x4;
182 typedef int (*VP8WMetric)(const uint8_t* pix, const uint8_t* ref, 182 typedef int (*VP8WMetric)(const uint8_t* pix, const uint8_t* ref,
183 const uint16_t* const weights); 183 const uint16_t* const weights);
184 // The weights for VP8TDisto4x4 and VP8TDisto16x16 contain a row-major 184 // The weights for VP8TDisto4x4 and VP8TDisto16x16 contain a row-major
185 // 4 by 4 symmetric matrix. 185 // 4 by 4 symmetric matrix.
186 extern VP8WMetric VP8TDisto4x4, VP8TDisto16x16; 186 extern VP8WMetric VP8TDisto4x4, VP8TDisto16x16;
187 187
188 // Compute the average (DC) of four 4x4 blocks.
189 // Each sub-4x4 block #i sum is stored in dc[i].
190 typedef void (*VP8MeanMetric)(const uint8_t* ref, uint32_t dc[4]);
191 extern VP8MeanMetric VP8Mean16x4;
192
188 typedef void (*VP8BlockCopy)(const uint8_t* src, uint8_t* dst); 193 typedef void (*VP8BlockCopy)(const uint8_t* src, uint8_t* dst);
189 extern VP8BlockCopy VP8Copy4x4; 194 extern VP8BlockCopy VP8Copy4x4;
190 extern VP8BlockCopy VP8Copy16x8; 195 extern VP8BlockCopy VP8Copy16x8;
191 // Quantization 196 // Quantization
192 struct VP8Matrix; // forward declaration 197 struct VP8Matrix; // forward declaration
193 typedef int (*VP8QuantizeBlock)(int16_t in[16], int16_t out[16], 198 typedef int (*VP8QuantizeBlock)(int16_t in[16], int16_t out[16],
194 const struct VP8Matrix* const mtx); 199 const struct VP8Matrix* const mtx);
195 // Same as VP8QuantizeBlock, but quantizes two consecutive blocks. 200 // Same as VP8QuantizeBlock, but quantizes two consecutive blocks.
196 typedef int (*VP8Quantize2Blocks)(int16_t in[32], int16_t out[32], 201 typedef int (*VP8Quantize2Blocks)(int16_t in[32], int16_t out[32],
197 const struct VP8Matrix* const mtx); 202 const struct VP8Matrix* const mtx);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 244
240 // Cost calculation function. 245 // Cost calculation function.
241 typedef int (*VP8GetResidualCostFunc)(int ctx0, 246 typedef int (*VP8GetResidualCostFunc)(int ctx0,
242 const struct VP8Residual* const res); 247 const struct VP8Residual* const res);
243 extern VP8GetResidualCostFunc VP8GetResidualCost; 248 extern VP8GetResidualCostFunc VP8GetResidualCost;
244 249
245 // must be called before anything using the above 250 // must be called before anything using the above
246 void VP8EncDspCostInit(void); 251 void VP8EncDspCostInit(void);
247 252
248 //------------------------------------------------------------------------------ 253 //------------------------------------------------------------------------------
249 // SSIM utils 254 // SSIM / PSNR utils
250 255
251 // struct for accumulating statistical moments 256 // struct for accumulating statistical moments
252 typedef struct { 257 typedef struct {
253 double w; // sum(w_i) : sum of weights 258 uint32_t w; // sum(w_i) : sum of weights
254 double xm, ym; // sum(w_i * x_i), sum(w_i * y_i) 259 uint32_t xm, ym; // sum(w_i * x_i), sum(w_i * y_i)
255 double xxm, xym, yym; // sum(w_i * x_i * x_i), etc. 260 uint32_t xxm, xym, yym; // sum(w_i * x_i * x_i), etc.
256 } VP8DistoStats; 261 } VP8DistoStats;
257 262
263 // Compute the final SSIM value
264 // The non-clipped version assumes stats->w = (2 * VP8_SSIM_KERNEL + 1)^2.
265 double VP8SSIMFromStats(const VP8DistoStats* const stats);
266 double VP8SSIMFromStatsClipped(const VP8DistoStats* const stats);
267
258 #define VP8_SSIM_KERNEL 3 // total size of the kernel: 2 * VP8_SSIM_KERNEL + 1 268 #define VP8_SSIM_KERNEL 3 // total size of the kernel: 2 * VP8_SSIM_KERNEL + 1
259 typedef void (*VP8SSIMAccumulateClippedFunc)(const uint8_t* src1, int stride1, 269 typedef double (*VP8SSIMGetClippedFunc)(const uint8_t* src1, int stride1,
260 const uint8_t* src2, int stride2, 270 const uint8_t* src2, int stride2,
261 int xo, int yo, // center position 271 int xo, int yo, // center position
262 int W, int H, // plane dimension 272 int W, int H); // plane dimension
263 VP8DistoStats* const stats);
264 273
265 // This version is called with the guarantee that you can load 8 bytes and 274 // This version is called with the guarantee that you can load 8 bytes and
266 // 8 rows at offset src1 and src2 275 // 8 rows at offset src1 and src2
267 typedef void (*VP8SSIMAccumulateFunc)(const uint8_t* src1, int stride1, 276 typedef double (*VP8SSIMGetFunc)(const uint8_t* src1, int stride1,
268 const uint8_t* src2, int stride2, 277 const uint8_t* src2, int stride2);
269 VP8DistoStats* const stats);
270 278
271 extern VP8SSIMAccumulateFunc VP8SSIMAccumulate; // unclipped / unchecked 279 extern VP8SSIMGetFunc VP8SSIMGet; // unclipped / unchecked
272 extern VP8SSIMAccumulateClippedFunc VP8SSIMAccumulateClipped; // with clipping 280 extern VP8SSIMGetClippedFunc VP8SSIMGetClipped; // with clipping
281
282 typedef uint32_t (*VP8AccumulateSSEFunc)(const uint8_t* src1,
283 const uint8_t* src2, int len);
284 extern VP8AccumulateSSEFunc VP8AccumulateSSE;
273 285
274 // must be called before using any of the above directly 286 // must be called before using any of the above directly
275 void VP8SSIMDspInit(void); 287 void VP8SSIMDspInit(void);
276 288
277 //------------------------------------------------------------------------------ 289 //------------------------------------------------------------------------------
278 // Decoding 290 // Decoding
279 291
280 typedef void (*VP8DecIdct)(const int16_t* coeffs, uint8_t* dst); 292 typedef void (*VP8DecIdct)(const int16_t* coeffs, uint8_t* dst);
281 // when doing two transforms, coeffs is actually int16_t[2][16]. 293 // when doing two transforms, coeffs is actually int16_t[2][16].
282 typedef void (*VP8DecIdct2)(const int16_t* coeffs, uint8_t* dst, int do_two); 294 typedef void (*VP8DecIdct2)(const int16_t* coeffs, uint8_t* dst, int do_two);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 // Convert RGB or BGR to Y 421 // Convert RGB or BGR to Y
410 extern void (*WebPConvertRGB24ToY)(const uint8_t* rgb, uint8_t* y, int width); 422 extern void (*WebPConvertRGB24ToY)(const uint8_t* rgb, uint8_t* y, int width);
411 extern void (*WebPConvertBGR24ToY)(const uint8_t* bgr, uint8_t* y, int width); 423 extern void (*WebPConvertBGR24ToY)(const uint8_t* bgr, uint8_t* y, int width);
412 424
413 // used for plain-C fallback. 425 // used for plain-C fallback.
414 extern void WebPConvertARGBToUV_C(const uint32_t* argb, uint8_t* u, uint8_t* v, 426 extern void WebPConvertARGBToUV_C(const uint32_t* argb, uint8_t* u, uint8_t* v,
415 int src_width, int do_store); 427 int src_width, int do_store);
416 extern void WebPConvertRGBA32ToUV_C(const uint16_t* rgb, 428 extern void WebPConvertRGBA32ToUV_C(const uint16_t* rgb,
417 uint8_t* u, uint8_t* v, int width); 429 uint8_t* u, uint8_t* v, int width);
418 430
431 // utilities for accurate RGB->YUV conversion
432 extern uint64_t (*WebPSharpYUVUpdateY)(const uint16_t* src, const uint16_t* ref,
433 uint16_t* dst, int len);
434 extern void (*WebPSharpYUVUpdateRGB)(const int16_t* src, const int16_t* ref,
435 int16_t* dst, int len);
436 extern void (*WebPSharpYUVFilterRow)(const int16_t* A, const int16_t* B,
437 int len,
438 const uint16_t* best_y, uint16_t* out);
439
419 // Must be called before using the above. 440 // Must be called before using the above.
420 void WebPInitConvertARGBToYUV(void); 441 void WebPInitConvertARGBToYUV(void);
421 442
422 //------------------------------------------------------------------------------ 443 //------------------------------------------------------------------------------
423 // Rescaler 444 // Rescaler
424 445
425 struct WebPRescaler; 446 struct WebPRescaler;
426 447
427 // Import a row of data and save its contribution in the rescaler. 448 // Import a row of data and save its contribution in the rescaler.
428 // 'channel' denotes the channel number to be imported. 'Expand' corresponds to 449 // 'channel' denotes the channel number to be imported. 'Expand' corresponds to
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 int width, int height, 502 int width, int height,
482 uint32_t* dst, int dst_stride); 503 uint32_t* dst, int dst_stride);
483 504
484 // Extract the alpha values from 32b values in argb[] and pack them into alpha[] 505 // Extract the alpha values from 32b values in argb[] and pack them into alpha[]
485 // (this is the opposite of WebPDispatchAlpha). 506 // (this is the opposite of WebPDispatchAlpha).
486 // Returns true if there's only trivial 0xff alpha values. 507 // Returns true if there's only trivial 0xff alpha values.
487 extern int (*WebPExtractAlpha)(const uint8_t* argb, int argb_stride, 508 extern int (*WebPExtractAlpha)(const uint8_t* argb, int argb_stride,
488 int width, int height, 509 int width, int height,
489 uint8_t* alpha, int alpha_stride); 510 uint8_t* alpha, int alpha_stride);
490 511
512 // Extract the green values from 32b values in argb[] and pack them into alpha[]
513 // (this is the opposite of WebPDispatchAlphaToGreen).
514 extern void (*WebPExtractGreen)(const uint32_t* argb, uint8_t* alpha, int size);
515
491 // Pre-Multiply operation transforms x into x * A / 255 (where x=Y,R,G or B). 516 // Pre-Multiply operation transforms x into x * A / 255 (where x=Y,R,G or B).
492 // Un-Multiply operation transforms x into x * 255 / A. 517 // Un-Multiply operation transforms x into x * 255 / A.
493 518
494 // Pre-Multiply or Un-Multiply (if 'inverse' is true) argb values in a row. 519 // Pre-Multiply or Un-Multiply (if 'inverse' is true) argb values in a row.
495 extern void (*WebPMultARGBRow)(uint32_t* const ptr, int width, int inverse); 520 extern void (*WebPMultARGBRow)(uint32_t* const ptr, int width, int inverse);
496 521
497 // Same a WebPMultARGBRow(), but for several rows. 522 // Same a WebPMultARGBRow(), but for several rows.
498 void WebPMultARGBRows(uint8_t* ptr, int stride, int width, int num_rows, 523 void WebPMultARGBRows(uint8_t* ptr, int stride, int width, int num_rows,
499 int inverse); 524 int inverse);
500 525
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 extern WebPUnfilterFunc WebPUnfilters[WEBP_FILTER_LAST]; 585 extern WebPUnfilterFunc WebPUnfilters[WEBP_FILTER_LAST];
561 586
562 // To be called first before using the above. 587 // To be called first before using the above.
563 void VP8FiltersInit(void); 588 void VP8FiltersInit(void);
564 589
565 #ifdef __cplusplus 590 #ifdef __cplusplus
566 } // extern "C" 591 } // extern "C"
567 #endif 592 #endif
568 593
569 #endif /* WEBP_DSP_DSP_H_ */ 594 #endif /* WEBP_DSP_DSP_H_ */
OLDNEW
« no previous file with comments | « third_party/libwebp/dsp/dec_sse41.c ('k') | third_party/libwebp/dsp/enc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698