jpegparse: discard incomplete image
... as determined when finding SOI next image before an EOI.
This commit is contained in:
parent
0a26e138dd
commit
49d7f207cb
@ -289,9 +289,10 @@ gst_jpeg_parse_parse_tag_has_entropy_segment (guint8 tag)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns image length in bytes if parsed
|
/* returns image length in bytes if parsed successfully,
|
||||||
* successfully, otherwise 0 if not enough data */
|
* otherwise 0 if more data needed,
|
||||||
static guint
|
* if < 0 the absolute value needs to be flushed */
|
||||||
|
static gint
|
||||||
gst_jpeg_parse_get_image_length (GstJpegParse * parse)
|
gst_jpeg_parse_get_image_length (GstJpegParse * parse)
|
||||||
{
|
{
|
||||||
guint size;
|
guint size;
|
||||||
@ -353,6 +354,13 @@ gst_jpeg_parse_get_image_length (GstJpegParse * parse)
|
|||||||
parse->priv->last_resync = FALSE;
|
parse->priv->last_resync = FALSE;
|
||||||
parse->priv->last_offset = 0;
|
parse->priv->last_offset = 0;
|
||||||
return (offset + 4);
|
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)
|
if (value >= 0xd0 && value <= 0xd7)
|
||||||
@ -846,7 +854,7 @@ static GstFlowReturn
|
|||||||
gst_jpeg_parse_chain (GstPad * pad, GstBuffer * buf)
|
gst_jpeg_parse_chain (GstPad * pad, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstJpegParse *parse;
|
GstJpegParse *parse;
|
||||||
guint len;
|
gint len;
|
||||||
GstClockTime timestamp, duration;
|
GstClockTime timestamp, duration;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
|
|
||||||
@ -865,8 +873,12 @@ gst_jpeg_parse_chain (GstPad * pad, GstBuffer * buf)
|
|||||||
|
|
||||||
/* check if we already have a EOI */
|
/* check if we already have a EOI */
|
||||||
len = gst_jpeg_parse_get_image_length (parse);
|
len = gst_jpeg_parse_get_image_length (parse);
|
||||||
if (len == 0)
|
if (len == 0) {
|
||||||
return GST_FLOW_OK;
|
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);
|
GST_LOG_OBJECT (parse, "parsed image of size %d", len);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user