summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-11-07 00:52:56 +0100
committerDudemanguy <random342@airmail.cc>2023-11-08 21:45:07 +0000
commit477a0f83184d18a5cd89261b5f81ee668c7f4441 (patch)
tree73f7ffb96a1799fa390394b0435a08ec92d78ca8 /video
parenta96d26e63a78d6325ed0238a24d8bd4a66519d19 (diff)
downloadmpv-477a0f83184d18a5cd89261b5f81ee668c7f4441.tar.bz2
mpv-477a0f83184d18a5cd89261b5f81ee668c7f4441.tar.xz
vo: replace VOCTRL_HDR_METADATA with direct VO params read
Currently VOCTRL are completely unusable for frequent data query. Since the HDR parameter addition to video-params, the parameters can change each frame. In which case observe on those parameter would be triggered constantly. The problem is that quering those parameters involves VOCTRL which in turn involves whole render cycle of delay. Instead update VO params on each draw_frame. This requires changes to VO reconfiguration condition, but in practice it should only be triggered when image size or data layout changes. In other cases it will be handled internal by VO driver. I'm not quite happy with this solution, but don't see better one without changing observe/notify logic significantly. There is no good way currently to handle VOCTRL that are constantly queried. This adds unfortunate synchronization of player command with VO thread, but there is not way around that and if too frequent queries of this param becomes a problem we can thing of other solutions. Changes the way to get data from VO driver added by a98c5328dc Fixes: 84de84b Fixes: #12825
Diffstat (limited to 'video')
-rw-r--r--video/out/vo.c10
-rw-r--r--video/out/vo.h4
-rw-r--r--video/out/vo_gpu_next.c22
3 files changed, 16 insertions, 20 deletions
diff --git a/video/out/vo.c b/video/out/vo.c
index bf1ba114fd..6d06973a47 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -1422,3 +1422,13 @@ int lookup_keymap_table(const struct mp_keymap *map, int key)
map++;
return map->to;
}
+
+struct mp_image_params vo_get_current_params(struct vo *vo)
+{
+ struct mp_image_params p = {0};
+ mp_mutex_lock(&vo->in->lock);
+ if (vo->params)
+ p = *vo->params;
+ mp_mutex_unlock(&vo->in->lock);
+ return p;
+}
diff --git a/video/out/vo.h b/video/out/vo.h
index a643830e1b..f73cbf5989 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -122,8 +122,6 @@ enum mp_voctrl {
/* private to vo_gpu and vo_gpu_next */
VOCTRL_EXTERNAL_RESIZE,
-
- VOCTRL_HDR_METADATA, // struct pl_hdr_metadata*
};
// Helper to expose what kind of content is currently playing to the VO.
@@ -536,4 +534,6 @@ void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src,
struct vo_frame *vo_frame_ref(struct vo_frame *frame);
+struct mp_image_params vo_get_current_params(struct vo *vo);
+
#endif /* MPLAYER_VIDEO_OUT_H */
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c
index d0da4ebef6..60fcaedd42 100644
--- a/video/out/vo_gpu_next.c
+++ b/video/out/vo_gpu_next.c
@@ -153,8 +153,6 @@ struct priv {
bool target_hint;
float corner_rounding;
-
- struct pl_hdr_metadata last_hdr_metadata;
};
static void update_render_options(struct vo *vo);
@@ -1033,19 +1031,11 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame)
goto done;
}
- const struct pl_frame *cur_frame = NULL;
- for (int i = 0; i < mix.num_frames; i++) {
- if (mix.timestamps[i] > 0.0f)
- break;
- cur_frame = mix.frames[i];
- }
-
- if (cur_frame) {
- p->last_hdr_metadata = cur_frame->color.hdr;
+ const struct pl_frame *cur_frame = pl_frame_mix_nearest(&mix);
+ if (cur_frame && vo->params) {
+ vo->params->color.hdr = cur_frame->color.hdr;
// Augment metadata with peak detection max_pq_y / avg_pq_y
- pl_renderer_get_hdr_metadata(p->rr, &p->last_hdr_metadata);
- } else {
- p->last_hdr_metadata = (struct pl_hdr_metadata){0};
+ pl_renderer_get_hdr_metadata(p->rr, &vo->params->color.hdr);
}
p->is_interpolated = mix.num_frames > 1;
@@ -1430,10 +1420,6 @@ static int control(struct vo *vo, uint32_t request, void *data)
return true;
}
- case VOCTRL_HDR_METADATA:
- *(struct pl_hdr_metadata *) data = p->last_hdr_metadata;
- return true;
-
case VOCTRL_SCREENSHOT:
video_screenshot(vo, data);
return true;