[MPlayer-cvslog] r19546 - in trunk: Gui/mplayer/gtk/menu.c libmpdemux/demux_mkv.c libmpdemux/demux_ogg.c libmpdemux/demux_ts.c libmpdemux/demuxer.c libmpdemux/stheader.h

reimar subversion at mplayerhq.hu
Sat Aug 26 21:17:04 CEST 2006


Author: reimar
Date: Sat Aug 26 21:17:04 2006
New Revision: 19546

Modified:
   trunk/Gui/mplayer/gtk/menu.c
   trunk/libmpdemux/demux_mkv.c
   trunk/libmpdemux/demux_ogg.c
   trunk/libmpdemux/demux_ts.c
   trunk/libmpdemux/demuxer.c
   trunk/libmpdemux/stheader.h

Log:
Get rid of demux_aid_vid_mismatch mess.


Modified: trunk/Gui/mplayer/gtk/menu.c
==============================================================================
--- trunk/Gui/mplayer/gtk/menu.c	(original)
+++ trunk/Gui/mplayer/gtk/menu.c	Sat Aug 26 21:17:04 2006
@@ -16,6 +16,7 @@
 
 #include "../../stream/stream.h"
 #include "../../libmpdemux/demuxer.h"
+#include "../../libmpdemux/stheader.h"
 
 #include "../pixmaps/ab.xpm"
 #include "../pixmaps/half.xpm"
@@ -546,20 +547,14 @@
     
     if ( c > 1 )
      {
-      int basedec = 0;
-      int setdec = 0;
       SubMenu=AddSubMenu( window1, (const char*)empty_xpm, Menu,MSGTR_MENU_AudioTrack );
       for ( i=0;i < MAX_A_STREAMS;i++ )
        if ( ((demuxer_t *)guiIntfStruct.demuxer)->a_streams[i] )
         {
+         int aid = ((sh_audio_t *)((demuxer_t *)guiIntfStruct.demuxer)->a_streams[i])->aid;
          char tmp[32];
-         if (!(setdec) )
-           {
-           basedec = (i > 1 ? i : 1);
-           setdec = 1;
-           }
-         snprintf( tmp,32,MSGTR_MENU_Track,(i-(basedec-1)) );
-         AddMenuItem( window1, (const char*)empty_xpm, SubMenu,tmp,( (i-basedec) << 16 ) + evSetAudio );
+         snprintf( tmp,32,MSGTR_MENU_Track,aid );
+         AddMenuItem( window1, (const char*)empty_xpm, SubMenu,tmp,( aid << 16 ) + evSetAudio );
         }
      }
 
@@ -572,9 +567,10 @@
       for ( i=0;i < MAX_V_STREAMS;i++ )
        if ( ((demuxer_t *)guiIntfStruct.demuxer)->v_streams[i] )
         {
+         int vid = ((sh_video_t *)((demuxer_t *)guiIntfStruct.demuxer)->v_streams[i])->vid;
          char tmp[32];
-         snprintf( tmp,32,MSGTR_MENU_Track,i );
-         AddMenuItem( window1, (const char*)empty_xpm, SubMenu,tmp,( i << 16 ) + evSetVideo );
+         snprintf( tmp,32,MSGTR_MENU_Track,vid );
+         AddMenuItem( window1, (const char*)empty_xpm, SubMenu,tmp,( vid << 16 ) + evSetVideo );
         }
      }
    }

Modified: trunk/libmpdemux/demux_mkv.c
==============================================================================
--- trunk/libmpdemux/demux_mkv.c	(original)
+++ trunk/libmpdemux/demux_mkv.c	Sat Aug 26 21:17:04 2006
@@ -271,7 +271,6 @@
 extern char *dvdsub_lang;
 extern char *audio_lang;
 extern int dvdsub_id;
-extern int demux_aid_vid_mismatch;
 
 
 static mkv_track_t *
@@ -1687,9 +1686,15 @@
   return res;
 }
 
