2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
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.
16 #include "third_party/googletest/src/include/gtest/gtest.h"
17 #include "vpx/vpx_image.h"
20 #define GET_PARAM(k) std::tr1::get< k >(GetParam())
22 inline double compute_psnr(const vpx_image_t
*img1
, const vpx_image_t
*img2
) {
23 assert((img1
->fmt
== img2
->fmt
) &&
24 (img1
->d_w
== img2
->d_w
) &&
25 (img1
->d_h
== img2
->d_h
));
27 const unsigned int width_y
= img1
->d_w
;
28 const unsigned int height_y
= img1
->d_h
;
32 for (i
= 0; i
< height_y
; ++i
)
33 for (j
= 0; j
< width_y
; ++j
) {
34 int64_t d
= img1
->planes
[VPX_PLANE_Y
][i
* img1
->stride
[VPX_PLANE_Y
] + j
] -
35 img2
->planes
[VPX_PLANE_Y
][i
* img2
->stride
[VPX_PLANE_Y
] + j
];
38 double mse
= static_cast<double>(sqrerr
) / (width_y
* height_y
);
41 psnr
= 10 * log10(255.0 * 255.0 / mse
);
46 #endif // TEST_UTIL_H_