Commit 9bce2f76 authored by Yaowu Xu's avatar Yaowu Xu Committed by Gerrit Code Review

Merge "Extend HBDMetricTest" into nextgenv2

parents 404c5127 f6a7b17a
......@@ -31,12 +31,13 @@ typedef double (*LBDMetricFunc)(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest);
typedef double (*HBDMetricFunc)(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest,
uint32_t bd);
uint32_t in_bd, uint32_t bd);
double compute_hbd_psnr(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest, uint32_t bit_depth) {
const YV12_BUFFER_CONFIG *dest,
uint32_t in_bd, uint32_t bd) {
PSNR_STATS psnr;
calc_highbd_psnr(source, dest, &psnr, bit_depth, bit_depth);
calc_highbd_psnr(source, dest, &psnr, bd, in_bd);
return psnr.psnr[0];
}
......@@ -48,11 +49,11 @@ double compute_psnr(const YV12_BUFFER_CONFIG *source,
}
double compute_hbd_psnrhvs(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest,
uint32_t bit_depth) {
const YV12_BUFFER_CONFIG *dest,
uint32_t in_bd, uint32_t bd) {
double tempy, tempu, tempv;
return vpx_psnrhvs(source, dest,
&tempy, &tempu, &tempv, bit_depth);
&tempy, &tempu, &tempv, bd);
}
double compute_psnrhvs(const YV12_BUFFER_CONFIG *source,
......@@ -64,10 +65,10 @@ double compute_psnrhvs(const YV12_BUFFER_CONFIG *source,
double compute_hbd_fastssim(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest,
uint32_t bit_depth) {
uint32_t in_bd, uint32_t bd) {
double tempy, tempu, tempv;
return vpx_calc_fastssim(source, dest,
&tempy, &tempu, &tempv, bit_depth);
&tempy, &tempu, &tempv, bd);
}
double compute_fastssim(const YV12_BUFFER_CONFIG *source,
......@@ -79,9 +80,9 @@ double compute_fastssim(const YV12_BUFFER_CONFIG *source,
double compute_hbd_vpxssim(const YV12_BUFFER_CONFIG *source,
const YV12_BUFFER_CONFIG *dest,
uint32_t bit_depth) {
uint32_t in_bd, uint32_t bd) {
double ssim, weight;
ssim = vpx_highbd_calc_ssim(source, dest, &weight, bit_depth);
ssim = vpx_highbd_calc_ssim(source, dest, &weight, bd);
return 100 * pow(ssim / weight, 8.0);
}
......@@ -131,7 +132,7 @@ class HBDMetricsTestBase {
}
lbd_db = lbd_metric_(&lbd_src, &lbd_dst);
hbd_db = hbd_metric_(&hbd_src, &hbd_dst, bit_depth_);
hbd_db = hbd_metric_(&hbd_src, &hbd_dst, input_bit_depth_, bit_depth_);
EXPECT_LE(fabs(lbd_db - hbd_db), threshold_);
i = 0;
......@@ -145,7 +146,7 @@ class HBDMetricsTestBase {
}
lbd_db = lbd_metric_(&lbd_src, &lbd_dst);
hbd_db = hbd_metric_(&hbd_src, &hbd_dst, bit_depth_);
hbd_db = hbd_metric_(&hbd_src, &hbd_dst, input_bit_depth_, bit_depth_);
EXPECT_LE(fabs(lbd_db - hbd_db), threshold_);
i = 0;
......@@ -159,7 +160,7 @@ class HBDMetricsTestBase {
}
lbd_db = lbd_metric_(&lbd_src, &lbd_dst);
hbd_db = hbd_metric_(&hbd_src, &hbd_dst, bit_depth_);
hbd_db = hbd_metric_(&hbd_src, &hbd_dst, input_bit_depth_, bit_depth_);
EXPECT_LE(fabs(lbd_db - hbd_db), threshold_);
vpx_free_frame_buffer(&lbd_src);
......@@ -168,6 +169,7 @@ class HBDMetricsTestBase {
vpx_free_frame_buffer(&hbd_dst);
}
int input_bit_depth_;
int bit_depth_;
double threshold_;
LBDMetricFunc lbd_metric_;
......@@ -175,7 +177,7 @@ class HBDMetricsTestBase {
};
typedef std::tr1::tuple<LBDMetricFunc,
HBDMetricFunc, int, double> MetricTestTParam;
HBDMetricFunc, int, int, double> MetricTestTParam;
class HBDMetricsTest
: public HBDMetricsTestBase,
public ::testing::TestWithParam<MetricTestTParam> {
......@@ -183,8 +185,9 @@ class HBDMetricsTest
virtual void SetUp() {
lbd_metric_ = GET_PARAM(0);
hbd_metric_ = GET_PARAM(1);
bit_depth_ = GET_PARAM(2);
threshold_ = GET_PARAM(3);
input_bit_depth_ = GET_PARAM(2);
bit_depth_ = GET_PARAM(3);
threshold_ = GET_PARAM(4);
}
virtual void TearDown() {}
};
......@@ -203,32 +206,46 @@ static const double kPhvs_thresh = 0.3;
INSTANTIATE_TEST_CASE_P(
VPXSSIM, HBDMetricsTest,
::testing::Values(
MetricTestTParam(&compute_vpxssim, &compute_hbd_vpxssim, 10,
MetricTestTParam(&compute_vpxssim, &compute_hbd_vpxssim, 8, 10,
kSsim_thresh),
MetricTestTParam(&compute_vpxssim, &compute_hbd_vpxssim, 10, 10,
kSsim_thresh),
MetricTestTParam(&compute_vpxssim, &compute_hbd_vpxssim, 8, 12,
kSsim_thresh),
MetricTestTParam(&compute_vpxssim, &compute_hbd_vpxssim, 12,
MetricTestTParam(&compute_vpxssim, &compute_hbd_vpxssim, 12, 12,
kSsim_thresh)));
INSTANTIATE_TEST_CASE_P(
FASTSSIM, HBDMetricsTest,
::testing::Values(
MetricTestTParam(&compute_fastssim, &compute_hbd_fastssim, 10,
MetricTestTParam(&compute_fastssim, &compute_hbd_fastssim, 8, 10,
kFSsim_thresh),
MetricTestTParam(&compute_fastssim, &compute_hbd_fastssim, 12,
MetricTestTParam(&compute_fastssim, &compute_hbd_fastssim, 10, 10,
kFSsim_thresh),
MetricTestTParam(&compute_fastssim, &compute_hbd_fastssim, 8, 12,
kFSsim_thresh),
MetricTestTParam(&compute_fastssim, &compute_hbd_fastssim, 12, 12,
kFSsim_thresh)));
INSTANTIATE_TEST_CASE_P(
PSNRHVS, HBDMetricsTest,
::testing::Values(
MetricTestTParam(&compute_psnrhvs, &compute_hbd_psnrhvs, 10,
MetricTestTParam(&compute_psnrhvs, &compute_hbd_psnrhvs, 8, 10,
kPhvs_thresh),
MetricTestTParam(&compute_psnrhvs, &compute_hbd_psnrhvs, 10, 10,
kPhvs_thresh),
MetricTestTParam(&compute_psnrhvs, &compute_hbd_psnrhvs, 12,
MetricTestTParam(&compute_psnrhvs, &compute_hbd_psnrhvs, 8, 12,
kPhvs_thresh),
MetricTestTParam(&compute_psnrhvs, &compute_hbd_psnrhvs, 12, 12,
kPhvs_thresh)));
INSTANTIATE_TEST_CASE_P(
PSNR, HBDMetricsTest,
::testing::Values(
MetricTestTParam(&compute_psnr, &compute_hbd_psnr, 10,
MetricTestTParam(&compute_psnr, &compute_hbd_psnr, 8, 10,
kPhvs_thresh),
MetricTestTParam(&compute_psnr, &compute_hbd_psnr, 10, 10,
kPhvs_thresh),
MetricTestTParam(&compute_psnr, &compute_hbd_psnr, 12,
MetricTestTParam(&compute_psnr, &compute_hbd_psnr, 8, 12,
kPhvs_thresh),
MetricTestTParam(&compute_psnr, &compute_hbd_psnr, 12, 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