mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-08 01:36:47 +08:00
jpeg psnr avoid duplicates with libyuv by checking HAVE_JPEG
BUG=339 TESTED=local psnr test R=harryjin@google.com Review URL: https://webrtc-codereview.appspot.com/15949004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@1023 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
44e049b307
commit
b7d674e305
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 1022
|
||||
Version: 1023
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 1022
|
||||
#define LIBYUV_VERSION 1023
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
||||
|
||||
13
util/psnr.cc
13
util/psnr.cc
@ -32,6 +32,9 @@ typedef unsigned long long uint64; // NOLINT
|
||||
#endif // __LP64__
|
||||
#endif // _MSC_VER
|
||||
|
||||
// libyuv provides this function when linking library for jpeg support.
|
||||
#if !defined(HAVE_JPEG)
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_NEON) && defined(__ARM_NEON__)
|
||||
#define HAS_SUMSQUAREERROR_NEON
|
||||
static uint32 SumSquareError_NEON(const uint8* src_a,
|
||||
@ -231,6 +234,16 @@ double ComputeSumSquareError(const uint8* src_a,
|
||||
}
|
||||
return static_cast<double>(sse);
|
||||
}
|
||||
#endif
|
||||
|
||||
// PSNR formula: psnr = 10 * log10 (Peak Signal^2 * size / sse)
|
||||
// Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match).
|
||||
double ComputePSNR(double sse, double size) {
|
||||
const double kMINSSE = 255.0 * 255.0 * size / pow(10.0, kMaxPSNR / 10.0);
|
||||
if (sse <= kMINSSE)
|
||||
sse = kMINSSE; // Produces max PSNR of 128
|
||||
return 10.0 * log10(255.0 * 255.0 * size / sse);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
16
util/psnr.h
16
util/psnr.h
@ -26,19 +26,17 @@ typedef unsigned char uint8;
|
||||
|
||||
static const double kMaxPSNR = 128.0;
|
||||
|
||||
// PSNR formula: psnr = 10 * log10 (Peak Signal^2 * size / sse)
|
||||
// Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match).
|
||||
static double ComputePSNR(double sse, double size) {
|
||||
const double kMINSSE = 255.0 * 255.0 * size / pow(10.0, kMaxPSNR / 10.0);
|
||||
if (sse <= kMINSSE)
|
||||
sse = kMINSSE; // Produces max PSNR of 128
|
||||
return 10.0 * log10(255.0 * 255.0 * size / sse);
|
||||
}
|
||||
|
||||
// libyuv provides this function when linking library for jpeg support.
|
||||
// TODO(fbarchard): make psnr lib compatible subset of libyuv.
|
||||
#if !defined(HAVE_JPEG)
|
||||
// Computer Sum of Squared Error (SSE).
|
||||
// Pass this to ComputePSNR for final result.
|
||||
double ComputeSumSquareError(const uint8* org, const uint8* rec, int size);
|
||||
#endif
|
||||
|
||||
// PSNR formula: psnr = 10 * log10 (Peak Signal^2 * size / sse)
|
||||
// Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match).
|
||||
double ComputePSNR(double sse, double size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
#include "./psnr.h"
|
||||
#include "./ssim.h"
|
||||
#ifdef HAVE_JPEG
|
||||
#include "libyuv/compare.h"
|
||||
#include "libyuv/convert.h"
|
||||
#endif
|
||||
|
||||
@ -241,9 +242,15 @@ bool UpdateMetrics(uint8* ch_org, uint8* ch_rec,
|
||||
const uint8* const v_org = ch_org + y_size + (uv_size - uv_offset);
|
||||
const uint8* const v_rec = ch_rec + y_size + uv_size;
|
||||
if (do_psnr) {
|
||||
#ifdef HAVE_JPEG
|
||||
double y_err = (double)libyuv::ComputeSumSquareError(ch_org, ch_rec, y_size);
|
||||
double u_err = (double)libyuv::ComputeSumSquareError(u_org, u_rec, uv_size);
|
||||
double v_err = (double)libyuv::ComputeSumSquareError(v_org, v_rec, uv_size);
|
||||
#else
|
||||
double y_err = ComputeSumSquareError(ch_org, ch_rec, y_size);
|
||||
double u_err = ComputeSumSquareError(u_org, u_rec, uv_size);
|
||||
double v_err = ComputeSumSquareError(v_org, v_rec, uv_size);
|
||||
#endif
|
||||
const double total_err = y_err + u_err + v_err;
|
||||
cur_distortion_psnr->global_y += y_err;
|
||||
cur_distortion_psnr->global_u += u_err;
|
||||
|
||||
@ -326,6 +326,10 @@ double CalcSSIM(const uint8 *org, const uint8 *rec,
|
||||
return SSIM;
|
||||
}
|
||||
|
||||
double CalcLSSIM(double ssim) {
|
||||
return -10.0 * log10(1.0 - ssim);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
@ -27,9 +27,7 @@ typedef unsigned char uint8;
|
||||
double CalcSSIM(const uint8* org, const uint8* rec,
|
||||
const int image_width, const int image_height);
|
||||
|
||||
static double CalcLSSIM(double ssim) {
|
||||
return -10.0 * log10(1.0 - ssim);
|
||||
}
|
||||
double CalcLSSIM(double ssim);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user