summaryrefslogtreecommitdiffstats
path: root/core/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/command.c')
-rw-r--r--core/command.c80
1 files changed, 14 insertions, 66 deletions
diff --git a/core/command.c b/core/command.c
index 3ee8f39c3d..416fbcd06a 100644
--- a/core/command.c
+++ b/core/command.c
@@ -50,7 +50,6 @@
#include "audio/filter/af.h"
#include "video/decode/dec_video.h"
#include "audio/decode/dec_audio.h"
-#include "sub/spudec.h"
#include "core/path.h"
#include "sub/ass_mp.h"
#include "stream/tv.h"
@@ -1273,11 +1272,12 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg,
static int mp_property_sub_delay(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
+ struct MPOpts *opts = &mpctx->opts;
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_PRINT:
- *(char **)arg = format_delay(sub_delay);
+ *(char **)arg = format_delay(opts->sub_delay);
return M_PROPERTY_OK;
}
return mp_property_generic_option(prop, action, arg, mpctx);
@@ -1286,56 +1286,16 @@ static int mp_property_sub_delay(m_option_t *prop, int action, void *arg,
static int mp_property_sub_pos(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
+ struct MPOpts *opts = &mpctx->opts;
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
if (action == M_PROPERTY_PRINT) {
- *(char **)arg = talloc_asprintf(NULL, "%d/100", sub_pos);
+ *(char **)arg = talloc_asprintf(NULL, "%d/100", opts->sub_pos);
return M_PROPERTY_OK;
}
return property_osd_helper(prop, action, arg, mpctx);
}
-/// Subtitle visibility (RW)
-static int mp_property_sub_visibility(m_option_t *prop, int action,
- void *arg, MPContext *mpctx)
-{
- struct MPOpts *opts = &mpctx->opts;
-
- if (!mpctx->sh_video)
- return M_PROPERTY_UNAVAILABLE;
-
- switch (action) {
- case M_PROPERTY_SET:
- opts->sub_visibility = *(int *)arg;
- vo_osd_changed(OSDTYPE_SUBTITLE);
- if (vo_spudec)
- vo_osd_changed(OSDTYPE_SPU);
- return M_PROPERTY_OK;
- case M_PROPERTY_GET:
- *(int *)arg = opts->sub_visibility;
- return M_PROPERTY_OK;
- }
- return M_PROPERTY_NOT_IMPLEMENTED;
-}
-
-/// Show only forced subtitles (RW)
-static int mp_property_sub_forced_only(m_option_t *prop, int action,
- void *arg, MPContext *mpctx)
-{
- struct MPOpts *opts = &mpctx->opts;
-
- if (!vo_spudec)
- return M_PROPERTY_UNAVAILABLE;
-
- if (action == M_PROPERTY_SET) {
- opts->forced_subs_only = *(int *)arg;
- spudec_set_forced_subs_only(vo_spudec, opts->forced_subs_only);
- return M_PROPERTY_OK;
- }
- return mp_property_generic_option(prop, action, arg, mpctx);
-}
-
-
#ifdef CONFIG_TV
static tvi_handle_t *get_tvh(struct MPContext *mpctx)
@@ -1513,9 +1473,8 @@ static const m_option_t mp_properties[] = {
M_OPTION_PROPERTY_CUSTOM("sid", mp_property_sub),
M_OPTION_PROPERTY_CUSTOM("sub-delay", mp_property_sub_delay),
M_OPTION_PROPERTY_CUSTOM("sub-pos", mp_property_sub_pos),
- { "sub-visibility", mp_property_sub_visibility, CONF_TYPE_FLAG,
- M_OPT_RANGE, 0, 1, NULL },
- M_OPTION_PROPERTY_CUSTOM("sub-forced-only", mp_property_sub_forced_only),
+ M_OPTION_PROPERTY_CUSTOM("sub-visibility", property_osd_helper),
+ M_OPTION_PROPERTY_CUSTOM("sub-forced-only", property_osd_helper),
M_OPTION_PROPERTY_CUSTOM("sub-scale", property_osd_helper),
#ifdef CONFIG_ASS
M_OPTION_PROPERTY_CUSTOM("ass-use-margins", property_osd_helper),
@@ -1991,26 +1950,18 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
}
case MP_CMD_SUB_STEP:
- if (sh_video) {
- int movement = cmd->args[0].v.i;
- struct track *track = mpctx->current_track[STREAM_SUB];
- bool available = false;
- if (track && track->subdata) {
- available = true;
- step_sub(track->subdata, mpctx->video_pts, movement);
- }
#ifdef CONFIG_ASS
- struct ass_track *ass_track = sub_get_ass_track(mpctx->osd);
+ if (mpctx->osd->dec_sub) {
+ int movement = cmd->args[0].v.i;
+ struct ass_track *ass_track = sub_get_ass_track(mpctx->osd->dec_sub);
if (ass_track) {
- available = true;
- sub_delay += ass_step_sub(ass_track,
- (mpctx->video_pts + sub_delay) * 1000 + .5, movement) / 1000.;
- }
-#endif
- if (available)
set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, osdl, osd_duration,
- "Sub delay: %d ms", ROUND(sub_delay * 1000));
+ "Sub delay: %d ms", ROUND(opts->sub_delay * 1000));
+ double cur = (mpctx->video_pts + opts->sub_delay) * 1000 + .5;
+ opts->sub_delay += ass_step_sub(ass_track, cur, movement) / 1000.;
+ }
}
+#endif
break;
case MP_CMD_OSD: {
@@ -2194,7 +2145,6 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (tv_channel_list) {
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration,
"Channel: %s", tv_channel_current->name);
- //vo_osd_changed(OSDTYPE_SUBTITLE);
}
}
#ifdef CONFIG_PVR
@@ -2232,7 +2182,6 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (tv_channel_list) {
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration,
"Channel: %s", tv_channel_current->name);
- //vo_osd_changed(OSDTYPE_SUBTITLE);
}
}
#ifdef CONFIG_PVR
@@ -2265,7 +2214,6 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (tv_channel_list) {
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration,
"Channel: %s", tv_channel_current->name);
- //vo_osd_changed(OSDTYPE_SUBTITLE);
}
}
#ifdef CONFIG_PVR