+static int
+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 void
-display_tracks (mkv_demuxer_t *mkv_d)
+display_create_tracks (demuxer_t *demuxer)
 {
+  mkv_demuxer_t *mkv_d = (mkv_demuxer_t *)demuxer->priv;
   int i, vid=0, aid=0, sid=0;
 
   for (i=0; i<mkv_d->num_tracks; i++)
@@ -1700,12 +1705,12 @@
         {
         case MATROSKA_TRACK_VIDEO:
           type = "video";
-          mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ID=%d\n", vid);
+          demux_mkv_open_video(demuxer, mkv_d->tracks[i], vid);
           sprintf (str, "-vid %u", vid++);
           break;
         case MATROSKA_TRACK_AUDIO:
           type = "audio";
-          mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", aid);
+          demux_mkv_open_audio(demuxer, mkv_d->tracks[i], aid);
           mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", aid, mkv_d->tracks[i]->language);
           sprintf (str, "-aid %u, -alang %.5s",aid++,mkv_d->tracks[i]->language);
           break;
@@ -1722,7 +1727,7 @@
 }
 
 static int
-demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track)
+demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track, int vid)
 {
   BITMAPINFOHEADER *bih;
   void *ImageDesc = NULL;
@@ -1878,7 +1883,7 @@
         }
     }
 
-  sh_v = new_sh_video (demuxer, track->tnum);
+  sh_v = new_sh_video_vid (demuxer, track->tnum, vid);
   sh_v->bih = bih;
   sh_v->format = sh_v->bih->biCompression;
   if (track->v_frate == 0.0)
@@ -1911,10 +1916,10 @@
 }
 
 static int
-demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track)
+demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid)
 {
   mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
-  sh_audio_t *sh_a = new_sh_audio(demuxer, track->tnum);
+  sh_audio_t *sh_a = new_sh_audio_aid(demuxer, track->tnum, aid);
   demux_packet_t *dp;
   if(!sh_a) return 1;
   mkv_d->audio_tracks[mkv_d->last_aid] = track->tnum;
@@ -2394,8 +2399,6 @@
 
   mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] + a segment...\n");
 
-  demux_aid_vid_mismatch = 1; // don't identify in new_sh_* since ids don't match
-
   mkv_d = (mkv_demuxer_t *) malloc (sizeof (mkv_demuxer_t));
   memset (mkv_d, 0, sizeof(mkv_demuxer_t));
   demuxer->priv = mkv_d;
@@ -2476,7 +2479,7 @@
         }
     }
 
-  display_tracks (mkv_d);
+  display_create_tracks (demuxer);
 
   /* select video track */
   track = NULL;
@@ -2505,7 +2508,7 @@
     track = demux_mkv_find_track_by_num (mkv_d, demuxer->video->id,
                                          MATROSKA_TRACK_VIDEO);
 
