mjpeg: Split off bits shared by MJPEG and LJPEG encoders

This obviates a dependency of the LJPEG encoder on mpegvideo.