I have analysed the JPEG files furthers. It turns out the ffmpeg MJPEG encoder uses very odd sampling factors. A YUV444p image saved by Gimp uses sampling factors 1/1, 1/1, 1/1 for each component where ffmpeg uses 1/2,1/2,1/2. I have looked into the source of ffmpeg and it seems this odd behaviour is caused by how ffmpeg works with planar images. Worse, it will be very hard to fix ffmpeg. All in all the conclusion is that the MJPEG files created by ffmpeg are not compatible with the iMX8MQ hardware decoder except when using YUV420p.