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

Side by Side Diff: source/libvpx/test/util.h

Issue 1339513003: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 3 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 | « source/libvpx/test/test_libvpx.cc ('k') | source/libvpx/test/video_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef TEST_UTIL_H_ 11 #ifndef TEST_UTIL_H_
12 #define TEST_UTIL_H_ 12 #define TEST_UTIL_H_
13 13
14 #include <stdio.h> 14 #include <stdio.h>
15 #include <math.h> 15 #include <math.h>
16 #include "third_party/googletest/src/include/gtest/gtest.h" 16 #include "third_party/googletest/src/include/gtest/gtest.h"
17 #include "vpx/vpx_image.h" 17 #include "vpx/vpx_image.h"
18 18
19 // Macros 19 // Macros
20 #define GET_PARAM(k) std::tr1::get< k >(GetParam()) 20 #define GET_PARAM(k) std::tr1::get< k >(GetParam())
21 21
22 static double compute_psnr(const vpx_image_t *img1, 22 inline double compute_psnr(const vpx_image_t *img1, const vpx_image_t *img2) {
23 const vpx_image_t *img2) {
24 assert((img1->fmt == img2->fmt) && 23 assert((img1->fmt == img2->fmt) &&
25 (img1->d_w == img2->d_w) && 24 (img1->d_w == img2->d_w) &&
26 (img1->d_h == img2->d_h)); 25 (img1->d_h == img2->d_h));
27 26
28 const unsigned int width_y = img1->d_w; 27 const unsigned int width_y = img1->d_w;
29 const unsigned int height_y = img1->d_h; 28 const unsigned int height_y = img1->d_h;
30 unsigned int i, j; 29 unsigned int i, j;
31 30
32 int64_t sqrerr = 0; 31 int64_t sqrerr = 0;
33 for (i = 0; i < height_y; ++i) 32 for (i = 0; i < height_y; ++i)
34 for (j = 0; j < width_y; ++j) { 33 for (j = 0; j < width_y; ++j) {
35 int64_t d = img1->planes[VPX_PLANE_Y][i * img1->stride[VPX_PLANE_Y] + j] - 34 int64_t d = img1->planes[VPX_PLANE_Y][i * img1->stride[VPX_PLANE_Y] + j] -
36 img2->planes[VPX_PLANE_Y][i * img2->stride[VPX_PLANE_Y] + j]; 35 img2->planes[VPX_PLANE_Y][i * img2->stride[VPX_PLANE_Y] + j];
37 sqrerr += d * d; 36 sqrerr += d * d;
38 } 37 }
39 double mse = static_cast<double>(sqrerr) / (width_y * height_y); 38 double mse = static_cast<double>(sqrerr) / (width_y * height_y);
40 double psnr = 100.0; 39 double psnr = 100.0;
41 if (mse > 0.0) { 40 if (mse > 0.0) {
42 psnr = 10 * log10(255.0 * 255.0 / mse); 41 psnr = 10 * log10(255.0 * 255.0 / mse);
43 } 42 }
44 return psnr; 43 return psnr;
45 } 44 }
46 45
47 #endif // TEST_UTIL_H_ 46 #endif // TEST_UTIL_H_
OLDNEW
« no previous file with comments | « source/libvpx/test/test_libvpx.cc ('k') | source/libvpx/test/video_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698