From 1544e6471755ec91d954ab604abdcedfac082acc Mon Sep 17 00:00:00 2001 From: albeu Date: Mon, 9 Jul 2007 11:19:21 +0000 Subject: Add the sub_scale property and command. Patch from Anatoli Marinov (anatoli [dot] marinov [at] gmail [dot] com). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23745 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/tech/slave.txt | 5 +++++ command.c | 29 +++++++++++++++++++++++++++++ etc/input.conf | 2 ++ etc/menu.conf | 1 + help/help_mp-en.h | 1 + input/input.c | 1 + input/input.h | 1 + 7 files changed, 40 insertions(+) diff --git a/DOCS/tech/slave.txt b/DOCS/tech/slave.txt index 7a44426d8d..a74ba2fe38 100644 --- a/DOCS/tech/slave.txt +++ b/DOCS/tech/slave.txt @@ -288,6 +288,10 @@ sub_select [value] than -1. Supported subtitle sources are -sub options on the command line, VOBsubs, DVD subtitles, and Ogg and Matroska text streams. +sub_scale [abs] + Adjust the subtitle size by +/- or set it to when [abs] + is nonzero. + vobsub_lang This is a stub linked to sub_select for backwards compatibility. @@ -443,6 +447,7 @@ sub_pos int 0 100 X X X subtitle position sub_alignment int 0 2 X X X subtitle alignment sub_visibility flag 0 1 X X X show/hide subtitles sub_forced_only flag 0 1 X X X +sub_scale float 0 100 X X X subtitles font size tv_brightness int -100 100 X X X tv_contrast int -100 100 X X X tv_saturation int -100 100 X X X diff --git a/command.c b/command.c index b2bd9f89b2..f438effe43 100644 --- a/command.c +++ b/command.c @@ -19,6 +19,7 @@ #include "libmpcodecs/vf.h" #include "libmpcodecs/vd.h" #include "libvo/video_out.h" +#include "libvo/font_load.h" #include "playtree.h" #include "libao2/audio_out.h" #include "mpcommon.h" @@ -1411,6 +1412,31 @@ static int mp_property_sub_forced_only(m_option_t * prop, int action, } +/// Subtitle scale (RW) +static int mp_property_sub_scale(m_option_t * prop, int action, void *arg, + MPContext * mpctx) +{ + + switch (action) { + case M_PROPERTY_SET: + if (!arg) + return M_PROPERTY_ERROR; + M_PROPERTY_CLAMP(prop, *(float *) arg); + text_font_scale_factor = *(float *) arg; + force_load_font = 1; + return M_PROPERTY_OK; + case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP_DOWN: + text_font_scale_factor += (arg ? *(float *) arg : 0.1)* + (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0); + M_PROPERTY_CLAMP(prop, text_font_scale_factor); + force_load_font = 1; + return M_PROPERTY_OK; + default: + return m_property_float_ro(prop, action, arg, text_font_scale_factor); + } +} + ///@} /// \defgroup TVProperties TV properties @@ -1568,6 +1594,8 @@ static m_option_t mp_properties[] = { M_OPT_RANGE, 0, 1, NULL }, { "sub_forced_only", mp_property_sub_forced_only, CONF_TYPE_FLAG, M_OPT_RANGE, 0, 1, NULL }, + { "sub_scale", mp_property_sub_scale, CONF_TYPE_FLOAT, + M_OPT_RANGE, 0, 100, NULL }, #ifdef USE_TV { "tv_brightness", mp_property_tv_color, CONF_TYPE_INT, @@ -1672,6 +1700,7 @@ static struct { { "sub_delay", MP_CMD_SUB_DELAY, 0, 0, OSD_MSG_SUB_DELAY, MSGTR_SubDelayStatus }, { "sub_visibility", MP_CMD_SUB_VISIBILITY, 1, 0, -1, MSGTR_SubVisibleStatus }, { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY, 1, 0, -1, MSGTR_SubForcedOnlyStatus }, + { "sub_scale", MP_CMD_SUB_SCALE, 0, 0, -1, MSGTR_SubScale}, #ifdef USE_TV { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness }, { "tv_hue", MP_CMD_TV_SET_HUE, 0, OSD_HUE, -1, MSGTR_Hue }, diff --git a/etc/input.conf b/etc/input.conf index 733cb18b08..c34eb7e1f6 100644 --- a/etc/input.conf +++ b/etc/input.conf @@ -58,6 +58,8 @@ r sub_pos -1 # move subtitles up t sub_pos +1 # down #? sub_step +1 # immediately display next subtitle #? sub_step -1 # previous +#? sub_scale +0.1 # increase subtitle font size +#? sub_scale -0.1 # decrease subtitle font size f vo_fullscreen T vo_ontop # toggle video window ontop of other windows w panscan -0.1 # zoom out with -panscan 0 -fs diff --git a/etc/menu.conf b/etc/menu.conf index 51c329b849..5cc8625e5e 100644 --- a/etc/menu.conf +++ b/etc/menu.conf @@ -29,6 +29,7 @@ + diff --git a/help/help_mp-en.h b/help/help_mp-en.h index e5ac9cb0bc..592bf0642f 100644 --- a/help/help_mp-en.h +++ b/help/help_mp-en.h @@ -245,6 +245,7 @@ static char help_text[]= #define MSGTR_SubPosStatus "Sub position: %s/100" #define MSGTR_SubAlignStatus "Sub alignment: %s" #define MSGTR_SubDelayStatus "Sub delay: %s" +#define MSGTR_SubScale "Sub Scale: %s" #define MSGTR_SubVisibleStatus "Subtitles: %s" #define MSGTR_SubForcedOnlyStatus "Forced sub only: %s" diff --git a/input/input.c b/input/input.c index c6f3461b9a..3b9312a916 100644 --- a/input/input.c +++ b/input/input.c @@ -88,6 +88,7 @@ static mp_cmd_t mp_cmds[] = { { MP_CMD_SUB_SELECT, "vobsub_lang", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, // for compatibility { MP_CMD_SUB_SELECT, "sub_select", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, { MP_CMD_SUB_LOG, "sub_log", 0, { {-1,{0}} } }, + { MP_CMD_SUB_SCALE, "sub_scale",1, { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, { MP_CMD_GET_PERCENT_POS, "get_percent_pos", 0, { {-1,{0}} } }, { MP_CMD_GET_TIME_POS, "get_time_pos", 0, { {-1,{0}} } }, { MP_CMD_GET_TIME_LENGTH, "get_time_length", 0, { {-1,{0}} } }, diff --git a/input/input.h b/input/input.h index cee0597fa0..264bd2269f 100644 --- a/input/input.h +++ b/input/input.h @@ -94,6 +94,7 @@ #define MP_CMD_RADIO_STEP_FREQ 92 #define MP_CMD_TV_STEP_FREQ 93 #define MP_CMD_BALANCE 96 +#define MP_CMD_SUB_SCALE 97 #define MP_CMD_GUI_EVENTS 5000 #define MP_CMD_GUI_LOADFILE 5001 -- cgit v1.2.3