Example #1
0
/* Return when an SOI, EOI, SOFn, or SOS is found */
PUBLIC JPEG_MARKER_E ProcessTables(JPEG_DEC_INPUT_PARA_T  *jpeg_dec_input)
{
	uint32 c = 0;

	while (TRUE)/*lint !e716*/
	{
		if(!GetNextMarker(&c))
		{
			return M_ERROR;
		}

		switch (c) 
		{
			case M_SOF0:
			case M_SOF1:
				if(GetSOF(FALSE, jpeg_dec_input) != JPEG_SUCCESS)
				{
					return M_ERROR;
				}
				break;
			case M_SOF2:
				if(GetSOF(TRUE, jpeg_dec_input) != JPEG_SUCCESS)
				{
					return M_ERROR;
				}
				JPEG_TRACE("Sorry, we can not support the Progressive image!\n");
				break;
				//return M_ERROR;
			case M_SOI:
			case M_EOI:
			case M_SOS:
				return c;

			case M_DHT:
				if(GetHuffTbl() != JPEG_SUCCESS)
				{
					return M_ERROR;
				}
				break;

			case M_DQT:
				if(GetQuantTbl() != JPEG_SUCCESS)
				{
					return M_ERROR;
				}
				break;

			case M_APP0:
				if(GetAPP0() != JPEG_SUCCESS)
				{
					return M_ERROR;
				}
				break;

			case M_DRI:
				if(GetDRI() != JPEG_SUCCESS)
				{
					return M_ERROR;
				}
				break;

		//	case M_SOF1:
			case M_SOF3:
			case M_SOF5:
			case M_SOF6:
			case M_SOF7:
			case M_JPG:
			case M_SOF9:
			case M_SOF10:
			case M_SOF11:
			case M_SOF13:
			case M_SOF14:
			case M_SOF15:
			case M_DAC:
			case M_RST0:
			case M_RST1:
			case M_RST2:
			case M_RST3:
			case M_RST4:
			case M_RST5:
			case M_RST6:
			case M_RST7:
			case M_TEM:
	 			JPEG_TRACE("Unexpected marker 0x%02x\n", c);
				return M_ERROR;

			default:	/* must be DNL, DHP, EXP, APPn, JPGn, COM, or RESn */
				if(SkipVariable(jpeg_dec_input) != JPEG_SUCCESS)
				{
					return M_ERROR;
				}
				break;
		}
	}
}
Example #2
0
/*
 *--------------------------------------------------------------
 *
 * ProcessTables --
 *
 *        Scan and process JPEG markers that can appear in any order
 *        Return when an SOI, EOI, SOFn, or SOS is found
 *
 * Results:
 *        The marker found.
 *
 * Side effects:
 *        Bitstream is parsed.
 *
 *--------------------------------------------------------------
 */
static JpegMarker ProcessTables (DecompressInfo *dcPtr)
{
  int c;

    while (1) {
        c = NextMarker ();

        switch (c) {
        case M_SOF0:
        case M_SOF1:
        case M_SOF2:
        case M_SOF3:
        case M_SOF5:
        case M_SOF6:
        case M_SOF7:
        case M_JPG:
        case M_SOF9:
        case M_SOF10:
        case M_SOF11:
        case M_SOF13:
        case M_SOF14:
        case M_SOF15:
        case M_SOI:
        case M_EOI:
        case M_SOS:
            return ((JpegMarker)c);

        case M_DHT:
            GetDht (dcPtr); if (dcPtr->error) return 0;
            break;

        case M_DQT:
            fprintf(stderr,"Not a lossless JPEG file.\n");
            break;

        case M_DRI:
            GetDri (dcPtr); if (dcPtr->error) return 0;
            break;

        case M_APP0:
            GetApp0 (dcPtr);
            break;

        case M_RST0:                /* these are all parameterless */
        case M_RST1:
        case M_RST2:
        case M_RST3:
        case M_RST4:
        case M_RST5:
        case M_RST6:
        case M_RST7:
        case M_TEM:
            fprintf (stderr, "Warning: unexpected marker 0x%02x\n", c);
            break;

        default:                /* must be DNL, DHP, EXP, APPn, JPGn, COM,
                                 * or RESn */
            SkipVariable (dcPtr);
            break;
        }
    }
}/*endof ProcessTables */