diff --git a/README.chromium b/README.chromium index 1140b59c0..f0763709f 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 311 +Version: 312 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 5080331db..499d6aa5c 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 311 +#define LIBYUV_VERSION 312 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/libyuv_test.gyp b/libyuv_test.gyp index a9bfbbd9f..d368012d7 100644 --- a/libyuv_test.gyp +++ b/libyuv_test.gyp @@ -43,6 +43,26 @@ }], ], # conditions }, + + { + 'target_name': 'compare', + 'type': 'executable', + 'dependencies': [ + 'libyuv.gyp:libyuv', + ], + 'sources': [ + # sources + 'util/compare.cc', + ], + 'conditions': [ + ['OS=="linux"', { + 'cflags': [ + '-fexceptions', + ], + }], + ], # conditions + }, + ], # targets } diff --git a/unit_test/planar_test.cc b/unit_test/planar_test.cc index 7c209cbda..84cfd48a0 100644 --- a/unit_test/planar_test.cc +++ b/unit_test/planar_test.cc @@ -825,10 +825,10 @@ TEST_F(libyuvTest, TestInterpolate) { SIMD_ALIGNED(uint8 orig_pixels_1[256][4]); SIMD_ALIGNED(uint8 interpolate_pixels[256][4]); - orig_pixels_0[0][0] = 10u; - orig_pixels_0[0][1] = 20u; - orig_pixels_0[0][2] = 40u; - orig_pixels_0[0][3] = 80u; + orig_pixels_0[0][0] = 16u; + orig_pixels_0[0][1] = 32u; + orig_pixels_0[0][2] = 64u; + orig_pixels_0[0][3] = 128u; orig_pixels_0[1][0] = 0u; orig_pixels_0[1][1] = 0u; orig_pixels_0[1][2] = 0u; @@ -861,10 +861,10 @@ TEST_F(libyuvTest, TestInterpolate) { ARGBInterpolate(&orig_pixels_0[0][0], 0, &orig_pixels_1[0][0], 0, &interpolate_pixels[0][0], 0, 4, 1, 128); - EXPECT_EQ(5u, interpolate_pixels[0][0]); - EXPECT_EQ(10u, interpolate_pixels[0][1]); - EXPECT_EQ(20u, interpolate_pixels[0][2]); - EXPECT_EQ(40u, interpolate_pixels[0][3]); + EXPECT_EQ(8u, interpolate_pixels[0][0]); + EXPECT_EQ(16u, interpolate_pixels[0][1]); + EXPECT_EQ(32u, interpolate_pixels[0][2]); + EXPECT_EQ(64u, interpolate_pixels[0][3]); EXPECT_EQ(0u, interpolate_pixels[1][0]); EXPECT_EQ(0u, interpolate_pixels[1][1]); EXPECT_EQ(0u, interpolate_pixels[1][2]); @@ -880,11 +880,18 @@ TEST_F(libyuvTest, TestInterpolate) { ARGBInterpolate(&orig_pixels_0[0][0], 0, &orig_pixels_1[0][0], 0, &interpolate_pixels[0][0], 0, 4, 1, 0); + EXPECT_EQ(16u, interpolate_pixels[0][0]); + EXPECT_EQ(32u, interpolate_pixels[0][1]); + EXPECT_EQ(64u, interpolate_pixels[0][2]); + EXPECT_EQ(128u, interpolate_pixels[0][3]); - EXPECT_EQ(10u, interpolate_pixels[0][0]); - EXPECT_EQ(20u, interpolate_pixels[0][1]); - EXPECT_EQ(40u, interpolate_pixels[0][2]); - EXPECT_EQ(80u, interpolate_pixels[0][3]); + ARGBInterpolate(&orig_pixels_0[0][0], 0, &orig_pixels_1[0][0], 0, + &interpolate_pixels[0][0], 0, 4, 1, 192); + + EXPECT_EQ(4u, interpolate_pixels[0][0]); + EXPECT_EQ(8u, interpolate_pixels[0][1]); + EXPECT_EQ(16u, interpolate_pixels[0][2]); + EXPECT_EQ(32u, interpolate_pixels[0][3]); for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { ARGBInterpolate(&orig_pixels_0[0][0], 0, &orig_pixels_1[0][0], 0, diff --git a/util/compare.cc b/util/compare.cc new file mode 100644 index 000000000..968ec3c30 --- /dev/null +++ b/util/compare.cc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2012 The LibYuv project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include +#include +#include +#include + +#include "libyuv/basic_types.h" +#include "libyuv/compare.h" +#include "libyuv/version.h" + +int main(int argc, char** argv) { + if (argc < 1) { + printf("libyuv compare v\n", LIBYUV_VERSION); + printf("compare file1.yuv file2.yuv\n"); + return -1; + } + char* name1 = argv[1]; + char* name2 = (argc > 2) ? argv[2] : NULL; + FILE* fin1 = fopen(name1, "rb"); + FILE* fin2 = name2 ? fopen(name2, "rb") : NULL; + + const int kBlockSize = 32768; + uint8 buf1[kBlockSize]; + uint8 buf2[kBlockSize]; + uint32 hash1 = 5381; + uint32 hash2 = 5381; + uint64 sum_square_err = 0; + uint64 size_min = 0; + int amt1 = 0; + int amt2 = 0; + do { + amt1 = fread(buf1, 1, kBlockSize, fin1); + if (amt1 > 0) hash1 = libyuv::HashDjb2(buf1, amt1, hash1); + if (fin2) { + amt2 = fread(buf2, 1, kBlockSize, fin2); + if (amt2 > 0) hash2 = libyuv::HashDjb2(buf2, amt2, hash2); + int amt_min = (amt1 < amt2) ? amt1 : amt2; + size_min += amt_min; + sum_square_err += libyuv::ComputeSumSquareError(buf1, buf2, amt_min); + } + } while (amt1 > 0 || amt2 > 0); + + printf("hash1 %x", hash1); + if (fin2) { + printf(", hash2 %x", hash1, hash2); + double mse = static_cast(sum_square_err) / + static_cast(size_min); + printf(", mse %.2f", mse); + double psnr = libyuv::SumSquareErrorToPsnr(sum_square_err, size_min); + printf(", psnr %.2f\n", psnr); + fclose(fin2); + } + fclose(fin1); +} +