[libcamera-devel] qcam: Corrupt JPEG data

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri Sep 2 00:34:56 CEST 2022


Hi Christian,

On Thu, Sep 01, 2022 at 11:44:24PM +0200, Christian Rauch via libcamera-devel wrote:
> Am 01.09.22 um 07:40 schrieb Laurent Pinchart:
> > On Wed, Aug 31, 2022 at 11:13:50PM +0200, Christian Rauch via libcamera-devel wrote:
> >> Hi,
> >>
> >> I have a "Logitech, Inc. Webcam C270" (046d:0825) USB wecam that causes
> >> an MJPEG related error message in qcam of the form: "Corrupt JPEG data:
> >> XX extraneous bytes before marker 0xXX". I don't see obvious issues with
> >> the resulting (decoded) image.
> >
> > How often does this occur ? Do you see the message for every frame, or
> > once in a while ?
> 
> I see this every 2~4 frame.
> 
> >> I don't have this issue with other cameras on MJPEG mode or in "cam". I,
> >
> > "cam" doesn't attempt to decompress JPEG images, so you won't see the
> > rror there indeed.
> >
> >> however, have this same issue in my own code where I decode the jpeg
> >> payload via OpenCV imdecode.
> >
> >> The error message originates from "libjpeg-turbo":
> >> https://github.com/libjpeg-turbo/libjpeg-turbo/blob/2.1.4/jerror.h#L192-L193
> >>
> >> Is this a:
> >> a) hardware issue
> >> b) libcamera issue
> >> c) libjpeg-turbo issue
> >> d) all of the above :-)
> >
> > Could you share one JPEG frame that triggers the issue ?
> 
> I attached a 160x120 jpeg ("img.jpg") that I dumped from within "qcam"
> via the "src->data(0).data()" in "FormatConverter::convert".
> 
> Running
>   python3 -c "import cv2; cv2.imread('img.jpg')"
> on this give me
>   Corrupt JPEG data: 2 extraneous bytes before marker 0xd4

I'm no expert here, but there are only two 0xd4 markers (RST4, coded as
FF D4) in the file, and if I delete two bytes before any of them, the
cv2.imread() call prints

Corrupt JPEG data: 2 extraneous bytes before marker 0xd4

This probably requires further investigation within libjpeg-turbo to
figure out what is happening. The message is printed by the Qt JPEG
image reader, and there's no option in Qt to prevent that. If it's
indeed an error in the input data (it seems to be a harmless one as the
image can be decoded), then the only option to suppress the message
would be to decode the JPEG data manually in qcam to have full control
over the warning messages. If it's a bug in libjpeg-turbo, it should be
fixed there.

If this is due to corrupt data, there's a drawback in suppressing the
message : the same warning may indicate a real problem with other
devices, and not outputting any message may thus prevent the user from
getting useful information.

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list