GNOME Bugzilla – Bug 635734
jpegdec: infinite loop when playing back motion jpeg stream
Last modified: 2010-12-06 18:26:31 UTC
When playing back a simple multipart motion jpeg stream coming from a publicly available camera, after a time my cpu usage spikes and it enters what seems like an infinite loop in gst_jpeg_dec_parse_image_data(). I captured a suspect stream (using souphttpsrc and filesink) and removed most of the frames (to decrease file size). The loop happens when the second frame in the file is decoded (just search for the second "--myboundary" marker to see where it begins). Removing the 2nd and 3rd frames allows the file to play normally. I'm using the following pipeline to play it back: gst-launch filesrc location=test.mjpg ! multipartdemux ! jpegdec ! ffmpegcolorspace ! videorate ! video/x-raw-yuv,framerate=1/1 ! autovideosink
After examining the file a bit more, the 3rd frame seems to be cut off and is therefore missing the EOI marker.
Created attachment 175210 [details] Captured stream
Created attachment 175211 [details] The bad frame
Created attachment 175581 [details] [review] Fixes the issue The attached patch resolved the issue for me by flushing the adapter and essentially skipping the corrupt frame. Worked on stills and motion jpeg streams.
This is probably applicable to jpegparse as well, although I have not tested against it except to say that using jpegparse resulted in the same problem described originally. It's probable that this patch will fix the issue in jpegparse as well.
Thanks. Following should take care (including a slightly modified version of patch). commit 04fae48d1da38e41f9b65f4a91de89f538a1775f Author: Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> Date: Mon Dec 6 18:16:19 2010 +0100 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. commit c50695c14b0856d0cd2573a0b9a0c0f40a6d8270 Author: Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> Date: Mon Dec 6 17:45:38 2010 +0100 jpegdec: avoid infinite loop when resyncing Fixes #635734 (partly).
Btw, and FWIW, similar fixes have been done for jpegparse (in -bad): commit a4538365b4de78e6df456bd856be75616a617bb0 Author: Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> Date: Mon Dec 6 18:19:20 2010 +0100 jpegparse: discard incomplete image ... as determined when finding SOI next image before an EOI. commit e25be1595aeb82db7a810ba0313c802faa52e71f Author: Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> Date: Mon Dec 6 18:18:11 2010 +0100 jpegparse: avoid infinite loop when resyncing