[Mplayer-cvslog] CVS: main/libmpdemux demuxer.h, 1.68, 1.69 demux_ogg.c, 1.55, 1.56

Moritz Bunkus CVS syncmail at mplayerhq.hu
Tue Aug 24 23:20:27 CEST 2004


CVS change done by Moritz Bunkus CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv28222/libmpdemux

Modified Files:
	demuxer.h demux_ogg.c 
Log Message:
Do not use globals. Put the variables into the appropriate demuxer struct instead.

Index: demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- demuxer.h	12 Apr 2004 14:19:12 -0000	1.68
+++ demuxer.h	24 Aug 2004 21:20:24 -0000	1.69
@@ -278,6 +278,12 @@
 int demux_info_print(demuxer_t *demuxer);
 int demux_control(demuxer_t *demuxer, int cmd, void *arg);
 
+#ifdef HAVE_OGGVORBIS
+/* Found in demux_ogg.c */
+int demux_ogg_num_subs(demuxer_t *demuxer);
+int demux_ogg_sub_id(demuxer_t *demuxer, int index);
+#endif
+
 #endif
 
 extern unsigned long demuxer_get_time_length(demuxer_t *demuxer);

Index: demux_ogg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ogg.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- demux_ogg.c	22 Aug 2004 18:47:48 -0000	1.55
+++ demux_ogg.c	24 Aug 2004 21:20:24 -0000	1.56
@@ -128,6 +128,10 @@
   int num_syncpoint;
   off_t pos, last_size;
   int64_t final_granulepos;
+
+  /* Used for subtitle switching. */
+  int n_text;
+  int *text_ids;
 } ogg_demuxer_t;
 
 #define NUM_VORBIS_HDR_PACKETS 3
@@ -655,11 +659,29 @@
 extern void print_wave_header(WAVEFORMATEX *h);
 extern void print_video_header(BITMAPINFOHEADER *h);
 
-static int n_text = 0;
-static int *text_ids = NULL;
+/** \brief Return the number of subtitle tracks in the file.
+
+  \param demuxer The demuxer for which the number of subtitle tracks
+  should be returned.
+*/
+int demux_ogg_num_subs(demuxer_t *demuxer) {
+  ogg_demuxer_t *ogg_d = (ogg_demuxer_t *)demuxer->priv;
+  return ogg_d->n_text;
+}
 
-int demux_ogg_num_subs() { return n_text; }
-int demux_ogg_sub_id(int index) { return (index < 0) ? index : text_ids[index]; }
+/** \brief Change the current subtitle stream and return its ID.
+
+  \param demuxer The demuxer whose subtitle stream will be changed.
+  \param new_num The number of the new subtitle track. The number must be
+  between 0 and ogg_d->n_text - 1.
+
+  \returns The Ogg stream number ( = page serial number) of the newly selected
+  track.
+*/
+int demux_ogg_sub_id(demuxer_t *demuxer, int index) {
+  ogg_demuxer_t *ogg_d = (ogg_demuxer_t *)demuxer->priv;
+  return (index < 0) ? index : (index >= ogg_d->n_text) ? -1 : ogg_d->text_ids[index];
+}
 
 /// Open an ogg physical stream
 int demux_ogg_open(demuxer_t* demuxer) {
@@ -905,11 +927,11 @@
           mp_msg(MSGT_DEMUX, MSGL_V, "Ogg stream %d is text\n", ogg_d->num_sub);
 	  ogg_d->subs[ogg_d->num_sub].samplerate= get_uint64(&st->time_unit)/10;
 	  ogg_d->subs[ogg_d->num_sub].text = 1;
-          if (demuxer->sub->id == n_text)
+          if (demuxer->sub->id == ogg_d->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;
+          ogg_d->n_text++;
+          ogg_d->text_ids = (int *)realloc(ogg_d->text_ids, sizeof(int) * ogg_d->n_text);
+          ogg_d->text_ids[ogg_d->n_text - 1] = ogg_d->num_sub;
           demux_ogg_init_sub();
 	//// Unknown header type
       } else
@@ -977,7 +999,7 @@
   /* Disable the subs only if there are no text streams at all.
      Otherwise the stream to display might be chosen later when the comment
      packet is encountered and the user used -slang instead of -sid. */
-  if(!n_text)
+  if(!ogg_d->n_text)
     demuxer->sub->id = -2;
   else if (text_id >= 0) {
     demuxer->sub->id = text_id;
@@ -994,7 +1016,7 @@
     demux_ogg_scan_stream(demuxer);
   }
 
-  mp_msg(MSGT_DEMUX,MSGL_V,"Ogg demuxer : found %d audio stream%s, %d video stream%s and %d text stream%s\n",n_audio,n_audio>1?"s":"",n_video,n_video>1?"s":"",n_text,n_text>1?"s":"");
+  mp_msg(MSGT_DEMUX,MSGL_V,"Ogg demuxer : found %d audio stream%s, %d video stream%s and %d text stream%s\n",n_audio,n_audio>1?"s":"",n_video,n_video>1?"s":"",ogg_d->n_text,ogg_d->n_text>1?"s":"");
  
   return 1;
 }
@@ -1370,6 +1392,8 @@
     free(ogg_d->subs);
   if(ogg_d->syncpoints)
     free(ogg_d->syncpoints);
+  if (ogg_d->text_ids)
+    free(ogg_d->text_ids);
   free(ogg_d);
 }
 




More information about the MPlayer-cvslog mailing list