[MPlayer-cvslog] CVS: main/libmpdemux demux_mpg.c,1.52,1.53
Nico Sabbi CVS
syncmail at mplayerhq.hu
Sat Jan 8 11:05:47 CET 2005
CVS change done by Nico Sabbi CVS
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv25682
Modified Files:
demux_mpg.c
Log Message:
fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
Index: demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- demux_mpg.c 23 Oct 2004 00:05:37 -0000 1.52
+++ demux_mpg.c 8 Jan 2005 10:05:44 -0000 1.53
@@ -410,15 +410,18 @@
sh_video_t *sh_video=d_video->sh;
mpg_demuxer_t *mpg_d=(mpg_demuxer_t*)demuxer->priv;
int precision = 1;
- float oldpts = mpg_d->last_pts;
+ float oldpts = 0;
off_t oldpos = demuxer->filepos;
- float newpts = (flags & 1) ? 0.0 : oldpts;
+ float newpts = 0;
off_t newpos = (flags & 1) ? demuxer->movi_start : oldpos;
+ if(mpg_d)
+ oldpts = mpg_d->last_pts;
+ newpts = (flags & 1) ? 0.0 : oldpts;
//================= seek in MPEG ==========================
//calculate the pts to seek to
if(flags & 2) {
- if (mpg_d->final_pts > 0.0)
+ if (mpg_d && mpg_d->final_pts > 0.0)
newpts += mpg_d->final_pts * rel_seek_secs;
else
newpts += rel_seek_secs * (demuxer->movi_end - demuxer->movi_start) * oldpts / oldpos;
@@ -475,9 +478,17 @@
}
}
i=sync_video_packet(d_video);
- if(i==0x1B3 || i==0x1B8) break; // found it!
+ if(sh_video->format == 0x10000004) { //mpeg4
+ if(i==0x1B6) break; //vop (frame) startcode
+ } else if(sh_video->format == 0x10000005){ //h264
+ if((i & ~0x60) == 0x101 || (i & ~0x60) == 0x102 || (i & ~0x60) == 0x105) break;
+ } else { //default mpeg1/2
+ if(i==0x1B3 || i==0x1B8) break; // found it!
+ }
if(!i || !skip_video_packet(d_video)) break; // EOF?
}
+ if(!mpg_d)
+ break;
if (!precision || abs(newpts - mpg_d->last_pts) < 0.5 || (mpg_d->last_pts == oldpts)) break;
if ((newpos - oldpos) * (mpg_d->last_pts - oldpts) < 0) { // invalid timestamps
mpg_d->has_valid_timestamps = 0;
@@ -485,12 +496,14 @@
}
precision--;
//prepare another seek because we are off by more than 0.5s
+ if(mpg_d) {
newpos += (newpts - mpg_d->last_pts) * (newpos - oldpos) / (mpg_d->last_pts - oldpts);
ds_free_packs(d_audio);
ds_free_packs(d_video);
demuxer->stream->eof=0; // clear eof flag
d_video->eof=0;
d_audio->eof=0;
+ }
}
}
More information about the MPlayer-cvslog
mailing list