diff options
author | wm4 <wm4@nowhere> | 2019-10-31 15:44:09 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-10-31 15:44:09 +0100 |
commit | 2c43d2b75a88b8e0e8f0a715f993ffc1c8977d13 (patch) | |
tree | c32e05a5cb48910cbd3ae0f1020f18fcb0adf8b3 /player/screenshot.c | |
parent | 835586513d026bcf1e7dec4693e07c28dda8cedd (diff) | |
download | mpv-2c43d2b75a88b8e0e8f0a715f993ffc1c8977d13.tar.bz2 mpv-2c43d2b75a88b8e0e8f0a715f993ffc1c8977d13.tar.xz |
screenshot, vo_image: use global swscale/zimg parameters
Lots of dumb crap to do... something. Instead of adding yet another dumb
helper, just use the main" sws_utils API in both callers. (Which,
unfortunately, has been duplicated for glorious webp screenshots,
despite the fact that webp is crap.)
Good part: can enable zimg for screenshots (as far as needed).
Bad part: uses "default" swscale parameters instead of HQ now.
Diffstat (limited to 'player/screenshot.c')
-rw-r--r-- | player/screenshot.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/player/screenshot.c b/player/screenshot.c index af06701bbb..eccce16dd6 100644 --- a/player/screenshot.c +++ b/player/screenshot.c @@ -83,7 +83,8 @@ static bool write_screenshot(struct mp_cmd_ctx *cmd, struct mp_image *img, mp_core_unlock(mpctx); - bool ok = img && write_image(img, &opts_copy, filename, mpctx->log); + bool ok = img && write_image(img, &opts_copy, filename, mpctx->global, + mpctx->log); mp_core_lock(mpctx); @@ -370,7 +371,7 @@ static struct mp_image *screenshot_get(struct MPContext *mpctx, int mode, } struct mp_image *convert_image(struct mp_image *image, int destfmt, - struct mp_log *log) + struct mpv_global *global, struct mp_log *log) { int d_w, d_h; mp_image_params_get_dsize(&image->params, &d_w, &d_h); @@ -396,7 +397,14 @@ struct mp_image *convert_image(struct mp_image *image, int destfmt, dst->params = p; - if (mp_image_swscale(dst, image, mp_sws_hq_flags) < 0) { + struct mp_sws_context *sws = mp_sws_alloc(NULL); + sws->log = log; + if (global) + mp_sws_enable_cmdline_opts(sws, global); + bool ok = mp_sws_scale(sws, dst, image) >= 0; + talloc_free(sws); + + if (!ok) { mp_err(log, "Error when converting image.\n"); talloc_free(dst); return NULL; @@ -411,7 +419,8 @@ static struct mp_image *screenshot_get_rgb(struct MPContext *mpctx, int mode) struct mp_image *mpi = screenshot_get(mpctx, mode, false); if (!mpi) return NULL; - struct mp_image *res = convert_image(mpi, IMGFMT_BGR0, mpctx->log); + struct mp_image *res = convert_image(mpi, IMGFMT_BGR0, mpctx->global, + mpctx->log); talloc_free(mpi); return res; } |