mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
audioencoder: also adjust sample count upon discont to avoid ts overflow
Only adjusting the base_ts might lead to a negative ts and as such integer overflow into a huge timestamp which then propagates into the granulepos and so on. Instead, resync to incoming buffer timestamp using both base_ts and sample count rather than only base_ts. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=785948
This commit is contained in:
parent
2d632ff367
commit
00fa39befa
1 changed files with 20 additions and 1 deletions
|
@ -1325,7 +1325,18 @@ gst_audio_encoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
}
|
||||
if (discont) {
|
||||
/* now re-sync ts */
|
||||
priv->base_ts += diff;
|
||||
GstClockTime shift =
|
||||
gst_util_uint64_scale (gst_adapter_available (priv->adapter),
|
||||
GST_SECOND, ctx->info.rate * ctx->info.bpf);
|
||||
|
||||
if (G_UNLIKELY (shift > GST_BUFFER_TIMESTAMP (buffer))) {
|
||||
/* ERROR */
|
||||
goto wrong_time;
|
||||
}
|
||||
/* arrange for newly added samples to come out with the ts
|
||||
* of the incoming buffer that adds these */
|
||||
priv->base_ts = GST_BUFFER_TIMESTAMP (buffer) - shift;
|
||||
priv->samples = 0;
|
||||
gst_audio_encoder_set_base_gp (enc);
|
||||
priv->discont |= discont;
|
||||
}
|
||||
|
@ -1362,6 +1373,14 @@ wrong_buffer:
|
|||
ret = GST_FLOW_ERROR;
|
||||
goto done;
|
||||
}
|
||||
wrong_time:
|
||||
{
|
||||
GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL),
|
||||
("buffer going too far back in time"));
|
||||
gst_buffer_unref (buffer);
|
||||
ret = GST_FLOW_ERROR;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
Loading…
Reference in a new issue