[MPlayer-cvslog] r20888 - in trunk/libmpdemux: demux_mkv.c demux_mpg.c demuxer.c demuxer.h

reimar subversion at mplayerhq.hu
Mon Nov 13 17:15:24 CET 2006


Author: reimar
Date: Mon Nov 13 17:15:23 2006
New Revision: 20888

Modified:
   trunk/libmpdemux/demux_mkv.c
   trunk/libmpdemux/demux_mpg.c
   trunk/libmpdemux/demuxer.c
   trunk/libmpdemux/demuxer.h

Log:
Make subtitle stream handling more similar to audio and video streams.


Modified: trunk/libmpdemux/demux_mkv.c
==============================================================================
--- trunk/libmpdemux/demux_mkv.c	(original)
+++ trunk/libmpdemux/demux_mkv.c	Mon Nov 13 17:15:23 2006
@@ -1766,6 +1766,8 @@
 demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track, int vid);
 static int
 demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid);
+static int
+demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track, int sid);
 
 static void
 display_create_tracks (demuxer_t *demuxer)
@@ -1796,7 +1798,7 @@
           break;
         case MATROSKA_TRACK_SUBTITLE:
           type = "subtitles";
-          mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sid);
+          demux_mkv_open_sub(demuxer, mkv_d->tracks[i], sid);
           if (mkv_d->tracks[i]->name)
             mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_NAME=%s\n", sid, mkv_d->tracks[i]->name);
           mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", sid, mkv_d->tracks[i]->language);
@@ -2408,18 +2410,18 @@
 #endif
 
 static int
-demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track)
+demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track, int sid)
 {
   if (track->subtitle_type != MATROSKA_SUBTYPE_UNKNOWN)
     {
+      sh_sub_t *sh = new_sh_sub_sid(demuxer, track->tnum, sid);
       if ((track->subtitle_type == MATROSKA_SUBTYPE_VOBSUB) ||
           (track->subtitle_type == MATROSKA_SUBTYPE_SSA))
         {
           if (track->private_data != NULL)
             {
-              demuxer->sub->sh = malloc(sizeof(sh_sub_t));
-              if (demuxer->sub->sh != NULL)
-                memcpy(demuxer->sub->sh, &track->sh_sub, sizeof(sh_sub_t));
+              if (sh)
+                memcpy(sh, &track->sh_sub, sizeof(sh_sub_t));
             }
         }
     }
@@ -2680,7 +2682,7 @@
     track = demux_mkv_find_track_by_language (mkv_d, dvdsub_lang,
                                               MATROSKA_TRACK_SUBTITLE);
 
-  if (track && !demux_mkv_open_sub (demuxer, track))
+  if (track)
           {
             mp_msg (MSGT_DEMUX, MSGL_INFO,
                     MSGTR_MPDEMUX_MKV_WillDisplaySubtitleTrack, track->tnum);

Modified: trunk/libmpdemux/demux_mpg.c
==============================================================================
--- trunk/libmpdemux/demux_mpg.c	(original)
+++ trunk/libmpdemux/demux_mpg.c	Mon Nov 13 17:15:23 2006
@@ -298,7 +298,7 @@
 
         if(!demux->s_streams[aid]){
             mp_msg(MSGT_DEMUX,MSGL_V,"==> Found subtitle: %d\n",aid);
-            demux->s_streams[aid]=1;
+            new_sh_sub(demux, aid);
         }
 
         if(demux->sub->id > -1)

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	(original)
+++ trunk/libmpdemux/demuxer.c	Mon Nov 13 17:15:23 2006
@@ -201,6 +201,23 @@
   return d;
 }
 
+sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid) {
+  if (id > MAX_S_STREAMS - 1 || id < 0) {
+    mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested sub stream id overflow (%d > %d)\n",
+           id, MAX_S_STREAMS);
+    return NULL;
+  }
+  if (demuxer->s_streams[id])
+    mp_msg(MSGT_DEMUXER, MSGL_WARN, "Sub stream %i redefined\n", id);
+  else {
+    sh_sub_t *sh = calloc(1, sizeof(sh_sub_t));
+    demuxer->s_streams[id] = sh;
+    sh->sid = sid;
+    mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sid);
+  }
+  return demuxer->s_streams[id];
+}
+
 sh_audio_t* new_sh_audio_aid(demuxer_t *demuxer,int id,int aid){
     if(id > MAX_A_STREAMS-1 || id < 0)
     {

Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h	(original)
+++ trunk/libmpdemux/demuxer.h	Mon Nov 13 17:15:23 2006
@@ -128,6 +128,7 @@
 } demuxer_info_t;
 
 typedef struct {
+  int sid;
   char type;                    // t = text, v = VobSub, a = SSA/ASS
   int has_palette;              // If we have a valid palette
   unsigned int palette[16];     // for VobSubs
@@ -142,6 +143,7 @@
 
 #define MAX_A_STREAMS 256
 #define MAX_V_STREAMS 256
+#define MAX_S_STREAMS 32
 
 struct demuxer_st;
 
@@ -199,7 +201,7 @@
   // stream headers:
   void* a_streams[MAX_A_STREAMS]; // audio streams (sh_audio_t)
   void* v_streams[MAX_V_STREAMS]; // video sterams (sh_video_t)
-  char s_streams[32];   // dvd subtitles (flag)
+  void *s_streams[MAX_S_STREAMS];   // dvd subtitles (flag)
 
   demux_chapter_t* chapters;
   int num_chapters;



More information about the MPlayer-cvslog mailing list