summaryrefslogtreecommitdiff
path: root/ext/faac
diff options
context:
space:
mode:
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2010-10-11 17:05:28 +0200
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2010-10-11 17:13:10 +0200
commitbc6549a108d7b18f0b1b79caba754a1654536731 (patch)
tree50514d10e7435ee3a8adee3878bfc0451d2f75cd /ext/faac
parentd7d28ea4db284b309564cdba49e48e90912f754d (diff)
downloadgstreamer-plugins-bad-bc6549a108d7b18f0b1b79caba754a1654536731.tar.gz
faac: handle trailing encoder output
Diffstat (limited to 'ext/faac')
-rw-r--r--ext/faac/gstfaac.c19
-rw-r--r--ext/faac/gstfaac.h2
2 files changed, 13 insertions, 8 deletions
diff --git a/ext/faac/gstfaac.c b/ext/faac/gstfaac.c
index 85716db64..5c1666819 100644
--- a/ext/faac/gstfaac.c
+++ b/ext/faac/gstfaac.c
@@ -700,17 +700,17 @@ gst_faac_push_buffers (GstFaac * faac, gboolean force)
break;
}
- /* in case encoder returns more data than is expected (which seems possible)
- * ignore the extra part */
+ /* deal with encoder lead-out */
if (G_UNLIKELY (av == 0 && faac->offset == 0)) {
- GST_DEBUG_OBJECT (faac, "encoder returned unexpected data; discarding");
- gst_buffer_unref (outbuf);
- continue;
+ GST_DEBUG_OBJECT (faac, "encoder returned additional data");
+ /* continuous with previous output, ok to have 0 duration */
+ timestamp = faac->next_ts;
+ } else {
+ /* after some caching, finally some data */
+ /* adapter gives time */
+ timestamp = gst_adapter_prev_timestamp (faac->adapter, &distance);
}
- /* after some caching, finally some data */
- /* adapter gives time */
- timestamp = gst_adapter_prev_timestamp (faac->adapter, &distance);
if (G_LIKELY ((av = gst_adapter_available (faac->adapter)) >= frame_size)) {
/* must have then come from a complete frame */
gst_adapter_flush (faac->adapter, frame_size);
@@ -731,6 +731,9 @@ gst_faac_push_buffers (GstFaac * faac, gboolean force)
GST_BUFFER_DURATION (outbuf) =
GST_FRAMES_TO_CLOCK_TIME (size / faac->channels / faac->bps,
faac->samplerate);
+ faac->next_ts =
+ GST_BUFFER_TIMESTAMP (outbuf) + GST_BUFFER_DURATION (outbuf);
+
/* perhaps check/set DISCONT based on timestamps ? */
GST_LOG_OBJECT (faac, "Pushing out buffer time: %" GST_TIME_FORMAT
diff --git a/ext/faac/gstfaac.h b/ext/faac/gstfaac.h
index 781e24041..7a282ec50 100644
--- a/ext/faac/gstfaac.h
+++ b/ext/faac/gstfaac.h
@@ -68,6 +68,8 @@ struct _GstFaac {
GstAdapter *adapter;
/* offset of data to be encoded next */
guint offset;
+ /* ts for last buffer */
+ GstClockTime next_ts;
};
struct _GstFaacClass {