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

Side by Side Diff: fuzz/FuzzPaeth.cpp

Issue 1589563002: Add new fuzz binary. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify gyp Created 4 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
« fuzz/Fuzz.h ('K') | « fuzz/Fuzz.h ('k') | fuzz/fuzz.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Fuzz.h"
9
10 // This really is just an example Fuzz*.cpp file.
11 // It tests that two different ways of calculating the Paeth predictor function are equivalent.
12
13 static uint8_t paeth_std(uint8_t a, uint8_t b, uint8_t c) {
14 int p = a+b-c;
15
16 int pa = abs(p-a),
17 pb = abs(p-b),
18 pc = abs(p-c);
19
20 if (pb < pa) { pa = pb; a = b; }
21 if (pc < pa) { a = c; }
22 return a;
23 }
24
25 static uint8_t paeth_alt(uint8_t a, uint8_t b, uint8_t c) {
26 int min = SkTMin(a,b),
27 max = SkTMax(a,b);
28 int delta = (max-min)/3;
29
30 if (c <= min+delta) return max;
31 if (c >= max-delta) return min;
32 return c;
33 }
34
35 DEF_FUZZ(Paeth, fuzz) {
36 int a = fuzz->nextU(),
37 b = fuzz->nextU(),
38 c = fuzz->nextU();
39 ASSERT(paeth_alt(a,b,c) == paeth_std(a,b,c));
40 }
OLDNEW
« fuzz/Fuzz.h ('K') | « fuzz/Fuzz.h ('k') | fuzz/fuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698