mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
audiorate: fix support for non-interleaved buffers
https://bugzilla.gnome.org/show_bug.cgi?id=796741
This commit is contained in:
parent
b33d70e97f
commit
09171b11ac
1 changed files with 12 additions and 14 deletions
|
@ -439,6 +439,7 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
GstClockTimeDiff diff;
|
GstClockTimeDiff diff;
|
||||||
gint rate, bpf;
|
gint rate, bpf;
|
||||||
|
GstAudioMeta *meta;
|
||||||
|
|
||||||
audiorate = GST_AUDIO_RATE (parent);
|
audiorate = GST_AUDIO_RATE (parent);
|
||||||
|
|
||||||
|
@ -492,8 +493,9 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
in_time = audiorate->next_ts;
|
in_time = audiorate->next_ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
meta = gst_buffer_get_audio_meta (buf);
|
||||||
in_size = gst_buffer_get_size (buf);
|
in_size = gst_buffer_get_size (buf);
|
||||||
in_samples = in_size / bpf;
|
in_samples = meta ? meta->samples : in_size / bpf;
|
||||||
audiorate->in += in_samples;
|
audiorate->in += in_samples;
|
||||||
|
|
||||||
/* calculate the buffer offset */
|
/* calculate the buffer offset */
|
||||||
|
@ -549,6 +551,10 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
fillmap.size);
|
fillmap.size);
|
||||||
gst_buffer_unmap (fill, &fillmap);
|
gst_buffer_unmap (fill, &fillmap);
|
||||||
|
|
||||||
|
if (audiorate->info.layout == GST_AUDIO_LAYOUT_NON_INTERLEAVED) {
|
||||||
|
gst_buffer_add_audio_meta (fill, &audiorate->info, cursamples, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (audiorate, "inserting %" G_GUINT64_FORMAT " samples",
|
GST_DEBUG_OBJECT (audiorate, "inserting %" G_GUINT64_FORMAT " samples",
|
||||||
cursamples);
|
cursamples);
|
||||||
|
|
||||||
|
@ -591,7 +597,7 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
} else if (in_offset < audiorate->next_offset) {
|
} else if (in_offset < audiorate->next_offset) {
|
||||||
/* need to remove samples */
|
/* need to remove samples */
|
||||||
if (in_offset_end <= audiorate->next_offset) {
|
if (in_offset_end <= audiorate->next_offset) {
|
||||||
guint64 drop = in_size / bpf;
|
guint64 drop = in_samples;
|
||||||
|
|
||||||
audiorate->drop += drop;
|
audiorate->drop += drop;
|
||||||
|
|
||||||
|
@ -607,24 +613,16 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
|
|
||||||
goto beach;
|
goto beach;
|
||||||
} else {
|
} else {
|
||||||
guint64 truncsamples;
|
guint64 truncsamples, leftsamples;
|
||||||
guint truncsize, leftsize;
|
|
||||||
GstBuffer *trunc;
|
|
||||||
|
|
||||||
/* truncate buffer */
|
/* truncate buffer */
|
||||||
truncsamples = audiorate->next_offset - in_offset;
|
truncsamples = audiorate->next_offset - in_offset;
|
||||||
truncsize = truncsamples * bpf;
|
leftsamples = in_samples - truncsamples;
|
||||||
leftsize = in_size - truncsize;
|
|
||||||
|
|
||||||
trunc =
|
buf = gst_audio_buffer_truncate (buf, bpf, truncsamples, leftsamples);
|
||||||
gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, truncsize,
|
|
||||||
leftsize);
|
|
||||||
|
|
||||||
gst_buffer_unref (buf);
|
|
||||||
buf = trunc;
|
|
||||||
|
|
||||||
audiorate->drop += truncsamples;
|
audiorate->drop += truncsamples;
|
||||||
audiorate->out += (leftsize / bpf);
|
audiorate->out += leftsamples;
|
||||||
GST_DEBUG_OBJECT (audiorate, "truncating %" G_GUINT64_FORMAT " samples",
|
GST_DEBUG_OBJECT (audiorate, "truncating %" G_GUINT64_FORMAT " samples",
|
||||||
truncsamples);
|
truncsamples);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue