summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2022-06-05 20:00:10 +0200
committerNiklas Haas <github-daiK1o@haasn.dev>2022-06-06 17:04:08 +0200
commit969bdf5f4149971d8c16e9ab2b4f399c735115f5 (patch)
treef26243a84d9f1ca6b1ca8829c07a42dc85840ee2
parentc4c7b07acfa58166f47136aca8187fb7e175b79e (diff)
downloadmpv-969bdf5f4149971d8c16e9ab2b4f399c735115f5.tar.bz2
mpv-969bdf5f4149971d8c16e9ab2b4f399c735115f5.tar.xz
vo_gpu_next: fix OSD rendering of screenshots
One downside of this approach is that it bypasses the mixer cache, but while this is not ideal for performance reasons, the status quo is also simply broken so I'd rather have a slower implementation that works than a faster implementation that does not. And as it turns out, updating the OSD state and invalidating the mixer cache correctly is sufficiently nontrivial to do in a clean way, so I'd rather have this code that I can be reasonably certain does the right thing. Fixes #9923 as discussed. Also fixes #9928.
-rw-r--r--video/out/vo_gpu_next.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c
index 628417218b..3727c072f6 100644
--- a/video/out/vo_gpu_next.c
+++ b/video/out/vo_gpu_next.c
@@ -1109,8 +1109,8 @@ static void video_screenshot(struct vo *vo, struct voctrl_screenshot *args)
// Passing an interpolation radius of 0 guarantees that the first frame in
// the resulting mix is the correct frame for this PTS
- struct pl_frame *image = (struct pl_frame *) mix.frames[0];
- struct mp_image *mpi = image->user_data;
+ struct pl_frame image = *(struct pl_frame *) mix.frames[0];
+ struct mp_image *mpi = image.user_data;
struct mp_rect src = p->src, dst = p->dst;
struct mp_osd_res osd = p->osd_res;
if (!args->scaled) {
@@ -1159,7 +1159,7 @@ static void video_screenshot(struct vo *vo, struct voctrl_screenshot *args)
};
apply_target_options(p, &target);
- apply_crop(image, src, mpi->params.w, mpi->params.h);
+ apply_crop(&image, src, mpi->params.w, mpi->params.h);
apply_crop(&target, dst, fbo->params.w, fbo->params.h);
int osd_flags = 0;
@@ -1167,9 +1167,10 @@ static void video_screenshot(struct vo *vo, struct voctrl_screenshot *args)
osd_flags |= OSD_DRAW_OSD_ONLY;
if (!args->osd)
osd_flags |= OSD_DRAW_SUB_ONLY;
- update_overlays(vo, osd, 0, osd_flags, &p->osd_state, &target);
+ update_overlays(vo, osd, mpi->pts, osd_flags, &p->osd_state, &target);
+ image.num_overlays = 0; // Disable on-screen overlays
- if (!pl_render_image_mix(p->rr, &mix, &target, &p->params)) {
+ if (!pl_render_image(p->rr, &image, &target, &p->params)) {
MP_ERR(vo, "Failed rendering frame!\n");
goto done;
}