Terminator3
Advanced Member level 3
- Joined
- Feb 25, 2012
- Messages
- 802
- Helped
- 71
- Reputation
- 142
- Reaction score
- 63
- Trophy points
- 1,308
- Activity points
- 9,027
Hello! I have device with erroneous JPEG stream, last MCU is filled with debug data of camera, so JPEG decoder algorithm throws an error. Sometimes debug data comes across 0xFFD9 marker (EOI = End of Image). And it can even provide fake marker, like progressive JPEG or something like that, or fake start of image, so it is obvious problem with the camera.
Is there any way to exactly know where is the last 8x8 unit inside the file? Currently overwriting last bytes of data by 0xFF (around 10 bytes) solves the problem, if there any more correct way, i want to ask how to do it.
For example, i want to overwrite last JPEG Minimum Coded Unit (MCU) with previous, but unsure how to do it.
Is there any way to exactly know where is the last 8x8 unit inside the file? Currently overwriting last bytes of data by 0xFF (around 10 bytes) solves the problem, if there any more correct way, i want to ask how to do it.
For example, i want to overwrite last JPEG Minimum Coded Unit (MCU) with previous, but unsure how to do it.