diff options
author | Dmitry Kovalev <dkovalev@google.com> | 2014-02-26 18:38:26 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@gerrit.golo.chromium.org> | 2014-02-26 18:38:26 -0800 |
commit | e4118e253a0f8c4712039162dcada4a32f531e59 (patch) | |
tree | 70f657ff02e60e22b6d786815ab055133c095c28 /vpx | |
parent | b83b159e0421cf1394fdacf40a5d5fe9279fd986 (diff) | |
parent | 7d5bffc452c1b284463fc5e6b72194f854f88db4 (diff) | |
download | libvpx-e4118e253a0f8c4712039162dcada4a32f531e59.tar.gz libvpx-e4118e253a0f8c4712039162dcada4a32f531e59.tar.bz2 libvpx-e4118e253a0f8c4712039162dcada4a32f531e59.zip |
Merge "Adding vpx_sse_to_psnr() function."
Diffstat (limited to 'vpx')
-rw-r--r-- | vpx/internal/vpx_psnr.h | 34 | ||||
-rw-r--r-- | vpx/src/vpx_psnr.c | 24 | ||||
-rw-r--r-- | vpx/vpx_codec.mk | 2 |
3 files changed, 60 insertions, 0 deletions
diff --git a/vpx/internal/vpx_psnr.h b/vpx/internal/vpx_psnr.h new file mode 100644 index 000000000..07d81bb8d --- /dev/null +++ b/vpx/internal/vpx_psnr.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2014 The WebM 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. + */ + +#ifndef VPX_INTERNAL_VPX_PSNR_H_ +#define VPX_INTERNAL_VPX_PSNR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// TODO(dkovalev) change vpx_sse_to_psnr signature: double -> int64_t + +/*!\brief Converts SSE to PSNR + * + * Converts sum of squared errros (SSE) to peak signal-to-noise ratio (PNSR). + * + * \param[in] samples Number of samples + * \param[in] peak Max sample value + * \param[in] sse Sum of squared errors + */ +double vpx_sse_to_psnr(double samples, double peak, double sse); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // VPX_INTERNAL_VPX_PSNR_H_ diff --git a/vpx/src/vpx_psnr.c b/vpx/src/vpx_psnr.c new file mode 100644 index 000000000..05843acb6 --- /dev/null +++ b/vpx/src/vpx_psnr.c @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2014 The WebM 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 <math.h> + +#include "vpx/internal/vpx_psnr.h" + +#define MAX_PSNR 100.0 + +double vpx_sse_to_psnr(double samples, double peak, double sse) { + if (sse > 0.0) { + const double psnr = 10.0 * log10(samples * peak * peak / sse); + return psnr > MAX_PSNR ? MAX_PSNR : psnr; + } else { + return MAX_PSNR; + } +} diff --git a/vpx/vpx_codec.mk b/vpx/vpx_codec.mk index 111c87e53..98d1d567c 100644 --- a/vpx/vpx_codec.mk +++ b/vpx/vpx_codec.mk @@ -34,8 +34,10 @@ API_SRCS-yes += vpx_decoder.h API_SRCS-yes += src/vpx_encoder.c API_SRCS-yes += vpx_encoder.h API_SRCS-yes += internal/vpx_codec_internal.h +API_SRCS-yes += internal/vpx_psnr.h API_SRCS-yes += src/vpx_codec.c API_SRCS-yes += src/vpx_image.c +API_SRCS-yes += src/vpx_psnr.c API_SRCS-yes += vpx_codec.h API_SRCS-yes += vpx_codec.mk API_SRCS-yes += vpx_frame_buffer.h |