# HG changeset patch
# User arpi
# Date 1033926051 0
# Node ID d6608342591d1272790c16426f26e06a2333ca8f
# Parent 382b28368402af049c9e3bbfac4f7ac56e5ddaca
This patch adds the functionality to disable/enable subtitles while playing
a video. I mapped it to the input-keyword "sub_visibility".
This keyword is mapped to the 'v' key on the keyboard. I tested the patch
with old-fashioned subtitles, with freetype subtitles and DVD subtitles.
Works fine. The patch also includes documentation updates.
patch by Uwe.Reder@3SOFT.de
diff -r 382b28368402 -r d6608342591d DOCS/documentation.html
--- a/DOCS/documentation.html Sun Oct 06 17:31:36 2002 +0000
+++ b/DOCS/documentation.html Sun Oct 06 17:40:51 2002 +0000
@@ -1098,6 +1098,7 @@
| / or * | | decrease/increase volume |
| f | | toggle fullscreen |
| o | | toggle OSD: none / seek / seek+timer |
+ | v | | toggle subtitle visibility |
| z or x | | adjust subtitle delay by +/- 0.1 second |
| r or t | | adjust subtitle position |
| HOME or END | | go to next/previous playtree entry in the parent list |
@@ -1256,6 +1257,8 @@
Set/Adjust video parameters. Val range from -100 to 100.
frame_drop [(int) type=-1]
Toggle/Set frame dropping mode.
+ sub_visibility
+ Toggle subtitle visibility.
sub_pos (int) val
Adjust subtitles position.
vo_fullscreen
diff -r 382b28368402 -r d6608342591d DOCS/mplayer.1
--- a/DOCS/mplayer.1 Sun Oct 06 17:31:36 2002 +0000
+++ b/DOCS/mplayer.1 Sun Oct 06 17:40:51 2002 +0000
@@ -2020,6 +2020,8 @@
toggle between OSD states: none / seek / seek+timer
.IPs d
toggle frame dropping
+.IPs v
+toggle subtitle visibility
.IPs "z and x"
adjust subtitle delay by +/\- 0.1 second
.IPs "r and t"
@@ -2127,6 +2129,8 @@
Set/Adjust video parameters.
.IPs "frame_drop [type=]"
Toggle/Set frame dropping mode.
+.IPs "sub_visibility"
+Toggle subtitle visibility.
.IPs "sub_pos "
Adjust subtitles position.
.IPs vo_fullscreen
diff -r 382b28368402 -r d6608342591d input/input.c
--- a/input/input.c Sun Oct 06 17:31:36 2002 +0000
+++ b/input/input.c Sun Oct 06 17:40:51 2002 +0000
@@ -59,6 +59,7 @@
{ MP_CMD_SATURATION, "saturation",1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
{ MP_CMD_FRAMEDROPPING, "frame_drop",0, { { MP_CMD_ARG_INT,{-1} }, {-1,{0}} } },
{ MP_CMD_SUB_POS, "sub_pos", 1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
+ { MP_CMD_SUB_VISIBILITY, "sub_visibility", 0, { {-1,{0}} } },
#ifdef USE_TV
{ MP_CMD_TV_STEP_CHANNEL, "tv_step_channel", 1, { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }},
{ MP_CMD_TV_STEP_NORM, "tv_step_norm",0, { {-1,{0}} } },
@@ -221,6 +222,7 @@
{ { 'd', 0 }, "frame_drop" },
{ { 'r', 0 }, "sub_pos -1" },
{ { 't', 0 }, "sub_pos +1" },
+ { { 'v', 0 }, "sub_visibility" },
#ifdef USE_TV
{ { 'h', 0 }, "tv_step_channel 1" },
{ { 'k', 0 }, "tv_step_channel -1" },
diff -r 382b28368402 -r d6608342591d input/input.h
--- a/input/input.h Sun Oct 06 17:31:36 2002 +0000
+++ b/input/input.h Sun Oct 06 17:40:51 2002 +0000
@@ -29,6 +29,7 @@
#define MP_CMD_LOADLIST 27
#define MP_CMD_VF_CHANGE_RECTANGLE 28
#define MP_CMD_GAMMA 29
+#define MP_CMD_SUB_VISIBILITY 30
#define MP_CMD_GUI_EVENTS 5000
#define MP_CMD_GUI_LOADFILE 5001
diff -r 382b28368402 -r d6608342591d libvo/sub.c
--- a/libvo/sub.c Sun Oct 06 17:31:36 2002 +0000
+++ b/libvo/sub.c Sun Oct 06 17:40:51 2002 +0000
@@ -33,6 +33,7 @@
int sub_unicode=0;
int sub_utf8=0;
int sub_pos=100;
+int sub_visibility=1;
// return the real height of a char:
static inline int get_height(int c,int h){
@@ -298,8 +299,8 @@
int h,lasth;
obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
-
- if(!vo_sub || !vo_font){
+
+ if(!vo_sub || !vo_font || !sub_visibility){
obj->flags&=~OSDFLAG_VISIBLE;
return;
}
@@ -504,7 +505,7 @@
vo_update_text_progbar(obj,dxs,dys);
break;
case OSDTYPE_SPU:
- if(vo_spudec && spudec_visible(vo_spudec)){
+ if(sub_visibility && vo_spudec && spudec_visible(vo_spudec)){
vo_update_spudec_sub(obj, dxs, dys);
obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
}
diff -r 382b28368402 -r d6608342591d libvo/sub.h
--- a/libvo/sub.h Sun Oct 06 17:31:36 2002 +0000
+++ b/libvo/sub.h Sun Oct 06 17:40:51 2002 +0000
@@ -97,6 +97,7 @@
extern char *sub_cp;
#endif
extern int sub_pos;
+extern int sub_visibility;
//extern void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
//extern void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
diff -r 382b28368402 -r d6608342591d mplayer.c
--- a/mplayer.c Sun Oct 06 17:31:36 2002 +0000
+++ b/mplayer.c Sun Oct 06 17:40:51 2002 +0000
@@ -514,6 +514,7 @@
int osd_last_pts=-303;
int osd_show_av_delay = 0;
int osd_show_sub_delay = 0;
+int osd_show_sub_visibility = 0;
int rtc_fd=-1;
@@ -2193,6 +2194,13 @@
if(sub_pos <0) sub_pos=0;
vo_osd_changed(OSDTYPE_SUBTITLE);
} break;
+ case MP_CMD_SUB_VISIBILITY:
+ {
+ sub_visibility=1-sub_visibility;
+ osd_show_sub_visibility = 9; // show state of subtitle visibility in OSD
+ vo_osd_changed(OSDTYPE_SUBTITLE);
+ break;
+ }
case MP_CMD_SCREENSHOT :
if(vo_config_count) video_out->control(VOCTRL_SCREENSHOT, NULL);
break;
@@ -2557,6 +2565,10 @@
osd_show_dvd_nav_delay--;
} else
#endif
+ if (osd_show_sub_visibility) {
+ sprintf(osd_text_tmp, "Subtitles: %sabled", sub_visibility?"en":"dis");
+ osd_show_sub_visibility--;
+ } else
if (osd_show_sub_delay) {
sprintf(osd_text_tmp, "Sub delay: %d ms",(int)(sub_delay*1000));
osd_show_sub_delay--;