Mercurial > mplayer.hg
changeset 32392:7fd2de8d6f32
Add the overlay_add and overlay_remove commands.
author | cigaes |
---|---|
date | Sun, 10 Oct 2010 09:30:42 +0000 |
parents | b4c3659d16b1 |
children | 98fda5253e80 |
files | DOCS/tech/slave.txt command.c input/input.c input/input.h |
diffstat | 4 files changed, 87 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/tech/slave.txt Sun Oct 10 09:27:11 2010 +0000 +++ b/DOCS/tech/slave.txt Sun Oct 10 09:30:42 2010 +0000 @@ -472,6 +472,13 @@ volume <value> [abs] Increase/decrease volume or set it to <value> if [abs] is nonzero. +overlay_add <file> <id> <x> <y> <color> + Add an overlay bitmap. <file> must be a PGM file without comments. + <id> is an arbitrary integer used to identify the overlay. + +overlay_remove <id> + Remove all overlays identified by <id>. + The following commands are really only useful for OSD menu console mode:
--- a/command.c Sun Oct 10 09:27:11 2010 +0000 +++ b/command.c Sun Oct 10 09:30:42 2010 +0000 @@ -62,6 +62,7 @@ #include "m_struct.h" #include "libmenu/menu.h" #include "gui/interface.h" +#include "eosd.h" #include "mp_core.h" #include "mp_fifo.h" @@ -2492,6 +2493,70 @@ } } +static int overlay_source_registered = 0; +static struct mp_eosd_source overlay_source = { + .z_index = 5, +}; + +static void overlay_add(char *file, int id, int x, int y, unsigned col) +{ + FILE *f; + unsigned w, h, nc; + unsigned char *data; + struct mp_eosd_image *img; + + if (!(f = fopen(file, "r"))) { + mp_msg(MSGT_CPLAYER, MSGL_ERR, "overlay_add: unable to open file.\n"); + return; + } + if (fscanf(f, "P5\n%d %d\n%d\n", &w, &h, &nc) != 3 || nc != 255) { + mp_msg(MSGT_CPLAYER, MSGL_ERR, "overlay_add: unable to parse file.\n"); + fclose(f); + return; + } + data = malloc(w * h); + if (fread(data, 1, w * h, f) != w * h) { + mp_msg(MSGT_CPLAYER, MSGL_ERR, "overlay_add: unable to read file.\n"); + fclose(f); + return; + } + if (!overlay_source_registered) { + eosd_register(&overlay_source); + eosd_image_remove_all(&overlay_source); + overlay_source_registered = 1; + } + fclose(f); + img = eosd_image_alloc(); + img->w = w; + img->h = h; + img->stride = w; + img->bitmap = data; + img->color = col ^ 0xFF; /* col is RGBA, img->color is RGBT */ + img->dst_x = x; + img->dst_y = y; + img->opaque = (void *)id; + eosd_image_append(&overlay_source, img); + overlay_source.changed = EOSD_CHANGED_BITMAP; +} + +static void overlay_remove(int id) +{ + struct mp_eosd_image *img, **prev, *next; + prev = &overlay_source.images; + img = overlay_source.images; + while (img) { + next = img->next; + if ((int)img->opaque == id) { + free(img->bitmap); + eosd_image_remove(&overlay_source, img, prev); + overlay_source.changed = EOSD_CHANGED_BITMAP; + } else { + prev = &img->next; + } + img = next; + } +} + int run_command(MPContext *mpctx, mp_cmd_t *cmd) { sh_audio_t * const sh_audio = mpctx->sh_audio; @@ -3060,6 +3125,17 @@ &(cmd->args[0].v.i)); break; } + case MP_CMD_OVERLAY_ADD: + { + overlay_add(cmd->args[0].v.s, cmd->args[1].v.i, + cmd->args[2].v.i, cmd->args[3].v.i, cmd->args[4].v.i); + break; + } + case MP_CMD_OVERLAY_REMOVE: + { + overlay_remove(cmd->args[0].v.i); + break; + } case MP_CMD_SUB_LOAD: if (sh_video) {
--- a/input/input.c Sun Oct 10 09:27:11 2010 +0000 +++ b/input/input.c Sun Oct 10 09:30:42 2010 +0000 @@ -176,6 +176,8 @@ { MP_CMD_VF_CHANGE_RECTANGLE, "change_rectangle", 2, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}}}}, { MP_CMD_TV_TELETEXT_ADD_DEC, "teletext_add_dec", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } }, { MP_CMD_TV_TELETEXT_GO_LINK, "teletext_go_link", 1, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, + { MP_CMD_OVERLAY_ADD, "overlay_add", 5, { {MP_CMD_ARG_STRING,{0}}, {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, + { MP_CMD_OVERLAY_REMOVE, "overlay_remove", 1, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, #ifdef CONFIG_DVDNAV { MP_CMD_DVDNAV, "dvdnav", 1, { {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } },