diff options
author | Dudemanguy <random342@airmail.cc> | 2023-02-25 21:50:08 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-03-02 15:45:27 +0000 |
commit | 9db818279aa63d071f2bca369235285314444dcd (patch) | |
tree | 9aafc5cf73e19ae8ea69751c060cab9766a6b9a4 /video/out | |
parent | 61532421571f972f076b3700d7ae468c0a0438c0 (diff) | |
download | mpv-9db818279aa63d071f2bca369235285314444dcd.tar.bz2 mpv-9db818279aa63d071f2bca369235285314444dcd.tar.xz |
test: integrate unittests with meson
This reworks all of mpv's unit tests so they are compiled as separate
executables (optional) and run via meson test. Because most of the tests
are dependant on mpv's internals, existing compiled objects are
leveraged to create static libs and used when necessary. As an aside, a
function was moved into video/out/gpu/utils for sanity's sake (otherwise
most of vo would have been needed). As a plus, meson multithreads
running tests automatically and also the output no longer pollutes the
source directory. There are tests that can break due to ffmpeg changes,
so they require a specific minimum libavutil version to be built.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/gpu/utils.c | 15 | ||||
-rw-r--r-- | video/out/gpu/utils.h | 3 | ||||
-rw-r--r-- | video/out/gpu/video.c | 15 |
3 files changed, 18 insertions, 15 deletions
diff --git a/video/out/gpu/utils.c b/video/out/gpu/utils.c index 2c625dc26a..8a1aacfff5 100644 --- a/video/out/gpu/utils.c +++ b/video/out/gpu/utils.c @@ -39,6 +39,21 @@ void gl_transform_ortho_fbo(struct gl_transform *t, struct ra_fbo fbo) gl_transform_ortho(t, 0, fbo.tex->params.w, 0, fbo.tex->params.h * y_dir); } +float gl_video_scale_ambient_lux(float lmin, float lmax, + float rmin, float rmax, float lux) +{ + assert(lmax > lmin); + + float num = (rmax - rmin) * (log10(lux) - log10(lmin)); + float den = log10(lmax) - log10(lmin); + float result = num / den + rmin; + + // clamp the result + float max = MPMAX(rmax, rmin); + float min = MPMIN(rmax, rmin); + return MPMAX(MPMIN(result, max), min); +} + void ra_buf_pool_uninit(struct ra *ra, struct ra_buf_pool *pool) { for (int i = 0; i < pool->num_buffers; i++) diff --git a/video/out/gpu/utils.h b/video/out/gpu/utils.h index ac0cbf28d7..215873eec8 100644 --- a/video/out/gpu/utils.h +++ b/video/out/gpu/utils.h @@ -65,6 +65,9 @@ void gl_transform_trans(struct gl_transform t, struct gl_transform *x); void gl_transform_ortho_fbo(struct gl_transform *t, struct ra_fbo fbo); +float gl_video_scale_ambient_lux(float lmin, float lmax, + float rmin, float rmax, float lux); + // A pool of buffers, which can grow as needed struct ra_buf_pool { struct ra_buf_params current_params; diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index df689b53c3..21e004cd43 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -4239,21 +4239,6 @@ static int validate_error_diffusion_opt(struct mp_log *log, const m_option_t *op return r; } -float gl_video_scale_ambient_lux(float lmin, float lmax, - float rmin, float rmax, float lux) -{ - assert(lmax > lmin); - - float num = (rmax - rmin) * (log10(lux) - log10(lmin)); - float den = log10(lmax) - log10(lmin); - float result = num / den + rmin; - - // clamp the result - float max = MPMAX(rmax, rmin); - float min = MPMIN(rmax, rmin); - return MPMAX(MPMIN(result, max), min); -} - void gl_video_set_ambient_lux(struct gl_video *p, int lux) { if (p->opts.gamma_auto) { |