return FALSE;
}
-/* returns image length in bytes if parsed
- * successfully, otherwise 0 */
-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_dec_parse_image_data (GstJpegDec * dec)
{
guint size;
dec->parse_resync = FALSE;
dec->parse_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);
+ dec->parse_resync = FALSE;
+ dec->parse_offset = 0;
+ return -(offset + 2);
}
+
if (value >= 0xd0 && value <= 0xd7)
frame_len = 0;
else {
#endif
guchar *outdata;
guchar *base[3], *last[3];
- guint img_len, outsize;
+ gint img_len;
+ guint outsize;
gint width, height;
gint r_h, r_v;
guint code, hdr_ok;
goto need_more_data;
}
+again:
if (!gst_jpeg_dec_ensure_header (dec))
goto need_more_data;
* is not aligned to buffer boundaries */
img_len = gst_jpeg_dec_parse_image_data (dec);
- if (img_len == 0)
+ if (img_len == 0) {
goto need_more_data;
+ } else if (img_len < 0) {
+ gst_adapter_flush (dec->adapter, -img_len);
+ goto again;
+ }
}
dec->rem_img_len = img_len;