1 /*
2  *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS. All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef INCLUDE_LIBYUV_COMPARE_H_
12 #define INCLUDE_LIBYUV_COMPARE_H_
13 
14 #include "libyuv/basic_types.h"
15 
16 #ifdef __cplusplus
17 namespace libyuv {
18 extern "C" {
19 #endif
20 
21 // Compute a hash for specified memory. Seed of 5381 recommended.
22 LIBYUV_API
23 uint32_t HashDjb2(const uint8_t* src, uint64_t count, uint32_t seed);
24 
25 // Hamming Distance
26 LIBYUV_API
27 uint64_t ComputeHammingDistance(const uint8_t* src_a,
28                                 const uint8_t* src_b,
29                                 int count);
30 
31 // Scan an opaque argb image and return fourcc based on alpha offset.
32 // Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown.
33 LIBYUV_API
34 uint32_t ARGBDetect(const uint8_t* argb,
35                     int stride_argb,
36                     int width,
37                     int height);
38 
39 // Sum Square Error - used to compute Mean Square Error or PSNR.
40 LIBYUV_API
41 uint64_t ComputeSumSquareError(const uint8_t* src_a,
42                                const uint8_t* src_b,
43                                int count);
44 
45 LIBYUV_API
46 uint64_t ComputeSumSquareErrorPlane(const uint8_t* src_a,
47                                     int stride_a,
48                                     const uint8_t* src_b,
49                                     int stride_b,
50                                     int width,
51                                     int height);
52 
53 static const int kMaxPsnr = 128;
54 
55 LIBYUV_API
56 double SumSquareErrorToPsnr(uint64_t sse, uint64_t count);
57 
58 LIBYUV_API
59 double CalcFramePsnr(const uint8_t* src_a,
60                      int stride_a,
61                      const uint8_t* src_b,
62                      int stride_b,
63                      int width,
64                      int height);
65 
66 LIBYUV_API
67 double I420Psnr(const uint8_t* src_y_a,
68                 int stride_y_a,
69                 const uint8_t* src_u_a,
70                 int stride_u_a,
71                 const uint8_t* src_v_a,
72                 int stride_v_a,
73                 const uint8_t* src_y_b,
74                 int stride_y_b,
75                 const uint8_t* src_u_b,
76                 int stride_u_b,
77                 const uint8_t* src_v_b,
78                 int stride_v_b,
79                 int width,
80                 int height);
81 
82 LIBYUV_API
83 double CalcFrameSsim(const uint8_t* src_a,
84                      int stride_a,
85                      const uint8_t* src_b,
86                      int stride_b,
87                      int width,
88                      int height);
89 
90 LIBYUV_API
91 double I420Ssim(const uint8_t* src_y_a,
92                 int stride_y_a,
93                 const uint8_t* src_u_a,
94                 int stride_u_a,
95                 const uint8_t* src_v_a,
96                 int stride_v_a,
97                 const uint8_t* src_y_b,
98                 int stride_y_b,
99                 const uint8_t* src_u_b,
100                 int stride_u_b,
101                 const uint8_t* src_v_b,
102                 int stride_v_b,
103                 int width,
104                 int height);
105 
106 #ifdef __cplusplus
107 }  // extern "C"
108 }  // namespace libyuv
109 #endif
110 
111 #endif  // INCLUDE_LIBYUV_COMPARE_H_
112