Commit bb72d637 authored by Yaowu Xu's avatar Yaowu Xu

Enable computing PSNRHVS for highbitdepth build

Ported from libvpx/nextgenv2: bb8ca088

Change-Id: I911529bae9c125baf583e992453106190583fdc2
parent beb3ee3f
This diff is collapsed.
......@@ -12,6 +12,7 @@
#ifndef AOM_DSP_SSIM_H_
#define AOM_DSP_SSIM_H_
#define MAX_PSNR 100.0;
#define MAX_SSIM_DB 100.0;
#ifdef __cplusplus
......@@ -79,8 +80,8 @@ double aom_calc_fastssim(const YV12_BUFFER_CONFIG *source,
double *ssim_u, double *ssim_v, uint32_t bit_depth);
double aom_psnrhvs(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest, double *ssim_y,
double *ssim_u, double *ssim_v);
const YV12_BUFFER_CONFIG *dest, double *phvs_y,
double *phvs_u, double *phvs_v, uint32_t bit_depth);
#if CONFIG_AOM_HIGHBITDEPTH
double aom_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source,
......
......@@ -44,8 +44,8 @@
#define ALIGN_POWER_OF_TWO(value, n) \
(((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
#if CONFIG_AOM_HIGHBITDEPTH
#define CONVERT_TO_SHORTPTR(x) ((uint16_t *)(((uintptr_t)x) << 1))
#if CONFIG_AOM_HIGHBITDEPTH
#define CONVERT_TO_BYTEPTR(x) ((uint8_t *)(((uintptr_t)x) >> 1))
#endif // CONFIG_AOM_HIGHBITDEPTH
......
......@@ -4088,14 +4088,9 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
frame_all = aom_calc_fastssim(cpi->Source, cm->frame_to_show, &y, &u,
&v, bit_depth);
adjust_image_stat(y, u, v, frame_all, &cpi->fastssim);
/* TODO(JBB): add 10/12 bit support */
}
#if CONFIG_AOM_HIGHBITDEPTH
if (!cm->use_highbitdepth)
#endif
{
double y, u, v, frame_all;
frame_all = aom_psnrhvs(cpi->Source, cm->frame_to_show, &y, &u, &v);
frame_all =
aom_psnrhvs(cpi->Source, cm->frame_to_show, &y, &u, &v, bit_depth);
adjust_image_stat(y, u, v, frame_all, &cpi->psnrhvs);
}
}
......
......@@ -31,6 +31,18 @@ typedef double (*LBDMetricFunc)(const YV12_BUFFER_CONFIG *source,
typedef double (*HBDMetricFunc)(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest, uint32_t bd);
double compute_hbd_psnrhvs(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest, uint32_t bit_depth) {
double tempy, tempu, tempv;
return aom_psnrhvs(source, dest, &tempy, &tempu, &tempv, bit_depth);
}
double compute_psnrhvs(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest) {
double tempy, tempu, tempv;
return aom_psnrhvs(source, dest, &tempy, &tempu, &tempv, 8);
}
double compute_hbd_fastssim(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest,
uint32_t bit_depth) {
......@@ -97,10 +109,35 @@ class HBDMetricsTestBase {
lbd_db = lbd_metric_(&lbd_src, &lbd_dst);
hbd_db = hbd_metric_(&hbd_src, &hbd_dst, bit_depth_);
EXPECT_LE(fabs(lbd_db - hbd_db), threshold_);
i = 0;
while (i < lbd_src.buffer_alloc_sz) {
uint16_t dpel;
// Create some small distortion for dst buffer.
dpel = 120 + (rnd.Rand8() >> 4);
lbd_dst.buffer_alloc[i] = (uint8_t)dpel;
((uint16_t *)(hbd_dst.buffer_alloc))[i] = dpel << (bit_depth_ - 8);
i++;
}
lbd_db = lbd_metric_(&lbd_src, &lbd_dst);
hbd_db = hbd_metric_(&hbd_src, &hbd_dst, bit_depth_);
EXPECT_LE(fabs(lbd_db - hbd_db), threshold_);
printf("%10f \n", lbd_db);
printf("%10f \n", hbd_db);
i = 0;
while (i < lbd_src.buffer_alloc_sz) {
uint16_t dpel;
// Create some small distortion for dst buffer.
dpel = 126 + (rnd.Rand8() >> 6);
lbd_dst.buffer_alloc[i] = (uint8_t)dpel;
((uint16_t *)(hbd_dst.buffer_alloc))[i] = dpel << (bit_depth_ - 8);
i++;
}
lbd_db = lbd_metric_(&lbd_src, &lbd_dst);
hbd_db = hbd_metric_(&hbd_src, &hbd_dst, bit_depth_);
EXPECT_LE(fabs(lbd_db - hbd_db), threshold_);
aom_free_frame_buffer(&lbd_src);
aom_free_frame_buffer(&lbd_dst);
aom_free_frame_buffer(&hbd_src);
......@@ -133,8 +170,10 @@ TEST_P(HBDMetricsTest, RunAccuracyCheck) { RunAccuracyCheck(); }
// Allow small variation due to floating point operations.
static const double kSsim_thresh = 0.001;
// Allow some variation from accumulated errors in floating point operations.
static const double kFSsim_thresh = 0.01;
// Allow some additional errors accumulated in floating point operations.
static const double kFSsim_thresh = 0.03;
// Allow some extra variation due to rounding error accumulated in dct.
static const double kPhvs_thresh = 0.3;
INSTANTIATE_TEST_CASE_P(
AOMSSIM, HBDMetricsTest,
......@@ -148,4 +187,10 @@ INSTANTIATE_TEST_CASE_P(
10, kFSsim_thresh),
MetricTestTParam(&compute_fastssim, &compute_hbd_fastssim,
12, kFSsim_thresh)));
INSTANTIATE_TEST_CASE_P(
PSNRHVS, HBDMetricsTest,
::testing::Values(MetricTestTParam(&compute_psnrhvs, &compute_hbd_psnrhvs,
10, kPhvs_thresh),
MetricTestTParam(&compute_psnrhvs, &compute_hbd_psnrhvs,
12, kPhvs_thresh)));
} // namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment