diff options
author | Jan Schmidt <thaytan@mad.scientist.com> | 2006-09-28 21:44:49 +0000 |
---|---|---|
committer | Jan Schmidt <thaytan@mad.scientist.com> | 2006-09-28 21:44:49 +0000 |
commit | 65d7dd9c60ae69f94f111397b7caa1b7f816da30 (patch) | |
tree | 44df4ba0524f101ab54cc93870567fb714a09475 /gst/dvdlpcmdec | |
parent | 53ce6d70d65191bd2e0725699fcfe522c04e1741 (diff) |
gst/dvdlpcmdec/gstdvdlpcmdec.c: If an incoming timestamp is within one sample of our current timestamp, then keep it....
Original commit message from CVS:
* gst/dvdlpcmdec/gstdvdlpcmdec.c: (update_timestamps):
If an incoming timestamp is within one sample of our current
timestamp, then keep it. This prevents imprecision in the
PTS (which only has 90khz granularity) from affecting our stream.
Diffstat (limited to 'gst/dvdlpcmdec')
-rw-r--r-- | gst/dvdlpcmdec/gstdvdlpcmdec.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/gst/dvdlpcmdec/gstdvdlpcmdec.c b/gst/dvdlpcmdec/gstdvdlpcmdec.c index 15a05965..2c5831b9 100644 --- a/gst/dvdlpcmdec/gstdvdlpcmdec.c +++ b/gst/dvdlpcmdec/gstdvdlpcmdec.c @@ -259,16 +259,30 @@ caps_parse_error: static void update_timestamps (GstDvdLpcmDec * dvdlpcmdec, GstBuffer * buf, int samples) { + gboolean take_buf_ts = FALSE; + GST_BUFFER_DURATION (buf) = gst_util_uint64_scale (samples, GST_SECOND, dvdlpcmdec->rate); if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { - /* Then leave it as-is, and save this timestamp */ + if (GST_CLOCK_TIME_IS_VALID (dvdlpcmdec->timestamp)) { + GstClockTimeDiff one_sample = GST_SECOND / dvdlpcmdec->rate; + GstClockTimeDiff diff = GST_CLOCK_DIFF (GST_BUFFER_TIMESTAMP (buf), + dvdlpcmdec->timestamp); + + if (diff > one_sample || diff < -one_sample) + take_buf_ts = TRUE; + } else { + take_buf_ts = TRUE; + } + } else if (!GST_CLOCK_TIME_IS_VALID (dvdlpcmdec->timestamp)) { + dvdlpcmdec->timestamp = dvdlpcmdec->segment_start; + } + + if (take_buf_ts) { + /* Take buffer timestamp */ dvdlpcmdec->timestamp = GST_BUFFER_TIMESTAMP (buf); } else { - if (!GST_CLOCK_TIME_IS_VALID (dvdlpcmdec->timestamp)) - dvdlpcmdec->timestamp = dvdlpcmdec->segment_start; - GST_BUFFER_TIMESTAMP (buf) = dvdlpcmdec->timestamp; } |