JPEG vs MJPG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



FYI, thanks to Trent Piepho's note on JFIF using the Y'PbPr colorspace,
not the Bt848's Y'CbCr, I've done some digging to find out what MJPG
(AVI motion JPEG uses)...

The bottom line is that it (MJPG) uses Y'CbCr.

The details are:

The Microsoft JPEG DIB specification, which appplies to both JPEG and
MJPG, specifies an extended BITMAPINFOHEADER (which is stored in the AVI
<strf> chunk) for JPEG, which includes:

1) JPEGColorSpaceID  1=Y,2=CCIR 601 YCbCr,3=RGB
2) JPEGBitsPerSample 8/10
3) JPEGHSubSampling  1/2/4
4) JPEGVSubSampling  1/2/4

The Microsoft spec. says that all MJEG AVIs will use JPEGColorSpaceID=2
(Y'CbCr). The other JPEGColorSpaceID values are applicable to Microsoft
JPEG DIBs.

The other (nice to have a choice, isn't it?) MJPG specification, part of
the OpenDML extended AVI specification, references Microsoft's
specification, and says that OpenDML MJPG will always use 8 bit 4:2:2
(i.e. H/VSubSampling = 2) Y'CbCr.

Both the Microsft and OpenDML specifications, thankfully, say that MJPG
should save space in the individual JPEG frames by using use an implicit
(which they specify) DHT (huffman table) segment.

It therefore appears the rules for encoding/decoding AVI MJPG are:

1) If the <strf> chunk BITMAPINFOHEADER is NOT extended, then assume 8
bit 4:2:2 YCbCr
2) If an extended BITMAPINFOHEADER is present, then use Microsft's
definition, which will still be YCbCr, but may specify different bpp and
H/V sub-sampling.
3) Always use the implicit huffman table, rather than assuming it to be
present.

I've had the buz tools lavplay fail to play MJPG AVI's complaining about
a missing huffman table, so I'm guessing that (some at least) hardware
MJPG compressors include it. If lavplay wants to be able to play
software generated MJPG AVI's (e.g. from xawtv), then it should assume
the implicit table if one is not present.

Finally, for normal JPEG files (as opposed to MJPG AVI's or Microsoft's
JPEG DIBs), the JFIF (Y'PbPr) format applies, and you will need to
convert from bttv/Bt848's Y'CbCr to get correct colors.

I hope this is useful to someone (other than myself)!

Ben





[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux