mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-04 15:19:57 +00:00
jpegparse: discard incomplete image
... as determined when finding SOI next image before an EOI.
This commit is contained in:
parent
0a26e138dd
commit
49d7f207cb
1 changed files with 17 additions and 5 deletions
|
@ -289,9 +289,10 @@ gst_jpeg_parse_parse_tag_has_entropy_segment (guint8 tag)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* returns image length in bytes if parsed
|
||||
* successfully, otherwise 0 if not enough data */
|
||||
static guint
|
||||
/* returns image length in bytes if parsed successfully,
|
||||
* otherwise 0 if more data needed,
|
||||
* if < 0 the absolute value needs to be flushed */
|
||||
static gint
|
||||
gst_jpeg_parse_get_image_length (GstJpegParse * parse)
|
||||
{
|
||||
guint size;
|
||||
|
@ -353,6 +354,13 @@ gst_jpeg_parse_get_image_length (GstJpegParse * parse)
|
|||
parse->priv->last_resync = FALSE;
|
||||
parse->priv->last_offset = 0;
|
||||
return (offset + 4);
|
||||
} else if (value == 0xd8) {
|
||||
/* Skip this frame if we found another SOI marker */
|
||||
GST_DEBUG ("0x%08x: SOI marker before EOI, skipping", offset + 2);
|
||||
/* clear parse state */
|
||||
parse->priv->last_resync = FALSE;
|
||||
parse->priv->last_offset = 0;
|
||||
return -(offset + 2);
|
||||
}
|
||||
|
||||
if (value >= 0xd0 && value <= 0xd7)
|
||||
|
@ -846,7 +854,7 @@ static GstFlowReturn
|
|||
gst_jpeg_parse_chain (GstPad * pad, GstBuffer * buf)
|
||||
{
|
||||
GstJpegParse *parse;
|
||||
guint len;
|
||||
gint len;
|
||||
GstClockTime timestamp, duration;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
|
@ -865,8 +873,12 @@ gst_jpeg_parse_chain (GstPad * pad, GstBuffer * buf)
|
|||
|
||||
/* check if we already have a EOI */
|
||||
len = gst_jpeg_parse_get_image_length (parse);
|
||||
if (len == 0)
|
||||
if (len == 0) {
|
||||
return GST_FLOW_OK;
|
||||
} else if (len < 0) {
|
||||
gst_adapter_flush (parse->priv->adapter, -len);
|
||||
continue;
|
||||
}
|
||||
|
||||
GST_LOG_OBJECT (parse, "parsed image of size %d", len);
|
||||
|
||||
|
|
Loading…
Reference in a new issue