For JPX decoding only read next packet after checking for byte aligning.

This patch makes the image from #5349 appear correctly, the artefacts
for the last packet are fixed in #5426.
This patch also optimizes some "in-checks" and adds a few header parsings.
Merge pull request #5350 from CodingFabian/issue-5349

For JPX decoding only read next packet after checking for byte aligning.