mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 08:46:47 +08:00
A compare utility that reports psnr, mse and hash values
BUG=none TEST=none Review URL: https://webrtc-codereview.appspot.com/709005 git-svn-id: http://libyuv.googlecode.com/svn/trunk@312 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
4f45c11aaf
commit
4f10e97ff2
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 311
|
||||
Version: 312
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
64
util/compare.cc
Normal file
64
util/compare.cc
Normal file
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#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<double>(sum_square_err) /
|
||||
static_cast<double>(size_min);
|
||||
printf(", mse %.2f", mse);
|
||||
double psnr = libyuv::SumSquareErrorToPsnr(sum_square_err, size_min);
|
||||
printf(", psnr %.2f\n", psnr);
|
||||
fclose(fin2);
|
||||
}
|
||||
fclose(fin1);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user