summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-15 20:10:11 +0100
committerwm4 <wm4@nowhere>2015-01-15 20:10:11 +0100
commit66c8a87485dbed3c0007ff3a9d509ec985deeb2c (patch)
tree865b0e90db63423cfcb22f2ee3eae62b86993693
parentc118d8f6cc9950ef74d6b5c24bc3a3e56c4b7d42 (diff)
downloadmpv-66c8a87485dbed3c0007ff3a9d509ec985deeb2c.tar.bz2
mpv-66c8a87485dbed3c0007ff3a9d509ec985deeb2c.tar.xz
vo_opengl_cb: initial screenshot support
Support for taking screenshots when doing hardware decoding needs to be added later. This takes the last image queued to the VO, which is logically the image the player thinks is on screen (so e.g. subtitles will match). forget_frames() does not clear this, because seeking does not remove the current image from the screen (until the next one is drawn).
-rw-r--r--video/out/vo_opengl_cb.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c
index 6c7916d7f1..4a0ba3dc54 100644
--- a/video/out/vo_opengl_cb.c
+++ b/video/out/vo_opengl_cb.c
@@ -65,6 +65,7 @@ struct mpv_opengl_cb_context {
mpv_opengl_cb_update_fn update_cb;
void *update_cb_ctx;
struct mp_image *waiting_frame;
+ struct mp_image *displayed_frame;
struct mp_image **frame_queue;
int queued_frames;
struct mp_image_params img_params;
@@ -357,6 +358,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
pthread_mutex_lock(&p->ctx->lock);
mp_image_setrefp(&p->ctx->waiting_frame, mpi);
+ mp_image_setrefp(&p->ctx->displayed_frame, mpi);
talloc_free(mpi);
pthread_mutex_unlock(&p->ctx->lock);
}
@@ -486,6 +488,13 @@ static int control(struct vo *vo, uint32_t request, void *data)
update(p);
pthread_mutex_unlock(&p->ctx->lock);
return VO_TRUE;
+ case VOCTRL_SCREENSHOT: {
+ struct voctrl_screenshot_args *args = data;
+ pthread_mutex_lock(&p->ctx->lock);
+ args->out_image = mp_image_new_ref(p->ctx->displayed_frame);
+ pthread_mutex_unlock(&p->ctx->lock);
+ return VO_TRUE;
+ }
case VOCTRL_SET_COMMAND_LINE: {
char *arg = data;
return reparse_cmdline(p, arg);
@@ -506,6 +515,7 @@ static void uninit(struct vo *vo)
pthread_mutex_lock(&p->ctx->lock);
forget_frames(p->ctx);
+ mp_image_unrefp(&p->ctx->displayed_frame);
p->ctx->img_params = (struct mp_image_params){0};
p->ctx->reconfigured = true;
p->ctx->active = NULL;