mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
baseaudioencoder: use buffer running time for granule calculation
This commit is contained in:
parent
6c04035eec
commit
d1f5c34fe7
1 changed files with 30 additions and 9 deletions
|
@ -715,6 +715,34 @@ gst_base_audio_encoder_drain (GstBaseAudioEncoder * enc)
|
||||||
return gst_base_audio_encoder_push_buffers (enc, TRUE);
|
return gst_base_audio_encoder_push_buffers (enc, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_base_audio_encoder_set_base_gp (GstBaseAudioEncoder * enc)
|
||||||
|
{
|
||||||
|
GstClockTime ts;
|
||||||
|
|
||||||
|
if (!enc->granule)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* use running time for granule */
|
||||||
|
/* incoming data is clipped, so a valid input should yield a valid output */
|
||||||
|
ts = gst_segment_to_running_time (&enc->segment, GST_FORMAT_TIME,
|
||||||
|
enc->priv->base_ts);
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (ts)) {
|
||||||
|
enc->priv->base_gp =
|
||||||
|
GST_CLOCK_TIME_TO_FRAMES (enc->priv->base_ts, enc->ctx->state.rate);
|
||||||
|
GST_DEBUG_OBJECT (enc, "new base gp %" G_GINT64_FORMAT,
|
||||||
|
GST_TIME_ARGS (enc->priv->base_gp));
|
||||||
|
} else {
|
||||||
|
/* should reasonably have a valid base,
|
||||||
|
* otherwise start at 0 if we did not already start there earlier */
|
||||||
|
if (enc->priv->base_gp < 0) {
|
||||||
|
enc->priv->base_gp = 0;
|
||||||
|
GST_DEBUG_OBJECT (enc, "new base gp %" G_GINT64_FORMAT,
|
||||||
|
GST_TIME_ARGS (enc->priv->base_gp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_base_audio_encoder_chain (GstPad * pad, GstBuffer * buffer)
|
gst_base_audio_encoder_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
|
@ -790,12 +818,7 @@ gst_base_audio_encoder_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
priv->base_ts = GST_BUFFER_TIMESTAMP (buffer);
|
priv->base_ts = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
GST_DEBUG_OBJECT (enc, "new base ts %" GST_TIME_FORMAT,
|
GST_DEBUG_OBJECT (enc, "new base ts %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (priv->base_ts));
|
GST_TIME_ARGS (priv->base_ts));
|
||||||
if (enc->granule) {
|
gst_base_audio_encoder_set_base_gp (enc);
|
||||||
priv->base_gp =
|
|
||||||
GST_CLOCK_TIME_TO_FRAMES (priv->base_ts, enc->ctx->state.rate);
|
|
||||||
GST_DEBUG_OBJECT (enc, "new base gp %" G_GINT64_FORMAT,
|
|
||||||
GST_TIME_ARGS (priv->base_gp));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for continuity;
|
/* check for continuity;
|
||||||
|
@ -854,9 +877,7 @@ gst_base_audio_encoder_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
/* now re-sync ts */
|
/* now re-sync ts */
|
||||||
priv->base_ts += diff;
|
priv->base_ts += diff;
|
||||||
if (priv->base_gp >= 0)
|
gst_base_audio_encoder_set_base_gp (enc);
|
||||||
priv->base_gp =
|
|
||||||
GST_CLOCK_TIME_TO_FRAMES (priv->base_ts, enc->ctx->state.rate);
|
|
||||||
priv->discont |= discont;
|
priv->discont |= discont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue