[MPlayer-dev-eng] [PATCH] combine vobsub_lang with sub_select
Joey Parrish
joey at nicewarrior.org
Fri Aug 13 16:50:38 CEST 2004
On Thu, Aug 12, 2004 at 01:06:19PM +0200, Diego Biurrun wrote:
> Joey Parrish writes:
> > I don't like having vobsub_lang and sub_select as two different keys in
> > my input config file. So I suggest we combine them. I also think this
> > would be useful for adding other kinds of dynamic sub selection. All of
> > them should be done with one input event.
> >
> > The first patch moves vobsub_lang into sub_select. I have also attached
> > patches to add dynamic sub selection for dvds and ogg files. Apply
> > these three patches in order and you can use sub_select event to cycle
> > through subtitles from -sub option, dvd, vobsubs, or ogg text streams,
> > whichever is appropriate.
>
> I suggest you update the docs as well, at least DOCS/tech/slave.txt
> ;-)
All three patches updated.
--Joey
--
"The tide is turning... the enemy is suffering terrible losses..."
--Gen. Custer
-------------- next part --------------
combine vobsub_lang into sub_select
change osd_show_vobsub_changed to sh_video->fps
diff -ur main.sofar/DOCS/tech/slave.txt main.dev/DOCS/tech/slave.txt
--- main.sofar/DOCS/tech/slave.txt 2004-04-27 07:21:35.000000000 +0000
+++ main.dev/DOCS/tech/slave.txt 2004-08-12 23:52:06.501963200 +0000
@@ -71,8 +71,12 @@
get_sub_visibility
Print out subtitle visibility (1 == on, 0 == off).
+sub_select
+ Cycle through the subtitle set. Supported subtitle sources are -sub
+ options on the command line, and VOBSubs.
+
vobsub_lang
- Switch the subtitle language when using VOBSub subtitles.
+ This is a stub linked to sub_select for backwards compatibility.
get_percent_pos
Print out the current position in the file, in integer percentage [0-100).
diff -ur main.sofar/input/input.c main.dev/input/input.c
--- main.sofar/input/input.c 2004-08-10 03:07:23.000000000 +0000
+++ main.dev/input/input.c 2004-08-12 23:40:29.019032000 +0000
@@ -77,7 +77,7 @@
{ MP_CMD_SUB_POS, "sub_pos", 1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
{ MP_CMD_SUB_ALIGNMENT, "sub_alignment",0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } },
{ MP_CMD_SUB_VISIBILITY, "sub_visibility", 0, { {-1,{0}} } },
- { MP_CMD_VOBSUB_LANG, "vobsub_lang", 0, { {-1,{0}} } },
+ { MP_CMD_SUB_SELECT, "vobsub_lang", 0, { {-1,{0}} } }, // for compatibility
{ MP_CMD_SUB_SELECT, "sub_select", 0, { {-1,{0}} } },
{ MP_CMD_GET_PERCENT_POS, "get_percent_pos", 0, { {-1,{0}} } },
{ MP_CMD_GET_TIME_LENGTH, "get_time_length", 0, { {-1,{0}} } },
diff -ur main.sofar/input/input.h main.dev/input/input.h
--- main.sofar/input/input.h 2004-07-17 12:47:12.000000000 +0000
+++ main.dev/input/input.h 2004-08-12 23:40:29.059089600 +0000
@@ -30,7 +30,7 @@
#define MP_CMD_VF_CHANGE_RECTANGLE 28
#define MP_CMD_GAMMA 29
#define MP_CMD_SUB_VISIBILITY 30
-#define MP_CMD_VOBSUB_LANG 31
+// #define MP_CMD_VOBSUB_LANG 31 // combined with SUB_SELECT
#define MP_CMD_MENU 32
#define MP_CMD_SET_MENU 33
#define MP_CMD_GET_TIME_LENGTH 34
diff -ur main.sofar/mplayer.c main.dev/mplayer.c
--- main.sofar/mplayer.c 2004-08-10 03:07:21.000000000 +0000
+++ main.dev/mplayer.c 2004-08-12 23:40:29.089132800 +0000
@@ -3114,19 +3114,6 @@
}
#endif
} break;
- case MP_CMD_VOBSUB_LANG:
- if (vo_vobsub)
- {
- int new_id = vobsub_id + 1;
- if (vobsub_id < 0)
- new_id = 0;
- if ((unsigned int) new_id >= vobsub_get_indexes_count(vo_vobsub))
- new_id = -1;
- if(new_id != vobsub_id)
- osd_show_vobsub_changed = 9;
- vobsub_id = new_id;
- }
- break;
case MP_CMD_SUB_SELECT:
#ifdef USE_SUB
if (set_of_sub_size > 0){ //change subtitle file
@@ -3137,6 +3124,17 @@
vo_osd_changed(OSDTYPE_SUBTITLE);
}
#endif
+ if (vo_vobsub)
+ {
+ int new_id = vobsub_id + 1;
+ if (vobsub_id < 0)
+ new_id = 0;
+ if ((unsigned int) new_id >= vobsub_get_indexes_count(vo_vobsub))
+ new_id = -1;
+ if(new_id != vobsub_id)
+ osd_show_vobsub_changed = sh_video->fps;
+ vobsub_id = new_id;
+ }
break;
case MP_CMD_SUB_FORCED_ONLY:
if (vo_spudec) {
-------------- next part --------------
allow runtime selection of dvd subtitle language (including 'none')
diff -ur main.sofar/DOCS/tech/slave.txt main.dev/DOCS/tech/slave.txt
--- main.sofar/DOCS/tech/slave.txt 2004-08-12 23:53:29.561396800 +0000
+++ main.dev/DOCS/tech/slave.txt 2004-08-12 23:55:04.828384000 +0000
@@ -73,7 +73,7 @@
sub_select
Cycle through the subtitle set. Supported subtitle sources are -sub
- options on the command line, and VOBSubs.
+ options on the command line, VOBSubs, and DVD subtitles.
vobsub_lang
This is a stub linked to sub_select for backwards compatibility.
diff -ur main.sofar/libmpdemux/open.c main.dev/libmpdemux/open.c
--- main.sofar/libmpdemux/open.c 2004-06-25 15:19:11.000000000 +0000
+++ main.dev/libmpdemux/open.c 2004-08-12 23:53:45.544379200 +0000
@@ -636,6 +636,25 @@
return d->nr_of_channels ? d->audio_streams[0].id : -1;
}
+int dvd_number_of_subs(stream_t *stream)
+{
+ dvd_priv_t *d;
+ if (!stream) return -1;
+ d = stream->priv;
+ if (!d) return -1;
+ return d->nr_of_subtitles;
+}
+
+int dvd_lang_from_sid(stream_t *stream, int id)
+{
+ dvd_priv_t *d;
+ if (!stream) return 0;
+ d = stream->priv;
+ if (!d) return 0;
+ if (id >= d->nr_of_subtitles) return 0;
+ return d->subtitles[id].language;
+}
+
int dvd_sid_from_lang(stream_t *stream, unsigned char* lang){
dvd_priv_t *d=stream->priv;
int code,i;
diff -ur main.sofar/libmpdemux/stream.h main.dev/libmpdemux/stream.h
--- main.sofar/libmpdemux/stream.h 2004-03-13 16:10:02.000000000 +0000
+++ main.dev/libmpdemux/stream.h 2004-08-12 23:53:45.574422400 +0000
@@ -321,6 +321,8 @@
stream_language_t subtitles[32];
} dvd_priv_t;
+int dvd_number_of_subs(stream_t *stream);
+int dvd_lang_from_sid(stream_t *stream, int id);
int dvd_aid_from_lang(stream_t *stream, unsigned char* lang);
int dvd_sid_from_lang(stream_t *stream, unsigned char* lang);
int dvd_chapter_from_cell(dvd_priv_t *dvd,int title,int cell);
diff -ur main.sofar/mplayer.c main.dev/mplayer.c
--- main.sofar/mplayer.c 2004-08-12 23:53:29.651526400 +0000
+++ main.dev/mplayer.c 2004-08-12 23:53:45.624494400 +0000
@@ -1586,7 +1586,7 @@
demux_info_print(demuxer);
//================== Read SUBTITLES (DVD & TEXT) ==========================
-if(d_dvdsub->id >= 0 && vo_spudec==NULL && sh_video){
+if(vo_spudec==NULL && sh_video && stream->type==STREAMTYPE_DVD){
if (spudec_ifo) {
unsigned int palette[16], width, height;
@@ -3135,6 +3135,18 @@
osd_show_vobsub_changed = sh_video->fps;
vobsub_id = new_id;
}
+ if (vo_spudec && stream->type == STREAMTYPE_DVD)
+ {
+ int new_id = dvdsub_id + 1;
+ if (dvdsub_id < 0)
+ new_id = 0;
+ if ((unsigned int) new_id >= dvd_number_of_subs(stream))
+ new_id = -1;
+ if(new_id != dvdsub_id)
+ osd_show_vobsub_changed = sh_video->fps;
+ d_dvdsub->id = dvdsub_id = new_id;
+ spudec_reset(vo_spudec);
+ }
break;
case MP_CMD_SUB_FORCED_ONLY:
if (vo_spudec) {
@@ -3557,10 +3569,22 @@
osd_show_sub_visibility--;
} else
if (osd_show_vobsub_changed) {
- const char *language = "none";
- if (vo_vobsub && vobsub_id >= 0)
+ if (vo_vobsub && vobsub_id >= 0) {
+ const char *language = "none";
language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id);
snprintf(osd_text_tmp, 63, "Subtitles: (%d) %s", vobsub_id, language ? language : "unknown");
+ }
+ if (vo_spudec) {
+ char lang[5] = "none";
+ int code = 0;
+ if (dvdsub_id >= 0) code = dvd_lang_from_sid(stream, dvdsub_id);
+ if (code) {
+ lang[0] = code >> 8;
+ lang[1] = code;
+ lang[2] = 0;
+ }
+ snprintf(osd_text_tmp, 63, "Subtitles: (%d) %s", dvdsub_id, lang);
+ }
osd_show_vobsub_changed--;
} else
#ifdef USE_SUB
-------------- next part --------------
support switching ogg text subtitle streams during runtime
diff -ur main.sofar/DOCS/tech/slave.txt main.dev/DOCS/tech/slave.txt
--- main.sofar/DOCS/tech/slave.txt 2004-08-12 23:56:16.241070400 +0000
+++ main.dev/DOCS/tech/slave.txt 2004-08-12 23:57:11.810976000 +0000
@@ -73,7 +73,8 @@
sub_select
Cycle through the subtitle set. Supported subtitle sources are -sub
- options on the command line, VOBSubs, and DVD subtitles.
+ options on the command line, VOBSubs, DVD subtitles, and OGG text
+ streams.
vobsub_lang
This is a stub linked to sub_select for backwards compatibility.
diff -ur main.sofar/libmpdemux/demux_ogg.c main.dev/libmpdemux/demux_ogg.c
--- main.sofar/libmpdemux/demux_ogg.c 2004-08-02 18:01:55.000000000 +0000
+++ main.dev/libmpdemux/demux_ogg.c 2004-08-12 23:56:21.698918400 +0000
@@ -655,12 +655,18 @@
extern void print_wave_header(WAVEFORMATEX *h);
extern void print_video_header(BITMAPINFOHEADER *h);
+static int n_text = 0;
+static int *text_ids = NULL;
+
+int demux_ogg_num_subs() { return n_text; }
+int demux_ogg_sub_id(int index) { return (index < 0) ? index : text_ids[index]; }
+
/// Open an ogg physical stream
int demux_ogg_open(demuxer_t* demuxer) {
ogg_demuxer_t* ogg_d;
stream_t *s;
char* buf;
- int np,s_no, n_audio = 0, n_video = 0, n_text = 0;
+ int np,s_no, n_audio = 0, n_video = 0;
int audio_id = -1, video_id = -1, text_id = -1;
ogg_sync_state* sync;
ogg_page* page;
@@ -902,6 +908,8 @@
if (demuxer->sub->id == n_text)
text_id = ogg_d->num_sub;
n_text++;
+ text_ids = (int *)realloc(text_ids, sizeof(int) * n_text);
+ text_ids[n_text - 1] = ogg_d->num_sub;
demux_ogg_init_sub();
//// Unknown header type
} else
diff -ur main.sofar/mplayer.c main.dev/mplayer.c
--- main.sofar/mplayer.c 2004-08-12 23:56:16.331200000 +0000
+++ main.dev/mplayer.c 2004-08-12 23:56:21.748990400 +0000
@@ -3147,6 +3147,18 @@
d_dvdsub->id = dvdsub_id = new_id;
spudec_reset(vo_spudec);
}
+ if (d_dvdsub && demuxer->type == DEMUXER_TYPE_OGG)
+ {
+ int new_id = dvdsub_id + 1;
+ if (dvdsub_id < 0)
+ new_id = 0;
+ if ((unsigned int) new_id >= demux_ogg_num_subs())
+ new_id = -1;
+ if (new_id != dvdsub_id)
+ osd_show_vobsub_changed = sh_video->fps;
+ dvdsub_id = new_id;
+ d_dvdsub->id = demux_ogg_sub_id(new_id);
+ }
break;
case MP_CMD_SUB_FORCED_ONLY:
if (vo_spudec) {
@@ -3574,6 +3586,12 @@
language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id);
snprintf(osd_text_tmp, 63, "Subtitles: (%d) %s", vobsub_id, language ? language : "unknown");
}
+ if (d_dvdsub && demuxer->type == DEMUXER_TYPE_OGG) {
+ if (dvdsub_id < 0)
+ snprintf(osd_text_tmp, 63, "Subtitles: (off)");
+ else
+ snprintf(osd_text_tmp, 63, "Subtitles: (%d)", dvdsub_id);
+ }
if (vo_spudec) {
char lang[5] = "none";
int code = 0;
More information about the MPlayer-dev-eng
mailing list