aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/out
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2018-04-20 17:05:53 +0200
committerGravatar wm4 <wm4@nowhere>2018-04-20 17:05:53 +0200
commit6435d9ae7f3afe88ad2dbaad378335185acecd38 (patch)
tree51c4a7ade0348a61f34cdfbe91823e58db56d9ed /video/out
parent2e768ad0d89e6a787187b2831914b46f449d4fc0 (diff)
vo_gpu: move some extra code for screenshot to video.c
This also happens to fix some UB on the error path (target being declared after the first "goto done;").
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gpu/video.c19
-rw-r--r--video/out/vo_gpu.c9
2 files changed, 15 insertions, 13 deletions
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c
index 693a3f274d..aeaff7a3b1 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -3169,15 +3169,23 @@ done:
void gl_video_screenshot(struct gl_video *p, struct vo_frame *frame,
struct voctrl_screenshot *args)
{
- bool ok = false;
- struct mp_image *res = NULL;
-
if (!p->ra->fns->tex_download)
return;
+ bool ok = false;
+ struct mp_image *res = NULL;
+ struct ra_tex *target = NULL;
struct mp_rect old_src = p->src_rect;
struct mp_rect old_dst = p->dst_rect;
struct mp_osd_res old_osd = p->osd_rect;
+ struct vo_frame *nframe = vo_frame_ref(frame);
+
+ // Disable interpolation and such.
+ nframe->redraw = true;
+ nframe->repeat = false;
+ nframe->still = true;
+ nframe->pts = 0;
+ nframe->duration = -1;
if (!args->scaled) {
int w, h;
@@ -3216,7 +3224,7 @@ void gl_video_screenshot(struct gl_video *p, struct vo_frame *frame,
if (!params.format || !params.format->renderable)
goto done;
- struct ra_tex *target = ra_tex_create(p->ra, &params);
+ target = ra_tex_create(p->ra, &params);
if (!target)
goto done;
@@ -3225,7 +3233,7 @@ void gl_video_screenshot(struct gl_video *p, struct vo_frame *frame,
flags |= RENDER_FRAME_SUBS;
if (args->osd)
flags |= RENDER_FRAME_OSD;
- gl_video_render_frame(p, frame, (struct ra_fbo){target}, flags);
+ gl_video_render_frame(p, nframe, (struct ra_fbo){target}, flags);
res = mp_image_alloc(mpfmt, params.w, params.h);
if (!res)
@@ -3244,6 +3252,7 @@ void gl_video_screenshot(struct gl_video *p, struct vo_frame *frame,
ok = true;
done:
+ talloc_free(nframe);
ra_tex_free(p->ra, &target);
gl_video_resize(p, &old_src, &old_dst, &old_osd);
if (!ok)
diff --git a/video/out/vo_gpu.c b/video/out/vo_gpu.c
index 61696af0e4..a80ba233c2 100644
--- a/video/out/vo_gpu.c
+++ b/video/out/vo_gpu.c
@@ -178,15 +178,8 @@ static int control(struct vo *vo, uint32_t request, void *data)
return VO_TRUE;
case VOCTRL_SCREENSHOT: {
struct vo_frame *frame = vo_get_current_vo_frame(vo);
- if (frame) {
- // Disable interpolation and such.
- frame->redraw = true;
- frame->repeat = false;
- frame->still = true;
- frame->pts = 0;
- frame->duration = -1;
+ if (frame)
gl_video_screenshot(p->renderer, frame, data);
- }
talloc_free(frame);
return true;
}