summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2023-08-30 14:53:57 +0200
committerNiklas Haas <github-daiK1o@haasn.dev>2023-08-30 17:10:13 +0200
commit67d31a8266893eafd0e823c59da673ac718be36f (patch)
tree5b3737862d23aded3eadccef0ddd9d017094e65e /video
parent15ada7c41cdc3943666ddf281be69f58cddc1143 (diff)
downloadmpv-67d31a8266893eafd0e823c59da673ac718be36f.tar.bz2
mpv-67d31a8266893eafd0e823c59da673ac718be36f.tar.xz
vo_gpu_next: improve --tonemapping-visualize
Pick a smarter rect, limit it to right half of screen (to allow more easily using it simultaneously with stats), and also auto-rotate through the hue plane by default (wrapping once every 10 seconds of playback). I briefly considered making it based on wallclock time instead of pts, but this has the rather unfortunate downside of only being updated sporadically as the user moves the mouse over OSC elements. (Of course, we could also forcibly redraw the screen continously to avoid it, but I'd rather not make such an invasive change for no real reason) This design also allows you to pause and focus on (via framestepping) individual parts of the hue graph that you're interested in.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_gpu_next.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c
index dcce45db3e..c598cca3c8 100644
--- a/video/out/vo_gpu_next.c
+++ b/video/out/vo_gpu_next.c
@@ -912,6 +912,29 @@ static void apply_crop(struct pl_frame *frame, struct mp_rect crop,
}
}
+static void update_tm_viz(struct pl_color_map_params *params,
+ const struct pl_frame *target,
+ double pts)
+{
+ if (!params->visualize_lut)
+ return;
+
+ // Use right half of sceen for TM visualization, constrain to 1:1 AR
+ const float out_w = fabsf(pl_rect_w(target->crop));
+ const float out_h = fabsf(pl_rect_h(target->crop));
+ const float size = MPMIN(out_w / 2.0f, out_h);
+ params->visualize_rect = (pl_rect2df) {
+ .x0 = 1.0f - size / out_w,
+ .x1 = 1.0f,
+ .y0 = 0.0f,
+ .y1 = size / out_h,
+ };
+
+ // Complete one full rotation of the hue plane every 10 seconds
+ const float tm_period = 10.0;
+ params->visualize_hue = 2 * M_PI * pts / tm_period;
+}
+
static void draw_frame(struct vo *vo, struct vo_frame *frame)
{
struct priv *p = vo->priv;
@@ -1015,6 +1038,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame)
// initialization, but pl_queue does not like these. Hard-clamp as
// a simple work-around.
qparams.pts = p->last_pts = MPMAX(qparams.pts, p->last_pts);
+ update_tm_viz(&pars->color_map_params, &target, qparams.pts);
switch (pl_queue_update(p->queue, &mix, &qparams)) {
case PL_QUEUE_ERR:
@@ -1324,6 +1348,7 @@ static void video_screenshot(struct vo *vo, struct voctrl_screenshot *args)
apply_crop(&image, src, mpi->params.w, mpi->params.h);
apply_crop(&target, dst, fbo->params.w, fbo->params.h);
+ update_tm_viz(&pars->color_map_params, &target, p->last_pts);
int osd_flags = 0;
if (!args->subs)