[MPlayer-dev-eng] [PATCH] initialize sh_audio/sh_video on creation

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Nov 28 18:33:50 CET 2006


Hello,
currently the members of the sh_audio and sh_video structs are set in
demux_avi and only for the selected streams. This is especially bad for
implementing stream switching.
Thus I propose moving at least the easy and essential once to aviheader,
where they will be set for all streams found.
Ok to apply?

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: demux_avi.c
===================================================================
--- demux_avi.c	(revision 21356)
+++ demux_avi.c	(working copy)
@@ -499,12 +500,8 @@
       d_audio->sh=sh_audio=NULL;
     } else {
       sh_audio=d_audio->sh;sh_audio->ds=d_audio;
-      sh_audio->format=sh_audio->wf->wFormatTag;
     }
   }
-  // calc. FPS:
-  sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
-  sh_video->frametime=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
 
   // calculating audio/video bitrate:
   if(priv->idx_size>0){
@@ -546,7 +543,6 @@
     if(sh_audio){
       if(sh_audio->wf->nAvgBytesPerSec && sh_audio->audio.dwSampleSize!=1){
         asize=(float)sh_audio->wf->nAvgBytesPerSec*sh_audio->audio.dwLength*sh_audio->audio.dwScale/sh_audio->audio.dwRate;
-        sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
       } else {
         asize=sh_audio->audio.dwLength;
         sh_audio->i_bps=(float)asize/(sh_video->frametime*priv->numberofframes);
@@ -557,11 +553,6 @@
     sh_video->i_bps=(float)vsize/(sh_video->frametime*priv->numberofframes);
   }
 
-  if (sh_video)
-    sh_video->stream_delay = (float)sh_video->video.dwStart * sh_video->video.dwScale/sh_video->video.dwRate;
-  if (sh_audio)
-    sh_audio->stream_delay = (float)sh_audio->audio.dwStart * sh_audio->audio.dwScale/sh_audio->audio.dwRate;
-
   return demuxer;
   
 }
Index: aviheader.c
===================================================================
--- aviheader.c	(revision 21356)
+++ aviheader.c	(working copy)
@@ -196,10 +196,12 @@
       if(h.fccType==streamtypeVIDEO){
         sh_video=new_sh_video(demuxer,stream_id);
         memcpy(&sh_video->video,&h,sizeof(h));
+        sh_video->stream_delay = (float)sh_video->video.dwStart * sh_video->video.dwScale/sh_video->video.dwRate;
       } else
       if(h.fccType==streamtypeAUDIO){
         sh_audio=new_sh_audio(demuxer,stream_id);
         memcpy(&sh_audio->audio,&h,sizeof(h));
+        sh_audio->stream_delay = (float)sh_audio->audio.dwStart * sh_audio->audio.dwScale/sh_audio->audio.dwRate;
       }
       last_fccType=h.fccType;
       if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_strh(&h,MSGL_V);
@@ -265,8 +267,8 @@
 	    sh_video->bih->biSize=chunksize;
         if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_video_header(sh_video->bih,MSGL_V);
         chunksize=0;
-//        sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
-//        sh_video->frametime=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
+        sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
+        sh_video->frametime=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
 //        if(demuxer->video->id==-1) demuxer->video->id=stream_id;
         // IdxFix:
         idxfix_videostream=stream_id;
@@ -317,6 +319,8 @@
 	    wf_size < sizeof(WAVEFORMATEX)+sh_audio->wf->cbSize) {
 	    sh_audio->wf=realloc(sh_audio->wf, sizeof(WAVEFORMATEX)+sh_audio->wf->cbSize);
 	}
+	sh_audio->format=sh_audio->wf->wFormatTag;
+	sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
         chunksize=0;
         if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_wave_header(sh_audio->wf,MSGL_V);
 	++priv->audio_streams;


More information about the MPlayer-dev-eng mailing list