From 636d1caf0db5d206ee77fafb8749ea407927ecb5 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 29 Sep 2010 10:08:17 +0200 Subject: [PATCH] faad: tweak output buffer timestamping In particular, avoid packetised input leading to initial to non-0 output ts. --- ext/faad/gstfaad.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/ext/faad/gstfaad.c b/ext/faad/gstfaad.c index 5e4570095b..527503a2b3 100644 --- a/ext/faad/gstfaad.c +++ b/ext/faad/gstfaad.c @@ -263,8 +263,8 @@ gst_faad_reset (GstFaad * faad) faad->packetised = FALSE; g_free (faad->channel_positions); faad->channel_positions = NULL; - faad->next_ts = 0; - faad->prev_ts = GST_CLOCK_TIME_NONE; + faad->next_ts = GST_CLOCK_TIME_NONE; + faad->prev_ts = 0; faad->bytes_in = 0; faad->sum_dur_out = 0; faad->error_count = 0; @@ -698,8 +698,8 @@ gst_faad_sink_event (GstPad * pad, GstEvent * event) " - %" GST_TIME_FORMAT, GST_TIME_ARGS (new_start), GST_TIME_ARGS (new_end)); - faad->next_ts = new_start; - faad->prev_ts = GST_CLOCK_TIME_NONE; + faad->next_ts = GST_CLOCK_TIME_NONE; + faad->prev_ts = new_start; } res = gst_pad_push_event (faad->srcpad, event); @@ -1045,16 +1045,22 @@ gst_faad_chain (GstPad * pad, GstBuffer * buffer) next = FALSE; } - ts = gst_adapter_prev_timestamp (faad->adapter, NULL); - if (GST_CLOCK_TIME_IS_VALID (ts) && (ts != faad->prev_ts)) - faad->prev_ts = faad->next_ts = ts; - available = gst_adapter_available (faad->adapter); input_size = available; - if (G_UNLIKELY (!available)) goto out; + ts = gst_adapter_prev_timestamp (faad->adapter, NULL); + if (GST_CLOCK_TIME_IS_VALID (ts) && (ts != faad->prev_ts)) { + faad->prev_ts = ts; + } else { + /* nothing new */ + ts = GST_CLOCK_TIME_NONE; + } + + if (!GST_CLOCK_TIME_IS_VALID (faad->next_ts)) + faad->next_ts = faad->prev_ts; + input_data = (guchar *) gst_adapter_peek (faad->adapter, available); if (!faad->packetised) { @@ -1211,6 +1217,12 @@ gst_faad_chain (GstPad * pad, GstBuffer * buffer) } } } + + /* adjust to incoming new timestamp, if any, after decoder delay */ + if (GST_CLOCK_TIME_IS_VALID (ts)) { + faad->next_ts = ts; + ts = GST_CLOCK_TIME_NONE; + } } out: -- 2.34.1