[libcamera-devel] JPEG support for libcamera

Pavel Machek pavel at ucw.cz
Tue Jul 12 22:40:44 CEST 2022


Hi!

> > > Best explanation I found so far was that JPEG = EXIF + MJPEG. Kernel
> > > interface exposes JPEG and MJPEG as separate types, so IMO it makes
> > > sense for libcamera to support both.
> > 
> > TBH JPEG at least has a specification. MJPEG largely doesn't - it's
> > just a concatenation of JPEG encoded frames, and there seems to be no
> > real definition of which JPEG blocks are required and in which order.
> > Some MJPEG encoders drop the Huffman tables and rely on the decoder
> > assuming defaults.
> > There are then also MJPEG-A and MJPEG-B variants defined by Apple as
> > part of the Quicktime spec [1], with MJPEG-B not being compatible with
> > JPEG decoders due to changing headers.
> > 
> > Which flavour V4L2_PIX_FMT_MJPEG relates to seems to be undefined.
> > 
> > I've had issues in the past with what conditions VLC judges to be JPEG
> > vs MJPEG, and never found a definitive answer [2]
> > 
> > So how Libcamera should handle JPEG vs MJPEG probably doesn't have an
> > obvious answer. There's little point in encoding EXIF in a hardware
> > encoder as you have the overhead of passing all the parameters in.
> > For mapping into V4L2, just treat both of them the same.
> 
> Older C920 could be setup to produce jpeg, which embeds H.264 into the EXIF
> header. You'll find support for that in GStreamer [0]. Probably not relevant to
> the discussion. In GStreamer v4l2src [1], all form of jpeg is assumed to be the
> same. Which made me notice that V4L2_PIX_FMT_PJPG not mentionned here. I have no
> idea what this refer too, this special case [1] dates from before me. I think
> kernel driver encoders today will in software append the missing table/headers
> as needed.

PJPG is "progressive jpeg", AFAICT, see here:
https://cloudinary.com/blog/progressive_jpegs_and_green_martians . I
actually wishpinephone would produce that, as it would make previews
faster.

Best regards,
							Pavel
-- 
People of Russia, stop Putin before his war on Ukraine escalates.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20220712/50a8f0ef/attachment.sig>


More information about the libcamera-devel mailing list