mirror of https://github.com/mpv-player/mpv
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
For a given subtitle language you can now chose to display only the forced subtitles. Defaut is set to "show all subtitles" so that current mplayer behaviour is not changed. For DVD: Use -forced_subs_only additionally to e.g. -slang en if you are only interested in the forced subtitles. For VobSub: The idx file is now parsed for the "forced subs: ON/OFF" tag and used according to its settings. Key: You can toggle the display of forced subtitles by pressing "F" (upper case letter). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10918 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
1526dc6cdf
commit
943904865f
|
@ -923,6 +923,9 @@ alte Schriftunterst
|
|||
.PD 1
|
||||
.
|
||||
.TP
|
||||
.B \-forcedsubsonly
|
||||
Nur "erzwungene" DVD-Untertitel in der z.B. mit \-slang gewähten Sprache darstellen.
|
||||
.TP
|
||||
.B \-noautosub
|
||||
Deaktiviert das automatische Laden von Untertiteln.
|
||||
.TP
|
||||
|
@ -1126,6 +1129,9 @@ benutzt Gau
|
|||
.PD 1
|
||||
.
|
||||
.TP
|
||||
.B \-forcedsubsonly
|
||||
Display only "forced subtitles" for the DVD subtitle stream selected by e.g. \-slang.
|
||||
.TP
|
||||
.B \-spugauss <0.0\-3.0>
|
||||
Varianzparameter der Gaußschen Unschärfe bei \-spuaa 4. Höhere Werte stehen
|
||||
für mehr Unschärfe. Der Standardwert ist 1.0.
|
||||
|
@ -3346,6 +3352,8 @@ schaltet Verwerfen von Bildern an/\:aus
|
|||
de\-/\:aktiviert die Anzeige von Untertiteln
|
||||
.IPs j\ \ \ \
|
||||
schaltet durch die vorhandenen Untertitelsprachen
|
||||
.IPs F\ \ \ \
|
||||
de\-/\:aktiviert "erzwungene Untertitel"
|
||||
.IPs a\ \ \ \
|
||||
wechselt die Ausrichtung der Untertitel: oben, mittig, unten
|
||||
.IPs "z und x"
|
||||
|
|
|
@ -287,6 +287,8 @@ toggle frame dropping
|
|||
toggle subtitle visibility
|
||||
.IPs j\ \ \ \
|
||||
switch subtitle language
|
||||
.IP F\ \ \ \
|
||||
toggle display of "forced subtitles"
|
||||
.IPs a\ \ \ \
|
||||
toggle subtitle aligment: top/middle/bottom
|
||||
.IPs "z and x"
|
||||
|
@ -1121,6 +1123,10 @@ The \-subfont-* options are available only with FreeType support compiled in.
|
|||
.PD 1
|
||||
.
|
||||
.TP
|
||||
.B \-forcedsubsonly
|
||||
Display only "forced subtitles" for the DVD subtitle stream selected by e.g.
|
||||
\-slang.
|
||||
.TP
|
||||
.B \-fribidi_charset <charset\ name>
|
||||
Specifies the charset that will be passed to FriBiDi when decoding a non-utf8
|
||||
subtitles. Default is "ISO8859-8".
|
||||
|
|
|
@ -347,6 +347,7 @@ m_option_t mplayer_opts[]={
|
|||
// these should be moved to -common, and suppot in mencoder too
|
||||
{"vobsub", &vobsub_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
{"vobsubid", &vobsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL},
|
||||
{"forcedsubsonly", &forced_subs_only,CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
|
||||
{"sstep", &step_sec, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ static mp_cmd_t mp_cmds[] = {
|
|||
{ MP_CMD_TV_SET_HUE, "tv_set_hue", 1, { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }},
|
||||
{ MP_CMD_TV_SET_SATURATION, "tv_set_saturation", 1, { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }},
|
||||
#endif
|
||||
{ MP_CMD_SUB_FORCED_ONLY, "forced_subs_only", 0, { {-1,{0}} } },
|
||||
#ifdef HAS_DVBIN_SUPPORT
|
||||
{ MP_CMD_DVB_SET_CHANNEL, "dvb_set_channel", 1, { { MP_CMD_ARG_INT, {0}}, {-1,{0}} }},
|
||||
#endif
|
||||
|
@ -300,6 +301,7 @@ static mp_cmd_bind_t def_cmd_binds[] = {
|
|||
{ { 'a', 0 }, "sub_alignment" },
|
||||
{ { 'v', 0 }, "sub_visibility" },
|
||||
{ { 'j', 0 }, "vobsub_lang" },
|
||||
{ { 'F', 0 }, "forced_subs_only" },
|
||||
#ifdef USE_EDL
|
||||
{ { 'i', 0 }, "edl_mark" },
|
||||
#endif
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#define MP_CMD_TV_SET_SATURATION 47
|
||||
#define MP_CMD_GET_VO_FULLSCREEN 48
|
||||
#define MP_CMD_GET_SUB_VISIBILITY 49
|
||||
#define MP_CMD_SUB_FORCED_ONLY 50
|
||||
|
||||
#define MP_CMD_GUI_EVENTS 5000
|
||||
#define MP_CMD_GUI_LOADFILE 5001
|
||||
|
|
13
mplayer.c
13
mplayer.c
|
@ -243,6 +243,7 @@ char* audio_lang=NULL;
|
|||
char* dvdsub_lang=NULL;
|
||||
static char* spudec_ifo=NULL;
|
||||
char* filename=NULL; //"MI2-Trailer.avi";
|
||||
int forced_subs_only=0;
|
||||
|
||||
// cache2:
|
||||
int stream_cache_size=-1;
|
||||
|
@ -1256,6 +1257,8 @@ if(!use_stdin && !slave_mode){
|
|||
sub_auto=0; // don't do autosub for textsubs if vobsub found
|
||||
inited_flags|=INITED_VOBSUB;
|
||||
vobsub_set_from_lang(vo_vobsub, dvdsub_lang);
|
||||
// check if vobsub requested only to display forced subtitles
|
||||
forced_subs_only=vobsub_get_forced_subs_flag(vo_vobsub);
|
||||
}
|
||||
|
||||
//============ Open & Sync STREAM --- fork cache2 ====================
|
||||
|
@ -1597,6 +1600,10 @@ if (vo_spudec!=NULL)
|
|||
|
||||
}
|
||||
|
||||
// Apply current settings for forced subs
|
||||
if (vo_spudec!=NULL)
|
||||
spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
|
||||
|
||||
#ifdef USE_SUB
|
||||
if(sh_video) {
|
||||
// after reading video params we should load subtitles because
|
||||
|
@ -3063,6 +3070,12 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still)
|
|||
}
|
||||
#endif
|
||||
break;
|
||||
case MP_CMD_SUB_FORCED_ONLY:
|
||||
if (vo_spudec) {
|
||||
forced_subs_only = forced_subs_only ? 0 : ~0; // toggle state
|
||||
spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
|
||||
}
|
||||
break;
|
||||
case MP_CMD_SCREENSHOT :
|
||||
if(vo_config_count) video_out->control(VOCTRL_SCREENSHOT, NULL);
|
||||
break;
|
||||
|
|
27
spudec.c
27
spudec.c
|
@ -89,6 +89,8 @@ typedef struct {
|
|||
int font_start_level; /* Darkest value used for the computed font */
|
||||
vo_functions_t *hw_spu;
|
||||
int spu_changed;
|
||||
unsigned int forced_subs_only; /* flag: 0=display all subtitle, !0 display only forced subtitles */
|
||||
unsigned int is_forced_sub; /* true if current subtitle is a forced subtitle */
|
||||
} spudec_handle_t;
|
||||
|
||||
static void spudec_queue_packet(spudec_handle_t *this, packet_t *packet)
|
||||
|
@ -371,8 +373,10 @@ static void spudec_process_control(spudec_handle_t *this, unsigned int pts100)
|
|||
/* Menu ID, 1 byte */
|
||||
mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Menu ID\n");
|
||||
/* shouldn't a Menu ID type force display start? */
|
||||
//this->start_pts = pts100 + date;
|
||||
//this->end_pts = UINT_MAX;
|
||||
start_pts = pts100 + date;
|
||||
end_pts = UINT_MAX;
|
||||
display = 1;
|
||||
this->is_forced_sub=~0; // current subtitle is forced
|
||||
break;
|
||||
case 0x01:
|
||||
/* Start display */
|
||||
|
@ -380,6 +384,7 @@ static void spudec_process_control(spudec_handle_t *this, unsigned int pts100)
|
|||
start_pts = pts100 + date;
|
||||
end_pts = UINT_MAX;
|
||||
display = 1;
|
||||
this->is_forced_sub=0;
|
||||
break;
|
||||
case 0x02:
|
||||
/* Stop display */
|
||||
|
@ -604,6 +609,14 @@ int spudec_visible(void *this){
|
|||
return ret;
|
||||
}
|
||||
|
||||
void spudec_set_forced_subs_only(void * const this, const unsigned int flag)
|
||||
{
|
||||
if(this){
|
||||
((spudec_handle_t *)this)->forced_subs_only=flag;
|
||||
mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPU: Display only forced subs now %s\n", flag ? "enabled": "disabled");
|
||||
}
|
||||
}
|
||||
|
||||
void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride))
|
||||
{
|
||||
spudec_handle_t *spu = (spudec_handle_t *)this;
|
||||
|
@ -752,7 +765,14 @@ void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*dra
|
|||
spudec_handle_t *spu = (spudec_handle_t *)me;
|
||||
scale_pixel *table_x;
|
||||
scale_pixel *table_y;
|
||||
|
||||
if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts) {
|
||||
|
||||
// check if only forced subtitles are requested
|
||||
if( (spu->forced_subs_only) && !(spu->is_forced_sub) ){
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(spu_aamode&16) && (spu->orig_frame_width == 0 || spu->orig_frame_height == 0
|
||||
|| (spu->orig_frame_width == dxs && spu->orig_frame_height == dys))) {
|
||||
if (spu->image)
|
||||
|
@ -1125,6 +1145,9 @@ void *spudec_new_scaled_vobsub(unsigned int *palette, unsigned int *cuspal, unsi
|
|||
memcpy(this->cuspal, cuspal, sizeof(this->cuspal));
|
||||
this->auto_palette = 0;
|
||||
}
|
||||
// forced subtitles default: show all subtitles
|
||||
this->forced_subs_only=0;
|
||||
this->is_forced_sub=0;
|
||||
}
|
||||
else
|
||||
mp_msg(MSGT_SPUDEC,MSGL_FATAL, "FATAL: spudec_init: calloc");
|
||||
|
|
1
spudec.h
1
spudec.h
|
@ -19,5 +19,6 @@ void spudec_set_hw_spu(void *this, vo_functions_t *hw_spu);
|
|||
int spudec_changed(void *this);
|
||||
void spudec_calc_bbox(void *me, unsigned int dxs, unsigned int dys, unsigned int* bbox);
|
||||
void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
void spudec_set_forced_subs_only(void * const this, const unsigned int flag);
|
||||
#endif
|
||||
|
||||
|
|
36
vobsub.c
36
vobsub.c
|
@ -576,6 +576,7 @@ typedef struct {
|
|||
unsigned int have_palette;
|
||||
unsigned int orig_frame_width, orig_frame_height;
|
||||
unsigned int origin_x, origin_y;
|
||||
unsigned int forced_subs;
|
||||
/* index */
|
||||
packet_queue_t *spu_streams;
|
||||
unsigned int spu_streams_size;
|
||||
|
@ -887,6 +888,26 @@ vobsub_set_lang(const char *line)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_forced_subs(vobsub_t *vob, const char *line)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
p = line;
|
||||
while (isspace(*p))
|
||||
++p;
|
||||
|
||||
if (strncasecmp("on",p,2) == 0){
|
||||
vob->forced_subs=~0;
|
||||
return 0;
|
||||
} else if (strncasecmp("off",p,3) == 0){
|
||||
vob->forced_subs=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd)
|
||||
{
|
||||
|
@ -920,6 +941,8 @@ vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd)
|
|||
else if (strncmp("custom colors:", line, 14) == 0)
|
||||
//custom colors: ON/OFF, tridx: XXXX, colors: XXXXXX, XXXXXX, XXXXXX,XXXXXX
|
||||
res = vobsub_parse_cuspal(vob, line) + vobsub_parse_tridx(line) + vobsub_parse_custom(vob, line);
|
||||
else if (strncmp("forced subs:", line, 12) == 0)
|
||||
res = vobsub_parse_forced_subs(vob, line + 12);
|
||||
else {
|
||||
mp_msg(MSGT_VOBSUB,MSGL_V, "vobsub: ignoring %s", line);
|
||||
continue;
|
||||
|
@ -1017,6 +1040,7 @@ vobsub_open(const char *const name,const char *const ifo,const int force,void**
|
|||
vob->spu_streams_size = 0;
|
||||
vob->spu_streams_current = 0;
|
||||
vob->delay = 0;
|
||||
vob->forced_subs=0;
|
||||
buf = malloc((strlen(name) + 5) * sizeof(char));
|
||||
if (buf) {
|
||||
rar_stream_t *fd;
|
||||
|
@ -1149,6 +1173,15 @@ vobsub_get_id(void *vobhandle, unsigned int index)
|
|||
return (index < vob->spu_streams_size) ? vob->spu_streams[index].id : NULL;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
vobsub_get_forced_subs_flag(void const * const vobhandle)
|
||||
{
|
||||
if (vobhandle)
|
||||
return ((vobsub_t*) vobhandle)->forced_subs;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
vobsub_set_from_lang(void *vobhandle, unsigned char * lang)
|
||||
{
|
||||
|
@ -1256,6 +1289,9 @@ create_idx(vobsub_out_t *me, const unsigned int *palette, unsigned int orig_widt
|
|||
}
|
||||
putc('\n', me->fidx);
|
||||
}
|
||||
|
||||
fprintf(me->fidx,"# ON: displays only forced subtitles, OFF: shows everything\n"
|
||||
"forced subs: OFF\n");
|
||||
}
|
||||
|
||||
void *
|
||||
|
|
2
vobsub.h
2
vobsub.h
|
@ -14,5 +14,7 @@ extern void *vobsub_out_open(const char *basename, const unsigned int *palette,
|
|||
extern void vobsub_out_output(void *me, const unsigned char *packet, int len, double pts);
|
||||
extern void vobsub_out_close(void *me);
|
||||
extern int vobsub_set_from_lang(void *vobhandle, unsigned char * lang);
|
||||
extern unsigned int vobsub_get_forced_subs_flag(void const * const vobhandle);
|
||||
|
||||
#endif /* MPLAYER_VOBSUB_H */
|
||||
|
||||
|
|
Loading…
Reference in New Issue