[FFmpeg-devel] mjpegenc: wrong chrominance sampling values written to SOF header for YUVJ422P?

Andrey Utkin andrey.krieger.utkin at gmail.com
Sat Dec 14 03:03:55 CET 2013

In RFC 2435 (JPEG RTP) section 4.1 there is a table which defines
"types" 0 and 1 for pixel formats. (You can look at it at
rtpenc_jpeg.c sets type=0 if pixel format is yuvj422p, and 1 if yuvj420p.

Actually the issue is not related to RTP, just JPEG RTP RFC is one of
my info sources on this issue, because the issue has raised while i
have been working on JPEG RTP payloader for VLC.
The issue is probably mjpegenc.c.

For yuvj420p everything is ok - in mjpegenc.c output in SOF section
the components Y, Cb, Cr have such sampling factor values: 0x22, 0x11,
0x11 (first half-byte is for horizontal, second is for vertical).
But for yuvj422p mjpegenc.c outputs sampling factors 0x22, 0x12, 0x12.
By the table from RFC, there should be values 0x21, 0x11, 0x11. Also
looking at GStreamer JPEG RTP payloader, it expects the same values -
0x21, 0x11, 0x11 in such case.
Looking at gstreamer jpeg encoder, i see some division operations under comment
"maximum is invariant, as one of the components should have samp 1".
As far as i understand, there we need to divide all vertival sampling
factors so that we have at least one of them equal to 1. Is that

Andrey Utkin

More information about the ffmpeg-devel mailing list