[Mplayer-cvslog] CVS: main/libmpdemux demux_real.c,1.40,1.41
Arpi of Ize
arpi at mplayerhq.hu
Sun Mar 9 20:01:37 CET 2003
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv10079
Modified Files:
demux_real.c
Log Message:
Hopefully fixed all RV30/RV40 A-V sync issues
based on patch by Balatoni Denes <pnis at coder.hu>
Index: demux_real.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_real.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- demux_real.c 9 Mar 2003 17:21:30 -0000 1.40
+++ demux_real.c 9 Mar 2003 19:01:20 -0000 1.41
@@ -60,6 +60,7 @@
int current_vpacket;
// timestamp correction:
+ int kf_base;// timestamp of the prev. video keyframe
int kf_pts; // timestamp of next video keyframe
int a_pts; // previous audio timestamp
float v_pts; // previous video timestamp
@@ -321,7 +322,9 @@
uint32_t buffer= (s[0]<<24) + (s[1]<<16) + (s[2]<<8) + s[3];
int kf=timestamp;
int pict_type;
-
+ int orig_kf;
+
+#if 1
if(format==mmioFOURCC('R','V','3','0') || format==mmioFOURCC('R','V','4','0')){
if(format==mmioFOURCC('R','V','3','0')){
SKIP_BITS(3);
@@ -330,24 +333,36 @@
}else{
SKIP_BITS(1);
pict_type= SHOW_BITS(2);
- SKIP_BITS(2 + 7 + 1);
+ SKIP_BITS(2 + 7 + 3);
+ }
+ orig_kf=
+ kf= SHOW_BITS(13); // kf= 2*SHOW_BITS(12);
+// if(pict_type==0)
+ if(pict_type<=1){
+ // I frame, sync timestamps:
+ priv->kf_base=timestamp-kf;
+ if(verbose>1) printf("\nTS: base=%08X\n",priv->kf_base);
+ kf=timestamp;
+ } else {
+ // P/B frame, merge timestamps:
+ int tmp=timestamp-priv->kf_base;
+ kf|=tmp&(~0x1fff); // combine with packet timestamp
+ if(kf<tmp-4096) kf+=8192; else // workaround wrap-around problems
+ if(kf>tmp+4096) kf-=8192;
+ kf+=priv->kf_base;
}
- kf= 2*SHOW_BITS(12);
- if(verbose>1) printf("\nTS: %08X (%04X) %d %02X %02X %02X %02X\n",timestamp,kf,pict_type,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(pict_type != 3){ // P || I frame -> swap timestamps
int tmp=kf;
kf=priv->kf_pts;
priv->kf_pts=tmp;
// if(kf<=tmp) kf=0;
}
+ if(verbose>1) printf("\nTS: %08X -> %08X (%04X) %d %02X %02X %02X %02X %5d\n",timestamp,kf,orig_kf,pict_type,s[0],s[1],s[2],s[3],kf-(int)(1000.0*priv->v_pts));
}
+#endif
v_pts=kf*0.001f;
- if(v_pts<priv->v_pts || !kf) v_pts=priv->v_pts+frametime;
+// 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);
return v_pts;
}
More information about the MPlayer-cvslog
mailing list