After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 635734 - jpegdec: infinite loop when playing back motion jpeg stream
jpegdec: infinite loop when playing back motion jpeg stream
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Windows
: Normal normal
: 0.10.27
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-11-24 23:29 UTC by David Hoyt
Modified: 2010-12-06 18:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Captured stream (560.98 KB, application/octet-stream)
2010-11-24 23:41 UTC, David Hoyt
  Details
The bad frame (7.13 KB, image/jpeg)
2010-11-24 23:42 UTC, David Hoyt
  Details
Fixes the issue (555 bytes, patch)
2010-11-30 21:40 UTC, David Hoyt
none Details | Review

Description David Hoyt 2010-11-24 23:29:47 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
Comment 1 David Hoyt 2010-11-24 23:39:00 UTC
After examining the file a bit more, the 3rd frame seems to be cut off and is therefore missing the EOI marker.
Comment 2 David Hoyt 2010-11-24 23:41:29 UTC
Created attachment 175210 [details]
Captured stream
Comment 3 David Hoyt 2010-11-24 23:42:25 UTC
Created attachment 175211 [details]
The bad frame
Comment 4 David Hoyt 2010-11-30 21:40:56 UTC
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.
Comment 5 David Hoyt 2010-11-30 21:52:57 UTC
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.
Comment 6 Mark Nauwelaerts 2010-12-06 18:15:54 UTC
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).
Comment 7 Mark Nauwelaerts 2010-12-06 18:26:31 UTC
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