diff --git a/DOCS/mplayer.1 b/DOCS/mplayer.1 index 0711bf44fb..ffcba68937 100644 --- a/DOCS/mplayer.1 +++ b/DOCS/mplayer.1 @@ -774,6 +774,9 @@ If FreeType support is enabled, the old font support can't be used. .B \-noautosub Turns off automatic loading of subtitle files. .TP +.B \-nooverlapsub +Turns off support for overlapping subtitles. +.TP .B \-osdlevel <0\-2> (MPLAYER only) Specifies which mode the OSD should start in (0: none, 1: seek, 2: seek+timer, default is 1). diff --git a/cfg-common.h b/cfg-common.h index 0291708cad..731434784e 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -180,6 +180,7 @@ {"ifo", &spudec_ifo, CONF_TYPE_STRING, 0, 0, 0, NULL}, // enable Closed Captioning display {"subcc", &subcc_enabled, CONF_TYPE_FLAG, 0, 0, 1, NULL}, + {"nooverlapsub", &suboverlap_enabled, CONF_TYPE_FLAG, 0, 0, 0, NULL}, #endif #ifdef USE_OSD {"font", &font_name, CONF_TYPE_STRING, 0, 0, 0, NULL}, diff --git a/libvo/sub.c b/libvo/sub.c index 67003cf9a1..075431df5e 100644 --- a/libvo/sub.c +++ b/libvo/sub.c @@ -351,7 +351,20 @@ inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){ lastk=k; lastStripPosition=j; lastxsize=xsize; - } else if ((font=vo_font->font[c])>=0){ + } else if ((!suboverlap_enabled) && ((font = vo_font->font[c]) >= 0)) { + /* + With overlapping subtitles, we need to comment this out, + beacuse that part of the code creates subtitles with the + last line blank (" "): in this case previous 'if' statement + is false an following 'if' is not executed. When, instead, + a subtitle with a non-blank last line arrives, the following + code is executed, and the result is a small 'jump' of the + subtiles. We can not simply delete the following, unless + having the last subtitle line partly drawn outside the + screen, so, some lines forward, we introduce an increment + which affects both blank and non-blank lines. + *sfalco* + */ if (vo_font->pic_a[font]->h > h){ h=vo_font->pic_a[font]->h; } @@ -396,6 +409,13 @@ inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){ } } + /* + Here is the little increment we talked about before. '40' is the + ASCII code for '(', which, hopefully, is the highest char of the + font. + *sfalco* + */ + if(suboverlap_enabled) obj->y -= vo_font->pic_a[vo_font->font[40]]->h - vo_font->height; if (obj->y >= (dys * sub_pos / 100)){ int old=obj->y; obj->y = dys * sub_pos /100; diff --git a/libvo/sub.h b/libvo/sub.h index 5646535f42..ead5a131ff 100644 --- a/libvo/sub.h +++ b/libvo/sub.h @@ -98,6 +98,7 @@ extern char *sub_cp; #endif extern int sub_pos; extern int sub_visibility; +extern int suboverlap_enabled; //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 --git a/mencoder.c b/mencoder.c index bc9786f6b4..464ae64794 100644 --- a/mencoder.c +++ b/mencoder.c @@ -162,6 +162,7 @@ float sub_delay=0; float sub_fps=0; int sub_auto = 0; int subcc_enabled=0; +int suboverlap_enabled = 1; #ifdef USE_SUB static subtitle* subtitles=NULL; diff --git a/mplayer.c b/mplayer.c index e1138e4e55..f51d4769ce 100644 --- a/mplayer.c +++ b/mplayer.c @@ -256,6 +256,7 @@ int sub_auto = 1; char *vobsub_name=NULL; /*DSP!!char *dsp=NULL;*/ int subcc_enabled=0; +int suboverlap_enabled = 1; #ifdef USE_SUB subtitle* subtitles=NULL; float sub_last_pts = -303; diff --git a/subreader.c b/subreader.c index 3e374c26f9..deb55bb52c 100644 --- a/subreader.c +++ b/subreader.c @@ -1048,7 +1048,7 @@ subtitle* sub_read_file (char *filename, float fps) { } adjust_subs_time(first, 6.0, fps, 0); /* ~6 secs AST */ - +if(suboverlap_enabled){ // here we manage overlapping subtitles sub_orig = sub_num; n_first = sub_num; @@ -1057,7 +1057,7 @@ subtitle* sub_read_file (char *filename, float fps) { second = NULL; // for each subtitle in first[] for (sub_first = 0; sub_first < n_first; ++sub_first) { - while (first[sub_first].start <= first[sub_first].end) { + while (first[sub_first].start < first[sub_first].end) { unsigned long end_time = first[sub_first].end; int lines_to_add = 0, sub_to_add, event, ls, lf; @@ -1144,6 +1144,11 @@ subtitle* sub_read_file (char *filename, float fps) { } return second; +} else { //if(suboverlap_enabled) + adjust_subs_time(first, 6.0, fps, 1); /* ~6 secs AST */ + + return first; +} } #if 0 diff --git a/subreader.h b/subreader.h index 3da5b1939d..61922d46a3 100644 --- a/subreader.h +++ b/subreader.h @@ -4,6 +4,7 @@ extern int sub_uses_time; extern int sub_errs; extern int sub_num; // number of subtitle structs +extern int suboverlap_enabled; // subtitle formats #define SUB_INVALID -1