mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:06:17 +00:00
jpegdec: discard incomplete image
... as determined when finding SOI next image before an EOI. Based on patch by David Hoyt <david.hoyt@llnl.gov> Fixes #635734.
This commit is contained in:
parent
c50695c14b
commit
04fae48d1d
1 changed files with 19 additions and 5 deletions
|
@ -382,9 +382,10 @@ gst_jpeg_dec_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 */
|
* otherwise 0 if more data needed,
|
||||||
static guint
|
* if < 0 the absolute value needs to be flushed */
|
||||||
|
static gint
|
||||||
gst_jpeg_dec_parse_image_data (GstJpegDec * dec)
|
gst_jpeg_dec_parse_image_data (GstJpegDec * dec)
|
||||||
{
|
{
|
||||||
guint size;
|
guint size;
|
||||||
|
@ -445,8 +446,15 @@ gst_jpeg_dec_parse_image_data (GstJpegDec * dec)
|
||||||
dec->parse_resync = FALSE;
|
dec->parse_resync = FALSE;
|
||||||
dec->parse_offset = 0;
|
dec->parse_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);
|
||||||
|
dec->parse_resync = FALSE;
|
||||||
|
dec->parse_offset = 0;
|
||||||
|
return -(offset + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (value >= 0xd0 && value <= 0xd7)
|
if (value >= 0xd0 && value <= 0xd7)
|
||||||
frame_len = 0;
|
frame_len = 0;
|
||||||
else {
|
else {
|
||||||
|
@ -1149,7 +1157,8 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
|
||||||
#endif
|
#endif
|
||||||
guchar *outdata;
|
guchar *outdata;
|
||||||
guchar *base[3], *last[3];
|
guchar *base[3], *last[3];
|
||||||
guint img_len, outsize;
|
gint img_len;
|
||||||
|
guint outsize;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint r_h, r_v;
|
gint r_h, r_v;
|
||||||
guint code, hdr_ok;
|
guint code, hdr_ok;
|
||||||
|
@ -1187,6 +1196,7 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
|
||||||
goto need_more_data;
|
goto need_more_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
again:
|
||||||
if (!gst_jpeg_dec_ensure_header (dec))
|
if (!gst_jpeg_dec_ensure_header (dec))
|
||||||
goto need_more_data;
|
goto need_more_data;
|
||||||
|
|
||||||
|
@ -1201,8 +1211,12 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
|
||||||
* is not aligned to buffer boundaries */
|
* is not aligned to buffer boundaries */
|
||||||
img_len = gst_jpeg_dec_parse_image_data (dec);
|
img_len = gst_jpeg_dec_parse_image_data (dec);
|
||||||
|
|
||||||
if (img_len == 0)
|
if (img_len == 0) {
|
||||||
goto need_more_data;
|
goto need_more_data;
|
||||||
|
} else if (img_len < 0) {
|
||||||
|
gst_adapter_flush (dec->adapter, -img_len);
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dec->rem_img_len = img_len;
|
dec->rem_img_len = img_len;
|
||||||
|
|
Loading…
Reference in a new issue