-  if (track && !demux_mkv_open_video (demuxer, track))
+  if (track && demuxer->v_streams[track->tnum])
               {
                 mp_msg (MSGT_DEMUX, MSGL_INFO,
                         "[mkv] Will play video track %u\n", track->tnum);
@@ -2562,7 +2565,7 @@
     {
       if(mkv_d->tracks[i]->type != MATROSKA_TRACK_AUDIO)
           continue;
-      if(!demux_mkv_open_audio (demuxer, mkv_d->tracks[i]))
+      if(demuxer->a_streams[track->tnum])
         {
           if(track && mkv_d->tracks[i] == track)
             {

Modified: trunk/libmpdemux/demux_ogg.c
==============================================================================
--- trunk/libmpdemux/demux_ogg.c	(original)
+++ trunk/libmpdemux/demux_ogg.c	Sat Aug 26 21:17:04 2006
@@ -162,7 +162,6 @@
 
 extern char *dvdsub_lang, *audio_lang;
 extern int dvdsub_id;
-extern int demux_aid_vid_mismatch;
 
 //-------- subtitle support - should be moved to decoder layer, and queue
 //                          - subtitles up in demuxer buffer...
@@ -919,20 +918,18 @@
     sh_a = NULL;
     sh_v = NULL;
 
-    demux_aid_vid_mismatch = 1; // don't identify in new_sh_* since ids don't match
     ogg_d->subs[ogg_d->num_sub].ogg_d = ogg_d;
 
     // Check for Vorbis
     if(pack.bytes >= 7 && ! strncmp(&pack.packet[1],"vorbis", 6) ) {
-      sh_a = new_sh_audio(demuxer,ogg_d->num_sub);
+      sh_a = new_sh_audio_aid(demuxer,ogg_d->num_sub, n_audio);
       sh_a->format = FOURCC_VORBIS;
       ogg_d->subs[ogg_d->num_sub].vorbis = 1;
-      mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
       ogg_d->subs[ogg_d->num_sub].id = n_audio;
       n_audio++;
       mp_msg(MSGT_DEMUX,MSGL_INFO,"[Ogg] stream %d: audio (Vorbis), -aid %d\n",ogg_d->num_sub,n_audio-1);
     } else if (pack.bytes >= 80 && !strncmp(pack.packet,"Speex", 5)) {
-      sh_a = new_sh_audio(demuxer, ogg_d->num_sub);
+      sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio);
       sh_a->wf = calloc(1, sizeof(WAVEFORMATEX) + pack.bytes);
       sh_a->format = FOURCC_SPEEX;
       sh_a->samplerate = sh_a->wf->nSamplesPerSec = get_uint32(&pack.packet[36]);
@@ -947,7 +944,6 @@
 
       ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate;
       ogg_d->subs[ogg_d->num_sub].speex = 1;
-      mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
       ogg_d->subs[ogg_d->num_sub].id = n_audio;
       n_audio++;
       mp_msg(MSGT_DEMUX,MSGL_INFO,"[Ogg] stream %d: audio (Speex), -aid %d\n",ogg_d->num_sub,n_audio-1);
@@ -968,7 +964,7 @@
 		   errorCode);
 	else
 	{
-	    sh_v = new_sh_video(demuxer,ogg_d->num_sub);
+	    sh_v = new_sh_video_vid(demuxer,ogg_d->num_sub, n_video);
 
 	    sh_v->context = NULL;
 	    sh_v->bih = calloc(1,sizeof(BITMAPINFOHEADER));
@@ -986,7 +982,6 @@
 				      sh_v->bih->biWidth*sh_v->bih->biHeight);
 	    ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps;
 	    ogg_d->subs[ogg_d->num_sub].theora = 1;
-	    mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ID=%d\n", n_video);
 	    ogg_d->subs[ogg_d->num_sub].id = n_video;
 	    n_video++;
 	    mp_msg(MSGT_DEMUX,MSGL_INFO,
@@ -1001,9 +996,8 @@
 #   endif /* HAVE_OGGTHEORA */
 #   ifdef HAVE_FLAC
     } else if (pack.bytes >= 4 && !strncmp (&pack.packet[0], "fLaC", 4)) {
-	sh_a = new_sh_audio(demuxer,ogg_d->num_sub);
+	sh_a = new_sh_audio_aid(demuxer,ogg_d->num_sub, n_audio);
 	sh_a->format =  mmioFOURCC('f', 'L', 'a', 'C');
-	mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
 	ogg_d->subs[ogg_d->num_sub].id = n_audio;
 	n_audio++;
 	ogg_d->subs[ogg_d->num_sub].flac = 1;
@@ -1016,7 +1010,7 @@
 
        // Old video header
       if(get_uint32 (pack.packet+96) == 0x05589f80 && pack.bytes >= 184) {
-	sh_v = new_sh_video(demuxer,ogg_d->num_sub);
+	sh_v = new_sh_video_vid(demuxer,ogg_d->num_sub, n_video);
 	sh_v->bih = calloc(1,sizeof(BITMAPINFOHEADER));
 	sh_v->bih->biSize=sizeof(BITMAPINFOHEADER);
 	sh_v->bih->biCompression=
@@ -1032,7 +1026,6 @@
 	sh_v->bih->biSizeImage=(sh_v->bih->biBitCount>>3)*sh_v->bih->biWidth*sh_v->bih->biHeight;
 
 	ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps;
-	mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ID=%d\n", n_video);
 	ogg_d->subs[ogg_d->num_sub].id = n_video;
 	n_video++;
 	mp_msg(MSGT_DEMUX,MSGL_INFO,"[Ogg] stream %d: video (FOURCC %c%c%c%c), -vid %d\n",
@@ -1041,7 +1034,7 @@
 	// Old audio header
       } else if(get_uint32(pack.packet+96) == 0x05589F81) {
 	unsigned int extra_size;
-	sh_a = new_sh_audio(demuxer,ogg_d->num_sub);
+	sh_a = new_sh_audio_aid(demuxer,ogg_d->num_sub, n_audio);
 	extra_size = get_uint16(pack.packet+140);
 	sh_a->wf = calloc(1,sizeof(WAVEFORMATEX)+extra_size);
 	sh_a->format = sh_a->wf->wFormatTag = get_uint16(pack.packet+124);
@@ -1056,7 +1049,6 @@
 	  memcpy(((char *)sh_a->wf)+sizeof(WAVEFORMATEX),pack.packet+142,extra_size);
 
 	ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; // * sh_a->channels;
-	mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
 	ogg_d->subs[ogg_d->num_sub].id = n_audio;
 	n_audio++;
 	mp_msg(MSGT_DEMUX,MSGL_INFO,"[Ogg] stream %d: audio (format 0x%04x), -aid %d\n",ogg_d->num_sub,sh_a->format,n_audio-1);
@@ -1070,7 +1062,7 @@
       stream_header *st = (stream_header*)(pack.packet+1);
       /// New video header
       if(strncmp(st->streamtype,"video",5) == 0) {
-	sh_v = new_sh_video(demuxer,ogg_d->num_sub);
+	sh_v = new_sh_video_vid(demuxer,ogg_d->num_sub, n_video);
 	sh_v->bih = calloc(1,sizeof(BITMAPINFOHEADER));
 	sh_v->bih->biSize=sizeof(BITMAPINFOHEADER);
 	sh_v->bih->biCompression=
@@ -1086,7 +1078,6 @@
 	sh_v->bih->biSizeImage=(sh_v->bih->biBitCount>>3)*sh_v->bih->biWidth*sh_v->bih->biHeight;
 
 	ogg_d->subs[ogg_d->num_sub].samplerate= sh_v->fps;
-	mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ID=%d\n", n_video);
 	ogg_d->subs[ogg_d->num_sub].id = n_video;
 	n_video++;
 	mp_msg(MSGT_DEMUX,MSGL_INFO,"[Ogg] stream %d: video (FOURCC %c%c%c%c), -vid %d\n",
@@ -1111,7 +1102,7 @@
 	  extra_offset = 4;
 	}
 
-	sh_a = new_sh_audio(demuxer,ogg_d->num_sub);
+	sh_a = new_sh_audio_aid(demuxer,ogg_d->num_sub, n_audio);
 	sh_a->wf = calloc(1,sizeof(WAVEFORMATEX)+extra_size);
 	sh_a->format =  sh_a->wf->wFormatTag = strtol(buffer, NULL, 16);
 	sh_a->channels = sh_a->wf->nChannels = get_uint16(&st->sh.audio.channels);
@@ -1125,7 +1116,6 @@
 	  memcpy(((char *)sh_a->wf)+sizeof(WAVEFORMATEX),((char *)(st+1))+extra_offset,extra_size);
 
 	ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; // * sh_a->channels;
-	mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
 	ogg_d->subs[ogg_d->num_sub].id = n_audio;
 	n_audio++;
 	mp_msg(MSGT_DEMUX,MSGL_INFO,"[Ogg] stream %d: audio (format 0x%04x), -aid %d\n",ogg_d->num_sub,sh_a->format,n_audio-1);

Modified: trunk/libmpdemux/demux_ts.c
==============================================================================
--- trunk/libmpdemux/demux_ts.c	(original)
+++ trunk/libmpdemux/demux_ts.c	Sat Aug 26 21:17:04 2006
@@ -62,7 +62,6 @@
 int ts_keep_broken=0;
 off_t ts_probe = TS_MAX_PROBE_SIZE;
 extern char *dvdsub_lang, *audio_lang;	//for -alang
-extern int demux_aid_vid_mismatch;
 
 typedef enum
 {
@@ -935,12 +934,10 @@
 	demuxer->sub->id = params.spid;
 	priv->prog = params.prog;
 
-	demux_aid_vid_mismatch = 1; // don't identify in new_sh_* since ids don't match
-
 	if(params.vtype != UNKNOWN)
 	{
 		ES_stream_t *es = priv->ts.pids[params.vpid];
-		sh_video = new_sh_video(demuxer, 0);
+		sh_video = new_sh_video_vid(demuxer, 0, es->pid);
 		if(params.vtype == VIDEO_AVC && es->extradata && es->extradata_len)
 		{
 			int w = 0, h = 0;
@@ -966,7 +963,7 @@
 	if(params.atype != UNKNOWN)
 	{
 		ES_stream_t *es = priv->ts.pids[params.apid];
-		sh_audio = new_sh_audio(demuxer, 0);
+		sh_audio = new_sh_audio_aid(demuxer, 0, es->pid);
 		priv->ts.streams[params.apid].id = 0;
 		priv->ts.streams[params.apid].sh = sh_audio;
 		priv->ts.streams[params.apid].type = TYPE_AUDIO;
@@ -2756,7 +2753,7 @@
 		{
 			if((IS_AUDIO(tss->type) || IS_AUDIO(tss->subtype)) && is_start && !priv->ts.streams[pid].sh && priv->last_aid+1 < MAX_A_STREAMS)
 			{
-				sh_audio_t *sh = new_sh_audio(demuxer, priv->last_aid+1);
+				sh_audio_t *sh = new_sh_audio_aid(demuxer, priv->last_aid+1, pid);
 				if(sh)
 				{
 					sh->format = IS_AUDIO(tss->type) ? tss->type : tss->subtype;

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	(original)
+++ trunk/libmpdemux/demuxer.c	Sat Aug 26 21:17:04 2006
@@ -126,10 +126,6 @@
   NULL
 };
 
-// Should be set to 1 by demux module if ids it passes to new_sh_audio and
-// new_sh_video don't match aids and vids it accepts from the command line
-int demux_aid_vid_mismatch = 0;
-
 void free_demuxer_stream(demux_stream_t *ds){
     ds_free_packs(ds);
     free(ds);
@@ -203,7 +199,7 @@
   return d;
 }
 
-sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id){
+sh_audio_t* new_sh_audio_aid(demuxer_t *demuxer,int id,int aid){
     if(id > MAX_A_STREAMS-1 || id < 0)
     {
 	mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested audio stream id overflow (%d > %d)\n",
@@ -223,9 +219,9 @@
         sh->sample_format=AF_FORMAT_S16_NE;
         sh->audio_out_minsize=8192;/* default size, maybe not enough for Win32/ACM*/
         sh->pts=MP_NOPTS_VALUE;
-        if (!demux_aid_vid_mismatch)
-          mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", id);
+          mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", aid);
     }
+    ((sh_audio_t *)demuxer->a_streams[id])->aid = aid;
     return demuxer->a_streams[id];
 }
 
@@ -237,7 +233,7 @@
     free(sh);
 }
 
-sh_video_t* new_sh_video(demuxer_t *demuxer,int id){
+sh_video_t* new_sh_video_vid(demuxer_t *demuxer,int id,int vid){
     if(id > MAX_V_STREAMS-1 || id < 0)
     {
 	mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested video stream id overflow (%d > %d)\n",
@@ -250,9 +246,9 @@
         mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_FoundVideoStream,id);
         demuxer->v_streams[id]=malloc(sizeof(sh_video_t));
         memset(demuxer->v_streams[id],0,sizeof(sh_video_t));
-        if (!demux_aid_vid_mismatch)
-          mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ID=%d\n", id);
+          mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ID=%d\n", vid);
     }
+    ((sh_video_t *)demuxer->v_streams[id])->vid = vid;
     return demuxer->v_streams[id];
 }
 
@@ -814,8 +810,6 @@
   int demuxer_force = 0, audio_demuxer_force = 0,
       sub_demuxer_force = 0;
 
-  demux_aid_vid_mismatch = 0;
-
   if ((demuxer_type = get_demuxer_type_from_name(demuxer_name, &demuxer_force)) < 0) {
     mp_msg(MSGT_DEMUXER,MSGL_ERR,"-demuxer %s does not exist.\n",demuxer_name);
   }

Modified: trunk/libmpdemux/stheader.h
==============================================================================
--- trunk/libmpdemux/stheader.h	(original)
+++ trunk/libmpdemux/stheader.h	Sat Aug 26 21:17:04 2006
@@ -7,6 +7,7 @@
 // Stream headers:
 
 typedef struct {
+  int aid;
   demux_stream_t *ds;
   struct codecs_st *codec;
   unsigned int format;
@@ -52,6 +53,7 @@
 } sh_audio_t;
 
 typedef struct {
+  int vid;
   demux_stream_t *ds;
   struct codecs_st *codec;
   unsigned int format;
@@ -89,8 +91,10 @@
 } sh_video_t;
 
 // demuxer.c:
-sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id);
-sh_video_t* new_sh_video(demuxer_t *demuxer,int id);
+#define new_sh_audio(d, i) new_sh_audio_aid(d, i, i)
+sh_audio_t* new_sh_audio_aid(demuxer_t *demuxer,int id,int aid);
+#define new_sh_video(d, i) new_sh_video_vid(d, i, i)
+sh_video_t* new_sh_video_vid(demuxer_t *demuxer,int id,int vid);
 void free_sh_audio(demuxer_t *demuxer, int id);
 void free_sh_video(sh_video_t *sh);
 



More information about the MPlayer-cvslog mailing list