changeset 13089:b9171604a4ac

moved combined vobsub_lang into sub_select add support for dvd subs and ogg subs into sub_select document sub_select vobsub_lang left as a link to sub_select for backwards compatibility
author joey
date Sun, 22 Aug 2004 18:47:48 +0000
parents e624cc4fc290
children 0c37bcfc5ef0
files DOCS/tech/slave.txt input/input.c input/input.h libmpdemux/demux_ogg.c libmpdemux/open.c libmpdemux/stream.h mplayer.c
diffstat 7 files changed, 94 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/tech/slave.txt	Sun Aug 22 17:09:42 2004 +0000
+++ b/DOCS/tech/slave.txt	Sun Aug 22 18:47:48 2004 +0000
@@ -71,8 +71,13 @@
 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, VOBSubs, DVD subtitles, and OGG text
+    streams.
+
 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).
--- a/input/input.c	Sun Aug 22 17:09:42 2004 +0000
+++ b/input/input.c	Sun Aug 22 18:47:48 2004 +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}} } },
--- a/input/input.h	Sun Aug 22 17:09:42 2004 +0000
+++ b/input/input.h	Sun Aug 22 18:47:48 2004 +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
--- a/libmpdemux/demux_ogg.c	Sun Aug 22 17:09:42 2004 +0000
+++ b/libmpdemux/demux_ogg.c	Sun Aug 22 18:47:48 2004 +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
--- a/libmpdemux/open.c	Sun Aug 22 17:09:42 2004 +0000
+++ b/libmpdemux/open.c	Sun Aug 22 18:47:48 2004 +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;
--- a/libmpdemux/stream.h	Sun Aug 22 17:09:42 2004 +0000
+++ b/libmpdemux/stream.h	Sun Aug 22 18:47:48 2004 +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);
--- a/mplayer.c	Sun Aug 22 17:09:42 2004 +0000
+++ b/mplayer.c	Sun Aug 22 18:47:48 2004 +0000
@@ -1587,7 +1587,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;
@@ -3115,19 +3115,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  
@@ -3138,6 +3125,41 @@
         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;
+    }
+    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);
+    }
+    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) {
@@ -3560,10 +3582,28 @@
 	  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 (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;
+	      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