0

My recover program is able to output all 16 jpg but the structure seems off as it states SOS before SOF. I'm guessing the issue might be with the fwrite function but I'm unable to figure it out. I'm attaching my pseudo-code but if the original is needed I'll mail it. Thanks!

open input file

declare title[8]

declare buffer of size BLOCK

initialize img
initialise counter
open a new img file

while not EOF
{ read data into buffer

if (beginning of JPEG)
{
close previous output file if exists
open new output file
write to the file
update counter
}

else if (output file exists and is not null)

append the file which is open

else
continue
}
close remaining files

  • probably you should update your question/email me with the code! – Kareem Apr 9 '15 at 17:46
  • Are you sure you write the first 4 BYTES to EACH image? The loop seems to be a problem :-? – Hieu Do Apr 16 '15 at 17:53
  • I think I do, as soon as it detects the jpeg, I use fwrite(&buffer,512,1,img). The loop is exactly as I have mentioned above. – Akshat Malik Apr 22 '15 at 16:47
0

I was calling the 'fwrite' function twice and thus there was a mismanagement of the blocks resulting in the wrong jpg structure.

  • Could you elaborate on what you mean by this Akshat? I'm also getting all of the JPG's to output but in the wrong structure "SOS before SOF" and "missing SOS marker" and "unsupported marker type 0x6c". – user7591 Jul 11 '15 at 21:51
  • Check how many times you are using the fread and fwrite functions. Even if you are calling fread in a while loop, the block will be stored in the buffer and if you call fread again then a block would be skipped resulting in mismanagement. – Akshat Malik Aug 15 '15 at 9:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .