summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-03-09 19:01:20 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-03-09 19:01:20 +0000
commit56d2905fe7769a9e8ae249f9fc1b022d4145f01b (patch)
tree7b676125276617069eaba85765d998c19e7eab58 /libmpdemux
parentadc47d34a7e87ad01271040b539b74ffc4e0e1f4 (diff)
downloadmpv-56d2905fe7769a9e8ae249f9fc1b022d4145f01b.tar.bz2
mpv-56d2905fe7769a9e8ae249f9fc1b022d4145f01b.tar.xz
Hopefully fixed all RV30/RV40 A-V sync issues
based on patch by Balatoni Denes <pnis@coder.hu> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9556 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/demux_real.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/libmpdemux/demux_real.c b/libmpdemux/demux_real.c
index 4e4ecfab46..d3ebd1bff8 100644
--- a/libmpdemux/demux_real.c
+++ b/libmpdemux/demux_real.c
@@ -60,6 +60,7 @@ typedef struct {
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 @@ static float real_fix_timestamp(real_priv_t* priv, unsigned char* s, int timesta
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 @@ static float real_fix_timestamp(real_priv_t* priv, unsigned char* s, int timesta
}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;
}