mirror of
https://github.com/mpv-player/mpv
synced 2025-02-17 04:58:06 +00:00
video: pass some VO params as struct
Not particularly elegant, but better than adding more and more stuff to the relevant function signatures.
This commit is contained in:
parent
f5b314e9e8
commit
282e3202d5
@ -452,9 +452,12 @@ int mp_initialize(struct MPContext *mpctx)
|
||||
|
||||
if (opts->force_vo) {
|
||||
opts->fixed_vo = 1;
|
||||
mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input,
|
||||
mpctx->osd,
|
||||
mpctx->encode_lavc_ctx);
|
||||
struct vo_extra ex = {
|
||||
.input_ctx = mpctx->input,
|
||||
.osd = mpctx->osd,
|
||||
.encode_lavc_ctx = mpctx->encode_lavc_ctx,
|
||||
};
|
||||
mpctx->video_out = init_best_video_out(mpctx->global, &ex);
|
||||
if (!mpctx->video_out) {
|
||||
MP_FATAL(mpctx, "Error opening/initializing "
|
||||
"the selected video_out (-vo) device.\n");
|
||||
|
@ -265,9 +265,12 @@ int reinit_video_chain(struct MPContext *mpctx)
|
||||
|
||||
//================== Init VIDEO (codec & libvo) ==========================
|
||||
if (!opts->fixed_vo || !mpctx->video_out) {
|
||||
mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input,
|
||||
mpctx->osd,
|
||||
mpctx->encode_lavc_ctx);
|
||||
struct vo_extra ex = {
|
||||
.input_ctx = mpctx->input,
|
||||
.osd = mpctx->osd,
|
||||
.encode_lavc_ctx = mpctx->encode_lavc_ctx,
|
||||
};
|
||||
mpctx->video_out = init_best_video_out(mpctx->global, &ex);
|
||||
if (!mpctx->video_out) {
|
||||
MP_FATAL(mpctx, "Error opening/initializing "
|
||||
"the selected video_out (-vo) device.\n");
|
||||
|
@ -203,9 +203,7 @@ static void dealloc_vo(struct vo *vo)
|
||||
}
|
||||
|
||||
static struct vo *vo_create(bool probing, struct mpv_global *global,
|
||||
struct input_ctx *input_ctx, struct osd_state *osd,
|
||||
struct encode_lavc_context *encode_lavc_ctx,
|
||||
char *name, char **args)
|
||||
struct vo_extra *ex, char *name, char **args)
|
||||
{
|
||||
struct mp_log *log = mp_log_new(NULL, global->log, "vo");
|
||||
struct m_obj_desc desc;
|
||||
@ -220,11 +218,12 @@ static struct vo *vo_create(bool probing, struct mpv_global *global,
|
||||
.driver = desc.p,
|
||||
.opts = &global->opts->vo,
|
||||
.global = global,
|
||||
.encode_lavc_ctx = encode_lavc_ctx,
|
||||
.input_ctx = input_ctx,
|
||||
.osd = osd,
|
||||
.encode_lavc_ctx = ex->encode_lavc_ctx,
|
||||
.input_ctx = ex->input_ctx,
|
||||
.osd = ex->osd,
|
||||
.event_fd = -1,
|
||||
.monitor_par = 1,
|
||||
.extra = *ex,
|
||||
.probing = probing,
|
||||
.in = talloc(vo, struct vo_internal),
|
||||
};
|
||||
@ -260,10 +259,7 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct vo *init_best_video_out(struct mpv_global *global,
|
||||
struct input_ctx *input_ctx,
|
||||
struct osd_state *osd,
|
||||
struct encode_lavc_context *encode_lavc_ctx)
|
||||
struct vo *init_best_video_out(struct mpv_global *global, struct vo_extra *ex)
|
||||
{
|
||||
struct m_obj_settings *vo_list = global->opts->vo.video_driver_list;
|
||||
// first try the preferred drivers, with their optional subdevice param:
|
||||
@ -273,8 +269,8 @@ struct vo *init_best_video_out(struct mpv_global *global,
|
||||
if (strlen(vo_list[n].name) == 0)
|
||||
goto autoprobe;
|
||||
bool p = !!vo_list[n + 1].name;
|
||||
struct vo *vo = vo_create(p, global, input_ctx, osd, encode_lavc_ctx,
|
||||
vo_list[n].name, vo_list[n].attribs);
|
||||
struct vo *vo = vo_create(p, global, ex, vo_list[n].name,
|
||||
vo_list[n].attribs);
|
||||
if (vo)
|
||||
return vo;
|
||||
}
|
||||
@ -283,8 +279,8 @@ struct vo *init_best_video_out(struct mpv_global *global,
|
||||
autoprobe:
|
||||
// now try the rest...
|
||||
for (int i = 0; video_out_drivers[i]; i++) {
|
||||
struct vo *vo = vo_create(true, global, input_ctx, osd, encode_lavc_ctx,
|
||||
(char *)video_out_drivers[i]->name, NULL);
|
||||
char *name = (char *)video_out_drivers[i]->name;
|
||||
struct vo *vo = vo_create(true, global, ex, name, NULL);
|
||||
if (vo)
|
||||
return vo;
|
||||
}
|
||||
|
@ -165,6 +165,12 @@ struct osd_state;
|
||||
struct mp_image;
|
||||
struct mp_image_params;
|
||||
|
||||
struct vo_extra {
|
||||
struct input_ctx *input_ctx;
|
||||
struct osd_state *osd;
|
||||
struct encode_lavc_context *encode_lavc_ctx;
|
||||
};
|
||||
|
||||
struct vo_driver {
|
||||
// Encoding functionality, which can be invoked via --o only.
|
||||
bool encode;
|
||||
@ -273,6 +279,7 @@ struct vo {
|
||||
struct encode_lavc_context *encode_lavc_ctx;
|
||||
struct vo_internal *in;
|
||||
struct mp_vo_opts *opts;
|
||||
struct vo_extra extra;
|
||||
|
||||
// --- The following fields are generally only changed during initialization.
|
||||
|
||||
@ -297,10 +304,7 @@ struct vo {
|
||||
};
|
||||
|
||||
struct mpv_global;
|
||||
struct vo *init_best_video_out(struct mpv_global *global,
|
||||
struct input_ctx *input_ctx,
|
||||
struct osd_state *osd,
|
||||
struct encode_lavc_context *encode_lavc_ctx);
|
||||
struct vo *init_best_video_out(struct mpv_global *global, struct vo_extra *ex);
|
||||
int vo_reconfig(struct vo *vo, struct mp_image_params *p, int flags);
|
||||
|
||||
int vo_control(struct vo *vo, uint32_t request, void *data);
|
||||
|
Loading…
Reference in New Issue
Block a user