VLC encoding in any compressed format makes it almost impossible to recover and it is even theoretical impossible to recover.
However, most file formats take due care about this. So if you are reading JPEG files - a typical .jpg in JFIF format - it is practically very easy.
Basically, there are many markers that are placed in the stream which forms the segments of individual runs in these file which are independently identifiable. The VLC encoding of one segment is independent from the other segment - so if you find that a particular section of bytes broken, you can simply give up on the VLC decoding for that segment and search for the next segment marker. Typically the same concept is used to make MPEG compressed video to allow skipping in the case of streaming error.
For JPEG's JFIF format, there are following markers which helps achieve the above:
a. SOS n (Start of scan) markers b. SOF (Start of frame) markers c. RST n (Restart) markers
See references for more information:
- The JFIF file format - http://www.w3.org/Graphics/JPEG/jfif3.pdf
- FileFormat.Info - http://www.fileformat.info/format/jpeg/egff.htm or
- Book Compressed image file formats: JPEG, PNG, GIF, XBM, BMP by John Miano