avcodec/mjpegdec: handle luma upscale detection generically

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/mjpegdec: factorize some parts of the pix_fmt_id switch()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>