예제 #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;
		}
	}
}
예제 #2
0
int ieJpegDecoder::ParseTables()
//
// Scan and process JPEG markers that can appear in any order
// Return when an SOI, EOI, SOFn, or SOS is found
//
{
	for (;;) {

		int c = GetMarker();		
		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 c;

		case M_DHT:
			if (!GetDHT()) return M_ERROR;
			break;

		case M_DAC:
			if (!GetDAC()) return M_ERROR;
			break;

		case M_DQT:
			if (!GetDQT()) return M_ERROR;
			break;

		case M_DRI:
			if (!GetDRI()) return M_ERROR;
			break;

		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:
			break;

		case M_APP14:
			if (!GetAPP14()) return M_ERROR;
			break;

		case M_APP0:
		case M_APP1:
		case M_APP2:
		case M_APP3:
		case M_APP4:
		case M_APP5:
		case M_APP6:
		case M_APP7:
		case M_APP8:
		case M_APP9:
		case M_APP10:
		case M_APP11:
		case M_APP12:
		case M_APP13:
		case M_APP15:
		case M_COM:
		case M_DNL:			// Ignore DNL ... perhaps the wrong thing
			pbStream += (GetWord() - 2);
			break;

		default:			// Must be DHP, EXP, JPGn, or RESn
			// For now, we treat the reserved markers as fatal errors since they are
			// likely to be used to signal incompatible JPEG Part 3 extensions.
			return M_ERROR;
		}
	}
}