summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-08 01:35:44 +0200
committerwm4 <wm4@nowhere>2013-06-28 20:34:46 +0200
commit3382a6f6e48c7e093c2b7e0e4a0e28b60a084358 (patch)
treecc50df6d6ae5ffa6b1f7d3eb4e816a3afcfd1641 /video/out
parent823e0c511bea235be06d5e2037ef9d0b345d9405 (diff)
downloadmpv-3382a6f6e48c7e093c2b7e0e4a0e28b60a084358.tar.bz2
mpv-3382a6f6e48c7e093c2b7e0e4a0e28b60a084358.tar.xz
video: add a new method to configure filters and VOs
The filter chain and the video ouputs have config() functions. They are strictly limited to transfering the video size and format. Other parameters (like color levels) have to be transferred separately. Improve upon this by introducing a separate set of reconfig() functions, which use mp_image_params to carry format parameters. This struct contains all image format related parameters from config(), plus additional parameters such as colorspace. Change vf_rotate to use it, as well as vo_opengl. vf_rotate is just an example/test case, but vo_opengl will need it later. The intention is also to get rid of VOCTRL_SET_YUV_COLORSPACE. This information is now handed to the VOs via reconfig(). The getter, VOCTRL_GET_YUV_COLORSPACE, will still be needed though.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gl_video.c16
-rw-r--r--video/out/gl_video.h2
-rw-r--r--video/out/vo.c29
-rw-r--r--video/out/vo.h37
-rw-r--r--video/out/vo_opengl.c13
5 files changed, 58 insertions, 39 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 4d780f41d8..658c531546 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -1848,17 +1848,19 @@ bool gl_video_check_format(int mp_format)
return init_format(mp_format, NULL);
}
-void gl_video_config(struct gl_video *p, int format, int w, int h, int dw, int dh)
+void gl_video_config(struct gl_video *p, struct mp_image_params *params)
{
- if (p->image_format != format || p->image_w != w || p->image_h != h) {
+ if (p->image_format != params->imgfmt || p->image_w != params->w ||
+ p->image_h != params->h)
+ {
uninit_video(p);
- p->image_w = w;
- p->image_h = h;
- init_format(format, p);
+ p->image_w = params->w;
+ p->image_h = params->h;
+ init_format(params->imgfmt, p);
init_video(p);
}
- p->image_dw = dw;
- p->image_dh = dh;
+ p->image_dw = params->d_w;
+ p->image_dh = params->d_h;
}
void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b)
diff --git a/video/out/gl_video.h b/video/out/gl_video.h
index 0d796502bb..289ccddf52 100644
--- a/video/out/gl_video.h
+++ b/video/out/gl_video.h
@@ -54,7 +54,7 @@ struct gl_video;
struct gl_video *gl_video_init(GL *gl);
void gl_video_uninit(struct gl_video *p);
void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts);
-void gl_video_config(struct gl_video *p, int format, int w, int h, int dw, int dh);
+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);
void gl_video_set_lut3d(struct gl_video *p, struct lut3d *lut3d);
void gl_video_draw_osd(struct gl_video *p, struct osd_state *osd);
diff --git a/video/out/vo.c b/video/out/vo.c
index c621f37472..02d51bf7b6 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -406,21 +406,34 @@ static int event_fd_callback(void *ctx, int fd)
return MP_INPUT_NOTHING;
}
-int vo_config(struct vo *vo, uint32_t width, uint32_t height,
- uint32_t d_width, uint32_t d_height, uint32_t flags,
- uint32_t format)
+int vo_reconfig(struct vo *vo, struct mp_image_params *params, int flags)
{
- aspect_save_videores(vo, width, height, d_width, d_height);
+ int d_width = params->d_w;
+ int d_height = params->d_h;
+ aspect_save_videores(vo, params->w, params->h, d_width, d_height);
if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
- determine_window_geometry(vo, d_width, d_height);
+ determine_window_geometry(vo, params->d_w, params->d_h);
d_width = vo->dwidth;
d_height = vo->dheight;
}
+ vo->dwidth = d_width;
+ vo->dheight = d_height;
- int ret = vo->driver->config(vo, width, height, d_width, d_height, flags,
- format);
- vo->config_ok = (ret == 0);
+ struct mp_image_params p2 = *params;
+ p2.d_w = vo->aspdat.prew;
+ p2.d_h = vo->aspdat.preh;
+
+ 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);
vo->config_count += vo->config_ok;
if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) {
mp_input_add_key_fd(vo->input_ctx, vo->event_fd, 1, event_fd_callback,
diff --git a/video/out/vo.h b/video/out/vo.h
index df16a01d0e..9f4d2a9060 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -47,8 +47,8 @@ enum mp_voctrl {
VOCTRL_GET_PANSCAN,
VOCTRL_SET_PANSCAN,
- VOCTRL_SET_EQUALIZER, // struct voctrl_set_equalizer_args
- VOCTRL_GET_EQUALIZER, // struct voctrl_get_equalizer_args
+ VOCTRL_SET_EQUALIZER, // struct voctrl_set_equalizer_args*
+ VOCTRL_GET_EQUALIZER, // struct voctrl_get_equalizer_args*
/* for vdpau hardware decoding */
VOCTRL_HWDEC_DECODER_RENDER, // pointer to hw state
@@ -62,7 +62,7 @@ enum mp_voctrl {
VOCTRL_BORDER,
VOCTRL_UPDATE_WINDOW_TITLE, // char*
- VOCTRL_SET_CURSOR_VISIBILITY, // bool
+ VOCTRL_SET_CURSOR_VISIBILITY, // bool*
VOCTRL_KILL_SCREENSAVER,
VOCTRL_RESTORE_SCREENSAVER,
@@ -72,12 +72,12 @@ enum mp_voctrl {
VOCTRL_UPDATE_SCREENINFO,
- VOCTRL_SET_YUV_COLORSPACE, // struct mp_csp_details
- VOCTRL_GET_YUV_COLORSPACE, // struct mp_csp_details
+ VOCTRL_SET_YUV_COLORSPACE, // struct mp_csp_details*
+ VOCTRL_GET_YUV_COLORSPACE, // struct mp_csp_details*
- VOCTRL_SCREENSHOT, // struct voctrl_screenshot_args
+ VOCTRL_SCREENSHOT, // struct voctrl_screenshot_args*
- VOCTRL_SET_COMMAND_LINE, // char*
+ VOCTRL_SET_COMMAND_LINE, // char**
};
// VOCTRL_SET_EQUALIZER
@@ -139,6 +139,7 @@ typedef struct vo_info_s
struct vo;
struct osd_state;
struct mp_image;
+struct mp_image_params;
struct vo_driver {
// Driver buffers or adds (deinterlace) frames and will keep track
@@ -164,20 +165,28 @@ struct vo_driver {
int (*query_format)(struct vo *vo, uint32_t format);
/*
- * Initialize (means CONFIGURE) the display driver.
- * params:
+ * Initialize or reconfigure the display driver.
* width,height: image source size
- * d_width,d_height: size of the requested window size, just a hint
- * fullscreen: flag, 0=windowd 1=fullscreen, just a hint
+ * 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 fullscreen,
+ 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
+ */
+ int (*reconfig)(struct vo *vo, struct mp_image_params *params, int flags);
+
+ /*
* Control interface
*/
int (*control)(struct vo *vo, uint32_t request, void *data);
@@ -284,9 +293,7 @@ struct vo *init_best_video_out(struct mp_vo_opts *opts,
struct mp_fifo *key_fifo,
struct input_ctx *input_ctx,
struct encode_lavc_context *encode_lavc_ctx);
-int vo_config(struct vo *vo, uint32_t width, uint32_t height,
- uint32_t d_width, uint32_t d_height, uint32_t flags,
- uint32_t format);
+int vo_reconfig(struct vo *vo, struct mp_image_params *p, int flags);
void list_video_out(void);
int vo_control(struct vo *vo, uint32_t request, void *data);
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 35ea0cebb0..882689ed87 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -163,15 +163,13 @@ static void video_resize_redraw_callback(struct vo *vo, int w, int h)
}
-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;
mpgl_lock(p->glctx);
- if (!config_window(p, d_width, d_height, flags)) {
+ if (!config_window(p, vo->dwidth, vo->dheight, flags)) {
mpgl_unlock(p->glctx);
return -1;
}
@@ -180,8 +178,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
p->glctx->register_resize_callback(vo, video_resize_redraw_callback);
}
- gl_video_config(p->renderer, format, width, height,
- p->vo->aspdat.prew, p->vo->aspdat.preh);
+ gl_video_config(p->renderer, params);
p->vo_flipped = !!(flags & VOFLAG_FLIPPING);
@@ -378,7 +375,7 @@ const struct vo_driver video_out_opengl = {
},
.preinit = preinit,
.query_format = query_format,
- .config = config,
+ .reconfig = reconfig,
.control = control,
.draw_image = draw_image,
.draw_osd = draw_osd,
@@ -398,7 +395,7 @@ const struct vo_driver video_out_opengl_hq = {
},
.preinit = preinit,
.query_format = query_format,
- .config = config,
+ .reconfig = reconfig,
.control = control,
.draw_image = draw_image,
.draw_osd = draw_osd,