summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-07-16 22:43:40 +0200
committerwm4 <wm4@nowhere>2015-07-16 22:43:40 +0200
commit968bd3df3b57685400c5d000c799d1ec9f7da59a (patch)
treeb5a2c5e94c69c4eb30f1831c701fac69553fbbff /video
parentbb9717a630cd3d1cc0d8aecc03e18c86e49d4d9c (diff)
downloadmpv-968bd3df3b57685400c5d000c799d1ec9f7da59a.tar.bz2
mpv-968bd3df3b57685400c5d000c799d1ec9f7da59a.tar.xz
vo_opengl: refactor queue configuration
Just avoid some code duplication. Also, gl_video_set_options() having a queue size output parameter is weird at best. While I don't appreciate that this commit suddenly requires gl_video.c to deal with vo.c directly in a special case, it's simply the best place to put this function.
Diffstat (limited to 'video')
-rw-r--r--video/out/gl_video.c31
-rw-r--r--video/out/gl_video.h6
-rw-r--r--video/out/vo_opengl.c10
-rw-r--r--video/out/vo_opengl_cb.c5
4 files changed, 29 insertions, 23 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 1b4ddd0490..588db843ef 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -40,6 +40,7 @@
#include "aspect.h"
#include "bitmap_packer.h"
#include "dither.h"
+#include "vo.h"
// Pixel width of 1D lookup textures.
#define LOOKUP_TEXTURE_SIZE 256
@@ -2802,8 +2803,7 @@ static char **dup_str_array(void *parent, char **src)
// Set the options, and possibly update the filter chain too.
// Note: assumes all options are valid and verified by the option parser.
-void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts,
- int *queue_size)
+void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts)
{
talloc_free(p->opts.source_shader);
talloc_free(p->opts.scale_shader);
@@ -2817,28 +2817,35 @@ void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts,
(char *)handle_scaler_opt(p->opts.scaler[n].kernel.name, n==3);
}
+ p->opts.source_shader = talloc_strdup(p, p->opts.source_shader);
+ p->opts.scale_shader = talloc_strdup(p, p->opts.scale_shader);
+ p->opts.pre_shaders = dup_str_array(p, p->opts.pre_shaders);
+ p->opts.post_shaders = dup_str_array(p, p->opts.post_shaders);
+
+ check_gl_features(p);
+ uninit_rendering(p);
+}
+
+void gl_video_configure_queue(struct gl_video *p, struct vo *vo)
+{
+ int queue_size = 0;
+
// Figure out an adequate size for the interpolation queue. The larger
// the radius, the earlier we need to queue frames.
- if (queue_size && p->opts.interpolation) {
+ if (p->opts.interpolation) {
const struct filter_kernel *kernel =
mp_find_filter_kernel(p->opts.scaler[3].kernel.name);
if (kernel) {
double radius = kernel->f.radius;
radius = radius > 0 ? radius : p->opts.scaler[3].radius;
- *queue_size = 1 + ceil(radius);
+ queue_size = 1 + ceil(radius);
} else {
// Oversample case
- *queue_size = 2;
+ queue_size = 2;
}
}
- p->opts.source_shader = talloc_strdup(p, p->opts.source_shader);
- p->opts.scale_shader = talloc_strdup(p, p->opts.scale_shader);
- p->opts.pre_shaders = dup_str_array(p, p->opts.pre_shaders);
- p->opts.post_shaders = dup_str_array(p, p->opts.post_shaders);
-
- check_gl_features(p);
- uninit_rendering(p);
+ vo_set_queue_params(vo, 0, p->opts.interpolation, queue_size);
}
struct mp_csp_equalizer *gl_video_eq_ptr(struct gl_video *p)
diff --git a/video/out/gl_video.h b/video/out/gl_video.h
index 4e82215268..840fab211c 100644
--- a/video/out/gl_video.h
+++ b/video/out/gl_video.h
@@ -82,8 +82,7 @@ struct vo_frame;
struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct mpv_global *g);
void gl_video_uninit(struct gl_video *p);
void gl_video_set_osd_source(struct gl_video *p, struct osd_state *osd);
-void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts,
- int *queue_size);
+void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts);
bool gl_video_check_format(struct gl_video *p, int mp_format);
void gl_video_config(struct gl_video *p, struct mp_image_params *params);
void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b);
@@ -110,4 +109,7 @@ bool gl_video_showing_interpolated_frame(struct gl_video *p);
struct gl_hwdec;
void gl_video_set_hwdec(struct gl_video *p, struct gl_hwdec *hwdec);
+struct vo;
+void gl_video_configure_queue(struct gl_video *p, struct vo *vo);
+
#endif
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index b25d162d7b..76276ccfe0 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -293,9 +293,8 @@ static bool reparse_cmdline(struct gl_priv *p, char *args)
}
if (r >= 0) {
- int queue = 1;
- gl_video_set_options(p->renderer, opts->renderer_opts, &queue);
- vo_set_queue_params(p->vo, 0, opts->renderer_opts->interpolation, queue);
+ gl_video_set_options(p->renderer, opts->renderer_opts);
+ gl_video_configure_queue(p->renderer, p->vo);
p->vo->want_redraw = true;
}
@@ -426,9 +425,8 @@ static int preinit(struct vo *vo)
gl_video_set_osd_source(p->renderer, vo->osd);
gl_video_set_output_depth(p->renderer, p->glctx->depth_r, p->glctx->depth_g,
p->glctx->depth_b);
- int queue = 0;
- gl_video_set_options(p->renderer, p->renderer_opts, &queue);
- vo_set_queue_params(p->vo, 0, p->renderer_opts->interpolation, queue);
+ gl_video_set_options(p->renderer, p->renderer_opts);
+ gl_video_configure_queue(p->renderer, vo);
p->cms = gl_lcms_init(p, vo->log, vo->global);
if (!p->cms)
diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c
index 35241de207..fe7ed86d75 100644
--- a/video/out/vo_opengl_cb.c
+++ b/video/out/vo_opengl_cb.c
@@ -329,9 +329,8 @@ int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h)
struct vo_priv *p = vo ? vo->priv : NULL;
struct vo_priv *opts = ctx->new_opts ? ctx->new_opts : p;
if (opts) {
- int queue = 0;
- gl_video_set_options(ctx->renderer, opts->renderer_opts, &queue);
- vo_set_queue_params(vo, 0, opts->renderer_opts->interpolation, queue);
+ gl_video_set_options(ctx->renderer, opts->renderer_opts);
+ gl_video_configure_queue(ctx->renderer, vo);
ctx->gl->debug_context = opts->use_gl_debug;
gl_video_set_debug(ctx->renderer, opts->use_gl_debug);
frame_queue_shrink(ctx, opts->frame_queue_size);