Skip to content

Commit c70debb

Browse files
committed
libvmaf/test: port new adm/vif/speed tests
1 parent 314db13 commit c70debb

5 files changed

Lines changed: 1314 additions & 0 deletions

File tree

libvmaf/test/meson.build

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,39 @@ test_framesync = executable('test_framesync',
139139
dependencies : thread_lib,
140140
)
141141

142+
test_adm_csf = executable('test_adm_csf',
143+
['test.c', 'test_adm_csf.c'],
144+
include_directories : [libvmaf_inc, test_inc, include_directories('../src/')],
145+
link_with : get_option('default_library') == 'both' ? libvmaf.get_static_lib() : libvmaf,
146+
dependencies : math_lib,
147+
)
148+
149+
test_barten_csf = executable('test_barten_csf',
150+
['test.c', 'test_barten_csf.c'],
151+
include_directories : [libvmaf_inc, test_inc, include_directories('../src/')],
152+
link_with : get_option('default_library') == 'both' ? libvmaf.get_static_lib() : libvmaf,
153+
dependencies : math_lib,
154+
)
155+
156+
if float_enabled
157+
test_vif_tools = executable('test_vif_tools',
158+
['test.c', 'test_vif_tools.c'],
159+
include_directories : [libvmaf_inc, test_inc, include_directories('../src/')],
160+
link_with : get_option('default_library') == 'both' ? libvmaf.get_static_lib() : libvmaf,
161+
dependencies : math_lib,
162+
)
163+
164+
test_speed_chroma = executable('test_speed_chroma',
165+
['test.c', 'test_speed_chroma.c', '../src/picture.c', '../src/mem.c', '../src/ref.c'],
166+
include_directories : [libvmaf_inc, test_inc, include_directories('../src/')],
167+
link_with : get_option('default_library') == 'both' ? libvmaf.get_static_lib() : libvmaf,
168+
dependencies : math_lib,
169+
)
170+
171+
test('test_vif_tools', test_vif_tools)
172+
test('test_speed_chroma', test_speed_chroma)
173+
endif
174+
142175
if get_option('enable_cuda')
143176
test_ring_buffer = executable('test_ring_buffer',
144177
['test.c', 'test_ring_buffer.c', '../src/cuda/ring_buffer.c', '../src/cuda/picture_cuda.c'],
@@ -189,3 +222,5 @@ test('test_cli_parse', test_cli_parse)
189222
test('test_psnr', test_psnr)
190223
test('test_framesync', test_framesync)
191224
test('test_propagate_metadata', test_propagate_metadata)
225+
test('test_adm_csf', test_adm_csf)
226+
test('test_barten_csf', test_barten_csf)

libvmaf/test/test_adm_csf.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
*
3+
* Copyright 2016-2020 Netflix, Inc.
4+
*
5+
* Licensed under the BSD+Patent License (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://opensource.org/licenses/BSDplusPatent
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
#include "test.h"
20+
#include "feature/adm_csf_tools.h"
21+
22+
#define EPS 0.00001
23+
24+
/* Test support function */
25+
int almost_equal(double a, double b)
26+
{
27+
double diff = a > b ? a - b : b - a;
28+
return diff < EPS;
29+
}
30+
31+
static char *test_adm_csf()
32+
{
33+
mu_assert("adm csf mismatch", almost_equal(adm_native_csf(3, 3.0, 1080, 0), 0.986264592442799));
34+
mu_assert("adm csf mismatch", almost_equal(adm_native_csf(3, 3.0, 1080, 45), 0.8773599546532113));
35+
return NULL;
36+
}
37+
38+
char *run_tests()
39+
{
40+
mu_run_test(test_adm_csf);
41+
return NULL;
42+
}

libvmaf/test/test_barten_csf.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
*
3+
* Copyright 2016-2020 Netflix, Inc.
4+
*
5+
* Licensed under the BSD+Patent License (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://opensource.org/licenses/BSDplusPatent
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
#include "test.h"
20+
#include "feature/barten_csf_tools.h"
21+
22+
#define EPS 0.00001
23+
24+
/* Test support function */
25+
int almost_equal(double a, double b)
26+
{
27+
double diff = a > b ? a - b : b - a;
28+
return diff < EPS;
29+
}
30+
31+
static char *test_barten_csf()
32+
{
33+
mu_assert("barten rod/cone sensitivity mismatch", almost_equal(barten_rod_cone_sens(150.0), 30.141537));
34+
mu_assert("barten rod/cone sensitivity mismatch", almost_equal(barten_rod_cone_sens(100.0), 30.121951521378232));
35+
mu_assert("barten mtf mismatch", almost_equal(barten_mtf(3.0), 0.5792610023712589));
36+
mu_assert("barten csf mismatch lum 100", almost_equal(barten_csf(3, 3.0, 1080, 100.0, 1.0), 26.97588185355269));
37+
mu_assert("barten csf mismatch lum 100", almost_equal(barten_csf(3, 3.0, 1080, 100.0, 0.5), 13.4879409268));
38+
mu_assert("barten csf mismatch lum 80", almost_equal(barten_csf(3, 3.0, 1080, 80.0, 1.0), 26.949246017567383));
39+
mu_assert("barten csf mismatch lum 50", almost_equal(barten_csf(3, 3.0, 1080, 50.0, 1.0), 26.9958));
40+
// although we clamp below 0.002 for the interpolation, we still use the un-clamped in the rest of the CSF
41+
mu_assert("barten csf mismatch lum 0.001", almost_equal(barten_csf(3, 3.0, 1080, 0.001, 1.0), 0.112742));
42+
mu_assert("barten csf mismatch lum 0.002", almost_equal(barten_csf(3, 3.0, 1080, 0.002, 1.0), 0.154019));
43+
mu_assert("barten csf mismatch lum 0.01", almost_equal(barten_csf(3, 3.0, 1080, 0.01, 1.0), 0.439781));
44+
mu_assert("barten csf mismatch lum 0.05", almost_equal(barten_csf(3, 3.0, 1080, 0.05, 1.0), 1.240470));
45+
mu_assert("barten csf mismatch lum 1.0", almost_equal(barten_csf(3, 3.0, 1080, 1.0, 1.0), 9.063454));
46+
mu_assert("barten csf mismatch lum 10.0", almost_equal(barten_csf(3, 3.0, 1080, 10.0, 1.0), 23.722300));
47+
mu_assert("barten csf mismatch lum 150.0", almost_equal(barten_csf(3, 3.0, 1080, 150.0, 1.0), 27.113543));
48+
mu_assert("barten csf mismatch lum 155.0", almost_equal(barten_csf(3, 3.0, 1080, 155.0, 1.0), 27.114515));
49+
mu_assert("linear interpolate", almost_equal(linear_interpolate(log10(20), barten_csf_params[4][1], log10(150.0),
50+
barten_csf_params[5][1], log10(50.0)), 0.361679));
51+
mu_assert("csf blend scale 0 H/V 1080p 3H", almost_equal(barten_watson_blend_csf(0, 0, 3.0, 1080), 0.01183));
52+
mu_assert("csf blend scale 0 D 1080p 3H", almost_equal(barten_watson_blend_csf(0, 1, 3.0, 1080), 0.004302));
53+
mu_assert("csf blend scale 1 H/V 1080p 3H", almost_equal(barten_watson_blend_csf(1, 0, 3.0, 1080), 0.025026));
54+
mu_assert("csf blend scale 1 D 1080p 3H", almost_equal(barten_watson_blend_csf(1, 1, 3.0, 1080), 0.011778));
55+
mu_assert("csf blend scale 2 H/V 1080p 3H", almost_equal(barten_watson_blend_csf(2, 0, 3.0, 1080), 0.04295));
56+
mu_assert("csf blend scale 2 D 1080p 3H", almost_equal(barten_watson_blend_csf(2, 1, 3.0, 1080), 0.023918));
57+
mu_assert("csf blend scale 3 H/V 1080p 3H", almost_equal(barten_watson_blend_csf(3, 0, 3.0, 1080), 0.058621));
58+
mu_assert("csf blend scale 3 D 1080p 3H", almost_equal(barten_watson_blend_csf(3, 1, 3.0, 1080), 0.035901));
59+
return NULL;
60+
}
61+
62+
char *run_tests()
63+
{
64+
mu_run_test(test_barten_csf);
65+
return NULL;
66+
}

0 commit comments

Comments
 (0)