faac: handle trailing encoder output
This commit is contained in:
parent
d7d28ea4db
commit
bc6549a108
@ -700,17 +700,17 @@ gst_faac_push_buffers (GstFaac * faac, gboolean force)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* in case encoder returns more data than is expected (which seems possible)
|
/* deal with encoder lead-out */
|
||||||
* ignore the extra part */
|
|
||||||
if (G_UNLIKELY (av == 0 && faac->offset == 0)) {
|
if (G_UNLIKELY (av == 0 && faac->offset == 0)) {
|
||||||
GST_DEBUG_OBJECT (faac, "encoder returned unexpected data; discarding");
|
GST_DEBUG_OBJECT (faac, "encoder returned additional data");
|
||||||
gst_buffer_unref (outbuf);
|
/* continuous with previous output, ok to have 0 duration */
|
||||||
continue;
|
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)) {
|
if (G_LIKELY ((av = gst_adapter_available (faac->adapter)) >= frame_size)) {
|
||||||
/* must have then come from a complete frame */
|
/* must have then come from a complete frame */
|
||||||
gst_adapter_flush (faac->adapter, frame_size);
|
gst_adapter_flush (faac->adapter, frame_size);
|
||||||
@ -731,6 +731,9 @@ gst_faac_push_buffers (GstFaac * faac, gboolean force)
|
|||||||
GST_BUFFER_DURATION (outbuf) =
|
GST_BUFFER_DURATION (outbuf) =
|
||||||
GST_FRAMES_TO_CLOCK_TIME (size / faac->channels / faac->bps,
|
GST_FRAMES_TO_CLOCK_TIME (size / faac->channels / faac->bps,
|
||||||
faac->samplerate);
|
faac->samplerate);
|
||||||
|
faac->next_ts =
|
||||||
|
GST_BUFFER_TIMESTAMP (outbuf) + GST_BUFFER_DURATION (outbuf);
|
||||||
|
|
||||||
/* perhaps check/set DISCONT based on timestamps ? */
|
/* perhaps check/set DISCONT based on timestamps ? */
|
||||||
|
|
||||||
GST_LOG_OBJECT (faac, "Pushing out buffer time: %" GST_TIME_FORMAT
|
GST_LOG_OBJECT (faac, "Pushing out buffer time: %" GST_TIME_FORMAT
|
||||||
|
@ -68,6 +68,8 @@ struct _GstFaac {
|
|||||||
GstAdapter *adapter;
|
GstAdapter *adapter;
|
||||||
/* offset of data to be encoded next */
|
/* offset of data to be encoded next */
|
||||||
guint offset;
|
guint offset;
|
||||||
|
/* ts for last buffer */
|
||||||
|
GstClockTime next_ts;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstFaacClass {
|
struct _GstFaacClass {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user