[Mplayer-cvslog] CVS: main/libmpdemux stheader.h,1.38,1.39 video.c,1.29,1.30
Arpi of Ize
arpi at mplayerhq.hu
Thu Jan 16 23:34:49 CET 2003
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv27859/libmpdemux
Modified Files:
stheader.h video.c
Log Message:
fixed the well-known DVD/DVB audio delay bug :)
Index: stheader.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/stheader.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- stheader.h 11 Nov 2002 23:46:27 -0000 1.38
+++ stheader.h 16 Jan 2003 22:34:46 -0000 1.39
@@ -91,6 +91,9 @@
// frame counters:
float num_frames; // number of frames played
int num_frames_decoded; // number of frames decoded
+ // timing (mostly for mpeg):
+ float pts; // predicted/interpolated PTS of the current frame
+ float i_pts; // PTS for the _next_ I/P frame
// output format: (set by demuxer)
float fps; // frames per second (set only if constant fps)
float frametime; // 1/fps
Index: video.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/video.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- video.c 1 Nov 2002 17:46:43 -0000 1.29
+++ video.c 16 Jan 2003 22:34:46 -0000 1.30
@@ -214,6 +214,8 @@
demuxer_t *demuxer=d_video->demuxer;
float frame_time=1;
float pts1=d_video->pts;
+ float pts=0;
+ int picture_coding_type=0;
// unsigned char* start=NULL;
int in_size=0;
@@ -246,6 +248,10 @@
break;
}
} else {
+ if(i==0x100){
+ pts=d_video->pts;
+ d_video->pts=0;
+ }
//if(i==0x100) in_frame=1; // picture startcode
if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode
else if(!i) return -1; // EOF
@@ -258,6 +264,7 @@
case 0x1B3: mp_header_process_sequence_header (&picture, &videobuffer[start]);break;
case 0x1B5: mp_header_process_extension (&picture, &videobuffer[start]);break;
case 0x1B2: process_userdata (&videobuffer[start], videobuf_len-start);break;
+ case 0x100: picture_coding_type=(videobuffer[start+1] >> 3) & 7;break;
}
}
@@ -336,7 +343,27 @@
}
if(demuxer->file_format==DEMUXER_TYPE_MPEG_PS ||
- demuxer->file_format==DEMUXER_TYPE_MPEG_ES) d_video->pts+=frame_time;
+ demuxer->file_format==DEMUXER_TYPE_MPEG_ES){
+
+// if(pts>0.0001) printf("\r!!! pts: %5.3f [%d] (%5.3f) \n",pts,picture_coding_type,i_pts);
+
+ sh_video->pts+=frame_time;
+ if(picture_coding_type<=2 && sh_video->i_pts){
+// printf("XXX predict: %5.3f pts: %5.3f error=%5.5f \n",i_pts,d_video->pts2,i_pts-d_video->pts2);
+ sh_video->pts=sh_video->i_pts;
+ sh_video->i_pts=pts;
+ } else {
+ if(pts){
+ if(picture_coding_type<=2) sh_video->i_pts=pts;
+ else {
+// printf("BBB predict: %5.3f pts: %5.3f error=%5.5f \n",pts,d_video->pts2,pts-d_video->pts2);
+ sh_video->pts=pts;
+ }
+ }
+ }
+// printf("\rIII pts: %5.3f [%d] (%5.3f) \n",d_video->pts2,picture_coding_type,i_pts);
+ } else
+ sh_video->pts=d_video->pts;
if(frame_time_ptr) *frame_time_ptr=frame_time;
return in_size;
More information about the MPlayer-cvslog
mailing list