summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: aebf3e1)
raw | patch | inline | side by side (parent: aebf3e1)
author | Rob Clark <rob@ti.com> | |
Tue, 27 Dec 2011 22:03:50 +0000 (16:03 -0600) | ||
committer | Alessandro Decina <alessandro.decina@collabora.co.uk> | |
Thu, 5 Jan 2012 16:49:34 +0000 (17:49 +0100) |
When input timestamps are in ascending order, and output timestamps
are not, that must mean the parser/demuxser is giving us the timestamps
in presentation order (PTS), not decode order (DTS).
are not, that must mean the parser/demuxser is giving us the timestamps
in presentation order (PTS), not decode order (DTS).
src/gstducatividdec.c | patch | blob | history | |
src/gstducatividdec.h | patch | blob | history |
diff --git a/src/gstducatividdec.c b/src/gstducatividdec.c
index ce59d57d06689781857b35493d23e50fcdf90551..5a95c84beb2e841759fb40181815623ea7bd0da3 100644 (file)
--- a/src/gstducatividdec.c
+++ b/src/gstducatividdec.c
outbuf = codec_get_outbuf (self, self->outArgs->outputID[i]);
if (send) {
+ GstClockTime ts;
+
if (GST_IS_DUCATIBUFFER (outbuf)) {
outbuf = gst_ducati_buffer_get (GST_DUCATIBUFFER (outbuf));
}
+
+ ts = GST_BUFFER_TIMESTAMP (outbuf);
+
GST_DEBUG_OBJECT (self, "got buffer: %d %p (%" GST_TIME_FORMAT ")",
- i, outbuf, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
+ i, outbuf, GST_TIME_ARGS (ts));
+
+ if (self->ts_may_be_pts) {
+ if ((self->last_pts != GST_CLOCK_TIME_NONE) &&
+ (self->last_pts > ts)) {
+ GST_DEBUG_OBJECT (self, "detected PTS going backwards, "
+ "enabling ts_is_pts");
+ self->ts_is_pts = TRUE;
+ }
+ }
+
+ self->last_pts = ts;
+
+ if (self->dts_ridx != self->dts_widx) {
+ ts = self->dts_queue[self->dts_ridx++ % NDTS];
+ }
if (self->ts_is_pts) {
/* if we have a queued DTS from demuxer, use that instead: */
- if (self->dts_ridx != self->dts_widx) {
- GST_BUFFER_TIMESTAMP (outbuf) =
- self->dts_queue[self->dts_ridx++ % NDTS];
- GST_DEBUG_OBJECT (self, "fixed ts: %d %p (%" GST_TIME_FORMAT ")",
- i, outbuf, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
- }
+ GST_BUFFER_TIMESTAMP (outbuf) = ts;
+ GST_DEBUG_OBJECT (self, "fixed ts: %d %p (%" GST_TIME_FORMAT ")",
+ i, outbuf, GST_TIME_ARGS (ts));
}
gst_pad_push (self->srcpad, outbuf);
GST_PAD_STREAM_LOCK (self->sinkpad);
self->dts_ridx = self->dts_widx = 0;
+ self->last_dts = self->last_pts = GST_CLOCK_TIME_NONE;
+ self->ts_may_be_pts = TRUE;
if (G_UNLIKELY (self->first_in_buffer)) {
return TRUE;
self->in_size = 0;
buf = GST_DUCATIVIDDEC_GET_CLASS (self)->push_input (self, buf);
- if (self->ts_is_pts && (ts != GST_CLOCK_TIME_NONE)) {
+ if (ts != GST_CLOCK_TIME_NONE) {
self->duration = GST_BUFFER_DURATION (outbuf);
self->dts_queue[self->dts_widx++ % NDTS] = ts;
+ /* if next buffer has earlier ts than previous, then the ts
+ * we are getting are definitely decode order (DTS):
+ */
+ if ((self->last_dts != GST_CLOCK_TIME_NONE) &&
+ (self->last_dts > ts)) {
+ GST_DEBUG_OBJECT (self, "input timestamp definitely DTS");
+ self->ts_may_be_pts = FALSE;
+ }
+ self->last_dts = ts;
}
if (self->in_size == 0) {
@@ -1096,6 +1124,11 @@ gst_ducati_viddec_init (GstDucatiVidDec * self, GstDucatiVidDecClass * klass)
self->first_in_buffer = TRUE;
self->first_out_buffer = TRUE;
+ self->dts_ridx = self->dts_widx = 0;
+ self->last_dts = self->last_pts = GST_CLOCK_TIME_NONE;
+ self->ts_may_be_pts = TRUE;
+ self->ts_is_pts = FALSE;
+
self->pageMemType = XDM_MEMTYPE_TILEDPAGE;
gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED);
diff --git a/src/gstducatividdec.h b/src/gstducatividdec.h
index f783d0e2a662f70263582fb7b7287d9e2d8243a7..d3d35c4af4c12ba65055c165aabc74254a14c3e8 100644 (file)
--- a/src/gstducatividdec.h
+++ b/src/gstducatividdec.h
*/
gboolean ts_is_pts;
+ /* auto-detection for ts_is_pts workaround.. if we detect out of order
+ * timestamps from demuxer/parser, then the ts is definitely DTS,
+ * otherwise it may be PTS and out of order timestamps out of decoder
+ * will trigger the ts_is_pts workaround.
+ */
+ gboolean ts_may_be_pts;
+
GstClockTime duration;
#define NDTS 32
GstClockTime dts_queue[NDTS];
gint dts_ridx, dts_widx;
+ GstClockTime last_dts, last_pts;
Engine_Handle engine;
VIDDEC3_Handle codec;