c - What does "ERROR interpreting JPEG image file( invalid JPEG file structure :SOS before SOF)" mean? -


i trying recover jpg's .raw file, when try , open ".jpg's" out put of program, gives error, or says weird hexadecimal , says unsupported marker type jpeg (but says jpg!). doing wrong?

     *  * recovers jpegs forensic image.  */   //0xff 0xd8 0xff 0xe0  //0xff 0xd8 0xff 0xe1  #define block 512 #define start1end 0xe0 #define start2end 0xe1  #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <stdint.h>   //sets begins or jpgs uint8_t checkjpg1[4] = {0xff, 0xd8, 0xff, 0xe0}; uint8_t checkjpg2[4] = {0xff, 0xd8, 0xff, 0xe1};  //making variables int found = 0;  char title[block]; file* img; int ifopen = 1;   int main(int argc, char* argv[]) {     //opening file     file* inptr = fopen("card.raw", "r");     //checking if file opening failed     if (inptr == null)     {         return 2;     }      //making buffer     unsigned char buffer[block];      //going through file     while(fread(&buffer,sizeof(char),block,inptr) == block)     {          //checking if begin == possible begin of jpg              if ((buffer[0] == checkjpg1[0] && buffer[1] == checkjpg1[1] && buffer[2] == checkjpg1[2]) &&           (buffer[3] == checkjpg1[3] || buffer[3] == checkjpg2[3]))          {             //if jpg not open             if (ifopen == 1)             {                 //make 1                 found+=1;                 sprintf(title,"00%d.jpg",found);                 img = fopen(title,"a");                 if(buffer[3] == checkjpg1[3])                 {                     fwrite(&checkjpg1,sizeof(char),4,img);                 }              }             else//else             {                 //end 1 , open new 1                 fclose(img);                 found +=1;                 sprintf(title,"00%d.jpg",found);                 img = fopen(title,"a");                 if(buffer[3] == checkjpg1[3])                 {                     fwrite(&checkjpg2,sizeof(char),4,img);                 }             }          }          else if (img != null)          {             fwrite(buffer,sizeof(char),block,img);          }      }      fclose(inptr); } 

the start of frame (sof) market defines structure of image. start of scan marker contains compressed image data. need know size of image (sof) in order expand compressed data (sos).

it sounds streams missing sof marker.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -