mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
ac3parse: correctly handle timestamps when parsing x-private1-ac3
... the way it has always worked fine in a52dec.
This commit is contained in:
parent
b81b2efa3e
commit
49d52a64d6
1 changed files with 68 additions and 9 deletions
|
@ -690,24 +690,83 @@ cleanup:
|
||||||
* */
|
* */
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_ac3_parse_chain_priv (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
gst_ac3_parse_chain_priv (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstAc3Parse *ac3parse = GST_AC3_PARSE (parent);
|
GstAc3Parse *ac3parse = GST_AC3_PARSE (parent);
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstBuffer *newbuf;
|
|
||||||
gsize size;
|
gsize size;
|
||||||
|
guint8 data[2];
|
||||||
|
gint offset;
|
||||||
|
gint len;
|
||||||
|
GstBuffer *subbuf;
|
||||||
|
gint first_access;
|
||||||
|
|
||||||
size = gst_buffer_get_size (buffer);
|
size = gst_buffer_get_size (buf);
|
||||||
if (size >= 2) {
|
if (size < 2)
|
||||||
newbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 2, size - 2);
|
goto not_enough_data;
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
ret = ac3parse->baseparse_chainfunc (pad, parent, newbuf);
|
gst_buffer_extract (buf, 0, data, 2);
|
||||||
} else {
|
first_access = (data[0] << 8) | data[1];
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
ret = GST_FLOW_OK;
|
/* Skip the first_access header */
|
||||||
|
offset = 2;
|
||||||
|
|
||||||
|
if (first_access > 1) {
|
||||||
|
/* Length of data before first_access */
|
||||||
|
len = first_access - 1;
|
||||||
|
|
||||||
|
if (len <= 0 || offset + len > size)
|
||||||
|
goto bad_first_access_parameter;
|
||||||
|
|
||||||
|
subbuf = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, offset, len);
|
||||||
|
GST_BUFFER_DTS (subbuf) = GST_CLOCK_TIME_NONE;
|
||||||
|
GST_BUFFER_PTS (subbuf) = GST_CLOCK_TIME_NONE;
|
||||||
|
ret = ac3parse->baseparse_chainfunc (pad, parent, subbuf);
|
||||||
|
if (ret != GST_FLOW_OK) {
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offset += len;
|
||||||
|
len = size - offset;
|
||||||
|
|
||||||
|
if (len > 0) {
|
||||||
|
subbuf = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, offset, len);
|
||||||
|
GST_BUFFER_PTS (subbuf) = GST_BUFFER_PTS (buf);
|
||||||
|
GST_BUFFER_DTS (subbuf) = GST_BUFFER_DTS (buf);
|
||||||
|
|
||||||
|
ret = ac3parse->baseparse_chainfunc (pad, parent, subbuf);
|
||||||
|
}
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
} else {
|
||||||
|
/* first_access = 0 or 1, so if there's a timestamp it applies to the first byte */
|
||||||
|
subbuf =
|
||||||
|
gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, offset,
|
||||||
|
size - offset);
|
||||||
|
GST_BUFFER_PTS (subbuf) = GST_BUFFER_PTS (buf);
|
||||||
|
GST_BUFFER_DTS (subbuf) = GST_BUFFER_DTS (buf);
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
ret = ac3parse->baseparse_chainfunc (pad, parent, subbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
not_enough_data:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (GST_ELEMENT (ac3parse), STREAM, FORMAT, (NULL),
|
||||||
|
("Insufficient data in buffer. Can't determine first_acess"));
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
|
bad_first_access_parameter:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (GST_ELEMENT (ac3parse), STREAM, FORMAT, (NULL),
|
||||||
|
("Bad first_access parameter (%d) in buffer", first_access));
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue