diff options
author | Graham Booker <gbooker@plexapp.com> | 2022-10-03 13:58:45 -0500 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-12-08 13:37:26 +0100 |
commit | 4754bd54c7ab22c6c98283d81e22d219b3b64ade (patch) | |
tree | ec1fcd96a9337905c64defcb3e02af3bef937f21 /player/command.c | |
parent | f886eb5678d0ed7eea196e577e04525248963f28 (diff) | |
download | mpv-4754bd54c7ab22c6c98283d81e22d219b3b64ade.tar.bz2 mpv-4754bd54c7ab22c6c98283d81e22d219b3b64ade.tar.xz |
player/command: add ability to scale overlay
Diffstat (limited to 'player/command.c')
-rw-r--r-- | player/command.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/player/command.c b/player/command.c index 1e4b355aed..4197748ac1 100644 --- a/player/command.c +++ b/player/command.c @@ -124,6 +124,7 @@ static const struct m_option udata_type = { struct overlay { struct mp_image *source; int x, y; + int dw, dh; }; struct hook_handler { @@ -4450,8 +4451,8 @@ static void recreate_overlays(struct MPContext *mpctx) struct sub_bitmap b = { .bitmap = s->planes[0], .stride = s->stride[0], - .w = s->w, .dw = s->w, - .h = s->h, .dh = s->h, + .w = s->w, .dw = o->dw, + .h = s->h, .dh = o->dh, .x = o->x, .y = o->y, }; @@ -4548,7 +4549,12 @@ static void cmd_overlay_add(void *pcmd) int offset = cmd->args[4].v.i; char *fmt = cmd->args[5].v.s; int w = cmd->args[6].v.i, h = cmd->args[7].v.i, stride = cmd->args[8].v.i; + int dw = cmd->args[9].v.i, dh = cmd->args[10].v.i; + if (dw <= 0) + dw = w; + if (dh <= 0) + dh = h; if (strcmp(fmt, "bgra") != 0) { MP_ERR(mpctx, "overlay-add: unsupported OSD format '%s'\n", fmt); goto error; @@ -4565,6 +4571,8 @@ static void cmd_overlay_add(void *pcmd) .source = mp_image_alloc(IMGFMT_BGRA, w, h), .x = x, .y = y, + .dw = dw, + .dh = dh, }; if (!overlay.source) goto error; @@ -6719,7 +6727,9 @@ const struct mp_cmd_def mp_cmds[] = { {"fmt", OPT_STRING(v.s)}, {"w", OPT_INT(v.i)}, {"h", OPT_INT(v.i)}, - {"stride", OPT_INT(v.i)}, }}, + {"stride", OPT_INT(v.i)}, + {"dw", OPT_INT(v.i)}, + {"dh", OPT_INT(v.i)}, }}, { "overlay-remove", cmd_overlay_remove, { {"id", OPT_INT(v.i)} } }, { "osd-overlay", cmd_osd_overlay, |