diff options
author | Niklas Haas <git@haasn.xyz> | 2017-09-11 18:20:18 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.xyz> | 2017-09-11 18:20:18 +0200 |
commit | 3faf1fb0a4482712b2177af2f72ef8877f8adc10 (patch) | |
tree | 4a9b118cc074d6acbaa7fffe828e90199db08db1 | |
parent | 71c25df5e66154e6b8b72ebc0f8ef5ae0c40d7f6 (diff) | |
download | mpv-3faf1fb0a4482712b2177af2f72ef8877f8adc10.tar.bz2 mpv-3faf1fb0a4482712b2177af2f72ef8877f8adc10.tar.xz |
vo: avoid putting large voctrl_performance_data on stack
This is around 512 kB, which is just way too much. Heap-allocate it
instead. Also cut down the max pass count to 64, since 128 was
unrealistically high even for vo_opengl.
-rw-r--r-- | player/command.c | 27 | ||||
-rw-r--r-- | video/out/opengl/video.h | 2 | ||||
-rw-r--r-- | video/out/vo.h | 2 |
3 files changed, 19 insertions, 12 deletions
diff --git a/player/command.c b/player/command.c index 87709e119c..1147eab14e 100644 --- a/player/command.c +++ b/player/command.c @@ -2913,19 +2913,21 @@ static int mp_property_vo_passes(void *ctx, struct m_property *prop, return M_PROPERTY_OK; } - struct voctrl_performance_data data = {0}; - if (vo_control(mpctx->video_out, VOCTRL_PERFORMANCE_DATA, &data) <= 0) - return M_PROPERTY_UNAVAILABLE; + int ret = M_PROPERTY_UNAVAILABLE; + struct voctrl_performance_data *data = talloc_ptrtype(NULL, data); + if (vo_control(mpctx->video_out, VOCTRL_PERFORMANCE_DATA, data) <= 0) + goto out; switch (action) { case M_PROPERTY_PRINT: { char *res = NULL; res = talloc_asprintf_append(res, "fresh:\n"); - res = asprint_perf(res, &data.fresh); + res = asprint_perf(res, &data->fresh); res = talloc_asprintf_append(res, "\nredraw:\n"); - res = asprint_perf(res, &data.redraw); + res = asprint_perf(res, &data->redraw); *(char **)arg = res; - return M_PROPERTY_OK; + ret = M_PROPERTY_OK; + goto out; } case M_PROPERTY_GET: { @@ -2933,14 +2935,19 @@ static int mp_property_vo_passes(void *ctx, struct m_property *prop, node_init(&node, MPV_FORMAT_NODE_MAP, NULL); struct mpv_node *fresh = node_map_add(&node, "fresh", MPV_FORMAT_NODE_ARRAY); struct mpv_node *redraw = node_map_add(&node, "redraw", MPV_FORMAT_NODE_ARRAY); - get_frame_perf(fresh, &data.fresh); - get_frame_perf(redraw, &data.redraw); + get_frame_perf(fresh, &data->fresh); + get_frame_perf(redraw, &data->redraw); *(struct mpv_node *)arg = node; - return M_PROPERTY_OK; + ret = M_PROPERTY_OK; + goto out; } } - return M_PROPERTY_NOT_IMPLEMENTED; + ret = M_PROPERTY_NOT_IMPLEMENTED; + +out: + talloc_free(data); + return ret; } static int mp_property_vo(void *ctx, struct m_property *p, int action, void *arg) diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h index e20af90643..d163bc8405 100644 --- a/video/out/opengl/video.h +++ b/video/out/opengl/video.h @@ -27,6 +27,7 @@ #include "shader_cache.h" #include "video/csputils.h" #include "video/out/filter_kernels.h" +#include "video/out/vo.h" // Assume we have this many texture units for sourcing additional passes. // The actual texture unit assignment is dynamic. @@ -164,7 +165,6 @@ void gl_video_resize(struct gl_video *p, struct mp_rect *src, struct mp_rect *dst, struct mp_osd_res *osd); void gl_video_set_fb_depth(struct gl_video *p, int fb_depth); -struct voctrl_performance_data; void gl_video_perfdata(struct gl_video *p, struct voctrl_performance_data *out); void gl_video_set_clear_color(struct gl_video *p, struct m_color color); void gl_video_set_osd_pts(struct gl_video *p, double pts); diff --git a/video/out/vo.h b/video/out/vo.h index 50fdab6db4..2a0c3ef626 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -152,7 +152,7 @@ struct mp_pass_perf { uint64_t count; }; -#define VO_PASS_PERF_MAX 128 +#define VO_PASS_PERF_MAX 64 struct mp_frame_perf { int count; |