PUBLIC JPEG_RET_E ParseHead(JPEG_DEC_INPUT_PARA_T *jpeg_dec_input) { uint32 c = 0; /* Expect an SOI marker first */ while(1)/*lint !e716*/ { if ((!GetNextMarker(&c)) || (c == M_EOI) ) { JPEG_TRACE("[JPEG_HWParseHead] find the SOI marker error: %x", c); return JPEG_FAILED; } if(c == M_SOI) { break; } } /* Process markers until SOF */ c = ProcessTables(jpeg_dec_input); switch (c) { case M_ERROR: return JPEG_FAILED; case M_SOS: if(GetSOS() != JPEG_SUCCESS) { return JPEG_FAILED; } break; case M_EOI: return JPEG_FAILED; default: return JPEG_FAILED; } return JPEG_SUCCESS; }
/* *-------------------------------------------------------------- * * ReadFileHeader -- * * Initialize and read the file header (everything through * the SOF marker). * * Results: * None * * Side effects: * Exit on error. * *-------------------------------------------------------------- */ void ReadFileHeader (DecompressInfo *dcPtr) { int c, c2; /* * Demand an SOI marker at the start of the file --- otherwise it's * probably not a JPEG file at all. */ c = GetJpegChar(); c2 = GetJpegChar(); if ((c != 0xFF) || (c2 != M_SOI)) { if( c == EOF ) { fprintf(stderr, "Reached end of input file. All done!\n"); /* fclose(outFile); */ /* exit(1); */ dcPtr->error = -1; return; } else { fprintf (stderr, "Not a JPEG file. Found %02X %02X\n", c, c2); /* exit (1); */ dcPtr->error = -1; return; } }/*endif*/ GetSoi (dcPtr); if (dcPtr->error) return; /* OK, process SOI */ /* * Process markers until SOF */ c = ProcessTables (dcPtr); if (dcPtr->error) return; switch (c) { case M_SOF0: case M_SOF1: case M_SOF3: GetSof (dcPtr, c); break; default: fprintf (stderr, "Unsupported SOF marker type 0x%02x\n", c); break; } }/*endof ReadFileHeader*/
/* *-------------------------------------------------------------- * * ReadScanHeader -- * * Read the start of a scan (everything through the SOS marker). * * Results: * 1 if find SOS, 0 if find EOI * * Side effects: * Bitstream is parsed, may exit on errors. * *-------------------------------------------------------------- */ int ReadScanHeader (DecompressInfo *dcPtr) { int c; /* * Process markers until SOS or EOI */ c = ProcessTables (dcPtr); if (dcPtr->error) return 0; switch (c) { case M_SOS: GetSos (dcPtr); return 1; case M_EOI: return 0; default: fprintf (stderr, "Unexpected marker 0x%02x\n", c); break; } return 0; }/*endof ReadScanHeader*/