mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 19:42:26 +00:00
baseparse: maintain frame state during frame parsing round
See #650093.
This commit is contained in:
parent
af5061e943
commit
35567592ef
1 changed files with 28 additions and 5 deletions
|
@ -311,6 +311,9 @@ struct _GstBaseParsePrivate
|
||||||
|
|
||||||
/* Segment event that closes the running segment prior to SEEK */
|
/* Segment event that closes the running segment prior to SEEK */
|
||||||
GstEvent *close_segment;
|
GstEvent *close_segment;
|
||||||
|
|
||||||
|
/* push mode helper frame */
|
||||||
|
GstBaseParseFrame frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _GstBaseParseSeek
|
typedef struct _GstBaseParseSeek
|
||||||
|
@ -571,8 +574,11 @@ gst_base_parse_frame_free (GstBaseParseFrame * frame)
|
||||||
frame->buffer = NULL;
|
frame->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(frame->_private_flags & GST_BASE_PARSE_FRAME_PRIVATE_FLAG_NOALLOC))
|
if (!(frame->_private_flags & GST_BASE_PARSE_FRAME_PRIVATE_FLAG_NOALLOC)) {
|
||||||
g_slice_free (GstBaseParseFrame, frame);
|
g_slice_free (GstBaseParseFrame, frame);
|
||||||
|
} else {
|
||||||
|
memset (frame, 0, sizeof (*frame));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GType
|
GType
|
||||||
|
@ -725,6 +731,11 @@ gst_base_parse_reset (GstBaseParse * parse)
|
||||||
g_slist_foreach (parse->priv->pending_seeks, (GFunc) g_free, NULL);
|
g_slist_foreach (parse->priv->pending_seeks, (GFunc) g_free, NULL);
|
||||||
g_slist_free (parse->priv->pending_seeks);
|
g_slist_free (parse->priv->pending_seeks);
|
||||||
parse->priv->pending_seeks = NULL;
|
parse->priv->pending_seeks = NULL;
|
||||||
|
|
||||||
|
/* we know it is not alloc'ed, but maybe other stuff to free, some day ... */
|
||||||
|
parse->priv->frame._private_flags |=
|
||||||
|
GST_BASE_PARSE_FRAME_PRIVATE_FLAG_NOALLOC;
|
||||||
|
gst_base_parse_frame_free (&parse->priv->frame);
|
||||||
GST_OBJECT_UNLOCK (parse);
|
GST_OBJECT_UNLOCK (parse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1028,6 +1039,9 @@ gst_base_parse_sink_eventfunc (GstBaseParse * parse, GstEvent * event)
|
||||||
parse->priv->flushing = FALSE;
|
parse->priv->flushing = FALSE;
|
||||||
parse->priv->discont = TRUE;
|
parse->priv->discont = TRUE;
|
||||||
parse->priv->last_ts = GST_CLOCK_TIME_NONE;
|
parse->priv->last_ts = GST_CLOCK_TIME_NONE;
|
||||||
|
parse->priv->frame._private_flags |=
|
||||||
|
GST_BASE_PARSE_FRAME_PRIVATE_FLAG_NOALLOC;
|
||||||
|
gst_base_parse_frame_free (&parse->priv->frame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GST_EVENT_EOS:
|
case GST_EVENT_EOS:
|
||||||
|
@ -2162,19 +2176,17 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
const guint8 *data;
|
const guint8 *data;
|
||||||
guint old_min_size = 0, min_size, av;
|
guint old_min_size = 0, min_size, av;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
GstBaseParseFrame _frame;
|
|
||||||
GstBaseParseFrame *frame;
|
GstBaseParseFrame *frame;
|
||||||
|
|
||||||
parse = GST_BASE_PARSE (GST_OBJECT_PARENT (pad));
|
parse = GST_BASE_PARSE (GST_OBJECT_PARENT (pad));
|
||||||
bclass = GST_BASE_PARSE_GET_CLASS (parse);
|
bclass = GST_BASE_PARSE_GET_CLASS (parse);
|
||||||
frame = &_frame;
|
frame = &parse->priv->frame;
|
||||||
|
|
||||||
gst_base_parse_frame_init (frame);
|
|
||||||
|
|
||||||
if (G_LIKELY (buffer)) {
|
if (G_LIKELY (buffer)) {
|
||||||
GST_LOG_OBJECT (parse, "buffer size: %d, offset = %" G_GINT64_FORMAT,
|
GST_LOG_OBJECT (parse, "buffer size: %d, offset = %" G_GINT64_FORMAT,
|
||||||
GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer));
|
GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer));
|
||||||
if (G_UNLIKELY (parse->priv->passthrough)) {
|
if (G_UNLIKELY (parse->priv->passthrough)) {
|
||||||
|
gst_base_parse_frame_init (frame);
|
||||||
frame->buffer = gst_buffer_make_metadata_writable (buffer);
|
frame->buffer = gst_buffer_make_metadata_writable (buffer);
|
||||||
return gst_base_parse_push_frame (parse, frame);
|
return gst_base_parse_push_frame (parse, frame);
|
||||||
}
|
}
|
||||||
|
@ -2191,11 +2203,22 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
gst_adapter_push (parse->priv->adapter, buffer);
|
gst_adapter_push (parse->priv->adapter, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (G_UNLIKELY (buffer &&
|
||||||
|
GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))) {
|
||||||
|
frame->_private_flags |= GST_BASE_PARSE_FRAME_PRIVATE_FLAG_NOALLOC;
|
||||||
|
gst_base_parse_frame_free (frame);
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse and push as many frames as possible */
|
/* Parse and push as many frames as possible */
|
||||||
/* Stop either when adapter is empty or we are flushing */
|
/* Stop either when adapter is empty or we are flushing */
|
||||||
while (!parse->priv->flushing) {
|
while (!parse->priv->flushing) {
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
|
/* maintain frame state for a single frame parsing round across _chain calls,
|
||||||
|
* so only init when needed */
|
||||||
|
if (!frame->_private_flags)
|
||||||
|
gst_base_parse_frame_init (frame);
|
||||||
|
|
||||||
tmpbuf = gst_buffer_new ();
|
tmpbuf = gst_buffer_new ();
|
||||||
|
|
||||||
old_min_size = 0;
|
old_min_size = 0;
|
||||||
|
|
Loading…
Reference in a new issue