[MPlayer-users] RealMedia audio/video de-sync

Mica Telodico maria_libera2000 at yahoo.it
Sun Feb 23 14:33:01 CET 2003


 --- Balatoni Denes <pnis at coder.hu> ha scritto: >
[Automatic answer: RTFM (read DOCS, FAQ), also read
> DOCS/bugreports.html]
> > Hi!
> 
> There was a patch on mplayer-dev-eng that probably
> fixes this a/v sync issue.
> Unfortunatelly mailman cut it from the mail in the
> archive, so I attached it 
> to this mail too.
> 
> bye
> Denes
> 
> ps: apply it in libmpdemux/ dir.
> 
> On 2003. február 23. 12:37, Mica Telodico wrote:
> > [Automatic answer: RTFM (read DOCS, FAQ), also
> read DOCS/bugreports.html]
> > Hi all, I have a problem with some RM files
> > syncronization.
> >
> > This files are about 21 MB ad the duration time is
> > about 25-30 Mins , so are quite compressed , and
> the
> > problem can be this.
> >
> > I' ve tried to use RealPlayer8-9 and RealONE
> codecs
> > but without results.
> >
> > The problem is that these files seems to start
> > correctly and syncronized , but after 1 or 2
> minutes,
> > --- demux_real.c	2003-02-05 23:51:17.000000000
+0100
> +++ demux_real.c	2003-02-18 23:11:52.000000000 +0100
> @@ -35,6 +35,7 @@
>  //#define mp_dbg(mod,lev, args... )
> mp_msg_c((mod<<8)|lev, ## args )
>  
>  #define MKTAG(a, b, c, d) (a | (b << 8) | (c << 16)
> | (d << 24))
> +#define ABS(a) (((a)<0) ? (0-(a)) : (a))
>  
>  #define MAX_STREAMS 32
>  
> @@ -60,9 +61,10 @@
>      int		current_vpacket;
>      
>      // timestamp correction:
> +    int		kf_pts_error; // difference between kf_pts
> and stream pts
>      int		kf_pts;	// timestamp of next video
> keyframe
>      int		a_pts;	// previous audio timestamp
> -    float	v_pts;  // previous video timestamp
> +    int		v_pts;  // previous video timestamp
>      
>      /* stream id table */
>  //    int		last_a_stream;
> @@ -307,33 +309,55 @@
>      priv = malloc(sizeof(real_priv_t));
>      memset(priv, 0, sizeof(real_priv_t));
>      demuxer->priv = priv;
> +    priv->kf_pts=65535;
>  
>      return 1;
>  }
>  
>  void hexdump(char *, unsigned long);
>  
> +static int calcts(int kf, int ts, int error){
> +    int tmp=kf;
> +    tmp+=error;
> +    tmp+=ts&(~0x1fff);	// combine with packet
> timestamp
> +    if(tmp<ts-4096) tmp+=8192; else // workaround
> wrap-around problems
> +    if(tmp>ts+4096) tmp-=8192;
> +    return tmp;
> +}
> +
>  static float real_fix_timestamp(real_priv_t* priv,
> unsigned char* s, int timestamp, float frametime,
> unsigned int format){
>    float v_pts;
>    int kf=timestamp;
> -  if(format==0x30335652){ // RV30 timestamps:
> -    kf=2*(((s[1]&15)<<8)+s[2]); // 12-bit timestamp
> from frame header
> -    //kf=((s[1]<<8)+s[2])>>3; // 12-bit timestamp
> from frame header
> -    if(verbose>1) printf("\nTS: %08X (%04X) %02X
> %02X %02X %02X\n",timestamp,kf,s[0],s[1],s[2],s[3]);
> -    kf|=timestamp&(~0x1fff);	// combine with packet
> timestamp
> -    if(kf<timestamp-4096) kf+=8192; else //
> workaround wrap-around problems
> -    if(kf>timestamp+4096) kf-=8192;
> -    if(!(s[0]&0x8) || !(s[0]&0x10)){ // P || I 
> frame -> swap timestamps
> +  int drop=0;
> +
> +  if((format==0x30335652) || (format==0x30345652)){
> // RV30/RV40 timestamps:
> +    if (format==0x30345652)
> kf=4*(((s[1]&15)<<8)+s[2]); 
> +    else if (format==0x30335652)
> kf=2*(((s[1]&15)<<8)+s[2]); // 12-bit timestamp from
> frame header
> +    mp_msg(MSGT_DEMUX,MSGL_V,"ts in packet: %d 
> \n",kf);
> +    if( ( ( s[0] & (~0xf) ) ==0 ) || ( ( s[0] &
> (~0xf) ) ==0x40 ) ||
> +	( ( s[0] & (~0xf) ) ==0x50 ) || ( ( s[0] & (~0x7)
> ) ==0x10 ) ){
>  	int tmp=kf;
> +	if ((priv->kf_pts==65535) || s[0]==0 || s[0]==1) {
> +	    int tmp=(timestamp&0x1fff)-kf;
> +	    if ((ABS(priv->kf_pts_error-tmp) > 100) ||
> (priv->kf_pts==65535)) drop=1;
> +	    priv->kf_pts_error=tmp;
> +	    mp_msg(MSGT_DEMUX,MSGL_V,"kf_pts vs.
> stream_pts desync: %d\n",priv->kf_pts_error);
> +	}
>  	kf=priv->kf_pts;
>  	priv->kf_pts=tmp;
> -//	if(kf<=tmp) kf=0;
> +	mp_msg(MSGT_DEMUX,MSGL_V,"Using previous KF
> pts\n");
>      }
> +     mp_msg(MSGT_DEMUX,MSGL_V,"kf: %d error:
> %d\n",kf,priv->kf_pts_error);
> +     mp_msg(MSGT_DEMUX,MSGL_V,"\nTS: %08X (%04X)
> %02X %02X %02X
> %02X\n",timestamp,kf,s[0],s[1],s[2],s[3]);
> +     kf=calcts(kf, timestamp,priv->kf_pts_error);
> +     mp_msg(MSGT_DEMUX,MSGL_V," stream-ts: %d 
> calc.ed ts: %d \n",timestamp,kf);
> +    }    
> +    if (priv->v_pts>=kf || drop) {
> +	mp_msg(MSGT_DEMUX,MSGL_V,"Timestamp is erratic,
> ignoring/dropping this timestamp!\n");
> +	v_pts=(priv->v_pts)*0.001f;
>    }
> -    v_pts=kf*0.001f;
> -    if(v_pts<priv->v_pts || !kf)
> v_pts=priv->v_pts+frametime;
> -    priv->v_pts=v_pts;
> -//    printf("\n#T# %5d/%5d (%5.3f) %5.3f 
> \n",kf,timestamp,frametime,v_pts);
> +    else v_pts=kf*0.001f;
> +    if (!drop) priv->v_pts=kf;
>      return v_pts;
>  }
>  
> @@ -363,18 +387,17 @@
>  
>    while(1){
>  
> -#if 0
> -    /* also don't check if no num_of_packets was
> defined in header */
> -    if ((priv->current_packet >
> priv->num_of_packets) &&
> -	(priv->num_of_packets != -10)){
> -	printf("num_of_packets reached!\n");
> -	return 0; /* EOF */
> -    }
> -#endif
> -
>      demuxer->filepos =
> stream_tell(demuxer->stream);
>      version = stream_read_word(demuxer->stream); /*
> version */
>      len = stream_read_word(demuxer->stream);
> +    if ((version==0x4441) && (len==0x5441)) { //
> new data chunk
> +	mp_msg(MSGT_DEMUX,MSGL_V,"New data chunk is
> comming\n");
> +	stream_skip(demuxer->stream,14); 
> +	demuxer->filepos = stream_tell(demuxer->stream);
> +        version =
> stream_read_word(demuxer->stream); /* version */
> +	len = stream_read_word(demuxer->stream);	
> +    }
> +
>      
>      if (len == -256){ /* EOF */
>  //	printf("len==-256!\n");
> @@ -579,7 +602,7 @@
>  			    if(dp_hdr->len!=vpkg_length-vpkg_offset)
>  				mp_msg(MSGT_DEMUX,MSGL_V,"warning!
> assembled.len=%d  frag.len=%d  total.len=%d 
> \n",dp->len,vpkg_offset,vpkg_length-vpkg_offset);
>              		    stream_read(demuxer->stream,
> dp_data+dp_hdr->len, vpkg_offset);
> -			    if(dp_data[dp_hdr->len]&0x20)
> --dp_hdr->chunks; else
> +			    if((dp_data[dp_hdr->len]&0x20) &&
> (sh_video->format!=0x30345652)) --dp_hdr->chunks;
> else
>  			    dp_hdr->len+=vpkg_offset;
>  			    len-=vpkg_offset;
>   			    mp_dbg(MSGT_DEMUX,MSGL_DBG2, "fragment (%d
> bytes) appended, %d bytes left\n",vpkg_offset,len);
> @@ -595,7 +618,7 @@
>  			if(dp_hdr->len!=vpkg_offset)
>  			    mp_msg(MSGT_DEMUX,MSGL_V,"warning!
> assembled.len=%d  offset=%d  frag.len=%d 
> total.len=%d 
> \n",dp->len,vpkg_offset,len,vpkg_length);
>              		stream_read(demuxer->stream,
> dp_data+dp_hdr->len, len);
> -			if(dp_data[dp_hdr->len]&0x20) --dp_hdr->chunks;
> else
> +			if((dp_data[dp_hdr->len]&0x20) &&
> (sh_video->format!=0x30345652)) --dp_hdr->chunks;
> else
>  			dp_hdr->len+=len;
>  			len=0;
>  			break; // no more fragments in this chunk!
> @@ -687,7 +710,7 @@
>  //    stream_skip(demuxer->stream, 4); /* number of
> headers */
>  
>      /* parse chunks */
> -    for (i = 1; i < num_of_headers; i++)
> +    for (;;)
>      {
>  	int chunk_id, chunk_pos, chunk_size;
>  	
> @@ -1011,8 +1034,8 @@
>  		    mp_msg(MSGT_DEMUX,MSGL_V,"video fourcc: %.4s
> (%x)\n", (char *)&sh->format, sh->format);
> 
=== message truncated ===>
_______________________________________________
> RTFM!!!  http://www.MPlayerHQ.hu/DOCS
> Search:  http://www.MPlayerHQ.hu/cgi-bin/htsearch
> http://mplayerhq.hu/mailman/listinfo/mplayer-users
>  

The patch does not apply, says that there are errors
:-(



______________________________________________________________________
Yahoo! Cellulari: loghi, suonerie, picture message per il tuo telefonino
http://it.yahoo.com/mail_it/foot/?http://it.mobile.yahoo.com/index2002.html



More information about the MPlayer-users mailing list