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

3
  • probably you should update your question/email me with the code!
    – kzidane
    Apr 9, 2015 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, 2015 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. Apr 22, 2015 at 16:47

1 Answer 1

0

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

2
  • 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, 2015 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. Aug 15, 2015 at 9:36

You must log in to answer this question.

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