mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
bb9717a630
commit
968bd3df3b
|
@ -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,21 +2817,6 @@ 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);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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);
|
||||
} else {
|
||||
// Oversample case
|
||||
*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);
|
||||
|
@ -2841,6 +2826,28 @@ void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts,
|
|||
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 (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);
|
||||
} else {
|
||||
// Oversample case
|
||||
queue_size = 2;
|
||||
}
|
||||
}
|
||||
|
||||
vo_set_queue_params(vo, 0, p->opts.interpolation, queue_size);
|
||||
}
|
||||
|
||||
struct mp_csp_equalizer *gl_video_eq_ptr(struct gl_video *p)
|
||||
{
|
||||
return &p->video_eq;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue