vo: add vo_reconfig2()

1. I want to get away from mp_image_params (maybe).
2. For encoding mode, it's convenient to get the nominal_fps, which is
   a mp_image field, and not in mp_image_params.
This commit is contained in:
wm4 2018-04-22 19:36:16 +02:00 committed by Jan Ekström
parent bfc33da250
commit 8135e25600
3 changed files with 27 additions and 4 deletions

View File

@ -1063,7 +1063,7 @@ void write_video(struct MPContext *mpctx)
info->name, p.w, p.h, extra, mp_imgfmt_to_name(p.imgfmt), sfmt);
MP_VERBOSE(mpctx, "VO: Description: %s\n", info->description);
int vo_r = vo_reconfig(vo, &p);
int vo_r = vo_reconfig2(vo, mpctx->next_frames[0]);
if (vo_r < 0) {
mpctx->error_playing = MPV_ERROR_VO_INIT_FAILED;
goto error;

View File

@ -571,9 +571,11 @@ static void run_reconfig(void *p)
{
void **pp = p;
struct vo *vo = pp[0];
struct mp_image_params *params = pp[1];
struct mp_image *img = pp[1];
int *ret = pp[2];
struct mp_image_params *params = &img->params;
struct vo_internal *in = vo->in;
MP_VERBOSE(vo, "reconfig to %s\n", mp_image_params_to_str(params));
@ -585,7 +587,11 @@ static void run_reconfig(void *p)
talloc_free(vo->params);
vo->params = talloc_dup(vo, params);
*ret = vo->driver->reconfig(vo, vo->params);
if (vo->driver->reconfig2) {
*ret = vo->driver->reconfig2(vo, img);
} else {
*ret = vo->driver->reconfig(vo, vo->params);
}
vo->config_ok = *ret >= 0;
if (vo->config_ok) {
check_vo_caps(vo);
@ -607,7 +613,17 @@ static void run_reconfig(void *p)
int vo_reconfig(struct vo *vo, struct mp_image_params *params)
{
int ret;
void *p[] = {vo, params, &ret};
struct mp_image dummy = {0};
mp_image_set_params(&dummy, params);
void *p[] = {vo, &dummy, &ret};
mp_dispatch_run(vo->in->dispatch, run_reconfig, p);
return ret;
}
int vo_reconfig2(struct vo *vo, struct mp_image *img)
{
int ret;
void *p[] = {vo, img, &ret};
mp_dispatch_run(vo->in->dispatch, run_reconfig, p);
return ret;
}

View File

@ -292,6 +292,12 @@ struct vo_driver {
*/
int (*reconfig)(struct vo *vo, struct mp_image_params *params);
/*
* Like reconfig(), but provides the whole mp_image for which the change is
* required. (The image doesn't have to have real data.)
*/
int (*reconfig2)(struct vo *vo, struct mp_image *img);
/*
* Control interface
*/
@ -440,6 +446,7 @@ struct vo {
struct mpv_global;
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 vo_reconfig2(struct vo *vo, struct mp_image *img);
int vo_control(struct vo *vo, int request, void *data);
void vo_control_async(struct vo *vo, int request, void *data);