From 10a1ae7b720b7b116c98f78d611c92923559620e Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 21 Nov 2012 19:56:25 +0100 Subject: [PATCH] screenshot: add subs even with vf_screenshot Until now, screenshots with the video filter didn't add subs (unclear whether that was an oversight or feature). Fix this and make behavior when taking screenshots with vf_screenshot more consistent with VO screenshots. The change in vf_screenshot is needed, because add_subs() checks this flag to decide whether it's allowed to mutate the image. This commit has another user visible side effect. When taking a screenshot each frame (using the "each-frame" mode of the screenshot command), a normal screenshot command will stop the each-frame mode. --- core/screenshot.c | 16 +++++++++++----- video/filter/vf_screenshot.c | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/screenshot.c b/core/screenshot.c index 09f1aa7ee6..8e16771289 100644 --- a/core/screenshot.c +++ b/core/screenshot.c @@ -290,9 +290,11 @@ static void vf_screenshot_callback(void *pctx, struct mp_image *image) { struct MPContext *mpctx = (struct MPContext *)pctx; screenshot_ctx *ctx = mpctx->screenshot_ctx; - screenshot_save(mpctx, image, ctx->mode); - if (ctx->each_frame) - screenshot_request(mpctx, ctx->mode, false); + screenshot_save(mpctx, image, ctx->mode == MODE_SUBTITLES); + if (ctx->each_frame) { + ctx->each_frame = false; + screenshot_request(mpctx, ctx->mode, true); + } } static bool force_vf(struct MPContext *mpctx) @@ -320,11 +322,14 @@ void screenshot_request(struct MPContext *mpctx, int mode, bool each_frame) if (each_frame) { ctx->each_frame = !ctx->each_frame; - ctx->mode = mode; if (!ctx->each_frame) return; + } else { + ctx->each_frame = false; } + ctx->mode = mode; + struct voctrl_screenshot_args args = { .full_window = (mode == MODE_FULL_WINDOW) }; if (!force_vf(mpctx) @@ -365,5 +370,6 @@ void screenshot_flip(struct MPContext *mpctx) if (ctx->using_vf_screenshot) return; - screenshot_request(mpctx, ctx->mode, false); + ctx->each_frame = false; + screenshot_request(mpctx, ctx->mode, true); } diff --git a/video/filter/vf_screenshot.c b/video/filter/vf_screenshot.c index e4ba696f69..bb5ca517a0 100644 --- a/video/filter/vf_screenshot.c +++ b/video/filter/vf_screenshot.c @@ -139,6 +139,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) image = *dmpi; else image = *vf->priv->image; + image.flags &= ~MP_IMGFLAG_ALLOCATED; image.w = vf->priv->image->w; image.h = vf->priv->image->h; vf_clone_mpi_attributes(&image, mpi);