summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authoruau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-07-06 06:58:17 +0000
committeruau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-07-06 06:58:17 +0000
commite2727ec797e19fb6d4d2d3338ce17dce976e0b28 (patch)
treed66f39217166121fab9751c1b271eb0734f68999 /libmpdemux
parent11ade8f86d0d358e90737451983ed37075832e5e (diff)
downloadmpv-e2727ec797e19fb6d4d2d3338ce17dce976e0b28.tar.bz2
mpv-e2727ec797e19fb6d4d2d3338ce17dce976e0b28.tar.xz
Add a new video pts tracking mode, enabled by option -correct-pts.
This mode has the following differences: - Video timing is correct for streams with B frames, at least with some demuxers. - Video filters can modify frame timestamps and insert new frames, and removing frames is handled better than before. - Some things are known to break, it's not usable as the default yet. Things should work as before when the -correct-pts option is not used. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18922 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/demux_mkv.c6
-rw-r--r--libmpdemux/demuxer.c11
-rw-r--r--libmpdemux/demuxer.h6
-rw-r--r--libmpdemux/stheader.h2
4 files changed, 17 insertions, 8 deletions
diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c
index de75f00748..14fbf2efeb 100644
--- a/libmpdemux/demux_mkv.c
+++ b/libmpdemux/demux_mkv.c
@@ -1690,12 +1690,12 @@ demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track)
else if (!strcmp(track->codec_id, MKV_V_MPEG1))
{
bih->biCompression = mmioFOURCC('m', 'p', 'g', '1');
- track->reorder_timecodes = 1;
+ track->reorder_timecodes = !correct_pts;
}
else if (!strcmp(track->codec_id, MKV_V_MPEG2))
{
bih->biCompression = mmioFOURCC('m', 'p', 'g', '2');
- track->reorder_timecodes = 1;
+ track->reorder_timecodes = !correct_pts;
}
else if (!strcmp(track->codec_id, MKV_V_MPEG4_AVC))
{
@@ -1706,7 +1706,7 @@ demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track)
bih = (BITMAPINFOHEADER *) realloc (bih, bih->biSize);
memcpy (bih + 1, track->private_data, track->private_size);
}
- track->reorder_timecodes = 1;
+ track->reorder_timecodes = !correct_pts;
}
else
{
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index cf474a789c..d648ac7363 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -355,7 +355,7 @@ int ds_fill_buffer(demux_stream_t *ds){
ds->pos=p->pos;
ds->dpos+=p->len; // !!!
++ds->pack_no;
- if(p->pts){
+ if (p->pts != (correct_pts ? MP_NOPTS_VALUE : 0)) {
ds->pts=p->pts;
ds->pts_bytes=0;
}
@@ -511,10 +511,11 @@ int ds_get_packet_pts(demux_stream_t *ds,unsigned char **start, double *pts)
*start = NULL;
return -1;
}
- // Should use MP_NOPTS_VALUE for "unknown pts" in the packets too
- if (ds->current->pts)
- *pts = ds->current->pts;
}
+ // Should use MP_NOPTS_VALUE for "unknown pts" in the packets too
+ // Return pts unless this read starts from the middle of a packet
+ if (!ds->buffer_pos && (correct_pts || ds->current->pts))
+ *pts = ds->current->pts;
len=ds->buffer_size-ds->buffer_pos;
*start = &ds->buffer[ds->buffer_pos];
ds->buffer_pos+=len;
@@ -624,6 +625,8 @@ int get_demuxer_type_from_name(char *demuxer_name, int *force)
int extension_parsing=1; // 0=off 1=mixed (used only for unstable formats)
+int correct_pts=0;
+
/*
NOTE : Several demuxers may be opened at the same time so
demuxers should NEVER rely on an external var to enable them
diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h
index 00093d288e..93b43721c4 100644
--- a/libmpdemux/demuxer.h
+++ b/libmpdemux/demuxer.h
@@ -126,6 +126,8 @@ typedef struct demuxer_info_st {
struct demuxer_st;
+extern int correct_pts;
+
/**
* Demuxer description structure
*/
@@ -182,7 +184,9 @@ inline static demux_packet_t* new_demux_packet(int len){
demux_packet_t* dp=(demux_packet_t*)malloc(sizeof(demux_packet_t));
dp->len=len;
dp->next=NULL;
- dp->pts=0;
+ // still using 0 by default in case there is some code that uses 0 for both
+ // unknown and a valid pts value
+ dp->pts=correct_pts ? MP_NOPTS_VALUE : 0;
dp->pos=0;
dp->flags=0;
dp->refcount=1;
diff --git a/libmpdemux/stheader.h b/libmpdemux/stheader.h
index 74a43f9262..bdb36d4002 100644
--- a/libmpdemux/stheader.h
+++ b/libmpdemux/stheader.h
@@ -64,6 +64,8 @@ typedef struct {
// timing (mostly for mpeg):
double pts; // predicted/interpolated PTS of the current frame
double i_pts; // PTS for the _next_ I/P frame
+ double buffered_pts[20];
+ int num_buffered_pts;
// output format: (set by demuxer)
float fps; // frames per second (set only if constant fps)
float frametime; // 1/fps