diff --git a/video/out/vo.c b/video/out/vo.c index 334cc9958f..66c148135d 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -431,21 +431,11 @@ int vo_reconfig(struct vo *vo, struct mp_image_params *params, int flags) vo->dwidth = d_width; vo->dheight = d_height; - struct mp_image_params p2 = *params; - talloc_free(vo->params); - vo->params = talloc_memdup(vo, &p2, sizeof(p2));; + vo->params = talloc_memdup(vo, params, sizeof(*params)); - int ret; - if (vo->driver->reconfig) { - ret = vo->driver->reconfig(vo, &p2, flags); - } else { - // Old config() takes window size, while reconfig() takes aspect (!) - ret = vo->driver->config(vo, p2.w, p2.h, d_width, d_height, flags, - p2.imgfmt); - ret = ret ? -1 : 0; - } - vo->config_ok = (ret >= 0); + int ret = vo->driver->reconfig(vo, vo->params, flags); + vo->config_ok = ret >= 0; vo->config_count += vo->config_ok; if (!vo->config_ok) { talloc_free(vo->params); diff --git a/video/out/vo.h b/video/out/vo.h index df5ef5ecd9..47c6a1ed96 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -155,20 +155,6 @@ struct vo_driver { /* * Initialize or reconfigure the display driver. - * width,height: image source size - * d_width,d_height: requested window size, just a hint - * flags: combination of VOFLAG_ values - * title: window title, if available - * format: fourcc of pixel format - * returns : zero on successful initialization, non-zero on error. - */ - int (*config)(struct vo *vo, uint32_t width, uint32_t height, - uint32_t d_width, uint32_t d_height, uint32_t flags, - uint32_t format); - - /* - * Initialize or reconfigure the display driver. Alternative to config(), - * and can carry more image parameters. * params: video parameters, like pixel format and frame size * flags: combination of VOFLAG_ values * returns: < 0 on error, >= 0 on success diff --git a/video/out/vo_caca.c b/video/out/vo_caca.c index 13885b510e..9cc6835c9a 100644 --- a/video/out/vo_caca.c +++ b/video/out/vo_caca.c @@ -83,7 +83,7 @@ static int resize(struct vo *vo) rmask, gmask, bmask, amask); if (dither == NULL) { MP_FATAL(vo, "caca_create_dither failed!\n"); - return ENOSYS; + return -1; } dither_buffer = talloc_array(NULL, uint8_t, depth * image_width * image_height); @@ -97,13 +97,11 @@ static int resize(struct vo *vo) return 0; } -static int config(struct vo *vo, uint32_t width, uint32_t height, - uint32_t d_width, uint32_t d_height, uint32_t flags, - uint32_t format) +static int reconfig(struct vo *vo, struct mp_image_params *params, int flags) { - image_height = height; - image_width = width; - image_format = format; + image_height = params->h; + image_width = params->w; + image_format = params->imgfmt; return resize(vo); } @@ -290,7 +288,7 @@ const struct vo_driver video_out_caca = { .description = "libcaca", .preinit = preinit, .query_format = query_format, - .config = config, + .reconfig = reconfig, .control = control, .draw_image = draw_image, .flip_page = flip_page, diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c index eae04eecb8..0dde474f62 100644 --- a/video/out/vo_direct3d.c +++ b/video/out/vo_direct3d.c @@ -1260,19 +1260,7 @@ static int control(struct vo *vo, uint32_t request, void *data) return r; } -/** @brief libvo Callback: Configre the Direct3D adapter. - * @param width Movie source width - * @param height Movie source height - * @param d_width Screen (destination) width - * @param d_height Screen (destination) height - * @param options Options bitmap - * @param format Movie colorspace format (using MPlayer's - * defines, e.g. IMGFMT_YUYV) - * @return 0 on success, VO_ERROR on failure - */ -static int config(struct vo *vo, uint32_t width, uint32_t height, - uint32_t d_width, uint32_t d_height, uint32_t options, - uint32_t format) +static int reconfig(struct vo *vo, struct mp_image_params *params, int flags) { d3d_priv *priv = vo->priv; @@ -1281,20 +1269,20 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, /* w32_common framework call. Creates window on the screen with * the given coordinates. */ - if (!vo_w32_config(vo, d_width, d_height, options)) { + if (!vo_w32_config(vo, vo->dwidth, vo->dheight, flags)) { MP_VERBOSE(priv, "Creating window failed.\n"); return VO_ERROR; } - if ((priv->image_format != format) - || (priv->src_width != width) - || (priv->src_height != height)) + if ((priv->image_format != params->imgfmt) + || (priv->src_width != params->w) + || (priv->src_height != params->h)) { d3d_destroy_video_objects(priv); - priv->src_width = width; - priv->src_height = height; - init_rendering_mode(priv, format, true); + priv->src_width = params->w; + priv->src_height = params->h; + init_rendering_mode(priv, params->imgfmt, true); } if (!resize_d3d(priv)) @@ -1737,7 +1725,7 @@ const struct vo_driver video_out_direct3d = { .name = "direct3d", .preinit = preinit, .query_format = query_format, - .config = config, + .reconfig = reconfig, .control = control, .draw_image = draw_image, .draw_osd = draw_osd, @@ -1753,7 +1741,7 @@ const struct vo_driver video_out_direct3d_shaders = { .name = "direct3d_shaders", .preinit = preinit, .query_format = query_format, - .config = config, + .reconfig = reconfig, .control = control, .draw_image = draw_image, .draw_osd = draw_osd, diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c index fe5bbcf775..e96556b1e8 100644 --- a/video/out/vo_lavc.c +++ b/video/out/vo_lavc.c @@ -89,20 +89,20 @@ static void uninit(struct vo *vo) vo->priv = NULL; } -static int config(struct vo *vo, uint32_t width, uint32_t height, - uint32_t d_width, uint32_t d_height, uint32_t flags, - uint32_t format) +static int reconfig(struct vo *vo, struct mp_image_params *params, int flags) { struct priv *vc = vo->priv; - enum AVPixelFormat pix_fmt = imgfmt2pixfmt(format); + enum AVPixelFormat pix_fmt = imgfmt2pixfmt(params->imgfmt); AVRational display_aspect_ratio, image_aspect_ratio; AVRational aspect; + uint32_t width = params->w; + uint32_t height = params->h; if (!vc) return -1; - display_aspect_ratio.num = d_width; - display_aspect_ratio.den = d_height; + display_aspect_ratio.num = params->d_w; + display_aspect_ratio.den = params->d_h; image_aspect_ratio.num = width; image_aspect_ratio.den = height; aspect = av_div_q(display_aspect_ratio, image_aspect_ratio); @@ -137,7 +137,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, if (pix_fmt == AV_PIX_FMT_NONE) { MP_FATAL(vo, "Format %s not supported by lavc.\n", - mp_imgfmt_to_name(format)); + mp_imgfmt_to_name(params->imgfmt)); goto error; } @@ -524,7 +524,7 @@ const struct vo_driver video_out_lavc = { .name = "lavc", .preinit = preinit, .query_format = query_format, - .config = config, + .reconfig = reconfig, .control = control, .uninit = uninit, .draw_image = draw_image, diff --git a/video/out/vo_null.c b/video/out/vo_null.c index b59eb13e81..8d8d95d065 100644 --- a/video/out/vo_null.c +++ b/video/out/vo_null.c @@ -43,9 +43,7 @@ static int query_format(struct vo *vo, uint32_t format) return VFCAP_CSP_SUPPORTED; } -static int config(struct vo *vo, uint32_t width, uint32_t height, - uint32_t d_width, uint32_t d_height, uint32_t flags, - uint32_t format) +static int reconfig(struct vo *vo, struct mp_image_params *params, int flags) { return 0; } @@ -69,7 +67,7 @@ const struct vo_driver video_out_null = { .name = "null", .preinit = preinit, .query_format = query_format, - .config = config, + .reconfig = reconfig, .control = control, .draw_image = draw_image, .flip_page = flip_page, diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c index 0d877c5946..9ebf6c4c0e 100644 --- a/video/out/vo_opengl_old.c +++ b/video/out/vo_opengl_old.c @@ -1709,30 +1709,28 @@ static bool config_window(struct vo *vo, uint32_t d_width, uint32_t d_height, return mpgl_config_window(p->glctx, mpgl_caps, d_width, d_height, flags); } -static int config(struct vo *vo, uint32_t width, uint32_t height, - uint32_t d_width, uint32_t d_height, uint32_t flags, - uint32_t format) +static int reconfig(struct vo *vo, struct mp_image_params *params, int flags) { struct gl_priv *p = vo->priv; - struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(format); + struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(params->imgfmt); - p->image_height = height; - p->image_width = width; - p->image_format = format; + p->image_height = params->h; + p->image_width = params->w; + p->image_format = params->imgfmt; p->is_yuv = !!(desc.flags & MP_IMGFLAG_YUV_P); p->is_yuv |= (desc.chroma_xs << 8) | (desc.chroma_ys << 16); - if (format == IMGFMT_Y8) + if (p->image_format == IMGFMT_Y8) p->is_yuv = 0; - glFindFormat(format, p->have_texture_rg, NULL, &p->texfmt, &p->gl_format, - &p->gl_type); + glFindFormat(p->image_format, p->have_texture_rg, NULL, &p->texfmt, + &p->gl_format, &p->gl_type); p->vo_flipped = !!(flags & VOFLAG_FLIPPING); if (vo->config_count) uninitGl(vo); - if (!config_window(vo, d_width, d_height, flags)) + if (!config_window(vo, vo->dwidth, vo->dheight, flags)) return -1; initGl(vo, vo->dwidth, vo->dheight); @@ -2165,7 +2163,7 @@ const struct vo_driver video_out_opengl_old = { .name = "opengl-old", .preinit = preinit, .query_format = query_format, - .config = config, + .reconfig = reconfig, .control = control, .draw_image = draw_image, .draw_osd = draw_osd, diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 3f743a17a4..915909578e 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -398,11 +398,11 @@ static void set_fullscreen(struct vo *vo) force_resize(vo); } -static int config(struct vo *vo, uint32_t width, uint32_t height, - uint32_t d_width, uint32_t d_height, uint32_t flags, - uint32_t format) +static int reconfig(struct vo *vo, struct mp_image_params *params, int flags) { struct priv *vc = vo->priv; + int win_w = vo->dwidth; + int win_h = vo->dheight; if (vc->reinit_renderer) { destroy_renderer(vo); @@ -410,9 +410,9 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, } if (vc->window) - SDL_SetWindowSize(vc->window, d_width, d_height); + SDL_SetWindowSize(vc->window, win_w, win_h); else { - if (init_renderer(vo, d_width, d_height) != 0) + if (init_renderer(vo, win_w, win_h) != 0) return -1; } @@ -432,14 +432,15 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, vc->tex_swapped = texfmt == SDL_PIXELFORMAT_YV12; vc->tex = SDL_CreateTexture(vc->renderer, texfmt, - SDL_TEXTUREACCESS_STREAMING, width, height); + SDL_TEXTUREACCESS_STREAMING, + params->w, params->h); if (!vc->tex) { MP_ERR(vo, "Could not create a texture\n"); return -1; } mp_image_t *texmpi = &vc->texmpi; - mp_image_set_size(texmpi, width, height); + mp_image_set_size(texmpi, params->w, params->h); mp_image_setfmt(texmpi, format); switch (texmpi->num_planes) { case 1: @@ -452,7 +453,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, return -1; } - resize(vo, d_width, d_height); + resize(vo, win_w, win_h); SDL_DisableScreenSaver(); @@ -1011,7 +1012,7 @@ const struct vo_driver video_out_sdl = { }, .preinit = preinit, .query_format = query_format, - .config = config, + .reconfig = reconfig, .control = control, .draw_image = draw_image, .uninit = uninit, diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index 90460a9ff4..0385d0505a 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -781,9 +781,7 @@ static bool status_ok(struct vo *vo) * connect to X server, create and map window, initialize all * VDPAU objects, create different surfaces etc. */ -static int config(struct vo *vo, uint32_t width, uint32_t height, - uint32_t d_width, uint32_t d_height, uint32_t flags, - uint32_t format) +static int reconfig(struct vo *vo, struct mp_image_params *params, int flags) { struct vdpctx *vc = vo->priv; @@ -791,17 +789,17 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, return -1; vc->flip = flags & VOFLAG_FLIPPING; - vc->image_format = format; - vc->vid_width = width; - vc->vid_height = height; + vc->image_format = params->imgfmt; + vc->vid_width = params->w; + vc->vid_height = params->h; - vc->rgb_mode = get_rgb_format(format) >= 0; + vc->rgb_mode = get_rgb_format(params->imgfmt) >= 0; vc->deint = vc->rgb_mode ? 0 : vc->user_deint; free_video_specific(vo); - vo_x11_config_vo_window(vo, NULL, d_width, d_height, flags, "vdpau"); + vo_x11_config_vo_window(vo, NULL, vo->dwidth, vo->dheight, flags, "vdpau"); if (initialize_vdpau_objects(vo) < 0) return -1; @@ -1513,7 +1511,7 @@ const struct vo_driver video_out_vdpau = { .name = "vdpau", .preinit = preinit, .query_format = query_format, - .config = config, + .reconfig = reconfig, .control = control, .draw_image = draw_image, .get_buffered_frame = set_next_frame_info, diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index 9f63c2ba49..d9995ffa96 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -417,12 +417,10 @@ static void resize(struct vo *vo) } /* - * connect to server, create and map window, + * create and map window, * allocate colors and (shared) memory */ -static int config(struct vo *vo, uint32_t width, uint32_t height, - uint32_t d_width, uint32_t d_height, uint32_t flags, - uint32_t format) +static int reconfig(struct vo *vo, struct mp_image_params *params, int flags) { struct vo_x11_state *x11 = vo->x11; struct xvctx *ctx = vo->priv; @@ -430,9 +428,9 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, mp_image_unrefp(&ctx->original_image); - ctx->image_height = height; - ctx->image_width = width; - ctx->image_format = format; + ctx->image_height = params->h; + ctx->image_width = params->w; + ctx->image_format = params->imgfmt; if ((ctx->max_width != 0 && ctx->max_height != 0) && (ctx->image_width > ctx->max_width @@ -449,7 +447,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, MP_VERBOSE(vo, "Xvideo image format: 0x%x (%4.4s) %s\n", ctx->fo[i].id, (char *) &ctx->fo[i].id, (ctx->fo[i].format == XvPacked) ? "packed" : "planar"); - if (ctx->fo[i].id == find_xv_format(format)) + if (ctx->fo[i].id == find_xv_format(ctx->image_format)) ctx->xv_format = ctx->fo[i].id; } if (!ctx->xv_format) @@ -889,7 +887,7 @@ const struct vo_driver video_out_xv = { .name = "xv", .preinit = preinit, .query_format = query_format, - .config = config, + .reconfig = reconfig, .control = control, .draw_image = draw_image, .draw_osd = draw_osd,