mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
mp3parse: Fix glitches in the output when playing (for e.g.) AVI
Don't introduce glitches in the output by a) relaxing the threshold for taking upstream timestamps in preference to our calculated timestamps and b) only set the discont flag on outgoing buffers in response to an incoming discont buffer. Fixes: #575046
This commit is contained in:
parent
abf7f47769
commit
d2c6f0b2b6
2 changed files with 15 additions and 9 deletions
|
@ -623,24 +623,20 @@ gst_mp3parse_emit_frame (GstMPEGAudioParse * mp3parse, guint size,
|
|||
* here */
|
||||
if (GST_CLOCK_TIME_IS_VALID (mp3parse->pending_ts)) {
|
||||
if (mp3parse->tracked_offset >= mp3parse->pending_offset) {
|
||||
/* If the incoming timestamp differs from our expected by more than 2
|
||||
* 90khz MPEG ticks, then take it and, if needed, set the discont flag.
|
||||
/* If the incoming timestamp differs from our expected by more than
|
||||
* half a frame, then take it instead of our calculated timestamp.
|
||||
* This avoids creating imperfect streams just because of
|
||||
* quantization in the MPEG clock sampling */
|
||||
* quantization in the container timestamping */
|
||||
GstClockTimeDiff diff = mp3parse->next_ts - mp3parse->pending_ts;
|
||||
GstClockTimeDiff thresh = GST_BUFFER_DURATION (outbuf) / 2;
|
||||
|
||||
if (diff < -2 * (GST_SECOND / 90000) || diff > 2 * (GST_SECOND / 90000)) {
|
||||
if (diff < -thresh || diff > thresh) {
|
||||
GST_DEBUG_OBJECT (mp3parse, "Updating next_ts from %" GST_TIME_FORMAT
|
||||
" to pending ts %" GST_TIME_FORMAT
|
||||
" at offset %lld (pending offset was %lld)",
|
||||
GST_TIME_ARGS (mp3parse->next_ts),
|
||||
GST_TIME_ARGS (mp3parse->pending_ts), mp3parse->tracked_offset,
|
||||
mp3parse->pending_offset);
|
||||
|
||||
/* Only set discont if we sent out some timestamps already and we're
|
||||
* adjusting */
|
||||
if (GST_CLOCK_TIME_IS_VALID (mp3parse->next_ts))
|
||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
|
||||
mp3parse->next_ts = mp3parse->pending_ts;
|
||||
}
|
||||
mp3parse->pending_ts = GST_CLOCK_TIME_NONE;
|
||||
|
@ -829,6 +825,13 @@ gst_mp3parse_emit_frame (GstMPEGAudioParse * mp3parse, guint size,
|
|||
g_list_free (mp3parse->pending_events);
|
||||
mp3parse->pending_events = NULL;
|
||||
}
|
||||
|
||||
/* set discont if needed */
|
||||
if (mp3parse->discont) {
|
||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
|
||||
mp3parse->discont = FALSE;
|
||||
}
|
||||
|
||||
ret = gst_pad_push (mp3parse->srcpad, outbuf);
|
||||
}
|
||||
|
||||
|
@ -1174,6 +1177,8 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
|
|||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
|
||||
mp3parse->discont |= GST_BUFFER_IS_DISCONT (buf);
|
||||
|
||||
/* If we don't yet have a next timestamp, save it and the incoming offset
|
||||
* so we can apply it to the right outgoing buffer */
|
||||
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
|
||||
|
|
|
@ -62,6 +62,7 @@ struct _GstMPEGAudioParse {
|
|||
|
||||
GstSegment segment;
|
||||
GstClockTime next_ts;
|
||||
gboolean discont;
|
||||
|
||||
/* Offset as supplied by incoming buffers */
|
||||
gint64 cur_offset;
|
||||
|
|
Loading…
Reference in a new issue