From 9fb593d0fce31ae42a521cc901dccbe2043f6186 Mon Sep 17 00:00:00 2001 From: Yaowu Xu Date: Wed, 17 Feb 2016 12:38:54 -0800 Subject: [PATCH] Add tests for Highbitdepth PSNR metric computations Change-Id: I07324155f73bbdbe25bb7a7ccd587ebf9010ac7a --- test/hbd_metrics_test.cc | 22 ++++++++++++++++++++++ vpx_dsp/psnr.c | 3 +-- vpx_dsp/psnr.h | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/test/hbd_metrics_test.cc b/test/hbd_metrics_test.cc index bf75a2912..dac001f5a 100644 --- a/test/hbd_metrics_test.cc +++ b/test/hbd_metrics_test.cc @@ -16,6 +16,7 @@ #include "test/acm_random.h" #include "test/util.h" #include "./vpx_config.h" +#include "vpx_dsp/psnr.h" #include "vpx_dsp/ssim.h" #include "vpx_ports/mem.h" #include "vpx_ports/msvc.h" @@ -32,6 +33,19 @@ typedef double (*HBDMetricFunc)(const YV12_BUFFER_CONFIG *source, const YV12_BUFFER_CONFIG *dest, uint32_t bd); +double compute_hbd_psnr(const YV12_BUFFER_CONFIG *source, + const YV12_BUFFER_CONFIG *dest, uint32_t bit_depth) { + PSNR_STATS psnr; + calc_highbd_psnr(source, dest, &psnr, bit_depth, bit_depth); + return psnr.psnr[0]; +} + +double compute_psnr(const YV12_BUFFER_CONFIG *source, + const YV12_BUFFER_CONFIG *dest) { + PSNR_STATS psnr; + calc_psnr(source, dest, &psnr); + return psnr.psnr[0]; +} double compute_hbd_psnrhvs(const YV12_BUFFER_CONFIG *source, const YV12_BUFFER_CONFIG *dest, @@ -208,5 +222,13 @@ INSTANTIATE_TEST_CASE_P( MetricTestTParam(&compute_psnrhvs, &compute_hbd_psnrhvs, 12, kPhvs_thresh))); +INSTANTIATE_TEST_CASE_P( + PSNR, HBDMetricsTest, + ::testing::Values( + MetricTestTParam(&compute_psnr, &compute_hbd_psnr, 10, + kPhvs_thresh), + MetricTestTParam(&compute_psnr, &compute_hbd_psnr, 12, + kPhvs_thresh))); + } // namespace diff --git a/vpx_dsp/psnr.c b/vpx_dsp/psnr.c index ee803f6ac..1b92e2ab4 100644 --- a/vpx_dsp/psnr.c +++ b/vpx_dsp/psnr.c @@ -258,7 +258,7 @@ void calc_highbd_psnr(const YV12_BUFFER_CONFIG *a, (double)total_sse); } -#else // !CONFIG_VP9_HIGHBITDEPTH +#endif // !CONFIG_VP9_HIGHBITDEPTH void calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr) { @@ -295,4 +295,3 @@ void calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b, psnr->psnr[0] = vpx_sse_to_psnr((double)total_samples, peak, (double)total_sse); } -#endif // CONFIG_VP9_HIGHBITDEPTH diff --git a/vpx_dsp/psnr.h b/vpx_dsp/psnr.h index e58eb3de0..c8da94f8f 100644 --- a/vpx_dsp/psnr.h +++ b/vpx_dsp/psnr.h @@ -51,11 +51,11 @@ int64_t highbd_get_sse_shift(const uint8_t *a8, int a_stride, const uint8_t *b8, int b_stride, int width, int height, unsigned int input_shift); -#else +#endif void calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr); -#endif + int64_t highbd_get_sse(const uint8_t *a, int a_stride, const uint8_t *b, int b_stride, int width, int height); -- 2.40.0