From e4693d1999ebb54c28f6c0bb484ad6e618b54c1c Mon Sep 17 00:00:00 2001 From: der richter Date: Sun, 22 Dec 2024 14:42:57 +0100 Subject: [PATCH 1/2] libmpv: remove MPV_RENDER_PARAM_AMBIENT_LIGHT render parameter --- DOCS/client-api-changes.rst | 2 ++ libmpv/client.h | 2 +- libmpv/render.h | 7 ------- video/out/gpu/libmpv_gpu.c | 7 ------- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/DOCS/client-api-changes.rst b/DOCS/client-api-changes.rst index fadd7dab0f097..d0ff4bc2aec55 100644 --- a/DOCS/client-api-changes.rst +++ b/DOCS/client-api-changes.rst @@ -32,6 +32,8 @@ API changes :: + --- mpv 0.41.0 --- + 2.6 - Remove MPV_RENDER_PARAM_AMBIENT_LIGHT --- mpv 0.40.0 --- 2.5 - Deprecate MPV_RENDER_PARAM_AMBIENT_LIGHT. no replacement. --- mpv 0.39.0 --- diff --git a/libmpv/client.h b/libmpv/client.h index 85cff63bd5d20..190839c2b576b 100644 --- a/libmpv/client.h +++ b/libmpv/client.h @@ -248,7 +248,7 @@ extern "C" { * relational operators (<, >, <=, >=). */ #define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL) -#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(2, 5) +#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(2, 6) /** * The API user is allowed to "#define MPV_ENABLE_DEPRECATED 0" before diff --git a/libmpv/render.h b/libmpv/render.h index 99aadeb5d837d..a9636ef55ff16 100644 --- a/libmpv/render.h +++ b/libmpv/render.h @@ -224,13 +224,6 @@ typedef enum mpv_render_param_type { * option is not enabled, the ICC data will not be used.) */ MPV_RENDER_PARAM_ICC_PROFILE = 6, - /** - * Deprecated - * Ambient light in lux. Valid for mpv_render_context_set_parameter(). - * Type: int* - * This can be used for automatic gamma correction. - */ - MPV_RENDER_PARAM_AMBIENT_LIGHT = 7, /** * X11 Display, sometimes used for hwdec. Valid for * mpv_render_context_create(). The Display must stay valid for the lifetime diff --git a/video/out/gpu/libmpv_gpu.c b/video/out/gpu/libmpv_gpu.c index e43e66b4811e6..c4646911b633b 100644 --- a/video/out/gpu/libmpv_gpu.c +++ b/video/out/gpu/libmpv_gpu.c @@ -110,13 +110,6 @@ static int set_parameter(struct render_backend *ctx, mpv_render_param param) gl_video_set_icc_profile(p->renderer, bstrdup(NULL, (bstr){data->data, data->size})); return 0; } - case MPV_RENDER_PARAM_AMBIENT_LIGHT: { - MP_WARN(ctx, "MPV_RENDER_PARAM_AMBIENT_LIGHT is deprecated and might be " - "removed in the future (replacement: gamma-auto.lua)\n"); - int lux = *(int *)param.data; - gl_video_set_ambient_lux(p->renderer, (double)lux); - return 0; - } default: return MPV_ERROR_NOT_IMPLEMENTED; } From 2949db36c42e46fe952c5bc651fd34f0fd778628 Mon Sep 17 00:00:00 2001 From: der richter Date: Sun, 22 Dec 2024 14:59:09 +0100 Subject: [PATCH 2/2] vo_gpu: remove deprecated option --gamma-auto --- DOCS/interface-changes/gamma-auto.txt | 1 + DOCS/man/options.rst | 8 -------- test/gl_video.c | 25 ------------------------- test/meson.build | 7 ------- video/out/gpu/utils.c | 15 --------------- video/out/gpu/utils.h | 3 --- video/out/gpu/video.c | 18 +----------------- video/out/gpu/video.h | 5 ----- video/out/vo_gpu.c | 17 ----------------- 9 files changed, 2 insertions(+), 97 deletions(-) create mode 100644 DOCS/interface-changes/gamma-auto.txt delete mode 100644 test/gl_video.c diff --git a/DOCS/interface-changes/gamma-auto.txt b/DOCS/interface-changes/gamma-auto.txt new file mode 100644 index 0000000000000..e11ffef5b8e76 --- /dev/null +++ b/DOCS/interface-changes/gamma-auto.txt @@ -0,0 +1 @@ +remove deprecated `--gamma-auto` option diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 6094287da471e..5b8e4ce25f19a 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -6832,14 +6832,6 @@ them. other ways (like with the ``--gamma`` option or key bindings and the ``gamma`` property), the value is multiplied with the other gamma value. -``--gamma-auto`` - Automatically corrects the gamma value depending on ambient lighting - conditions (adding a gamma boost for bright rooms). - - This option is deprecated and may be removed in the future. - - NOTE: Only implemented on macOS and ``--vo=gpu``. - ``--image-lut=`` Specifies a custom LUT file (in Adobe .cube format) to apply to the colors during image decoding. The exact interpretation of the LUT depends on diff --git a/test/gl_video.c b/test/gl_video.c deleted file mode 100644 index a2bdda43a3634..0000000000000 --- a/test/gl_video.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "test_utils.h" -#include "video/out/gpu/utils.h" - -int main(void) -{ - float x; - - x = gl_video_scale_ambient_lux(16.0, 64.0, 2.40, 1.961, 16.0); - assert_float_equal(x, 2.40f, FLT_EPSILON); - - x = gl_video_scale_ambient_lux(16.0, 64.0, 2.40, 1.961, 64.0); - assert_float_equal(x, 1.961f, FLT_EPSILON); - - x = gl_video_scale_ambient_lux(16.0, 64.0, 1.961, 2.40, 64.0); - assert_float_equal(x, 2.40f, FLT_EPSILON); - - x = gl_video_scale_ambient_lux(16.0, 64.0, 2.40, 1.961, 0.0); - assert_float_equal(x, 2.40f, FLT_EPSILON); - - // 32 corresponds to the midpoint after converting lux to the log10 scale - x = gl_video_scale_ambient_lux(16.0, 64.0, 2.40, 1.961, 32.0); - float mid_gamma = (2.40 - 1.961) / 2 + 1.961; - assert_float_equal(x, mid_gamma, FLT_EPSILON); - return 0; -} diff --git a/test/meson.build b/test/meson.build index 41ff11125064d..cf450c90cb28c 100644 --- a/test/meson.build +++ b/test/meson.build @@ -83,13 +83,6 @@ chmap = executable('chmap', 'chmap.c', include_directories: incdir, link_with: test_utils) test('chmap', chmap) -gl_video_objects = libmpv.extract_objects('video/out/gpu/ra.c', - 'video/out/gpu/utils.c') -gl_video = executable('gl-video', 'gl_video.c', objects: gl_video_objects, - dependencies: [libavutil, libplacebo], include_directories: incdir, - link_with: [img_utils, test_utils]) -test('gl-video', gl_video) - json = executable('json', 'json.c', include_directories: incdir, link_with: test_utils) test('json', json) diff --git a/video/out/gpu/utils.c b/video/out/gpu/utils.c index 7a3a72279c31c..17c0275ccf01d 100644 --- a/video/out/gpu/utils.c +++ b/video/out/gpu/utils.c @@ -39,21 +39,6 @@ void gl_transform_ortho_fbo(struct gl_transform *t, const struct ra_fbo *fbo) gl_transform_ortho(t, 0, fbo->tex->params.w, 0, fbo->tex->params.h * y_dir); } -double gl_video_scale_ambient_lux(float lmin, float lmax, - float rmin, float rmax, double lux) -{ - assert(lmax > lmin); - - double num = (rmax - rmin) * (log10(lux) - log10(lmin)); - double den = log10(lmax) - log10(lmin); - double 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 ebb2f4cb4593a..406e85b4b9bb8 100644 --- a/video/out/gpu/utils.h +++ b/video/out/gpu/utils.h @@ -65,9 +65,6 @@ void gl_transform_trans(struct gl_transform t, struct gl_transform *x); void gl_transform_ortho_fbo(struct gl_transform *t, const struct ra_fbo *fbo); -double gl_video_scale_ambient_lux(float lmin, float lmax, - float rmin, float rmax, double 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 f1dcf6b0734ff..68280637ad952 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -434,8 +434,7 @@ const struct m_sub_options gl_video_conf = { {"gpu-dumb-mode", OPT_CHOICE(dumb_mode, {"auto", 0}, {"yes", 1}, {"no", -1})}, {"gamma-factor", OPT_FLOAT(gamma), M_RANGE(0.1, 2.0)}, - {"gamma-auto", OPT_BOOL(gamma_auto), - .deprecation_message = "replacement: gamma-auto.lua"}, + {"gamma-auto", OPT_REMOVED("Replaced by gamma-auto.lua")}, {"target-prim", OPT_CHOICE_C(target_prim, pl_csp_prim_names)}, {"target-trc", OPT_CHOICE_C(target_trc, pl_csp_trc_names)}, {"target-peak", OPT_CHOICE(target_peak, {"auto", 0}), @@ -669,11 +668,6 @@ static void uninit_rendering(struct gl_video *p) gl_sc_reset_error(p->sc); } -bool gl_video_gamma_auto_enabled(struct gl_video *p) -{ - return p->opts.gamma_auto; -} - // Warning: profile.start must point to a ta allocation, and the function // takes over ownership. void gl_video_set_icc_profile(struct gl_video *p, bstr icc_data) @@ -3956,7 +3950,6 @@ static void check_gl_features(struct gl_video *p) }, }, .gamma = p->opts.gamma, - .gamma_auto = p->opts.gamma_auto, .pbo = p->opts.pbo, .fbo_format = p->opts.fbo_format, .background = p->opts.background, @@ -4271,15 +4264,6 @@ static int validate_error_diffusion_opt(struct mp_log *log, const m_option_t *op return r; } -void gl_video_set_ambient_lux(struct gl_video *p, double lux) -{ - if (p->opts.gamma_auto) { - p->opts.gamma = gl_video_scale_ambient_lux(16.0, 256.0, 1.0, 1.2, lux); - MP_TRACE(p, "ambient light changed: %f lux (gamma: %f)\n", lux, - p->opts.gamma); - } -} - static void *gl_video_dr_alloc_buffer(struct gl_video *p, size_t size) { struct ra_buf_params params = { diff --git a/video/out/gpu/video.h b/video/out/gpu/video.h index 00e843c11506c..d88f58586cd86 100644 --- a/video/out/gpu/video.h +++ b/video/out/gpu/video.h @@ -133,7 +133,6 @@ struct gl_video_opts { int dumb_mode; struct scaler_config scaler[4]; float gamma; - bool gamma_auto; int target_prim; int target_trc; int target_peak; @@ -209,12 +208,8 @@ bool gl_video_check_osd_change(struct gl_video *p, struct mp_osd_res *osd, void gl_video_screenshot(struct gl_video *p, struct vo_frame *frame, struct voctrl_screenshot *args); -double gl_video_scale_ambient_lux(float lmin, float lmax, - float rmin, float rmax, double lux); -void gl_video_set_ambient_lux(struct gl_video *p, double lux); void gl_video_set_icc_profile(struct gl_video *p, bstr icc_data); bool gl_video_icc_auto_enabled(struct gl_video *p); -bool gl_video_gamma_auto_enabled(struct gl_video *p); void gl_video_reset(struct gl_video *p); bool gl_video_showing_interpolated_frame(struct gl_video *p); diff --git a/video/out/vo_gpu.c b/video/out/vo_gpu.c index 837292b248500..bc4a8e5d1ac05 100644 --- a/video/out/vo_gpu.c +++ b/video/out/vo_gpu.c @@ -160,19 +160,6 @@ static void get_and_update_icc_profile(struct gpu_priv *p) } } -static void get_and_update_ambient_lighting(struct gpu_priv *p) -{ - double lux; - int r = p->ctx->fns->control(p->ctx, &p->events, VOCTRL_GET_AMBIENT_LUX, &lux); - if (r == VO_TRUE) { - gl_video_set_ambient_lux(p->renderer, lux); - } - if (r != VO_TRUE && gl_video_gamma_auto_enabled(p->renderer)) { - MP_ERR(p, "gamma_auto option provided, but querying for ambient" - " lighting is not supported on this platform\n"); - } -} - static void update_ra_ctx_options(struct vo *vo, struct ra_ctx_opts *ctx_opts) { struct gpu_priv *p = vo->priv; @@ -234,10 +221,6 @@ static int control(struct vo *vo, uint32_t request, void *data) get_and_update_icc_profile(p); vo->want_redraw = true; } - if (events & VO_EVENT_AMBIENT_LIGHTING_CHANGED) { - get_and_update_ambient_lighting(p); - vo->want_redraw = true; - } events |= p->events; p->events = 0; if (events & VO_EVENT_RESIZE)