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 664792 - Staircase effect in M-JPEG over RTP with unaligned image dimensions..
Staircase effect in M-JPEG over RTP with unaligned image dimensions..
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other All
: Normal normal
: 0.10.31
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-11-25 10:05 UTC by Sebastian Rasmussen
Modified: 2011-12-05 09:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed fix ceiling image dimensions instead of flooring them. (1.84 KB, patch)
2011-11-25 10:05 UTC, Sebastian Rasmussen
committed Details | Review

Description Sebastian Rasmussen 2011-11-25 10:05:21 UTC
Created attachment 202117 [details] [review]
Proposed fix ceiling image dimensions instead of flooring them.

When M-JPEG images are streamed over RTP they may get a staircase effect if their dimensions are not a multiple of 8. E.g. if the width of an image is 450 pixels then it has to be either floored to 448 or ceiled to 456 in order for its width to be expressed properly in an RFC2435 JPEG over RTP header.

The current rtpjpegpay element floors the dimensions before writing the image dimensions into the RFC2435 header. Unfortunately if an image of 450 pixels is being transmitted, then it actually contains image data for 456 pixels, but the flooring in the RFC2435 header states that the width is 448 pixels. This is what causes the staircase effect mentioned above.

In order to fix this rtpjpegpay should of course round up to the nearest multiple of 8. Doing so should always be safe since JPEG image data is expressed in 8x8 pixel (or larger) MCUs.

Unfortunately I can not provide a pipeline testcase that exhibits this behaviour that I am able to share with you, so I need to appeal to your insights about the RTP and JPEG specifications and hope that you can identify the same bug as I do. And hopefully you are also of the opinion that my fix is sane.

 / Sebastian
Comment 1 Sebastian Rasmussen 2011-11-30 13:31:53 UTC
This testcase exhibits the staircase effect that I manage to get rid of using the attached patch:

hostname$ gst-launch-0.10 -e videotestsrc ! video/x-raw-yuv,width=450,hight=800,framerate=1/1 ! jpegenc ! rtpjpegpay ! rtpjpegdepay ! jpegdec ! autovideosink
Comment 2 Sebastian Dröge (slomo) 2011-12-05 09:49:08 UTC
commit c090201ca59f4d16df8af7390472b5eebfa86cab
Author: Sebastian Rasmussen <sebrn@axis.com>
Date:   Thu Nov 24 13:58:01 2011 +0100

    rtpjpegpay: Ceil jpeg dimensions, instead of floor
    
    A JPEG image inside an RTP stream has a preceeding RFC2435 header that
    conveys width/height. The dimensions in this header are limited to be
    multiples of 8. Since JPEG uses an MCU of 8x8 pixels any image must
    already indirectly have image data dimensions that are rounded up in
    order to contain enough data to render the image. Therefore this fix
    safely rounds the image dimensions in the RFC2435 header up to the
    closest multiple of 8.